Skip to main content

SolverOptions

Struct SolverOptions 

Source
pub struct SolverOptions<S: Scalar> {
    pub rtol: S,
    pub atol: S,
    pub h0: Option<S>,
    pub h_max: S,
    pub h_min: S,
    pub max_steps: usize,
    pub t_eval: Option<Vec<S>>,
    pub dense_output: bool,
    pub events: Vec<Arc<dyn EventFunction<S>>>,
}
Expand description

Solver options and tolerances.

Cloneable thanks to Arc-wrapped event functions.

Fields§

§rtol: S

Relative tolerance

§atol: S

Absolute tolerance (scalar)

§h0: Option<S>

Initial step size (None = auto)

§h_max: S

Maximum step size

§h_min: S

Minimum step size

§max_steps: usize

Maximum number of steps

§t_eval: Option<Vec<S>>

Output grid in the integration direction. When Some, each solver returns exactly these (t, y) pairs (Hermite cubic interpolated from accepted step endpoints; endpoints are reproduced bit-exact). When None, the natural adaptive step grid is returned.

§dense_output: bool

Enable dense output

§events: Vec<Arc<dyn EventFunction<S>>>

Event functions for zero-crossing detection (Arc enables Clone)

Implementations§

Source§

impl<S: Scalar> SolverOptions<S>

Source

pub fn rtol(self, rtol: S) -> Self

Set relative tolerance.

Examples found in repository?
examples/radau5_step_audit.rs (line 15)
10fn run<F>(name: &str, rhs: F, t0: f64, tf: f64, y0: Vec<f64>, rtol: f64, atol: f64)
11where
12    F: Fn(f64, &[f64], &mut [f64]) + Copy,
13{
14    let problem = OdeProblem::new(rhs, t0, tf, y0.clone());
15    let opts = SolverOptions::default().rtol(rtol).atol(atol);
16    let res = Radau5::solve(&problem, t0, tf, &y0, &opts).expect("solve failed");
17    println!(
18        "{:<32} acc={:>4}  rej={:>3}  rhs={:>5}  jac={:>3}  lu={:>4}",
19        name,
20        res.stats.n_accept,
21        res.stats.n_reject,
22        res.stats.n_eval,
23        res.stats.n_jac,
24        res.stats.n_lu,
25    );
26}
Source

pub fn atol(self, atol: S) -> Self

Set absolute tolerance.

Examples found in repository?
examples/radau5_step_audit.rs (line 15)
10fn run<F>(name: &str, rhs: F, t0: f64, tf: f64, y0: Vec<f64>, rtol: f64, atol: f64)
11where
12    F: Fn(f64, &[f64], &mut [f64]) + Copy,
13{
14    let problem = OdeProblem::new(rhs, t0, tf, y0.clone());
15    let opts = SolverOptions::default().rtol(rtol).atol(atol);
16    let res = Radau5::solve(&problem, t0, tf, &y0, &opts).expect("solve failed");
17    println!(
18        "{:<32} acc={:>4}  rej={:>3}  rhs={:>5}  jac={:>3}  lu={:>4}",
19        name,
20        res.stats.n_accept,
21        res.stats.n_reject,
22        res.stats.n_eval,
23        res.stats.n_jac,
24        res.stats.n_lu,
25    );
26}
Source

pub fn h0(self, h0: S) -> Self

Set initial step size.

Source

pub fn h_max(self, h_max: S) -> Self

Set maximum step size.

Source

pub fn t_eval(self, t_eval: Vec<S>) -> Self

Set evaluation times.

Source

pub fn dense(self) -> Self

Enable dense output.

Source

pub fn max_steps(self, max_steps: usize) -> Self

Set maximum number of steps.

Source

pub fn h_min(self, h_min: S) -> Self

Set minimum step size.

Source

pub fn event(self, event: Box<dyn EventFunction<S>>) -> Self

Add an event function for zero-crossing detection.

Internally converts to Arc to enable Clone on SolverOptions.

Trait Implementations§

Source§

impl<S: Scalar> Clone for SolverOptions<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Scalar> Debug for SolverOptions<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Scalar> Default for SolverOptions<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for SolverOptions<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for SolverOptions<S>

§

impl<S> Send for SolverOptions<S>

§

impl<S> Sync for SolverOptions<S>

§

impl<S> Unpin for SolverOptions<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for SolverOptions<S>
where S: UnsafeUnpin,

§

impl<S> !UnwindSafe for SolverOptions<S>

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