Skip to content

Commit 62295f7

Browse files
Update symbolic_analysis.md
1 parent d146e80 commit 62295f7

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

docs/src/showcase/symbolic_analysis.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ traced_sys = modelingtoolkitize(pendulum_prob)
5959
pendulum_sys = structural_simplify(dae_index_lowering(traced_sys))
6060
prob = ODEProblem(pendulum_sys, [], tspan)
6161
sol = solve(prob, Rodas5P(), abstol = 1e-8, reltol = 1e-8)
62-
plot(sol, vars = states(traced_sys))
62+
plot(sol, vars = unknowns(traced_sys))
6363
```
6464

6565
## Explanation
@@ -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)
181182
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))
201201
prob = ODEProblem(pendulum_sys, Pair[], tspan)
202202
sol = solve(prob, Rodas5P(), abstol = 1e-8, reltol = 1e-8)
203-
plot(sol, vars = states(traced_sys))
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)