Skip to content

Commit a5bd781

Browse files
committed
add strange attractor examples
1 parent 48b4984 commit a5bd781

File tree

5 files changed

+236
-8
lines changed

5 files changed

+236
-8
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "4.13.2"
77
Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83"
88
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
99
DiffEqOperators = "9fdde737-9c7f-55bf-ade8-46b3f136cc48"
10+
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
1011
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1112
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1213
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"

src/DiffEqProblemLibrary.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module DiffEqProblemLibrary
22

33
module ODEProblemLibrary
4+
using Latexify
45
function importodeproblems()
56
@isdefined(prob_ode_linear) ||
67
include(joinpath(@__DIR__, "ode/ode_premade_problems.jl"));

src/ode/ode_premade_problems.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@ Random.seed!(100)
55

66
#ODE Example Problems
77
export prob_ode_linear, prob_ode_bigfloatlinear, prob_ode_2Dlinear,
8-
prob_ode_large2Dlinear, prob_ode_bigfloat2Dlinear, prob_ode_rigidbody,
9-
prob_ode_2Dlinear_notinplace, prob_ode_vanderpol, prob_ode_vanderpol_stiff,
10-
prob_ode_lorenz, prob_ode_rober, prob_ode_threebody, prob_ode_mm_linear, prob_ode_pleiades,
11-
prob_ode_brusselator_1d, prob_ode_brusselator_2d, prob_ode_orego,
12-
prob_ode_hires, prob_ode_pollution, prob_ode_filament,
13-
prob_ode_nonlinchem,
14-
SolverDiffEq, filament_prob
8+
prob_ode_large2Dlinear, prob_ode_bigfloat2Dlinear, prob_ode_rigidbody,
9+
prob_ode_2Dlinear_notinplace, prob_ode_vanderpol, prob_ode_vanderpol_stiff,
10+
prob_ode_rober, prob_ode_threebody, prob_ode_mm_linear, prob_ode_pleiades,
11+
prob_ode_brusselator_1d, prob_ode_brusselator_2d, prob_ode_orego,
12+
prob_ode_hires, prob_ode_pollution, prob_ode_filament,
13+
prob_ode_nonlinchem,
14+
SolverDiffEq, filament_prob,
15+
thomas, lorenz, aizawa, dadras, chen, rossler, rabinovich_fabrikant, sprott, hindmarsh_rose,
16+
prob_ode_thomas, prob_ode_lorenz, prob_ode_aizawa, prob_ode_dadras,
17+
prob_ode_chen, prob_ode_rossler, prob_ode_rabinovich_fabrikant, prob_ode_sprott,
18+
prob_ode_hindmarsh_rose
1519

1620
include("ode_linear_prob.jl")
1721
include("ode_simple_nonlinear_prob.jl")
1822
include("brusselator_prob.jl")
1923
include("pollution_prob.jl")
2024
include("filament_prob.jl")
2125
include("nonlinchem.jl")
26+
include("strange_attractors.jl")

