Try Rumoca in your browser (no installation required).
Rumoca is a modern Modelica compiler written in Rust.
It provides:
- an end-to-end compilation pipeline from Modelica source to DAE
- a Rust-native DAE simulation stack focused on robust, high-quality runs
- code generation templates for multiple targets
- LSP, formatter, linting, Python, and WASM integrations
- Full compiler pipeline: parse -> resolve -> typecheck -> instantiate -> flatten -> DAE
- Multi-file session API for CLI, LSP, WASM, and tests (
rumoca-session) - DAE simulation with exact AD Jacobians/mass terms and solver fallbacks (
rumoca-sim-diffsol) - Structural preparation and IC planning for robust initialization (
rumoca-phase-structural,rumoca-sim-core) - Template-based codegen to CasADi, C, JAX, Julia MTK, ONNX, and Modelica render targets
- MLS contract test framework (
rumoca-contracts) - Spec-driven quality gates (including SPEC_0021 and SPEC_0025)
- Rust toolchain from
rust-toolchain.toml(nightly,wasm32-unknown-unknowntarget)
cargo build --workspacerumoca: user-facing Modelica CLI (compile,simulate,check,fmt,lint,project,completions)rum: developer workflow CLI (test,ci-parity,vscode-dev,wasm-test,coverage, hook/release tooling)
Examples:
# User-facing
cargo run -p rumoca -- lint path/to/model.mo
cargo run -p rumoca -- project sync --prune-orphans
# Developer-facing
cargo run --bin rum -- test
cargo run --bin rum -- vscode-dev -w dev/samplecargo run -p rumoca -- \
compile path/to/model.mo \
--model MyModel \
--json--model is optional when the file has a single unambiguous model candidate.
cargo run -p rumoca -- \
simulate path/to/model.mo \
--model MyModel \
--t-end 1.0cargo run -p rumoca -- fmt --check path/to/models
cargo run -p rumoca -- fmt path/to/modelscargo run -p rumoca -- lint path/to/modelscargo run -p rumoca-tool-lsp --bin rumoca-lspcargo run -p rumoca -- completions bash
cargo run --bin rum -- completions bashcargo install rumocapip install rumoca| Stage | Crate | Main Responsibility |
|---|---|---|
| Parse | rumoca-phase-parse |
Parse Modelica source into AST/class tree |
| Resolve | rumoca-phase-resolve |
DefId assignment, scope setup, name resolution |
| Typecheck | rumoca-phase-typecheck |
Type resolution, dimension evaluation, structural parameters |
| Instantiate | rumoca-phase-instantiate |
Extends/modifier application, model instantiation |
| Flatten | rumoca-phase-flatten |
Hierarchy flattening, connection expansion, residual equations |
| ToDAE | rumoca-phase-dae |
Variable classification and DAE construction |
| Structural | rumoca-phase-structural |
BLT, incidence/matching, IC plan generation |
| Simulate | rumoca-sim-core, rumoca-sim-diffsol |
IC solving + runtime integration |
| Codegen | rumoca-phase-codegen |
Template-driven target generation |
Session pipeline invariants and failure contracts:
crates/rumoca-session/PIPELINE_INVARIANTS.md
| Crate | Key Features |
|---|---|
rumoca |
Primary compiler crate and end-user CLI (check/compile/simulate/fmt/lint/project) plus compiler API (Compiler, CompilationResult) |
rumoca-session |
Unified multi-file session API, parallel parse/compile helpers, best-effort compile reports |
rumoca-tool-fmt |
Modelica formatter engine used by rumoca fmt and dev tooling |
rumoca-tool-lint |
Modelica lint engine (library API) with configurable rules and severity levels |
rumoca-tool-lsp |
Language server (rumoca-lsp) with diagnostics, completion, hover, symbols, formatting, code actions |
rumoca-tool-dev |
Cross-platform developer workflows (rum): hooks, checks, release, WASM, VSCode, Python |
rumoca-bind-wasm |
WASM bindings for parse/lint/check/compile and editor workflows |
rumoca-bind-python |
Python bindings for parse/lint/check/compile and template code generation |
| Crate | Key Features |
|---|---|
rumoca-core |
Shared types, IDs, diagnostics utilities, MSL cache path resolution |
rumoca-ir-ast |
Class-tree IR structures for parsed/resolved/typed model representation |
rumoca-ir-flat |
Flat model IR with globally unique variables/equations |
rumoca-ir-dae |
Canonical hybrid DAE IR (continuous + discrete equations) |
rumoca-eval-const |
Compile-time expression evaluation (dimensions, parameters, constant functions) |
rumoca-eval-runtime |
Runtime evaluator with SimFloat abstraction and dual-number AD support |
| Crate | Key Features |
|---|---|
rumoca-phase-parse |
Parol-based Modelica grammar parser |
rumoca-phase-resolve |
Scope graph and cross-reference resolution |
rumoca-phase-typecheck |
Type/variability/causality checks and dimension inference |
rumoca-phase-instantiate |
Model instantiation and modification propagation |
rumoca-phase-flatten |
Connection equation generation, algorithm handling, flat equation construction |
rumoca-phase-dae |
Flat-to-DAE transformation with balance-oriented variable/equation accounting |
rumoca-phase-structural |
Structural analysis, BLT decomposition, IC plan creation |
rumoca-phase-codegen |
Minijinja-based template rendering for code and model outputs |
| Crate | Key Features |
|---|---|
rumoca-sim-core |
BLT-guided IC solver blocks (direct/newton/torn/coupled paths) |
rumoca-sim-diffsol |
DAE runtime integration, solver fallbacks, timeout budgeting, diagnostics/introspection hooks |
rumoca-contracts |
MLS contract registry, execution, and compliance reporting framework |
Built-in templates in rumoca-phase-codegen include:
CASADI_SXCASADI_MXCYECCAJULIA_MTKJAXC_CODEONNXDAE_MODELICAFLAT_MODELICA
You can use built-in template constants or provide custom template files.
The simulator stack is designed to improve result quality and avoid fragile shortcuts.
Key capabilities:
- Exact Jacobian-vector and mass-term evaluation via AD (
Dual/SimFloatpath) - Structured DAE preparation before runtime integration, including:
- derivative expansion and alias cleanup
- structural index-reduction pass for missing derivative rows
- promotion/demotion of state/algebraic variables based on equation structure
- orphan variable pinning for determinism
- Initial condition solving using structural IC plans, with Newton fallback when needed
- Multi-method integration fallback sequence (BDF, TR-BDF2, ESDIRK34 with startup profiles)
- Wall-clock timeout budgets enforced across setup, IC, and integration stages
- Introspection/trace hooks for deep simulation debugging
Useful simulation/debug environment flags:
RUMOCA_SIM_TRACE=1RUMOCA_SIM_INTROSPECT=1RUMOCA_SIM_INTROSPECT_EQ_LIMIT=<N>RUMOCA_DEBUG=1
MSL workflows target Modelica Standard Library v4.1.0.
Cache behavior:
- default cache:
<workspace>/target/msl - override:
RUMOCA_MSL_CACHE_DIR=/abs/or/relative/path
Run full MSL pipeline tests (release mode is required for practical runtime):
cargo test --release --package rumoca-test-msl --test msl_tests -- --ignored --nocaptureSimulation subset controls for faster iteration:
RUMOCA_MSL_SIM_MATCH=<comma-separated substrings>RUMOCA_MSL_SIM_LIMIT=<N>RUMOCA_MSL_SIM_SET=short|long|full(default:short)RUMOCA_MSL_SIM_SET_LIMIT=<N>(default:180, used byshort/long)RUMOCA_MSL_SIM_TARGETS_FILE=<json>(overrides default committed target set)RUMOCA_MSL_SIM_SETis applied within the selected target list; it does not expand beyond that list.
Only explicit example models are simulated in the main MSL simulation sweep:
Modelica.*.Examples.*
Default compile/balance/simulation scope is the committed 180-model explicit
example target file:
crates/rumoca-test-msl/tests/msl_tests/msl_simulation_targets_180.json.
Use RUMOCA_MSL_SIM_TARGETS_FILE=<json> to run an alternate or full model list.
Single-model OMC vs Rumoca overlay plot (regenerates both traces on each run):
cargo run --release --package rumoca-tool-dev --bin rumoca-msl-tools -- \
plot-compare --model Modelica.Blocks.Examples.PID_ControllerDefaults:
- rumoca trace:
target/msl/results/sim_traces/rumoca/<model>.json - OMC trace:
target/msl/results/sim_traces/omc/<model>.json - output HTML:
target/msl/results/sim_trace_plots/<model>.html
Canonical gate baseline (committed):
crates/rumoca-test-msl/tests/msl_tests/msl_quality_baseline.json- includes minimal compile/balance/simulation counts plus OMC parity distributions (runtime speedup ratio + trace-accuracy stats).
Ephemeral run artifacts (regenerated per run in cache):
target/msl/results/msl_results.jsontarget/msl/results/omc_reference.json(run with--model-timeout-seconds 30)target/msl/results/omc_simulation_reference.jsontarget/msl/results/sim_trace_comparison.jsontarget/msl/results/msl_quality_current.json(current run snapshot used for baseline promotion)
The simulation target set used for scoreboard runs:
crates/rumoca-test-msl/tests/msl_tests/msl_simulation_targets_180.json
Promote latest run to committed baseline after review:
cargo run --release --package rumoca-tool-dev --bin rumoca-msl-tools -- \
promote-quality-baselineFor compiler-affecting PRs, compare MSL results to this baseline and report:
- compiled model count delta
- compilation rate on simulatable models delta (
compiled/simulatable) - non-simulatable non-partial model count delta
- balanced model count delta
- initial-balance OK model count delta
- initial-balance deficit model count delta
- compile phase time delta
- both-balanced agreement delta
- balanced-but-eq/var-count-differs-vs-OMC count delta
- rumoca-unbalanced-vs-OMC-balanced count delta
- rumoca-failed-vs-OMC-succeeded count delta
No regressions are allowed unless explicitly justified and approved. Baseline updates are explicit: run tests, inspect target/msl/results/msl_quality_current.json, then promote with rumoca-msl-tools promote-quality-baseline (from rumoca-tool-dev).
Related specs:
spec/SPEC_0021_CODE_COMPLEXITY.mdspec/SPEC_0025_PR_REVIEW_PROCESS.mdspec/SPEC_0030_COVERAGE_TRIM_PROCESS.md
Install repository-managed hooks:
cargo run --bin rum -- install-git-hooksCurrent pre-commit checks (fast path):
rum check-rust-file-lines(staged files, SPEC_0021 guard)cargo fmt --all -- --checkcargo clippyon changed crates (or workspace when needed)cargo docwithRUSTDOCFLAGS="-D warnings"on changed crates (or workspace when needed)
Current pre-push checks (CI-parity, excluding slow MSL/coverage jobs):
rum check-rust-file-lines --all-filesrum ci-parity(fmt + clippy + rustdoc + workspace tests)
Run the same CI-parity gate manually:
cargo run --bin rum -- ci-parityStandardized workspace coverage artifacts are generated under:
target/llvm-cov/
Generate unified workspace coverage from tests:
cargo run --bin rum -- coverageInclude ignored/slow suites (for example ignored MSL tests):
cargo run --bin rum -- coverage --include-ignoredGenerate workspace trim inventory report + candidate list from llvm-cov artifacts:
cargo run --bin rum -- coverage-reportEnforce candidate-growth guardrails against committed baseline:
cargo run --bin rum -- coverage-gatePromote current metrics as the new baseline (explicit update step):
cargo run --bin rum -- coverage-gate --promote-baselineUnified artifacts produced:
target/llvm-cov/workspace-full.jsontarget/llvm-cov/workspace-summary.json
Coverage inventory artifacts:
target/llvm-cov/coverage-trim-report.mdtarget/llvm-cov/trim-candidates.jsontarget/llvm-cov/coverage-gate.md(baseline/current diff used by the gate)
Committed coverage-trim gate baseline:
crates/rumoca-tool-dev/coverage/trim-gate-baseline.json- includes workspace line coverage metrics:
workspace_line_coverage_percent,workspace_lines_covered,workspace_lines_total
- includes workspace line coverage metrics:
Current committed workspace line coverage (from trim baseline):
75.57%(97,258 / 128,706lines)
trim-candidates.json includes both:
triage_label(dead_likely,rare_path_keep,single_use_helper_keep,needs_targeted_test,public_api_review)owner_decision(delete_candidate,keep_document_rare_path,keep_single_use_helper,keep_add_targeted_test,keep_public_api_review)- callsite stats:
callsites_same_filecallsites_workspacecallsites_other_crates
Command runbook:
target/llvm-cov/coverage-commands.txt
Coverage trim SOP (baseline triage/promotion/rollback):
spec/SPEC_0030_COVERAGE_TRIM_PROCESS.md
The VS Code extension is available as Rumoca Modelica in the marketplace and includes a bundled rumoca-lsp server.
- Extension docs:
editors/vscode/README.md - Marketplace: https://marketplace.visualstudio.com/items?itemName=JamesGoppert.rumoca-modelica
Contributions are welcome.
Project specifications:
For compiler-affecting changes, follow:
spec/SPEC_0025_PR_REVIEW_PROCESS.mdspec/README.md
Install repo hooks before opening PRs:
cargo run --bin rum -- install-git-hooks
@inproceedings{condie2025rumoca,
title={Rumoca: Towards a Translator from Modelica to Algebraic Modeling Languages},
author={Condie, Micah and Woodbury, Abigaile and Goppert, James and Andersson, Joel},
booktitle={Modelica Conferences},
pages={1009--1016},
year={2025}
}Apache-2.0 (LICENSE)