differential_equations/methods/erk/fixed/
mod.rs1mod delay;
4mod ordinary;
5mod stochastic;
6
7use crate::{
8 methods::{ExplicitRungeKutta, Fixed},
9 tableau::ButcherTableau,
10 traits::{Real, State},
11};
12
13macro_rules! impl_erk_fixed_step_constructor {
15 ($method_name:ident, $fsal_val:expr, $order_val:expr, $s_val:expr, $doc:expr) => {
16 impl<E, T: Real, Y: State<T>>
17 ExplicitRungeKutta<E, Fixed, T, Y, $order_val, $s_val, $s_val>
18 {
19 #[doc = $doc]
20 pub fn $method_name(h0: T) -> Self {
21 let tableau = ButcherTableau::$method_name();
22 let c = tableau.c;
23 let a = tableau.a;
24 let b = tableau.b;
25 let fsal = $fsal_val;
26
27 ExplicitRungeKutta {
28 h0,
29 c,
30 a,
31 b,
32 fsal,
33 ..Default::default()
34 }
35 }
36 }
37 };
38}
39
40impl_erk_fixed_step_constructor!(
42 euler,
43 false,
44 1,
45 1,
46 "Creates an Explicit Euler method (1st order, 1 stage)."
47);
48impl_erk_fixed_step_constructor!(
49 midpoint,
50 false,
51 2,
52 2,
53 "Creates an Explicit Midpoint method (2nd order, 2 stages)."
54);
55impl_erk_fixed_step_constructor!(
56 heun,
57 false,
58 2,
59 2,
60 "Creates an Explicit Heun method (2nd order, 2 stages)."
61);
62impl_erk_fixed_step_constructor!(
63 ralston,
64 false,
65 2,
66 2,
67 "Creates an Explicit Ralston method (2nd order, 2 stages)."
68);
69impl_erk_fixed_step_constructor!(
70 rk4,
71 false,
72 4,
73 4,
74 "Creates the classical 4th order Runge-Kutta method."
75);
76impl_erk_fixed_step_constructor!(
77 three_eighths,
78 false,
79 4,
80 4,
81 "Creates the three-eighths rule 4th order Runge-Kutta method."
82);