While testing out different ODE solvers, I found that DP5() completely fails when given a simple SIR model (while other solvers handle it perfectly fine):
function SIR!(du,u,pars,t)
β, γ = pars
S, I, R = u
dS = -β*S*I
dI = β*S*I - γ*I
dR = γ*I
du .= [dS, dI, dR]
end
t_obs = collect(0:1.0:218)
prob = ODEProblem(SIR!, [0.99, 0.01, 0.0], (t_obs[1], t_obs[end]), [0.20, 0.15])
sol = solve(prob, DP5(), reltol = 1e-6, abstol = 1e-6, saveat = t_obs)
y = DataFrame(sol',[:S,:I,:R])
plot(t_obs, y."I")
This produces the following nonsensical plot:
I tried it with extreme low tolerances as well. Here’s what it looks like when rtol = 1e-22
and abstol = 1e-22
:
Much better, but still not at all good…
Tsit5() handles it fine though:
Any idea what’s going on here? I thought DP5 was quite robust.