gpt4 book ai didi

Modelica:混合连接器和直接输入

转载 作者:行者123 更新时间:2023-12-05 02:22:20 24 4
gpt4 key购买 nike

以下 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.c = a.y;
end B;
end P;

但是,当 A 不使用连接器时,如以下情况,会出现警告:以下输入缺少绑定(bind)方程: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;

最佳答案

这里的问题是没有有约束力的方程式。只有一个普通的方程。绑定(bind)方程式是作为对元素的修改而应用的方程式,例如

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;

绑定(bind)方程限制的原因与确保组件平衡有关。您可以在规范或 Modelica by Example 中阅读更多相关信息.通过将其用作绑定(bind)方程,可以清楚地表明该方程可用于求解该变量(包含该变量的方程中的项不会消失或病态).

关于Modelica:混合连接器和直接输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29799702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com