pub struct OdeWrapper(/* private fields */);Implementations§
Source§impl OdeWrapper
impl OdeWrapper
Sourcepub fn new_external_dynamic(
path: impl Into<PathBuf>,
rhs_state_deps: Vec<(usize, usize)>,
rhs_input_deps: Vec<(usize, usize)>,
mass_state_deps: Vec<(usize, usize)>,
scalar_type: ScalarType,
matrix_type: MatrixType,
linear_solver: LinearSolverType,
ode_solver: OdeSolverType,
) -> Result<Self, DiffsolRtError>
pub fn new_external_dynamic( path: impl Into<PathBuf>, rhs_state_deps: Vec<(usize, usize)>, rhs_input_deps: Vec<(usize, usize)>, mass_state_deps: Vec<(usize, usize)>, scalar_type: ScalarType, matrix_type: MatrixType, linear_solver: LinearSolverType, ode_solver: OdeSolverType, ) -> Result<Self, DiffsolRtError>
Construct an ODE solver backed by DiffSL symbols loaded from a dynamic library.
Sourcepub fn get_matrix_type(&self) -> Result<MatrixType, DiffsolRtError>
pub fn get_matrix_type(&self) -> Result<MatrixType, DiffsolRtError>
Matrix type used in the ODE solver. This is fixed after construction.
pub fn get_nstates(&self) -> Result<usize, DiffsolRtError>
pub fn get_nparams(&self) -> Result<usize, DiffsolRtError>
pub fn get_nout(&self) -> Result<usize, DiffsolRtError>
pub fn has_stop(&self) -> Result<bool, DiffsolRtError>
Sourcepub fn get_ode_solver(&self) -> Result<OdeSolverType, DiffsolRtError>
pub fn get_ode_solver(&self) -> Result<OdeSolverType, DiffsolRtError>
Ode solver method, default Bdf (backward differentiation formula).
pub fn set_ode_solver(&self, value: OdeSolverType) -> Result<(), DiffsolRtError>
Sourcepub fn get_linear_solver(&self) -> Result<LinearSolverType, DiffsolRtError>
pub fn get_linear_solver(&self) -> Result<LinearSolverType, DiffsolRtError>
Linear solver type used in the ODE solver. Set to default to use the solver’s default choice, which is typically an LU solver.
pub fn set_linear_solver( &self, value: LinearSolverType, ) -> Result<(), DiffsolRtError>
Sourcepub fn get_rtol(&self) -> Result<f64, DiffsolRtError>
pub fn get_rtol(&self) -> Result<f64, DiffsolRtError>
Relative tolerance for the solver, default 1e-6. Governs the error relative to the solution size.
pub fn set_rtol(&self, value: f64) -> Result<(), DiffsolRtError>
Sourcepub fn get_atol(&self) -> Result<f64, DiffsolRtError>
pub fn get_atol(&self) -> Result<f64, DiffsolRtError>
Absolute tolerance for the solver, default 1e-6. Governs the error as the solution goes to zero.
pub fn set_atol(&self, value: f64) -> Result<(), DiffsolRtError>
Sourcepub fn get_t0(&self) -> Result<f64, DiffsolRtError>
pub fn get_t0(&self) -> Result<f64, DiffsolRtError>
Initial time for the ODE solve, default 0.0.
pub fn set_t0(&self, value: f64) -> Result<(), DiffsolRtError>
Sourcepub fn get_h0(&self) -> Result<f64, DiffsolRtError>
pub fn get_h0(&self) -> Result<f64, DiffsolRtError>
Initial step size for the ODE solver, default 1.0.
pub fn set_h0(&self, value: f64) -> Result<(), DiffsolRtError>
Sourcepub fn get_integrate_out(&self) -> Result<bool, DiffsolRtError>
pub fn get_integrate_out(&self) -> Result<bool, DiffsolRtError>
Whether to integrate output equations alongside state equations.
pub fn set_integrate_out(&self, value: bool) -> Result<(), DiffsolRtError>
Sourcepub fn get_sens_rtol(&self) -> Result<Option<f64>, DiffsolRtError>
pub fn get_sens_rtol(&self) -> Result<Option<f64>, DiffsolRtError>
Relative tolerance for forward sensitivity or adjoint equations.
pub fn set_sens_rtol(&self, value: Option<f64>) -> Result<(), DiffsolRtError>
Sourcepub fn get_sens_atol(&self) -> Result<Option<f64>, DiffsolRtError>
pub fn get_sens_atol(&self) -> Result<Option<f64>, DiffsolRtError>
Absolute tolerance for forward sensitivity or adjoint equations.
pub fn set_sens_atol(&self, value: Option<f64>) -> Result<(), DiffsolRtError>
Sourcepub fn get_out_rtol(&self) -> Result<Option<f64>, DiffsolRtError>
pub fn get_out_rtol(&self) -> Result<Option<f64>, DiffsolRtError>
Relative tolerance for integrated output equations.
pub fn set_out_rtol(&self, value: Option<f64>) -> Result<(), DiffsolRtError>
Sourcepub fn get_out_atol(&self) -> Result<Option<f64>, DiffsolRtError>
pub fn get_out_atol(&self) -> Result<Option<f64>, DiffsolRtError>
Absolute tolerance for integrated output equations.
pub fn set_out_atol(&self, value: Option<f64>) -> Result<(), DiffsolRtError>
Sourcepub fn get_param_rtol(&self) -> Result<Option<f64>, DiffsolRtError>
pub fn get_param_rtol(&self) -> Result<Option<f64>, DiffsolRtError>
Relative tolerance for adjoint parameter gradient equations.
pub fn set_param_rtol(&self, value: Option<f64>) -> Result<(), DiffsolRtError>
Sourcepub fn get_param_atol(&self) -> Result<Option<f64>, DiffsolRtError>
pub fn get_param_atol(&self) -> Result<Option<f64>, DiffsolRtError>
Absolute tolerance for adjoint parameter gradient equations.
pub fn set_param_atol(&self, value: Option<f64>) -> Result<(), DiffsolRtError>
pub fn get_code(&self) -> Result<String, DiffsolRtError>
pub fn get_scalar_type(&self) -> Result<ScalarType, DiffsolRtError>
pub fn get_jit_backend(&self) -> Result<Option<JitBackendType>, DiffsolRtError>
pub fn get_ic_options(&self) -> InitialConditionSolverOptions
pub fn get_options(&self) -> OdeSolverOptions
Sourcepub fn y0(&self, params: HostArray) -> Result<HostArray, DiffsolRtError>
pub fn y0(&self, params: HostArray) -> Result<HostArray, DiffsolRtError>
Get the initial condition vector y0 as a 1D numpy array.
Sourcepub fn rhs(
&self,
params: HostArray,
t: f64,
y: HostArray,
) -> Result<HostArray, DiffsolRtError>
pub fn rhs( &self, params: HostArray, t: f64, y: HostArray, ) -> Result<HostArray, DiffsolRtError>
evaluate the right-hand side function at time t and state y.
Sourcepub fn rhs_jac_mul(
&self,
params: HostArray,
t: f64,
y: HostArray,
v: HostArray,
) -> Result<HostArray, DiffsolRtError>
pub fn rhs_jac_mul( &self, params: HostArray, t: f64, y: HostArray, v: HostArray, ) -> Result<HostArray, DiffsolRtError>
evaluate the right-hand side Jacobian-vector product Jv`` at time tand statey`.
Sourcepub fn solve(
&self,
params: HostArray,
final_time: f64,
) -> Result<SolutionWrapper, DiffsolRtError>
pub fn solve( &self, params: HostArray, final_time: f64, ) -> Result<SolutionWrapper, DiffsolRtError>
Using the provided state, solve the problem up to time final_time.
The number of params must match the expected params in the diffsl code.
If specified, the config can be used to override the solver method
(Bdf by default) and SolverType (Lu by default) along with other solver
params like rtol.
:param params: 1D array of solver parameters
:type params: numpy.ndarray
:param final_time: end time of solver
:type final_time: float
:return: (ys, ts) tuple where ys is a 2D array of values at times
ts chosen by the solver
:rtype: Tuple[numpy.ndarray, numpy.ndarray]
Example: >>> print(ode.solve(np.array([]), 0.5))
Sourcepub fn solve_dense(
&self,
params: HostArray,
t_eval: HostArray,
) -> Result<SolutionWrapper, DiffsolRtError>
pub fn solve_dense( &self, params: HostArray, t_eval: HostArray, ) -> Result<SolutionWrapper, DiffsolRtError>
Using the provided state, solve the problem up to time
t_eval[t_eval.len()-1]. Returns 2D array of solution values at
timepoints given by t_eval.
The number of params must match the expected params in the diffsl code. The config may be optionally specified to override solver settings.
:param params: 1D array of solver parameters
:type params: numpy.ndarray
:param t_eval: 1D array of solver times
:type params: numpy.ndarray
:return: 2D array of values at times t_eval
:rtype: numpy.ndarray
Sourcepub fn solve_fwd_sens(
&self,
params: HostArray,
t_eval: HostArray,
) -> Result<SolutionWrapper, DiffsolRtError>
pub fn solve_fwd_sens( &self, params: HostArray, t_eval: HostArray, ) -> Result<SolutionWrapper, DiffsolRtError>
Using the provided state, solve the problem up to time t_eval[t_eval.len()-1].
Returns 2D array of solution values at timepoints given by t_eval.
Also returns a list of 2D arrays of sensitivities at the same timepoints
as the solution.
The number of params must match the expected params in the diffsl code.
The config may be optionally specified to override solver settings.
:param params: 1D array of solver parameters
:type params: numpy.ndarray
:param t_eval: 1D array of solver times
:type params: numpy.ndarray
:return: 2D array of values at times t_eval and a list of 2D arrays of sensitivities at the same timepoints
:rtype: (numpy.ndarray, List[numpy.ndarray])
Sourcepub fn solve_continuous_adjoint(
&self,
params: HostArray,
final_time: f64,
) -> Result<(HostArray, HostArray), DiffsolRtError>
pub fn solve_continuous_adjoint( &self, params: HostArray, final_time: f64, ) -> Result<(HostArray, HostArray), DiffsolRtError>
Solve the continuous adjoint problem for the integral of the model output
from the initial time to final_time.
Returns (integral, gradient), where integral is a vector of length
nout and gradient is an (nparams, nout) matrix.
Sourcepub fn solve_adjoint_fwd(
&self,
params: HostArray,
t_eval: HostArray,
) -> Result<(SolutionWrapper, AdjointCheckpointWrapper), DiffsolRtError>
pub fn solve_adjoint_fwd( &self, params: HostArray, t_eval: HostArray, ) -> Result<(SolutionWrapper, AdjointCheckpointWrapper), DiffsolRtError>
Solve the forward problem at t_eval and retain checkpoint data for a
later discrete adjoint backward pass.
Sourcepub fn solve_adjoint_bkwd(
&self,
solution: &SolutionWrapper,
checkpoint: &AdjointCheckpointWrapper,
dgdu_eval: HostArray,
) -> Result<HostArray, DiffsolRtError>
pub fn solve_adjoint_bkwd( &self, solution: &SolutionWrapper, checkpoint: &AdjointCheckpointWrapper, dgdu_eval: HostArray, ) -> Result<HostArray, DiffsolRtError>
Solve the discrete adjoint backward pass using a prior forward adjoint checkpoint and the gradient of a scalar objective with respect to model outputs at each saved evaluation time.
Returns an (nparams, 1) gradient matrix.
Trait Implementations§
Source§impl Clone for OdeWrapper
impl Clone for OdeWrapper
Source§fn clone(&self) -> OdeWrapper
fn clone(&self) -> OdeWrapper
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de> Deserialize<'de> for OdeWrapper
impl<'de> Deserialize<'de> for OdeWrapper
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for OdeWrapper
impl RefUnwindSafe for OdeWrapper
impl Send for OdeWrapper
impl Sync for OdeWrapper
impl Unpin for OdeWrapper
impl UnsafeUnpin for OdeWrapper
impl UnwindSafe for OdeWrapper
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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>
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>
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.