pub struct Solution<V: DefaultDenseMatrix> {
pub ts: Vec<V::T>,
pub ys: <V as DefaultDenseMatrix>::M,
pub y_sens: Vec<<V as DefaultDenseMatrix>::M>,
pub stop_reason: Option<OdeSolverStopReason<V::T>>,
/* private fields */
}Expand description
Stores ODE solve output and continuation state for staged integrations.
A Solution can be reused across multiple calls to
crate::OdeSolverMethod::solve_soln, allowing you to stop, inspect
stop_reason, update model parameters or state, and then continue from where
you left off.
Use Solution::new to collect adaptive internal timesteps up to a final
time, or Solution::new_dense to fill user-provided evaluation times.
§Example
use diffsol::{
OdeBuilder, OdeSolverMethod, Solution, NalgebraLU, NalgebraMat,
NalgebraVec,
};
type M = NalgebraMat<f64>;
type V = NalgebraVec<f64>;
type LS = NalgebraLU<f64>;
let problem = OdeBuilder::<M>::new()
.p([0.1, 1.0])
.rhs_implicit(
|x, p, _t, y| {
y[0] = -p[0] * x[0];
},
|_x, p, _t, v, y| {
y[0] = -p[0] * v[0];
},
)
.init(|p, _t, y| {
y[0] = p[1];
}, 1)
.build()
.unwrap();
let mut state = problem.bdf_state::<LS>().unwrap();
let mut soln = Solution::<V>::new(1.0_f64);
while !soln.is_complete() {
state = problem
.bdf_solver::<LS>(state)
.unwrap()
.solve_soln(&mut soln)
.unwrap()
.into_state();
}
assert!(soln.is_complete());
assert!(!soln.ts.is_empty());Fields§
§ts: Vec<V::T>§ys: <V as DefaultDenseMatrix>::M§y_sens: Vec<<V as DefaultDenseMatrix>::M>§stop_reason: Option<OdeSolverStopReason<V::T>>Implementations§
Source§impl<V: DefaultDenseMatrix> Solution<V>
impl<V: DefaultDenseMatrix> Solution<V>
pub fn is_complete(&self) -> bool
pub fn truncate<Eqn>( &mut self, problem: &OdeSolverProblem<Eqn>, state: StateRef<'_, V>, ) -> Result<(), DiffsolError>
pub fn truncate_sens<Eqn>( &mut self, problem: &OdeSolverProblem<Eqn>, state: StateRef<'_, V>, ) -> Result<(), DiffsolError>
pub fn new(t_final: V::T) -> Self
pub fn new_dense(t_evals: Vec<V::T>) -> Result<Self, DiffsolError>
Auto Trait Implementations§
impl<V> Forget for Solution<V>
impl<V> Freeze for Solution<V>where
Vec<<V as VectorCommon>::T>: Freeze,
<V as DefaultDenseMatrix>::M: Freeze,
Vec<<V as DefaultDenseMatrix>::M>: Freeze,
Option<OdeSolverStopReason<<V as VectorCommon>::T>>: Freeze,
V: Freeze,
SolutionMode<<V as VectorCommon>::T>: Freeze,
impl<V> RefUnwindSafe for Solution<V>where
Vec<<V as VectorCommon>::T>: RefUnwindSafe,
<V as DefaultDenseMatrix>::M: RefUnwindSafe,
Vec<<V as DefaultDenseMatrix>::M>: RefUnwindSafe,
Option<OdeSolverStopReason<<V as VectorCommon>::T>>: RefUnwindSafe,
V: RefUnwindSafe,
SolutionMode<<V as VectorCommon>::T>: RefUnwindSafe,
impl<V> Send for Solution<V>where
Vec<<V as VectorCommon>::T>: Send,
<V as DefaultDenseMatrix>::M: Send,
Vec<<V as DefaultDenseMatrix>::M>: Send,
Option<OdeSolverStopReason<<V as VectorCommon>::T>>: Send,
SolutionMode<<V as VectorCommon>::T>: Send,
impl<V> Sync for Solution<V>where
Vec<<V as VectorCommon>::T>: Sync,
<V as DefaultDenseMatrix>::M: Sync,
Vec<<V as DefaultDenseMatrix>::M>: Sync,
Option<OdeSolverStopReason<<V as VectorCommon>::T>>: Sync,
V: Sync,
SolutionMode<<V as VectorCommon>::T>: Sync,
impl<V> Unpin for Solution<V>where
Vec<<V as VectorCommon>::T>: Unpin,
<V as DefaultDenseMatrix>::M: Unpin,
Vec<<V as DefaultDenseMatrix>::M>: Unpin,
Option<OdeSolverStopReason<<V as VectorCommon>::T>>: Unpin,
V: Unpin,
SolutionMode<<V as VectorCommon>::T>: Unpin,
impl<V> UnsafeUnpin for Solution<V>where
Vec<<V as VectorCommon>::T>: UnsafeUnpin,
<V as DefaultDenseMatrix>::M: UnsafeUnpin,
Vec<<V as DefaultDenseMatrix>::M>: UnsafeUnpin,
Option<OdeSolverStopReason<<V as VectorCommon>::T>>: UnsafeUnpin,
V: UnsafeUnpin,
SolutionMode<<V as VectorCommon>::T>: UnsafeUnpin,
impl<V> UnwindSafe for Solution<V>where
Vec<<V as VectorCommon>::T>: UnwindSafe,
<V as DefaultDenseMatrix>::M: UnwindSafe,
Vec<<V as DefaultDenseMatrix>::M>: UnwindSafe,
Option<OdeSolverStopReason<<V as VectorCommon>::T>>: UnwindSafe,
V: UnwindSafe,
SolutionMode<<V as VectorCommon>::T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.