modelConservationEquation
Extends from Buildings.Fluid.Interfaces.LumpedVolumeDeclarations (Declarations for lumped volumes).
Information
Basic model for an ideally mixed fluid volume with the ability to store mass and energy. It implements a dynamic or a steady-state conservation equation for energy and mass fractions. The model has zero pressure drop between its ports.
If the constant simplify_mWat_flow = true then adding
moisture does not increase the mass of the volume or the leaving mass flow rate.
It does however change the mass fraction medium.Xi.
This allows to decouple the moisture balance from the pressure drop equations.
If simplify_mWat_flow = false, then
the outlet mass flow rate is
mout = min (1 + Δ Xw),
where
Δ Xw is the change in water vapor mass
fraction across the component. In this case,
this component couples
the energy calculation to the
pressure drop versus mass flow rate calculations.
However, in typical building HVAC systems,
Δ Xw < 0.005 kg/kg.
Hence, by tolerating a relative error of 0.005 in the mass balance,
one can decouple these equations.
Decoupling these equations avoids having
to compute the energy balance of the humidifier
and its upstream components when solving for the
pressure drop of downstream components.
Therefore, the default value is simplify_mWat_flow = true.
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.
The model
Buildings.Fluid.MixingVolumes.Validation.MixingVolumeAdiabaticCooling
shows that the relative error on the temperature difference between these
two options of simplify_mWat_flow is less than
0.1%.
Implementation
When extending or instantiating this model, the input
fluidVolume, which is the actual volume occupied by the fluid,
needs to be assigned.
For most components, this can be set to a parameter.
-
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 be used as a dynamic model or as a steady-state model. However, for a steady-state model with exactly two fluid ports connected, the model Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation provides a more efficient implementation.
For a model that instantiates this model, see Buildings.Fluid.MixingVolumes.MixingVolume.
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. Used only if Medium.nX > 1 |
| Modelica.Units.SI.Volume | fluidVolume | Volume | |
| Modelica.Units.SI.HeatCapacity | CSen | (mSenFac - 1)*rho_default*cp_default*fluidVolume | Aditional heat capacity for implementing mFactor |
| Dynamics › Conservation equations | |||
| Modelica.Fluid.Types.Dynamics | energyDynamics (from LumpedVolumeDeclarations) | Modelica.Fluid.Types.Dynamics.DynamicFreeInitial | Type of energy balance: dynamic (3 initialization options) or steady state |
| Modelica.Fluid.Types.Dynamics | substanceDynamics (from LumpedVolumeDeclarations) | energyDynamics | Type of independent mass fraction balance: dynamic (3 initialization options) or steady state |
| Modelica.Fluid.Types.Dynamics | traceDynamics (from LumpedVolumeDeclarations) | energyDynamics | Type of trace substance balance: dynamic (3 initialization options) or steady state |
| Advanced › Dynamics | |||
| Modelica.Fluid.Types.Dynamics | massDynamics (from LumpedVolumeDeclarations) | energyDynamics | Type of mass balance: dynamic (3 initialization options) or steady state, must be steady state if energyDynamics is steady state |
| Initialization | |||
| Medium.AbsolutePressure | p_start (from LumpedVolumeDeclarations) | Medium.p_default | Start value of pressure |
| Medium.Temperature | T_start (from LumpedVolumeDeclarations) | Medium.T_default | Start value of temperature |
| Medium.MassFraction[Medium.nX] | X_start (from LumpedVolumeDeclarations) | Medium.X_default | Start value of mass fractions m_i/m |
| Medium.ExtraProperty[Medium.nC] | C_start (from LumpedVolumeDeclarations) | fill(0, Medium.nC) | Start value of trace substances |
| Medium.ExtraProperty[Medium.nC] | C_nominal (from LumpedVolumeDeclarations) | fill(1E-2, Medium.nC) | Nominal value of trace substances. (Set to typical order of magnitude.) |
| Dynamics | |||
| Real | mSenFac (from LumpedVolumeDeclarations) | 1 | Factor for scaling the sensible thermal mass of the volume |
| Advanced | |||
| Boolean | initialize_p | not Medium.singleState | = true to set up initial equations for pressure |
| 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 |
| General › Ports | |||
| Integer | nPorts | 0 | Number of ports |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| 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 | |
| Modelica.Blocks.Interfaces.RealOutput | UOut | Internal energy of the component | |
| Modelica.Blocks.Interfaces.RealOutput[Medium.nXi] | mXiOut | Species mass of the component | |
| Modelica.Blocks.Interfaces.RealOutput | mOut | Mass of the component | |
| Modelica.Blocks.Interfaces.RealOutput[Medium.nC] | mCOut | Trace substance mass of the component | |
| Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b[nPorts] | ports | Fluid inlets and outlets |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Medium.BaseProperties | medium | Medium properties | |
| Modelica.Units.SI.Energy | U | Internal energy of fluid | |
| Modelica.Units.SI.Mass | m | Mass of fluid | |
| Modelica.Units.SI.Mass | mXi | Masses of independent components in the fluid | |
| Modelica.Units.SI.Mass | mC | Masses of trace substances in the fluid | |
| Medium.ExtraProperty[Medium.nC] | C | Trace substance mixture content | |
| Modelica.Units.SI.MassFlowRate | mb_flow | Mass flows across boundaries | |
| Modelica.Units.SI.MassFlowRate | mbXi_flow | Substance mass flows across boundaries | |
| Medium.ExtraPropertyFlowRate | mbC_flow | Trace substance mass flows across boundaries | |
| Modelica.Units.SI.EnthalpyFlowRate | Hb_flow | Enthalpy flow across boundaries or energy source/sink |
Revisions
-
June 25, 2026, by Michael Wetter:
Addednominalattribute tom.
This is for IBPSA, #2163. -
June 18, 2024, by Michael Wetter:
Addedstartandnominalattributes to avoid warnings in OpenModelica due to conflicting values.
This is for IBPSA, #1890. -
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:
Changed state variable frommXitomedium.Xias this allows setting a good nominal attribute without having to use the fluid volume, which is non-literal value that leads to a warning in Dymola.
This is for 1634. -
April 26, 2019, by Filip Jorissen:
ReturninggetInstanceName()in asserts. This is for 1133. -
April 16, 2019, by Michael Wetter:
Changed computation ofcomputeCSento avoid the volume to become a structural parameter.
This is for IBPSA, issue 1122. -
April 16, 2018, by Michael Wetter:
Reformulated mass calculation so that Dymola can differentiate the equations.
This is for IBPSA, issue 910. -
November 3, 2017, by Michael Wetter:
Setstartattributes.
This is for 727. -
October 19, 2017, by Michael Wetter:
Changed initialization of pressure from aconstantto aparameter.
This is for Buildings, issue 1013. -
January 27, 2017, by Michael Wetter:
AddedstateSelectfor massm.
This is for Buildings, #642. -
December 22, 2016, by Michael Wetter:
Set nominal value forU.
This is for 637. -
February 19, 2016 by Filip Jorissen:
Added outputs UOut, mOut, mXiOut, mCOut for being able to check conservation of quantities. This is for issue 247. -
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:
AddedC_flowto the steady-state trace substance balance, and removed the units ofC_flowto allow for PPM. -
December 2, 2015, by Filip Jorissen:
Added inputC_flowand code for handling trace substance insertions. -
September 3, 2015, by Filip Jorissen and Michael Wetter:
Revised implementation for allowing moisture mass flow rate to be approximated using parametersimplify_mWat_flow. This may lead to smaller algebraic loops. This is for #247. -
July 17, 2015, by Michael Wetter:
Added constantsimplify_mWat_flowto remove dependencies of the pressure drop calculation on the moisture balance. -
June 5, 2015 by Michael Wetter:
RemovedpreferredMediumStates= falsein the instancemediumas the default is alreadyfalse. This is for #260. -
June 5, 2015 by Filip Jorissen:
RemovedXi(start=X_start[1:Medium.nXi], each stateSelect=if (not (substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState)) then StateSelect.prefer else StateSelect.default),and setpreferredMediumStates = falsebecause the previous declaration led to more equations and translation problems in large models. This is for #260. -
June 5, 2015, by Michael Wetter:
Moved assignment ofdynBal.U.startfrom instancedynBalofPartialMixingVolumeto this model implementation. This is required for a pedantic model check in Dymola 2016. It addresses issue 266. This revison also renames the protected variablerho_nominaltorho_startas it depends on the start values and not the nominal values. -
May 22, 2015 by Michael Wetter:
Removedp(stateSelect=if not (massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) then StateSelect.prefer else StateSelect.default)
because the previous declaration led to the translation errorThe model requires derivatives of some inputs as listed below: 1 inlet.m_flow 1 inlet.p
when translatingBuildings.Fluid.FMI.ExportContainers.Examples.FMUs.HeaterCooler_uwith a dynamic energy balance. -
May 6, 2015, by Michael Wetter:
Corrected documentation. -
April 13, 2015, by Filip Jorissen:
Now usingsemiLinear()function for calculation ofports_H_flow. This enables Dymola to simplify based on theminandmaxattribute of the mass flow rate. -
February 16, 2015, by Filip Jorissen:
Fixed SteadyState massDynamics implementation for compressible media. Massmis now constant. -
February 5, 2015, by Michael Wetter:
Changedinitalize_pfrom aparameterto aconstant. This is only required in finite volume models of heat exchangers (to avoid consistent but redundant initial conditions) and hence it should be set as aconstant. -
February 3, 2015, by Michael Wetter:
RemovedstateSelect.preferfor temperature. This is for #160. -
October 21, 2014, by Filip Jorissen:
Added parametermFactorto increase the thermal capacity. -
October 6, 2014, by Michael Wetter:
Changed medium declaration in ports to be final. -
October 6, 2014, by Michael Wetter:
Set start attributes inmediumto avoid in OpenModelica the warning alias set with several free start values. -
October 3, 2014, by Michael Wetter:
Changed assignment of nominal value to avoid in OpenModelica the warning alias set with different nominal values. -
July 3, 2014, by Michael Wetter:
Added parameterinitialize_p. This is required to enable the coil models to initialize the pressure in the first volume, but not in the downstream volumes. Otherwise, the initial equations will be overdetermined, but consistent. This change was done to avoid a long information message that appears when translating models. -
May 29, 2014, by Michael Wetter:
Removed undesirable annotationEvaluate=true. -
February 11, 2014 by Michael Wetter:
Improved documentation forQ_flowinput. -
September 17, 2013 by Michael Wetter:
Added start value forhOut. -
September 10, 2013 by Michael Wetter:
Removed unrequired parameteri_w.
Corrected the syntax errorMedium.ExtraProperty C[Medium.nC](each nominal=C_nominal)toMedium.ExtraProperty C[Medium.nC](nominal=C_nominal)becauseC_nominalis a vector. This syntax error caused a compilation error in OpenModelica. -
July 30, 2013 by Michael Wetter:
Changed connectormXi_flow[Medium.nXi]to a scalar input connectormWat_flow. The reason is thatmXi_flowdoes not allow to compute the other components inmX_flowand therefore leads to an ambiguous use of the model. By only requestingmWat_flow, the mass balance and species balance can be implemented correctly. -
March 27, 2013 by Michael Wetter:
Removed wrong unit attribute ofCOut, and added min and max attributes forXiOut. -
July 31, 2011 by Michael Wetter:
Added test to stop model translation if the setting forenergyBalanceandmassBalancecan lead to inconsistent equations. -
July 26, 2011 by Michael Wetter:
Removed the option to useh_start, as this is not needed for building simulation. Also removed the reference toModelica.Fluid.System. Moved parameters and medium to Buildings.Fluid.Interfaces.LumpedVolumeDeclarations. -
July 14, 2011 by Michael Wetter:
Added start value for medium density. -
March 29, 2011 by Michael Wetter:
Changed default value forsubstanceDynamicsandtraceDynamicsfromenergyDynamicstomassDynamics. -
September 28, 2010 by Michael Wetter:
Changed array index for nominal value ofXi. -
September 13, 2010 by Michael Wetter:
Set nominal attributes for medium based on default medium values. -
July 30, 2010 by Michael Wetter:
Added parameterC_nominalwhich is used as the nominal attribute forC. Without this value, the ODE solver gives wrong results for concentrations around 1E-7. -
March 21, 2010 by Michael Wetter:
Changed pressure start value fromsystem.p_starttoMedium.p_defaultsince HVAC models may have water and air, which are typically at different pressures. - February 6, 2010 by Michael Wetter:
Added toMedium.BasePropertiesthe initializationX(start=X_start[1:Medium.nX]). Previously, the initialization was only done forXibut not forX, which caused the medium to be initialized toreference_X, ignoring the value ofX_start. - October 12, 2009 by Michael Wetter:
Implemented first version inBuildingslibrary, based on model fromModelica.Fluid 1.0.