Skip to main content

Solution

Struct Solution 

Source
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>

Source

pub fn is_complete(&self) -> bool

Source

pub fn truncate<Eqn>( &mut self, problem: &OdeSolverProblem<Eqn>, state: StateRef<'_, V>, ) -> Result<(), DiffsolError>
where Eqn: OdeEquations<T = V::T, V = V, C = V::C>,

Source

pub fn truncate_sens<Eqn>( &mut self, problem: &OdeSolverProblem<Eqn>, state: StateRef<'_, V>, ) -> Result<(), DiffsolError>
where Eqn: OdeEquationsImplicitSens<T = V::T, V = V, C = V::C>,

Source

pub fn new(t_final: V::T) -> Self

Source

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>

§

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>

§

impl<V> UnwindSafe for Solution<V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.