From here:
- Double check if you’re doing anything that violates assumptions of being an ODE. As an ODE, the right-hand side
f
function should always give you the same result:u' = f(u,p,t)
needs to be uniquely defined. These issues are just fundamental to the mathematics: if you do these things inf
, thenf
no longer defines an ODE so of course it cannot be solved!- If you put randomness into
f
, then the adaptivity will think your ODE is being solved at a high error because the derivative keeps changing, and therefore it will fail and hitdtmin
trying to reduce the randomness to zero (if you do need randomness, use an SDE or RODE solver).- If your
f
function is modifyingu
, then callingf
with different stepsizes is not deterministic and the solver is likely to fail. If you need to do this, you should be using a callback.- If your
f
function is caching values from a previous step, just think about what this means. If you changedt
, then you’re changingf
. In that sense,u'
is no longer defined since it’s now dependent on how it’s being solved! Even worse, adaptive ODE solvers do not always move forwards in time: sometimes they tryt + dt1
before tryingt + dt2
and choosing what to do. So if you’re assuming that the cached values are from the last step, that’s not actually the case: those values can be coming from a fake (too incorrect according to error estimates) future!