You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,14 @@
1
1
# Changelog for `CriticalTransitions.jl`
2
2
3
+
## v0.3.0
4
+
Major overhaul introducing `CoupledSDEs`
5
+
6
+
This release replaces the `StochSystem` struct with the new `CoupledSDEs` struct to define a stochastic dynamical system. To see how the new version works, check out the [documentation](https://juliadynamics.github.io/CriticalTransitions.jl/dev/).
7
+
8
+
The update is a breaking change for almost all functions, because the interface is now built around `CoupledSDEs`. The benefit is that the package now integrates much more seamlessly with DynamicalSystems.jl and DifferentialEquations.jl. To use the package with the old `StochSystem` struct, choose version v0.2.1 or lower.
9
+
10
+
Full changelog [here](https://github.com/JuliaDynamics/CriticalTransitions.jl/compare/v0.2.1...v0.3.0)
Copy file name to clipboardExpand all lines: docs/src/index.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
Building on [DynamicalSystems.jl](https://juliadynamics.github.io/DynamicalSystems.jl/stable/) and [DifferentialEquations.jl](https://diffeq.sciml.ai/stable/), this package aims to provide a toolbox for dynamical systems under time-dependent forcing, with a focus on tipping phenomena and metastability.
where $\text{d}\mathcal{W}=\Gamma \cdot \text{d}\mathcal{N}$, $\vec x \in \mathbb{R}^\text{dim}$ and $\mathcal N$ denotes a stochastic process. The (positive definite) noise covariance matrix is $\Sigma = \Gamma \Gamma^\top \in \mathbb R^{N\times N}$.
8
+
where $\vec x \in \mathbb{R}^\text{D}$, $\sigma > 0$ is the noise strength, $\text{d}\mathcal{W}=\Gamma \cdot \text{d}\mathcal{N}$, and $\mathcal N$ denotes a stochastic process. The (positive definite) noise covariance matrix is $\Sigma = \Gamma \Gamma^\top \in \mathbb R^{N\times N}$.
9
9
10
-
The function $f$ is the deterministic part of the system and is assumed to be of similar form as is accepted in [DynamicalSystems.jl](https://juliadynamics.github.io/DynamicalSystems.jl/latest/tutorial/), i.e., `f(u, p, t)` for out-of-place (oop) and `f(du, u, p, t)` for in-place (iip).
10
+
The function $f$ is the deterministic part of the system and follows the syntax of a `ContinuousTimeDynamicalSystem`in [DynamicalSystems.jl](https://juliadynamics.github.io/DynamicalSystems.jl/latest/tutorial/), i.e., `f(u, p, t)` for out-of-place (oop) and `f!(du, u, p, t)` for in-place (iip). The function $g$ allows to specify the stochastic dynamics of the system along with the [noise process](#noise-process) $\mathcal{W}$. It should be of the same type (iip or oop) as $f$.
11
11
12
-
The function $g$ represent the stochastics dynamics of the system and should be the of the same type (iip or oop) as $f$.
13
-
14
-
The keyword `noise` defines the system [noise process](#noise-process). In combination with `g` one can define different type of stochastic systems. Examples of different type of stochastics systems can be found on the [StochasticDiffEq.jl tutorial page](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/sde_example/). A quick overview of the different types of stochastic systems can be found [here](#Type-of-stochastic-system).
12
+
By combining $\sigma$, $g$ and $\mathcal{W}$, you can define different type of stochastic systems. Examples of different types of stochastic systems can be found on the [StochasticDiffEq.jl tutorial page](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/sde_example/). A quick overview of common types of stochastic systems can be found [below](#Type-of-stochastic-system).
15
13
16
14
!!! info
17
-
Note that nonlinear mixings of the Noise Process $\mathcal{W}$ are not Stochasitic Differential Equations but are a different class of differential equations of random ordinary differential equations (RODEs) which have a separate set of solvers. See [this example](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/rode_example/) of DifferentialEquations.jl.
18
-
19
-
15
+
Note that nonlinear mixings of the Noise Process $\mathcal{W}$ fall into the class of random ordinary differential equations (RODEs) which have a separate set of solvers. See [this example](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/rode_example/) of DifferentialEquations.jl.
20
16
21
17
```@docs
22
18
CoupledSDEs
23
19
```
24
-
## Type of stochastic system
25
-
Let us make some examples of the different types of stochastic systems that can be defined.
20
+
21
+
## Defining stochastic dynamics
22
+
Let's look at some examples of the different types of stochastic systems that can be defined.
23
+
24
+
For simplicity, we choose a slow exponential growth in 2 dimensions as the deterministic dynamics `f`:
26
25
```@example type
27
26
using CriticalTransitions, Plots
28
27
import Random # hide
29
28
Random.seed!(10) # hide
30
-
f!(du, u, p, t) = du .= 1.01u
31
-
σ = 0.25
29
+
f!(du, u, p, t) = du .= 1.01u # deterministic part
30
+
σ = 0.25 # noise strength
32
31
```
33
32
### Additive noise
34
-
When `g` is independent of the state variables `u`, the noise is called additive.
33
+
When `g \, \text{d}\mathcal{W}` is independent of the state variables `u`, the noise is called additive.
35
34
36
35
#### Diagonal noise
37
-
A system of diagional noise is the most common type of noise. It is defined by a vector of random numbers `dW` whose size matches the output of `g` where the noise is applied element-wise, i.e. `g.*dW`.
36
+
A system of diagonal noise is the most common type of noise. It is defined by a vector of random numbers `dW` whose size matches the output of `g` where the noise is applied element-wise, i.e. `g.*dW`.
38
37
```@example type
39
38
t0 = 0.0; W0 = zeros(2);
40
39
W = WienerProcess(t0, W0, 0.0)
@@ -100,9 +99,9 @@ plot(sol)
100
99
```
101
100
102
101
!!! warning
103
-
Non-diagonal problem need specific type of solvers. See the [SciML recommendations](https://docs.sciml.ai/DiffEqDocs/stable/solvers/sde_solve/#sde_solve).
102
+
Non-diagonal problems need specific type of solvers. See the [SciML recommendations](https://docs.sciml.ai/DiffEqDocs/stable/solvers/sde_solve/#sde_solve).
104
103
105
-
### Corelated noise
104
+
### Correlated noise
106
105
```@example type
107
106
ρ = 0.3
108
107
Σ = [1 ρ; ρ 1]
@@ -113,11 +112,53 @@ sol = simulate(sde, 1.0, dt=0.01, alg=SOSRA())
113
112
plot(sol)
114
113
```
115
114
116
-
## Noise process
117
-
We provide the noise processes $\text{d}\mathcal{W}$ that can be used in the stochastic simulations through the [DiffEqNoiseProcess.jl](https://docs.sciml.ai/DiffEqNoiseProcess/stable) package. A complete list of the available processes can be found [here](https://docs.sciml.ai/DiffEqNoiseProcess/stable/noise_processes/). We list some of the most common ones below:
115
+
## Available noise processes
116
+
We provide the noise processes $\mathcal{W}$ that can be used in the stochastic simulations through the [DiffEqNoiseProcess.jl](https://docs.sciml.ai/DiffEqNoiseProcess/stable) package. A complete list of the available processes can be found [here](https://docs.sciml.ai/DiffEqNoiseProcess/stable/noise_processes/). We list some of the most common ones below:
118
117
```@docs
119
118
WienerProcess
120
119
SimpleWienerProcess
121
120
OrnsteinUhlenbeckProcess
122
121
CorrelatedWienerProcess
122
+
```
123
+
124
+
## Interface to `DynamicalSystems.jl`
125
+
126
+
!!! tip "Analyzing deterministic dynamics with DynamicalSystems.jl"
127
+
The deterministic part of a [`CoupledSDEs`](@ref) system can easily be extracted as a
128
+
[`CoupledODEs`](https://juliadynamics.github.io/DynamicalSystems.jl/dev/tutorial/#DynamicalSystemsBase.CoupledODEs), a common subtype of a `ContinuousTimeDynamicalSystem` in DynamicalSystems.jl.
129
+
130
+
131
+
-
132
+
type of `DynamicalSystems.jl` using the function [`CoupledODEs`](@ref). Vice vera,
133
+
a `CoupledODEs` system can be converted into a `CoupledSDEs` via `CoupledSDEs(ds::CoupledODEs, g)` with g the noise function.
134
+
135
+
#### Converting between `CoupledSDEs` and `CoupledODEs`
136
+
137
+
-`CoupledODEs(sde::CoupledSDEs)` extracts the deterministic part of `sde` as a `CoupledODEs`
138
+
-`CoupledSDEs(ode::CoupledODEs, g)`, with `g` the noise function, turns `ode` into a `CoupledSDEs`
139
+
140
+
For example, the
141
+
Lyapunov spectrum of a `CoupledSDEs` in the absence of noise, here exemplified by the
Copy file name to clipboardExpand all lines: docs/src/quickstart.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,11 @@ As this module is not published yet, there are two ways to access it:
14
14
## Basic usage
15
15
The general workflow of `CriticalTransitions` essentially follows two steps:
16
16
17
-
1. Define your system (see [Define a CoupledSDE](@ref))
17
+
1. Define your system (see [Define a CoupledSDEs system](@ref))
18
18
2. Investigate the system by calling methods (see [Methods](@ref))
19
19
20
-
!!! info "Extension to RateSystem and TippingSystem"
21
-
We are currently working on extending the types of dynamical systems that can be studied with CriticalTransitions.jl. Particularly, we are planning to introduce the overarching structure `TippingSystem`, which has two subtypes: `CoupledSDEs` (as it already exists) and `RateSystem`, a new dynamical system type in which the system parameters may evolve in time.
20
+
!!! info "New system type: RateSystem"
21
+
We are planning to introduce the the struct `RateSystem` along `CoupledSDEs`. In a `RateSystem`, the time dependence of parameters can conveniently be specified, laying the foundation for a toolbox to study rate-induced tipping, or R-tipping.
Copy file name to clipboardExpand all lines: docs/src/tutorial.md
+12-14Lines changed: 12 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
To give you an idea of how our package works, this tutorial provides some example code with explanations.
4
4
5
5
## Example: FitzHugh-Nagumo model
6
-
Consider the FitzHugh-Nagumo model,
6
+
Let's consider a simple 2-dimensional dynamical system - the *FitzHugh-Nagumo* model:
7
7
8
8
```math
9
9
\begin{aligned}
@@ -19,7 +19,7 @@ Let's investigate this system under stochastic forcing.
19
19
### System definition
20
20
First, we need to translate the system equations above into Julia code.
21
21
22
-
This works by defining a function `f(u,p,t)` which takes as input a vector `u` of state variables (``u``,``v``), a vector `p` of parameters, and time `t`. The function must return an array of flow increments ($\text{d}u$, $\text{d}v$). For performance reasons, it is advisable to return a StaticArray `SA[du, dv]` rather than just a Vector `[du, dv]`. This is why we need the `StaticArrays` package.
22
+
This works exactly as in [DynamicalSystems.jl](https://juliadynamics.github.io/DynamicalSystemsBase.jl/dev/)by defining a function `f(u,p,t)` which takes as input a vector `u` of state variables (``u``,``v``), a vector `p` of parameters, and time `t`. The function must return an array of flow increments ($\text{d}u$, $\text{d}v$). For performance reasons, it is advisable to return a StaticArray `SA[du, dv]` rather than just a Vector `[du, dv]`.
23
23
24
24
```@example MAIN
25
25
using CriticalTransitions
@@ -37,14 +37,12 @@ function fitzhugh_nagumo(u,p,t)
37
37
end
38
38
```
39
39
40
-
Note that the system parameters `ϵ, β, α, γ, κ, I = p[1]` are unpacked as the first component of `p`. This is necessary because in CriticalTransitions.jl one can also define a separate set of parameters for the stochastic component of the system, which would then make up the second component `p[2]` ( see [Define a CoupledSDE](@ref)).
41
-
42
40
!!! tip "In-place vs. out-of-place"
43
41
The function `fitzhugh_nagumo(u,p,t)` is defined *out-of-place*. It is also possible to define the system *in-place* as `fitzhugh_nagumo!(du,u,p,t)`. For more info, see [here](https://diffeq.sciml.ai/stable/types/ode_types/).
44
42
45
43
### CoupledSDE
46
44
47
-
Next, we turn the `fitzhugh_nagumo`system into a stochastic dynamical system. Suppose we would like to force both state variables ``u`` and ``v`` with additive, uncorrelated Gaussian noise of intensity ``\sigma``. This is the default case. We simply write
45
+
Next, we construct a stochastic system with the `fitzhugh_nagumo`equation as the deterministic part. Suppose we would like to force both state variables ``u`` and ``v`` with additive, uncorrelated Gaussian noise of intensity ``\sigma``. This is the default case. We simply write
Here we have chosen `zeros(2)` as the initial state of the system. The length of this vector must correspond to the system's dimensionality, but for now the state is just a placeholder that aligns our syntax with that of DifferentialEquations.jl and DynamicalSystems.jl.
54
+
Here the first field `fitzhugh_nagumo` specifies the deterministic dynamics `f` (see [Define a CoupledSDEs system](@ref)), and the second field `idfunc` specifies the noise function `g`. The `idfunc` identity function is predefined for convenience. We have chosen `zeros(2)` as the initial state of the system, which is the third field. The length of this vector must match the system's dimensionality. In the fourth field, we specify the parameter vector, which includes the parameters of `f` followed by the parameters of `g` (in this case, there are no parameters for `g`). Lastly, `σ` sets the noise strength. Since we have not specified a noise process, the default case of an uncorrelated Wiener process is used.
57
55
58
56
!!! note "Multiplicative and/or correlated noise"
59
-
Of course, it is also possible to define more complicated noise processes than simple additive white noise. This is done by specifying a custom *noise function* and *covariance matrix* in the `CoupledSDEs` definition. For more info, see [Define a CoupledSDE](@ref).
57
+
Of course, it is also possible to define more complicated noise processes than simple additive white noise. This is done by specifying a custom *noise function* and *covariance matrix* in the `CoupledSDEs` definition. For more info, see [Define a CoupledSDEs system](@ref).
60
58
61
-
That's it! Now we can throw the toolbox of `CriticalTransitions`at our stochastic FitzHugh-Nagumo system `sys`.
59
+
That's it! Now we can apply the toolbox of `CriticalTransitions`to our stochastic FitzHugh-Nagumo system `sys`.
62
60
63
61
### Find stable equilibria
64
-
For the parameters chosen above, the FitzHugh-Nagumo system is bistable. Let's compute the fixed points using the [`fixedpoints`](https://juliadynamics.github.io/DynamicalSystemsDocs.jl/chaostools/stable/periodicity/#ChaosTools.fixedpoints) function from ChaosTools.jl. As this function is from the `DynamicalSystems` ecosystem, it takes a system of type `CoupledODEs`as input. We can simply convert the CoupledSDEs `sys` via the [`CoupledODEs`](@ref) function:
62
+
For the parameters chosen above, the FitzHugh-Nagumo system is bistable. Let's compute the fixed points using the [`fixedpoints`](https://juliadynamics.github.io/CriticalTransitions.jl/dev/man/systemanalysis/#ChaosTools.fixedpoints) function. This function is borrowed from ChaosTools.jl and is loaded as an extension when we write `using ChaosTools`.
65
63
66
64
```@example MAIN
67
65
using ChaosTools
@@ -74,21 +72,21 @@ fp1, fp2 = eqs[stab]
74
72
```
75
73
76
74
### Stochastic simulation
77
-
Using the `simulate` function, we now run a simulation of our system starting out from the fixed point `fp1`:
75
+
Using the [`simulate`](@ref) function, we now run a simulation of our system for `1e3` time units starting out from the fixed point `fp1`:
78
76
79
77
```@example MAIN
80
-
sim = simulate(sys, 1e3, fp1, saveat=0.1)
78
+
sim = simulate(sys, 1e3, fp1; saveat=0.1)
81
79
```
82
80
83
-
In the keyword arguments, we have specified the time step `dt` and total duration `tmax` of the numerical time integration.
81
+
In the keyword arguments, we have specified at which interval the solution is saved. Further keyword arguments can be used to change the solver (the default is `SOSRA()` for stochastic integration) and other settings.
84
82
85
-
The simulated trajectory is stored in `sim`as a matrix with 2 rows corresponding to the state variables ``u``, ``v``, and 10,000 columns corresponding to the time steps.
83
+
The simulated trajectory is stored in `sim`in the usual output format of the [`solve`](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/#CommonSolve.solve-Tuple%7BSciMLBase.AbstractDEProblem,%20Vararg%7BAny%7D%7D) method of DifferentialEquations.jl, including the solution `sim.u` and the vector of time points `sim.t`. The solution can also be accessed as a matrix `sim[i, t]`, where `i` is the `i`-th component of `u` and `t` the time index.
86
84
87
85
Let's plot the result. Did the trajectory transition to the other attractor?
0 commit comments