在Modelica中正确使用inStream()

时间:2013-07-25 19:33:34

标签: modelica

我正在尝试在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;

1 个答案:

答案 0 :(得分:0)

大约4个星期前,我遇到了同样的问题。 尝试将其作为接近正确使用inStream的一步。

  1. 移除 Medium.EnthalpyFlowRate [2] H_flow“焓流” SI.HeatFlowRate Q_flow“热流率”; Interfaces.HeatPort heatPort; SI.HeatFlowRate Q_flow“热流率”; Medium.Temperature T_mean; T_mean =(Medium.temperature(state_a)+ Medium.temperature(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;

  3. 代替:     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. 更改您的无热量测试
    2. =>这有用吗?

      此致 乌韦