Skip to content

Clocked Modelica (MLS 16): clock partitioning and code generation (0.6.0) - #87

Merged
JKRT merged 5 commits into
masterfrom
clocked
Oct 16, 2026
Merged

JKRT merged 5 commits into
masterfrom
clocked

Conversation

@JKRT

@JKRT JKRT commented Oct 15, 2026

Copy link
Copy Markdown
Member

Clocked (synchronous) Modelica, MLS 16.

  • Clock partitioning (Backend.ClockPartitioning): clocks resolved (clock variables, rational, real, event and solver clocks, sub-clock operators), partitions by sample/hold boundaries and sub-clock operators, clock inference across sub-partitions.
  • Code generation (Backend.ClockedLowering): one when-clause per base clock; sub-clocks by a tick counter with noEvent guards; previous, sample, hold, subSample/superSample/shiftSample/backSample, interval() (event clocks too), firstTick(); statements sorted by their data; event clocks on compound conditions and their sub-clocks. Refused with UnsupportedLowering: solver clocks, Boolean whens inside a clocked partition, algebraic loops at a tick.
  • Discrete synthesis leaves clocked partitions' equations alone.
  • If-equations: a state an if-equation defines (nested, residual equations) stays an unknown; derivatives index reduction makes of it are read with each time's branch (MSL 4 KinematicPTP). Before, both were read back from the solution with the condition parameters' final values.

Checked locally: tests 454/454; OM.jl tests pass (6 broken); MSL validate 3.2.3 347/425, 4.1.0 435/534 (before: 347, 366; the 77 Clocked models 73).

Version 0.6.0; compat OMFrontend 1.7.4 (OpenModelica/OMFrontend.jl#105, same branch).

🤖 Generated with Claude Code

JKRT added 5 commits October 14, 2026 22:27
…of the continuous system

Backend.ClockPartitioning, after the BDAE is created: clock variables and
equations resolved to a base clock and a sub-clock (factor, shift), the
partitions split at sample/hold and sub-clock operators, clocks inferred
(clocked when-clauses, inferred factors, rational clocks related), the
clocked partitions in BACKEND_DAE.clocked. translate refuses them until
they are generated. Also: traverseExpTopDown and traverseExpClk handle
clock constants, the BDAE printer prints them. All 75 MSL 4.1.0 Clocked
models partition; four checked against omc's dumpSynchronous.

Assisted-by: Claude Opus 5.5
ClockedLowering: one when-clause per base clock; sub-clocks by a tick
counter and noEvent guards; previous, sample, hold, sub-clock operators,
interval() (event clocks too), firstTick(); statements sorted by their
data. Event clocks count whole ticks; compound event conditions become a
lifted Boolean. Clocked partition variables stay out of the discrete
synthesis (ClockPartitioning.clockedVariables). Tuple if-expressions use
ifelse.

Assisted-by: Claude Opus 5.5
The solution evaluates observed variables with the parameters' final
values: der() of an if-equation's variable (MSL 4 KinematicPTP) read
the last branch throughout. structural_simplify runs again with such
readers irreducible, accepted with the same differential states.

Assisted-by: Claude Opus 5.5
…aders

getIrreducibleVars left out a state an if-equation defines (getAllVariables
skips states outside der(); nested if-equations, residual equations): MSL 4
KinematicPTP's s became an observed ifelse read back with the final branch.
The re-simplify now keeps only the direct readers of index-reduction
derivatives of if-conditions (sd, sdd): kept as 130 unknowns, fullRobot's
friction modes moved.

Assisted-by: Claude Opus 5.5
@JKRT
JKRT merged commit 5e1bdc7 into master Oct 16, 2026
10 checks passed
@JKRT
JKRT deleted the clocked branch October 16, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant