Skip to content

Commit 02824b1

Browse files
docs: use @mtkbuild in place of redundant structural_simplify
1 parent 1b2d474 commit 02824b1

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

docs/src/basics/Events.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ D = Differential(t)
9393
root_eqs = [x ~ 0] # the event happens at the ground x(t) = 0
9494
affect = [v ~ -v] # the effect is that the velocity changes sign
9595
96-
@named ball = ODESystem([D(x) ~ v
96+
@mtkbuild ball = ODESystem([D(x) ~ v
9797
D(v) ~ -9.8], t; continuous_events = root_eqs => affect) # equation => affect
9898
99-
ball = structural_simplify(ball)
100-
10199
tspan = (0.0, 5.0)
102100
prob = ODEProblem(ball, Pair[], tspan)
103101
sol = solve(prob, Tsit5())
@@ -116,15 +114,13 @@ D = Differential(t)
116114
continuous_events = [[x ~ 0] => [vx ~ -vx]
117115
[y ~ -1.5, y ~ 1.5] => [vy ~ -vy]]
118116
119-
@named ball = ODESystem([
117+
@mtkbuild ball = ODESystem([
120118
D(x) ~ vx,
121119
D(y) ~ vy,
122120
D(vx) ~ -9.8 - 0.1vx, # gravity + some small air resistance
123121
D(vy) ~ -0.1vy,
124122
], t; continuous_events)
125123
126-
ball = structural_simplify(ball)
127-
128124
tspan = (0.0, 10.0)
129125
prob = ODEProblem(ball, Pair[], tspan)
130126
@@ -197,10 +193,9 @@ end
197193
198194
reflect = [x ~ 0] => (bb_affect!, [v], [], nothing)
199195
200-
@named bb_model = ODESystem(bb_eqs, t, sts, par,
196+
@mtkbuild bb_sys = ODESystem(bb_eqs, t, sts, par,
201197
continuous_events = reflect)
202198
203-
bb_sys = structural_simplify(bb_model)
204199
u0 = [v => 0.0, x => 1.0]
205200
206201
bb_prob = ODEProblem(bb_sys, u0, (0, 5.0))

docs/src/basics/FAQ.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ using ModelingToolkit, StaticArrays
141141
sts = @variables x1(t)=0.0
142142
D = Differential(t)
143143
eqs = [D(x1) ~ 1.1 * x1]
144-
@named sys = ODESystem(eqs, t)
145-
sys = structural_simplify(sys)
144+
@mtkbuild sys = ODESystem(eqs, t)
146145
prob = ODEProblem{false}(sys, [], (0,1); u0_constructor = x->SVector(x...))
147146
```

docs/src/examples/perturbation.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ We are nearly there! From this point on, the rest is standard ODE solving proced
9292
```julia
9393
using ModelingToolkit, DifferentialEquations
9494

95-
@named sys = ODESystem(eqs, t)
96-
sys = structural_simplify(sys)
95+
@mtkbuild sys = ODESystem(eqs, t)
9796
unknowns(sys)
9897
```
9998

@@ -158,8 +157,7 @@ eqs = [substitute(first(v), subs) ~ substitute(last(v), subs) for v in vals]
158157
We continue with converting 'eqs' to an `ODEProblem`, solving it, and finally plot the results against the exact solution to the original problem, which is $x(t, \epsilon) = (1 - \epsilon)^{-1/2} e^{-\epsilon t} \sin((1- \epsilon^2)^{1/2}t)$,
159158

160159
```julia
161-
@named sys = ODESystem(eqs, t)
162-
sys = structural_simplify(sys)
160+
@mtkbuild sys = ODESystem(eqs, t)
163161
```
164162

165163
```julia

0 commit comments

Comments
 (0)