Skip to content

Commit 59dff34

Browse files
Update to ModelingToolkit v9
1 parent df61f71 commit 59dff34

File tree

4 files changed

+44
-43
lines changed

4 files changed

+44
-43
lines changed

lib/ODEProblemLibrary/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
1515
Aqua = "0.5"
1616
DiffEqBase = "6"
1717
Latexify = "0.15, 0.16"
18-
ModelingToolkit = "7,8"
18+
ModelingToolkit = "9"
1919
RuntimeGeneratedFunctions = "0.5"
2020
julia = "1.6"
2121

lib/ODEProblemLibrary/src/ODEProblemLibrary.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module ODEProblemLibrary
55
using DiffEqBase
66
using Latexify
77
using ModelingToolkit
8+
using ModelingToolkit: t_nounits as t, D_nounits as D
89

910
using LinearAlgebra
1011
using Markdown

lib/ODEProblemLibrary/src/ode_simple_nonlinear_prob.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ prob_ode_fitzhughnagumo = ODEProblem(fitz, [1.0; 1.0], (0.0, 1.0),
4949
(0.7, 0.8, 1 / 12.5, 0.5))
5050

5151
#Van der Pol Equations
52-
@parameters t μ
52+
@parameters μ
5353
@variables x(t) y(t)
54-
D = Differential(t)
54+
5555
eqs = [D(y) ~ μ * ((1 - x^2) * y - x),
5656
D(x) ~ y]
57-
de = ODESystem(eqs; name = :van_der_pol)
57+
de = ODESystem(eqs,t; name = :van_der_pol) |> structural_simplify |> complete
5858
van = ODEFunction(de, [y, x], [μ], jac = true, eval_module = @__MODULE__)
5959

6060
"""
@@ -90,13 +90,13 @@ Stiff parameters.
9090
prob_ode_vanderpol_stiff = ODEProblem(van, [0; sqrt(3)], (0.0, 1.0), 1e6)
9191

9292
# ROBER
93-
@parameters t k₁ k₂ k₃
93+
@parameters k₁ k₂ k₃
9494
@variables y₁(t) y₂(t) y₃(t)
95-
D = Differential(t)
95+
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; name = :rober)
99+
de = ODESystem(eqs,t; name = :rober) |> structural_simplify |> complete
100100
rober = ODEFunction(de, [y₁, y₂, y₃], [k₁, k₂, k₃], jac = true, eval_module = @__MODULE__)
101101

102102
"""
@@ -171,13 +171,13 @@ prob_ode_threebody = ODEProblem(threebody,
171171

172172
# Rigid Body Equations
173173

174-
@parameters t I₁ I₂ I₃
174+
@parameters I₁ I₂ I₃
175175
@variables y₁(t) y₂(t) y₃(t)
176-
D = Differential(t)
176+
177177
eqs = [D(y₁) ~ I₁ * y₂ * y₃,
178178
D(y₂) ~ I₂ * y₁ * y₃,
179179
D(y₃) ~ I₃ * y₁ * y₂]
180-
de = ODESystem(eqs; name = :rigid_body)
180+
de = ODESystem(eqs,t; name = :rigid_body) |> structural_simplify |> complete
181181
rigid = ODEFunction(de, [y₁, y₂, y₃], [I₁, I₂, I₃], jac = true, eval_module = @__MODULE__)
182182

183183
"""
@@ -348,9 +348,9 @@ mm_f = ODEFunction(mm_linear; analytic = (u0, p, t) -> exp(inv(MM_linear) * mm_A
348348
mass_matrix = MM_linear)
349349
prob_ode_mm_linear = ODEProblem(mm_f, rand(4), (0.0, 1.0))
350350

351-
@parameters t p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12
351+
@parameters p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12
352352
@variables y1(t) y2(t) y3(t) y4(t) y5(t) y6(t) y7(t) y8(t)
353-
D = Differential(t)
353+
354354
eqs = [D(y1) ~ -p1 * y1 + p2 * y2 + p3 * y3 + p4,
355355
D(y2) ~ p1 * y1 - p5 * y2,
356356
D(y3) ~ -p6 * y3 + p2 * y4 + p7 * y5,
@@ -360,7 +360,7 @@ eqs = [D(y1) ~ -p1 * y1 + p2 * y2 + p3 * y3 + p4,
360360
p2 * y6 + p11 * y7,
361361
D(y7) ~ p10 * y6 * y8 - p12 * y7,
362362
D(y8) ~ -p10 * y6 * y8 + p12 * y7]
363-
de = ODESystem(eqs; name = :hires)
363+
de = ODESystem(eqs,t; name = :hires) |> structural_simplify |> complete
364364
hires = ODEFunction(de, [y1, y2, y3, y4, y5, y6, y7, y8],
365365
[p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12],
366366
jac = true)
@@ -396,13 +396,13 @@ prob_ode_hires = ODEProblem(hires, u0, (0.0, 321.8122),
396396
10.03, 0.035, 1.12, 1.745, 280.0,
397397
0.69, 1.81))
398398

399-
@parameters t p1 p2 p3
399+
@parameters p1 p2 p3
400400
@variables y1(t) y2(t) y3(t)
401-
D = Differential(t)
401+
402402
eqs = [D(y1) ~ p1 * (y2 + y1 * (1 - p2 * y1 - y2)),
403403
D(y2) ~ (y3 - (1 + y1) * y2) / p1,
404404
D(y3) ~ p3 * (y1 - y3)]
405-
de = ODESystem(eqs; name = :orego)
405+
de = ODESystem(eqs,t; name = :orego) |> structural_simplify |> complete
406406
jac = calculate_jacobian(de)
407407
orego = ODEFunction(de, [y1, y2, y3], [p1, p2, p3], jac = true, eval_module = @__MODULE__)
408408

lib/ODEProblemLibrary/src/strange_attractors.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
# Opted for the equations as reported in papers
44

55
# Thomas
6-
@parameters t b=0.208186
6+
@parameters b=0.208186
77
@variables x(t)=1 y(t)=0 z(t)=0
8-
D = Differential(t)
8+
99

1010
eqs = [D(x) ~ sin(y) - b * x,
1111
D(y) ~ sin(z) - b * y,
1212
D(z) ~ sin(x) - b * z]
1313

14-
@named thomas = ODESystem(eqs)
14+
@mtkbuild thomas = ODESystem(eqs,t)
1515

1616
"""
1717
Thomas' cyclically symmetric attractor equations
@@ -27,15 +27,15 @@ $(latexify(thomas))
2727
prob_ode_thomas = ODEProblem(thomas, [], (0.0, 1.0))
2828

2929
# Lorenz
30-
@parameters t σ=10 ρ=28 β=8 / 3
30+
@parameters σ=10 ρ=28 β=8 / 3
3131
@variables x(t)=1 y(t)=0 z(t)=0
32-
D = Differential(t)
32+
3333

3434
eqs = [D(x) ~ σ * (y - x),
3535
D(y) ~ x *- z) - y,
3636
D(z) ~ x * y - β * z]
3737

