Reputation: 1232
In my model, I got confused that why the initial conditions are NOT fully specified.
Here are the code and screenshot:
model WithAlgebraicLoop_Right
extends Modelica.Icons.Example;
Real x;
Real y(start=1, fixed=true);
Boolean cond;
equation
cond = x > 0.5;
when pre(cond) then
y = 1*time;
end when;
x = sin(y*10*time);
end WithAlgebraicLoop_Right;
I think that during the initialization, x
could be calculated from y
, so cond
could be calculated from x
, so why doesn't Dymola do as I think?
Upvotes: 0
Views: 254
Reputation: 1349
Sure, discrete-time variable cond
can be calucated according to the given equations. However, its pre-value for the event iteration at initialization is not known and must be set, either by setting a fixed start value or by an initial equation, whatever you prefer.
model WithAlgebraicLoop_Right1
Real x;
Real y(start=1, fixed=true);
Boolean cond(start=false, fixed=true);
equation
cond = x > 0.5;
when pre(cond) then
y = 1*time;
end when;
x = sin(y*10*time);
end WithAlgebraicLoop_Right1;
or
model WithAlgebraicLoop_Right2
Real x;
Real y(start=1, fixed=true);
Boolean cond;
initial equation
pre(cond) = false;
equation
cond = x > 0.5;
when pre(cond) then
y = 1*time;
end when;
x = sin(y*10*time);
end WithAlgebraicLoop_Right2;
Upvotes: 7