Modelica:混合连接器和直接输入
下面的Modelica包虽然既不是特别有用也不是特别有趣,但不会产生任何警告Modelica:混合连接器和直接输入,modelica,openmodelica,Modelica,Openmodelica,下面的Modelica包虽然既不是特别有用也不是特别有趣,但不会产生任何警告 package P connector C Real c; end C; model A input C x; output Real y; equation y = x.c; end A; model B input C inp; output C out; A a; equation a.x = inp; out
package P
connector C
Real c;
end C;
model A
input C x;
output Real y;
equation
y = x.c;
end A;
model B
input C inp;
output C out;
A a;
equation
a.x = inp;
out.c = a.y;
end B;
end P;
但是,当A
未像以下情况那样使用连接器时,会出现警告:以下输入缺少绑定公式:A.x
。显然,a.x
有一个绑定方程。为什么会有这样的警告
package P
connector C
Real c;
end C;
model A
input Real x;
output Real y;
equation
y = x;
end A;
model B
input C inp;
output C out;
A a;
equation
a.x = inp.c;
out.c = a.y;
end B;
end P;
这里的问题是,不存在约束方程。只有一个普通的方程式。绑定方程是一个应用于元素修改的方程,例如
model B
input C inp;
output C out;
A a(x=inp.c) "Binding equation";
equation
out.c = a.y;
end B;
请注意,一般来说,如果两个东西是连接器,则它们不应等同,而应连接起来。这将帮助您避免这个问题。因此,在您的B
的第一个版本中:
model B
input C inp;
output C out;
A a;
equation
connect(a.x, inp);
out.c = a.y;
end B;
约束方程限制的原因与确保组件平衡有关。您可以在规范或中阅读更多关于这方面的信息。通过将其用作约束方程,可以清楚地表明该方程可用于求解该变量(即,方程中包含该变量的项不会消失或病态)