Skip to content

Commit

Permalink
Simplify handling of Δt in trajectory GUI: just use `stop_at_dt = tru…
Browse files Browse the repository at this point in the history
…e` 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
  • Loading branch information
Datseris authored Nov 21, 2024
1 parent 8e94a09 commit 0972a4b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
The package DynamicalSystems.jl has little actual code.
It mainly re-exports other packages. The source code contained here is only regarding graphical interactive applications for dynamical systems.

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

The changelogs of individual subpackages are self-contained for each package.
The changelogs of individual sub-packages are self-contained for each package.

# v3.4

Some important fixes on the `interactive_trajectory` GUI:

- 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.
- The documentation around the "run" button of the GUI has been clarified.

# v3.3

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DynamicalSystems"
uuid = "61744808-ddfa-5f27-97ff-6e42cc95d634"
repo = "https://github.com/JuliaDynamics/DynamicalSystems.jl.git"
version = "3.3.26"
version = "3.4.0"

[deps]
Attractors = "f3fd9213-ca85-4dba-9dfd-7fc91308fec7"
Expand Down
2 changes: 1 addition & 1 deletion ext/src/dynamicalsystemobservable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function DynamicalSystems.step!(dso::DynamicalSystemObservable, n::Int = 1)
N = length(dso.tail_observables)
# Always store values, but only update observables after loop
for _ in 1:n
step!(dso.pds, Δt)
step!(dso.pds, Δt, true)
for i in 1:N
ob = dso.tail_observables[i]
last_state = current_state(dso.pds, i)
Expand Down
5 changes: 0 additions & 5 deletions ext/src/interactive_trajectory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function DynamicalSystems.interactive_trajectory(
throw(ArgumentError("State space plot can be up to 3 dimensional! Change `idxs`."))
end

if ds isa CoupledODEs # force time evolution into non-adaptive
newdiffeq = (ds.diffeq..., adaptive = false, dt = Δt)
ds = CoupledODEs(ds, newdiffeq)
end

p0 = initial_parameters(ds)
pds = DynamicalSystems.ParallelDynamicalSystem(ds, u0s)
u00s = deepcopy(current_states(pds))
Expand Down
33 changes: 20 additions & 13 deletions src/visualizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,41 @@ See also [`interactive_trajectory`](@ref).
## Interactivity and time stepping keywords
_GUI functionality is possible when the plotting backend is `GLMakie`.
Do `using GLMakie; GLMakie.activate!()` to ensure this is the chosen backend._
!!! note "GLMakie"
GUI functionality is possible when the plotting backend is `GLMakie` or `WGLMakie`.
Do `using GLMakie; GLMakie.activate!()` to ensure this is the chosen backend.
- `add_controls = true`: If `true`, below the state space axis
some buttons for animating the trajectories live are added:
- `reset`: results the parallel trajectories to their initial conditions
- `run`: when clicked it evolves the trajectories forwards in time indefinitely.
click again to stop the evolution.
- `step`: when clicked it evolves the trajectories forwards in time for the
amount of steps chosen by the slider to its right.
- "reset": results the parallel trajectories to their initial conditions.
- "run": when clicked it evolves the trajectories forwards in time indefinitely.
click again to stop the evolution. Note that "run" simply presses the "step"
button indefinitely, and hence the visual progress you see on the screen depends
on the value of the "steps" slider. Thus, while the animation "runs" you can
increase/decrease the "steps" slider to increase/decrease the animation speed.
For smooth animations for continuous time systems you should have small `Δt` and large `tail`.
- "step": when clicked it evolves the trajectories forwards in time for the
amount of steps chosen by the "steps" slider to its right. Each step is an
evolution of `Δt` unit of time long (and clicking the "step" button may do
more than one steps according to the slider).
The plotted trajectories can always be evolved
manually using the custom animations etup that we describe below; `add_controls` only
manually using the custom animations setup that we describe below; `add_controls` only
concerns the buttons and interactivity added to the created figure.
- `parameter_sliders = nothing`: If given, it must be a dictionary, mapping
parameter indices (any valid index that can be given to [`set_parameter!`](@ref))
to ranges of parameter values. Each combination of index and range becomes a slider
that can be interactively controlled to alter a system parameter on the fly during time
evolution. Below the parameter sliders, three buttons are added for GUI usage:
- `update`: when clicked the chosen parameter values are propagated into the system
- `u.r.s.`: when clicked it is equivalent with clicking in order: "update", "reset", "step".
- `reset p`: when clicked it resets
- "update": when clicked the chosen parameter values are propagated into the system.
- "u.r.s.": when clicked it is equivalent with clicking in order: "update", "reset", "step".
- "reset p": when clicked it resets parameters to their initial values.
Parameters can also be altered using the custom animation setup that we describe below;
`parameter_sliders` only conserns the buttons and interactivity added to the created figure.
- `parameter_names = Dict(keys(ps) .=> string.(keys(ps)))`: Dictionary mapping parameter
keys to labels. Only used if `parameter_sliders` is given.
- `Δt`: Time step of time evolution. Defaults to 1 for discrete time,
0.01 for continuous time systems. For internal simplicity, continuous time dynamical
systems are evolved non-adaptively with constant step size equal to `Δt`.
0.01 for continuous time systems. Continuous time dynamical
systems are stepped for exactly `Δt` time (third argument to `step!` is `true`).
- `pause = nothing`: If given, it must be a real number. This number is given to the `sleep`
function, which is called between each plot update. Useful when time integration is
computationally inexpensive and animation proceeds too fast.
Expand Down

0 comments on commit 0972a4b

Please sign in to comment.