Skip to content

Examples

Each example is a plain script that can be run from a repository checkout. The pages explain the modelling choice, show the important code, and link to the script that produces the result.

Install the optional example dependencies once:

bash
uv sync --extra examples

Choose an example

ExampleWhat it showsRun it
Harmonic oscillatorA known one-parameter optimum for checking that the data, ODE, loss, and training path are wired correctly.uv run python examples/pendulum/train_harmonic.py --no-plot
CrystallisationThe canonical end-to-end model with irregular channels, two bounded neural rates, and a population-balance ODE.uv run python examples/crystallisation/train_kinetic.py
Hybrid ODETwo predictors in different positions: one outside the solve and one inside the vector field.uv run python examples/hybrid_ode/train_hybrid_ode.py
Batch reactorEvosax followed by Optax: a mechanistic Arrhenius trunk plus a learned residual.uv run python examples/batch_reactor/train_hybrid.py
Batch reactor RLA bounded controller trained with PPO around a frozen hybrid model.uv run python examples/batch_reactor/train_rl_deactivation.py
SBML hybrid kineticsAn external SBML mechanism with one unknown rate law supplied by a predictor.uv run python examples/sbml_hybrid/train_sbml_hybrid.py
Neural polynomial kineticsA structured NeuralNPolynomial rate law instead of a black-box MLP.uv run python examples/supersaturation_poly/train_supersaturation_poly.py
Custom predictorA random Fourier feature predictor with fixed and trainable leaves.uv run python examples/custom_predictor/train_custom_predictor.py
Custom training loopA hand-written loop assembled from the public gradient kernels.uv run python examples/custom_loop/train_custom_loop.py
Mechanistic crystallisationFour fitted kinetic constants and CMA-ES, with no neural rate predictors.uv run python examples/crystallisation/train_crystallisation_mechanistic.py

Suggested order

Start with the harmonic oscillator, then read the crystallisation walkthrough. Use Hybrid ODE when predictor placement and irregular data are the questions. Move to the custom predictor or custom loop pages when the stock components no longer express your model.

Released under the BSD-3-Clause License.