I want with conditional expressions reduce large general models with over 300000 equations so that only a relevant part remains. To illustrate the problem I have the following minimal model:
model Test
parameter Boolean level1=true;
parameter Boolean level2=false;
Integer x=1 if level1;
Integer y=2 if level2;
Integer z;
equation
if level1 and level2 then
z = x+y;
elseif level1 then
z = x;
elseif level2 then
z = y;
else
z=0;
end if;
end Test;
This model does not work in Dymola, with the error message:
Undeclared variables: y since the declaration of y was conditionally removed
In OpenModelica the model works. So my question is, is this Model Modelica compliant? In the Modelica 3.4 specification section 4.4.5 I did not find anything that would invalidate this model.
Thanks for the help.
No, since y
and x
are declared conditional and 4.4.5 includes the statement "A component declared with a condition-attribute can only be modified and/or used in connections".
There is no special rule that they can be removed from branches of if-statements.