# DP5() algorithm failing to solve simple SIR problem?

**URL:** <https://discourse.julialang.org/t/dp5-algorithm-failing-to-solve-simple-sir-problem/64835>\
**Category:** Numerics\
**Tags:** diffeq, numerics\
**Created:** [July 17, 2021, 10:59pm UTC](https://discourse.julialang.org/t/dp5-algorithm-failing-to-solve-simple-sir-problem/64835 "2021-07-17T22:59:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Barmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael_barmann/32/20389_2.png) [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)\
**Post date:** [July 17, 2021, 10:59pm UTC](https://discourse.julialang.org/t/dp5-algorithm-failing-to-solve-simple-sir-problem/64835/1 "2021-07-17T22:59:18Z")

</div>

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):

```julia
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:  
 ![DP5_fail](https://global.discourse-cdn.com/julialang/original/3X/3/b/3ba19f625bec0dabc01324ef8cab12ca649fb1b3.png)

I tried it with extreme low tolerances as well. Here’s what it looks like when `rtol = 1e-22` and `abstol = 1e-22`:  
 ![DP5_fail2](https://global.discourse-cdn.com/julialang/original/3X/8/1/8180678012f9983fc16a2fe1749eff8d8d8be76a.png)

Much better, but still not at all good…

Tsit5() handles it fine though:  
 ![DP5_Tsit](https://global.discourse-cdn.com/julialang/original/3X/9/c/9c6151127537957801330cf2fac0718a20c00456.png)

Any idea what’s going on here? I thought DP5 was quite robust.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 17, 2021, 11:34pm UTC](https://discourse.julialang.org/t/dp5-algorithm-failing-to-solve-simple-sir-problem/64835/2 "2021-07-17T23:34:05Z")

</div>

This is more of an issue than a Discourse post. There was a default that was somehow being set incorrectly which caused this. It’s a rather specific case so it wasn’t caught in the other tests. It’s fixed in [Fix calck default and add a test for DP5 only saveat interpolation by ChrisRackauckas · Pull Request #1450 · SciML/OrdinaryDiffEq.jl · GitHub](https://github.com/SciML/OrdinaryDiffEq.jl/pull/1450) and should get merged and tagged by tomorrow, and this has been turned into a test. Thanks for sharing.
