r/coolgithubprojects • • Oct 12 '26

I built an open-source scientific modeling engine because simulations should be reproducible, not just look convincing

Post image

I've been working on an open-source project called Axiomize.

One problem I've run into with scientific modeling is how easy it is to produce a convincing simulation without making the underlying assumptions, units, solver choices, and validation steps explicit.

A model might run successfully and generate a nice-looking graph, but that doesn't necessarily mean the equations are physically reasonable or that someone else can reproduce the result.

I wanted to build something that makes those details harder to ignore.

Axiomize is a Python-based scientific modeling engine built around a versioned, machine-readable Model IR (intermediate representation).

Instead of keeping everything scattered across notebooks and scripts, the idea is to describe a model in a structured format and make its assumptions, parameters, equations, constraints, and validation results inspectable.

What it supports

The engine covers several areas of scientific modeling:

  • Mathematical and dimensional consistency checks

  • Algebraic equations and nonlinear solvers

  • Ordinary and partial differential equations

  • Differential-algebraic and stochastic systems

  • Optimization and control systems

  • Network and agent-based models

  • Discrete-event and hybrid simulations

  • Multiphysics modeling workflows

  • Parameter fitting and calibration

  • Uncertainty and sensitivity analysis

  • Bayesian inference and diagnostics

  • Causal modeling with identification checks

  • Stability, bifurcation, and numerical convergence analysis

  • Model comparison, experimental design, and surrogate modeling

It also includes a verification workflow that distinguishes numerical errors from uncertainty in the underlying model.

One of the changes in v1.13.0 is physical-plausibility validation.

Dimensional consistency is important, but it's not enough.

Two equations can have perfectly valid units while one violates a physical constraint.

The new validation examples demonstrate this using drag-force models, checking conservation, passivity, and agreement with independent analytical references rather than relying only on whether the simulation completes.

I've also been working on reproducible run records and visualization exports.

Reproducibility and export

Models can be exported into several formats, including JSON, Python, Jupyter notebooks, SBML, CellML, and Modelica, subject to the model and adapter capabilities.

Axiomize records modeling decisions and execution information so results can be checked or reproduced later.

Using it with AI agents

Another part of the project is making scientific tools accessible through:

  • A Python API and CLI

  • A REST interface

  • An MCP server for compatible AI clients

  • An Agent Skill describing the modeling workflow

The important distinction is that the model doesn't get to declare its own scientific result correct just because its reasoning sounds plausible. Numerical and structural checks are performed by the scientific tooling.

Installation

The main Python package is on PyPI:

https://pypi.org/project/axiomize/

pip install axiomize

There's also an npm package:

https://www.npmjs.com/package/axiomize

npm install -g axiomize

The npm distribution is a Node.js launcher for the Python CLI. It isn't a standalone JavaScript scientific engine and still requires the Python package.

Current version: v1.13.0

The GitHub repository includes source code, examples, documentation, automated tests, and scientific validation workflows.

The release pipeline includes installed-package testing on Linux, Windows, and macOS.

Limitations

I don't want to suggest that this automatically makes every scientific model correct.

It can catch certain numerical, dimensional, and physical-consistency problems, but scientific validity still depends on the model, evidence, assumptions, and experimental validation.

Some advanced backends, including PyMC/JAX and FEniCS, require additional dependencies.

The project is still evolving, and broader independent validation is important.

It's MIT-licensed and open source.

GitHub:
https://github.com/Furox-Art/axiomize

PyPI:
https://pypi.org/project/axiomize/

npm:
https://www.npmjs.com/package/axiomize

Documentation:
https://furox-art.github.io/axiomize/

I'd especially appreciate feedback from people working with scientific Python, numerical simulation, mathematical modeling, or reproducible research.

What would you consider the most important requirement for trusting a scientific simulation produced by an automated modeling system?

9 Upvotes

9 comments sorted by

1

u/hsauro 3d ago

Can you give an example of building and modeling a small metabolic pathway? I am interested in how you handle parameter provenance and annotation of the model entities (state variables)

1

u/Emergency-Tutor-7 2d ago

Here is a small one I just ran: three irreversible Michaelis-Menten steps in series, substrate -> midA -> midB -> out.

