Opened 14 years ago

Last modified 14 years ago

#1359 closed defect (fixed)

OMC doesnot set the initianl values correctly

Reported by: mohsen Owned by: mohsen
Priority: high Milestone:
Component: Version:
Keywords: Cc: mohsen,

Description

Consider the below code:

{{{model Tank

Modelica.Blocks.Continuous.TransferFunction G(b={1/A}, a={1,1/T}); Modelica 3.1, y_start = 1/A
parameter Real T = 15;
Time constant
parameter Real A = 5;
Real weight_analyt = 1/A*exp(-1/T*time);

initial equation initial equation is not yet supported in OpenModelica

G.y = 1/A;

equation

G.u= if time > 0 then 0 else 1e6;

/*if time <= 0 then

G.y = 1/A;

else

G.u = 0;

end if;*/

end Tank;}}}

The weight_analyt and G.y should be the same. Dymola works fine but omc sets the G.y to zero and does ignoe the if statement.
neither initial equation or the if statement works.

Regards
Mohsen

Change History (1)

comment:1 by Willi Braun, 14 years ago

Suggested workaround:

model Tank
  Modelica.Blocks.Continuous.TransferFunction G(b={1/A}, a={1,1/T});
  parameter Real T = 15;                               
  parameter Real A = 5;
  Real weight_analyt = 1/A*exp(-1/T*time);
  Real diff;
initial equation 
  G.y = 1/A;
equation 
  //G.u= if time > 0 then 0 else 1e6;
  // time > 0 == not initial(), that will OpenModelica know that this is a time event
  // "and weight_analyt>1e-5" is a workaround for Bug [# 1549]
  G.u= if initial() and weight_analyt>1e-5 then 1e6 else 0;
  diff = weight_analyt -  G.y;
 /*if time <= 0 then
    G.y = 1/A; 
   else
    G.u = 0;
  end if;*/
end Tank;

But the initial equation is handled correctly. The uncommented "if statement" is structural variable and is not supported yet by OpenModelica.

Note: See TracTickets for help on using tickets.