Struct Bdf

Source
pub struct Bdf<'a, Eqn: OdeEquationsImplicit, Nls: NonLinearSolver<Eqn::M>, M: DenseMatrix<T = Eqn::T, V = Eqn::V, C = Eqn::C> = <<Eqn as Op>::V as DefaultDenseMatrix>::M, AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn> = NoAug<Eqn>>
where Eqn::V: DefaultDenseMatrix,
{ /* private fields */ }
Expand description

Implements a Backward Difference formula (BDF) implicit multistep integrator.

The basic algorithm is derived in [1]. This particular implementation follows that implemented in the Matlab routine ode15s described in [2] and the SciPy implementation /[3/], which features the NDF formulas for improved stability with associated differences in the error constants, and calculates the jacobian at J(t_{n+1}, y^0_{n+1}). This implementation was based on that implemented in the SciPy library [3], which also mainly follows [2] but uses the more standard Jacobian update.

§References

[1] Byrne, G. D., & Hindmarsh, A. C. (1975). A polyalgorithm for the numerical solution of ordinary differential equations. ACM Transactions on Mathematical Software (TOMS), 1(1), 71-96. [2] Shampine, L. F., & Reichelt, M. W. (1997). The matlab ode suite. SIAM journal on scientific computing, 18(1), 1-22. [3] Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T., Cournapeau, D., … & Van Mulbregt, P. (2020). SciPy 1.0: fundamental algorithms for scientific computing in Python. Nature methods, 17(3), 261-272.

Implementations§

Source§

impl<'a, M, Eqn, Nls, AugmentedEqn> Bdf<'a, Eqn, Nls, M, AugmentedEqn>
where AugmentedEqn: AugmentedOdeEquations<Eqn> + OdeEquationsImplicit, Eqn: OdeEquationsImplicit, Eqn::V: DefaultDenseMatrix, M: DenseMatrix<T = Eqn::T, V = Eqn::V, C = Eqn::C>, for<'b> &'b Eqn::V: VectorRef<Eqn::V>, for<'b> &'b Eqn::M: MatrixRef<Eqn::M>, Nls: NonLinearSolver<Eqn::M>,

Source

