Skip to content

Commit c81863f

Browse files
Update README.md
1 parent 01edf96 commit c81863f

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,16 @@ for the numerical integrator, and solve it.
3737

3838
```julia
3939
using DifferentialEquations, ModelingToolkit
40+
using ModelingToolkit: t_nounits as t, D_nounits as D
4041

4142
@parameters σ ρ β
42-
@variables t x(t) y(t) z(t)
43-
D = Differential(t)
43+
@variables x(t) y(t) z(t)
4444

4545
eqs = [D(D(x)) ~ σ * (y - x),
4646
D(y) ~ x *- z) - y,
4747
D(z) ~ x * y - β * z]
4848

49-
@named sys = ODESystem(eqs)
50-
sys = structural_simplify(sys)
49+
@mtkbuild sys = ODESystem(eqs)
5150

5251
u0 = [D(x) => 2.0,
5352
x => 1.0,
@@ -75,23 +74,22 @@ Equation (DAE):
7574

7675
```julia
7776
using DifferentialEquations, ModelingToolkit
77+
using ModelingToolkit: t_nounits as t, D_nounits as D
7878

7979
@parameters σ ρ β
80-
@variables t x(t) y(t) z(t)
81-
D = Differential(t)
80+
@variables x(t) y(t) z(t)
8281

8382
eqs = [D(x) ~ σ * (y - x),
8483
D(y) ~ x *- z) - y,
8584
D(z) ~ x * y - β * z]
8685

87-
@named lorenz1 = ODESystem(eqs)
88-
@named lorenz2 = ODESystem(eqs)
86+
@mtkbuild lorenz1 = ODESystem(eqs)
87+
@mtkbuild lorenz2 = ODESystem(eqs)
8988

9089
@variables a(t)
9190
@parameters γ
9291
connections = [0 ~ lorenz1.x + lorenz2.y + a * γ]
93-
@named connected = ODESystem(connections, t, [a], [γ], systems = [lorenz1, lorenz2])
94-
sys = structural_simplify(connected)
92+
@mtkbuild connected = ODESystem(connections, t, [a], [γ], systems = [lorenz1, lorenz2])
9593

9694
u0 = [lorenz1.x => 1.0,
9795
lorenz1.y => 0.0,
@@ -110,7 +108,7 @@ p = [lorenz1.σ => 10.0,
110108
γ => 2.0]
111109

112110
tspan = (0.0, 100.0)
113-
prob = ODEProblem(sys, u0, tspan, p)
111+
prob = ODEProblem(connected, u0, tspan, p)
114112
sol = solve(prob)
115113

116114
using Plots

0 commit comments

Comments
 (0)