modelPartialMixingVolume
Extends from Buildings.Fluid.Interfaces.LumpedVolumeDeclarations (Declarations for lumped volumes).
Information
This is a partial model of an instantaneously mixed volume. It is used as the base class for all fluid volumes of the package Buildings.Fluid.MixingVolumes.
Typical use and important parameters
Set the constant sensibleOnly=true if the model that extends
or instantiates this model sets mWat_flow = 0.
Set the constant simplify_mWat_flow = true to simplify the equation
port_a.m_flow + port_b.m_flow = - mWat_flow;
to
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 by the user.
This constant only has an effect if the model has exactly two fluid ports connected,
and if it is used as a steady-state model.
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.
Set the parameter use_C_flow = true to enable an input connector
for the trace substance flow rate.
Implementation
If the model is (i) operated in steady-state,
(ii) has two fluid ports connected, and
(iii) prescribedHeatFlowRate=true or allowFlowReversal=false,
then the model uses
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
in order to use
the same energy and mass balance implementation as is used as in
steady-state component models.
In this situation, the functions inStream are used for the two
flow directions rather than the function
actualStream, which is less efficient.
However, the use of inStream has the disadvantage
that hOut has to be computed, in
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation,
using
if allowFlowReversal then
hOut = Buildings.Utilities.Math.Functions.regStep(y1=port_b.h_outflow,
y2=port_a.h_outflow,
x=port_a.m_flow,
x_small=m_flow_small/1E3);
else
hOut = port_b.h_outflow;
end if;
Hence, for allowFlowReversal=true, if hOut
were to be used to compute the temperature that
drives heat transfer such as by conduction,
then the heat transfer would depend on upstream and the downstream
temperatures for small mass flow rates.
This can give wrong results. Consider for example a mass flow rate that is positive
but very close to zero. Suppose the upstream temperature is 20°C,
the downstream temperature is 10°C, and the heat port is
connected through a heat conductor to a boundary condition of 20°C.
Then, hOut = (port_b.h_outflow + port_a.h_outflow)/2 and hence
the temperature heatPort.T
is 15°C. Therefore, heat is added to the component.
As the mass flow rate is by assumption very small, the fluid that leaves the component
will have a very high temperature, violating the 2nd law.
To avoid this situation, if
prescribedHeatFlowRate=false, then the model
Buildings.Fluid.Interfaces.ConservationEquation
is used instead of
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation.
For simple models that uses this model, see Buildings.Fluid.MixingVolumes.
Parameters
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | prescribedHeatFlowRate | false | Set to true if the model has a prescribed heat flow at its heatPort. If the heat flow rate at the heatPort is only based on temperature difference, then set to false |
| 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 |
| Modelica.Units.SI.Volume | V | Volume | |
| 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 |
| Modelica.Units.SI.MassFlowRate | m_flow_small | 1E-4*abs(m_flow_nominal) | Small mass flow rate for regularization of zero flow |
| Nominal condition | |||
| Modelica.Units.SI.MassFlowRate | m_flow_nominal | Nominal mass flow rate | |
| General › Ports | |||
| Integer | nPorts | 0 | Number of ports |
| Assumptions | |||
| Boolean | allowFlowReversal | true | = false to simplify equations, assuming, but not enforcing, no flow reversal. Used only if model has two ports. |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b[nPorts] | ports | Fluid inlets and outlets | |
| Modelica.Blocks.Interfaces.RealOutput | U | Internal energy of the component | |
| Modelica.Blocks.Interfaces.RealOutput | m | Mass of the component | |
| Modelica.Blocks.Interfaces.RealOutput[Medium.nXi] | mXi | Species mass of the component | |
| Modelica.Blocks.Interfaces.RealOutput[Medium.nC] | mC | Trace substance mass of the component |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Medium.Temperature | T | Medium.temperature_phX(p = p, h = hOut_internal, X = if Medium.reducedX then cat(1, Xi, {1 - sum(Xi)}) else Xi) | Temperature of the fluid |
| Modelica.Units.SI.Pressure | p | if nPorts > 0 then ports[1].p else p_start | Pressure of the fluid |
| Modelica.Units.SI.MassFraction[Medium.nXi] | Xi | XiOut_internal | Species concentration of the fluid |
| Medium.ExtraProperty[Medium.nC] | C | COut_internal | Trace substance mixture content |
Revisions
-
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:
Improved conversion fromXitoXso that it also works with media that havereducedX=true.
See #1650. -
September 18, 2020, by Michael Wetter:
Set start value forsteBal.hOutso thatT_startcan be used which is not known in that instance.
See #1397. -
February 21, 2020, by Michael Wetter:
Changed icon to display its operating state.
This is for #1294. -
October 30, 2019 by Filip Jorissen:
AddedgetInstanceName()to flow reversal check. This if or issue 1228. -
October 19, 2017, by Michael Wetter:
Changed initialization of pressure from aconstantto aparameter.
Removedpartialkeyword as this model is not partial.
MovedC_flowanduse_C_flowto child classes.
This is for Buildings, issue 1013. -
April 11, 2017, by Michael Wetter:
Moved heat port to the extending classes to provide better comment. Otherwise, the mixing volume without water input would have a comment that says latent heat can be added at this port.
Removed blocksQSen_flowandQLat_flow.
This is for issue Buildings #704. -
February 19, 2016 by Filip Jorissen:
Added outputs U, m, mXi, mC for being able to check conservation of quantities. This if or issue 247. -
January 22, 2016 by Michael Wetter:
Updated model to use the new parameteruse_mWat_flowrather thansensibleOnly. -
January 17, 2016, by Michael Wetter:
RemovedprotectedblockmasExcas this revision introduces a conditional connector for the moisture flow rate in the energy and mass balance models. This change was done to use the same modeling concept for the moisture input as is used for the trace substance input. -
December 2, 2015, by Filip Jorissen:
Added conditional inputC_flowfor handling trace substance insertions. -
July 17, 2015, by Michael Wetter:
Added constantsimplify_mWat_flowto remove dependencies of the pressure drop calculation on the moisture balance. -
July 1, 2015, by Filip Jorissen:
SetprescribedHeatFlowRate=prescribedHeatflowRatefor Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation. This results in equations that are solved more easily. See issue 282 for a discussion. -
June 9, 2015 by Michael Wetter:
Set start value forheatPort.Tand changed type ofTtoMedium.Temperaturerather thanModelica.Units.SI.Temperatureto avoid an error because of conflicting start values ifBuildings.Fluid.Chillers.Carnot_yis translated using pedantic mode in Dymola 2016. This is for #426. -
June 5, 2015, by Michael Wetter:
Moved assignment ofdynBal.U.startfrom instancedynBalto the actual model implementation. This is required for a pedantic model check in Dymola 2016. It addresses issue 266. -
May 6, 2015, by Michael Wetter:
Improved documentation and changed the testfinal parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and prescribedHeatFlowRate and ...
tofinal parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and (prescribedHeatFlowRate or (not allowFlowReversal)) and ...
The reason is that if there is no flow reversal, then Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation computeshOut = port_b.h_outflow;, and hence it is correct to usehOutto compute temperature-driven heat flow, such as by conduction or convection. See also the model documentation.
This is for issue #412. -
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. -
October 29, 2014, by Michael Wetter:
Made assignment ofmFactorfinal, and changed computation of density to use default medium states as are also used to compute the specific heat capacity. -
October 21, 2014, by Filip Jorissen:
Added parametermFactorto increase the thermal capacity. -
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:
RemovedQ_flowand addedQSen_flow. This was done to clarify what is sensible and total heat flow rate as part of the correction of issue #197. -
October 8, 2013 by Michael Wetter:
Removed propagation ofshow_V_flowto instancesteBalas it has no longer this parameter. -
September 13, 2013 by Michael Wetter:
Renamedrho_nominaltorho_startbecause this quantity is computed using start values and not nominal values. -
April 18, 2013 by Michael Wetter:
Removed the check of multiple connections to the same element of a fluid port, as this check required the use of the deprecatedcardinalityfunction. -
February 7, 2012 by Michael Wetter:
Revised base classes for conservation equations inBuildings.Fluid.Interfaces. -
September 17, 2011 by Michael Wetter:
Removed instancemediumas this is already used indynBal. Removing the base properties led to 30% faster computing time for a solar thermal system that contains many fluid volumes. -
September 13, 2011 by Michael Wetter:
Changed in declaration ofmediumthe parameter assignmentpreferredMediumStates=truetopreferredMediumStates= not (energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState). Otherwise, for a steady-state model, Dymola 2012 may differentiate the model to obtainTas a state. See ticket Dynasim #13596. -
July 26, 2011 by Michael Wetter:
Revised model to use new declarations from Buildings.Fluid.Interfaces.LumpedVolumeDeclarations. -
July 14, 2011 by Michael Wetter:
Added start values for mass and internal energy of dynamic balance model. -
May 25, 2011 by Michael Wetter:
-
Changed implementation of balance equation. The new implementation uses a different model if
exactly two fluid ports are connected, and in addition, the model is used as a steady-state
component. For this model configuration, the same balance equations are used as were used
for steady-state component models, i.e., instead of
actualStream(...), theinStream(...)formulation is used. This changed required the introduction of a new parameterm_flow_nominalwhich is used for smoothing in the steady-state balance equations of the model with two fluid ports. This implementation also simplifies the implementation of Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolumeWaterPort, which now uses the same equations as this model. -
Another revision was the removal of the parameter
use_HeatTransferas there is no noticeable overhead in always having theheatPortconnector present.
-
Changed implementation of balance equation. The new implementation uses a different model if
exactly two fluid ports are connected, and in addition, the model is used as a steady-state
component. For this model configuration, the same balance equations are used as were used
for steady-state component models, i.e., instead of
-
July 30, 2010 by Michael Wetter:
Added nominal value formCto avoid wrong trajectory when concentration is around 1E-7. See also https://trac.modelica.org/Modelica/ticket/393. -
February 7, 2010 by Michael Wetter:
Simplified model and its base classes by removing the port data and the vessel area. Eliminated the base classPartialLumpedVessel. -
October 12, 2009 by Michael Wetter:
Changed base class to Buildings.Fluid.MixingVolumes.BaseClasses.ClosedVolume.