Skip to content

Commit fc6828d

Browse files
Fix the DAE example
1 parent b99ed1f commit fc6828d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/src/tutorials/dae.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,20 @@ Let's build two different ODE problems, and check how well we can solve each:
118118
prob_index3 = ODEProblem(complete(traced_sys), Pair[], tspan)
119119
prob_index1 = ODEProblem(simplified_sys, Pair[], tspan)
120120
121-
sol3 = solve(prob_index3, EK1())
122-
sol1 = solve(prob_index1, EK1())
121+
sol3 = solve(prob_index3, EK1(), abstol=1e-7)
122+
sol1 = solve(prob_index1, EK1(), abstol=1e-7)
123123
124124
truesol = solve(prob_index1, Rodas4(), abstol=1e-10, reltol=1e-10)
125125
126126
sol1_final_error = norm(sol1.u[end] - truesol.u[end])
127127
sol1_f_evals = sol1.stats.nf
128-
sol3_final_error = norm(sol3.u[end] - truesol.u[end])
128+
perm = [findfirst(x -> x === s, unknowns(traced_sys)) for s in unknowns(simplified_sys)]
129+
sol3_final_error = norm(sol3.u[end][perm] - truesol.u[end])
129130
sol3_f_evals = sol3.stats.nf
130131
@info "Results" sol1_final_error sol1_f_evals sol3_final_error sol3_f_evals
131132
```
132133

133-
The error for the index-1 DAE solve is _much_ lower.
134+
The error for the index-1 DAE solve is quite a bit lower.
134135
Thus it seems that, even if the index-3 DAE could also be solved directly, index lowering might still be beneficial when solving DAEs with the `EK1`!
135136

136137

0 commit comments

Comments
 (0)