0

I am developing a model for Heat Exchangers. I wrote the energy balance equation. When I check the model, I am getting the error shown in the figure. I am not able to figure it out the remaining three equations

model HX1
  replaceable package Medium1 = Modelica.Media.Air.DryAirNasa annotation (
      choicesAllMatching=true);
  replaceable package Medium2 =
      Modelica.Media.Water.ConstantPropertyLiquidWater annotation (
      choicesAllMatching=true);
  Modelica.Fluid.Interfaces.FluidPort_a AirInlet
    annotation (Placement(transformation(extent={{-110,48},{-90,68}})));
  Modelica.Fluid.Interfaces.FluidPort_a WaterOutlet
    annotation (Placement(transformation(extent={{90,-48},{110,-28}})));
  Modelica.Fluid.Interfaces.FluidPort_b AirOutlet
    annotation (Placement(transformation(extent={{88,50},{108,70}})));
  Modelica.Fluid.Interfaces.FluidPort_b WaterInlet
    annotation (Placement(transformation(extent={{-110,-56},{-90,-36}})));
equation 
  WaterInlet.m_flow * (WaterOutlet.h_outflow - WaterInlet.h_outflow)
            = AirInlet.m_flow * ( AirInlet.h_outflow - AirOutlet.h_outflow);
  WaterInlet.m_flow = - WaterOutlet.m_flow;
  AirInlet.m_flow = -AirOutlet.m_flow;
  AirInlet.p  = AirOutlet.p;
  WaterInlet.p = WaterOutlet.p;
  annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
        coordinateSystem(preserveAspectRatio=false)));
end HX1;

Can anyone help me with this? Are there any heat exchangers available for free? enter image description here

Priyanka
  • 559
  • 3
  • 13

1 Answers1

1

You need to specify the outgoing enthalpy in all situations. Please take a look at how to use stream variables — for example in Modelica.Fluid or in the Wiki of this simple example package.

The free Modelica Buildings Library has a number of heat exchanger models.

Code modifications

Your code will work if you change the energy balance to:

  ...
  Modelica.Units.SI.HeatFlowRate Q_flow;
equation 
  WaterInlet.m_flow*(actualStream(WaterOutlet.h_outflow) - actualStream(
    WaterInlet.h_outflow)) = Q_flow;
  Q_flow = AirInlet.m_flow*(actualStream(AirInlet.h_outflow) - actualStream(
    AirOutlet.h_outflow));
  WaterOutlet.h_outflow = WaterInlet.h_outflow;
  AirInlet.h_outflow = AirOutlet.h_outflow;
  ...
Rene Just Nielsen
  • 3,023
  • 12
  • 15
  • I am getting 3 equations short if I use the above code. The total number of variables are 4*3+1 = 13 and the number of equations I got are 6+4 = 10 . May I know what are the three equations – YEKAMBARAM RENTAMALLU Apr 04 '22 at 13:25
  • You still need your mass and momentum balance equations (represented by the three dots `...` in the code snippet) – Rene Just Nielsen Apr 04 '22 at 13:50