我正在尝试建立我的水力计算库。我对管道模型有疑问。
这就是我的管道模型的样子:
model pipe_v0
import Modelica.Units.SI;
parameter SI.Area muF = 8e-5;
parameter SI.Density rho = 998;
parameter SI.SpecificHeatCapacityAtConstantPressure cp = 4200;
SI.Pressure dp;
parameter Real dt = 10;
SI.MassFlowRate G;
SI.Pressure pin, pout;
SI.Temperature tin, tout;
Port.port_b port_b annotation(
Placement(transformation(origin = {-100, 0}, extent = {{-5, -5}, {5, 5}}), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}})));
Port.port_a port_a annotation(
Placement(transformation(origin = {100, 0}, extent = {{-5, -5}, {5, 5}}), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}})));
equation
G = muF*sqrt(2*rho*dp);
pout = pin - dp;
tout = tin + dt;
port_b.p = pin;
port_a.p = pout;
port_b.h = tin*cp;
port_a.h = tout*cp;
port_b.m = G;
port_a.m = -G;
port_b.H + port_a.H = 0;
annotation(
Icon(graphics = {Rectangle( lineColor = {144, 144, 144}, fillColor = {190, 190, 190}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-100, 10}, {100, -10}})}));
end pipe_v0;
这些是我的边界条件模型:
model bound_PT
extends Librero.Sourse.bound_base;
import Modelica.Units.SI;
parameter SI.Pressure p;
parameter SI.Temperature T;
SI.SpecificHeatCapacityAtConstantPressure cp = 4200;
equation
port_a.p = p;
T = port_a.h/cp;
annotation(
Diagram,
Icon(graphics = {Text(origin = {13, -61}, rotation = 30, extent = {{-100, 20}, {100, -20}}, textString = "%name", fontName = "GOST Common")}));
end bound_PT;
还有另一个:
model bound_mH
extends Librero.Sourse.bound_base;
import Modelica.Units.SI;
parameter SI.MassFlowRate m;
parameter SI.EnthalpyFlowRate H;
equation
port_a.m = m;
port_a.H = H;
annotation(
Diagram,
Icon(graphics = {Text(origin = {45, -49}, rotation = 33, extent = {{-100, 20}, {100, -20}}, textString = "%name", fontName = "GOST Common")}));
end bound_mH;
当我尝试计算一根管道(一个管道模型由两个边界条件封闭)时,一切正常。 如果我想合并流量,以便根据水力特性划分质量流量,则计算会出现以下错误:
[1] 18:07:22 Symbolic Error An independent subset of the model has imbalanced number of equations (18) and variables (17). variables:
尽管当我检查模型时(参见图片),它告诉我一切都很好:
[1] 18:07:21 Scripting Notification Check of Librero.poligon.st completed successfully. Class Librero.poligon.st has 56 equation(s) and 56 variable(s). 37 of these are trivial equation(s).
怎么了?感谢您的帮助:-)
更新#1 这是连接器代码:
connector port_base
import Modelica.Units.SI;
SI.Pressure p;
SI.SpecificEnthalpy h;
flow SI.MassFlowRate m;
flow SI.EnthalpyFlowRate H;
end port_base;
对于连接器模型,我简单地应用
extends Librero.Port.port_base;
并画了一个图标
我尝试删除所有
h
和 H
相关方程,并且该模型有效(具有 2 个压力输入和 1 个质量流量输出)。因此,这表明问题与模型的热部分有关。不知怎的,我不知道如何用当前的建模来解决混合点上游的H
问题。
经过进一步思考,我无法理解为什么要定义两个流变量,因为
port.H
将直接链接到 port.m
和 port.h
。基于Modelica.Fluid.Interfaces.FluidPort
的东西不是更实用吗?
connector FluidPort
flow Medium.MassFlowRate m_flow "Mass flow rate from the connection point into the component";
Medium.AbsolutePressure p "Thermodynamic pressure in the connection point";
stream Medium.SpecificEnthalpy h_outflow "Specific thermodynamic enthalpy close to the connection point if m_flow < 0";
end FluidPort;