differential_equations/methods/irk/fixed/
mod.rs1mod ordinary;
4use super::ImplicitRungeKutta;
7use crate::methods::{Fixed, Ordinary};
8
9use crate::{
10 traits::{CallBackData, Real, State},
11 tableau::ButcherTableau,
12};
13
14macro_rules! impl_irk_fixed_step_constructor {
16 ($method_name:ident, $order_val:expr, $s_val:expr, $m_val:expr, $doc:expr) => {
17 impl<E, T: Real, V: State<T>, D: CallBackData> ImplicitRungeKutta<E, Fixed, T, V, D, $order_val, $s_val, $m_val> {
18 #[doc = $doc]
19 pub fn $method_name(h0: T) -> Self {
20 let tableau = ButcherTableau::<T, $s_val>::$method_name();
21 let c = tableau.c;
22 let a = tableau.a;
23 let b = tableau.b;
24
25 ImplicitRungeKutta {
26 h0,
27 c,
28 a,
29 b,
30 order: $order_val,
31 stages: $s_val,
32 dense_stages: $m_val,
33 ..Default::default()
34 }
35 }
36 }
37 };
38}
39
40impl_irk_fixed_step_constructor!(backward_euler, 1, 1, 1, "Backward Euler method of order 1 with 1 stage. A-stable and suitable for stiff problems.");
42impl_irk_fixed_step_constructor!(crank_nicolson, 2, 2, 2, "Crank-Nicolson method of order 2 with 2 stages. A-stable and suitable for stiff problems.");
43impl_irk_fixed_step_constructor!(trapezoidal, 2, 2, 2, "Trapezoidal method of order 2 with 2 stages. A-stable and suitable for stiff problems.");
44impl_irk_fixed_step_constructor!(radau_iia_3, 3, 2, 2, "Radau IIA method of order 3 with 2 stages. A-stable and suitable for stiff problems.");
45impl_irk_fixed_step_constructor!(radau_iia_5, 5, 3, 3, "Radau IIA method of order 5 with 3 stages. A-stable and suitable for stiff problems.");