Skip to content
bilt-frameworkPublic

About

Causal and acausal systems models in Python

Resources

Stars

10 stars

Watchers

0 watching

Forks

Repository files navigation

Bilt
Causal and acausal systems models in Python

Documentation · First model · Worked examples · Discussions

Python 3.15+ MIT License

Bilt is a Python framework for scientific and engineering models built from equations and reusable systems. Describe how quantities relate, supply what you know, and ask for the value you need. Bilt determines a supported calculation instead of requiring a fixed sequence of computations.

Quick start

Bilt requires Python 3.15 or newer and uv. Released wheels are available from the Bilt package index once the release build has completed. No Rust toolchain is needed for a supported platform:

uv init --python 3.15 my-bilt-project
cd my-bilt-project
uv add bilt --index bilt=https://bilt-framework.github.io/bilt/packages/ --no-build-package bilt

The index targets Linux x86-64 (glibc 2.28+), macOS (Apple Silicon and Intel) and Windows x86-64. It serves stable releases only. For unreleased changes or an unsupported platform, install from GitHub with a Rust toolchain:

uv add "git+https://github.com/bilt-framework/bilt.git"

If your existing project uses Bilt from its previous GitHub location, run the appropriate uv add command above to update the dependency source. The named index keeps Bilt tied to its own package source rather than a similarly named package on PyPI.

Replace main.py with this model:

from bilt import Implementation, Interface, equation, field, system


@system
class Converter(metaclass=Interface):
    energy_in: float = field()
    energy_out: float = field()
    efficiency: float = field()


@equation
def energy_balance(energy_in: float, energy_out: float, efficiency: float) -> bool:
    return energy_out == energy_in * efficiency


model = Implementation(Converter, [energy_balance])

with model:
    print(Converter(energy_in=100.0, efficiency=0.4).energy_out)  # 40.0
    print(Converter(energy_out=40.0, efficiency=0.4).energy_in)  # 100.0

Run it with uv run python main.py. Both requests use the same equation; only the known values and the requested output change.

Build your first model step by step

Why Bilt?

One model, different questions

Energy balance model evaluated in three directions: forward, inverse and parameter identification.

The same relationships can be used for forward calculations, inverse questions or parameter identification where supported. You do not need to write a separate function for each direction.

Equations and acausal modelling

Reusable systems and coupled equations

Two reusable spring systems connected by parent equations, with Bilt solving a coupled linear block across both subsystem boundaries.

Build larger models from reusable systems. Bilt can solve supported coupled linear equations across subsystem boundaries without requiring you to flatten the model or assemble the matrix yourself.

Two springs in series · Coupled systems

Physical quantities and dimensional analysis

Unit conversion from 36 km/h to 10 m/s, followed by a five-second distance calculation giving 50 m, with valid and invalid dimensional relationships.

Declare physical dimensions on model fields. Bilt checks equation dimensions and converts compatible units during evaluation.

Units in models · Quantity annotations

Named tensors and uncertainty propagation

Samples of uncertain output energy mapped through the same inverse relationship to an inferred efficiency distribution.

Supply values over named dimensions such as samples, scenarios and routes. Bilt aligns and broadcasts those dimensions, allowing the same relationships to be evaluated across many cases. Propagating samples is not the same as fitting a statistical model or estimating a Bayesian posterior.

Battery-electric mission uncertainty analysis

Bilt also supports directed transforms, conditional equations, Python and JAX execution backends, and a bilt check . command for model definitions.

Where next?

  • First model — a guided introduction, from a system to forward and inverse evaluation.
  • User guide — systems, equations, units, tensors, backends and model composition.
  • Worked examples — two springs, a two-shaft gas turbine, mission uncertainty and JAX.
  • API reference — signatures, supported operations and limitations.
  • Model checking — validate model definitions locally or in CI.

Development and project status

Bilt is developed at the Aviation Impact Accelerator, University of Cambridge and remains under active development. The API may change. Not every equation can be rearranged; coupled blocks currently need to be linear in the unknowns solved together. General nonlinear coupled solving and statistical calibration are not yet supported.

To contribute:

git clone https://github.com/bilt-framework/bilt.git
cd bilt
uv sync

For an existing checkout, update the remote with git remote set-url origin https://github.com/bilt-framework/bilt.git.

Questions and suggestions are welcome in issues and discussions.

Bilt provides optional coding-assistant skills: bilt for users and bilt-development for contributors. Install the user skill with npx skills add bilt-framework/bilt --skill bilt. Skills provide instructions for assistants; they do not install the Python package.

The README figures are generated from scripts/readme_figures.json with scripts/generate_readme_svgs.py. Run python scripts/generate_readme_svgs.py --check to verify them.

Maintained by James Emberton and Sam Brockie. MIT license.

About

Causal and acausal systems models in Python

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages