Skip to main content

numra_ode/
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#![allow(clippy::manual_memcpy)]
5#![allow(clippy::collapsible_else_if)]
6#![allow(clippy::single_match)]
7#![allow(clippy::too_many_arguments)]
8#![allow(clippy::excessive_precision)]
9#![allow(clippy::manual_clamp)]
10#![allow(clippy::identity_op)]
11#![allow(clippy::erasing_op)]
12
13//! # Numra ODE Solvers
14//!
15//! This crate provides a comprehensive suite of ODE solvers for solving
16//! initial value problems of the form:
17//!
18//! ```text
19//! dy/dt = f(t, y),  y(t0) = y0
20//! ```
21//!
22//! ## Available Solvers
23//!
24//! ### Explicit Runge-Kutta (Non-stiff)
25//! - [`DoPri5`] - Dormand-Prince 5(4) with dense output
26//! - [`Tsit5`] - Tsitouras 5(4), efficient with FSAL
27//! - [`Vern6`] - Verner 6(5), high accuracy
28//! - [`Vern7`] - Verner 7(6), higher accuracy
29//! - [`Vern8`] - Verner 8(7), very high accuracy
30//!
31//! ### Implicit Runge-Kutta (Stiff)
32//! - [`Radau5`] - Radau IIA 3-stage, L-stable (5th order)
33//! - [`Esdirk32`] - ESDIRK 3-stage, 2nd order
34//! - [`Esdirk43`] - ESDIRK 4-stage, 3rd order
35//! - [`Esdirk54`] - ESDIRK 5-stage, 4th order (L-stable)
36//!
37//! ### Multistep Methods (Stiff)
38//! - [`Bdf`] - BDF orders 1-5 with variable order
39//!
40//! ### Automatic Selection
41//! - [`auto_solve`] / [`auto_solve_with_hints`] - Automatic solver selection
42//!   based on problem characteristics
43//!
44//! ## Example
45//!
46//! ```rust
47//! use numra_ode::{OdeProblem, DoPri5, Solver, SolverOptions};
48//!
49//! // Define the Lorenz system
50//! fn lorenz(t: f64, y: &[f64], dydt: &mut [f64]) {
51//!     let sigma = 10.0;
52//!     let rho = 28.0;
53//!     let beta = 8.0 / 3.0;
54//!     dydt[0] = sigma * (y[1] - y[0]);
55//!     dydt[1] = y[0] * (rho - y[2]) - y[1];
56//!     dydt[2] = y[0] * y[1] - beta * y[2];
57//! }
58//!
59//! // Create problem
60//! let y0 = vec![1.0, 1.0, 1.0];
61//! let problem = OdeProblem::new(lorenz, 0.0, 20.0, y0.clone());
62//!
63//! // Solve with DoPri5
64//! let options = SolverOptions::default();
65//! let result = DoPri5::solve(&problem, 0.0, 20.0, &y0, &options).unwrap();
66//!
67//! println!("Final state: {:?}", result.y_final());
68//! ```
69//!
70//! Author: Moussa Leblouba
71//! Date: 9 February 2026
72//! Modified: 2 May 2026
73
74pub mod auto;
75#[cfg(feature = "autodiff")]
76pub mod autodiff_jacobian;
77pub mod bdf;
78pub mod dae_init;
79pub mod dense;
80pub mod dopri5;
81pub mod error;
82pub mod esdirk;
83pub mod events;
84pub mod index_reduction;
85pub mod problem;
86pub mod radau5;
87pub mod sensitivity;
88pub mod solver;
89pub mod step_control;
90pub mod t_eval;
91pub mod tsit5;
92pub mod uncertainty;
93pub mod verner;
94
95pub use dense::DenseOutput;
96pub use error::SolverError;
97pub use problem::{DaeProblem, OdeProblem, OdeSystem};
98pub use solver::{Solver, SolverOptions, SolverResult, SolverStats};
99pub use step_control::{PIController, StepController};
100
101// Explicit methods
102pub use dopri5::DoPri5;
103pub use tsit5::Tsit5;
104pub use verner::{Vern6, Vern7, Vern8};
105
106// Implicit methods
107pub use bdf::Bdf;
108pub use esdirk::{Esdirk32, Esdirk43, Esdirk54};
109pub use radau5::Radau5;
110
111// Automatic selection
112pub use auto::{auto_solve, auto_solve_with_hints, Accuracy, SolverHints, Stiffness};
113
114pub use sensitivity::{
115    solve_forward_sensitivity, solve_forward_sensitivity_with, solve_initial_condition_sensitivity,
116    solve_initial_condition_sensitivity_with, AugmentedSystem, ClosureSystem, ParametricOdeSystem,
117    SensitivityResult, StateTransitionResult,
118};
119
120#[cfg(feature = "autodiff")]
121pub use autodiff_jacobian::AutodiffJacobianSystem;
122
123pub use dae_init::{compute_consistent_initial, compute_consistent_initial_tol};
124
125pub use index_reduction::{
126    analyze_dae_index, analyze_system, detect_structure, reduce_dae_problem, reduce_index,
127    DaeIndexInfo, DaeStructure, ReducedDaeSystem,
128};
129
130pub use uncertainty::{
131    solve_monte_carlo, solve_trajectory, solve_with_uncertainty, UncertainParam,
132    UncertainSolverResult, UncertaintyMode,
133};
134
135pub use numra_core::{Scalar, Vector};