Greetings,
Is it possible to get the The Izhikevich Model to work with ContinuousCallback as the DiscreteCallback is not accurate near the zero-crossing.
# function reset!(integrator)
# @show integrator.u[1], integrator.t
# ...
(integrator.u[1], integrator.t) = (34.809473582040724, 2.596486286807452)
(integrator.u[1], integrator.t) = (32.229505727923915, 4.047660542741739)
(integrator.u[1], integrator.t) = (35.37791747113174, 5.655299412290314)
(integrator.u[1], integrator.t) = (36.029091214255416, 7.463878908313585)
(integrator.u[1], integrator.t) = (36.72604067495955, 9.567043050470012)
(integrator.u[1], integrator.t) = (31.099456800827046, 12.166997959461202)
...
I tried to change the parameters in this call:
cb =ContinuousCallback(thr, reset!;
idxs = 1,
interp_points = 2,
abstol = eps(), reltol = 0,
)
but i always get:
┌ Warning: dt(5.684341886080802e-14) <= dtmin(5.684341886080802e-14) at t=2.8496719219500215, and step error estimate = 52.62708532815521. Aborting. There is either an error in your model specification or the true solution is unstable.
Here is the full code:
using DifferentialEquations
function izh!(du, u, p, t)
a, b, c, d, I = p
du[1] = 0.04 * u[1]^2 + 5.0 * u[1] + 140.0 - u[2] + I
du[2] = a * (b * u[1] - u[2])
end
function thr(u, t, integrator)
integrator.u[1] -30.0
end
function reset!(integrator)
@show integrator.u[1], integrator.t
integrator.u[1] = integrator.p[3]
integrator.u[2] += integrator.p[4]
end
cb =ContinuousCallback(thr, reset!;
idxs = 1,
interp_points = 2,
abstol = eps(), reltol = 0,
)
solvers=[Tsit5()#= ,BS3() ,Rodas5(), ABDF2() , QNDF2() , Trapezoid() , TRBDF2() , Rosenbrock23() =#]
for alg in solvers
p = [0.02, 0.2, -50, 2.0, 10.0]
u0 = [-60.0, p[2] * -60.0]
tspan = (0.0, 300)
prob = ODEProblem(izh!, u0, tspan, p , callback = cb)
sol = solve(prob,alg,reltol=1e-3,abstol=1e-3);
end
many thanks!