38-
@named lorenz = ODESystem(eqs)
38+
@mtkbuild lorenz = ODESystem(eqs,t)
3939

4040
"""
4141
Lorenz equations
@@ -51,15 +51,15 @@ $(latexify(lorenz))
5151
prob_ode_lorenz = ODEProblem(lorenz, [], (0.0, 1.0))
5252

5353
# Aizawa
54-
@parameters t a=0.95 b=0.7 c=0.6 d=3.5 e=0.25 f=0.1
54+
@parameters a=0.95 b=0.7 c=0.6 d=3.5 e=0.25 f=0.1
5555
@variables x(t)=1 y(t)=0 z(t)=0
56-
D = Differential(t)
56+
5757

5858
eqs = [D(x) ~ (z - b) * x - d * y,
5959
D(y) ~ d * x + (z - b) * y,
6060
D(z) ~ c + a * z - z^3 / 3 - (x^2 + y^2) * (1 + e * z) + f * z * x^3]
6161

62-
@named aizawa = ODESystem(eqs)
62+
@mtkbuild aizawa = ODESystem(eqs,t)
6363

6464
"""
6565
Aizawa equations
@@ -74,15 +74,15 @@ $(latexify(aizawa))
7474
prob_ode_aizawa = ODEProblem(aizawa, [], (0.0, 1.0))
7575

7676
# Dadras
77-
@parameters t a=3 b=2.7 c=1.7 d=2 e=9
77+
@parameters a=3 b=2.7 c=1.7 d=2 e=9
7878
@variables x(t)=1 y(t)=0 z(t)=0
79-
D = Differential(t)
79+
8080

8181
eqs = [D(x) ~ y - a * x + b * y * z,
8282
D(y) ~ c * y - x * z + z,
8383
D(z) ~ d * x * y - e * z]
8484

