我希望使用条件表达式来减少具有超过300000个方程的大型通用模型,以便仅保留相关部分 . 为了说明问题,我有以下最小模型:
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;
此模型在Dymola中不起作用,并显示以下错误消息:
未声明的变量:y因为有条件地删除了y的声明
在OpenModelica中,模型有效 . So my question is, is this Model Modelica compliant? 在Modelica 3.4规范第4.4.5节中,我没有找到任何会使此模型无效的内容 .
谢谢您的帮助 .
1 回答
不,因为
y
和x
被声明为条件,4.4.5包含语句"A component declared with a condition-attribute can only be modified and/or used in connections" .没有特殊规则可以从if语句的分支中删除它们 .