Skip to content

Commit c8317c0

Browse files
github-actions[bot]CompatHelper JuliaDatseris
authored
CompatHelper: bump compat for StateSpaceSets to 2, (keep existing compat) (#243)
* CompatHelper: bump compat for StateSpaceSets to 2, (keep existing compat) * only use v2 * rename dataset * update tutorial * access solvers * fix mistak lyap henon --------- Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Datseris <[email protected]>
1 parent bd8c5a5 commit c8317c0

File tree

4 files changed

+58
-27
lines changed

4 files changed

+58
-27
lines changed

Project.toml

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

66
[deps]
77
Attractors = "f3fd9213-ca85-4dba-9dfd-7fc91308fec7"
88
ChaosTools = "608a59af-f2a3-5ad4-90b4-758bdf3122a7"
99
ComplexityMeasures = "ab4b797d-85ee-42ba-b621-05d793b346a2"
10-
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" # necessary for extension
10+
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1111
DelayEmbeddings = "5732040d-69e3-5649-938a-b6b4f237613f"
1212
DynamicalSystemsBase = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
1313
FractalDimensions = "4665ce21-e117-4649-aed8-08bbe5ccbead"
@@ -37,14 +37,13 @@ PredefinedDynamicalSystems = "1"
3737
RecurrenceAnalysis = "2"
3838
Reexport = "1"
3939
Scratch = "1"
40-
StateSpaceSets = "1"
40+
StateSpaceSets = "2"
4141
TimeseriesSurrogates = "2.1"
4242
julia = "1.9"
4343

44-
4544
[extras]
46-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4745
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
46+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4847

4948
[targets]
5049
test = ["Test", "Makie"]

docs/src/tutorial.jl

+50-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# # [Overarching tutorial for DynamicalSystems.jl](@id tutorial)
1+
# # [Overarching tutorial for **DynamicalSystems.jl**](@id tutorial)
22

3-
# This page serves as a short but to-the-point introduction to the **DynamicalSystems.jl**
3+
# This page serves as a short but to-the-point introduction to the ****DynamicalSystems.jl****
44
# library. It outlines the core components, and how they establish an interface that
55
# is used by the rest of the library. It also provides a couple of usage examples
66
# to connect the various packages of the library together.
@@ -15,7 +15,7 @@
1515
# ```
1616

1717
# This installs several packages for the Julia language. These are the sub-modules/packages
18-
# that comprise DynamicalSystems.jl, see [contents](@ref contents) for more.
18+
# that comprise **DynamicalSystems.jl**, see [contents](@ref contents) for more.
1919
# All of the functionality is brought into scope when doing:
2020

2121
using DynamicalSystems
@@ -31,7 +31,7 @@ import Pkg
3131
#nb Pkg.add(["DynamicalSystems", "CairoMakie", "GLMakie", "OrdinaryDiffEq", "BenchmarkTools"])
3232
Pkg.status(["DynamicalSystems", "CairoMakie", "GLMakie", "OrdinaryDiffEq", "BenchmarkTools"]; mode = Pkg.PKGMODE_MANIFEST)
3333

34-
#nb # ## DynamicalSystems.jl summary
34+
#nb # ## **DynamicalSystems.jl** summary
3535

3636
#nb @doc DynamicalSystems
3737

@@ -103,16 +103,18 @@ p0 = [1.4, 0.3]
103103
henon = DeterministicIteratedMap(henon_rule, u0, p0)
104104

105105
# `henon` is a `DynamicalSystem`, one of the two core structures of the library.
106-
# They can evolved interactively, and queried, using the interface defined by [`DynamicalSystem`](@ref). The simplest thing you can do with a `DynamicalSystem` is to get its trajectory:
106+
# They can evolved interactively, and queried, using the interface defined by [`DynamicalSystem`](@ref).
107+
# The simplest thing you can do with a `DynamicalSystem` is to get its trajectory:
107108

108109
total_time = 10_000
109110
X, t = trajectory(henon, total_time)
110111
X
111112

112-
# `X` is a `StateSpaceSet`, the second of the core structures of the library. We'll see below how, and where, to use a `StateSpaceset`, but for now let's just do a scatter plot
113+
# `X` is a `StateSpaceSet`, the second of the core structures of the library.
114+
# We'll see below how, and where, to use a `StateSpaceset`, but for now let's just do a scatter plot
113115

114116
using CairoMakie
115-
scatter(X[:, 1], X[:, 2])
117+
scatter(X)
116118

117119
# ### Example: Lorenz96
118120

@@ -167,15 +169,15 @@ fig
167169
# Continuous time dynamical systems are evolved through DifferentialEquations.jl.
168170
# In this sense, the above `trajectory` function is a simplified version of `DifferentialEquations.solve`.
169171
# If you only care about evolving a dynamical system forwards in time, you are probably better off using
170-
# DifferentialEquations.jl directly. DynamicalSystems.jl can be used to do many other things that either occur during
172+
# DifferentialEquations.jl directly. **DynamicalSystems.jl** can be used to do many other things that either occur during
171173
# the time evolution or after it, see the section below on [using dynamical systems](@ref using).
172174

173175
# When initializing a `CoupledODEs` you can tune the solver properties to your heart's
174176
# content using any of the [ODE solvers](https://diffeq.sciml.ai/latest/solvers/ode_solve/)
175177
# and any of the [common solver options](https://diffeq.sciml.ai/latest/basics/common_solver_opts/).
176178
# For example:
177179

178-
using OrdinaryDiffEq # accessing the ODE solvers
180+
using OrdinaryDiffEq: Vern9 # accessing the ODE solvers
179181
diffeq = (alg = Vern9(), abstol = 1e-9, reltol = 1e-9)
180182
lorenz96_vern = ContinuousDynamicalSystem(lorenz96_rule!, u0, p0; diffeq)
181183

@@ -189,15 +191,15 @@ Y[end]
189191

190192
# #### Higher accuracy, higher order
191193

192-
# The solver `Tsit5` (the default solver) is most performant when medium-high error
193-
# tolerances are requested. When we require very small errors, choosing a different solver
194+
# The solver `Tsit5` (the default solver) is most performant when medium-low error
195+
# tolerances are requested. When we require very small error tolerances, choosing a different solver
194196
# can be more accurate. This can be especially impactful for chaotic dynamical systems.
195197
# Let's first expliclty ask for a given accuracy when solving the ODE by passing the
196198
# keywords `abstol, reltol` (for absolute and relative tolerance respectively),
197199
# and compare performance to a naive solver one would use:
198200

199201
using BenchmarkTools: @btime
200-
using OrdinaryDiffEq: BS3 # equivalent of odeint23
202+
using OrdinaryDiffEq: BS3 # 3rd order solver
201203

202204
for alg in (BS3(), Vern9())
203205
diffeq = (; alg, abstol = 1e-12, reltol = 1e-12)
@@ -230,6 +232,8 @@ end
230232

231233
# Let's compare
232234

235+
using OrdinaryDiffEq: Tsit5, Rodas5P
236+
233237
function vanderpol_rule(u, μ, t)
234238
x, y = u
235239
dx = y
@@ -252,14 +256,28 @@ end
252256

253257
# ## [Using dynamical systems](@id using)
254258

255-
# You may use the [`DynamicalSystem`](@ref) interface to develop algorithms that utilize dynamical systems with a known evolution rule. The two main packages of the library that do this are [`ChaosTools`](@ref) and [`Attractors`](@ref). For example, you may want to compute the Lyapunov spectrum of the Lorenz96 system from above. This is as easy as calling the `lyapunovspectrum` function with `lorenz96`
259+
# You may use the [`DynamicalSystem`](@ref) interface to develop algorithms that utilize dynamical systems with a known evolution rule.
260+
# The two main packages of the library that do this are [`ChaosTools`](@ref) and [`Attractors`](@ref).
261+
# For example, you may want to compute the Lyapunov spectrum of the Lorenz96 system from above.
262+
# This is as easy as calling the `lyapunovspectrum` function with `lorenz96`
256263

257264
steps = 10_000
258265
lyapunovspectrum(lorenz96, steps)
259266

260-
# As expected, there is at least one positive Lyapunov exponent, because the system is chaotic, and at least one zero Lyapunov exponent, because the system is continuous time.
267+
# As expected, there is at least one positive Lyapunov exponent, because the system is chaotic,
268+
# and at least one zero Lyapunov exponent, because the system is continuous time.
269+
270+
# A fantastic feature of **DynamicalSystems.jl** is that all library functions work for any
271+
# applicable dynamical system. The exact same `lyapunovspectrum` function would also work
272+
# for the Henon map.
261273

262-
# Alternatively, you may want to estimate the basins of attraction of a multistable dynamical system. The Henon map is "multistable" in the sense that some initial conditions diverge to infinity, and some others converge to a chaotic attractor. Computing these basins of attraction is simple with [`Attractors`](@ref), and would work as follows:
274+
lyapunovspectrum(henon, steps)
275+
276+
# Something else that uses a dynamical system is estimating the basins of attraction
277+
# of a multistable dynamical system.
278+
# The Henon map is "multistable" in the sense that some initial conditions diverge to
279+
# infinity, and some others converge to a chaotic attractor.
280+
# Computing these basins of attraction is simple with [`Attractors`](@ref), and would work as follows:
263281

264282
## define a state space grid to compute the basins on:
265283
xg = yg = range(-2, 2; length = 201)
@@ -315,7 +333,12 @@ step!(henon, 2)
315333

316334
X
317335

318-
# It is printed like a matrix where each column is the timeseries of each dynamic variable. In reality, it is a vector of statically sized vectors (for performance reasons). When indexed with 1 index, it behaves like a vector of vectors
336+
# This is the main data structure used in **DynamicalSystems.jl** to handle numerical data.
337+
# It is printed like a matrix where each column is the timeseries of each dynamic variable.
338+
# In reality, it is a vector equally-sized vectors representing state space points.
339+
# _(For advanced users: `StateSpaceSet` directly subtypes `AbstractVector{<:AbstractVector}`)_
340+
341+
# When indexed with 1 index, it behaves like a vector of vectors
319342

320343
X[1]
321344

@@ -343,6 +366,15 @@ map(point -> point[1] + 1/(point[2]+0.1), X)
343366
x, y = columns(X)
344367
summary.((x, y))
345368

369+
# Because `StateSpaceSet` really is a vector of vectors, it can be given
370+
# to any Julia function that accepts such an input. For example,
371+
# the Makie plotting ecosystem knows how to plot vectors of vectors.
372+
# That's why this works:
373+
374+
scatter(X)
375+
376+
# even though Makie has no knowledge of the specifics of `StateSpaceSet`.
377+
346378
# ## Using state space sets
347379

348380
# Several packages of the library deal with `StateSpaceSets`.
@@ -420,7 +452,7 @@ fig
420452

421453
# ## Integration with ModelingToolkit.jl
422454

423-
# DynamicalSystems.jl understands when a model has been generated via [ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/stable/). The symbolic variables used in ModelingToolkit.jl can be used to access the state or parameters of the dynamical system.
455+
# **DynamicalSystems.jl** understands when a model has been generated via [ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/stable/). The symbolic variables used in ModelingToolkit.jl can be used to access the state or parameters of the dynamical system.
424456

425457
# To access this functionality, the `DynamicalSystem` must be created from a `DEProblem` of the SciML ecosystem, and the `DEProblem` itself must be created from a ModelingToolkit.jl model.
426458

@@ -514,4 +546,4 @@ current_parameter(roessler, :c)
514546

515547
# ## Learn more
516548

517-
# To learn more, you need to visit the documentation pages of the modules that compose DynamicalSystems.jl. See the [contents](@ref contents) page for more!
549+
# To learn more, you need to visit the documentation pages of the modules that compose **DynamicalSystems.jl**. See the [contents](@ref contents) page for more!

ext/src/numericdata/plot_dataset.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Dataset = DynamicalSystems.Dataset
1+
StateSpaceSet = DynamicalSystems.StateSpaceSet
22

33
plot_dataset(args...; kwargs...) = plot_dataset!(Scene(), args...; kwargs...)
4-
function plot_dataset!(scene, data::Dataset{2}, color = :black; kwargs...)
4+
function plot_dataset!(scene, data::StateSpaceSet{2}, color = :black; kwargs...)
55
makiedata = [Point2f(d) for d in data]
66
scatter!(scene, makiedata; color = color, markersize = 0.01, kwargs...)
77
return scene
@@ -12,7 +12,7 @@ function plot_dataset!(scene, data::Matrix, color = :black; kwargs...)
1212
scatter!(scene, makiedata; color = color, markersize = 0.01, kwargs...)
1313
return scene
1414
end
15-
function plot_dataset!(scene, data::Dataset{3}, color = :black; kwargs...)
15+
function plot_dataset!(scene, data::StateSpaceSet{3}, color = :black; kwargs...)
1616
makiedata = [Point3f(d) for d in data]
1717
lines!(scene, makiedata; color = color, transparency = true, linewidth = 2.0, kwargs...)
1818
return scene

ext/src/numericdata/trajectory_highlighter.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const DEFAULT_α = 0.01
88
"""
99
trajectory_highlighter(datasets, vals; kwargs...)
1010
Open an interactive application for highlighting specific datasets
11-
and properties of these datasets. `datasets` is a vector of `Dataset` from
11+
and properties of these datasets. `datasets` is a vector of `StateSpaceSet` from
1212
**DynamicalSystems.jl**. Each dataset corresponds to a specific value from `vals`
1313
(a `Vector{<:Real}`). The value of `vals` gives each dataset
1414
a specific color based on a colormap.

0 commit comments

Comments
 (0)