Opened 15 years ago

Last modified 14 years ago

#1202 closed defect (worksforme)

Initial equation is silently ignored

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

Description

In my interpretation the inital equations are not a suggestions, they
are required to be fulfilled before starting the simuation. To silently
ignore them has to be wrong as in the class below.

The following class should require no further initialization but
during simulation without specifying anything in model_init.txt all variables is initialized to zero.
{{{class closedSystemWithInitialValues

parameter Real pStart = 1e5 "Atmospheric pressure";

parameter Real TStart = 300 "Room temperature";

parameter Real V = 1e-3 "One litre";

parameter Real R = 300 "Mass Specific gas constant";

States

Real p; Pressure of system

Real T; Temperature of system

Real m; Mass of system

equation

p*V = m*R*T;

der(m) = 0;

der(T) = 0;

initial equation

p = pStart;

T = TStart;

end closedSystemWithInitialValues;}}}

Specifying, start=xx,fixed=true works though...

Change History (1)

comment:1 by Willi Braun, 14 years ago

works at least in the trunk with a good guess of the states as in the model below:

class closedSystemWithInitialValues
  parameter Real pStart = 1e5 "Atmospheric pressure";
  parameter Real TStart = 300 "Room temperature";
  parameter Real V = 1e-3 "One litre";
  parameter Real R = 300 "Mass Specific gas constant";
  // States
  Real p; // Pressure of system
  Real T(start=TStart,fixed = true); // Temperature of system
  Real m(start=0.1); // Mass of system
equation
  p*V = m*R*T;
  der(m) = 0;
  der(T) = 0;
initial equation
  p = pStart;
  //T = TStart; // it is better to initial states with start value
end closedSystemWithInitialValues;

otherwise we could adjust the number of function evaluations while the initialization.

Note: See TracTickets for help on using tickets.