modelStaticTwoPortHeatMassExchanger

Partial model transporting fluid between two ports without storing mass or energy

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model with two ports and declaration of quantities that are used by many models), Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters (Parameters for flow resistance for models with two ports).

Information

This component transports fluid between its two ports, without storing mass or energy. It is based on Modelica.Fluid.Interfaces.PartialTwoPortTransport but it does use a different implementation for handling reverse flow because in this component, mass flow rate can be added or removed from the medium.

If dp_nominal > Modelica.Constants.eps, this component computes pressure drop due to flow friction. The pressure drop is defined by a quadratic function that goes through the point (m_flow_nominal, dp_nominal). At |m_flow| < deltaM * m_flow_nominal, the pressure drop vs. flow relation is linearized. If the parameter linearizeFlowResistance is set to true, then the whole pressure drop vs. flow resistance curve is linearized.

Implementation

This model uses inputs and constants that need to be set by models that extend or instantiate this model. The following inputs need to be assigned:
  • Q_flow, which is the sensible and latent heat flow rate added to the medium.
  • mWat_flow, which is the moisture mass flow rate added to the medium.

Set the constant sensibleOnly=true if the model that extends or instantiates this model sets mWat_flow = 0.

To increase the numerical robustness of the model, the constant prescribedHeatFlowRate can be set. Use the following settings:

  • Set prescribedHeatFlowRate=true if the only means of heat transfer at the heatPort is a prescribed heat flow rate that is not a function of the temperature difference between the medium and an ambient temperature. Examples include an ideal electrical heater, a pump that rejects heat into the fluid stream, or a chiller that removes heat based on a performance curve. If the heatPort is not connected, then set prescribedHeatFlowRate=true as in this case, heatPort.Q_flow=0.
  • Set prescribedHeatFlowRate=false if there is heat flow at the heatPort computed as K * (T-heatPort.T), for some temperature T and some conductance K, which may itself be a function of temperature or mass flow rate.
    If there is a combination of K * (T-heatPort.T) and a prescribed heat flow rate, for example a solar collector that dissipates heat to the ambient and receives heat from the solar radiation, then set prescribedHeatFlowRate=false.

If prescribedHeatFlow=true, then energy and mass balance equations are formulated to guard against numerical problems near zero flow that can occur if Q_flow or m_flow are the results of an iterative solver.

Parameters

TypeNameDefaultDescription
BooleansensibleOnlySet to true if sensible exchange only
BooleanprescribedHeatFlowRateSet to true if the heat flow rate is not a function of the component temperature
BooleanhomotopyInitializationtrue= true, use homotopy method
Assumptions
BooleanallowFlowReversal (from PartialTwoPort)true= false to simplify equations, assuming, but not enforcing, no flow reversal
Nominal condition
Modelica.Units.SI.MassFlowRatem_flow_nominal (from PartialTwoPortInterface)Nominal mass flow rate
Modelica.Units.SI.PressureDifferencedp_nominal (from TwoPortFlowResistanceParameters)Pressure difference
Advanced
Modelica.Units.SI.MassFlowRatem_flow_small (from PartialTwoPortInterface)1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow
Advanced › Diagnostics
Booleanshow_T (from PartialTwoPortInterface)false= true, if actual temperature at port is computed
Flow resistance
BooleancomputeFlowResistance (from TwoPortFlowResistanceParameters)true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp (from TwoPortFlowResistanceParameters)false= true, use m_flow = f(dp) else dp = f(m_flow)
Realn (from TwoPortFlowResistanceParameters)2Flow exponent, n=1 for laminar, n=2 for turbulent
BooleanlinearizeFlowResistance (from TwoPortFlowResistanceParameters)false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM (from TwoPortFlowResistanceParameters)0.1Fraction of nominal flow rate where flow transitions to laminar

Connectors

TypeNameDefaultDescription
Modelica.Fluid.Interfaces.FluidPort_aport_a (from PartialTwoPort)Fluid connector a (positive design flow direction is from port_a to port_b)
Modelica.Fluid.Interfaces.FluidPort_bport_b (from PartialTwoPort)Fluid connector b (positive design flow direction is from port_a to port_b)
Modelica.Blocks.Interfaces.RealOutputhOutLeaving temperature of the component
Modelica.Blocks.Interfaces.RealOutput[Medium.nXi]XiOutLeaving species concentration of the component
Modelica.Blocks.Interfaces.RealOutput[Medium.nC]COutLeaving trace substances of the component

Components

