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

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.1.tar.gz (8.3 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.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelica-0.0.1.tar.gz
  • Upload date:
  • Size: 8.3 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.1.tar.gz
Algorithm Hash digest
SHA256 cb6e978411c806c63a86928ddaf8d59df1ccc1f395df6cc5a200be2d85a4607c
MD5 79c64c9d58fa9ef1664ba9c27461557b
BLAKE2b-256 f66e3fc167afad5515150280e05f705fba70acbb6f1fc30c89b9d482f4c00a86

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modelica-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ffb8ac3031d97db3cbdda7a42fdead54557539d42608f5d57b05ace02f6e5fe5
MD5 0658aaaab114b1d5b1527f2bfae61eaf
BLAKE2b-256 79acd2e3f1fd563c73a3d70bbf902072e3c415ccc5cef28978bf33fe460f278a

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