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