ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

Precise execution order of multiple discrete affect

Open baggepinnen opened this issue 1 month ago • 0 comments

When two clocked partitions execute on the same time instant, their respective order of execution matters. Consider the simple test case in #2744, where an operator that changes clock base for a variable is implemented. An equation like

x(k1) ~ x(k1 - 1) + ClockChange(from = c2, to = c1)(y(k2))

implies that x depends on y, and y should thus be treated as known in this equation. However, the current implementation does not appear to guarantee that the affect of clock c2 which y is associated with runs before that of clock c1.

The equivalent modelica model

model supersample
  Real x, y;
  equation 
  x = previous(x) + superSample(y, 2);
  y = previous(y) + 1;
end supersample;

correctly updates y before x

baggepinnen avatar May 28 '24 05:05 baggepinnen