DifferentialEquations.jl icon indicating copy to clipboard operation
DifferentialEquations.jl copied to clipboard

`dt <= dtmin` when using two discrete callbacks

Open dcabecinhas opened this issue 5 years ago • 1 comments

The dt <= dtmin error occurs for different f and disappears if the callback periods are nudged a bit.

Error

julia> include("test.jl");
┌ Warning: dt <= dtmin. Aborting. There is either an error in your model specification or the true solution is unstable.
└ @ DiffEqBase ~/.julia/packages/DiffEqBase/T5smF/src/integrator_interface.jl:343

Code to reproduce

using DifferentialEquations

function f!(du,u,p,t) 
  du .= -1.01*u
end

u0 = rand(2)
tspan = (0.0,10.0)

function periodic!(integrator) end
cb = PeriodicCallback(periodic!, 0.02)

function periodic2!(integrator) end
cb2 = PeriodicCallback(periodic2!, 0.1)

prob = ODEProblem(f!,u0,tspan, callback = CallbackSet(cb, cb2))

sol = solve(prob)

dcabecinhas avatar Aug 07 '20 16:08 dcabecinhas

Yeah, this is because of floating point error stuff. 0.1 + 0.1 != 0.2, etc. It gets stuck at 0.3 because one of the tstops misses it by a floating point number. We need to just clump those callback calls.

ChrisRackauckas avatar Aug 08 '20 01:08 ChrisRackauckas