tpt-science

Rust

Rust simulation & modeling substrate for science verticals: ODE/DAE, structured-grid PDE, multi-scale orchestration, probabilistic programming (NUTS), rigid-body physics, quantum state-vector sim, 2-D CT imaging, astrodynamics, and reaction-network DSL. Dual-licensed MIT OR Apache-2.0.

0 stars0 forks0 watchers5 open issuesApache License 2.0
astrodynamicsclimate-modelingcomputational-biologycomputational-fluid-dynamicscomputational-physicsdensity-functional-theorydifferential-equationselectrophysiologyhemodynamicsmolecular-dynamicsnumerical-methodspdeprobabilistic-programmingquantum-simulationrustscientific-computingsimulationtomography

Languages

Rust99.3%HTML0.4%Python0.2%Just0.1%Shell0.0%
README

tpt-science

CI license: MIT OR Apache-2.0

Simulation and modeling substrate for the TPT Solutions science verticals: differential equations, structured-grid PDE, multi-scale simulation orchestration, probabilistic programming, rigid-body physics, quantum simulation, tomographic imaging, and astrodynamics.

Dual-licensed under MIT or Apache-2.0.

Partially published to crates.io. The 18 simulation crates are on crates.io at 0.1.0. The umbrella tpt-sci, tpt-sci-units, and the tooling/binding crates (tpt-sci-cli, tpt-sci-wasm, tpt-sci-py) are not yet published and are consumed as git or path dependencies. There is no v0.1.0 git tag yet. APIs are unstable until the first tagged release.

Status

This repo is scaffolded from tpt-rust-map/template/. Build order and crate scope follow todo.md and spec.txt. Per tpt-rust-map/TODO.md, each crate's own flagged-needs-audit / flagged-deferred status is resolved before that crate is implemented — Phase 1 (scaffolding) does not require those audits.

