# Adaptive SDESolver yields "Warning: dt \<= dtmin. Aborting", unsure why, large non-adaptive dt works fine

**URL:** https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859
**Category:** Modelling & Simulations
**Tags:** diffeq, sde, differentialequation
**Created:** [April 1, 2022, 11:28am UTC](https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859 "2022-04-01T11:28:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)
#### Post date: [April 1, 2022, 11:28am UTC](https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859/1 "2022-04-01T11:28:40Z")

</div>

I have a simple model, which I am trying to simulate, however, I am getting

```julia
┌ Warning: dt <= dtmin. Aborting. There is either an error in your model specification or the true solution is unstable.
└ @ SciMLBase /home/SLCU/torkel.loman/.julia/packages/SciMLBase/GW7GW/src/integrator_interface.jl:345

```

errors. I am quite sure I run the same model like half a year/a year ago sometime, and it was all fine (but I have been unable to dig up a working example from then). Either way, if I try a large fixed dt it seems fine. Generally, I haven’t had problems with this combination of model/parameters, so am unsure what is going on.

MWE:

```julia
using StochasticDiffEq

function f(du,u,p,t)
    σ,A = u
    S,D,τ,v0,n,η = p
    du[1] = v0+(S*σ)^n/((S*σ)^n+(D*A)^n+1) - σ
    du[2] = (1/τ)*(σ-A)
end
function g(du,u,p,t)
    σ,A = u
    S,D,τ,v0,n,η = p
    du[1,1] = η*sqrt(v0+(S*σ)^n/((S*σ)^n+(D*A)^n+1))
    du[1,2] = -η*sqrt(σ)
    du[1,3] = 0
    du[1,4] = 0
    du[2,1] = 0
    du[2,2] = 0
    du[2,3] = η*sqrt((1/τ)*σ)
    du[2,4] = -η*sqrt((1/τ)*A)
end;

```

```julia
sprob = SDEProblem(f,g,[1.,1.],(0.,2000.),[5.0, 5.0, 0.1, 0.1, 3.0, 0.1],noise_rate_prototype=zeros(2,4))
sol = solve(sprob,ImplicitEM());

```

the solver fails pretty much independent of the seed. If I plot it:

```julia
using Plots
plot(sol)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/c/6/c6869475251d335d9b6417d683b6cc3964eb19fe.png)

the output looks normal, and nothing special happens when it crashes. I’m not sure if it is useful, but I can plot the `dt` over time:

```julia
plot(sol.t[2:end],sol.t[2:end]-sol.t[1:end-1])

```

![image](https://global.discourse-cdn.com/julialang/original/3X/d/7/d7c227ec74ca11d42d012ec943e7d33f02f1a2ef.png)

Finally, if I try fixing the stepsize, it works well, even for rather large `dt`s:

```julia
sprob = SDEProblem(f,g,[1.,1.],(0.,2000.),[5.0, 5.0, 0.1, 0.1, 3.0, 0.1],noise_rate_prototype=zeros(2,4))
sol = solve(sprob,ImplicitEM();adaptive=false,dt=0.25);

```

Finally, this output looks like:

```julia
using Plots
plot(sol)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/0/6/06c129239b22983be6508b5771ba693429828360.png)

The output of

```julia
using Pkg
Pkg.status()

```

is

```julia
      Status `~/Desktop/temporary_julia_environment/Project.toml`
  [91a5bcdd] Plots v1.27.4
  [789caeaf] StochasticDiffEq v6.46.0

```

and the Julia version 1.7.0.

Just clarifying the actual question: Why does the adaptive time-stepper failing, and is there some way to make it able to succesfully simulate this model?

---

<div class="post-metadata">

### Author: ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)
#### Post date: [April 1, 2022, 4:38pm UTC](https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859/2 "2022-04-01T16:38:31Z")

</div>

I am attempting to circumvent this by using `force_dtmin=true`, but am unsure whenever I am doing something potentially unwise…

---

<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: [April 3, 2022, 7:11am UTC](https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859/3 "2022-04-03T07:11:32Z")

</div>

While it can solve with a higher dt, is the error below the adaptive tolerance in a strong sense? Most likely it’s just due to not being able to hit the required tolerance.

---

<div class="post-metadata">

### Author: ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)
#### Post date: [April 4, 2022, 2:44pm UTC](https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859/4 "2022-04-04T14:44:16Z")

</div>

You are right, it seems to have to do with the error. If I add `abstol=1e-1` to the adaptive time-stepper it works without errors/warnings.

Just checking so that I know what is (probably going on): Basically, the solution is noisy. Even if the adaptive stepper tries to reduce the `dt` to keep the errors within the limits, the fluctuations are too much and it eventually fails. However, if I increase the error tolerance then the threshold is passed.

In the non-adaptive time-stepper, there’s a fixed `dt`, so it never actually checks the error, and this is never a problem. If I set my fixed `dt` too high, I get a

```julia
┌ Warning: Newton steps could not converge and algorithm is not adaptive. Use a lower dt.
└ @ SciMLBase /home/SLCU/torkel.loman/.julia/packages/SciMLBase/GW7GW/src/integrator_interface.jl:357

```

error, but that is a different phenomenon(?)

This is useful, I have never really paid much attention to the error (tolerance), but maybe this illustrates how it becomes important?

Thansk a lot!

---

<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: [April 4, 2022, 4:10pm UTC](https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859/5 "2022-04-04T16:10:31Z")

</div>

> [@Torkel](#):
>
> In the non-adaptive time-stepper, there’s a fixed `dt` , so it never actually checks the error, and this is never a problem. If I set my fixed `dt` too high, I get a

that’s different, that’s the solution diverging.

The error is measured in strong error as well, so it’s not necessarily the error of the average.

---

<div class="post-metadata">

### Author: ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)
#### Post date: [April 4, 2022, 4:20pm UTC](https://discourse.julialang.org/t/adaptive-sdesolver-yields-warning-dt-dtmin-aborting-unsure-why-large-non-adaptive-dt-works-fine/78859/6 "2022-04-04T16:20:26Z")

</div>

Thanks, I think I get what is going on, this has been really useful 👍
