Skip to content

Commit f0c50ad

Browse files
authored
Allow Dt as alternative keyword in trajectory (#173)
* Allow `Dt` in `trajectory` * increase accuracy of poincare tests * further increase poincare map accuracy
1 parent 6915b7d commit f0c50ad

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# v3.2.0
2+
The keyword `Dt` can now be used instead of `Δt` in `trajectory` if access to unicode isn't available.
3+
14
# v3.1.0
25
New error checking functionality added via `successful_step`. Returns `true` if the last `step!` call to `ds` was successful, `false` otherwise.
3-
For continuous time systems this uses DifferentialEquations.jl error checking,for discrete time it checks if any variable is `Inf` or `NaN`. Defaults to `true` for other types.
6+
For continuous time systems this uses DifferentialEquations.jl error checking,for discrete time it checks if any variable is `Inf` or `NaN`. Defaults to `true` for other types.
47

58
# v3.0
69

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.1.2"
4+
version = "3.2.0"
55

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

src/core/trajectory.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ The returned time vector is `t = (t0+Ttr):Δt:(t0+Ttr+T)`.
1414
## Keyword arguments
1515
1616
* `Δt`: Time step of value output. For discrete time systems it must be an integer.
17-
Defaults to `0.1` for continuous and `1` for discrete time systems.
17+
Defaults to `0.1` for continuous and `1` for discrete time systems. If you don't
18+
have access to unicode, the keyword `Dt` can be used instead.
1819
* `Ttr = 0`: Transient time to evolve the initial state before starting saving states.
1920
* `t0 = initial_time(ds)`: Starting time.
2021
* `save_idxs::AbstractVector{Int}`: Which variables to output in `X` (by default all).
@@ -31,7 +32,9 @@ function trajectory(ds::DynamicalSystem, T, u0 = initial_state(ds);
3132
end
3233
end
3334

34-
function trajectory_discrete(ds, T; Δt::Integer = 1, Ttr::Integer = 0, accessor = nothing)
35+
function trajectory_discrete(ds, T;
36+
Dt::Integer = 1, Δt::Integer = Dt, Ttr::Integer = 0, accessor = nothing
37+
)
3538
ET = eltype(current_state(ds))
3639
t0 = current_time(ds)
3740
tvec = (t0+Ttr):Δt:(t0+T+Ttr)
@@ -55,7 +58,7 @@ function trajectory_discrete(ds, T; Δt::Integer = 1, Ttr::Integer = 0, accessor
5558
return StateSpaceSet(data), tvec
5659
end
5760

58-
function trajectory_continuous(ds, T; Δt = 0.1, Ttr = 0.0, accessor = nothing)
61+
function trajectory_continuous(ds, T; Dt = 0.1, Δt = Dt, Ttr = 0.0, accessor = nothing)
5962
D = dimension(ds)
6063
t0 = current_time(ds)
6164
tvec = (t0+Ttr):Δt:(t0+T+Ttr)

test/poincare.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ plane2 = gis_plane(μ)
3636
function poincare_tests(ds, pmap, plane)
3737
P, t = trajectory(pmap, 10)
3838
reinit!(ds)
39-
P2 = poincaresos(ds, plane, 100)
39+
P2 = poincaresos(ds, plane, 100; rootkw = (xrtol = 1e-12, atol = 1e-12))
4040
@test length(P) == 11
4141
@test P[1] == P2[1]
4242
@test length(P2) > 1
@@ -57,13 +57,14 @@ end
5757
rule = !IIP ? gissinger_rule : gissinger_rule_iip
5858
ds = CoupledODEs(rule, recursivecopy(u0), p)
5959
plane = P == 1 ? plane1 : plane2
60-
pmap = PoincareMap(ds, plane)
60+
pmap = PoincareMap(ds, plane; rootkw = (xrtol = 1e-12, atol = 1e-12))
6161
u0pmap = recursivecopy(current_state(pmap))
6262
test_dynamical_system(pmap, u0pmap, p;
6363
idt=true, iip=IIP, test_trajectory = true,
6464
test_init_state_equiv=false, u0init = initial_state(pmap))
65-
# Specific poincare map tests here:
66-
poincare_tests(ds, pmap, plane)
65+
@testset "specific poincare" begin
66+
poincare_tests(ds, pmap, plane)
67+
end
6768
end
6869

6970
@testset "set_parameter works" begin
@@ -79,7 +80,7 @@ end
7980
plane = (1, 0.0)
8081
ds = CoupledODEs(lorenz_rule, recursivecopy(u0), p)
8182

82-
pmap = PoincareMap(ds, plane)
83+
pmap = PoincareMap(ds, plane; rootkw = (xrtol = 1e-12, atol = 1e-12))
8384
P, t = trajectory(pmap, 10)
8485
@test all(x -> abs(x) < 1e-6, P[:, 1])
8586

test/test_system_function.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function test_dynamical_system(ds, u0, p0; idt, iip,
123123
@test X[1] == u0
124124

125125
prev_u0 = deepcopy(current_state(ds))
126-
Y, t2 = trajectory(ds, 3, nothing; Δt = 1)
126+
Y, t2 = trajectory(ds, 3, nothing; Dt = 1)
127127
@test Y[1] prev_u0 atol=1e-6
128128
@test t2[1] > t[end]
129129

0 commit comments

Comments
 (0)