I have a simple model, which I am trying to simulate, however, I am getting
┌ 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:
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;
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:
using Plots
plot(sol)
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:
plot(sol.t[2:end],sol.t[2:end]-sol.t[1:end-1])
Finally, if I try fixing the stepsize, it works well, even for rather large dt
s:
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:
using Plots
plot(sol)
The output of
using Pkg
Pkg.status()
is
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?