OM.jl

OM.jl is a Modelica compiler written in Julia. It takes Modelica models (including the Modelica Standard Library), flattens and lowers them through a Julia frontend and backend, and simulates them via the SciML / ModelingToolkit ecosystem.

The typical user flow is a single call:

using OM
sol = OM.simulate("Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum";
                  MSL_Version = "MSL:4.1.0", stopTime = 1.0)

The examples showcase also includes the validated MSL Engine1a closed-loop mechanism and the full six-axis RobotR3 system.

  • Installation — how to get OM.jl and its submodules set up.
  • Examples — worked simulations.
  • Libraries — the bundled MSL versions, installed libraries, installing one from GitHub, your own; with examples.
  • Large array models — models with thousands of components: arrays are kept, the generated code does not grow with them.
  • Scripting in Julia — the usual scripting tasks the Julia way: results, parameter sweeps, testing many models, less output.
  • Scripting (.mos) — run OpenModelica-style .mos scripts through OM.runScript.
  • Coverage — how much of the MSL runs and validates, and where the reports are.
  • Troubleshooting — slow first calls, MSL versions, translation and initialization failures, diagnostics, memory.
  • API reference — the public functions (simulate, translate, flatten, library loading, result export).

Compiler pipeline

                         OM.simulate(...)
                                |
                                v
+--------------------------- FRONTEND ---------------------------+
| Modelica source -> parse -> Absyn -> SCode                     |
|                 -> instantiate -> type -> flatten -> FlatModel |
+------------------------------+---------------------------------+
                               |
                               v
+---------------------------- BACKEND ---------------------------+
| FlatModel -> OMJLIR -> passes (records, clocks, derivatives)   |
|           -> SimCode -> passes (aliases, constants, folds)     |
|           -> Julia / ModelingToolkit codegen                   |
+------------------------------+---------------------------------+
                               |
                               v
+--------------------------- SIMULATE ---------------------------+
| ModelingToolkit problem -> SciML solver -> solution / CSV      |
+----------------------------------------------------------------+

Citing OM.jl

If you use OM.jl, please cite the journal paper and the thesis (BibTeX in CITATION.bib of the repository):

  • Tinnerholm, J., Pop, A., & Sjölund, M. (2022). A Modular, Extensible, and Modelica-Standard-Compliant OpenModelica Compiler Framework in Julia Supporting Structural Variability. Electronics, 11(11), 1772. doi:10.3390/electronics11111772
  • Tinnerholm, J. (2025). Dynamic and Variable-Structure System Modeling for Equation-Based Languages: Applications, Methods and Tools. PhD thesis, Linköping University. Linköping Studies in Science and Technology, Dissertations No. 2491. doi:10.3384/9789181183375