Interpolation

Often you will want to get the solution at a specific time \(t_o\), which is probably different to the internal timesteps chosen by the solver. To do this, you can use the step method to first step the solver forward in time until you are just beyond \(t_o\), and then use the interpolate method to get the solution at \(t_o\).

use crate::{T, V};
use diffsol::{OdeEquations, OdeSolverMethod};

pub fn solve_interpolate<'a, Solver, Eqn>(solver: &mut Solver)
where
    Solver: OdeSolverMethod<'a, Eqn>,
    Eqn: OdeEquations<V = V, T = T> + 'a,
{
    let t_o = 10.0;
    while solver.state().t < t_o {
        solver.step().unwrap();
    }
    let _soln = solver.interpolate(t_o).unwrap();
}