Struct mathru::analysis::differential_equation::ordinary::ExplicitEuler [−][src]
pub struct ExplicitEuler<T> { /* fields omitted */ }
Solves an ODE using Euler’s method.
https://en.wikipedia.org/wiki/Euler_method
Example
For this example, we want to solve the following ordinary differiential equation:
\frac{dy}{dt} = ay = f(t, y)
The inial condition is $y(0) = 0.5
$ and we solve it in the interval
$\lbrack 0, 2\rbrack
$ The following equation is the closed solution for
this ODE:
y(t) = C a e^{at}
$C
$ is a parameter and depends on the initial condition $y(t_{0})
$
C = \frac{y(t_{0})}{ae^{at_{0}}}
In this example, we set $a=2
$
use mathru::{ algebra::linear::Vector, analysis::differential_equation::ordinary::{ExplicitEuler, FixedStepper, ExplicitODE}, }; pub struct ExplicitODE1 { time_span: (f64, f64), init_cond: Vector<f64>, } impl Default for ExplicitODE1 { fn default() -> ExplicitODE1 { ExplicitODE1 { time_span: (0.0, 2.0), init_cond: vector![0.5] } } } impl ExplicitODE<f64> for ExplicitODE1 { fn func(self: &Self, _t: &f64, x: &Vector<f64>) -> Vector<f64> { return x * &2.0f64; } fn time_span(self: &Self) -> (f64, f64) { return self.time_span; } fn init_cond(self: &Self) -> Vector<f64> { return self.init_cond.clone(); } } // We instantiate Euler's algorithm with a step size of 0.001 let solver: FixedStepper<f64> = FixedStepper::new(0.001); let problem: ExplicitODE1 = ExplicitODE1::default(); // Solve the ODE let (t, y): (Vec<f64>, Vec<Vector<f64>>) = solver.solve(&problem, &ExplicitEuler::default()).unwrap();
Trait Implementations
impl<T: Clone> Clone for ExplicitEuler<T>
[src]
fn clone(&self) -> ExplicitEuler<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug> Debug for ExplicitEuler<T>
[src]
impl<T> Default for ExplicitEuler<T> where
T: Real,
[src]
T: Real,
fn default() -> ExplicitEuler<T>
[src]
Creates a Euler instance
Auto Trait Implementations
impl<T> RefUnwindSafe for ExplicitEuler<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for ExplicitEuler<T> where
T: Send,
T: Send,
impl<T> Sync for ExplicitEuler<T> where
T: Sync,
T: Sync,
impl<T> Unpin for ExplicitEuler<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ExplicitEuler<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,