I am using DifferentialEquations.jl to solve a system of ordinary differential equations (an ODEProblem) of the form du = f(u, p, t) where u is a vector.
One component of u, say u[1], is monotonically increasing over the integration time span (0, tf), with known initial and final values u1_0, u1_f.
How can I store the solution to the ODE on a uniform grid over the values of u[1], i.e. for u1_0:u1_step:u1_f, where u1_step is given in input?
Note that this will result in a non-uniform time grid due to the nonlinearity in the ODEs, and I am interested in extracting this time grid together with the values of the other components of u.
I thought about using a ContinuousCallback to store the values on the fly, or to store the dense solution and then search for the tk such that sol(tk)[1] % u1_step == 0.
As I am not interested in the actual value of u[1], but only in its increment between saved steps, I ended up defining the callback function as u[1] -u1_step == 0 and resetting u[1] to zero after every occurrence of the event.
But how would you implement a discrete callback? My understanding is that this only checks the condition at the end of each time step, and does not perform root finding within one integration step.