numra_dde/lib.rs
1// Allow some clippy lints that are prevalent in numerical code
2#![allow(clippy::assign_op_pattern)]
3#![allow(clippy::needless_range_loop)]
4
5//! DDE (Delay Differential Equation) solvers for Numra.
6//!
7//! This crate provides methods for solving delay differential equations
8//! of the form:
9//!
10//! ```text
11//! y'(t) = f(t, y(t), y(t - τ₁), y(t - τ₂), ...)
12//! ```
13//!
14//! where τᵢ are the delays (constant or state-dependent).
15//!
16//! # Solvers
17//!
18//! - [`MethodOfSteps`] - Method of steps using embedded RK solver
19//!
20//! # Example
21//!
22//! ```
23//! use numra_dde::{DdeSystem, MethodOfSteps, DdeSolver, DdeOptions};
24//!
25//! // Mackey-Glass equation: y'(t) = β * y(t-τ) / (1 + y(t-τ)^n) - γ * y(t)
26//! struct MackeyGlass {
27//! beta: f64,
28//! gamma: f64,
29//! n: f64,
30//! tau: f64,
31//! }
32//!
33//! impl DdeSystem<f64> for MackeyGlass {
34//! fn dim(&self) -> usize { 1 }
35//! fn delays(&self) -> Vec<f64> { vec![self.tau] }
36//! fn rhs(&self, _t: f64, y: &[f64], y_delayed: &[&[f64]], dydt: &mut [f64]) {
37//! let y_tau = y_delayed[0][0]; // y(t - tau)
38//! dydt[0] = self.beta * y_tau / (1.0 + y_tau.powf(self.n)) - self.gamma * y[0];
39//! }
40//! }
41//!
42//! let mg = MackeyGlass { beta: 2.0, gamma: 1.0, n: 9.65, tau: 2.0 };
43//! let history = |_t: f64| vec![0.5]; // Constant history
44//! let opts = DdeOptions::default();
45//! let result = MethodOfSteps::solve(&mg, 0.0, 100.0, &history, &opts);
46//! ```
47//!
48//! Author: Moussa Leblouba
49//! Date: 3 February 2026
50//! Modified: 2 May 2026
51
52pub use numra_core::Scalar;
53
54mod history;
55mod method_of_steps;
56mod system;
57
58pub use history::{HermiteInterpolator, History, HistoryFunction};
59pub use method_of_steps::MethodOfSteps;
60pub use system::{DdeOptions, DdeResult, DdeSolver, DdeStats, DdeSystem};