我有以下简单的分层模型,其中包括室内的反应。反应模型只是将质量速率设置为质量,并将其连接到包围它的腔室。
connector Conn
Real mass;
flow Real massRate;
end Conn;
model Reaction
Conn conn;
equation
conn.massRate = conn.mass;
end Reaction;
model Chamber
Real mass(start = 1);
Reaction reaction;
Conn conn;
equation
conn.mass = mass;
der(mass) = conn.massRate;
connect(reaction.conn, conn);
end Chamber;
现在在我看来,总共有五个变量:mass
、reaction.conn.mass
、reaction.conn.massRate
、conn.mass
和conn.massRate
。并且有五个方程:方程部分中的两个,即。
conn.mass = mass
der(mass) = conn.massRate
一个来自反应
reaction.conn.massRate = reaction.conn.mass
和两个来自连接方程:
reaction.conn.mass = conn.mass
reaction.conn.massRate = conn.massRate
所以我们有五个变量的五个方程。求解器逻辑可以像这样简单地组合这些方程
der(mass) = conn.massRate = reaction.conn.massRate = reaction.conn.mass
= conn.mass = mass
并且由于质量被赋予了一个起始值,鲍勃是你的叔叔。mass
应该随着时间的推移而增加。但是我的模拟环境(Wolfram|One)说
Error: Simulation model is not globally balanced, having 1 variable and 2 equations.
有人可以解释发生了什么吗?请注意,如果我将反应器放在腔室外(将反应中的符号反转为 give conn.massRate = -conn.mass
),它会按预期工作。