Examples
Each example is a script you run from a repository checkout. Install the example dependencies once:
bash
uv sync --extra examples| Example | What it teaches | Run it |
|---|---|---|
| Harmonic oscillator | HybridModel 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 |
| Crystallisation | Irregular multi-channel data, two bounded neural rates, and a population-balance ODE. | uv run python examples/crystallisation/train_kinetic.py |
| Hybrid ODE | One 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 reactor | A 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 reactor | Evosax 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 RL | A bounded controller trained with PPO around a frozen hybrid model. | uv run python examples/batch_reactor/train_rl_deactivation.py |
| SBML hybrid kinetics | An external SBML mechanism with one rate law learned by a predictor. | uv run python examples/sbml_hybrid/train_sbml_hybrid.py |
| Neural polynomial kinetics | A structured NeuralNPolynomial rate law in place of a black-box MLP. | uv run python examples/supersaturation_poly/train_supersaturation_poly.py |
| Custom predictor | Writing a predictor family, freezing some of its arrays, and saving it. | uv run python examples/custom_predictor/train_custom_predictor.py |
| Custom training loop | A hand-written training loop built from the public gradient kernels. | uv run python examples/custom_loop/train_custom_loop.py |
| Mechanistic crystallisation | Four 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.