Hello,
I have a MWE here for when I solve a ODE with callback two times in the same script , it solves the first one case expected and does not for the second one.
using DifferentialEquations, Plots, OrdinaryDiffEq
function du!(du,u,p,t)
du .= -p[1]*ones(length(u))
end
function condition1(u, t, integrator) # Event when condition(u,t,integrator) == 0
u[1]
end
function floor_aff1(int)
int.p[1] = 0
end
function condition2(u, t, integrator) # Event when condition(u,t,integrator) == 0
u[1]
end
function floor_aff2(int)
int.p[1] = 0
end
u0 = [1.0]
tspan = (0.0,2.0)
p = [1.0]
prob = ODEProblem(du!,u0,tspan,p)
cb = ContinuousCallback(condition1, floor_aff1)
sol = solve(prob, Tsit5(), callback = cb)
plot(sol,label = "Case 1")
prob2 = ODEProblem(du!,u0,tspan,p)
cb2 = ContinuousCallback(condition2, floor_aff2)
sol2 = solve(prob2, Tsit5(), callback = cb2)
plot!(sol2,label = "Case 2")
Plot:
both should have the exact same solution. I have also renamed the callback functions so that there is no overlap.