Regarding to solving an ordinary differential equation f(u, t) with OrdinaryDiffEq.jl. Is it possible to store time steps as times and coefficients as coeffs so that one can replay the integration as

for k=1:K
u += coeffs[k] * f(u, times[k])
end

The reason I want to do this is to combine it with optimal checkpointing algorithm in TreeverseAlgorithm.jl so that I can differentiate large scale ODE solvers in a quantum emulator. If there is a better solution, that would be great.

UPDATE:
Just notice it might be impossible to only record times and coeffs unless the integrator is the simplest Euclidean one. But I am still interested to know if there is an easy way to record the steps or implement checkpointing algorithms.

Thanks for your prompt reply, but I forgot to mention that my program can not afford saving u in every step, because the memory cost can be huge. This is why I seek for optimal checkpointing to avoid storing every state. It is more like Seismic or fluid simulation. BTW, I found the APIs get_proposed_dt and step! in the integrator interface, Integrator Interface · DifferentialEquations.jl , which might satisfy my need.

I think using a discrete callback to grab the t’s is probably a better idea, but yeah you can also use the integrator interface if you need to control every step in a very specific way.