Skip to content

Commit d7669b0

Browse files
Merge pull request #79 from anandijain/aj/attractors
add common strange attractor systems and problems
2 parents 446191e + a5bd781 commit d7669b0

File tree

6 files changed

+253
-25
lines changed

6 files changed

+253
-25
lines changed

Project.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
name = "DiffEqProblemLibrary"
22
uuid = "a077e3f3-b75c-5d7f-a0c6-6bc4c8ec64a9"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "4.13.1"
4+
version = "4.13.2"
55

66
[deps]
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"
1314
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1415

1516
[compat]
16-
Catalyst = "5.1, 6.0"
17+
Catalyst = "9"
1718
DiffEqBase = "6"
1819
DiffEqOperators = "4"
19-
ModelingToolkit = "4, 5.0"
20+
ModelingToolkit = "6"
2021
julia = "1"
2122

2223
[extras]

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/jump_premade_problems.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ end kon kAon koff kAoff kAp kAdp
137137
rsi = rates_sym_to_idx
138138
rates = params[[rsi[:kon], rsi[:kAon], rsi[:koff], rsi[:kAoff], rsi[:kAp], rsi[:kAdp]]]
139139
u0 = zeros(Int,9)
140-
statesyms = ModelingToolkit.tosymbol.(ModelingToolkit.operation.(rs.states))
140+
statesyms = ModelingToolkit.tosymbol.(ModelingToolkit.operation.(states(rs)))
141141
u0[ findfirst(isequal(:S1), statesyms)] = params[1]
142142
u0[ findfirst(isequal(:S2), statesyms)] = params[2]
143143
u0[ findfirst(isequal(:S3), statesyms)] = params[3]
@@ -194,10 +194,10 @@ function construct_genenetwork(N)
194194
genenetwork
195195
end
196196
rs = construct_genenetwork(N)
197-
u0 = zeros(Int, length(rs.states))
198-
statesyms = ModelingToolkit.tosymbol.(ModelingToolkit.operation.(rs.states))
197+
u0 = zeros(Int, length(states(rs)))
198+
statesyms = ModelingToolkit.tosymbol.(ModelingToolkit.operation.(states(rs)))
199199
for i = 1:(2*N)
200-
u0[findfirst(isequal(G[i]),rs.states)] = 1
200+
u0[findfirst(isequal(G[i]),states(rs))] = 1
201201
end
202202
tf = 2000.0
203203
prob = DiscreteProblem(rs, u0, (0.0, tf))

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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ prob_ode_fitzhughnagumo = ODEProblem(fitz,[1.0;1.0],(0.0,1.0),(0.7,0.8,1/12.5,0.
5151
#Van der Pol Equations
5252
@parameters t μ
5353
@variables x(t) y(t)
54-
@derivatives D'~t
54+
D = Differential(t)
5555
eqs = [D(y) ~ μ*((1-x^2)*y - x),
5656
D(x) ~ y]
57-
de = ODESystem(eqs)
57+
de = ODESystem(eqs; name=:van_der_pol)
5858
van = ODEFunction(de, [y,x], [μ], jac=true)
5959

6060
"""
@@ -87,16 +87,16 @@ 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₃
9494
@variables y₁(t) y₂(t) y₃(t)
95-
@derivatives D'~t
95+
D = Differential(t)
9696
eqs = [D(y₁) ~ -k₁*y₁+k₃*y₂*y₃,
9797
D(y₂) ~ k₁*y₁-k₂*y₂^2-k₃*y₂*y₃,
9898
D(y₃) ~ k₂*y₂^2]
99-
de = ODESystem(eqs)
99+
de = ODESystem(eqs; name=:rober)
100100
rober = ODEFunction(de, [y₁,y₂,y₃], [k₁,k₂,k₃], jac=true)
101101

102102
"""
@@ -169,11 +169,11 @@ prob_ode_threebody = ODEProblem(threebody,[0.994, 0.0, 0.0, big(-2.0015851063790
169169

170170
@parameters t I₁ I₂ I₃
171171
@variables y₁(t) y₂(t) y₃(t)
172-
@derivatives D'~t
172+
D = Differential(t)
173173
eqs = [D(y₁) ~ I₁*y₂*y₃,
174174
D(y₂) ~ I₂*y₁*y₃,
175175
D(y₃) ~ I₃*y₁*y₂]
176-
de = ODESystem(eqs)
176+
de = ODESystem(eqs; name=:rigid_body)
177177
rigid = ODEFunction(de, [y₁,y₂,y₃], [I₁,I₂,I₃], jac=true)
178178

179179
"""
@@ -321,7 +321,7 @@ prob_ode_mm_linear = ODEProblem(mm_f,rand(4),(0.0,1.0))
321321

322322
@parameters t p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12
323323
@variables y1(t) y2(t) y3(t) y4(t) y5(t) y6(t) y7(t) y8(t)
324-
@derivatives D'~t
324+
D = Differential(t)
325325
eqs = [D(y1) ~ -p1*y1 + p2*y2 + p3*y3 + p4,
326326
D(y2) ~ p1*y1 - p5*y2,
327327
D(y3) ~ -p6*y3 + p2*y4 + p7*y5,
@@ -331,7 +331,7 @@ eqs = [D(y1) ~ -p1*y1 + p2*y2 + p3*y3 + p4,
331331
p2*y6 + p11*y7,
332332
D(y7) ~ p10*y6*y8 - p12*y7,
333333
D(y8) ~ -p10*y6*y8 + p12*y7]
334-
de = ODESystem(eqs)
334+
de = ODESystem(eqs; name=:hires)
335335
hires = ODEFunction(de, [y1,y2,y3,y4,y5,y6,y7,y8],
336336
[p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12],
337337
jac=true)
@@ -368,11 +368,11 @@ prob_ode_hires = ODEProblem(hires,u0,(0.0,321.8122), (1.71, 0.43, 8.32, 0.0007,
368368

369369
@parameters t p1 p2 p3
370370
@variables y1(t) y2(t) y3(t)
371-
@derivatives D'~t
371+
D = Differential(t)
372372
eqs = [D(y1) ~ p1*(y2+y1*(1-p2*y1-y2)),
373373
D(y2) ~ (y3-(1+y1)*y2)/p1,
374374
D(y3) ~ p3*(y1-y3)]
375-
de = ODESystem(eqs)
375+
de = ODESystem(eqs; name=:orego)
376376
jac = calculate_jacobian(de)
377377
orego = ODEFunction(de, [y1,y2,y3], [p1,p2,p3], jac=true)
378378

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)