pub struct RK45<N: ComplexField, S: DimName>where
DefaultAllocator: Allocator<N, S> + Allocator<N, U6> + Allocator<N, U6, U6> + Allocator<N, S, U6> + Allocator<N::RealField, U6> + Allocator<N::RealField, U6, U6>,{ /* private fields */ }Expand description
Runge-Kutta-Fehlberg method for solving an IVP.
Defines the Butch Tableaux for a 5(4) order adaptive runge-kutta method. Uses RKInfo to do the actual solving. Provides an interface for setting the conditions on RKInfo.
§Examples
use nalgebra::{VectorN, U1};
use bacon_sci::ivp::{RK45, RungeKuttaSolver};
fn derivatives(_t: f64, state: &[f64], _p: &mut ()) -> Result<VectorN<f64, U1>, String> {
Ok(VectorN::<f64, U1>::from_column_slice(state))
}
fn example() -> Result<(), String> {
let rk45 = RK45::new()
.with_dt_max(0.1)?
.with_dt_min(0.001)?
.with_start(0.0)?
.with_end(10.0)?
.with_tolerance(0.0001)?
.with_initial_conditions(&[1.0])?
.build();
let path = rk45.solve_ivp(derivatives, &mut ())?;
for (time, state) in &path {
assert!((time.exp() - state.column(0)[0]).abs() < 0.001);
}
Ok(())
}Implementations§
Trait Implementations§
Source§impl<N: ComplexField, S: DimName> RungeKuttaSolver<N, S, U6> for RK45<N, S>
impl<N: ComplexField, S: DimName> RungeKuttaSolver<N, S, U6> for RK45<N, S>
Source§fn t_coefficients() -> VectorN<N::RealField, U6>
fn t_coefficients() -> VectorN<N::RealField, U6>
Returns a vec of coeffecients to multiply the time step by when getting
intermediate results. Upper-left portion of Butch Tableaux
Source§fn k_coefficients() -> MatrixMN<N::RealField, U6, U6>
fn k_coefficients() -> MatrixMN<N::RealField, U6, U6>
Returns the coefficients to use on the k_i’s when finding another
k_i. Upper-right portion of the Butch Tableax. Should be
an NxN-1 matrix, where N is the order of the Runge-Kutta Method (Or order+1 for
adaptive methods)
Source§fn avg_coefficients() -> VectorN<N::RealField, U6>
fn avg_coefficients() -> VectorN<N::RealField, U6>
Coefficients to use when calculating the final step to take.
These are the weights of the weighted average of k_i’s. Bottom
portion of the Butch Tableaux. For adaptive methods, this is the first
row of the bottom portion.
Source§fn error_coefficients() -> VectorN<N::RealField, U6>
fn error_coefficients() -> VectorN<N::RealField, U6>
Coefficients to use on
the k_i’s to find the error between the two orders
of Runge-Kutta methods. In the Butch Tableaux, this is
the first row of the bottom portion minus the second row.
Source§fn solve_ivp<T: Clone, F: FnMut(N::RealField, &[N], &mut T) -> Result<VectorN<N, S>, String>>(
self,
f: F,
params: &mut T,
) -> Result<Vec<(N::RealField, VectorN<N, S>)>, String>
fn solve_ivp<T: Clone, F: FnMut(N::RealField, &[N], &mut T) -> Result<VectorN<N, S>, String>>( self, f: F, params: &mut T, ) -> Result<Vec<(N::RealField, VectorN<N, S>)>, String>
Ideally, call RKInfo.solve_ivp
Source§fn with_tolerance(self, tol: N::RealField) -> Result<Self, String>
fn with_tolerance(self, tol: N::RealField) -> Result<Self, String>
Set the error tolerance for this solver.
Source§fn with_dt_max(self, max: N::RealField) -> Result<Self, String>
fn with_dt_max(self, max: N::RealField) -> Result<Self, String>
Set the maximum time step for this solver.
Source§fn with_dt_min(self, min: N::RealField) -> Result<Self, String>
fn with_dt_min(self, min: N::RealField) -> Result<Self, String>
Set the minimum time step for this solver.
Source§fn with_start(self, t_initial: N::RealField) -> Result<Self, String>
fn with_start(self, t_initial: N::RealField) -> Result<Self, String>
Set the initial time for this solver.
Source§fn with_end(self, t_final: N::RealField) -> Result<Self, String>
fn with_end(self, t_final: N::RealField) -> Result<Self, String>
Set the end time for this solver.
Auto Trait Implementations§
impl<N, S> !Freeze for RK45<N, S>
impl<N, S> !RefUnwindSafe for RK45<N, S>
impl<N, S> !Send for RK45<N, S>
impl<N, S> !Sync for RK45<N, S>
impl<N, S> !Unpin for RK45<N, S>
impl<N, S> !UnwindSafe for RK45<N, S>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.