gpt4 book ai didi

modelica - 在 Modelica 中正确使用 inStream()

转载 作者:行者123 更新时间:2023-12-02 09:10:07 32 4
gpt4 key购买 nike

我正在尝试在 Modelica 中构建一个非常简单的分布式热流体体积模型,并且正在努力使用流运算符正确实现它。本卷使用 DryAirNasa 作为介质,我希望它没有海量存储、没有压降、也没有能量存储(很像 Modelica.Fluid.Pipes.StaticPipe 模型)。然而,我想明确地执行能量平衡,以便可以存在热传递相互作用。我也不想在此模型中定义质量流量,而是在连接到管道末端的边界之一中定义它(例如,Modelica.Fluid.Sources.MassFlowSource_h)。

我已经创建了此类模型的测试实现,但根据 Dymola 的说法,该模型显然缺少一个方程。对于如何修复此模型以使其正确的任何见解,我将不胜感激。如果我添加方程

port_a.h_outflow = Medium.specificEnthalpy(state_a)

对于方程部分,模型具有相同数量的方程和未知数,但我没有任何充分的理由来添加这样的方程。

 model AirFlowTemp

// Objective: create a component that has no pressure drop, no mass storage,
and no energy storage, but that has a heat input.

import SI=Modelica.SIunits;

final replaceable package Medium=Modelica.Media.Air.DryAirNasa;

AirFlow.AirFlowPort port_a(redeclare package Medium
= Medium);
AirFlow.AirFlowPort port_b(redeclare package Medium
= Medium);
Interfaces.HeatPort heatPort;

Medium.EnthalpyFlowRate[2] H_flow "enthalpy flow";
SI.HeatFlowRate Q_flow "heat flow rate";

Medium.Temperature T_mean;
Medium.ThermodynamicState state_a;
Medium.ThermodynamicState state_b;

equation
// no pressure drop across the component.
port_a.p = port_b.p;

// Assume that there is no mass storage in the volume
0 = port_a.m_flow + port_b.m_flow;

// Energy balance
H_flow[1] = semiLinear(port_a.m_flow, inStream(port_a.h_outflow), inStream(port_b.h_outflow));
H_flow[2] = semiLinear(port_b.m_flow, inStream(port_b.h_outflow), inStream(port_a.h_outflow));
0 = Q_flow + H_flow[1] + H_flow[2];

state_a = Medium.setState_ph(port_a.p, inStream(port_a.h_outflow));
state_b = Medium.setState_ph(port_b.p, inStream(port_b.h_outflow));

T_mean = (Medium.temperature(state_a) +
Medium.temperature(state_b))/2;

heatPort.Q_flow = Q_flow;
heatPort.T = T_mean;

end AirFlowTemp;

connector AirFlowPort

replaceable package Medium = Modelica.Media.Interfaces.PartialMedium;

Medium.AbsolutePressure p;
flow Medium.MassFlowRate m_flow;
stream Medium.SpecificEnthalpy h_outflow;
stream Medium.MassFraction Xi_outflow[Medium.nXi];

end AirFlowPort;


connector HeatPort
extends Modelica.Thermal.HeatTransfer.Interfaces.HeatPort;
end HeatPort;

最佳答案

大约 4 周前,我在做同样的事情时遇到了同样的问题。尝试一下这是否可以作为更接近正确使用 inStream 的一步。

  1. 删除Medium.EnthalpyFlowRate[2] H_flow“焓流量”SI.HeatFlowRate Q_flow "热流量";接口(interface).HeatPort heatPort;SI.HeatFlowRate Q_flow "热流量";介质.温度T_mean;T_mean = (中.温度(state_a) + 中.温度(state_b))/2;

    heatPort.Q_flow = Q_flow;heatPort.T = T_mean;=> 只是测试管道,没有 heatPort

  2. 使用port_a.outflow*port_a.m_flow = inStream(port_b.outflow)*port_b.m_flow;port_b.outflow*port_b.m_flow = inStream(port_a.outflow)*port_a.m_flow;

而不是: H_flow[1] = semiLinear(port_a.m_flow, inStream(port_a.h_outflow), inStream(port_b.h_outflow)); H_flow[2] = semiLinear(port_b.m_flow, inStream(port_b.h_outflow), inStream(port_a.h_outflow)); 0 = Q_flow + H_flow[1] + H_flow[2];

  1. 更改无热端口的测试

=>这有效吗?

问候乌韦

关于modelica - 在 Modelica 中正确使用 inStream(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17867152/

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