Skip to content

Commit fd65ee5

Browse files
authored
Update ODE solver to use Tsit5 method
1 parent f4e73ca commit fd65ee5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/src/symbolic_ude_tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ eqs = [D(X) ~ v * (Y^n) / (K^n + Y^n) - d*X
1919
Next, we simulate our model for a true parameter set (which we wish to recover).
2020

2121
```@example symbolic_ude
22-
using OrdinaryDiffEqDefault, Plots
22+
using OrdinaryDiffEqTsit5, Plots
2323
u0 = [X => 2.0, Y => 0.1]
2424
ps_true = [v => 1.1, K => 2.0, n => 3.0, d => 0.5]
2525
sim_cond = [u0; ps_true]
2626
tend = 45.0
2727
oprob_true = ODEProblem(xy_model, sim_cond, (0.0, tend))
28-
sol_true = solve(oprob_true)
28+
sol_true = solve(oprob_true, Tsit5())
2929
plot(sol_true; lw = 6, idxs = [X, Y])
3030
```
3131

@@ -77,7 +77,7 @@ We can now fit our UDE model (including the neural network and the parameter d)
7777
function loss(ps, (oprob_base, set_ps, sample_t, sample_X, sample_Y))
7878
p = set_ps(oprob_base, ps)
7979
new_oprob = remake(oprob_base; p)
80-
new_osol = solve(new_oprob; saveat = sample_t, verbose = false, maxiters = 10000)
80+
new_osol = solve(new_oprob, Tsit5(); saveat = sample_t, verbose = false, maxiters = 10000)
8181
SciMLBase.successful_retcode(new_osol) || return Inf # Simulation failed -> Inf loss.
8282
x_error = sum((x_sim - x_data)^2 for (x_sim, x_data) in zip(new_osol[X], sample_X))
8383
y_error = sum((y_sim - y_data)^2 for (y_sim, y_data) in zip(new_osol[Y], sample_Y))
@@ -108,7 +108,7 @@ By plotting a simulation from our fitted UDE, we can confirm that it can reprodu
108108

109109
```@example symbolic_ude
110110
oprob_fitted = remake(oprob_base; p = set_ps(oprob_base, opt_sol.u))
111-
sol_fitted = solve(oprob_fitted)
111+
sol_fitted = solve(oprob_fitted, Tsit5())
112112
plot!(sol_true; lw = 4, la = 0.7, linestyle = :dash, idxs = [X, Y], color = [:blue :red],
113113
label = ["X (UDE)" "Y (UDE)"])
114114
```

0 commit comments

Comments
 (0)