differential_equations/tableau/
mod.rs

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