gpt4 book ai didi

modelica - 集中体积模型中的加热流体

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

我很难找到准确地写出具有流体流动和热流输出的简单集总体积(例如管道)的能量平衡的最佳方法。我基本上只想在能量平衡中添加一个 Q_loss 项,以降低流过的任何流体的温度,但要保持整个模型 super 简单(没有摩擦、压力、对流损失等)。

我试图编写一个简单的模型,但我发现方程式比我需要的少了一个。有没有办法在不固定压力的情况下做到这一点?

我的代码(介质不标准,可能需要重新声明):

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;

预先感谢您帮助我!!

编辑:删除了我模型中不必要的 heatPort

最佳答案

我编辑了您的模型(见下文)。一些添加包括初始化 medium如果对基本属性使用该方法,则这是必需的。仔细研究现有的开源流体库(例如 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;

要记住的一件事是模型的“流量与体积”或“非状态(流量)与状态(非流量/体积)”表示。暴露状态的端口设置连接器状态变量的值(即流体压力),而非状态端口设置连接器的流量变量(即流体质量流量)。因此,对于流体,您要确保不连接每个设置压力(状态变量)的端口。与质量流量相似,但求解器往往更宽容。

作为引用,您的模型设置了状态变量(fluid_a.p = medium.pfluid_b.p = medium.p)。一个简单的模型示例希望将每个端口与设置质量流量的模型连接,例如 fluid_a 上的质量流量源。 fluid_b 上的阻力元件和压力边界.

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;

关于modelica - 集中体积模型中的加热流体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48835113/

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