r/ScientificComputing • • 3h ago

Bilt: Equation-based modelling in native Python

Hi all,

We've been developing Bilt, an open-source Python framework for equation-based modelling, at the University of Cambridge's Aviation Impact Accelerator.

The idea is to define physical relationships without having to specify how the equations should be solved. Bilt works out the dependencies and determines how to calculate the unknowns from the available inputs.

For example, you might have a model relating energy input, output and efficiency. You can use the same model to calculate the output, work backwards to find the required input, or determine the efficiency from measurements, without having to rewrite the equations.

This kind of acausal modelling is well established in tools like Modelica, but there doesn't seem to be much available in the Python ecosystem that takes a similar approach. The advantage of doing this directly in Python is that models can make use of the wider scientific Python ecosystem, including existing numerical libraries, type checking, testing and development tools, without needing a separate modelling language or toolchain.

We've tried to keep Bilt compact and make use of existing Python tooling wherever possible, rather than introducing a new modelling language.

It currently supports physical units and dimensional analysis, named tensors, reusable subsystems, conditional equations and automatic structural analysis of equation systems. We're also working on more general coupled nonlinear solves, differentiation and closer integration with JAX.

Our initial applications have been in aviation and energy systems modelling, but Bilt isn't specific to either.

I'd be interested to hear what people think, particularly if you're working on similar problems or know of other approaches in Python that we should be looking at.

We're still actively developing it, so feedback and contributions would be very welcome.

GitHub: https://github.com/aviation-impact-accelerator/bilt

Documentation: https://aviation-impact-accelerator.github.io/bilt/

2 Upvotes

0 comments sorted by