rtqichen / torchdiffeq

Differentiable ODE solvers with full GPU support and O(1)-memory backpropagation.
MIT License
5.61k stars 930 forks source link

reuse solver object #232

Open florian98765 opened 1 year ago

florian98765 commented 1 year ago

Dear torchdiffeq Developers, Thanks a lot for this useful library. We started using odeint and odeint_adjoint for solving inverse magnetic problems in our opensource project magnum.np.

Our current design just performs one timestep after each other and in between the timesteps the control is returned to the user, where logging and other post processing tasks can be done. Thus, we would need an API which allows to reuse the solver object and perform multiple steps after each other.

Here is a small code snippet how we would like to use the code:

while state.t < 1e-9:
    llg.step(state, 1e-11)
    logger << state

Within llg.step we call odeint(f, [state.t, state.t+dt]).

Would it be possible to provide the missing interface?

thanks and best wishes Florian