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