CrateDomainStatusWrap / buildNotes
tpt-sci-odedifferential-equationsimplementedbuild from scratchfrom-scratch ODE/DAE engine (Tsit45, TR-BDF2, ESDIRK34, variable-order BDF); dense + sparse LU; forward sensitivities; f32/f64; optional Cranelift JIT (cranelift-jit); diffsol is a dev-only oracle
tpt-sci-gridpdeimplementedbuild from scratch1-D/2-D/3-D finite-difference grids; dense and sparse (CSR) Laplacians; depends on tpt-math-linalg
tpt-sci-sim-coresimulationimplementedbuild from scratchmulti-scale orchestration, ODE and diffusion sub-models, cross-scale coupling, checkpoints; depends on tpt-sci-ode, tpt-sci-grid
tpt-sci-pplprobabilistic-programmingimplementedbuild from scratch (NUTS)consolidates tpt-augur; nuts-rs wrap dropped; R-hat, ESS, divergence-rate diagnostics via Trace
tpt-sci-imageimagingimplementedbuild from scratch2-D parallel-beam CT, 3-D volume CT, and cone-beam FDK; depends on tpt-math-signal-fft, tpt-math-linalg
tpt-sci-physics-rigidphysicsimplementedbuild from scratchrigid bodies with quaternion orientation, Coulomb friction, sweep-and-prune broad phase; rapier disqualified (ADR 0007)
tpt-sci-quantumquantumimplementedbuild from scratchstate-vector (≤20 qubits) and density-matrix paths with Kraus noise channels; QuantRS2 disqualified (ADR 0007)
tpt-sci-astroastrodynamicsimplementedbuild from scratchKeplerian two-body; J2/J4 secular rates; atmospheric drag; third-body (Kozai-Lidov); solar radiation pressure
tpt-sci-reaction-networksystems-biologyimplementedbuild from scratchCatalyst.jl-style DSL → mass-action ODE; exact SSA, tau-leaping/CLE, minimal SBML reader, conservation laws; SDE/jump out of scope
tpt-sci-mdmolecular-dynamicsimplementedbuild from scratchLennard-Jones and EAM; direct-sum Ewald; SHAKE/RATTLE constraints; cell lists; RDF; depends on tpt-math-linalg
tpt-sci-dft-classicalmaterialsimplementedwrap feos (feos-dft)PC-SAFT classical/soft-matter DFT via feos; from-scratch square-gradient solver in 1-D and 3-D; MIT OR Apache-2.0
tpt-sci-kineticschemical-kineticsimplementedbuild from scratchdepends on tpt-sci-reaction-network; Arrhenius, Langmuir–Hinshelwood (multi-site), Eley–Rideal, coverage-dependent activation
tpt-sci-chemoinformaticscheminformatics / QSPRimplemented (v0.1, unpublished)build from scratchSMILES parser, molecular descriptors, Morgan fingerprints, ridge + Tanimoto-kNN QSPR; TRPA1/TRPV1 model needs user-supplied curated data (demo set is illustrative only)
tpt-sci-cfd-corefluid-dynamicsimplementedbuild from scratchdepends on tpt-math-linalg; incompressible Navier–Stokes with explicit and SIMPLE schemes, k-ε/k-ω SST, unstructured FVM/FEM
tpt-sci-hemodynamicsbiomechanicsimplementedbuild from scratchdepends on tpt-sci-cfd-core, tpt-sci-ode; 1-D compliant vessel network, Womersley flow, Windkessel 0-D/1-D/3-D coupling
tpt-sci-electrophysbiomechanicsimplementedbuild from scratchdepends on tpt-sci-ode, tpt-sci-grid; Hodgkin–Huxley and Ten Tusscher ionic models, anisotropic tensor diffusion, bidomain
tpt-sci-climateearth-scienceimplementedbuild from scratchdepends on tpt-sci-ode, tpt-math-linalg; 0-D EBM, multi-band and correlated-k radiative transfer, 3-D tracer transport, primitive-equation GCM
tpt-sci-oceanearth-scienceimplementedbuild from scratchdepends on tpt-sci-cfd-core; 2-D shallow water, 3-D z-level ocean with non-hydrostatic projection, nudging, EnKF, 3D-Var-lite
tpt-sci-dft-electronicmaterialsimplementedbuild from scratchKohn–Sham in 1-D and 3-D real space; LDA and PBE; norm-conserving local pseudopotentials; periodic k-point band structure (1-D)
tpt-sciumbrellaimplementedre-exportone dependency; every domain crate behind a feature (default: ode, grid, sim-core; full: all)
tpt-sci-unitssharedimplementedbuild from scratchtyped SI quantities and physical constants (gas constant, Stefan–Boltzmann, Earth's μ) used by kinetics, climate and astro
tpt-sci-clitoolingimplementedbuild from scratchtpt-sci command: runs reaction-network JSON specs and writes CSV
tpt-sci-wasmbindingsimplementedwasm-bindgenWebAssembly exports (run_spec, EBM, CT, lid-driven cavity) plus a browser playground
tpt-sci-pybindingsimplementedPyO3 / maturinPython bindings; excluded from the Cargo workspace so CI does not link libpython

Choose your crate

Start from the question you are trying to answer, then follow the crate.

If you want to…Start withThen
Solve an ODE / DAE systemtpt-sci-odetpt-sci-reaction-network if the system is a chemical or compartmental network
Model a reaction network (mass-action, SSA, tau-leaping, SBML)tpt-sci-reaction-networktpt-sci-ode for deterministic runs
Solve a PDE on a regular gridtpt-sci-gridtpt-sci-sim-core to couple it to ODE sub-models
Run several models at different scales togethertpt-sci-sim-coretpt-sci-ode, tpt-sci-grid
Fit parameters to data (Bayesian, NUTS)tpt-sci-ppltpt-sci-ode for ODE-based likelihoods
Reconstruct images from projections (CT)tpt-sci-imagetpt-sci-grid for the underlying geometry
Simulate rigid bodies and collisionstpt-sci-physics-rigidtpt-sci-astro for orbital motion
Simulate qubits or noisy quantum circuitstpt-sci-quantum—
Orbital mechanics and perturbationstpt-sci-astrotpt-sci-ode for custom force models
Molecular dynamics of a particle systemtpt-sci-mdtpt-sci-dft-classical for interfacial density profiles
Classical / soft-matter DFT (adsorption, surface tension)tpt-sci-dft-classicaltpt-sci-kinetics for surface reactions
Surface or reactor kineticstpt-sci-kineticstpt-sci-reaction-network for the underlying CRN
Incompressible flowtpt-sci-cfd-coretpt-sci-ocean for geophysical flows
Blood flow in vessel networkstpt-sci-hemodynamicstpt-sci-cfd-core for 3-D coupling
Cardiac / neural excitationtpt-sci-electrophystpt-sci-hemodynamics for coupled physiology
Climate or atmospheric chemistrytpt-sci-climatetpt-sci-ocean for coupled ocean–atmosphere work
Ocean circulation or data assimilationtpt-sci-oceantpt-sci-cfd-core for the solver substrate
Electronic structure (Kohn–Sham)tpt-sci-dft-electronictpt-sci-md for classical atomistic work

Suggested tutorial path

  1. Foundations: tpt-sci-ode (van_der_pol) → tpt-sci-grid (diffusion).
  2. Coupling: tpt-sci-reaction-network (sir) → tpt-sci-sim-core (multi_scale_cookbook).
  3. Inference: tpt-sci-ppl (posterior).
  4. Applied domains: pick one of tpt-sci-image, tpt-sci-astro, or tpt-sci-cfd-core; each crate's README lists its own scope and limits.

The per-crate examples/ directories are the runnable reference; the Examples table below lists them.

no_std posture

All crates in this pillar are std-only by design. The tpt-math dense linear-algebra substrate and tpt-sci-ode (which implements its own ODE engine from scratch) are themselves std crates, so every simulation/physics/quantum crate transitively requires std. None currently target no_std.

Per ADR 0001, no_std is opted into per-crate, never forced workspace-wide: the CI no_std job is an intentional no-op until a crate is explicitly confirmed no_std and built with -p <crate> against thumbv6m-none-eabi. See CHANGELOG.md for the per-crate audit table.

Depending on the crates

The 18 simulation crates are on crates.io at 0.1.0, so add them directly:

[dependencies]
tpt-sci-ode = "0.1"
tpt-sci-grid = "0.1"

The umbrella crate tpt-sci is not on crates.io yet. Depend on it through git, pinned to a commit (no release tag exists yet):

[dependencies]
tpt-sci = { git = "https://github.com/tpt-solutions/tpt-science", rev = "<commit>", features = ["full"] }

Once v0.1.0 is cut from master (steps in RELEASE.md), tag = "v0.1.0" can replace rev. The tpt-math-* substrate is resolved from crates.io, so no sibling checkout is needed.

Building

This workspace depends on the tpt-math substrate (tpt-math-numeric, tpt-math-linalg, tpt-math-signal-fft), resolved as regular versioned dependencies from crates.io — no sibling checkout needed:

git clone https://github.com/tpt-solutions/tpt-science.git
cd tpt-science
cargo build --workspace
cargo test --workspace
  • Edition: 2024.
  • MSRV: 1.85 (pinned via rust-version in [workspace.package]).
  • Toolchain: fixed by rust-toolchain.toml via rustup.

Quickstart

use tpt_sci_ode::{OdeProblem, Method};

// dy/dt = -y  ->  y(t) = y0 * exp(-t)
let prob = OdeProblem::new(|_t, y, dydt| dydt[0] = -y[0], vec![1.0], 0.0).unwrap();
let y = prob.solve(Method::Bdf, 1.0).unwrap();
assert!((y[0] - std::f64::consts::E.recip()).abs() < 1e-6);

See the crate READMEs for the full API: tpt-sci-ode, tpt-sci-grid, tpt-sci-sim-core, tpt-sci-ppl, tpt-sci-image, tpt-sci-physics-rigid, tpt-sci-quantum, tpt-sci-astro, tpt-sci-reaction-network, tpt-sci-md, tpt-sci-dft-classical, tpt-sci-kinetics, tpt-sci-cfd-core, tpt-sci-hemodynamics, tpt-sci-electrophys, tpt-sci-climate, tpt-sci-ocean, tpt-sci-dft-electronic.

Examples

Every simulation crate ships a runnable examples/ program that is meatier than the README snippet — a good first place to see the API in action:

CrateExampleDemonstrates
tpt-sci-odevan_der_polVan der Pol limit cycle + dense trajectory (solve_dense)
tpt-sci-quantumbell_ghzBell/GHZ states + measurement statistics
tpt-sci-reaction-networksirFull SIR run, peak-infected tracking
tpt-sci-griddiffusion1-D diffusion of a Gaussian bump on a uniform grid
tpt-sci-sim-coremulti_scale_cookbookSIR → diffusion cross-scale coupling (composes reaction-network + grid)
tpt-sci-pplposteriorNUTS posterior + R-hat / ESS / divergence diagnostics
tpt-sci-imagereconstructionParallel-beam CT of a phantom (FBP)
tpt-sci-physics-rigidcollisionSpheres under gravity + walls, elastic collisions
tpt-sci-astropropagationLEO propagation + J2 RAAN regression
tpt-sci-mdlennard_jonesLJ fluid: velocity-Verlet trajectory + RDF
tpt-sci-dft-classicaladsorptionPC-SAFT density-profile solve (wrapped feos)
tpt-sci-kineticsreactorArrhenius + Langmuir–Hinshelwood, ODE via tpt-sci-ode
tpt-sci-cfd-corecavityLid-driven cavity, divergence-free projection
tpt-sci-hemodynamicsarterial_segmentCompliant vessel area/flow over a cardiac cycle
tpt-sci-electrophysap_waveAction-potential propagation across a tissue sheet
tpt-sci-climatewarming0-D EBM CO₂-doubling equilibrium warming
tpt-sci-oceanshallow_waterShallow-water gravity-wave propagation
tpt-sci-dft-electronicharmonic_atom1-D Kohn–Sham solve of a two-electron well

sim-core also ships decay_coupled (ODE↔diffusion coupling + checkpoint). Run any of them with, e.g.:

cargo run --example van_der_pol -p tpt-sci-ode

Benchmarking & coverage

  • Benchmarks. criterion benches live in crates/*/benches/: tpt-sci-ode (solve), tpt-sci-grid (laplacian), tpt-sci-quantum (apply_gate), and tpt-sci-image (radon) — each of the 18 simulation crates ships a representative Criterion suite. Run a single crate with cargo bench -p <crate>, or the whole workspace with cargo bench --workspace. The CI benches job runs a shortened measurement so the suite stays fast: cargo bench --workspace --benches -- --warm-up-time 0.5 --measurement-time 1 --sample-size 10.
  • Coverage. The CI coverage job produces an lcov report via cargo-llvm-cov and uploads it as a build artifact.
  • Docs. The CI doc job builds docs with RUSTDOCFLAGS=-D warnings, catching rustdoc warnings and broken intra-doc links (doctests are exercised by cargo test).

See RELEASE.md for the (currently dormant) publish/versioning process.

Changelogs

Each crate keeps its own CHANGELOG.md (initial v0.1.0 entry plus an [Unreleased] section): see e.g. crates/tpt-sci-ode/CHANGELOG.md. The workspace-level CHANGELOG.md tracks cross-cutting changes.

License

Licensed under either of MIT or Apache-2.0 at your option.

Copyright (c) 2026 TPT Solutions.