# Passing along data from one time step to the next using DifferentialEquations.jl

I am using DifferentialEquations.jl to solve an ODE of the form \frac{d\boldsymbol{M}}{dt} = \boldsymbol{f}(\boldsymbol{M}), where \boldsymbol{M} = [M_1, ..., M_k]^T, and \boldsymbol{f} = [f_1(\boldsymbol{M}), ..., f_k(\boldsymbol{M})]^T
Without going into the weeds of how exactly the right-hand side, \boldsymbol{f}(\boldsymbol{M}), is computed, let me just say that it involves solving a nonlinear system of equations. At each time step t, that system of equations uses the current state of the solution \boldsymbol{M} to determine a vector of unknowns \boldsymbol{x}, which in turn is needed to compute \boldsymbol{f}(\boldsymbol{M}).

To solve that system of equations it would be very useful to have access to the unknowns \boldsymbol{x} that were computed in the previous time step - they would be a good initial guess for solving the system of equations at the current time step.

Is there a way to achieve what I want, i.e., to pass \boldsymbol{x} to the next time step for use in the evaluation of \boldsymbol{f}?

If your problem is like Mu’=f(u), then you might want to use a mass matrix instead since that doesn’t require an extra nonlinear solve. Otherwise, you can use the parameters to hold a cache of the values, and then use those the values from in the parameters as the guess.

1 Like