pub fn new( problem: &'a OdeSolverProblem<Eqn>, state: BdfState<Eqn::V, M>, nonlinear_solver: Nls, ) -> Result<Self, DiffsolError>

Source

pub fn new_augmented( state: BdfState<Eqn::V, M>, problem: &'a OdeSolverProblem<Eqn>, augmented_eqn: AugmentedEqn, nonlinear_solver: Nls, ) -> Result<Self, DiffsolError>

Source

pub fn get_statistics(&self) -> &BdfStatistics

Trait Implementations§

Source§

impl<'a, M, Eqn, Nls, AugEqn> AugmentedOdeSolverMethod<'a, Eqn, AugEqn> for Bdf<'a, Eqn, Nls, M, AugEqn>
where Eqn: OdeEquationsImplicit, AugEqn: AugmentedOdeEquationsImplicit<Eqn>, M: DenseMatrix<T = Eqn::T, V = Eqn::V, C = Eqn::C>, for<'b> &'b Eqn::V: VectorRef<Eqn::V>, for<'b> &'b Eqn::M: MatrixRef<Eqn::M>, Nls: NonLinearSolver<Eqn::M>, Eqn::V: DefaultDenseMatrix<T = Eqn::T>,

Source§

impl<M, Eqn, Nls, AugmentedEqn> Clone for Bdf<'_, Eqn, Nls, M, AugmentedEqn>
where Eqn: OdeEquationsImplicit, Nls: NonLinearSolver<Eqn::M>, M: DenseMatrix<T = Eqn::T, V = Eqn::V, C = Eqn::C>, AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn>, Eqn::V: DefaultDenseMatrix,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, M, Eqn, Nls, AugmentedEqn> OdeSolverMethod<'a, Eqn> for Bdf<'a, Eqn, Nls, M, AugmentedEqn>
where Eqn: OdeEquationsImplicit, AugmentedEqn: AugmentedOdeEquations<Eqn> + OdeEquationsImplicit, M: DenseMatrix<T = Eqn::T, V = Eqn::V, C = Eqn::C>, Eqn::V: DefaultDenseMatrix, Nls: NonLinearSolver<Eqn::M>, for<'b> &'b Eqn::V: VectorRef<Eqn::V>, for<'b> &'b Eqn::M: MatrixRef<Eqn::M>,

Source§

type State = BdfState<<Eqn as Op>::V, M>

Source§

fn order(&self) -> usize

Get the current order of accuracy of the solver (e.g. explict euler method is first-order)
Source§

fn jacobian(&self) -> Option<Ref<'_, Eqn::M>>

Returns the current jacobian matrix of the solver, if it has one Note that this will force a full recalculation of the Jacobian.
Source§

fn mass(&self) -> Option<Ref<'_, Eqn::M>>

Returns the current mass matrix of the solver, if it has one Note that this will force a full recalculation of the mass matrix.
Source§

fn set_state(&mut self, state: Self::State)

Replace the current state of the solver with a new state.
Source§

fn interpolate(&self, t: Eqn::T) -> Result<Eqn::V, DiffsolError>

Interpolate the solution at a given time. This time should be between the current time and the last solver time step
Source§

fn interpolate_out(&self, t: Eqn::T) -> Result<Eqn::V, DiffsolError>

Interpolate the integral of the output function at a given time. This time should be between the current time and the last solver time step
Source§

fn interpolate_sens( &self, t: <Eqn as Op>::T, ) -> Result<Vec<Eqn::V>, DiffsolError>

Interpolate the sensitivity vectors at a given time. This time should be between the current time and the last solver time step
Source§

fn problem(&self) -> &'a OdeSolverProblem<Eqn>

Get the current problem
Source§

fn state(&self) -> StateRef<'_, Eqn::V>

Get the current state of the solver
Source§

fn into_state(self) -> BdfState<Eqn::V, M>

Take the current state of the solver, if it exists, returning it to the user. This is useful if you want to use this state in another solver or problem. Note that this will unset the current problem and solver state, so you will need to call set_problem again before calling step or solve.
Source§

fn state_mut(&mut self) -> StateRefMut<'_, Eqn::V>

Get a mutable reference to the current state of the solver Note that calling this will cause the next call to step to perform some reinitialisation to take into account the mutated state, this could be expensive for multi-step methods.
Source§

fn checkpoint(&mut self) -> Self::State

Take a checkpoint of the current state of the solver, returning it to the user. This is useful if you want to use this state in another solver or problem but want to keep this solver active. If you don’t need to use this solver again, you can use take_state instead. Note that this will force a reinitialisation of the internal Jacobian for the solver, if it has one.
Source§

fn step(&mut self) -> Result<OdeSolverStopReason<Eqn::T>, DiffsolError>

Step the solution forward by one step, altering the internal state of the solver. The return value is a Result containing the reason for stopping the solver, possible reasons are: Read more
Source§

fn set_stop_time(&mut self, tstop: <Eqn as Op>::T) -> Result<(), DiffsolError>

Set a stop time for the solver. The solver will stop when the internal time reaches this time. Once it stops, the stop time is unset. If tstop is at or before the current internal time, an error is returned.
Source§

fn solve( &mut self, final_time: Eqn::T, ) -> Result<(<Eqn::V as DefaultDenseMatrix>::M, Vec<Eqn::T>), DiffsolError>
where Eqn::V: DefaultDenseMatrix, Self: Sized,

Using the provided state, solve the problem up to time final_time Returns a Vec of solution values at timepoints chosen by the solver. After the solver has finished, the internal state of the solver is at time final_time.
Source§

fn solve_dense( &mut self, t_eval: &[Eqn::T], ) -> Result<<Eqn::V as DefaultDenseMatrix>::M, DiffsolError>
where Eqn::V: DefaultDenseMatrix, Self: Sized,

Using the provided state, solve the problem up to time t_eval[t_eval.len()-1] Returns a Vec of solution values at timepoints given by t_eval. After the solver has finished, the internal state of the solver is at time t_eval[t_eval.len()-1].
Source§

fn solve_with_checkpointing( &mut self, final_time: Eqn::T, max_steps_between_checkpoints: Option<usize>, ) -> Result<(Checkpointing<'a, Eqn, Self>, <Eqn::V as DefaultDenseMatrix>::M, Vec<Eqn::T>), DiffsolError>
where Eqn::V: DefaultDenseMatrix, Self: Sized,

Source§

fn solve_dense_with_checkpointing( &mut self, t_eval: &[Eqn::T], max_steps_between_checkpoints: Option<usize>, ) -> Result<(Checkpointing<'a, Eqn, Self>, <Eqn::V as DefaultDenseMatrix>::M), DiffsolError>
where Eqn::V: DefaultDenseMatrix, Self: Sized,

Solve the problem and write out the solution at the given timepoints, using checkpointing so that the solution can be interpolated at any timepoint. See Self::solve_dense for a similar method that does not use checkpointing.

Auto Trait Implementations§

§

impl<'a, Eqn, Nls, M = <<Eqn as Op>::V as DefaultDenseMatrix>::M, AugmentedEqn = NoAug<Eqn>> !Freeze for Bdf<'a, Eqn, Nls, M, AugmentedEqn>

§

impl<'a, Eqn, Nls, M = <<Eqn as Op>::V as DefaultDenseMatrix>::M, AugmentedEqn = NoAug<Eqn>> !RefUnwindSafe for Bdf<'a, Eqn, Nls, M, AugmentedEqn>

§

impl<'a, Eqn, Nls, M, AugmentedEqn> Send for Bdf<'a, Eqn, Nls, M, AugmentedEqn>
where <Eqn as Op>::V: Sized + Send + Sync, Nls: Send, M: Send, Eqn: Sync, AugmentedEqn: Send, <Eqn as Op>::M: Send, <<Eqn as Op>::M as Matrix>::Sparsity: Send,

§

impl<'a, Eqn, Nls, M = <<Eqn as Op>::V as DefaultDenseMatrix>::M, AugmentedEqn = NoAug<Eqn>> !Sync for Bdf<'a, Eqn, Nls, M, AugmentedEqn>

§

impl<'a, Eqn, Nls, M, AugmentedEqn> Unpin for Bdf<'a, Eqn, Nls, M, AugmentedEqn>
where <Eqn as Op>::V: Sized + Unpin, Nls: Unpin, <Eqn as Op>::T: Unpin, M: Unpin, AugmentedEqn: Unpin, <<Eqn as Op>::M as Matrix>::Sparsity: Unpin, <Eqn as Op>::M: Unpin,

§

impl<'a, Eqn, Nls, M, AugmentedEqn> UnwindSafe for Bdf<'a, Eqn, Nls, M, AugmentedEqn>
where <Eqn as Op>::V: Sized + UnwindSafe + RefUnwindSafe, Nls: UnwindSafe, <Eqn as Op>::T: UnwindSafe + RefUnwindSafe, M: UnwindSafe, Eqn: RefUnwindSafe, AugmentedEqn: UnwindSafe, <<Eqn as Op>::M as Matrix>::Sparsity: UnwindSafe, <Eqn as Op>::M: UnwindSafe,

Blanket Implementations§

Source§

impl<'a, Eqn, S, Solver> AdjointOdeSolverMethod<'a, Eqn, S> for Solver
where Eqn: OdeEquationsImplicitAdjoint + 'a, S: OdeSolverMethod<'a, Eqn>, Solver: AugmentedOdeSolverMethod<'a, Eqn, AdjointEquations<'a, Eqn, S>>,

Source§

fn solve_adjoint_backwards_pass( self, t_eval: &[Eqn::T], dgdu_eval: &[&<Eqn::V as DefaultDenseMatrix>::M], ) -> Result<Self::State, DiffsolError>
where Eqn::V: DefaultDenseMatrix, Eqn::M: DefaultSolver,

Backwards pass for adjoint sensitivity analysis Read more
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<'a, M, Eqn> SensitivitiesOdeSolverMethod<'a, Eqn> for M
where M: AugmentedOdeSolverMethod<'a, Eqn, SensEquations<'a, Eqn>>, Eqn: OdeEquationsImplicitSens + 'a,

Source§

fn solve_dense_sensitivities( &mut self, t_eval: &[Eqn::T], ) -> Result<(<Eqn::V as DefaultDenseMatrix>::M, Vec<<Eqn::V as DefaultDenseMatrix>::M>), DiffsolError>

Using the provided state, solve the problem up to time t_eval[t_eval.len()-1] Returns a tuple (y, sens), where y is a dense matrix of solution values at timepoints given by t_eval, and sens is a Vec of dense matrices, the ith element of the Vec are the the sensitivities with respect to the ith parameter. After the solver has finished, the internal state of the solver is at time t_eval[t_eval.len()-1].
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V