differential_equations/methods/erk/adaptive/
mod.rs1mod ordinary;
4mod delay;
5
6use super::ExplicitRungeKutta;
7use crate::methods::{Adaptive, Ordinary, Delay};
8
9use crate::{
10 traits::{CallBackData, Real, State},
11 tableau::ButcherTableau,
12};
13
14macro_rules! impl_erk_adaptive_step_constructor {
16 ($method_name:ident, $fsal_val:expr, $order_val:expr, $s_val:expr, $m_val:expr, $doc:expr) => {
17 impl<E, T: Real, V: State<T>, D: CallBackData> ExplicitRungeKutta<E, Adaptive, T, V, D, $order_val, $s_val, $m_val> {
18 #[doc = $doc]
19 pub fn $method_name() -> Self {
20 let tableau = ButcherTableau::<T, $s_val, $m_val>::$method_name();
21 let c = tableau.c;
22 let a = tableau.a;
23 let b = tableau.b;
24 let bh = tableau.bh;
25 let bi = tableau.bi;
26 let fsal = $fsal_val;
27
28 ExplicitRungeKutta {
29 c,
30 a,
31 b,
32 bh,
33 bi,
34 fsal,
35 ..Default::default()
36 }
37 }
38 }
39 };
40}
41
42impl_erk_adaptive_step_constructor!(rkf45, false, 5, 6, 6, "Creates a Runge-Kutta-Fehlberg 4(5) method with error estimation.");
44impl_erk_adaptive_step_constructor!(cash_karp, false, 5, 6, 6, "Creates a Cash-Karp 4(5) method with error estimation.");
45impl_erk_adaptive_step_constructor!(rkv655e, true, 6, 9, 10, "Creates a ExplictRungeKutta 6(5) method with 9 stages and a 5th order interpolant.");
46impl_erk_adaptive_step_constructor!(rkv656e, true, 6, 9, 12, "Creates a ExplictRungeKutta 6(5) method with 9 stages and a 6th order interpolant.");
47impl_erk_adaptive_step_constructor!(rkv766e, false, 7, 10, 13, "Creates a ExplicitRungeKutta 7(6) method with 10 stages and a 6th order interpolant.");
48impl_erk_adaptive_step_constructor!(rkv767e, false, 7, 10, 16, "Creates a ExplicitRungeKutta 7(6) method with 10 stages and a 7th order interpolant.");
49impl_erk_adaptive_step_constructor!(rkv877e, false, 8, 13, 17, "Creates a ExplicitRungeKutta 8(7) method with 13 stages and a 7th order interpolant.");
50impl_erk_adaptive_step_constructor!(rkv878e, false, 8, 13, 21, "Creates a ExplicitRungeKutta 8(7) method with 13 stages and a 8th order interpolant.");
51impl_erk_adaptive_step_constructor!(rkv988e, false, 9, 16, 21, "Creates a ExplicitRungeKutta 9(8) method with 16 stages and a 8th order interpolant.");
52impl_erk_adaptive_step_constructor!(rkv989e, false, 9, 16, 26, "Creates a ExplicitRungeKutta 9(8) method with 16 stages and a 9th order interpolant.");