differential_equations/
lib.rs

1//! # differential-equations
2//!
3//! A Rust library for solving ODE, DAE, DDE, and SDE initial value problems.
4//!
5//! [![GitHub](https://img.shields.io/badge/GitHub-differential--equations-blue)](https://github.com/Ryan-D-Gast/differential-equations)
6//! [![Documentation](https://docs.rs/differential-equations/badge.svg)](https://docs.rs/differential-equations)
7//!
8//! ## Overview
9//!
10//! This library provides numerical solvers for:
11//!
12//! - **[Ordinary Differential Equations (ODE)](crate::ode)**: initial value problems, fixed/adaptive step, event detection, flexible output
13//! - **[Differential Algebraic Equations (DAE)](crate::dae)**: equations in the form M f' = f(t,y) where M can be singular
14//! - **[Delay Differential Equations (DDE)](crate::dde)**: constant/state-dependent delays, same features as ODE
15//! - **[Stochastic Differential Equations (SDE)](crate::sde)**: drift-diffusion, user RNG, same features as ODE
16//!
17//! ## Feature Flags
18//!
19//! - `polars`: Enable converting `Solution` to a Polars DataFrame with `Solution::to_polars()`
20//!
21//! ## Example (ODE)
22//!
23//! ```rust
24//! use differential_equations::prelude::*;
25//! use nalgebra::{SVector, vector};
26//!
27//! pub struct LinearEquation {
28//!     pub a: f64,
29//!     pub b: f64,
30//! }
31//!
32//! impl ODE<f64, SVector<f64, 1>> for LinearEquation {
33//!     fn diff(&self, _t: f64, y: &SVector<f64, 1>, dydt: &mut SVector<f64, 1>) {
34//!         dydt[0] = self.a + self.b * y[0];
35//!     }
36//! }
37//!
38//! fn main() {
39//!     let system = LinearEquation { a: 1.0, b: 2.0 };
40//!     let t0 = 0.0;
41//!     let tf = 1.0;
42//!     let y0 = vector![1.0];
43//!     let problem = ODEProblem::new(system, t0, tf, y0);
44//!     let mut solver = ExplicitRungeKutta::dop853().rtol(1e-8).atol(1e-6);
45//!     let solution = match problem.solve(&mut solver) {
46//!         Ok(sol) => sol,
47//!         Err(e) => panic!("Error: {:?}", e),
48//!     };
49//!
50//!     for (t, y) in solution.iter() {
51//!         println!("t: {:.4}, y: {:.4}", t, y[0]);
52//!     }
53//! }
54//! ```
55//!
56//! ## License
57//!
58//! ```text
59//! Copyright 2025 Ryan D. Gast
60//!
61//! Licensed under the Apache License, Version 2.0 (the "License");
62//! you may not use this file except in compliance with the License.
63//! You may obtain a copy of the License at
64//!
65//!     http://www.apache.org/licenses/LICENSE-2.0
66//!
67//! Unless required by applicable law or agreed to in writing, software
68//! distributed under the License is distributed on an "AS IS" BASIS,
69//! WITHOUT WARRANTIES OR CONDITIONS OF ANY KINeither express or implied.
70//! See the License for the specific language governing permissions and
71//! limitations under the License.
72//! ```
73
74// Prelude & User-Facing API
75pub mod prelude;
76
77// Numerical Methods
78pub mod methods;
79pub mod tableau;
80
81// Differential Equations
82pub mod dae;
83pub mod dde;
84pub mod ode;
85pub mod sde;
86
87// Output Control
88pub mod solout;
89
90// Core Structures
91pub mod control;
92pub mod error;
93pub mod solution;
94pub mod stats;
95pub mod status;
96pub mod tolerance;
97
98// Shared Traits & Utilities
99pub mod interpolate;
100pub mod linalg;
101pub mod traits;
102pub mod utils;
103
104// Derive Macros
105pub mod derive {
106    pub use differential_equations_derive::State;
107}