85-
@named dadras = ODESystem(eqs)
85+
@mtkbuild dadras = ODESystem(eqs,t)
8686

8787
"""
8888
Dadras equations
@@ -97,15 +97,15 @@ $(latexify(dadras))
9797
prob_ode_dadras = ODEProblem(dadras, [], (0.0, 1.0))
9898

9999
# chen
100-
@parameters t a=35 b=3 c=28
100+
@parameters a=35 b=3 c=28
101101
@variables x(t)=1 y(t)=0 z(t)=0
102-
D = Differential(t)
102+
103103

104104
eqs = [D(x) ~ a * (y - x),
105105
D(y) ~ (c - a) * x - x * z + c * y,
106106
D(z) ~ x * y - b * z]
107107

108-
@named chen = ODESystem(eqs)
108+
@mtkbuild chen = ODESystem(eqs,t)
109109

110110
"""
111111
chen equations
@@ -120,15 +120,15 @@ $(latexify(chen))
120120
prob_ode_chen = ODEProblem(chen, [], (0.0, 1.0))
121121

122122
# rossler
123-
@parameters t a=0.2 b=0.2 c=5.7
123+
@parameters a=0.2 b=0.2 c=5.7
124124
@variables x(t)=1 y(t)=0 z(t)=0
125-
D = Differential(t)
125+
126126

127127
eqs = [D(x) ~ -(y + z),
128128
D(y) ~ x + a * y,
129129
D(z) ~ b + z * (x - c)]
130130

131-
@named rossler = ODESystem(eqs)
131+
@mtkbuild rossler = ODESystem(eqs,t)
132132

133133
"""
134134
rossler equations
@@ -144,15 +144,15 @@ $(latexify(rossler))
144144
prob_ode_rossler = ODEProblem(rossler, [], (0.0, 1.0))
145145

146146
# rabinovich_fabrikant
147-
@parameters t a=0.14 b=0.10
147+
@parameters a=0.14 b=0.10
148148
@variables x(t)=1 y(t)=0 z(t)=0
149-
D = Differential(t)
149+
150150

151151
eqs = [D(x) ~ y * (z - 1 + x^2) + b * x,
152152
D(y) ~ x * (3 * z + 1 - x^2) + b * y,
153153
D(z) ~ -2 * z * (a + x * y)]
154154

155-
@named rabinovich_fabrikant = ODESystem(eqs)
155+
@mtkbuild rabinovich_fabrikant = ODESystem(eqs,t)
156156

157157
"""
158158
rabinovich_fabrikant equations
@@ -167,15 +167,15 @@ $(latexify(rabinovich_fabrikant))
167167
prob_ode_rabinovich_fabrikant = ODEProblem(rabinovich_fabrikant, [], (0.0, 1.0))
168168

169169
# sprott
170-
@parameters t a=2.07 b=1.79
170+
@parameters a=2.07 b=1.79
171171
@variables x(t)=1 y(t)=0 z(t)=0
172-
D = Differential(t)
172+
173173

174174
eqs = [D(x) ~ y + a * x * y + x * z,
175175
D(y) ~ 1 - b * x^2 + y * z,
176176
D(z) ~ x - x^2 - y^2]
177177

178-
@named sprott = ODESystem(eqs)
178+
@mtkbuild sprott = ODESystem(eqs,t)
179179

180180
"""
181181
sprott equations
@@ -190,15 +190,15 @@ $(latexify(sprott))
190190
prob_ode_sprott = ODEProblem(sprott, [], (0.0, 1.0))
191191

192192
# hindmarsh_rose
193-
@parameters t a=1 b=3 c=1 d=5 r=1e-2 s=4 xr=-8 / 5 i=5
193+
@parameters a=1 b=3 c=1 d=5 r=1e-2 s=4 xr=-8 / 5 i=5
194194
@variables x(t)=1 y(t)=0 z(t)=0
195-
D = Differential(t)
195+
196196

197197
eqs = [D(x) ~ y - a * x^3 + b * x^2 - z + i,
198198
D(y) ~ c - d * x^2 - y,
199199
D(z) ~ r * (s * (x - xr) - z)]
200200

201-
@named hindmarsh_rose = ODESystem(eqs)
201+
@mtkbuild hindmarsh_rose = ODESystem(eqs,t)
202202

203203
"""
204204
hindmarsh_rose equations

0 commit comments

Comments
 (0)