@@ -19,6 +19,8 @@ A discrete time dynamical system that produces iterations over the Poincaré map
1919of the given continuous time `ds`. This map is defined as the sequence of points on the
2020Poincaré surface of section, which is defined by the `plane` argument.
2121
22+ Iterating `pmap` also mutates `ds` which is referrenced in `pmap`.
23+
2224See also [`StroboscopicMap`](@ref), [`poincaresos`](@ref).
2325
2426## Keyword arguments
@@ -67,8 +69,8 @@ and root finding from Roots.jl, to create a high accuracy estimate of the sectio
6769 surface of section. [`initial_time`](@ref) is always `0` and [`current_time`](@ref)
6870 is current iteration number.
69713. A new function [`current_crossing_time`](@ref) returns the real time corresponding
70- to the latest crossing of the hyperplane, which is what the [`current_state(ds)`](@ref)
71- corresponds to as well .
72+ to the latest crossing of the hyperplane. The corresponding state on the hyperplane
73+ is `current_state(pmap)` as expected .
72744. For the special case of `plane` being a `Tuple{Int, <:Real}`, a special `reinit!` method
7375 is allowed with input state of length `D-1` instead of `D`, i.e., a reduced state already
7476 on the hyperplane that is then converted into the `D` dimensional state.
@@ -95,7 +97,7 @@ mutable struct PoincareMap{I<:ContinuousTimeDynamicalSystem, F, P, R, V} <: Disc
9597 rootkw:: R
9698 state_on_plane:: V
9799 tcross:: Float64
98- t:: Base.RefValue{ Int}
100+ t:: Int
99101 # These two fields are for setting the state of the pmap from the plane
100102 # (i.e., given a D-1 dimensional state, create the full D-dimensional state)
101103 dummy:: Vector{Float64}
@@ -120,10 +122,10 @@ function PoincareMap(
120122 diffidxs = _indices_on_poincare_plane (plane, D)
121123 pmap = PoincareMap (
122124 ds, plane_distance, planecrossing, Tmax, rootkw,
123- v, current_time (ds), Ref ( 0 ) , dummy, diffidxs
125+ v, current_time (ds), 0 , dummy, diffidxs
124126 )
125127 step! (pmap)
126- pmap. t[] = 0 # first step is 0
128+ pmap. t = 0 # first step is 0
127129 return pmap
128130end
129131
@@ -143,7 +145,7 @@ for f in (:initial_state, :current_parameters, :initial_parameters, :referrenced
143145 @eval $ (f)(pmap:: PoincareMap , args... ) = $ (f)(pmap. ds, args... )
144146end
145147initial_time (pmap:: PoincareMap ) = 0
146- current_time (pmap:: PoincareMap ) = pmap. t[]
148+ current_time (pmap:: PoincareMap ) = pmap. t
147149current_state (pmap:: PoincareMap ) = pmap. state_on_plane
148150
149151"""
@@ -160,7 +162,7 @@ function SciMLBase.step!(pmap::PoincareMap)
160162 else
161163 pmap. state_on_plane = u # this is always a brand new vector
162164 pmap. tcross = t
163- pmap. t[] = pmap . t[] + 1
165+ pmap. t += 1
164166 return pmap
165167 end
166168end
@@ -169,7 +171,6 @@ SciMLBase.step!(pmap::PoincareMap, n::Int, s = true) = (for _ ∈ 1:n; step!(pma
169171function SciMLBase. reinit! (pmap:: PoincareMap , u0:: AbstractArray = initial_state (pmap);
170172 t0 = initial_time (pmap), p = current_parameters (pmap)
171173 )
172- isnothing (u0) && return pmap
173174 if length (u0) == dimension (pmap)
174175 u = u0
175176 elseif length (u0) == dimension (pmap) - 1
@@ -179,7 +180,7 @@ function SciMLBase.reinit!(pmap::PoincareMap, u0::AbstractArray = initial_state(
179180 end
180181 reinit! (pmap. ds, u; t0, p)
181182 step! (pmap) # always step once to reach the PSOS
182- pmap. t[] = 0 # first step is 0
183+ pmap. t = 0 # first step is 0
183184 pmap
184185end
185186
0 commit comments