TypeNameDefaultDescription
Modelica.Units.SI.MassFlowRatem_flow (from PartialTwoPortInterface)port_a.m_flowMass flow rate from port_a to port_b (m_flow > 0 is design flow direction)
Modelica.Units.SI.PressureDifferencedp (from PartialTwoPortInterface)port_a.p - port_b.pPressure difference between port_a and port_b
Medium.ThermodynamicStatesta_a (from PartialTwoPortInterface)if allowFlowReversal then Medium.setState_phX(port_a.p, noEvent(actualStream(port_a.h_outflow)), noEvent(actualStream(port_a.Xi_outflow))) else Medium.setState_phX(port_a.p, noEvent(inStream(port_a.h_outflow)), noEvent(inStream(port_a.Xi_outflow)))Medium properties in port_a
Medium.ThermodynamicStatesta_b (from PartialTwoPortInterface)if allowFlowReversal then Medium.setState_phX(port_b.p, noEvent(actualStream(port_b.h_outflow)), noEvent(actualStream(port_b.Xi_outflow))) else Medium.setState_phX(port_b.p, noEvent(port_b.h_outflow), noEvent(port_b.Xi_outflow))Medium properties in port_b
Modelica.Units.SI.HeatFlowRateQ_flowHeat transferred into the medium
Modelica.Units.SI.MassFlowRatemWat_flowMoisture mass flow rate added to the medium
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquationvolControl volume for steady-state energy and mass balance
Buildings.Fluid.FixedResistances.PressureDroppreDroFlow resistance

Revisions

  • June 17, 2026, by Michael Wetter:
    Updated implementation to allow a flow coefficient n that is different from 2. This allows use of the model for not fully turbulent flow.
    This is for Buildings, #4620.
  • April 14, 2020, by Michael Wetter:
    Changed homotopyInitialization to a constant.
    This is for IBPSA, #1341.
  • April 11, 2017, by Michael Wetter:
    Updated documentation to make clear that Q_flow includes latent heat flow rate.
    This is for issue Buildings #704.
  • December 1, 2016, by Michael Wetter:
    Updated model as use_dh is no longer a parameter in the pressure drop model.
    This is for #480.
  • January 22, 2016 by Michael Wetter:
    Removed assignment of sensibleOnly in bal1 and bal2 as this constant has been removed in Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger.
  • November 19, 2015, by Michael Wetter:
    Removed assignment of parameter showDesignFlowDirection in extends statement. This is for #349.
  • July 2, 2015 by Michael Wetter:
    Revised implementation of conservation equations, added default values for outlet quantities at port_a if allowFlowReversal=false and updated documentation. See issue 281 for a discussion.
  • July 1, 2015 by Filip Jorissen:
    Renamed use_safeDivision into prescribedHeatFlowRate. See issue 282 for a discussion.
  • November 13, 2013 by Michael Wetter:
    Added parameter homotopyInitialization as it has been removed in the base class.
  • October 8, 2013 by Michael Wetter:
    Removed propagation of show_V_flow to pressure drop calculation, as this model no longer has that parameter.
  • July 30, 2013 by Michael Wetter:
    Changed connector mXi_flow[Medium.nXi] to a scalar input connector mWat_flow. The reason is that mXi_flow does not allow to compute the other components in mX_flow and therefore leads to an ambiguous use of the model. By only requesting mWat_flow, the mass balance and species balance can be implemented correctly.
  • March 27, 2013 by Michael Wetter:
    Removed wrong unit attribute of COut, and added min and max attributes for XiOut.
  • February 8, 2012 by Michael Wetter:
    Changed model to use graphical modeling.
  • December 14, 2011 by Michael Wetter:
    Changed assignment of hOut, XiOut and COut to no longer declare that it is continuous. The declaration of continuity, i.e, the smooth(0, if (port_a.m_flow >= 0) then ...) declaration, was required for Dymola 2012 to simulate, but it is no longer needed for Dymola 2012 FD01.
  • August 19, 2011, by Michael Wetter:
    Changed assignment of hOut, XiOut and COut to declare that it is not differentiable.
  • August 4, 2011, by Michael Wetter:
    Moved linearized pressure drop equation from the function body to the equation section. With the previous implementation, the symbolic processor may not rearrange the equations, which can lead to coupled equations instead of an explicit solution.
  • March 29, 2011, by Michael Wetter:
    Changed energy and mass balance to avoid a division by zero if m_flow=0.
  • March 27, 2011, by Michael Wetter:
    Added homotopy operator.
  • August 19, 2010, by Michael Wetter:
    Fixed bug in energy and moisture balance that affected results if a component adds or removes moisture to the air stream. In the old implementation, the enthalpy and species outflow at port_b was multiplied with the mass flow rate at port_a. The old implementation led to small errors that were proportional to the amount of moisture change. For example, if the moisture added by the component was 0.005 kg/kg, then the error was 0.5%. Also, the results for forward flow and reverse flow differed by this amount. With the new implementation, the energy and moisture balance is exact.
  • March 22, 2010, by Michael Wetter:
    Added constant sensibleOnly to simplify species balance equation.
  • April 10, 2009, by Michael Wetter:
    Added model to compute flow friction.
  • April 22, 2008, by Michael Wetter:
    Revised to add mass balance.
  • March 17, 2008, by Michael Wetter:
    First implementation.