differential_equations/tableau/mod.rs
1//! Butcher Tableau
2
3// Explicit Runge-Kutta methods
4mod dorman_prince;
5mod runge_kutta;
6mod verner;
7
8// Implicit Runge-Kutta methods
9mod gauss_legendre;
10mod lobatto;
11
12// Diagonally Implicit Runge-Kutta methods
13pub mod dirk;
14pub mod kvaerno;
15
16use crate::traits::Real;
17
18/// Butcher Tableau structure for Runge-Kutta methods.
19///
20/// A Butcher tableau encodes the coefficients of a Runge-Kutta method and provides the
21/// necessary components for solving ordinary differential equations. This implementation
22/// includes support for embedded methods (for error estimation) and dense output through interpolation.
23///
24/// # Generic Parameters
25/// - `T`: The type of the coefficients, typically a floating-point type (e.g., `f32`, `f64`).
26/// - `S`: Number of stages in the method.
27/// - `I`: Primary Stages plus extra stages for interpolation (default is equal to `S`).
28///
29/// # Fields
30/// - `c`: Node coefficients (time steps within the interval).
31/// - `a`: Runge-Kutta matrix coefficients (coupling between stages).
32/// - `b`: Weight coefficients for the primary method's final stage.
33/// - `bh`: Weight coefficients for the embedded method (used for error estimation).
34/// - `bi`: Weight coefficients for the interpolation method (used for dense output).
35/// - `er`: Error estimation coefficients (optional, not all adaptive methods have these).
36///
37/// These allow approximation at any point within the integration step.
38///
39pub struct ButcherTableau<T: Real, const S: usize, const I: usize = S> {
40 pub c: [T; I],
41 pub a: [[T; I]; I],
42 pub b: [T; S],
43 pub bh: Option<[T; S]>,
44 pub bi: Option<[[T; I]; I]>,
45 pub er: Option<[T; S]>,
46}
47
48impl<T: Real, const S: usize, const I: usize> ButcherTableau<T, S, I> {
49 /// Number of stages in the method
50 pub const STAGES: usize = S;
51
52 /// Number of extra stages for interpolation
53 pub const EXTRA_STAGES: usize = I - S;
54}