modelStaticTwoPortConservationEquation
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=trueif the only means of heat transfer at theheatPortis 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 theheatPortis not connected, then setprescribedHeatFlowRate=trueas in this case,heatPort.Q_flow=0. - Set
prescribedHeatFlowRate=falseif there is heat flow at theheatPortcomputed 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 setprescribedHeatFlowRate=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
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | simplify_mWat_flow | true | Set to true to cause port_a.m_flow + port_b.m_flow = 0 even if mWat_flow is non-zero |
| Boolean | prescribedHeatFlowRate | false | Set to true if the heat flow rate is not a function of a temperature difference to the fluid temperature |
| Assumptions | |||
| Boolean | allowFlowReversal (from PartialTwoPort) | true | = false to simplify equations, assuming, but not enforcing, no flow reversal |
| Nominal condition | |||
| Modelica.Units.SI.MassFlowRate | m_flow_nominal (from PartialTwoPortInterface) | Nominal mass flow rate | |
| Advanced | |||
| Modelica.Units.SI.MassFlowRate | m_flow_small (from PartialTwoPortInterface) | 1E-4*abs(m_flow_nominal) | Small mass flow rate for regularization of zero flow |
| Boolean | use_mWat_flow | false | Set to true to enable input connector for moisture mass flow rate |
| Boolean | use_C_flow | false | Set to true to enable input connector for trace substance |
| Advanced › Diagnostics | |||
| Boolean | show_T (from PartialTwoPortInterface) | false | = true, if actual temperature at port is computed |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Fluid.Interfaces.FluidPort_a | port_a (from PartialTwoPort) | Fluid connector a (positive design flow direction is from port_a to port_b) | |
| Modelica.Fluid.Interfaces.FluidPort_b | port_b (from PartialTwoPort) | Fluid connector b (positive design flow direction is from port_a to port_b) | |
| Modelica.Blocks.Interfaces.RealInput | Q_flow | Sensible plus latent heat flow rate transferred into the medium | |
| Modelica.Blocks.Interfaces.RealInput | mWat_flow | Moisture mass flow rate added to the medium | |
| Modelica.Blocks.Interfaces.RealInput | C_flow | Trace substance mass flow rate added to the medium | |
| Modelica.Blocks.Interfaces.RealOutput | hOut | Leaving specific enthalpy of the component | |
| Modelica.Blocks.Interfaces.RealOutput[Medium.nXi] | XiOut | Leaving species concentration of the component | |
| Modelica.Blocks.Interfaces.RealOutput[Medium.nC] | COut | Leaving trace substances of the component |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Units.SI.MassFlowRate | m_flow (from PartialTwoPortInterface) | port_a.m_flow | Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction) |
| Modelica.Units.SI.PressureDifference | dp (from PartialTwoPortInterface) | port_a.p - port_b.p | Pressure difference between port_a and port_b |
| Medium.ThermodynamicState | sta_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.ThermodynamicState | sta_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 forXiOut.
This is for 1634. -
September 18, 2020, by Michael Wetter:
Removed start value forhOutas it will be set by Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume.
See #1397. -
February 12, 2019, by Filip Jorissen:
Removed obsolete division byTMaxin 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:
AddedgetInstanceName()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 implmentedregStepinstead ofspliceFunction. This is for #247 and for #300. -
September 3, 2015, by Filip Jorissen:
Revised implementation of conservation of vapor mass. Added new variablemFlow_inv_b. This is for #247. -
January 22, 2016, by Michael Wetter:
Removedconstant sensibleOnlyas this is no longer used because the model usesuse_mWat_flow.
Changed condition that determines whetherm_flowInvneeds 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 parametersensibleOnlysince this is no longer needed to simplify the equations. This is for #372. -
January 17, 2016, by Michael Wetter:
Added parameteruse_C_flowand convertedC_flowto a conditionally removed connector. This is for #372. -
December 16, 2015, by Michael Wetter:
Removed the units ofC_flowto allow for PPM. -
December 2, 2015, by Filip Jorissen:
Added inputC_flowand code for handling trace substance insertions. November 19, 2015, by Michael Wetter:
Removed assignment of parametershowDesignFlowDirectioninextendsstatement. 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 constantsimplify_mWat_flowto 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 atport_aifallowFlowReversal=falseand 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 aprescribedHeatFlowRatetoMixingVolumeinstances. Renameduse_safeDivisionintoprescribedHeatFlowRate. See #282 for a discussion. -
May 6, 2015, by Michael Wetter:
Corrected documentation. -
February 11, 2014 by Michael Wetter:
Improved documentation forQ_flowinput. -
October 21, 2013 by Michael Wetter:
Corrected sign error in the equation that is used ifuse_safeDivision=falseandsensibleOnly=true. This only affects internal numerical tests, but not any examples in the library as the constantuse_safeDivisionis set totrueby 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 forhOut. - September 10, 2013 by Michael Wetter:
Removed unrequired parameteri_w. -
May 7, 2013 by Michael Wetter:
Removedforloops for species balance and trace substance balance, as they cause the errorError: 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 ofCOut, and added min and max attributes forXiOut. -
June 22, 2012 by Michael Wetter:
Reformulated implementation withm_flowInvto useport_a.m_flow * ...ifuse_safeDivision=false. This avoids a division by zero ifport_a.m_flow=0. -
February 7, 2012 by Michael Wetter:
Revised base classes for conservation equations inBuildings.Fluid.Interfaces. -
December 14, 2011 by Michael Wetter:
Changed assignment ofhOut,XiOutandCOutto no longer declare that it is continuous. The declaration of continuity, i.e, thesmooth(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 ofhOut,XiOutandCOutto 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 ifm_flow=0. -
March 27, 2011, by Michael Wetter:
Addedhomotopyoperator. -
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 atport_bwas multiplied with the mass flow rate atport_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 was0.005 kg/kg, then the error was0.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 constantsensibleOnlyto 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.