Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#3309 closed defect (fixed)

A case of Assert malfunctioning?

Reported by: massimo ceraolo Owned by:
Priority: normal Milestone: 1.9.3
Component: Run-time Version: trunk
Keywords: Cc:

Description

The small package below shows what I presume is an OM (r25870) issue regarding assert.

Run “AssertGood”: the sentence “* AssertMessage *” is correctly displayed.
Run “AssertWrong”: the sentence “* AssertMessage *” is NOT displayed.

package TestAssert
  model AssertWrong

    TestLoad resistor annotation(Placement(visible = true, transformation(extent = {{-50, -10}, {-30, 10}}, rotation = 0)));
    Modelica.Electrical.Analog.Sources.TableCurrent tableCurrent(table = [0, 1; 10, 1; 10, 110; 200, 110; 200, 0]) annotation(Placement(visible = true, transformation(origin = {28, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 270)));
    Modelica.Electrical.Analog.Basic.Ground ground annotation(Placement(visible = true, transformation(extent = {{-10, -48}, {10, -28}}, rotation = 0)));
  equation 
    connect(resistor.n, ground.p) annotation(Line(points = {{-30, -6.1}, {-29.9, -6.1}, {-29.9, -28}, {0, -28}}, color = {0, 0, 255}));
    connect(tableCurrent.p, resistor.p) annotation(Line(points={{28,10},{28,10},
            {28,20},{-30,20},{-30,5.9},{-29.9,5.9}},                                                                            color = {0, 0, 255}));
    connect(tableCurrent.n, ground.p) annotation(Line(points = {{28, -10}, {28, -28}, {0, -28}}, color = {0, 0, 255}));
    annotation(experiment(StopTime = 500, NumberOfIntervals = 5000), Diagram(coordinateSystem(extent = {{-80, -60}, {80, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-80, -60}, {80, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
  end AssertWrong;

  model AssertGood

    TestLoad resistor annotation(Placement(visible = true, transformation(extent = {{-50, -10}, {-30, 10}}, rotation = 0)));
    Modelica.Electrical.Analog.Basic.Ground ground annotation(Placement(visible = true, transformation(extent = {{-10, -48}, {10, -28}}, rotation = 0)));
    Modelica.Electrical.Analog.Sources.ConstantCurrent constCurrent(I = 120) annotation(Placement(visible = true, transformation(origin = {22, 0}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  equation 
    connect(constCurrent.n, ground.p) annotation(Line(points = {{22, -10}, {22, -28}, {0, -28}}, color = {0, 0, 255}));
    connect(constCurrent.p, resistor.p) annotation(Line(points={{22,10},{22,20},
            {-29.9,20},{-29.9,5.9}},                                                                        color = {0, 0, 255}));
    connect(resistor.n, ground.p) annotation(Line(points = {{-30, -6.1}, {-29.9, -6.1}, {-29.9, -28}, {0, -28}}, color = {0, 0, 255}));
    annotation(experiment(StopTime = 500, NumberOfIntervals = 5000), Diagram(coordinateSystem(extent = {{-80, -60}, {80, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-80, -60}, {80, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
  end AssertGood;

  model TestLoad

    Modelica.Electrical.Analog.Basic.Resistor R0(final R = 1e-4) annotation(Placement(transformation(origin = {24, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
    Modelica.Electrical.Analog.Interfaces.Pin p annotation(Placement(transformation(extent = {{90, 50}, {110, 70}}), iconTransformation(extent = {{91, 49}, {111, 69}})));
    Modelica.Electrical.Analog.Interfaces.NegativePin n annotation(Placement(transformation(extent = {{90, -70}, {110, -50}}), iconTransformation(extent = {{90, -71}, {110, -51}})));
    parameter Modelica.SIunits.Capacitance CBattery = 36000;
  equation 
    connect(R0.n, n) annotation(Line(points={{14,60},{6,60},{6,-58},{100,-58},{100,
            -60},{100,-60}},                                                                                     color = {0, 0, 255}));
    connect(R0.p, p) annotation(Line(points = {{34, 60}, {100, 60}, {100, 60}, {100, 60}}, color = {0, 0, 255}));
    assert(n.i < 100, "*** AssertMessage ***\n");
    annotation(Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}, grid = {2, 2}, initialScale = 0.1), graphics), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics={  Text(origin = {-12, 0}, lineColor = {0, 0, 255}, extent = {{-100, 150}, {100, 110}}, textString = "%name"), Rectangle(origin = {-29, 0}, extent = {{-11, 30}, {9, -30}}), Line(origin = {31.7391, 42.8678}, points = {{-61.7391, -16.8678}, {62.2609, 17.1322}, {60.2609, 15.1322}}), Line(origin = {36, -44}, points = {{-64, 18}, {64, -18}})}));
  end TestLoad;
end TestAssert;

Change History (6)

comment:1 by massimo ceraolo, 10 years ago

Milestone: Future1.9.3
Priority: highnormal

comment:2 by Per Östlund, 10 years ago

Component: UnknownRun-time

To clarify, asserts are triggered in both cases, but the message is not displayed when simulating AssertWrong.

comment:3 by Martin Sjölund, 9 years ago

I get the message for AssertWrong, if simulating for a longer time (before then, the assertion is not shown since a valid solution is found):

./TestAssert.AssertWrong -override stopTime=300
assert            | warning | The following assertion has been violated at time 10.000000
|                 | |       | tableCurrent.i < 100.0
assert            | debug   | Unhandled Assertion-Error

comment:4 by massimo ceraolo, 9 years ago

Yes!
Something must have be changed for this ticket between its opening and today.
I checked with a more recent version of OM and this issue is not there anymore.
Therefore, I'm going to close this ticket.

BTW: My OMedit reports as version v1.9.3-dev-956-g91eaa01

while the file from which I installed OM is: OpenModelica-v1.9.3-dev-413-g8762871.exe

Is it correct? which version am I running?

comment:5 by massimo ceraolo, 9 years ago

Resolution: fixed
Status: newclosed

comment:6 by Martin Sjölund, 9 years ago

I guess OpenModelica.git v1.9.3-dev-413-g8762871 is based on OMCompiler.git v1.9.3-dev-956-g91eaa01. The Linux version reports version as "Connected to OpenModelica OpenModelica 1.9.3~dev-577-g660f4c7" (it reports which repository the version is based on).

Note: See TracTickets for help on using tickets.