from axiomize.general_engine import simulate_model
from axiomize.model_ir import ModelIR

MODEL = {
    "schema_version": "1.0", "name": "linear-pathway-mm", "domain": "systems-biology",
    "family": "ode", "independent_variable": "t", "independent_unit": "dimensionless",
    "variables": [
        {"name": "substrate", "unit": "mmol/L", "initial": 10.0, "bounds": [0.0, None]},
        {"name": "midA", "unit": "mmol/L", "initial": 0.0, "bounds": [0.0, None]},
        {"name": "midB", "unit": "mmol/L", "initial": 0.0, "bounds": [0.0, None]},
    ],
    "parameters": [
        {"name": "vmaxup", "unit": "mmol/L", "value": 0.5, "bounds": [0.0, None]},
        {"name": "kmup", "unit": "mmol/L", "value": 1.5, "bounds": [0.0, None]},
        {"name": "vmaxmid", "unit": "mmol/L", "value": 0.4, "bounds": [0.0, None]},
        {"name": "kmmid", "unit": "mmol/L", "value": 3.0, "bounds": [0.0, None]},
        {"name": "vmaxout", "unit": "mmol/L", "value": 0.6, "bounds": [0.0, None]},
        {"name": "kmout", "unit": "mmol/L", "value": 0.8, "bounds": [0.0, None]},
    ],
    "equations": [
        {"target": "substrate", "kind": "derivative", "expression": "-vmaxup*substrate/(kmup+substrate)"},
        {"target": "midA", "kind": "derivative",
         "expression": "vmaxup*substrate/(kmup+substrate) - vmaxmid*midA/(kmmid+midA)"},
        {"target": "midB", "kind": "derivative",
         "expression": "vmaxmid*midA/(kmmid+midA) - vmaxout*midB/(kmout+midB)"},
    ],
    "assumptions": ["well-mixed isothermal compartment", "irreversible single-substrate saturation"],
}

r = simulate_model(ModelIR.from_dict(MODEL), t_span=(0.0, 60.0), points=5)

substrate: [10.0, 3.909, 0.2934, 0.0024, 0.0] midA: [0.0, 3.7317, 3.8606, 1.4204, 0.2818] midB: [0.0, 0.4188, 0.5021, 0.2618, 0.0592]

Now the two things you actually asked about, warts left in.

Parameter provenance. There is no per-parameter source field. A parameter is value/unit/bounds/fit/prior/description, and provenance is a model-level append-only list of {action, detail} events, so the example records a dict keyed by parameter name under one event:

"provenance": [{"action": "parameter_source", "detail": {
    "vmaxup": {"source": "chemostat-run-2024", "kind": "measured"},
    "kmup":   {"source": "chemostat-run-2024", "kind": "fitted"},
    "vmaxmid": {"source": "literature", "kind": "assumed"}}}]

Nothing enforces that every parameter appears there, so it is a convention rather than a check, and it does not reach the SBML annotation. What is enforced is the run side: a RunState manifest records input_hash, seeds, solver settings and every backend version, is written as integrity-hashed run.json/manifest.json, and compare_run_states names which recorded input changed when two runs diverge. So parameter history is reproducible rather than citable.

Annotation of entities. Variables carry unit, role, initial, bounds and a free-text description, and units are mandatory (require_units=True is fail-closed, and unit_declaration_audit lists anything that silently defaulted to dimensionless). What is missing is what an SBML person looks for first: no MIRIAM RDF, no sboTerm, no ChEBI/KEGG/UniProt identifiers on species or parameters. The SBML L3V2 export writes species and parameters with id/name, turns each derivative into a rateRule, and the only annotation it emits is an axiomize:modelIR element holding units and assumptions. No reactions, no fbc, no stoichiometry matrix - a pathway is an ODE system in the IR, not a reaction network.

Two things I ran into building the example:

  • The dimensional gate uses a closed unit table and it has no flux unit. mmol/L and mol/L are listed, mmol/L/s is not, so a Vmax cannot be declared in concentration per time yet. I ran with a normalized time axis (independent_unit dimensionless) to get past it.

  • SBML export fails on species names containing a digit or an underscore: sympy renders s0 or vmax_uptake as an mml:msub and ElementTree then dies with "unbound prefix". substrate/midA export fine.

