I am solving a stochastic differential equation with a ContinuousCallback. Every time the continuous callback is activated, I modify my state vector discontinuously.
All the randomness comes from a phase, which follows a simple Wiener process, i.e., the phase is not coupled to the remaining variables of the differential equation.
Nonetheless, if I use the default tolerances, I sometimes observe a discontinuous change in the phase when the ContinuousCallback is activated:
When I decrease the tolerances, I don’t see these spikes anymore. Nonetheless, this seems like a strange behavior.
Here is a snippet of my code:
function jump_condition_func(slv)
return function (u, t, integrator)
jump_condition(u, t, integrator, slv)
end
end
function project_func!(slv, sys)
return function (integrator)
project!(integrator, slv, sys)
end
end
jump_cb = ContinuousCallback(
jump_condition_func(slv),
project_func!(slv, sys),
save_positions = (true, true),
)
prob = SDEProblem(eoms!, noise!, u₀, tspan, p)
sol = SDE.solve(
prob,
SDE.SRIW1(),
abstol = slv.abstol,
reltol = slv.reltol,
callback = jump_cb,
dtmax = slv.dtmax,
maxiters = slv.maxiters,
saveat = slv.saveat,
)
My questions are:
- Why does this happen? Is it because I save the dynamics before and after the jump?
- Can one even use a
ContinuousCallbackin combination with SDE solvers or does that lead to unexpected behavior? I know that there is also the option of using a jump diffusion process - is that preferred?
