tpt-sci-ode
ODE/DAE solving substrate for the tpt-science pillar.
This crate implements its own ODE integrators from scratch — no
diffsol, nalgebra, or faer in the
shipped dependency graph — so the whole crate is TPT-owned code under
MIT OR Apache-2.0. It carries its own dual-licensed dense linear algebra
(DMat + LU with partial pivoting) for the implicit-method linear solves, and
depends on tpt-math-numeric for the Scalar numeric trait.
Four methods are provided (see Method):
- [
Method::Tsit45] — explicit Runge–Kutta 4(5), non-stiff. - [
Method::TrBdf2] — 2-stage SDIRK (TR-BDF2), A-stable, stiff. - [
Method::Esdirk34] — 4-stage ESDIRK order 3(4), A-/L-stable, stiff. - [
Method::Bdf] — variable-order (1–5) backward differentiation, stiff.
All use a shared adaptive-step driver with Hermite dense output, so
[OdeProblem::solve_dense] returns exact states at the requested times.
diffsol is retained only as an optional, dev-only verification oracle (feature
verify-diffsol, excluded from license scanning).
Depends on tpt-math-numeric (published, tpt-math repo).
Features
- Closure-first problem API:
OdeProblem::new(|t, y, dydt| { .. }, y0, t0). - Adaptive step-size control with dense (Hermite) output for
solve_dense. - Stiff and non-stiff methods behind one
Methodenum and onesolveentry point. - Optional Cranelift JIT right-hand side (
JitRhs) behind thejitmodule, pluggable into the sameRhsCallabletrait as a plain closure. - Event detection (
solve_events) with terminal events,Trajectorywith CSV output (solve_trajectory), andJacobianPatternwith column colouring for sparse Jacobians (jacobian_colored). - Optional
serdefeature for result types.
Example
use ;
// dy/dt = -y, y(0) = 1 -> y(1) = e^-1
let prob = new.unwrap;
let y = prob.solve.unwrap;
assert!;
Scope
v1 covers deterministic initial-value ODEs (non-stiff and stiff) with dense
output. In addition to the dense DMat
linear algebra used by the implicit methods, the crate also ships:
- A sparse counterpart
(
CsrMatrix- sparse LU with partial pivoting) for large, sparse Jacobians.
- Forward sensitivity analysis
(
forward_sensitivities) ofdy/dt = f(t, y, p)via the augmented variational system. - A
Scalar-generic (f32/f64) dense-LA + RK4 core (scalar) proving the engine math at both precisions; the public [OdeProblem] API remainsf64-instantiated (the v1 supported precision).
DAE index reduction and adjoint (reverse) sensitivity analysis remain out of scope.
License
Licensed under either of MIT or Apache-2.0 at your option.