1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Safe, idiomatic Rust bindings to the [SUNDIALS](https://computing.llnl.gov/projects/sundials)
//! solver library.
//!
//! # Solvers
//!
//! | Module | Underlying library | What it solves |
//! |---|---|---|
//! | [`cvode`] | CVODE | Explicit ODE IVP: `y' = f(t, y)` |
//! | [`cvodes`] | CVODES | CVODE + forward/adjoint sensitivity |
//! | [`ida`] | IDA | Implicit DAE IVP: `F(t, y, y') = 0` |
//! | [`idas`] | IDAS | IDA + forward sensitivity |
//!
//! All four solvers use SUNDIALS's variable-order BDF (or Adams for CVODE)
//! method with an adaptive step-size controller — well-suited for stiff and
//! mildly stiff problems.
//!
//! # Choosing a solver
//!
//! - **Explicit ODE** `y' = f(t, y)` → [`cvode`] (no sensitivities) or [`cvodes`]
//! - **DAE / implicit ODE** `F(t, y, y') = 0` → [`ida`] (no sensitivities) or [`idas`]
//! - **Need `∂y/∂p`** (parameter gradients, UQ) → [`cvodes`] or [`idas`]
//!
//! # Quick start — CVODE BDF
//! ```no_run
//! use sundials_rs::cvode::{CvodeBuilder, Method};
//!
//! // dy/dt = -y, y(0) = 1.0 (exact: exp(-t))
//! let y0 = vec![1.0_f64];
//! let mut solver = CvodeBuilder::new(Method::BDF, &y0)
//! .rtol(1e-8)
//! .atol(1e-10)
//! .build(|_t, y, ydot| { ydot[0] = -y[0]; Ok(()) })
//! .unwrap();
//!
//! let (t, y) = solver.step(1.0).unwrap();
//! println!("y({t:.3}) = {:.8} (exact {:.8})", y[0], (-t).exp());
//! ```
//!
//! # Quick start — IDA (implicit ODE / DAE)
//! ```no_run
//! use sundials_rs::ida::IdaBuilder;
//!
//! // Same ODE in residual form: F = y' + y = 0
//! let y0 = vec![1.0_f64];
//! let yp0 = vec![-1.0_f64]; // consistent: y'(0) = -y(0)
//! let mut solver = IdaBuilder::new(&y0, &yp0)
//! .rtol(1e-8)
//! .atol(1e-10)
//! .build(|_t, y, yp, res| { res[0] = yp[0] + y[0]; Ok(()) })
//! .unwrap();
//!
//! let (t, y, _yp) = solver.step(1.0).unwrap();
//! println!("y({t:.3}) = {:.8} (exact {:.8})", y[0], (-t).exp());
//! ```
pub use SundialsError;