Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Model of heat exchanger not balanced

Model of heat exchanger not balanced

Hello OM users,
I am writing, because maybe somebody is familiar with this topic and will help.
I tried to develop a model of cross flow heat exchanger, but the checker always tells me that the system is under-constrained (28 variables and 26 equations) I have no idea where is the problem, so I am attaching my code below:

within HeatPump;

model Condenser

  // For 100% Vapour- 1 phase of Refr.
  //outer Modelica.Fluid.System system "System properties";

  import SI = Modelica.SIunits;
  import IF = Modelica.Fluid.Interfaces;

  //parameter SI.MassFlowRate m_flow_min =0.001 " Smallest Mass flow rate in model";
  replaceable package Medium_1 = Modelica.Media.Air.SimpleAir constrainedby
    Modelica.Media.Interfaces.PartialMedium "Fluid 1"
                             annotation(choicesAllMatching);
  replaceable package Medium_2 = Modelica.Media.R134a.R134a_ph constrainedby
    Modelica.Media.Interfaces.PartialMedium "Fluid 2"
                             annotation(choicesAllMatching);
   
// Declaration of the state of the both Fluid


Medium_1.ThermodynamicState State_1;
Medium_2.ThermodynamicState State_2;

 
 
  parameter SI.Area Aref = 1 "Tube with refrigerant contact area";
  parameter SI.CoefficientOfHeatTransfer href = 1;
  parameter SI.CoefficientOfHeatTransfer hair=1;
  parameter SI.Area Aair = 1 "Air with condenser contact area";
  parameter SI.Area Ao = 1;
  parameter SI.Efficiency etao = 1;


  Modelica.Fluid.Interfaces.FluidPort_a port_a(redeclare package Medium = Medium_2) "Inlet refrigerant" annotation(
    Placement(visible = true, transformation(extent = {{-110, -10}, {-90, 10}}, rotation = 0), iconTransformation(extent = {{-10, 88}, {12, 110}}, rotation = 0)));
   
  Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Medium_2) "Outlet refrigerant" annotation(
    Placement(visible = true,transformation(extent = {{90, -10}, {110, 10}}, rotation = 0), iconTransformation(extent = {{92, -10}, {114, 12}}, rotation = 0)));
   
  Modelica.Fluid.Interfaces.FluidPort_a port_a1(redeclare package Medium = Medium_1) "Inlet air" annotation(
    Placement(visible = true,transformation(extent = {{-10, 90}, {10, 110}}, rotation = 0), iconTransformation(origin = {-99, 1}, extent = {{-11, -11}, {11, 11}}, rotation = 0)));
   
  Modelica.Fluid.Interfaces.FluidPort_b port_b1(redeclare package Medium = Medium_1) "Outlet air" annotation(
    Placement(visible = true,transformation(origin = {1.33227e-15, -100}, extent = {{-10, 10}, {10, -10}}, rotation = 0), iconTransformation(origin = {1, -99}, extent = {{-11, -11}, {11, 11}}, rotation = 0)));


   Real Cair = port_a1.m_flow * Medium_1.specificHeatCapacityCp(State_1);
   Real Cref = port_a.m_flow * Medium_2.specificHeatCapacityCp(State_2);
   Real Cmin = min(Cair, Cref);
   Real Cmax = max(Cair, Cref);
   Real Cx = Cmin / Cmax;
   Real UA = 1/(1 / href * Aref + 1 / etao * hair * Ao);
   Real NTU = UA / Cmin;
   Real eps1 = 1 - exp(1 / Cx * NTU ^ 0.22 * (exp(-Cx * NTU ^ 0.78) - 1));
   Real Q = eps1 * Cmin * (Medium_2.temperature(State_2)-Medium_1.temperature(State_1));

 
equation
 
State_1=Medium_1.setState_phX(
port_a1.p,
port_a1.h_outflow,
port_a1.Xi_outflow);

State_2=Medium_2.setState_phX(
port_a.p,
port_a.h_outflow,
port_a.Xi_outflow);


  port_b.h_outflow = port_a.h_outflow + (Q/port_a.m_flow);
  port_b1.h_outflow = port_a1.h_outflow+ (Q/port_a1.m_flow);
 
  0=port_a.m_flow+port_b.m_flow;
  0=port_a1.m_flow+port_b1.m_flow;
 
  port_a.p=port_b.p;
  port_a1.p=port_b1.p;
   
  port_a1.Xi_outflow=port_b1.Xi_outflow;
  port_a.Xi_outflow=port_b.Xi_outflow;
 
  port_a1.C_outflow=port_b1.C_outflow;
  port_a.C_outflow=port_b.C_outflow;
 
  annotation(
    Icon(graphics = {Rectangle(fillPattern = FillPattern.Solid, extent = {{-100, 80}, {100, -80}}), Rectangle(origin = {1, 64}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-101, 6}, {99, -14}}), Rectangle(origin = {1, 24}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-101, 6}, {99, -14}}), Rectangle(origin = {1, -18}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-101, 6}, {99, -14}}), Rectangle(origin = {1, -56}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-101, 6}, {99, -14}}), Rectangle(origin = {87, 0}, rotation = 90, fillPattern = FillPattern.Solid, extent = {{-81, 2}, {81, -14}}), Rectangle(origin = {-99, 0}, rotation = 90, fillPattern = FillPattern.Solid, extent = {{-81, 2}, {81, -14}})}));
end Condenser;

all the parameters are just for an example.

