Skip to content

Commit a98372d

Browse files
Merge pull request #230 from SciML/ChrisRackauckas-patch-2
Fix doc builds
2 parents 412f421 + 62295f7 commit a98372d

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

docs/src/showcase/symbolic_analysis.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ tspan = (0, 10.0)
5757
pendulum_prob = ODEProblem(pendulum_fun!, u0, tspan, p)
5858
traced_sys = modelingtoolkitize(pendulum_prob)
5959
pendulum_sys = structural_simplify(dae_index_lowering(traced_sys))
60-
prob = ODAEProblem(pendulum_sys, [], tspan)
61-
sol = solve(prob, Tsit5(), abstol = 1e-8, reltol = 1e-8)
62-
plot(sol, vars = states(traced_sys))
60+
prob = ODEProblem(pendulum_sys, [], tspan)
61+
sol = solve(prob, Rodas5P(), abstol = 1e-8, reltol = 1e-8)
62+
plot(sol, vars = unknowns(traced_sys))
6363
```
6464

6565
## Explanation
@@ -98,7 +98,7 @@ u0 = [1.0, 0, 0, 0, 0];
9898
p = [9.8, 1];
9999
tspan = (0, 10.0);
100100
pendulum_prob = ODEProblem(pendulum_fun!, u0, tspan, p)
101-
solve(pendulum_prob, Rodas4())
101+
solve(pendulum_prob, Rodas5P())
102102
```
103103

104104
However, one will quickly be greeted with the unfortunate message:
@@ -170,42 +170,41 @@ we can avoid this by using methods like
170170
[the Pantelides algorithm](https://ptolemy.berkeley.edu/projects/embedded/eecsx44/lectures/Spring2013/modelica-dae-part-2.pdf)
171171
for automatically performing this reduction to index 1. While this requires the
172172
ModelingToolkit symbolic form, we use `modelingtoolkitize` to transform
173-
the numerical code into symbolic code, run `dae_index_lowering` lowering,
173+
the numerical code into symbolic code, run `structural_simplify` to
174+
simplify the system and lower the index,
174175
then transform back to numerical code with `ODEProblem`, and solve with a
175176
numerical solver. Let's try that out:
176177

177178
```@example indexred
178179
traced_sys = modelingtoolkitize(pendulum_prob)
179-
pendulum_sys = structural_simplify(dae_index_lowering(traced_sys))
180+
pendulum_sys = structural_simplify(traced_sys)
180181
prob = ODEProblem(pendulum_sys, Pair[], tspan)
181-
sol = solve(prob, Rodas4())
182+
sol = solve(prob, Rodas5P())
182183
183184
using Plots
184-
plot(sol, vars = states(traced_sys))
185+
plot(sol, vars = unknowns(traced_sys))
185186
```
186187

187-
Note that plotting using `states(traced_sys)` is done so that any
188+
Note that plotting using `unknowns(traced_sys)` is done so that any
188189
variables which are symbolically eliminated, or any variable reordering
189190
done for enhanced parallelism/performance, still show up in the resulting
190191
plot and the plot is shown in the same order as the original numerical
191192
code.
192193

193-
Note that we can even go a bit further. If we use the `ODAEProblem`
194-
constructor, we can remove the algebraic equations from the states of the
195-
system and fully transform the index-3 DAE into an index-0 ODE, which can
196-
be solved via an explicit Runge-Kutta method:
194+
Note that we can even go a bit further. If we use the `ODEProblem`
195+
constructor, we represent the mass matrix DAE of the index-reduced system,
196+
which can be solved via:
197197

198198
```@example indexred
199199
traced_sys = modelingtoolkitize(pendulum_prob)
200200
pendulum_sys = structural_simplify(dae_index_lowering(traced_sys))
201-
prob = ODAEProblem(pendulum_sys, Pair[], tspan)
202-
sol = solve(prob, Tsit5(), abstol = 1e-8, reltol = 1e-8)
203-
plot(sol, vars = states(traced_sys))
201+
prob = ODEProblem(pendulum_sys, Pair[], tspan)
202+
sol = solve(prob, Rodas5P(), abstol = 1e-8, reltol = 1e-8)
203+
plot(sol, vars = unknowns(traced_sys))
204204
```
205205

206206
And there you go: this has transformed the model from being too hard to
207-
solve with implicit DAE solvers, to something that is easily solved with
208-
explicit Runge-Kutta methods for non-stiff equations.
207+
solve with implicit DAE solvers, to something that is easily solved.
209208

210209
# Parameter Identifiability in ODE Models
211210

@@ -285,7 +284,7 @@ local_id_all = assess_local_identifiability(de, measured_quantities = measured_q
285284
# 1
286285
```
287286

288-
We can see that all states (except $x_7$) and all parameters are locally identifiable with probability 0.99.
287+
We can see that all unknowns (except $x_7$) and all parameters are locally identifiable with probability 0.99.
289288

290289
Let's try to check specific parameters and their combinations
291290

0 commit comments

Comments
 (0)