If I had to pick the next piece that matters for anything metabolomics adjacent: MIRIAM + SBO on species and parameters, then a real reaction list with stoichiometry and fbc bounds instead of rateRules.

1

u/hsauro 2d ago

I would recommend, unless you’ve done so already, to define a programming agnostic format. As you suggest elsewhere Python notebooks are fragile and have a short shelf life. This is the reason Sbml was developed to decouple a models description from it executable format. Have you seen the antimony format, it’s compatible with Sbml but it’s human readable. Users like it because it has a very shallow learning curve.

1

u/Emergency-Tutor-7 2d ago

Antimony is a good call and I don't support it yet. The only human-readable thing I have is the Model IR itself, which is readable but not pleasant to write by hand.

What exists today: the IR is format-agnostic (variables, parameters with units and bounds, equations, assumptions) with export adapters for SBML L3V2, CellML 2.0 and Modelica. SBML export writes species and parameters and turns each derivative into a rateRule, and it carries units and assumptions in an annotation block so the artifact keeps its own context.

Antimony would be the smallest useful adapter rather than a second model parser: libAntimony gives SBML to Antimony, so the path is IR to SBML to Antimony, and it gets the shallow learning curve you mean. I'd want reactions and stoichiometry in the export first though, since right now a pathway is an ODE system, and Antimony's strongest selling point is expressing reaction networks readably.

Thanks for the pointer. I'll open a repo issue so the progress is followable.

1

u/hsauro 2d ago

Readability, reuse, and persistence over long time I feel are important to science. Sbml models from 2003 can still be run today. An impressive example is latex, one can still view latex files written in the 1980s. I’ll watch your repo to see how you get on. What struck me about your intro was your observation that Python notebooks are unreliable for preserving scientific knowledge. I agree with you completely based on my own experience.

1

u/Emergency-Tutor-7 2d ago

The persistence argument is the one I find hardest to argue with. The IR is JSON with a schema_version and an explicit migration path - from_dict(..., allow_migration=True) still migrates 0.9 payloads to 1.0 - which buys versioning, but it does not buy a twenty-year track record. Nothing I write in 2026 becomes readable in 2046 because I put a version field in it.

That is why the exports matter more than the IR. SBML L3V2, CellML 2.0 and Modelica are the artifacts with the longevity you are describing, and the IR's job is to make them checkable before they leave. If a model cannot be rebuilt from the exported artifact alone, the export is decorative.

Antimony is on the list after reactions and stoichiometry, for exactly the reason you gave: shallow learning curve, SBML-compatible, so it does not start a second lineage.

1

u/Emergency-Tutor-7 4h ago

That persistence argument is the one I keep coming back to. SBML and Modelica files survive because the file carries the structure, so a 2003 model still runs; a script that encoded the same model in Python does not survive, because it carries the author's environment instead. That is why axiomize writes the Model IR as the artifact rather than only generating code - the thing left behind should be readable by someone who is not me.

Where I am still unsure is how much semantic load the export can carry before it stops being faithful to the model I meant. The unit checks survive the trip; the modelling intent does not always.

2

u/[deleted] Oct 12 '26

[removed] — view removed comment

1

u/Emergency-Tutor-7 Oct 12 '26

Thanks, that's a good suggestion. I actually have an example very close to what you're describing, and I agree it should be more prominent.

The physical-plausibility example compares a correct drag model against two deliberately broken versions (wrong sign and wrong scale). All three pass the structural and dimensional checks, but the incorrect models fail the physical validation against energy conservation and an independent analytical solution.

Here's the example:
https://github.com/Furox-Art/axiomize/blob/main/examples/physical_plausibility_validation.py

And yes, the versioned Model IR includes solver configuration: backend, method, relative and absolute tolerances, maximum steps, and fallbacks.

The run records also capture the actual solver settings, random seed, software versions, and integrity hashes. There's a separate example demonstrating reproducibility and detecting changes in solver tolerances:

https://github.com/Furox-Art/axiomize/blob/main/examples/reproducibility_run_record.py

That doesn't guarantee identical results across different environments, but it makes the relevant differences inspectable.

I appreciate the feedback. A concrete before-and-after example definitely communicates the value better than just listing features.