Skip to content

Question - ODE State at time of event #77

Closed Answered by martinjrobins
JEMH asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @JEMH, you can use OdeSolverMethod::interpolate to get the state vector at the time of the event (i.e. t_root).

If you are happy then continuing the integration from the internal time of the solver, then great :). However, if you wanted to restart from exactly the time of the event, then you would have to mutate the state (using OdeSolverMethod::state_mut) and set it to the interpolated state.

Perhaps something like this (I havn't tried compiling/running this!)

let t = loop {
    match solver.step() {
        Ok(OdeSolverStopReason::InternalTimestep) => continue,
        Ok(OdeSolverStopReason::TstopReached) => panic!("We didn't set a stop time"),
        Ok(OdeSolverStopReason::RootFound

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by martinjrobins
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #74 on July 19, 2024 08:54.