Skip to content

Commit 6f02500

Browse files
authored
Enhance type flexibility for PoincareMap & Add a Bigfloat test (#239)
* Enhance type flexibility for PoincareMap and add a Bigfloat test for Poincaré mapping. * Remove `setprecision` and designate precision locally. * Increment the patch version from 3.15.1 to 3.15.2.
1 parent 5dfeb12 commit 6f02500

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicalSystemsBase"
22
uuid = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
33
repo = "https://github.com/JuliaDynamics/DynamicalSystemsBase.jl.git"
4-
version = "3.15.1"
4+
version = "3.15.2"
55

66
[deps]
77
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"

src/derived_systems/poincare/poincaremap.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ next_state_on_psos = current_state(pmap)
9595
Datseris & Parlitz 2022, _Nonlinear Dynamics: A Concise Introduction Interlaced with Code_,
9696
[Springer Nature, Undergrad. Lect. Notes In Physics](https://doi.org/10.1007/978-3-030-91032-7)
9797
"""
98-
mutable struct PoincareMap{I<:ContinuousTimeDynamicalSystem, F, P, R, V} <: DiscreteTimeDynamicalSystem
98+
mutable struct PoincareMap{I<:ContinuousTimeDynamicalSystem, F, P, R, U<:Real, V} <: DiscreteTimeDynamicalSystem
9999
ds::I
100100
plane_distance::F
101101
planecrossing::P
102-
Tmax::Float64
102+
Tmax::U
103103
rootkw::R
104104
state_on_plane::V
105-
tcross::Float64
105+
tcross::U
106106
t::Int
107107
# These two fields are for setting the state of the pmap from the plane
108108
# (i.e., given a D-1 dimensional state, create the full D-dimensional state)
109-
dummy::Vector{Float64}
109+
dummy::Vector{U}
110110
diffidxs::Vector{Int}
111111
state_initial::V
112112
end
@@ -125,11 +125,13 @@ function PoincareMap(
125125
planecrossing = PlaneCrossing(plane, direction > 0)
126126
plane_distance = (t) -> planecrossing(ds(t))
127127
v = recursivecopy(current_state(ds))
128-
dummy = zeros(D)
128+
tcross = current_time(ds)
129+
Tmax = convert(typeof(tcross), Tmax)
130+
dummy = zeros(eltype(v), D)
129131
diffidxs = _indices_on_poincare_plane(plane, D)
130132
pmap = PoincareMap(
131133
ds, plane_distance, planecrossing, Tmax, rootkw,
132-
v, current_time(ds), 0, dummy, diffidxs, recursivecopy(v),
134+
v, tcross, 0, dummy, diffidxs, recursivecopy(v),
133135
)
134136
step!(pmap) # this ensures that the state is on the hyperplane
135137
pmap.state_initial = recursivecopy(current_state(pmap))

test/poincare.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,23 @@ end
9999
@test all(x -> abs(x) < 1e-12, B[:, 1])
100100
@test vec(A) == vec(B)
101101
end
102+
103+
@testset "PoincareMap BigFloat" begin
104+
u0Big = BigFloat.(u0, 113)
105+
pBig = BigFloat.(p, 113)
106+
ds = CoupledODEs(gissinger_rule, u0Big, pBig)
107+
rootkw = (xrtol = BigFloat(1e-25, 113), atol = BigFloat(1e-25, 113))
108+
pmap = PoincareMap(ds, plane1;
109+
rootkw = rootkw,
110+
)
111+
112+
# check if everything is BigFloat
113+
@test typeof(current_crossing_time(pmap)) == BigFloat
114+
@test typeof(pmap.Tmax) == BigFloat
115+
@test eltype(current_state(pmap)) == BigFloat
116+
117+
# check if BigFloat works
118+
pmap = poincaresos(ds, plane1, 100; rootkw = rootkw)
119+
@test eltype(pmap[1]) == BigFloat
120+
@test all(x -> abs(x) < 1e-20, pmap[:, 1])
121+
end

0 commit comments

Comments
 (0)