Skip to content

Examples ​

Each example is a script you run from a repository checkout. Install the example dependencies once:

bash
uv sync --extra examples
ExampleWhat it teachesRun it
Harmonic oscillatorHybridModel fit, predict and simulate on a one-Parameter problem with a known answer. Start here.uv run python examples/pendulum/train_harmonic.py --no-plot
CrystallisationIrregular multi-channel data, two bounded neural rates, and a population-balance ODE.uv run python examples/crystallisation/train_kinetic.py
Hybrid ODEOne network above the solver and one inside the vector field, log warps, and the saturation penalty.uv run python examples/hybrid_ode/train_hybrid_ode.py
Tubular reactorA PDE by the method of lines: a learned rate law in a 50-cell tube observed by four sensors.uv run python examples/tubular_reactor/train_tubular_reactor.py
Batch reactorEvosax search, then Optax refinement, on an Arrhenius trunk with a learned residual, compared against per-pH Arrhenius fits on held-out runs.uv run python examples/batch_reactor/train_hybrid.py, then compare_baselines.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 rate law learned by a predictor.uv run python examples/sbml_hybrid/train_sbml_hybrid.py
Neural polynomial kineticsA structured NeuralNPolynomial rate law in place of a black-box MLP.uv run python examples/supersaturation_poly/train_supersaturation_poly.py
Custom predictorWriting a predictor family, freezing some of its arrays, and saving it.uv run python examples/custom_predictor/train_custom_predictor.py
Custom training loopA hand-written training loop built from the public gradient kernels.uv run python examples/custom_loop/train_custom_loop.py
Mechanistic crystallisationFour kinetic constants fitted with CMA-ES, no neural predictors.uv run python examples/crystallisation/train_crystallisation_mechanistic.py

Read the harmonic oscillator first, then crystallisation for a full model on real data. Hybrid ODE covers where a network sits relative to the solver. The custom predictor and custom loop pages are for when the stock components no longer fit your model.

Released under the BSD-3-Clause License.