Name | Description |
---|---|
PartialMixingVolume | Mixing volume with inlet and outlet ports (flow reversal is allowed) |
PartialMixingVolumeWaterPort | Partial mixing volume that allows adding or subtracting water vapor |
This model represents the same physics as Modelica_Fluid.Volumes.MixingVolume, but it allows to have more than two fluid ports. This is convenient for modeling the room volume in a building energy simulation since rooms often have more than two fluid connections, such as an HVAC inlet, outlet and a leakage flow to other rooms or the outside. If a fluid port is connected twice, the model will terminate the simulation with an error message.
Models that extend this partial model need to provide the energy, mass and species balance equations. See Buildings.Fluids.MixingVolumes.MixingVolume.
The thermal port need not be connected, but can have any number of connections.
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Volume | V | Volume [m3] | |
Integer | nP | 2 | Number of ports |
Boolean | steadyState | false | Set to true for steady state model |
Initialization | |||
Temp | initType | Types.Init.NoInit | Initialization option |
AbsolutePressure | p_start | Medium.p_default | Start value of pressure [Pa] |
Boolean | use_T_start | true | = true, use T_start, otherwise h_start |
Temperature | T_start | if use_T_start then Medium.T... | Start value of temperature [K] |
SpecificEnthalpy | h_start | if use_T_start then Medium.s... | Start value of specific enthalpy [J/kg] |
MassFraction | X_start[Medium.nX] | Medium.X_default | Start value of mass fractions m_i/m [kg/kg] |
Type | Name | Description |
---|---|---|
FluidPort_a | port[nP] | Fluid port |
HeatPort_a | thermalPort | Thermal port |
partial model PartialMixingVolume "Mixing volume with inlet and outlet ports (flow reversal is allowed)" extends Modelica_Fluid.Interfaces.PartialInitializationParameters; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; parameter Modelica.SIunits.Volume V "Volume"; parameter Integer nP(min=1) = 2 "Number of ports"; Modelica_Fluid.Interfaces.FluidPort_a port[nP]( redeclare each package Medium = Medium, each C(nominal=1E-3)) "Fluid port"; Medium.BaseProperties medium( preferredMediumStates=true, p(start=p_start), h(start=h_start), T(start=T_start), Xi(start=X_start[1:Medium.nXi])); Modelica.SIunits.Energy U(start=V*rho0*Medium.specificInternalEnergy(sta0)) "Internal energy of fluid"; Modelica.SIunits.Mass m(start=V*rho0) "Mass of fluid"; Modelica.SIunits.Mass mXi[Medium.nXi] "Masses of independent components in the fluid"; Modelica.SIunits.Volume V_lumped "Volume"; Medium.ExtraProperty mC[Medium.nC] "Masses of auxiliary components in the fluid"; Medium.MassFraction mc[Medium.nC](start=zeros(Medium.nC), nominal=1E-3) "Mass fraction of auxiliary components in the fluid"; protected parameter Medium.ThermodynamicState sta0 = Medium.setState_pTX(T=T_start, p=p_start, X=X_start[1:Medium.nXi]); parameter Modelica.SIunits.Density rho0=Medium.density(sta0) "Density, used to compute fluid volume"; Modelica.SIunits.HeatFlowRate Qs_flow "Heat flow across boundaries or energy source/sink"; Modelica.SIunits.Power Ws_flow=0 "Work flow across boundaries or source term"; public Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a thermalPort "Thermal port"; public parameter Boolean steadyState = false "Set to true for steady state model"; equation V_lumped=V; thermalPort.T = medium.T; Qs_flow = thermalPort.Q_flow; // boundary conditions for i in 1:nP loop port[i].p = medium.p; port[i].H_flow = semiLinear( port[i].m_flow, port[i].h, medium.h); port[i].mXi_flow = semiLinear( port[i].m_flow, port[i].Xi, medium.Xi); port[i].mC_flow = semiLinear( port[i].m_flow, port[i].C, mc); end for; // Total quantities m = V_lumped*medium.d; mXi = m*medium.Xi; U = m*medium.u; // The auxiliary species balances is formulated in the non-dimensional form // using mc instead of mC, which makes it easier to provide a nominal value if steadyState then zeros(Medium.nC) = sum(port[i].mC_flow for i in 1:nP); else der(mc) = sum(port[i].mC_flow for i in 1:nP)/m; end if; mC = mc*m; // Mass and energy balance. // To be implemented by models that extend this partial model. // der(m) = sum(port[i].m_flow for i in 1:nP); // der(mXi) = sum(port[i].mXi_flow for i in 1:nP); // der(U) = sum(port[i].H_flow for i in 1:nP) + Qs_flow + Ws_flow; initial equation // Initial conditions for i in 1:nP loop assert(cardinality(port[i]) == 1, "Only one port connection allowed. To fix, increase nP and use new port."); end for; if initType == Modelica_Fluid.Types.Init.NoInit then // no initial equations elseif initType == Modelica_Fluid.Types.Init.InitialValues then if not Medium.singleState then medium.p = p_start; end if; if use_T_start then medium.T = T_start; else medium.h = h_start; end if; medium.Xi = X_start[1:Medium.nXi]; elseif initType == Modelica_Fluid.Types.Init.SteadyState then if not Medium.singleState then der(medium.p) = 0; end if; der(medium.h) = 0; der(medium.Xi) = zeros(Medium.nXi); elseif initType == Modelica_Fluid.Types.Init.SteadyStateHydraulic then if not Medium.singleState then der(medium.p) = 0; end if; if use_T_start then medium.T = T_start; else medium.h = h_start; end if; medium.Xi = X_start[1:Medium.nXi]; else assert(false, "Unsupported initialization option"); end if; end PartialMixingVolume;
This model represents the same physics as Buildings.Fluids.Components.BaseClasses.PartialMixingVolume but in addition, it allows to connect signals for the water exchanged with the volume. The model is partial in order to allow a submodel that can be used with media that contain water as a substance, and a submodel that can be used with dry air. Having separate models is required because calls to the medium property function enthalpyOfLiquid results in a linker error if a medium such as Modelica.Media.Air.SimpleAir is used that does not implement this function.
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Volume | V | Volume [m3] | |
Integer | nP | 2 | Number of ports |
Boolean | steadyState | false | Set to true for steady state model |
Initialization | |||
Temp | initType | Types.Init.NoInit | Initialization option |
AbsolutePressure | p_start | Medium.p_default | Start value of pressure [Pa] |
Boolean | use_T_start | true | = true, use T_start, otherwise h_start |
Temperature | T_start | if use_T_start then Medium.T... | Start value of temperature [K] |
SpecificEnthalpy | h_start | if use_T_start then Medium.s... | Start value of specific enthalpy [J/kg] |
MassFraction | X_start[Medium.nX] | Medium.X_default | Start value of mass fractions m_i/m [kg/kg] |
Type | Name | Description |
---|---|---|
FluidPort_a | port[nP] | Fluid port |
HeatPort_a | thermalPort | Thermal port |
input RealInput | mWat_flow | Water flow rate added into the medium |
input RealInput | TWat | Temperature of liquid that is drained from or injected into volume |
output RealOutput | XWat | Species composition of medium |
partial model PartialMixingVolumeWaterPort "Partial mixing volume that allows adding or subtracting water vapor" extends PartialMixingVolume; Modelica.Blocks.Interfaces.RealInput mWat_flow(redeclare type SignalType = Modelica.SIunits.MassFlowRate) "Water flow rate added into the medium"; Modelica.Blocks.Interfaces.RealInput TWat(redeclare type SignalType = Modelica.SIunits.Temperature) "Temperature of liquid that is drained from or injected into volume"; Modelica.Blocks.Interfaces.RealOutput XWat(redeclare type SignalType = Modelica.SIunits.MassFraction) "Species composition of medium"; Medium.MassFlowRate mXi_flow[Medium.nXi] "Mass flow rates of independent substances added to the medium"; Modelica.SIunits.HeatFlowRate HWat_flow "Enthalpy flow rate of extracted water"; equation // Mass and energy balance if steadyState then 0 = sum(port[i].m_flow for i in 1:nP) + mWat_flow; zeros(Medium.nXi) = sum(port[i].mXi_flow for i in 1:nP) + mXi_flow; 0 = sum(port[i].H_flow for i in 1:nP) + Qs_flow + Ws_flow + HWat_flow; else der(m) = sum(port[i].m_flow for i in 1:nP) + mWat_flow; der(mXi) = sum(port[i].mXi_flow for i in 1:nP) + mXi_flow; der(U) = sum(port[i].H_flow for i in 1:nP) + Qs_flow + Ws_flow + HWat_flow; end if; end PartialMixingVolumeWaterPort;