@@ -57,9 +57,9 @@ tspan = (0, 10.0)
57
57
pendulum_prob = ODEProblem(pendulum_fun!, u0, tspan, p)
58
58
traced_sys = modelingtoolkitize(pendulum_prob)
59
59
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))
63
63
```
64
64
65
65
## Explanation
@@ -98,7 +98,7 @@ u0 = [1.0, 0, 0, 0, 0];
98
98
p = [9.8, 1];
99
99
tspan = (0, 10.0);
100
100
pendulum_prob = ODEProblem(pendulum_fun!, u0, tspan, p)
101
- solve(pendulum_prob, Rodas4 ())
101
+ solve(pendulum_prob, Rodas5P ())
102
102
```
103
103
104
104
However, one will quickly be greeted with the unfortunate message:
@@ -170,42 +170,41 @@ we can avoid this by using methods like
170
170
[ the Pantelides algorithm] ( https://ptolemy.berkeley.edu/projects/embedded/eecsx44/lectures/Spring2013/modelica-dae-part-2.pdf )
171
171
for automatically performing this reduction to index 1. While this requires the
172
172
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,
174
175
then transform back to numerical code with ` ODEProblem ` , and solve with a
175
176
numerical solver. Let's try that out:
176
177
177
178
``` @example indexred
178
179
traced_sys = modelingtoolkitize(pendulum_prob)
179
- pendulum_sys = structural_simplify(dae_index_lowering( traced_sys) )
180
+ pendulum_sys = structural_simplify(traced_sys)
180
181
prob = ODEProblem(pendulum_sys, Pair[], tspan)
181
- sol = solve(prob, Rodas4 ())
182
+ sol = solve(prob, Rodas5P ())
182
183
183
184
using Plots
184
- plot(sol, vars = states (traced_sys))
185
+ plot(sol, vars = unknowns (traced_sys))
185
186
```
186
187
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
188
189
variables which are symbolically eliminated, or any variable reordering
189
190
done for enhanced parallelism/performance, still show up in the resulting
190
191
plot and the plot is shown in the same order as the original numerical
191
192
code.
192
193
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:
197
197
198
198
``` @example indexred
199
199
traced_sys = modelingtoolkitize(pendulum_prob)
200
200
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))
204
204
```
205
205
206
206
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.
209
208
210
209
# Parameter Identifiability in ODE Models
211
210
@@ -285,7 +284,7 @@ local_id_all = assess_local_identifiability(de, measured_quantities = measured_q
285
284
# 1
286
285
```
287
286
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.
289
288
290
289
Let's try to check specific parameters and their combinations
291
290
0 commit comments