pub trait OdeSolverState<V: Vector>: Clone + Sized {
Show 18 methods
// Required methods
fn as_ref(&self) -> StateRef<'_, V>;
fn as_mut(&mut self) -> StateRefMut<'_, V>;
fn into_common(self) -> StateCommon<V>;
fn new_from_common(state: StateCommon<V>) -> Self;
fn set_problem<Eqn: OdeEquations>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
) -> Result<(), DiffsolError>;
fn set_augmented_problem<Eqn: OdeEquations, AugmentedEqn: AugmentedOdeEquations<Eqn>>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &AugmentedEqn,
) -> Result<(), DiffsolError>;
// Provided methods
fn check_consistent_with_problem<Eqn: OdeEquations>(
&self,
problem: &OdeSolverProblem<Eqn>,
) -> Result<(), DiffsolError> { ... }
fn check_sens_consistent_with_problem<Eqn: OdeEquations, AugmentedEqn: AugmentedOdeEquations<Eqn>>(
&self,
problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &AugmentedEqn,
) -> Result<(), DiffsolError> { ... }
fn new<Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
where Eqn: OdeEquations<T = V::T, V = V, C = V::C> { ... }
fn new_and_consistent<LS, Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
where Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
LS: LinearSolver<Eqn::M> { ... }
fn new_with_sensitivities<Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
where Eqn: OdeEquationsImplicitSens<T = V::T, V = V, C = V::C> { ... }
fn new_with_sensitivities_and_consistent<LS, Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
where Eqn: OdeEquationsImplicitSens<T = V::T, V = V, C = V::C>,
LS: LinearSolver<Eqn::M> { ... }
fn into_adjoint<LS, Eqn, AugmentedEqn>(
self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
) -> Result<Self, DiffsolError>
where Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn> + Debug,
LS: LinearSolver<AugmentedEqn::M> { ... }
fn new_without_initialise<Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
) -> Result<Self, DiffsolError>
where Eqn: OdeEquations<T = V::T, V = V, C = V::C> { ... }
fn new_without_initialise_augmented<Eqn, AugmentedEqn>(
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
) -> Result<Self, DiffsolError>
where Eqn: OdeEquations<T = V::T, V = V, C = V::C>,
AugmentedEqn: AugmentedOdeEquations<Eqn> { ... }
fn set_consistent<Eqn, S>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
root_solver: &mut S,
) -> Result<(), DiffsolError>
where Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
S: NonLinearSolver<Eqn::M> { ... }
fn set_consistent_augmented<Eqn, AugmentedEqn, S>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
root_solver: &mut S,
) -> Result<(), DiffsolError>
where Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn> + Debug,
S: NonLinearSolver<AugmentedEqn::M> { ... }
fn set_step_size<Eqn>(
&mut self,
h0: Eqn::T,
atol: &Eqn::V,
rtol: Eqn::T,
eqn: &Eqn,
solver_order: usize,
)
where Eqn: OdeEquations<T = V::T, V = V, C = V::C> { ... }
}Expand description
State for the ODE solver, containing:
- the current solution
y - the derivative of the solution wrt time
dy - the current integral of the output function
g - the current derivative of the integral of the output function wrt time
dg - the current time
t - the current step size
h, - the sensitivity vectors
s - the derivative of the sensitivity vectors wrt time
ds
Required Methods§
Sourcefn as_mut(&mut self) -> StateRefMut<'_, V>
fn as_mut(&mut self) -> StateRefMut<'_, V>
Get a mutable reference to the state.
Sourcefn into_common(self) -> StateCommon<V>
fn into_common(self) -> StateCommon<V>
Convert the state into a common state representation.
Sourcefn new_from_common(state: StateCommon<V>) -> Self
fn new_from_common(state: StateCommon<V>) -> Self
Create a new state from a common state representation.
Sourcefn set_problem<Eqn: OdeEquations>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
) -> Result<(), DiffsolError>
fn set_problem<Eqn: OdeEquations>( &mut self, ode_problem: &OdeSolverProblem<Eqn>, ) -> Result<(), DiffsolError>
Set the ODE problem for the state, allocating any necessary data structures.
Sourcefn set_augmented_problem<Eqn: OdeEquations, AugmentedEqn: AugmentedOdeEquations<Eqn>>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &AugmentedEqn,
) -> Result<(), DiffsolError>
fn set_augmented_problem<Eqn: OdeEquations, AugmentedEqn: AugmentedOdeEquations<Eqn>>( &mut self, ode_problem: &OdeSolverProblem<Eqn>, augmented_eqn: &AugmentedEqn, ) -> Result<(), DiffsolError>
Set the augmented ODE problem (for sensitivities) for the state.
Provided Methods§
Sourcefn check_consistent_with_problem<Eqn: OdeEquations>(
&self,
problem: &OdeSolverProblem<Eqn>,
) -> Result<(), DiffsolError>
fn check_consistent_with_problem<Eqn: OdeEquations>( &self, problem: &OdeSolverProblem<Eqn>, ) -> Result<(), DiffsolError>
Check that the state is consistent with the given ODE problem.
Sourcefn check_sens_consistent_with_problem<Eqn: OdeEquations, AugmentedEqn: AugmentedOdeEquations<Eqn>>(
&self,
problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &AugmentedEqn,
) -> Result<(), DiffsolError>
fn check_sens_consistent_with_problem<Eqn: OdeEquations, AugmentedEqn: AugmentedOdeEquations<Eqn>>( &self, problem: &OdeSolverProblem<Eqn>, augmented_eqn: &AugmentedEqn, ) -> Result<(), DiffsolError>
Check that the sensitivity vectors in the state are consistent with the given ODE problem.
Sourcefn new<Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
fn new<Eqn>( ode_problem: &OdeSolverProblem<Eqn>, solver_order: usize, ) -> Result<Self, DiffsolError>
Create a new solver state from an ODE problem. This function will set the initial step size based on the given solver. If you want to create a state without this default initialisation, use Self::new_without_initialise instead. You can then use Self::set_consistent and Self::set_step_size to set the state up if you need to.
Sourcefn new_and_consistent<LS, Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
fn new_and_consistent<LS, Eqn>( ode_problem: &OdeSolverProblem<Eqn>, solver_order: usize, ) -> Result<Self, DiffsolError>
Create a new solver state from an ODE problem. This function will make the state consistent with any algebraic constraints using a default nonlinear solver. It will also set the initial step size based on the given solver. If you want to create a state without this default initialisation, use Self::new_without_initialise instead. You can then use Self::set_consistent and Self::set_step_size to set the state up if you need to.
Sourcefn new_with_sensitivities<Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
fn new_with_sensitivities<Eqn>( ode_problem: &OdeSolverProblem<Eqn>, solver_order: usize, ) -> Result<Self, DiffsolError>
Create a new solver state from an ODE problem with sensitivity equations. This will initialize the sensitivity vectors but will not make them consistent with algebraic constraints.
Sourcefn new_with_sensitivities_and_consistent<LS, Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
solver_order: usize,
) -> Result<Self, DiffsolError>
fn new_with_sensitivities_and_consistent<LS, Eqn>( ode_problem: &OdeSolverProblem<Eqn>, solver_order: usize, ) -> Result<Self, DiffsolError>
Create a new solver state from an ODE problem with sensitivity equations, making both the main state and sensitivities consistent with algebraic constraints.
Sourcefn into_adjoint<LS, Eqn, AugmentedEqn>(
self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
) -> Result<Self, DiffsolError>where
Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn> + Debug,
LS: LinearSolver<AugmentedEqn::M>,
fn into_adjoint<LS, Eqn, AugmentedEqn>(
self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
) -> Result<Self, DiffsolError>where
Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn> + Debug,
LS: LinearSolver<AugmentedEqn::M>,
Convert the state to an adjoint state by reversing the time direction and initializing the adjoint variables. This is typically used as the starting point for adjoint sensitivity analysis.
Sourcefn new_without_initialise<Eqn>(
ode_problem: &OdeSolverProblem<Eqn>,
) -> Result<Self, DiffsolError>
fn new_without_initialise<Eqn>( ode_problem: &OdeSolverProblem<Eqn>, ) -> Result<Self, DiffsolError>
Create a new solver state from an ODE problem, without any initialisation apart from setting the initial time state vector y, the initial time derivative dy and if applicable the sensitivity vectors s. This is useful if you want to set up the state yourself, or if you want to use a different nonlinear solver to make the state consistent, or if you want to set the step size yourself or based on the exact order of the solver.
Sourcefn new_without_initialise_augmented<Eqn, AugmentedEqn>(
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
) -> Result<Self, DiffsolError>
fn new_without_initialise_augmented<Eqn, AugmentedEqn>( ode_problem: &OdeSolverProblem<Eqn>, augmented_eqn: &mut AugmentedEqn, ) -> Result<Self, DiffsolError>
Create a new solver state with augmented equations (sensitivities) from an ODE problem, without making the augmented state consistent.
Sourcefn set_consistent<Eqn, S>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
root_solver: &mut S,
) -> Result<(), DiffsolError>
fn set_consistent<Eqn, S>( &mut self, ode_problem: &OdeSolverProblem<Eqn>, root_solver: &mut S, ) -> Result<(), DiffsolError>
Calculate a consistent state and time derivative of the state, based on the equations of the problem.
Sourcefn set_consistent_augmented<Eqn, AugmentedEqn, S>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
root_solver: &mut S,
) -> Result<(), DiffsolError>where
Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn> + Debug,
S: NonLinearSolver<AugmentedEqn::M>,
fn set_consistent_augmented<Eqn, AugmentedEqn, S>(
&mut self,
ode_problem: &OdeSolverProblem<Eqn>,
augmented_eqn: &mut AugmentedEqn,
root_solver: &mut S,
) -> Result<(), DiffsolError>where
Eqn: OdeEquationsImplicit<T = V::T, V = V, C = V::C>,
AugmentedEqn: AugmentedOdeEquationsImplicit<Eqn> + Debug,
S: NonLinearSolver<AugmentedEqn::M>,
Calculate the initial sensitivity vectors and their time derivatives, based on the equations of the problem. Note that this function assumes that the state is already consistent with the algebraic constraints (either via Self::set_consistent or by setting the state up manually).
Sourcefn set_step_size<Eqn>(
&mut self,
h0: Eqn::T,
atol: &Eqn::V,
rtol: Eqn::T,
eqn: &Eqn,
solver_order: usize,
)
fn set_step_size<Eqn>( &mut self, h0: Eqn::T, atol: &Eqn::V, rtol: Eqn::T, eqn: &Eqn, solver_order: usize, )
compute size of first step based on alg in Hairer, Norsett, Wanner Solving Ordinary Differential Equations I, Nonstiff Problems Section II.4.2 Note: this assumes that the state is already consistent with the algebraic constraints and y and dy are already set appropriately
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.