DAE Lowering and Structural Analysis
DAE Lowering (rumoca-phase-dae)
DAE lowering eliminates the Modelica-specific surface and produces the MLS Appendix B canonical system (see The Four IRs). The transformations with the most moving parts:
pre()elimination. Everypre(x)becomes an explicit__pre__.*parameter slot; the runtime writes those slots at event entry. This must hold in all partitions (f_x,f_z,f_m,f_c) —preexists only in AST and Flat.when/reinitlowering. When-clauses become event conditions plus guarded discrete update equations;reinit(x, e)becomes a guarded state update over current/pre slots.- Relation extraction. Every relational expression that can generate an
event gets a relation/condition variable;
conditions.relationsis the single owner of that surface. Synthetic numeric roots (fromabs,sign) live separately inevents.synthetic_root_conditions. sample/clocks. Scheduled events are explicit DAE metadata, not expressions the runtime has to discover.assert/terminate. Lowered to guardedevents.event_actionswith source spans, keeping the compute graphs pure.
A positive validation gate (appendix_b_validation) rejects any surviving
source temporal operator — the contract is enforced, not assumed.
Structural Analysis (rumoca-phase-structural)
Between the DAE and a runnable system sits structural preparation:
- Matching. Assign each equation to the unknown it will compute (maximum bipartite matching). Failure here is the structurally singular system diagnostic users see, which names unmatched equations and unknowns.
- Sorting (BLT). Order the matched system into block lower-triangular form: a sequence of scalar assignments and strongly connected components (simultaneous blocks).
- Tearing. Within coupled blocks, choose tearing variables so a small nonlinear core is iterated while the rest is evaluated explicitly.
- Index reduction. Higher-index DAEs are reduced with the Mattsson–Söderlind dummy-derivative method: constraint equations are differentiated and some derivative-defined states are demoted to dummy variables. State selection decides which candidates remain integrator states.
- Scalarization (when a backend requires it) expands symbolic arrays using shape metadata — never by parsing display strings.
The analysis products (matching, BLT blocks, tearing choices, state
selection reports) are returned as separate artifacts — they are inputs to
Solve lowering and to --inspect structure, and deliberately not stored
in the DAE.
Watching It Work
rumoca compile Model.mo --inspect structure # matching, BLT, SCCs, tearing
rumoca sim Model.mo --inspect eval # values + derivatives at a point
rumoca sim Model.mo --inspect jacobian --at "x=1@0"
These are the same tools the user guide teaches for debugging models — as a compiler developer you will mostly use them to verify that a lowering or matching change did what you intended on a specific model.