modelStaticTwoPortConservationEquation

Partial model for static energy and mass conservation equations

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

Information

This model transports fluid between its two ports, without storing mass or energy. It implements a steady-state conservation equation for energy and mass fractions. The model has zero pressure drop between its ports.

Typical use and important parameters

Set the parameter use_mWat_flow_in=true to enable an input connector for mWat_flow. Otherwise, the model uses mWat_flow = 0.

If the constant simplify_mWat_flow = true, which is its default value, then the equation

  port_a.m_flow + port_b.m_flow = - mWat_flow;

is simplified as

  port_a.m_flow + port_b.m_flow = 0;

This causes an error in the mass balance of about 0.5%, but generally leads to simpler equations because the pressure drop equations are then decoupled from the mass exchange in this component.

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.

Implementation

Input connectors of the model are

  • Q_flow, which is the sensible plus latent heat flow rate added to the medium,
  • mWat_flow, which is the moisture mass flow rate added to the medium, and
  • C_flow, which is the trace substance mass flow rate added to the medium.

The model can only be used as a steady-state model with two fluid ports. For a model with a dynamic balance, and more fluid ports, use Buildings.Fluid.Interfaces.ConservationEquation.

Parameters

TypeNameDefaultDescription
Booleansimplify_mWat_flowtrueSet to true to cause port_a.m_flow + port_b.m_flow = 0 even if mWat_flow is non-zero
BooleanprescribedHeatFlowRatefalseSet to true if the heat flow rate is not a function of a temperature difference to the fluid temperature
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
Advanced
Modelica.Units.SI.MassFlowRatem_flow_small (from PartialTwoPortInterface)1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow
Booleanuse_mWat_flowfalseSet to true to enable input connector for moisture mass flow rate
Booleanuse_C_flowfalseSet to true to enable input connector for trace substance
Advanced › Diagnostics
Booleanshow_T (from PartialTwoPortInterface)false= true, if actual temperature at port is computed

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.RealInputQ_flowSensible plus latent heat flow rate transferred into the medium
Modelica.Blocks.Interfaces.RealInputmWat_flowMoisture mass flow rate added to the medium
Modelica.Blocks.Interfaces.RealInputC_flowTrace substance mass flow rate added to the medium
Modelica.Blocks.Interfaces.RealOutputhOutLeaving specific enthalpy 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

Revisions

  • October 24, 2022, by Michael Wetter:
    Conditionally removed assertion that checks for water content as this is only required if water is added to the medium.
    See #1650.
  • September 9, 2022, by Michael Wetter:
    Set nominal attribute for XiOut.
    This is for 1634.
  • September 18, 2020, by Michael Wetter:
    Removed start value for hOut as it will be set by Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume.
    See #1397.
  • February 12, 2019, by Filip Jorissen:
    Removed obsolete division by TMax in assert.
    See #1097.
  • June 23, 2018, by Filip Jorissen:
    Added more details to energy conservation assert to facilitate debugging.
    See #962.
  • March 30, 2018, by Filip Jorissen:
    Added getInstanceName() in asserts to facilitate debugging.
    See #901.
  • April 24, 2017, by Michael Wetter and Filip Jorissen:
    Reimplemented check for energy conversion.
    See #741.
  • April 24, 2017, by Michael Wetter:
    Reverted change from April 21, 2017.
    See #741.
  • April 21, 2017, by Filip Jorissen:
    Revised test for energy conservation at small mass flow rates. See #741.
  • October 23, 2016, by Filip Jorissen:
    Added test for energy conservation at small mass flow rates.
  • March 17, 2016, by Michael Wetter:
    Refactored model and implmented regStep instead of spliceFunction. This is for #247 and for #300.
  • September 3, 2015, by Filip Jorissen:
    Revised implementation of conservation of vapor mass. Added new variable mFlow_inv_b. This is for #247.
  • January 22, 2016, by Michael Wetter:
    Removed constant sensibleOnly as this is no longer used because the model uses use_mWat_flow.
    Changed condition that determines whether m_flowInv needs to be computed because the change from January 20 introduced an error in Buildings.Fluid.MassExchangers.Examples.ConstantEffectiveness.
  • January 20, 2016, by Filip Jorissen:
    Removed if-else block in code for parameter sensibleOnly since this is no longer needed to simplify the equations. This is for #372.
  • January 17, 2016, by Michael Wetter:
    Added parameter use_C_flow and converted C_flow to a conditionally removed connector. This is for #372.
  • December 16, 2015, by Michael Wetter:
    Removed the units of C_flow to allow for PPM.
  • December 2, 2015, by Filip Jorissen:
    Added input C_flow and code for handling trace substance insertions. November 19, 2015, by Michael Wetter:
    Removed assignment of parameter showDesignFlowDirection in extends statement. This is for #349.
  • September 14, 2015, by Filip Jorissen:
    Rewrote some equations for better readability.
  • August 11, 2015, by Michael Wetter:
    Refactored implementation of Buildings.Utilities.Math.Functions.inverseXRegularized to allow function to be inlined and to factor out the computation of arguments that only depend on parameters. This is for issue 302.
  • July 17, 2015, by Michael Wetter:
    Corrected bug for situation with latent heat exchange and flow reversal not allowed. The previous formulation was singular. This caused some models to not translate. The error was introduced in #282.
  • July 17, 2015, by Michael Wetter:
    Added constant simplify_mWat_flow to remove dependencies of the pressure drop calculation on the moisture balance.
  • 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:
    Revised implementation so that equations are always consistent and do not lead to division by zero, also when connecting a prescribedHeatFlowRate to MixingVolume instances. Renamed use_safeDivision into prescribedHeatFlowRate. See #282 for a discussion.
  • May 6, 2015, by Michael Wetter:
    Corrected documentation.
  • February 11, 2014 by Michael Wetter:
    Improved documentation for Q_flow input.
  • October 21, 2013 by Michael Wetter:
    Corrected sign error in the equation that is used if use_safeDivision=false and sensibleOnly=true. This only affects internal numerical tests, but not any examples in the library as the constant use_safeDivision is set to true by default.
  • September 25, 2013 by Michael Wetter:
    Reformulated computation of outlet properties to avoid an event at zero mass flow rate.
  • September 17, 2013 by Michael Wetter:
    Added start value for hOut.
  • September 10, 2013 by Michael Wetter:
    Removed unrequired parameter i_w.
  • May 7, 2013 by Michael Wetter:
    Removed for loops for species balance and trace substance balance, as they cause the error Error: Operand port_a.Xi_outflow[1] to operator inStream is not a stream variable. in OpenModelica.
  • March 27, 2013 by Michael Wetter:
    Removed wrong unit attribute of COut, and added min and max attributes for XiOut.
  • June 22, 2012 by Michael Wetter:
    Reformulated implementation with m_flowInv to use port_a.m_flow * ... if use_safeDivision=false. This avoids a division by zero if port_a.m_flow=0.
  • February 7, 2012 by Michael Wetter:
    Revised base classes for conservation equations in Buildings.Fluid.Interfaces.
  • 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.