Skip to main content

modelica

A pure-Python Modelica toolchain: parse Modelica, flatten it to a DAE, simulate it, and interoperate with the two Modelica Association exchange standards — FMI 3.0 for single components and SSP 2.0 for systems of them.

Distribution name is modelica; the git repo keeps its historical name pymodelica. (PyPI's pymodelica is held by an abandoned Modelon/JModelica.org upload.)

pip install modelica          # core: parse + model structure, zero dependencies
pip install "modelica[sim]"   # + numpy/scipy for simulation

Status

Pre-alpha. This is a full rewrite of a 2010 Python 2 experiment — none of that code survives, only the goal. Python 3.11+.

Why

The Python side of Modelica is split: FMPy and PyFMI consume FMUs that some other tool compiled, and the tools that actually compile Modelica (Dymola, OpenModelica, JModelica) are large non-Python programs. Nothing in Python takes Modelica source all the way to a running simulation, and nothing treats the model — flat equations, the incidence structure, the index — as an ordinary Python data structure you can inspect and rewrite.

That gap is the project: a readable, dependency-light implementation where every stage is a value you can hold.

Layers

Each layer is usable without the ones above it.

Module Does
modelica.lang Modelica source → tokens → AST (hand-written lexer/parser, positions carried for diagnostics)
modelica.ir AST → flat model (variables, equations, expression IR), then matching / BLT sorting / index reduction
modelica.sim flat model → ODE/DAE problem, solver backends, event (zero-crossing) handling
modelica.fmi FMI 3.0 — read and simulate an FMU; export a flat model as one
modelica.ssp SSP 2.0 — .ssd/.ssv/.ssb inside a .ssp, and a co-simulation master over the components

See the architecture notes for the data model and the order things get built in.

Development

make install-hooks   # once after cloning: pre-commit (auto version bump + ruff), pre-push (full check)
make check           # lint + typecheck + test, exactly what CI gates on
make docs            # build the mkdocs site strictly

The toolchain is pinned in .prototools (moon + uv) — proto install brings up everything. All task ordering lives in moon.yml; CI is a single moon run :ci.

Releasing

There is no manual release step. pyproject.toml's version is the single source of truth:

  • the pre-commit hook auto-bumps the patch version whenever src/**/*.py changes;
  • scripts/ci-version-guard fails the pipeline if shipped source moved without a bump (the non-bypassable counterpart);
  • on main, moon run :release publishes to PyPI only if that version isn't there yet, via GitLab OIDC Trusted Publishing — no API token is stored anywhere.

Docs are published to GitLab Pages from the same pipeline.

License

MIT © Jorge Cardona

Trademarks

Modelica® is a registered trademark of the Modelica Association, as are FMI and SSP. They are used here in their descriptive sense — to identify the language this software parses and the standards it implements.

This project is not affiliated with, sponsored by, or endorsed by the Modelica Association. It is an independent open-source implementation. For the language itself, the specification and the Modelica Standard Library, go to modelica.org.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelica-0.0.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelica-0.0.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file modelica-0.0.2.tar.gz.

File metadata

  • Download URL: modelica-0.0.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for modelica-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ce4ed971999ab88954d5915b0d5e793c31df8d900c7d76b653ddc4093c16d40e
MD5 c42f2a438319b401ea1ed132b7b54f32
BLAKE2b-256 3ebde61b104d1f5089a79c650051b4b92eadbc549718bfd35de6361355d19789

See more details on using hashes here.

File details

Details for the file modelica-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: modelica-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for modelica-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a3d79d508ab72c922087f73b394cd9cf2e5a610a89177ad18774ae3fa332db89
MD5 6b89715caaff5b8d769b33ad4cb77de1
BLAKE2b-256 d882711ac094b5a278100311d2d75572efd56659598766bb6ba8545c294bfe68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page