Skip to main content

OdeWrapper

Struct OdeWrapper 

Source
pub struct OdeWrapper(/* private fields */);

Implementations§

Source§

impl OdeWrapper

Source

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.

Source

pub fn get_matrix_type(&self) -> Result<MatrixType, DiffsolRtError>

Matrix type used in the ODE solver. This is fixed after construction.

Source

pub fn get_nstates(&self) -> Result<usize, DiffsolRtError>

Source

pub fn get_nparams(&self) -> Result<usize, DiffsolRtError>

Source

pub fn get_nout(&self) -> Result<usize, DiffsolRtError>

Source

pub fn has_stop(&self) -> Result<bool, DiffsolRtError>

Source

pub fn get_ode_solver(&self) -> Result<OdeSolverType, DiffsolRtError>

Ode solver method, default Bdf (backward differentiation formula).

Source

pub fn set_ode_solver(&self, value: OdeSolverType) -> Result<(), DiffsolRtError>

Source

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.

Source

pub fn set_linear_solver( &self, value: LinearSolverType, ) -> Result<(), DiffsolRtError>

Source

pub fn get_rtol(&self) -> Result<f64, DiffsolRtError>

Relative tolerance for the solver, default 1e-6. Governs the error relative to the solution size.

Source

pub fn set_rtol(&self, value: f64) -> Result<(), DiffsolRtError>

Source

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.

Source

pub fn set_atol(&self, value: f64) -> Result<(), DiffsolRtError>

Source

pub fn get_code(&self) -> Result<String, DiffsolRtError>

Source

pub fn get_scalar_type(&self) -> Result<ScalarType, DiffsolRtError>

Source

pub fn get_jit_backend(&self) -> Result<Option<JitBackendType>, DiffsolRtError>

Source

pub fn get_ic_options(&self) -> InitialConditionSolverOptions

Source

pub fn get_options(&self) -> OdeSolverOptions

Source

pub fn y0(&self, params: HostArray) -> Result<HostArray, DiffsolRtError>

Get the initial condition vector y0 as a 1D numpy array.

Source

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.

Source

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`.

Source

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

Source

pub fn solve_hybrid( &self, params: HostArray, final_time: f64, ) -> Result<SolutionWrapper, DiffsolRtError>

Solve a hybrid ODE up to final_time, automatically applying reset functions and continuing after root events until the solution completes.

Source

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

Source

pub fn solve_hybrid_dense( &self, params: HostArray, t_eval: HostArray, ) -> Result<SolutionWrapper, DiffsolRtError>

Solve a hybrid ODE at dense evaluation times, automatically applying reset functions and continuing after root events until all requested output points are filled.

Source

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])

Source

pub fn solve_hybrid_fwd_sens( &self, params: HostArray, t_eval: HostArray, ) -> Result<SolutionWrapper, DiffsolRtError>

Solve a hybrid ODE with forward sensitivities at dense evaluation times, automatically applying sensitivity-aware reset functions and continuing after root events until all requested output points are filled.

Source

pub fn solve_sum_squares_adj( &self, params: HostArray, data: HostArray, t_eval: HostArray, ) -> Result<(f64, HostArray), DiffsolRtError>

Using the provided state, solve the adjoint problem for the sum of squares objective given data at timepoints t_eval. Returns the objective value and a list of 1D arrays of adjoint sensitivities for each parameter.

Trait Implementations§

Source§

impl Clone for OdeWrapper

Source§

fn clone(&self) -> OdeWrapper

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<'de> Deserialize<'de> for OdeWrapper

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for OdeWrapper

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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