This package contains models for completely mixed volumes.
Optionally, heat can be added to the volume by setting the
parameter use_HeatTransfer
to true
.
For most situations, the model Buildings.Fluid.MixingVolumes.MixingVolume should be used. The other models are only of interest if water should be added to or subtracted from the fluid volume, such as needed in a dynamic model of a coil with water vapor condensation.
Extends from Modelica.Icons.VariantsPackage (Icon for package containing variants).
Name | Description |
---|---|
MixingVolume | Mixing volume with inlet and outlet ports (flow reversal is allowed) |
MixingVolumeDryAir | Mixing volume with heat port for latent heat exchange, to be used with dry air |
MixingVolumeMoistAir | Mixing volume with heat port for latent heat exchange, to be used with media that contain water |
Examples | Collection of models that illustrate model use and test models |
BaseClasses | Package with base classes for Buildings.Fluid.MixingVolumes |
heatPort
.
The volume can be parameterized as a steady-state model or as dynamic model.
To increase the numerical robustness of the model, the parameter
prescribedHeatFlowRate
can be set by the user.
This parameter 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:
prescribedHeatFlowRate=true
if there is a model connected to heatPort
that computes the heat flow rate not as 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.
prescribedHeatFlowRate=true
if the only means of heat flow at the heatPort
is 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 the model is operated in steady-state and has two fluid ports connected,
then the same energy and mass balance implementation is used as in
steady-state component models, i.e., the use of actualStream
is not used for the properties at the port.
The implementation of these balance equations is done in the instances
dynBal
for the dynamic balance and steBal
for the steady-state balance. Both models use the same input variables:
Q_flow
is used to add sensible and latent heat to the fluid.
For example, Q_flow
participates in the steady-state energy balanceport_b.h_outflow = inStream(port_a.h_outflow) + Q_flow * m_flowInv;where
m_flowInv
approximates the expression 1/m_flow
.
mXi_flow
is used to add a species mass flow rate to the fluid.
For simple models that uses this model, see Buildings.Fluid.HeatExchangers.HeaterCoolerPrescribed and Buildings.Fluid.MassExchangers.HumidifierPrescribed.
Extends from Buildings.Fluid.Interfaces.LumpedVolumeDeclarations (Declarations for lumped volumes).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Volume | V | Volume [m3] | |
Nominal condition | |||
MassFlowRate | m_flow_nominal | Nominal mass flow rate [kg/s] | |
Dynamics | |||
Equations | |||
Dynamics | energyDynamics | Modelica.Fluid.Types.Dynamic... | Formulation of energy balance |
Dynamics | massDynamics | energyDynamics | Formulation of mass balance |
Initialization | |||
AbsolutePressure | p_start | Medium.p_default | Start value of pressure [Pa] |
Temperature | T_start | Medium.T_default | Start value of temperature [K] |
MassFraction | X_start[Medium.nX] | Medium.X_default | Start value of mass fractions m_i/m [kg/kg] |
ExtraProperty | C_start[Medium.nC] | fill(0, Medium.nC) | Start value of trace substances |
ExtraProperty | C_nominal[Medium.nC] | fill(1E-2, Medium.nC) | Nominal value of trace substances. (Set to typical order of magnitude.) |
Advanced | |||
MassFlowRate | m_flow_small | 1E-4*abs(m_flow_nominal) | Small mass flow rate for regularization of zero flow [kg/s] |
Boolean | homotopyInitialization | true | = true, use homotopy method |
Assumptions | |||
Boolean | allowFlowReversal | system.allowFlowReversal | = true to allow flow reversal in medium, false restricts to design direction (ports[1] -> ports[2]). Used only if model has two ports. |
Heat transfer | |||
Boolean | prescribedHeatFlowRate | false | Set to true if the model has a prescribed heat flow at its heatPort |
Type | Name | Description |
---|---|---|
VesselFluidPorts_b | ports[nPorts] | Fluid inlets and outlets |
HeatPort_a | heatPort | Heat port connected to outflowing medium |
model MixingVolume "Mixing volume with inlet and outlet ports (flow reversal is allowed)" outer Modelica.Fluid.System system "System properties"; extends Buildings.Fluid.Interfaces.LumpedVolumeDeclarations; parameter Modelica.SIunits.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate"; // Port definitions parameter Integer nPorts=0 "Number of ports"; parameter Medium.MassFlowRate m_flow_small(min=0) = 1E-4*abs(m_flow_nominal) "Small mass flow rate for regularization of zero flow"; parameter Boolean homotopyInitialization = true "= true, use homotopy method"; parameter Boolean allowFlowReversal = system.allowFlowReversal "= true to allow flow reversal in medium, false restricts to design direction (ports[1] -> ports[2]). Used only if model has two ports."; parameter Modelica.SIunits.Volume V "Volume"; parameter Boolean prescribedHeatFlowRate=false "Set to true if the model has a prescribed heat flow at its heatPort";Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b ports[nPorts]( redeclare each package Medium = Medium) "Fluid inlets and outlets"; Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat port connected to outflowing medium"; Modelica.SIunits.Temperature T "Temperature of the fluid"; Modelica.SIunits.Pressure p "Pressure of the fluid"; Modelica.SIunits.MassFraction Xi[Medium.nXi] "Species concentration of the fluid"; Medium.ExtraProperty C[Medium.nC](nominal=C_nominal) "Trace substance mixture content"; // Models for the steady-state and dynamic energy balance. protected Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger steBal( sensibleOnly = true, redeclare final package Medium=Medium, final m_flow_nominal = m_flow_nominal, final dp_nominal = 0, final allowFlowReversal = allowFlowReversal, final m_flow_small = m_flow_small, final homotopyInitialization = homotopyInitialization, final show_V_flow = false, final from_dp = false, final linearizeFlowResistance = true, final deltaM = 0.3, Q_flow = Q_flow, mXi_flow = zeros(Medium.nXi)) if useSteadyStateTwoPort "Model for steady-state balance if nPorts=2"; Buildings.Fluid.Interfaces.LumpedVolume dynBal( redeclare final package Medium = Medium, final nPorts = nPorts, final energyDynamics=energyDynamics, final massDynamics=massDynamics, final p_start=p_start, final T_start=T_start, final X_start=X_start, final C_start=C_start, final C_nominal=C_nominal, final fluidVolume = V, m(start=V*rho_nominal), U(start=V*rho_nominal*Medium.specificInternalEnergy( state_start)), Q_flow = Q_flow, mXi_flow = zeros(Medium.nXi)) if not useSteadyStateTwoPort "Model for dynamic energy balance"; parameter Medium.ThermodynamicState state_start = Medium.setState_pTX( T=T_start, p=p_start, X=X_start[1:Medium.nXi]) "Start state"; parameter Modelica.SIunits.Density rho_nominal=Medium.density( Medium.setState_pTX( T=T_start, p=p_start, X=X_start[1:Medium.nXi])) "Density, used to compute fluid mass"; //////////////////////////////////////////////////// final parameter Boolean useSteadyStateTwoPort=(nPorts == 2) and prescribedHeatFlowRate and ( energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and ( massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and ( substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) and ( traceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) "Flag, true if the model has two ports only and uses a steady state balance"; Modelica.SIunits.HeatFlowRate Q_flow "Heat flow across boundaries or energy source/sink"; // Outputs that are needed to assign the medium properties Modelica.Blocks.Interfaces.RealOutput hOut_internal(unit="J/kg") "Internal connector for leaving temperature of the component"; Modelica.Blocks.Interfaces.RealOutput XiOut_internal[Medium.nXi](unit="1") "Internal connector for leaving species concentration of the component"; Modelica.Blocks.Interfaces.RealOutput COut_internal[Medium.nC](unit="1") "Internal connector for leaving trace substances of the component"; equation /////////////////////////////////////////////////////////////////////////// // asserts if not allowFlowReversal then assert(ports[1].m_flow > -m_flow_small, "Model has flow reversal, but the parameter allowFlowReversal is set to false. m_flow_small = " + String(m_flow_small) + " ports[1].m_flow = " + String(ports[1].m_flow) + " "); end if; // Only one connection allowed to a port to avoid unwanted ideal mixing if not useSteadyStateTwoPort then for i in 1:nPorts loop assert(cardinality(ports[i]) == 2 or cardinality(ports[i]) == 0," each ports[i] of volume can at most be connected to one component. If two or more connections are present, ideal mixing takes place with these connections, which is usually not the intention of the modeller. Increase nPorts to add an additional port. "); end for; end if; // actual definition of port variables // If the model computes the energy and mass balances as steady-state, // and if it has only two ports, // then we use the same base class as for all other steady state models. if useSteadyStateTwoPort then connect(ports[1], steBal.port_a); connect(ports[2], steBal.port_b); connect(hOut_internal, steBal.hOut); connect(XiOut_internal, steBal.XiOut); connect(COut_internal, steBal.COut); else connect(ports, dynBal.ports); connect(hOut_internal, dynBal.hOut); connect(XiOut_internal, dynBal.XiOut); connect(COut_internal, dynBal.COut); end if; // Medium properties p = if nPorts > 0 then ports[1].p else p_start; T = Medium.temperature_phX(p=p, h=hOut_internal, X=cat(1,Xi,{1-sum(Xi)})); Xi = XiOut_internal; C = COut_internal; // Port properties heatPort.T = T; heatPort.Q_flow = Q_flow;end MixingVolume;
This model has the same ports as
Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir.
However, there is no mass exchange with the medium other than through the port
ports
.
For media that do provide water as a species, use the model
Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir to add
or subtract moisture using a signal that is connected to the port
mWat_flow
and TWat
.
Extends from BaseClasses.PartialMixingVolumeWaterPort (Partial mixing volume that allows adding or subtracting water vapor).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Volume | V | Volume [m3] | |
Nominal condition | |||
MassFlowRate | m_flow_nominal | Nominal mass flow rate [kg/s] | |
Dynamics | |||
Equations | |||
Dynamics | energyDynamics | Modelica.Fluid.Types.Dynamic... | Formulation of energy balance |
Dynamics | massDynamics | energyDynamics | Formulation of mass balance |
Initialization | |||
AbsolutePressure | p_start | Medium.p_default | Start value of pressure [Pa] |
Temperature | T_start | Medium.T_default | Start value of temperature [K] |
MassFraction | X_start[Medium.nX] | Medium.X_default | Start value of mass fractions m_i/m [kg/kg] |
ExtraProperty | C_start[Medium.nC] | fill(0, Medium.nC) | Start value of trace substances |
ExtraProperty | C_nominal[Medium.nC] | fill(1E-2, Medium.nC) | Nominal value of trace substances. (Set to typical order of magnitude.) |
Advanced | |||
MassFlowRate | m_flow_small | 1E-4*abs(m_flow_nominal) | Small mass flow rate for regularization of zero flow [kg/s] |
Boolean | homotopyInitialization | true | = true, use homotopy method |
Assumptions | |||
Boolean | allowFlowReversal | system.allowFlowReversal | = true to allow flow reversal in medium, false restricts to design direction (ports[1] -> ports[2]). Used only if model has two ports. |
Heat transfer | |||
Boolean | prescribedHeatFlowRate | false | Set to true if the model has a prescribed heat flow at its heatPort |
Type | Name | Description |
---|---|---|
VesselFluidPorts_b | ports[nPorts] | Fluid inlets and outlets |
HeatPort_a | heatPort | Heat port connected to outflowing medium |
input RealInput | mWat_flow | Water flow rate added into the medium [kg/s] |
input RealInput | TWat | Temperature of liquid that is drained from or injected into volume [K] |
output RealOutput | X_w | Species composition of medium |
model MixingVolumeDryAir "Mixing volume with heat port for latent heat exchange, to be used with dry air" extends BaseClasses.PartialMixingVolumeWaterPort( steBal( final sensibleOnly = true)); equation if cardinality(mWat_flow) == 0 then mWat_flow = 0; end if; if cardinality(TWat) == 0 then TWat = Medium.T_default; end if; HWat_flow = 0; mXi_flow = zeros(Medium.nXi); // Assign output port X_w = 0;end MixingVolumeDryAir;
This model represents the same physics as
Buildings.Fluid.MixingVolumes.MixingVolume, but in addition, it allows
adding or subtracting water in liquid phase.
The mass flow rate of the added or subtracted water is
specified at the port mWat_flow
.
The water flow rate is assumed to be added or subtracted at the
temperature of the input port TWat
, or
if this port is not connected, at the medium default temperature as
defined by Medium.T_default
.
Adding water causes a change in
enthalpy and species concentration in the volume.
Note that this model can only be used with medium models that include water
as a substance. In particular, the medium model needs to implement the function
enthalpyOfLiquid(T)
and the integer variable Water
that
contains the index to the water substance. For medium that do not provide this
functionality, use
Buildings.Fluid.MixingVolumes.MixingVolumeDryAir.
Extends from BaseClasses.PartialMixingVolumeWaterPort (Partial mixing volume that allows adding or subtracting water vapor).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Volume | V | Volume [m3] | |
Nominal condition | |||
MassFlowRate | m_flow_nominal | Nominal mass flow rate [kg/s] | |
Dynamics | |||
Equations | |||
Dynamics | energyDynamics | Modelica.Fluid.Types.Dynamic... | Formulation of energy balance |
Dynamics | massDynamics | energyDynamics | Formulation of mass balance |
Initialization | |||
AbsolutePressure | p_start | Medium.p_default | Start value of pressure [Pa] |
Temperature | T_start | Medium.T_default | Start value of temperature [K] |
MassFraction | X_start[Medium.nX] | Medium.X_default | Start value of mass fractions m_i/m [kg/kg] |
ExtraProperty | C_start[Medium.nC] | fill(0, Medium.nC) | Start value of trace substances |
ExtraProperty | C_nominal[Medium.nC] | fill(1E-2, Medium.nC) | Nominal value of trace substances. (Set to typical order of magnitude.) |
Advanced | |||
MassFlowRate | m_flow_small | 1E-4*abs(m_flow_nominal) | Small mass flow rate for regularization of zero flow [kg/s] |
Boolean | homotopyInitialization | true | = true, use homotopy method |
Assumptions | |||
Boolean | allowFlowReversal | system.allowFlowReversal | = true to allow flow reversal in medium, false restricts to design direction (ports[1] -> ports[2]). Used only if model has two ports. |
Heat transfer | |||
Boolean | prescribedHeatFlowRate | false | Set to true if the model has a prescribed heat flow at its heatPort |
Type | Name | Description |
---|---|---|
VesselFluidPorts_b | ports[nPorts] | Fluid inlets and outlets |
HeatPort_a | heatPort | Heat port connected to outflowing medium |
input RealInput | mWat_flow | Water flow rate added into the medium [kg/s] |
input RealInput | TWat | Temperature of liquid that is drained from or injected into volume [K] |
output RealOutput | X_w | Species composition of medium |
model MixingVolumeMoistAir "Mixing volume with heat port for latent heat exchange, to be used with media that contain water" extends BaseClasses.PartialMixingVolumeWaterPort(nPorts(min=2, max=2), steBal( final sensibleOnly = false)); // redeclare Medium with a more restricting base class. This improves the error // message if a user selects a medium that does not contain the function // enthalpyOfLiquid(.) replaceable package Medium = Modelica.Media.Interfaces.PartialCondensingGases; protected parameter Integer i_w(min=1, fixed=false) "Index for water substance"; parameter Real s[Medium.nXi](fixed=false) "Vector with zero everywhere except where species is"; initial algorithm i_w:= -1; if cardinality(mWat_flow) > 0 then for i in 1:Medium.nXi loop if Modelica.Utilities.Strings.isEqual(string1=Medium.substanceNames[i], string2="Water", caseSensitive=false) then i_w := i; s[i] :=1; else s[i] :=0; end if; end for; assert(i_w > 0, "Substance 'water' is not present in medium '" + Medium.mediumName + "'.\n" + "Check medium model."); end if; equation if cardinality(mWat_flow) == 0 then mWat_flow = 0; HWat_flow = 0; mXi_flow = zeros(Medium.nXi); else if cardinality(TWat) == 0 then HWat_flow = mWat_flow * Medium.enthalpyOfLiquid(Medium.T_default); else HWat_flow = mWat_flow * Medium.enthalpyOfLiquid(TWat); end if; // We obtain the substance concentration with a vector multiplication // because Dymola 7.4 cannot find the derivative in the model // Buildings.Fluid.HeatExchangers.Examples.WetCoilDiscretizedPControl // if we set mXi_flow[i] = if ( i == i_w) then mWat_flow else 0; mXi_flow = mWat_flow * s; end if; // Medium species concentration X_w = s * Xi;end MixingVolumeMoistAir;