Opened 14 years ago

Closed 12 years ago

#1489 closed defect (worksforme)

if equation with initial() as condition causes rightless error

Reported by: Jens Frenkel Owned by: Jens Frenkel
Priority: high Milestone:
Component: Backend Version:
Keywords: Cc: Frenkel, TUD, Adrian Pop, Per Östlund

Description

The following model causes an rightless IF_EQUATION_UNBALANCED_2 error. 

model A
    Real x;
    Real y;
    parameter Real a=3;
equation
    der(x) + x = y;
    y = time;
    if initial() then
      x = a;
      x = 1;
   end if;
end A;
 


Error: If-equation with conditions that are not parameter expressions must have the same number of equations in
each branch, equation count is {2,0} for each respective branch.

 

Change History (4)

comment:1 by Willi Braun, 14 years ago

But initial() is not constant while the simulation time, so that model is invalid and error is correct.

comment:2 by Martin Sjölund, 14 years ago

No, Modelica has special rules for if initial(), which changes the equation into an initial equation (I believe).

comment:3 by Jens Frenkel, 12 years ago

Cc: Frenkel TUD added; Jens Frenkel removed
Component: Backend
Owner: changed from Jens Frenkel to Jens Frenkel
Status: acceptedassigned

comment:4 by Martin Sjölund, 12 years ago

Status: assignedclosed

It works now (if you remove one of the equations as it said x=a=3=1...)

Note: See TracTickets for help on using tickets.