Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#3340 closed defect (fixed)

asserts inside initial equation triggers after initialization aswell

Reported by: fixed-term.Sven.Baetzing@… Owned by: Lennart Ochel
Priority: normal Milestone: 1.9.4
Component: Backend Version: 1.9.0Beta
Keywords: Cc:

Description

Asserts which are placed inside the initial equation part trigger aswell during the main simulation.

model Bug

  Modelica.Blocks.Interfaces.RealInput x
    annotation (Placement(transformation(extent={{-120,-20},{-80,20}})));
initial equation 
  assert(x>0,"x have to be greater 0 at initial");
equation 

  annotation ();
end Bug;

Minimal example is attached to this ticket.

Attachments (1)

OMCBug.mo (789 bytes ) - added by fixed-term.Sven.Baetzing@… 10 years ago.

Download all attachments as: .zip

Change History (10)

by fixed-term.Sven.Baetzing@…, 10 years ago

Attachment: OMCBug.mo added

comment:1 by Adeel Asghar, 10 years ago

Component: OMEditBackend
Owner: changed from Adeel Asghar to Lennart Ochel
Status: newassigned

comment:2 by Lennart Ochel, 10 years ago

Asserts in initial equations do not work for me at all. I get the following error message:

[/Testing/3340/main.mos:7:17-7:17:writable] Error: Missing token: EQUALS

# Error encountered! Exiting...
# Please check the error message and the flags.

comment:3 by Adrian Pop, 10 years ago

Lennart, the problem seems to be in your script. How does that looks like?

comment:4 by fixed-term.Sven.Baetzing@…, 10 years ago

Sorry but i can not reproduce your error message.

I am using the nightly version of OMEdit from 2015/05/19.
After loading the package:

package OMCBug
  model Bug
    Modelica.Blocks.Interfaces.RealInput x annotation(Placement(transformation(extent = {{-120, -20}, {-80, 20}})));
  initial equation
    assert(x > 0, "x have to be greater 0 at initial");
  equation

    annotation();
  end Bug;

  model BugToplvl
    OMCBug.Bug bug annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}})));
    Modelica.Blocks.Sources.Ramp ramp(height = -1, duration = 0.5, offset = 1) annotation(Placement(transformation(extent = {{-64, -10}, {-44, 10}})));
  equation
    connect(bug.x, ramp.y) annotation(Line(points = {{-10, 0}, {-26, 0}, {-43, 0}}, color = {0, 0, 127}));
    annotation();
  end BugToplvl;
  annotation(uses(Modelica(version = "3.2.1")));
end OMCBug;

Simulation of the model "BugToplvl" fails.

in reply to:  3 comment:5 by Lennart Ochel, 10 years ago

Replying to adrpo:

Lennart, the problem seems to be in your script. How does that looks like?

Oops! You are right.

comment:6 by Lennart Ochel, 9 years ago

Resolution: fixed
Status: assignedclosed

This should be fixed with 56d186b60d7904ed253b34995e6ff4543a16e09d/OMCompiler.

I tested it using the following assertion:

initial equation
  assert(x>0, "x have to be greater 0 at initial", AssertionLevel.warning);

comment:7 by Lennart Ochel, 9 years ago

Milestone: Future1.9.4

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

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

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

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.