Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#5497 closed defect (invalid)

OMC accepting illegal edge operator and generating wrong code

Reported by: AnHeuermann Owned by: somebody
Priority: high Milestone: 2.0.0
Component: Frontend Version: v1.14.0-dev-nightly
Keywords: edge relation Cc:

Description

OMC accepts edge operator with a relation as input. The modelica reference https://build.openmodelica.org/Documentation/ModelicaReference.Operators.%27edge()%27.html states that edge should only accept boolean values.
Whe should generate a warning or an error.

The backend-DAE is also wrong. For the model

model HystereseBug
  input Real u;
  output Real y;
equation
  when {u>1, u<-1} then
    y = if edge(u>u_max) then 1 else -1;
  end when;
end HystereseBug;

edge(u>u_max) gets expandet to edge(u)>edge(u_max) and that generates wrong code:

hystBug._y = if (hystBug.u and not pre(hystBug.u)) > (hystBug.u_max and not hystBug.u_max) then 1.0 else -1.0;

Suggested solution:
Add a warning from Frontend for these kind of edge usage.
Add a tmp variable and replace it in edge. Then everything in the backend should (hopefully) work with edge(tmp).

Change History (3)

comment:1 Changed 5 years ago by AnHeuermann

  • Resolution set to invalid
  • Status changed from new to closed

comment:2 Changed 5 years ago by casella

@AnHeuermann, why was this invalid?

comment:3 Changed 5 years ago by AnHeuermann

It's allready fixed with the new frontend.

Last edited 5 years ago by AnHeuermann (previous) (diff)
Note: See TracTickets for help on using tickets.