Skip to content

Commit 0972a4b

Browse files
authored
Simplify handling of Δt in trajectory GUI: just use stop_at_dt = true in step! (#249)
* Some fixes for the notebook output * simplify Dt handling in GUI by not remaking the system * documentation improvement * even more clarification * give instructions on how to make smooth animations
1 parent 8e94a09 commit 0972a4b

5 files changed

+31
-22
lines changed

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
The package DynamicalSystems.jl has little actual code.
44
It mainly re-exports other packages. The source code contained here is only regarding graphical interactive applications for dynamical systems.
55

6-
The changelog here therefore lists either major changes to the overarching DynamicalSystems.jl ecosystem, or major changes to plotting infastructure.
6+
The changelog here therefore lists either major changes to the overarching DynamicalSystems.jl ecosystem, or major changes to plotting infrastructure.
77

8-
The changelogs of individual subpackages are self-contained for each package.
8+
The changelogs of individual sub-packages are self-contained for each package.
9+
10+
# v3.4
11+
12+
Some important fixes on the `interactive_trajectory` GUI:
13+
14+
- Changed the internal handling for continuous time systems. Now they are stepped for exactly `Δt` by giving `true` as third input to `step!`. This increases consistency with discrete systems by not altering the integration protocol.
15+
- The documentation around the "run" button of the GUI has been clarified.
916

1017
# v3.3
1118

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicalSystems"
22
uuid = "61744808-ddfa-5f27-97ff-6e42cc95d634"
33
repo = "https://github.com/JuliaDynamics/DynamicalSystems.jl.git"
4-
version = "3.3.26"
4+
version = "3.4.0"
55

66
[deps]
77
Attractors = "f3fd9213-ca85-4dba-9dfd-7fc91308fec7"

ext/src/dynamicalsystemobservable.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function DynamicalSystems.step!(dso::DynamicalSystemObservable, n::Int = 1)
2323
N = length(dso.tail_observables)
2424
# Always store values, but only update observables after loop
2525
for _ in 1:n
26-
step!(dso.pds, Δt)
26+
step!(dso.pds, Δt, true)
2727
for i in 1:N
2828
ob = dso.tail_observables[i]
2929
last_state = current_state(dso.pds, i)

ext/src/interactive_trajectory.jl

-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ function DynamicalSystems.interactive_trajectory(
3232
throw(ArgumentError("State space plot can be up to 3 dimensional! Change `idxs`."))
3333
end
3434

35-
if ds isa CoupledODEs # force time evolution into non-adaptive
36-
newdiffeq = (ds.diffeq..., adaptive = false, dt = Δt)
37-
ds = CoupledODEs(ds, newdiffeq)
38-
end
39-
4035
p0 = initial_parameters(ds)
4136
pds = DynamicalSystems.ParallelDynamicalSystem(ds, u0s)
4237
u00s = deepcopy(current_states(pds))

src/visualizations.jl

+20-13
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,41 @@ See also [`interactive_trajectory`](@ref).
3232
3333
## Interactivity and time stepping keywords
3434
35-
_GUI functionality is possible when the plotting backend is `GLMakie`.
36-
Do `using GLMakie; GLMakie.activate!()` to ensure this is the chosen backend._
35+
!!! note "GLMakie"
36+
GUI functionality is possible when the plotting backend is `GLMakie` or `WGLMakie`.
37+
Do `using GLMakie; GLMakie.activate!()` to ensure this is the chosen backend.
3738
3839
- `add_controls = true`: If `true`, below the state space axis
3940
some buttons for animating the trajectories live are added:
40-
- `reset`: results the parallel trajectories to their initial conditions
41-
- `run`: when clicked it evolves the trajectories forwards in time indefinitely.
42-
click again to stop the evolution.
43-
- `step`: when clicked it evolves the trajectories forwards in time for the
44-
amount of steps chosen by the slider to its right.
41+
- "reset": results the parallel trajectories to their initial conditions.
42+
- "run": when clicked it evolves the trajectories forwards in time indefinitely.
43+
click again to stop the evolution. Note that "run" simply presses the "step"
44+
button indefinitely, and hence the visual progress you see on the screen depends
45+
on the value of the "steps" slider. Thus, while the animation "runs" you can
46+
increase/decrease the "steps" slider to increase/decrease the animation speed.
47+
For smooth animations for continuous time systems you should have small `Δt` and large `tail`.
48+
- "step": when clicked it evolves the trajectories forwards in time for the
49+
amount of steps chosen by the "steps" slider to its right. Each step is an
50+
evolution of `Δt` unit of time long (and clicking the "step" button may do
51+
more than one steps according to the slider).
4552
The plotted trajectories can always be evolved
46-
manually using the custom animations etup that we describe below; `add_controls` only
53+
manually using the custom animations setup that we describe below; `add_controls` only
4754
concerns the buttons and interactivity added to the created figure.
4855
- `parameter_sliders = nothing`: If given, it must be a dictionary, mapping
4956
parameter indices (any valid index that can be given to [`set_parameter!`](@ref))
5057
to ranges of parameter values. Each combination of index and range becomes a slider
5158
that can be interactively controlled to alter a system parameter on the fly during time
5259
evolution. Below the parameter sliders, three buttons are added for GUI usage:
53-
- `update`: when clicked the chosen parameter values are propagated into the system
54-
- `u.r.s.`: when clicked it is equivalent with clicking in order: "update", "reset", "step".
55-
- `reset p`: when clicked it resets
60+
- "update": when clicked the chosen parameter values are propagated into the system.
61+
- "u.r.s.": when clicked it is equivalent with clicking in order: "update", "reset", "step".
62+
- "reset p": when clicked it resets parameters to their initial values.
5663
Parameters can also be altered using the custom animation setup that we describe below;
5764
`parameter_sliders` only conserns the buttons and interactivity added to the created figure.
5865
- `parameter_names = Dict(keys(ps) .=> string.(keys(ps)))`: Dictionary mapping parameter
5966
keys to labels. Only used if `parameter_sliders` is given.
6067
- `Δt`: Time step of time evolution. Defaults to 1 for discrete time,
61-
0.01 for continuous time systems. For internal simplicity, continuous time dynamical
62-
systems are evolved non-adaptively with constant step size equal to `Δt`.
68+
0.01 for continuous time systems. Continuous time dynamical
69+
systems are stepped for exactly `Δt` time (third argument to `step!` is `true`).
6370
- `pause = nothing`: If given, it must be a real number. This number is given to the `sleep`
6471
function, which is called between each plot update. Useful when time integration is
6572
computationally inexpensive and animation proceeds too fast.

0 commit comments

Comments
 (0)