src/ode/ode_simple_nonlinear_prob.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ with ``μ=10^6`` and ``u_0=[0,\\sqrt{3}]``
8787
8888
Stiff parameters.
8989
"""
90-
prob_ode_vanstiff = ODEProblem(van,[0;sqrt(3)],(0.0,1.0),1e6)
90+
prob_ode_vanderpol_stiff = ODEProblem(van,[0;sqrt(3)],(0.0,1.0),1e6)
9191

9292
# ROBER
9393
@parameters t k₁ k₂ k₃

src/ode/strange_attractors.jl

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
# Strange attractors from https://www.dynamicmath.xyz/strange-attractors/ and
2+
# https://en.wikipedia.org/wiki/List_of_chaotic_maps
3+
# Opted for the equations as reported in papers
4+
5+
# Thomas
6+
@parameters t b=0.208186
7+
@variables x(t)=1 y(t)=0 z(t)=0
8+
D = Differential(t)
9+
10+
eqs = [D(x) ~ sin(y) - b*x,
11+
D(y) ~ sin(z) - b*y,
12+
D(z) ~ sin(x) - b*z]
13+
14+
@named thomas = ODESystem(eqs)
15+
16+
"""
17+
Thomas' cyclically symmetric attractor equations
18+
19+
```math
20+
$(latexify(thomas))
21+
```
22+
23+
[Reference](https://www.worldscientific.com/doi/abs/10.1142/S0218127499001383)
24+
25+
[Wikipedia](https://en.wikipedia.org/wiki/Thomas%27_cyclically_symmetric_attractor)
26+
"""
27+
prob_ode_thomas= ODEProblem(thomas,[],(0.0,1.0))
28+
29+
30+
# Lorenz
31+
@parameters t σ=10 ρ=28 β=8/3
32+
@variables x(t)=1 y(t)=0 z(t)=0
33+
D = Differential(t)
34+
35+
eqs = [D(x) ~ σ*(y-x),
36+
D(y) ~ x*-z)-y,
37+
D(z) ~ x*y - β*z]
38+
39+
@named lorenz = ODESystem(eqs)
40+
41+
"""
42+
Lorenz equations
43+
44+
```math
45+
$(latexify(lorenz))
46+
```
47+
48+
[Reference](https://journals.ametsoc.org/view/journals/atsc/20/2/1520-0469_1963_020_0130_dnf_2_0_co_2.xml)
49+
50+
[Wikipedia](https://en.wikipedia.org/wiki/Lorenz_system)
51+
"""
52+
prob_ode_lorenz = ODEProblem(lorenz,[],(0.0,1.0))
53+
54+
55+
# Aizawa
56+
@parameters t a=0.95 b=0.7 c=0.6 d=3.5 e=0.25 f=0.1
57+
@variables x(t)=1 y(t)=0 z(t)=0
58+
D = Differential(t)
59+
60+
eqs = [D(x) ~ (z-b)*x-d*y,
61+
D(y) ~ d*x+(z-b)*y,
62+
D(z) ~ c+a*z-z^3/3-(x^2+y^2)*(1+e*z)+ f*z*x^3]
63+
64+
@named aizawa = ODESystem(eqs)
65+
66+
"""
67+
Aizawa equations
68+
69+
```math
70+
$(latexify(aizawa))
71+
```
72+
73+
[Reference](https://journals.ametsoc.org/view/journals/atsc/20/2/1520-0469_1963_020_0130_dnf_2_0_co_2.xml)
74+
75+
"""
76+
prob_ode_aizawa = ODEProblem(aizawa,[],(0.0,1.0))
77+
78+
79+
# Dadras
80+
@parameters t a=3 b=2.7 c=1.7 d=2 e=9
81+
@variables x(t)=1 y(t)=0 z(t)=0
82+
D = Differential(t)
83+
84+
eqs = [D(x) ~ y-a*x+b*y*z,
85+
D(y) ~ c*y-x*z+z,
86+
D(z) ~ d*x*y-e*z]
87+
88+
@named dadras = ODESystem(eqs)
89+
90+
"""
91+
Dadras equations
92+
93+
```math
94+
$(latexify(dadras))
95+
```
96+
97+
[Reference](https://www.sciencedirect.com/science/article/abs/pii/S0375960109009591)
98+
99+
"""
100+
prob_ode_dadras = ODEProblem(dadras,[],(0.0,1.0))
101+
102+
103+
# chen
104+
@parameters t a=35 b=3 c=28
105+
@variables x(t)=1 y(t)=0 z(t)=0
106+
D = Differential(t)
107+
108+
eqs = [D(x) ~ a*(y-x),
109+
D(y) ~ (c-a)*x-x*z+c*y,
110+
D(z) ~ x*y-b*z]
111+
112+
@named chen = ODESystem(eqs)
113+
114+
"""
115+
chen equations
116+
117+
```math
118+
$(latexify(chen))
119+
```
120+
121+
[Reference](https://www.worldscientific.com/doi/abs/10.1142/S0218127499001024)
122+
123+
"""
124+
prob_ode_chen = ODEProblem(chen,[],(0.0,1.0))
125+
126+
127+
# rossler
128+
@parameters t a=0.2 b=0.2 c=5.7
129+
@variables x(t)=1 y(t)=0 z(t)=0
130+
D = Differential(t)
131+
132+
eqs = [D(x) ~ -(y+z),
133+
D(y) ~ x+a*y,
134+
D(z) ~ b+z*(x-c)]
135+
136+
@named rossler = ODESystem(eqs)
137+
138+
"""
139+
rossler equations
140+
141+
```math
142+
$(latexify(rossler))
143+
```
144+
145+
[Reference](https://www.sciencedirect.com/science/article/abs/pii/0375960176901018)
146+
[Wikipedia](https://en.wikipedia.org/wiki/R%C3%B6ssler_attractor)
147+
148+
"""
149+
prob_ode_rossler = ODEProblem(rossler,[],(0.0,1.0))
150+
151+
152+
# rabinovich_fabrikant
153+
@parameters t a=0.14 b=0.10
154+
@variables x(t)=1 y(t)=0 z(t)=0
155+
D = Differential(t)
156+
157+
eqs = [D(x) ~ y*(z-1+x^2) + b*x,
158+
D(y) ~ x*(3*z+1-x^2)+b*y,
159+
D(z) ~ -2*z*(a+x*y)]
160+
161+
@named rabinovich_fabrikant = ODESystem(eqs)
162+
163+
"""
164+
rabinovich_fabrikant equations
165+
166+
```math
167+
$(latexify(rabinovich_fabrikant))
168+
```
169+
170+
[Reference](https://en.wikipedia.org/wiki/Rabinovich%E2%80%93Fabrikant_equations)
171+
172+
"""
173+
prob_ode_rabinovich_fabrikant = ODEProblem(rabinovich_fabrikant,[],(0.0,1.0))
174+
175+
176+
# sprott
177+
@parameters t a=2.07 b=1.79
178+
@variables x(t)=1 y(t)=0 z(t)=0
179+
D = Differential(t)
180+
181+
eqs = [D(x) ~ y+a*x*y+x*z,
182+
D(y) ~ 1-b*x^2+y*z,
183+
D(z) ~ x-x^2-y^2]
184+
185+
@named sprott = ODESystem(eqs)
186+
187+
"""
188+
sprott equations
189+
190+
```math
191+
$(latexify(sprott))
192+
```
193+
194+
[Reference](http://sprott.physics.wisc.edu/pubs/paper423.pdf)
195+
196+
"""
197+
prob_ode_sprott = ODEProblem(sprott,[],(0.0,1.0))
198+
199+
200+
# hindmarsh_rose
201+
@parameters t a=1 b=3 c=1 d=5 r=1e-2 s=4 xr=-8/5 i=5
202+
@variables x(t)=1 y(t)=0 z(t)=0
203+
D = Differential(t)
204+
205+
eqs = [D(x) ~ y-a*x^3+b*x^2-z+i,
206+
D(y) ~ c-d*x^2-y,
207+
D(z) ~ r*(s*(x-xr)-z)]
208+
209+
@named hindmarsh_rose = ODESystem(eqs)
210+
211+
"""
212+
hindmarsh_rose equations
213+
214+
```math
215+
$(latexify(hindmarsh_rose))
216+
```
217+
218+
[Reference](https://en.wikipedia.org/wiki/Hindmarsh%E2%80%93Rose_model)
219+
220+
"""
221+
prob_ode_hindmarsh_rose = ODEProblem(hindmarsh_rose,[],(0.0,1.0))

0 commit comments

Comments
 (0)