Maybe someone have made such a model and have some advice? Thanks in advance.


I also made a test bench for that:

within HeatPump;

model Condenser_Test

replaceable package Medium_1= Modelica.Media.Air.MoistAir;
replaceable package Medium_2=Modelica.Media.R134a.R134a_ph;

  Condenser condenser1 annotation(
    Placement(visible = true, transformation(origin = {-2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
   
  Modelica.Fluid.Sources.MassFlowSource_h boundary(
 
  redeclare package Medium=Medium_2,h = 280,
  m_flow = 0.005,
  nPorts = 1,
  use_h_in = false, use_m_flow_in = false)  annotation(
    Placement(visible = true, transformation(origin = {-70, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
 
 
  Modelica.Fluid.Sources.MassFlowSource_h boundary2(
  redeclare package Medium = Medium_1,
  h = 76.9,
  m_flow = 0.05,
  nPorts = 1,
  use_m_flow_in = false)  annotation(
    Placement(visible = true, transformation(origin = {-2, 44}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
 
 
  Modelica.Fluid.Sources.Boundary_pT boundary4( 
  redeclare package Medium=Medium_2, T = 280, nPorts = 1, p = 1e5,
  use_T_in = false,
  use_X_in = false, use_p_in = false)  annotation(
    Placement(visible = true, transformation(origin = {48, 0}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
 
 
  Modelica.Fluid.Sources.Boundary_pT boundary5( 
  redeclare package Medium=Medium_1, T = 278, p = 1e5,
  use_T_in = false,
  use_X_in = false, use_p_in = false)  annotation(
    Placement(visible = true, transformation(origin = {-2, -52}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
 
 
  inner Modelica.Fluid.System system(allowFlowReversal = false, energyDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, m_flow_start = 0.005, massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, momentumDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial)  annotation(
    Placement(visible = true, transformation(origin = {70, 72}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(condenser1.port_b1, boundary5.ports[1]) annotation(
    Line(points = {{-2, -10}, {-2, -10}, {-2, -42}, {-2, -42}}, color = {0, 127, 255}));
  connect(condenser1.port_b, boundary4.ports[1]) annotation(
    Line(points = {{8, 0}, {36, 0}, {36, 0}, {38, 0}}, color = {0, 127, 255}));
  connect(boundary.ports[1], condenser1.port_a) annotation(
    Line(points = {{-60, 0}, {-12, 0}, {-12, 0}, {-12, 0}}, color = {0, 127, 255}));
  connect(boundary2.ports[1], condenser1.port_a1) annotation(
    Line(points = {{-2, 34}, {-2, 34}, {-2, 10}, {-2, 10}}, color = {0, 127, 255}));
end Condenser_Test;

but while solving error occurs:

[1] 18:50:11 Translation Error
[HeatPump.Condenser_Test: 46:3-47:88]: Incompatible components in connect statement: connect(condenser1.port_b1, boundary5.ports[1])
- condenser1.port_b1 has components {C_outflow, Xi_outflow, h_outflow, m_flow, p}
- boundary5.ports[1] has components {C_outflow, Xi_outflow, h_outflow, m_flow, p}



Re: Model of heat exchanger not balanced

Hello Gorzki,

First, I suggest that you look more into the usage of `Stream connectors`: you must always assign some value to the outflowing enthalpy/mass fractions/trace substances of all ports. Also when you don't consider flow reversal. Maybe this small example can be of use to you: https://github.com/justnielsen/ModelicaTutorials
The Wiki part contains a small explanation of `Stream Connectors`

In general, when debugging a model like this it's a good idea to comment out the heat exchange part and just make to separate flow models (side `a_b` and side `a1_b1`) work. Then subsequently including the heat exchange.

Below is a balanced `equation` section of your condenser where all `*_outflow` variables are assigned.

Best regards,
Rene Just Nielsen

equation

   State_1 = Medium_1.setState_phX(
     port_b1.p,
     port_b1.h_outflow,
     port_b1.Xi_outflow);

   State_2 = Medium_2.setState_phX(
     port_b.p,
     port_b.h_outflow,
     port_b.Xi_outflow);


  // Outflowing enthalpy is the inflowing enthalpy plus heat added — applies to both "ends"
  port_b.h_outflow = inStream(port_a.h_outflow) + (Q/port_a.m_flow);
  port_a.h_outflow = inStream(port_b.h_outflow);

  port_a1.h_outflow = inStream(port_b1.h_outflow);
  port_b1.h_outflow = inStream(port_a1.h_outflow) + (Q/port_a1.m_flow);

  0 = port_a.m_flow + port_b.m_flow;
  0 = port_a1.m_flow + port_b1.m_flow;

  port_a.p = port_b.p;
  port_a1.p = port_b1.p;

  port_a1.Xi_outflow = inStream(port_b1.Xi_outflow);
  port_b1.Xi_outflow = inStream(port_a1.Xi_outflow);

  port_a.Xi_outflow = inStream(port_b.Xi_outflow);
  port_b.Xi_outflow = inStream(port_a.Xi_outflow);

  port_a1.C_outflow = inStream(port_b1.C_outflow);
  port_b1.C_outflow = inStream(port_a1.C_outflow);

  port_a.C_outflow = inStream(port_b.C_outflow);
  port_b.C_outflow = inStream(port_a.C_outflow);

Edited by: justnielsen - Nov-25-19 08:05:11
There are 0 guests and 0 other users also viewing this topic
You are here: