Opened 7 years ago

Closed 7 years ago

#4530 closed defect (fixed)

Wrong implementation of sub/superSample in conjunction with shiftSample

Reported by: Rüdiger Franke Owned by: Rüdiger Franke
Priority: high Milestone: 1.12.0
Component: Backend Version:
Keywords: Cc: Adrian Pop, Volker Waurich

Description (last modified by Rüdiger Franke)

Modelica spec 3.3 Rev1, section 16.5.2 Sub-clock conversion specifies that subSample and superSample do not change the initial tick of a clock. See the following example:

model TwoClocks
  Real x1(start = 0);
  Real x2(start = 0);
  Clock c1 = shiftSample(Clock(1.0), 1, 2);
  Clock c2 = superSample(c1, 2);
equation
  when c1 then
    x1 = sample(time);
  end when;
  when c2 then
    x2 = sample(time);
  end when;
end TwoClocks;

Here the first tick of c1 and c2 should be at 1/2s. The Cpp runtime generates the first tick of c2 at 1/4s.

Two attempts were made to fix this:

The first rigorous attempt destroyed event clocks:
https://github.com/OpenModelica/OMCompiler/commit/edd5dda09c83358f72eaa91013e93b0dbc3a619d

The second attempt still resulted in failed validations for Modelica_Synchronous_cpp:
https://github.com/OpenModelica/OMCompiler/commit/6554061cfcd98080c64f4756464dc3f1895a78f8

Verification failed for the following models:

    Modelica_Synchronous.Examples.Elementary.BooleanSignals.BackSample
    Modelica_Synchronous.Examples.Elementary.BooleanSignals.Hold
    Modelica_Synchronous.Examples.Elementary.BooleanSignals.ShiftSample
    Modelica_Synchronous.Examples.Elementary.ClockSignals.ShiftSample
    Modelica_Synchronous.Examples.Elementary.IntegerSignals.BackSample
    Modelica_Synchronous.Examples.Elementary.IntegerSignals.Hold
    Modelica_Synchronous.Examples.Elementary.IntegerSignals.ShiftSample
    Modelica_Synchronous.Examples.Elementary.RealSignals.BackSample
    Modelica_Synchronous.Examples.Elementary.RealSignals.FractionalDelay
    Modelica_Synchronous.Examples.Elementary.RealSignals.Hold
    Modelica_Synchronous.Examples.Elementary.RealSignals.HoldWithDAeffects1
    Modelica_Synchronous.Examples.Elementary.RealSignals.HoldWithDAeffects2
    Modelica_Synchronous.Examples.Elementary.RealSignals.ShiftSample

Both attempts have been reverted. The problem persists and is most likely located in the backend.

Change History (4)

comment:1 by Rüdiger Franke, 7 years ago

Component: Cpp Run-timeBackend
Description: modified (diff)

comment:2 by Rüdiger Franke, 7 years ago

Cc: Volker Waurich added
Milestone: 1.13.01.12.0
Owner: changed from Volker Waurich to Rüdiger Franke
Status: newassigned

comment:3 by Rüdiger Franke, 7 years ago

This commit seems to fix the problem:

https://github.com/OpenModelica/OMCompiler/commit/0371e971141073a2b24c0bc76b0e58f0cd0cc3d8

One result under testsuite/modelica/simulation/synchronous needed to be corrected as well.

comment:4 by Rüdiger Franke, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.