集中体积模型中的加热流体
Heating fluid in lumped volumes modelica
我很难找到准确地写出具有流体流动和热流输出的简单集总体积(例如管道)的能量平衡的最佳方法。我基本上只想在能量平衡中添加一个 Q_loss 项来降低流过的任何流体的温度,但要保持整体模型超级简单(没有摩擦、压力、对流损失等)。
我试图编写一个简单的模型,但我发现方程式比我需要的少了一个。有没有办法在不固定压力的情况下做到这一点?
我的代码(介质不标准,可能需要重新声明):
model IdealLossPipe
extends SolarTherm.Interfaces.Models.Pipe;
Medium.BaseProperties medium;
replaceable package Medium = SolarTherm.Media.MoltenSalt.MoltenSalt_base
constrainedby Modelica.Media.Interfaces.PartialMedium
Modelica.Fluid.Interfaces.FluidPort_a fluid_a(redeclare package Medium =
Medium);
Modelica.Fluid.Interfaces.FluidPort_b fluid_b(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{110,-10},{90,10}}, rotation=0),
iconTransformation(extent={{110,-10},{90,10}})));
parameter Real Q_loss_spec(unit="W/m") = 284 "Heat loss per m of piping";
SI.HeatFlowRate Q_loss;
parameter SI.Length length = 13.1 annotation(Dialog(group="Length"));
parameter SI.Length diameter = 0.052;
SI.Energy U;
SI.Mass m;
SI.Volume V;
equation
V = length*(diameter/2)^2*Modelica.Constants.pi;
m=V*medium.d;
U=m*medium.u;
fluid_a.p=medium.p;
fluid_b.p=medium.p;
(instream(fluid_a.h_outflow)+fluid_b.h_outflow)/2=medium.h;
fluid_a.h_outflow=0;
Q_loss=-length*Q_loss_spec;
//Mass Balance
fluid_a.m_flow+fluid_b.m_flow=der(m);
//Energy Balance
der(U)= fluid_a.m_flow*inStream(fluid_a.h_outflow) + fluid_b.m_flow*fluid_b.h_outflow + Q_loss;
end IdealLossPipe;
在此先感谢您对我的帮助!!
编辑:删除了我模型中不必要的热端口
我编辑了你的模型(见下文)。一些添加包括 medium
的初始化,如果将这种方法用于基本属性,则这是必需的。仔细查看现有的 open-source 流体库(例如 Modelica 标准库、TRANSFORM 或 ThermoPower)以了解它们如何做事或使用它们的组件会很有帮助。
model IdealLossPipe
import SI = Modelica.SIunits;
replaceable package Medium = Modelica.Media.Water.StandardWater
constrainedby Modelica.Media.Interfaces.PartialMedium annotation (
choicesAllMatching=true);
Medium.BaseProperties medium(
each preferredMediumStates=true,
p(start=p_start),
T(start=T_start),
h(start=Medium.specificEnthalpy(Medium.setState_pT(p_start, T_start))),
d(start=Medium.density(Medium.setState_pT(p_start, T_start))),
u(start=Medium.specificInternalEnergy(Medium.setState_pT(p_start, T_start))),
Xi(start=X_start[1:Medium.nXi]),
X(start=X_start));
Modelica.Fluid.Interfaces.FluidPort_a fluid_a(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{-90,-10},{-110,10}},
rotation=0), iconTransformation(extent={{-90,-10},{-110,10}})));
Modelica.Fluid.Interfaces.FluidPort_b fluid_b(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{110,-10},{90,10}},
rotation=0), iconTransformation(extent={{110,-10},{90,10}})));
parameter Real Q_loss_spec(unit="W/m") = 284 "Heat loss per m of piping";
parameter SI.Length length=13.1 annotation (Dialog(group="Length"));
parameter SI.Length diameter=0.052;
// Initialization
parameter SI.Pressure p_start=1e5;
parameter SI.Temperature T_start=293.15;
parameter SI.MassFraction X_start[Medium.nX]=Medium.X_default "Mass fraction";
SI.HeatFlowRate Q_loss;
SI.Energy U;
SI.Mass m;
SI.Volume V;
equation
V = length*(diameter/2)^2*Modelica.Constants.pi;
m = V*medium.d;
U = m*medium.u;
Q_loss = -length*Q_loss_spec;
//Mass Balance
fluid_a.m_flow + fluid_b.m_flow = der(m);
//Energy Balance
der(U) = fluid_a.m_flow*inStream(fluid_a.h_outflow) + fluid_b.m_flow*inStream(
fluid_b.h_outflow) + Q_loss;
// Port definitions
fluid_a.h_outflow = medium.h;
fluid_b.h_outflow = medium.h;
fluid_a.p = medium.p;
fluid_b.p = medium.p;
fluid_a.Xi_outflow = medium.Xi;
fluid_b.Xi_outflow = medium.Xi;
fluid_a.C_outflow = inStream(fluid_b.C_outflow);
fluid_b.C_outflow = inStream(fluid_a.C_outflow);
end IdealLossPipe;
要记住的一件事是模型的 "flow vs volume" 或 "non-state (flow) vs state (non-flow/volume)" 表示。暴露状态的端口设置连接器状态变量的值(即流体压力),而 non-state 端口设置连接器的流量变量(即流体质量流量)。因此,对于流体,您要确保不连接每个设置压力(状态变量)的端口。与质量流量相似,但求解器往往更宽容。
作为参考,您的模型设置了状态变量(fluid_a.p = medium.p
、fluid_b.p = medium.p
)。一个简单的模型示例希望将每个端口与设置质量流量的模型连接,例如 fluid_a
上的质量流量源和后跟 fluid_b
.[=17 上的压力边界的阻力元件=]
model Example
Unnamed pipe(redeclare package Medium = Modelica.Media.Water.StandardWater,
Q_loss_spec=10000)
annotation (Placement(transformation(extent={{-68,4},{-48,24}})));
Modelica.Fluid.Sources.Boundary_pT boundary(
nPorts=1,
redeclare package Medium = Modelica.Media.Water.StandardWater,
p=100000,
T=293.15) annotation (Placement(transformation(extent={{34,2},{14,22}})));
Modelica.Fluid.Sources.MassFlowSource_T boundary1(
nPorts=1,
redeclare package Medium = Modelica.Media.Water.StandardWater,
m_flow=1,
T=293.15)
annotation (Placement(transformation(extent={{-124,2},{-104,22}})));
Modelica.Fluid.Valves.ValveLinear valveLinear(
redeclare package Medium = Modelica.Media.Water.StandardWater,
dp_nominal=100000,
m_flow_nominal=1)
annotation (Placement(transformation(extent={{-30,4},{-10,24}})));
Modelica.Blocks.Sources.Constant const(k=1)
annotation (Placement(transformation(extent={{-52,30},{-32,50}})));
equation
connect(boundary1.ports[1], pipe.fluid_a) annotation (Line(points={{-104,12},{
-86,12},{-86,14},{-68,14}}, color={0,127,255}));
connect(pipe.fluid_b, valveLinear.port_a)
annotation (Line(points={{-48,14},{-30,14}}, color={0,127,255}));
connect(valveLinear.port_b, boundary.ports[1]) annotation (Line(points={{-10,14},
{2,14},{2,12},{14,12}}, color={0,127,255}));
connect(const.y, valveLinear.opening)
annotation (Line(points={{-31,40},{-20,40},{-20,22}}, color={0,0,127}));
end Example;
我很难找到准确地写出具有流体流动和热流输出的简单集总体积(例如管道)的能量平衡的最佳方法。我基本上只想在能量平衡中添加一个 Q_loss 项来降低流过的任何流体的温度,但要保持整体模型超级简单(没有摩擦、压力、对流损失等)。
我试图编写一个简单的模型,但我发现方程式比我需要的少了一个。有没有办法在不固定压力的情况下做到这一点?
我的代码(介质不标准,可能需要重新声明):
model IdealLossPipe
extends SolarTherm.Interfaces.Models.Pipe;
Medium.BaseProperties medium;
replaceable package Medium = SolarTherm.Media.MoltenSalt.MoltenSalt_base
constrainedby Modelica.Media.Interfaces.PartialMedium
Modelica.Fluid.Interfaces.FluidPort_a fluid_a(redeclare package Medium =
Medium);
Modelica.Fluid.Interfaces.FluidPort_b fluid_b(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{110,-10},{90,10}}, rotation=0),
iconTransformation(extent={{110,-10},{90,10}})));
parameter Real Q_loss_spec(unit="W/m") = 284 "Heat loss per m of piping";
SI.HeatFlowRate Q_loss;
parameter SI.Length length = 13.1 annotation(Dialog(group="Length"));
parameter SI.Length diameter = 0.052;
SI.Energy U;
SI.Mass m;
SI.Volume V;
equation
V = length*(diameter/2)^2*Modelica.Constants.pi;
m=V*medium.d;
U=m*medium.u;
fluid_a.p=medium.p;
fluid_b.p=medium.p;
(instream(fluid_a.h_outflow)+fluid_b.h_outflow)/2=medium.h;
fluid_a.h_outflow=0;
Q_loss=-length*Q_loss_spec;
//Mass Balance
fluid_a.m_flow+fluid_b.m_flow=der(m);
//Energy Balance
der(U)= fluid_a.m_flow*inStream(fluid_a.h_outflow) + fluid_b.m_flow*fluid_b.h_outflow + Q_loss;
end IdealLossPipe;
在此先感谢您对我的帮助!!
编辑:删除了我模型中不必要的热端口
我编辑了你的模型(见下文)。一些添加包括 medium
的初始化,如果将这种方法用于基本属性,则这是必需的。仔细查看现有的 open-source 流体库(例如 Modelica 标准库、TRANSFORM 或 ThermoPower)以了解它们如何做事或使用它们的组件会很有帮助。
model IdealLossPipe
import SI = Modelica.SIunits;
replaceable package Medium = Modelica.Media.Water.StandardWater
constrainedby Modelica.Media.Interfaces.PartialMedium annotation (
choicesAllMatching=true);
Medium.BaseProperties medium(
each preferredMediumStates=true,
p(start=p_start),
T(start=T_start),
h(start=Medium.specificEnthalpy(Medium.setState_pT(p_start, T_start))),
d(start=Medium.density(Medium.setState_pT(p_start, T_start))),
u(start=Medium.specificInternalEnergy(Medium.setState_pT(p_start, T_start))),
Xi(start=X_start[1:Medium.nXi]),
X(start=X_start));
Modelica.Fluid.Interfaces.FluidPort_a fluid_a(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{-90,-10},{-110,10}},
rotation=0), iconTransformation(extent={{-90,-10},{-110,10}})));
Modelica.Fluid.Interfaces.FluidPort_b fluid_b(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{110,-10},{90,10}},
rotation=0), iconTransformation(extent={{110,-10},{90,10}})));
parameter Real Q_loss_spec(unit="W/m") = 284 "Heat loss per m of piping";
parameter SI.Length length=13.1 annotation (Dialog(group="Length"));
parameter SI.Length diameter=0.052;
// Initialization
parameter SI.Pressure p_start=1e5;
parameter SI.Temperature T_start=293.15;
parameter SI.MassFraction X_start[Medium.nX]=Medium.X_default "Mass fraction";
SI.HeatFlowRate Q_loss;
SI.Energy U;
SI.Mass m;
SI.Volume V;
equation
V = length*(diameter/2)^2*Modelica.Constants.pi;
m = V*medium.d;
U = m*medium.u;
Q_loss = -length*Q_loss_spec;
//Mass Balance
fluid_a.m_flow + fluid_b.m_flow = der(m);
//Energy Balance
der(U) = fluid_a.m_flow*inStream(fluid_a.h_outflow) + fluid_b.m_flow*inStream(
fluid_b.h_outflow) + Q_loss;
// Port definitions
fluid_a.h_outflow = medium.h;
fluid_b.h_outflow = medium.h;
fluid_a.p = medium.p;
fluid_b.p = medium.p;
fluid_a.Xi_outflow = medium.Xi;
fluid_b.Xi_outflow = medium.Xi;
fluid_a.C_outflow = inStream(fluid_b.C_outflow);
fluid_b.C_outflow = inStream(fluid_a.C_outflow);
end IdealLossPipe;
要记住的一件事是模型的 "flow vs volume" 或 "non-state (flow) vs state (non-flow/volume)" 表示。暴露状态的端口设置连接器状态变量的值(即流体压力),而 non-state 端口设置连接器的流量变量(即流体质量流量)。因此,对于流体,您要确保不连接每个设置压力(状态变量)的端口。与质量流量相似,但求解器往往更宽容。
作为参考,您的模型设置了状态变量(fluid_a.p = medium.p
、fluid_b.p = medium.p
)。一个简单的模型示例希望将每个端口与设置质量流量的模型连接,例如 fluid_a
上的质量流量源和后跟 fluid_b
.[=17 上的压力边界的阻力元件=]
model Example
Unnamed pipe(redeclare package Medium = Modelica.Media.Water.StandardWater,
Q_loss_spec=10000)
annotation (Placement(transformation(extent={{-68,4},{-48,24}})));
Modelica.Fluid.Sources.Boundary_pT boundary(
nPorts=1,
redeclare package Medium = Modelica.Media.Water.StandardWater,
p=100000,
T=293.15) annotation (Placement(transformation(extent={{34,2},{14,22}})));
Modelica.Fluid.Sources.MassFlowSource_T boundary1(
nPorts=1,
redeclare package Medium = Modelica.Media.Water.StandardWater,
m_flow=1,
T=293.15)
annotation (Placement(transformation(extent={{-124,2},{-104,22}})));
Modelica.Fluid.Valves.ValveLinear valveLinear(
redeclare package Medium = Modelica.Media.Water.StandardWater,
dp_nominal=100000,
m_flow_nominal=1)
annotation (Placement(transformation(extent={{-30,4},{-10,24}})));
Modelica.Blocks.Sources.Constant const(k=1)
annotation (Placement(transformation(extent={{-52,30},{-32,50}})));
equation
connect(boundary1.ports[1], pipe.fluid_a) annotation (Line(points={{-104,12},{
-86,12},{-86,14},{-68,14}}, color={0,127,255}));
connect(pipe.fluid_b, valveLinear.port_a)
annotation (Line(points={{-48,14},{-30,14}}, color={0,127,255}));
connect(valveLinear.port_b, boundary.ports[1]) annotation (Line(points={{-10,14},
{2,14},{2,12},{14,12}}, color={0,127,255}));
connect(const.y, valveLinear.opening)
annotation (Line(points={{-31,40},{-20,40},{-20,22}}, color={0,0,127}));
end Example;