modelPartialMixingVolume

Partial mixing volume with inlet and outlet ports (flow reversal is allowed)

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=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.

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

TypeNameDefaultDescription
BooleanprescribedHeatFlowRatefalseSet 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
Booleansimplify_mWat_flowtrueSet to true to cause port_a.m_flow + port_b.m_flow = 0 even if mWat_flow is non-zero
Modelica.Units.SI.VolumeVVolume
Dynamics › Conservation equations
Modelica.Fluid.Types.DynamicsenergyDynamics (from LumpedVolumeDeclarations)Modelica.Fluid.Types.Dynamics.DynamicFreeInitialType of energy balance: dynamic (3 initialization options) or steady state
Modelica.Fluid.Types.DynamicssubstanceDynamics (from LumpedVolumeDeclarations)energyDynamicsType of independent mass fraction balance: dynamic (3 initialization options) or steady state
Modelica.Fluid.Types.DynamicstraceDynamics (from LumpedVolumeDeclarations)energyDynamicsType of trace substance balance: dynamic (3 initialization options) or steady state
Advanced › Dynamics
Modelica.Fluid.Types.DynamicsmassDynamics (from LumpedVolumeDeclarations)energyDynamicsType of mass balance: dynamic (3 initialization options) or steady state, must be steady state if energyDynamics is steady state
Initialization
Medium.AbsolutePressurep_start (from LumpedVolumeDeclarations)Medium.p_defaultStart value of pressure
Medium.TemperatureT_start (from LumpedVolumeDeclarations)Medium.T_defaultStart value of temperature
Medium.MassFraction[Medium.nX]X_start (from LumpedVolumeDeclarations)Medium.X_defaultStart 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
RealmSenFac (from LumpedVolumeDeclarations)1Factor for scaling the sensible thermal mass of the volume
Advanced
Booleaninitialize_pnot Medium.singleState= true to set up initial equations for pressure
Modelica.Units.SI.MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow
Nominal condition
Modelica.Units.SI.MassFlowRatem_flow_nominalNominal mass flow rate
General › Ports
IntegernPorts0Number of ports
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal. Used only if model has two ports.

Connectors

TypeNameDefaultDescription
Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b[nPorts]portsFluid inlets and outlets
Modelica.Blocks.Interfaces.RealOutputUInternal energy of the component
Modelica.Blocks.Interfaces.RealOutputmMass of the component
Modelica.Blocks.Interfaces.RealOutput[Medium.nXi]mXiSpecies mass of the component
Modelica.Blocks.Interfaces.RealOutput[Medium.nC]mCTrace substance mass of the component

Components

TypeNameDefaultDescription
Medium.TemperatureTMedium.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.Pressurepif nPorts > 0 then ports[1].p else p_startPressure of the fluid
Modelica.Units.SI.MassFraction[Medium.nXi]XiXiOut_internalSpecies concentration of the fluid
Medium.ExtraProperty[Medium.nC]CCOut_internalTrace substance mixture content

Revisions

  • June 18, 2024, by Michael Wetter:
    Added start and nominal attributes to avoid warnings in OpenModelica due to conflicting values.
    This is for IBPSA, #1890.
  • October 24, 2022, by Michael Wetter:
    Improved conversion from Xi to X so that it also works with media that have reducedX=true.
    See #1650.
  • September 18, 2020, by Michael Wetter:
    Set start value for steBal.hOut so that T_start can 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:
    Added getInstanceName() to flow reversal check. This if or issue 1228.
  • October 19, 2017, by Michael Wetter:
    Changed initialization of pressure from a constant to a parameter.
    Removed partial keyword as this model is not partial.
    Moved C_flow and use_C_flow to 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 blocks QSen_flow and QLat_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 parameter use_mWat_flow rather than sensibleOnly.
  • January 17, 2016, by Michael Wetter:
    Removed protected block masExc as 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 input C_flow for handling trace substance insertions.
  • July 17, 2015, by Michael Wetter:
    Added constant simplify_mWat_flow to remove dependencies of the pressure drop calculation on the moisture balance.
  • July 1, 2015, by Filip Jorissen:
    Set prescribedHeatFlowRate=prescribedHeatflowRate for 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 for heatPort.T and changed type of T to Medium.Temperature rather than Modelica.Units.SI.Temperature to avoid an error because of conflicting start values if Buildings.Fluid.Chillers.Carnot_y is translated using pedantic mode in Dymola 2016. This is for #426.
  • June 5, 2015, by Michael Wetter:
    Moved assignment of dynBal.U.start from instance dynBal to 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 test
     final parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and
     prescribedHeatFlowRate and ...
    
    to
     final 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 computes hOut = port_b.h_outflow;, and hence it is correct to use hOut to 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:
    Changed initalize_p from a parameter to a constant. 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 a constant.
  • October 29, 2014, by Michael Wetter:
    Made assignment of mFactor final, 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 parameter mFactor to increase the thermal capacity.
  • July 3, 2014, by Michael Wetter:
    Added parameter initialize_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 annotation Evaluate=true.
  • February 11, 2014 by Michael Wetter:
    Removed Q_flow and added QSen_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 of show_V_flow to instance steBal as it has no longer this parameter.
  • September 13, 2013 by Michael Wetter:
    Renamed rho_nominal to rho_start because 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 deprecated cardinality function.
  • February 7, 2012 by Michael Wetter:
    Revised base classes for conservation equations in Buildings.Fluid.Interfaces.
  • September 17, 2011 by Michael Wetter:
    Removed instance medium as this is already used in dynBal. 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 of medium the parameter assignment preferredMediumStates=true to preferredMediumStates= not (energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState). Otherwise, for a steady-state model, Dymola 2012 may differentiate the model to obtain T as 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(...), the inStream(...) formulation is used. This changed required the introduction of a new parameter m_flow_nominal which 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_HeatTransfer as there is no noticeable overhead in always having the heatPort connector present.
  • July 30, 2010 by Michael Wetter:
    Added nominal value for mC to 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 class PartialLumpedVessel.
  • October 12, 2009 by Michael Wetter:
    Changed base class to Buildings.Fluid.MixingVolumes.BaseClasses.ClosedVolume.