Buildings.Fluid.Interfaces

Package with interfaces for fluid models

Information

This package contains basic classes that are used to build component models that change the state of the fluid. The classes are not directly usable, but can be extended when building a new model.

Extends from Modelica.Icons.InterfacesPackage (Icon for packages containing interfaces).

Package Content

Name Description
Buildings.Fluid.Interfaces.UsersGuide UsersGuide User's Guide
Buildings.Fluid.Interfaces.ConservationEquation ConservationEquation Lumped volume with mass and energy balance
Buildings.Fluid.Interfaces.EightPort EightPort Partial model with eight ports
Buildings.Fluid.Interfaces.EightPortHeatMassExchanger EightPortHeatMassExchanger Model transporting four fluid streams between eight ports with storing mass or energy
Buildings.Fluid.Interfaces.FourPortHeatMassExchanger FourPortHeatMassExchanger Model transporting two fluid streams between four ports with storing mass or energy
Buildings.Fluid.Interfaces.PartialEightPortInterface PartialEightPortInterface Partial model transporting fluid between eight ports without storing mass or energy
Buildings.Fluid.Interfaces.PartialFourPort PartialFourPort Partial model with four ports
Buildings.Fluid.Interfaces.PartialFourPortInterface PartialFourPortInterface Partial model transporting fluid between two ports without storing mass or energy
Buildings.Fluid.Interfaces.PartialFourPortParallel PartialFourPortParallel Partial model with four ports for components with parallel flow
Buildings.Fluid.Interfaces.PartialTwoPort PartialTwoPort Partial component with two ports
Buildings.Fluid.Interfaces.PartialTwoPortInterface PartialTwoPortInterface Partial model transporting fluid between two ports without storing mass or energy
Buildings.Fluid.Interfaces.PartialTwoPortTransport PartialTwoPortTransport Partial element transporting fluid between two ports without storage of mass or energy
Buildings.Fluid.Interfaces.PartialTwoPortVector PartialTwoPortVector Partial component with two ports, one of which being vectorized
Buildings.Fluid.Interfaces.PrescribedOutlet PrescribedOutlet Component that assigns the outlet fluid property at port_a based on an input signal
Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger StaticFourPortHeatMassExchanger Partial model transporting two fluid streams between four ports without storing mass or energy
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation StaticTwoPortConservationEquation Partial model for static energy and mass conservation equations
Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger StaticTwoPortHeatMassExchanger Partial model transporting fluid between two ports without storing mass or energy
Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger TwoPortHeatMassExchanger Partial model transporting one fluid stream with storing mass or energy
Buildings.Fluid.Interfaces.EightPortFlowResistanceParameters EightPortFlowResistanceParameters Parameters for flow resistance for models with height ports
Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters FourPortFlowResistanceParameters Parameters for flow resistance for models with four ports
Buildings.Fluid.Interfaces.LumpedVolumeDeclarations LumpedVolumeDeclarations Declarations for lumped volumes
Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters TwoPortFlowResistanceParameters Parameters for flow resistance for models with two ports
Buildings.Fluid.Interfaces.Examples Examples Collection of models that illustrate model use and test models

Buildings.Fluid.Interfaces.ConservationEquation Buildings.Fluid.Interfaces.ConservationEquation

Lumped volume with mass and energy balance

Buildings.Fluid.Interfaces.ConservationEquation

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.

Input connectors of the model are

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.

Extends from Buildings.Fluid.Interfaces.LumpedVolumeDeclarations (Declarations for lumped volumes).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
VolumefluidVolume Volume [m3]
Dynamics
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Type of energy balance: dynamic (3 initialization options) or steady state
DynamicsmassDynamicsenergyDynamicsType of mass balance: dynamic (3 initialization options) or steady state
RealmSenFac1Factor for scaling the sensible thermal mass of the volume
Initialization
AbsolutePressurep_startMedium.p_defaultStart value of pressure [Pa]
TemperatureT_startMedium.T_defaultStart value of temperature [K]
MassFractionX_start[Medium.nX]Medium.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC_start[Medium.nC]fill(0, Medium.nC)Start value of trace substances
ExtraPropertyC_nominal[Medium.nC]fill(1E-2, Medium.nC)Nominal value of trace substances. (Set to typical order of magnitude.)
Advanced
Booleaninitialize_pnot Medium.singleState= true to set up initial equations for pressure
Booleanuse_mWat_flowfalseSet to true to enable input connector for moisture mass flow rate
Booleanuse_C_flowfalseSet to true to enable input connector for trace substance

Connectors

TypeNameDescription
input RealInputQ_flowSensible plus latent heat flow rate transferred into the medium [W]
input RealInputmWat_flowMoisture mass flow rate added to the medium [kg/s]
input RealInputC_flow[Medium.nC]Trace substance mass flow rate added to the medium
output RealOutputhOutLeaving specific enthalpy of the component [J/kg]
output RealOutputXiOut[Medium.nXi]Leaving species concentration of the component [1]
output RealOutputCOut[Medium.nC]Leaving trace substances of the component
output RealOutputUOutInternal energy of the component [J]
output RealOutputmXiOut[Medium.nXi]Species mass of the component [kg]
output RealOutputmOutMass of the component [kg]
output RealOutputmCOut[Medium.nC]Trace substance mass of the component [kg]
VesselFluidPorts_bports[nPorts]Fluid inlets and outlets

Modelica definition

model ConservationEquation "Lumped volume with mass and energy balance" extends Buildings.Fluid.Interfaces.LumpedVolumeDeclarations; // Constants parameter Boolean initialize_p = not Medium.singleState "= true to set up initial equations for pressure"; constant 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"; // Port definitions parameter Integer nPorts=0 "Number of ports"; parameter Boolean use_mWat_flow = false "Set to true to enable input connector for moisture mass flow rate"; parameter Boolean use_C_flow = false "Set to true to enable input connector for trace substance"; Modelica.Blocks.Interfaces.RealInput Q_flow(unit="W") "Sensible plus latent heat flow rate transferred into the medium"; Modelica.Blocks.Interfaces.RealInput mWat_flow(final quantity="MassFlowRate", unit="kg/s") if use_mWat_flow "Moisture mass flow rate added to the medium"; Modelica.Blocks.Interfaces.RealInput[Medium.nC] C_flow if use_C_flow "Trace substance mass flow rate added to the medium"; // Outputs that are needed in models that use this model Modelica.Blocks.Interfaces.RealOutput hOut(unit="J/kg", start=hStart) "Leaving specific enthalpy of the component"; Modelica.Blocks.Interfaces.RealOutput XiOut[Medium.nXi](each unit="1", each min=0, each max=1) "Leaving species concentration of the component"; Modelica.Blocks.Interfaces.RealOutput COut[Medium.nC](each min=0) "Leaving trace substances of the component"; Modelica.Blocks.Interfaces.RealOutput UOut(unit="J") "Internal energy of the component"; Modelica.Blocks.Interfaces.RealOutput mXiOut[Medium.nXi](each min=0, each unit= "kg") "Species mass of the component"; Modelica.Blocks.Interfaces.RealOutput mOut(min=0, unit="kg") "Mass of the component"; Modelica.Blocks.Interfaces.RealOutput mCOut[Medium.nC](each min=0, each unit="kg") "Trace substance mass of the component"; Modelica.Fluid.Vessels.BaseClasses.VesselFluidPorts_b ports[nPorts]( redeclare each final package Medium = Medium) "Fluid inlets and outlets"; // Set nominal attributes where literal values can be used. Medium.BaseProperties medium( p(start=p_start), h(start=hStart), T(start=T_start), Xi(start=X_start[1:Medium.nXi]), X(start=X_start), d(start=rho_start)) "Medium properties"; Modelica.SIunits.Energy U(start=fluidVolume*rho_start* Medium.specificInternalEnergy(Medium.setState_pTX( T=T_start, p=p_start, X=X_start[1:Medium.nXi])) + (T_start - Medium.reference_T)*CSen, nominal = 1E5) "Internal energy of fluid"; Modelica.SIunits.Mass m( start=fluidVolume*rho_start, stateSelect=if massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then StateSelect.default else StateSelect.prefer) "Mass of fluid"; Modelica.SIunits.Mass[Medium.nXi] mXi( start=fluidVolume*rho_start*X_start[1:Medium.nXi]) "Masses of independent components in the fluid"; Modelica.SIunits.Mass[Medium.nC] mC( start=fluidVolume*rho_start*C_start) "Masses of trace substances in the fluid"; // C need to be added here because unlike for Xi, which has medium.Xi, // there is no variable medium.C Medium.ExtraProperty C[Medium.nC](nominal=C_nominal) "Trace substance mixture content"; Modelica.SIunits.MassFlowRate mb_flow "Mass flows across boundaries"; Modelica.SIunits.MassFlowRate[Medium.nXi] mbXi_flow "Substance mass flows across boundaries"; Medium.ExtraPropertyFlowRate[Medium.nC] mbC_flow "Trace substance mass flows across boundaries"; Modelica.SIunits.EnthalpyFlowRate Hb_flow "Enthalpy flow across boundaries or energy source/sink"; // Parameters that need to be defined by an extending class parameter Modelica.SIunits.Volume fluidVolume "Volume"; final parameter Modelica.SIunits.HeatCapacity CSen= (mSenFac - 1)*rho_default*cp_default*fluidVolume "Aditional heat capacity for implementing mFactor"; protected Medium.EnthalpyFlowRate ports_H_flow[nPorts]; Modelica.SIunits.MassFlowRate ports_mXi_flow[nPorts,Medium.nXi]; Medium.ExtraPropertyFlowRate ports_mC_flow[nPorts,Medium.nC]; parameter Modelica.SIunits.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=state_default) "Heat capacity, to compute additional dry mass"; parameter Modelica.SIunits.Density rho_start=Medium.density( Medium.setState_pTX( T=T_start, p=p_start, X=X_start[1:Medium.nXi])) "Density, used to compute fluid mass"; // Parameter for avoiding extra overhead calculations when CSen==0 final parameter Boolean computeCSen = abs(mSenFac-1) > Modelica.Constants.eps; final parameter Medium.ThermodynamicState state_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default values"; // Density at medium default values, used to compute the size of control volumes final parameter Modelica.SIunits.Density rho_default=Medium.density( state=state_default) "Density, used to compute fluid mass"; // Parameter that is used to construct the vector mXi_flow final parameter Real s[Medium.nXi] = {if Modelica.Utilities.Strings.isEqual( string1=Medium.substanceNames[i], string2="Water", caseSensitive=false) then 1 else 0 for i in 1:Medium.nXi} "Vector with zero everywhere except where species is"; parameter Modelica.SIunits.SpecificEnthalpy hStart= Medium.specificEnthalpy_pTX(p_start, T_start, X_start) "Start value for specific enthalpy"; // Set _simplify_mWat_flow == false for Glycol47; otherwise Dymola 2018FD01 // cannot differentiate the equations. constant Boolean _simplify_mWat_flow = simplify_mWat_flow and Medium.nX > 1 "If true, then port_a.m_flow + port_b.m_flow = 0 even if mWat_flow is non-zero, and equations are simplified"; // Conditional connectors Modelica.Blocks.Interfaces.RealInput mWat_flow_internal(unit="kg/s") "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput C_flow_internal[Medium.nC] "Needed to connect to conditional connector"; initial equation // Assert that the substance with name 'water' has been found. assert(Medium.nXi == 0 or abs(sum(s)-1) < 1e-5, "In " + getInstanceName() + ": If Medium.nXi > 1, then substance 'water' must be present for one component of '" + Medium.mediumName + "'. Check medium model."); // Make sure that if energyDynamics is SteadyState, then // massDynamics is also SteadyState. // Otherwise, the system of ordinary differential equations may be inconsistent. if energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then assert(massDynamics == energyDynamics, "In " + getInstanceName() + ": If 'massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState', then it is required that 'energyDynamics==Modelica.Fluid.Types.Dynamics.SteadyState'. Otherwise, the system of equations may not be consistent. You need to select other parameter values."); end if; // initialization of balances if energyDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then medium.T = T_start; else if energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then der(medium.T) = 0; end if; end if; if massDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then if initialize_p then medium.p = p_start; end if; else if massDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then if initialize_p then der(medium.p) = 0; end if; end if; end if; if substanceDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then medium.Xi = X_start[1:Medium.nXi]; else if substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then der(medium.Xi) = zeros(Medium.nXi); end if; end if; if traceDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then C = C_start[1:Medium.nC]; else if traceDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then der(C) = zeros(Medium.nC); end if; end if; equation // Conditional connectors connect(mWat_flow, mWat_flow_internal); if not use_mWat_flow then mWat_flow_internal = 0; end if; connect(C_flow, C_flow_internal); if not use_C_flow then C_flow_internal = zeros(Medium.nC); end if; // Total quantities if massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then m = fluidVolume*rho_start; else if _simplify_mWat_flow then // If moisture is neglected in mass balance, assume for computation // of the mass of air that the air is at Medium.X_default. m = fluidVolume*Medium.density(Medium.setState_phX( p = medium.p, h = hOut, X = Medium.X_default)); else // Use actual density m = fluidVolume*medium.d; end if; end if; mXi = m*medium.Xi; if computeCSen then U = m*medium.u + CSen*(medium.T-Medium.reference_T); else U = m*medium.u; end if; mC = m*C; hOut = medium.h; XiOut = medium.Xi; COut = C; for i in 1:nPorts loop //The semiLinear function should be used for the equations below //for allowing min/max simplifications. //See https://github.com/ibpsa/modelica-ibpsa/issues/216 for a discussion and motivation ports_H_flow[i] = semiLinear(ports[i].m_flow, inStream(ports[i].h_outflow), ports[i].h_outflow) "Enthalpy flow"; for j in 1:Medium.nXi loop ports_mXi_flow[i,j] = semiLinear(ports[i].m_flow, inStream(ports[i].Xi_outflow[j]), ports[i].Xi_outflow[j]) "Component mass flow"; end for; for j in 1:Medium.nC loop ports_mC_flow[i,j] = semiLinear(ports[i].m_flow, inStream(ports[i].C_outflow[j]), ports[i].C_outflow[j]) "Trace substance mass flow"; end for; end for; for i in 1:Medium.nXi loop mbXi_flow[i] = sum(ports_mXi_flow[:,i]); end for; for i in 1:Medium.nC loop mbC_flow[i] = sum(ports_mC_flow[:,i]); end for; mb_flow = sum(ports.m_flow); Hb_flow = sum(ports_H_flow); // Energy and mass balances if energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then 0 = Hb_flow + Q_flow; else der(U) = Hb_flow + Q_flow; end if; if massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then 0 = mb_flow + (if simplify_mWat_flow then 0 else mWat_flow_internal); else der(m) = mb_flow + (if simplify_mWat_flow then 0 else mWat_flow_internal); end if; if substanceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then zeros(Medium.nXi) = mbXi_flow + mWat_flow_internal * s; else der(mXi) = mbXi_flow + mWat_flow_internal * s; end if; if traceDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then zeros(Medium.nC) = mbC_flow + C_flow_internal; else der(mC) = mbC_flow + C_flow_internal; end if; // Properties of outgoing flows for i in 1:nPorts loop ports[i].p = medium.p; ports[i].h_outflow = medium.h; ports[i].Xi_outflow = medium.Xi; ports[i].C_outflow = C; end for; UOut=U; mXiOut=mXi; mOut=m; mCOut=mC; end ConservationEquation;

Buildings.Fluid.Interfaces.EightPort Buildings.Fluid.Interfaces.EightPort

Partial model with eight ports

Buildings.Fluid.Interfaces.EightPort

Information

This model defines an interface for components with eight ports. The parameters allowFlowReversal1, allowFlowReversal2, allowFlowReversal3 and allowFlowReversal4 may be used by models that extend this model to treat flow reversal.

This model is identical to Modelica.Fluid.Interfaces.PartialTwoPort, except that it has eight ports.

Parameters

TypeNameDefaultDescription
replaceable package Medium1Modelica.Media.Interfaces.Pa...Medium 1 in the component
replaceable package Medium2Modelica.Media.Interfaces.Pa...Medium 2 in the component
replaceable package Medium3Modelica.Media.Interfaces.Pa...Medium 3 in the component
replaceable package Medium4Modelica.Media.Interfaces.Pa...Medium 4 in the component
Assumptions
BooleanallowFlowReversal1true= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2true= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal3true= true to allow flow reversal in medium 3, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal4true= true to allow flow reversal in medium 4, false restricts to design direction (port_a -> port_b)
Advanced
Initialization
SpecificEnthalpyh_outflow_a1_startMedium1.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b1_startMedium1.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a2_startMedium2.h_defaultStart value for enthalpy flowing out of port a2 [J/kg]
SpecificEnthalpyh_outflow_b2_startMedium2.h_defaultStart value for enthalpy flowing out of port b2 [J/kg]
SpecificEnthalpyh_outflow_a3_startMedium3.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b3_startMedium3.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a4_startMedium4.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b4_startMedium4.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]

Connectors

TypeNameDescription
replaceable package Medium1Medium 1 in the component
replaceable package Medium2Medium 2 in the component
replaceable package Medium3Medium 3 in the component
replaceable package Medium4Medium 4 in the component
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_aport_a3Fluid connector a1 (positive design flow direction is from port_a3 to port_b3)
FluidPort_bport_b3Fluid connector b2 (positive design flow direction is from port_a3 to port_b3)
FluidPort_aport_a4Fluid connector a1 (positive design flow direction is from port_a4 to port_b4)
FluidPort_bport_b4Fluid connector b2 (positive design flow direction is from port_a4 to port_b4)

Modelica definition

partial model EightPort "Partial model with eight ports" replaceable package Medium1 = Modelica.Media.Interfaces.PartialMedium "Medium 1 in the component"; replaceable package Medium2 = Modelica.Media.Interfaces.PartialMedium "Medium 2 in the component"; replaceable package Medium3 = Modelica.Media.Interfaces.PartialMedium "Medium 3 in the component"; replaceable package Medium4 = Modelica.Media.Interfaces.PartialMedium "Medium 4 in the component"; parameter Boolean allowFlowReversal1 = true "= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)"; parameter Boolean allowFlowReversal2 = true "= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)"; parameter Boolean allowFlowReversal3 = true "= true to allow flow reversal in medium 3, false restricts to design direction (port_a -> port_b)"; parameter Boolean allowFlowReversal4 = true "= true to allow flow reversal in medium 4, false restricts to design direction (port_a -> port_b)"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a1_start = Medium1.h_default "Start value for enthalpy flowing out of port a1"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b1_start = Medium1.h_default "Start value for enthalpy flowing out of port b1"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a2_start = Medium2.h_default "Start value for enthalpy flowing out of port a2"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b2_start = Medium2.h_default "Start value for enthalpy flowing out of port b2"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a3_start = Medium3.h_default "Start value for enthalpy flowing out of port a1"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b3_start = Medium3.h_default "Start value for enthalpy flowing out of port b1"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a4_start = Medium4.h_default "Start value for enthalpy flowing out of port a1"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b4_start = Medium4.h_default "Start value for enthalpy flowing out of port b1"; Modelica.Fluid.Interfaces.FluidPort_a port_a1( redeclare final package Medium = Medium1, m_flow(min=if allowFlowReversal1 then -Modelica.Constants.inf else 0), h_outflow(start=h_outflow_a1_start)) "Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_b port_b1( redeclare final package Medium = Medium1, m_flow(max=if allowFlowReversal1 then +Modelica.Constants.inf else 0), h_outflow(start=h_outflow_b1_start)) "Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_a port_a2( redeclare final package Medium = Medium2, m_flow(min=if allowFlowReversal2 then -Modelica.Constants.inf else 0), h_outflow(start=h_outflow_a2_start)) "Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)"; Modelica.Fluid.Interfaces.FluidPort_b port_b2( redeclare final package Medium = Medium2, m_flow(max=if allowFlowReversal2 then +Modelica.Constants.inf else 0), h_outflow(start=h_outflow_b2_start)) "Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)"; Modelica.Fluid.Interfaces.FluidPort_a port_a3( redeclare final package Medium = Medium3, m_flow(min=if allowFlowReversal3 then -Modelica.Constants.inf else 0), h_outflow(start=h_outflow_a3_start)) "Fluid connector a1 (positive design flow direction is from port_a3 to port_b3)"; Modelica.Fluid.Interfaces.FluidPort_b port_b3( redeclare final package Medium = Medium3, m_flow(max=if allowFlowReversal3 then +Modelica.Constants.inf else 0), h_outflow(start=h_outflow_b3_start)) "Fluid connector b2 (positive design flow direction is from port_a3 to port_b3)"; Modelica.Fluid.Interfaces.FluidPort_a port_a4( redeclare final package Medium = Medium4, m_flow(min=if allowFlowReversal4 then -Modelica.Constants.inf else 0), h_outflow(start=h_outflow_a4_start)) "Fluid connector a1 (positive design flow direction is from port_a4 to port_b4)"; Modelica.Fluid.Interfaces.FluidPort_b port_b4( redeclare final package Medium = Medium4, m_flow(max=if allowFlowReversal4 then +Modelica.Constants.inf else 0), h_outflow(start=h_outflow_b4_start)) "Fluid connector b2 (positive design flow direction is from port_a4 to port_b4)"; end EightPort;

Buildings.Fluid.Interfaces.EightPortHeatMassExchanger Buildings.Fluid.Interfaces.EightPortHeatMassExchanger

Model transporting four fluid streams between eight ports with storing mass or energy

Buildings.Fluid.Interfaces.EightPortHeatMassExchanger

Information

This component transports four fluid streams between eight ports. It provides the basic model for implementing a dynamic heat exchanger.

The model can be used as-is, although there will be no heat or mass transfer between the four fluid streams. To add heat transfer, heat flow can be added to the heat port of the four volumes.

Implementation

The variable names follow the conventions used in Modelica.Fluid.Examples.HeatExchanger.BaseClasses.BasicHX.

Extends from Buildings.Fluid.Interfaces.PartialEightPortInterface (Partial model transporting fluid between eight ports without storing mass or energy), Buildings.Fluid.Interfaces.EightPortFlowResistanceParameters (Parameters for flow resistance for models with height ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
replaceable package Medium3PartialMediumMedium 3 in the component
replaceable package Medium4PartialMediumMedium 4 in the component
Nominal condition
MassFlowRatem1_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem3_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem4_flow_nominal Nominal mass flow rate [kg/s]
Pressuredp1_nominal Pressure [Pa]
Pressuredp2_nominal Pressure [Pa]
Pressuredp3_nominal Pressure [Pa]
Pressuredp4_nominal Pressure [Pa]
Assumptions
BooleanallowFlowReversal1true= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2true= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal3true= true to allow flow reversal in medium 3, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal4true= true to allow flow reversal in medium 4, false restricts to design direction (port_a -> port_b)
Advanced
Initialization
SpecificEnthalpyh_outflow_a1_starth1_outflow_startStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b1_starth1_outflow_startStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a2_starth2_outflow_startStart value for enthalpy flowing out of port a2 [J/kg]
SpecificEnthalpyh_outflow_b2_starth2_outflow_startStart value for enthalpy flowing out of port b2 [J/kg]
SpecificEnthalpyh_outflow_a3_starth3_outflow_startStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b3_starth3_outflow_startStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a4_starth4_outflow_startStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b4_starth4_outflow_startStart value for enthalpy flowing out of port b1 [J/kg]
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem3_flow_small1E-4*abs(m3_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem4_flow_small1E-4*abs(m4_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed
Flow resistance
Medium 1
BooleancomputeFlowResistance1true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar
Medium 3
BooleancomputeFlowResistance3true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp3false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance3false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM30.1Fraction of nominal flow rate where flow transitions to laminar
Medium 4
BooleancomputeFlowResistance4true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp4false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance4false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM40.1Fraction of nominal flow rate where flow transitions to laminar
Dynamics
Nominal condition
Timetau130Time constant at nominal flow [s]
Timetau230Time constant at nominal flow [s]
Timetau330Time constant at nominal flow [s]
Timetau430Time constant at nominal flow [s]
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Formulation of energy balance
DynamicsmassDynamicsenergyDynamicsFormulation of mass balance
Initialization
Medium 1
AbsolutePressurep1_startMedium1.p_defaultStart value of pressure [Pa]
TemperatureT1_startMedium1.T_defaultStart value of temperature [K]
MassFractionX1_start[Medium1.nX]Medium1.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC1_start[Medium1.nC]fill(0, Medium1.nC)Start value of trace substances
ExtraPropertyC1_nominal[Medium1.nC]fill(1E-2, Medium1.nC)Nominal value of trace substances. (Set to typical order of magnitude.)
Medium 2
AbsolutePressurep2_startMedium2.p_defaultStart value of pressure [Pa]
TemperatureT2_startMedium2.T_defaultStart value of temperature [K]
MassFractionX2_start[Medium2.nX]Medium2.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC2_start[Medium2.nC]fill(0, Medium2.nC)Start value of trace substances
ExtraPropertyC2_nominal[Medium2.nC]fill(1E-2, Medium2.nC)Nominal value of trace substances. (Set to typical order of magnitude.)
Medium 3
AbsolutePressurep3_startMedium3.p_defaultStart value of pressure [Pa]
TemperatureT3_startMedium3.T_defaultStart value of temperature [K]
MassFractionX3_start[Medium3.nX]Medium3.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC3_start[Medium3.nC]fill(0, Medium3.nC)Start value of trace substances
ExtraPropertyC3_nominal[Medium3.nC]fill(1E-2, Medium3.nC)Nominal value of trace substances. (Set to typical order of magnitude.)
Medium 4
AbsolutePressurep4_startMedium4.p_defaultStart value of pressure [Pa]
TemperatureT4_startMedium4.T_defaultStart value of temperature [K]
MassFractionX4_start[Medium4.nX]Medium4.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC4_start[Medium4.nC]fill(0, Medium4.nC)Start value of trace substances
ExtraPropertyC4_nominal[Medium4.nC]fill(1E-2, Medium4.nC)Nominal value of trace substances. (Set to typical order of magnitude.)

Connectors

TypeNameDescription
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_aport_a3Fluid connector a1 (positive design flow direction is from port_a3 to port_b3)
FluidPort_bport_b3Fluid connector b2 (positive design flow direction is from port_a3 to port_b3)
FluidPort_aport_a4Fluid connector a1 (positive design flow direction is from port_a4 to port_b4)
FluidPort_bport_b4Fluid connector b2 (positive design flow direction is from port_a4 to port_b4)

Modelica definition

model EightPortHeatMassExchanger "Model transporting four fluid streams between eight ports with storing mass or energy" extends Buildings.Fluid.Interfaces.PartialEightPortInterface( final h_outflow_a1_start = h1_outflow_start, final h_outflow_b1_start = h1_outflow_start, final h_outflow_a2_start = h2_outflow_start, final h_outflow_b2_start = h2_outflow_start, final h_outflow_a3_start = h3_outflow_start, final h_outflow_b3_start = h3_outflow_start, final h_outflow_a4_start = h4_outflow_start, final h_outflow_b4_start = h4_outflow_start); extends Buildings.Fluid.Interfaces.EightPortFlowResistanceParameters( final computeFlowResistance1=true, final computeFlowResistance2=true,final computeFlowResistance3=true, final computeFlowResistance4=true); parameter Modelica.SIunits.Time tau1 = 30 "Time constant at nominal flow"; parameter Modelica.SIunits.Time tau2 = 30 "Time constant at nominal flow"; parameter Modelica.SIunits.Time tau3 = 30 "Time constant at nominal flow"; parameter Modelica.SIunits.Time tau4 = 30 "Time constant at nominal flow"; // Advanced parameter Boolean homotopyInitialization = true "= true, use homotopy method"; // Assumptions parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Formulation of energy balance"; parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Formulation of mass balance"; // Initialization parameter Medium1.AbsolutePressure p1_start = Medium1.p_default "Start value of pressure"; parameter Medium1.Temperature T1_start = Medium1.T_default "Start value of temperature"; parameter Medium1.MassFraction X1_start[Medium1.nX] = Medium1.X_default "Start value of mass fractions m_i/m"; parameter Medium1.ExtraProperty C1_start[Medium1.nC]( quantity=Medium1.extraPropertiesNames)=fill(0, Medium1.nC) "Start value of trace substances"; parameter Medium1.ExtraProperty C1_nominal[Medium1.nC]( quantity=Medium1.extraPropertiesNames) = fill(1E-2, Medium1.nC) "Nominal value of trace substances. (Set to typical order of magnitude.)"; parameter Medium2.AbsolutePressure p2_start = Medium2.p_default "Start value of pressure"; parameter Medium2.Temperature T2_start = Medium2.T_default "Start value of temperature"; parameter Medium2.MassFraction X2_start[Medium2.nX] = Medium2.X_default "Start value of mass fractions m_i/m"; parameter Medium2.ExtraProperty C2_start[Medium2.nC]( quantity=Medium2.extraPropertiesNames)=fill(0, Medium2.nC) "Start value of trace substances"; parameter Medium2.ExtraProperty C2_nominal[Medium2.nC]( quantity=Medium2.extraPropertiesNames) = fill(1E-2, Medium2.nC) "Nominal value of trace substances. (Set to typical order of magnitude.)"; parameter Medium3.AbsolutePressure p3_start = Medium3.p_default "Start value of pressure"; parameter Medium3.Temperature T3_start = Medium3.T_default "Start value of temperature"; parameter Medium3.MassFraction X3_start[Medium3.nX] = Medium3.X_default "Start value of mass fractions m_i/m"; parameter Medium3.ExtraProperty C3_start[Medium3.nC]( quantity=Medium3.extraPropertiesNames)=fill(0, Medium3.nC) "Start value of trace substances"; parameter Medium3.ExtraProperty C3_nominal[Medium3.nC]( quantity=Medium3.extraPropertiesNames) = fill(1E-2, Medium3.nC) "Nominal value of trace substances. (Set to typical order of magnitude.)"; parameter Medium4.AbsolutePressure p4_start = Medium4.p_default "Start value of pressure"; parameter Medium4.Temperature T4_start = Medium4.T_default "Start value of temperature"; parameter Medium4.MassFraction X4_start[Medium4.nX] = Medium4.X_default "Start value of mass fractions m_i/m"; parameter Medium4.ExtraProperty C4_start[Medium4.nC]( quantity=Medium4.extraPropertiesNames)=fill(0, Medium4.nC) "Start value of trace substances"; parameter Medium4.ExtraProperty C4_nominal[Medium4.nC]( quantity=Medium4.extraPropertiesNames) = fill(1E-2, Medium4.nC) "Nominal value of trace substances. (Set to typical order of magnitude.)"; Modelica.SIunits.HeatFlowRate Q1_flow = vol1.heatPort.Q_flow "Heat flow rate into medium 1"; Modelica.SIunits.HeatFlowRate Q2_flow = vol2.heatPort.Q_flow "Heat flow rate into medium 2"; Modelica.SIunits.HeatFlowRate Q3_flow = vol3.heatPort.Q_flow "Heat flow rate into medium 1"; Modelica.SIunits.HeatFlowRate Q4_flow = vol4.heatPort.Q_flow "Heat flow rate into medium 2"; Buildings.Fluid.MixingVolumes.MixingVolume vol1( redeclare final package Medium = Medium1, nPorts = 2, V=m1_flow_nominal*tau1/rho1_nominal, final m_flow_nominal=m1_flow_nominal, energyDynamics=if tau1 > Modelica.Constants.eps then energyDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, massDynamics=if tau1 > Modelica.Constants.eps then massDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, final p_start=p1_start, final T_start=T1_start, final X_start=X1_start, final C_start=C1_start, final C_nominal=C1_nominal) "Volume for fluid 1"; Buildings.Fluid.MixingVolumes.MixingVolume vol2( redeclare final package Medium = Medium2, nPorts=2, energyDynamics=if tau2 > Modelica.Constants.eps then energyDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, massDynamics=if tau2 > Modelica.Constants.eps then massDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, final p_start=p2_start, final T_start=T2_start, final X_start=X2_start, final C_start=C2_start, final C_nominal=C2_nominal, final m_flow_nominal=m2_flow_nominal, V=m2_flow_nominal*tau2/rho2_nominal) "Volume for fluid 2"; Buildings.Fluid.MixingVolumes.MixingVolume vol3( redeclare final package Medium = Medium3, energyDynamics=if tau3 > Modelica.Constants.eps then energyDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, massDynamics=if tau3 > Modelica.Constants.eps then massDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, final p_start=p3_start, final T_start=T3_start, final X_start=X3_start, final C_start=C3_start, final C_nominal=C3_nominal, final m_flow_nominal=m3_flow_nominal, V=m3_flow_nominal*tau3/rho3_nominal, nPorts=2) "Volume for fluid 3"; Buildings.Fluid.MixingVolumes.MixingVolume vol4( redeclare final package Medium = Medium4, nPorts=2, energyDynamics=if tau4 > Modelica.Constants.eps then energyDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, massDynamics=if tau4 > Modelica.Constants.eps then massDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, final p_start=p4_start, final T_start=T4_start, final X_start=X4_start, final C_start=C4_start, final C_nominal=C4_nominal, final m_flow_nominal=m4_flow_nominal, V=m4_flow_nominal*tau4/rho4_nominal) "Volume for fluid 4"; Buildings.Fluid.FixedResistances.PressureDrop preDro1( redeclare final package Medium = Medium1, final m_flow_nominal=m1_flow_nominal, final deltaM=deltaM1, final allowFlowReversal=allowFlowReversal1, final show_T=false, final from_dp=from_dp1, final linearized=linearizeFlowResistance1, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp1_nominal) "Pressure drop model for fluid 1"; Buildings.Fluid.FixedResistances.PressureDrop preDro2( redeclare final package Medium = Medium2, final m_flow_nominal=m2_flow_nominal, final deltaM=deltaM2, final allowFlowReversal=allowFlowReversal2, final show_T=false, final from_dp=from_dp2, final linearized=linearizeFlowResistance2, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp2_nominal) "Pressure drop model for fluid 2"; Buildings.Fluid.FixedResistances.PressureDrop preDro3( redeclare final package Medium = Medium3, final m_flow_nominal=m3_flow_nominal, final deltaM=deltaM3, final allowFlowReversal=allowFlowReversal3, final show_T=false, final from_dp=from_dp3, final linearized=linearizeFlowResistance3, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp3_nominal) "Pressure drop model for fluid 3"; Buildings.Fluid.FixedResistances.PressureDrop preDro4( redeclare final package Medium = Medium4, final m_flow_nominal=m4_flow_nominal, final deltaM=deltaM4, final allowFlowReversal=allowFlowReversal4, final show_T=false, final from_dp=from_dp4, final linearized=linearizeFlowResistance4, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp4_nominal) "Pressure drop model for fluid 4"; protected parameter Medium1.ThermodynamicState sta1_nominal=Medium1.setState_pTX( T=Medium1.T_default, p=Medium1.p_default, X=Medium1.X_default); parameter Modelica.SIunits.Density rho1_nominal=Medium1.density(sta1_nominal) "Density, used to compute fluid volume"; parameter Medium2.ThermodynamicState sta2_nominal=Medium2.setState_pTX( T=Medium2.T_default, p=Medium2.p_default, X=Medium2.X_default); parameter Modelica.SIunits.Density rho2_nominal=Medium2.density(sta2_nominal) "Density, used to compute fluid volume"; parameter Medium1.ThermodynamicState sta3_nominal=Medium3.setState_pTX( T=Medium3.T_default, p=Medium3.p_default, X=Medium3.X_default); parameter Modelica.SIunits.Density rho3_nominal=Medium3.density(sta3_nominal) "Density, used to compute fluid volume"; parameter Medium4.ThermodynamicState sta4_nominal=Medium4.setState_pTX( T=Medium4.T_default, p=Medium4.p_default, X=Medium4.X_default); parameter Modelica.SIunits.Density rho4_nominal=Medium4.density(sta4_nominal) "Density, used to compute fluid volume"; parameter Medium1.ThermodynamicState sta1_start=Medium1.setState_pTX( T=T1_start, p=p1_start, X=X1_start); parameter Modelica.SIunits.SpecificEnthalpy h1_outflow_start = Medium1.specificEnthalpy(sta1_start) "Start value for outflowing enthalpy"; parameter Medium2.ThermodynamicState sta2_start=Medium2.setState_pTX( T=T2_start, p=p2_start, X=X2_start); parameter Modelica.SIunits.SpecificEnthalpy h2_outflow_start = Medium2.specificEnthalpy(sta2_start) "Start value for outflowing enthalpy"; parameter Medium3.ThermodynamicState sta3_start=Medium3.setState_pTX( T=T3_start, p=p3_start, X=X3_start); parameter Modelica.SIunits.SpecificEnthalpy h3_outflow_start = Medium3.specificEnthalpy(sta3_start) "Start value for outflowing enthalpy"; parameter Medium4.ThermodynamicState sta4_start=Medium4.setState_pTX( T=T4_start, p=p4_start, X=X4_start); parameter Modelica.SIunits.SpecificEnthalpy h4_outflow_start = Medium4.specificEnthalpy(sta4_start) "Start value for outflowing enthalpy"; initial algorithm // Check for tau1 assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau1 > Modelica.Constants.eps, "The parameter tau1, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau1 = " + String(tau1) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau1 > Modelica.Constants.eps, "The parameter tau1, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau1 = " + String(tau1) + "\n"); // Check for tau2 assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau2 > Modelica.Constants.eps, "The parameter tau2, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau2 = " + String(tau2) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau2 > Modelica.Constants.eps, "The parameter tau2, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau2 = " + String(tau2) + "\n"); // Check for tau1 assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau3 > Modelica.Constants.eps, "The parameter tau3, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau3 = " + String(tau3) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau3 > Modelica.Constants.eps, "The parameter tau3, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau3 = " + String(tau3) + "\n"); // Check for tau2 assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau4 > Modelica.Constants.eps, "The parameter tau4, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau4 = " + String(tau4) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau4 > Modelica.Constants.eps, "The parameter tau4, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau4 = " + String(tau4) + "\n"); equation connect(vol1.ports[2], port_b1); connect(port_a1, preDro1.port_a); connect(preDro1.port_b, vol1.ports[1]); connect(port_a2, preDro2.port_a); connect(preDro4.port_a, port_a4); connect(preDro4.port_b, vol4.ports[1]); connect(port_b4, vol4.ports[2]); connect(port_a3, preDro3.port_a); connect(preDro3.port_b, vol3.ports[1]); connect(port_b3, vol3.ports[2]); connect(port_b2, vol2.ports[1]); connect(preDro2.port_b, vol2.ports[2]); end EightPortHeatMassExchanger;

Buildings.Fluid.Interfaces.FourPortHeatMassExchanger Buildings.Fluid.Interfaces.FourPortHeatMassExchanger

Model transporting two fluid streams between four ports with storing mass or energy

Buildings.Fluid.Interfaces.FourPortHeatMassExchanger

Information

This component transports two fluid streams between four ports. It provides the basic model for implementing a dynamic heat exchanger.

The model can be used as-is, although there will be no heat or mass transfer between the two fluid streams. To add heat transfer, heat flow can be added to the heat port of the two volumes. See for example Buildings.Fluid.Chillers.Carnot_y. To add moisture input into (or moisture output from) volume vol2, the model can be replaced with Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir.

Implementation

The variable names follow the conventions used in Modelica.Fluid.Examples.HeatExchanger.BaseClasses.BasicHX.

Extends from Buildings.Fluid.Interfaces.PartialFourPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters (Parameters for flow resistance for models with four ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
MixingVolumeHeatPortvol1redeclare Buildings.Fluid.Mi...Volume for fluid 1
MixingVolumevol2redeclare Buildings.Fluid.Mi...Volume for fluid 2
Nominal condition
MassFlowRatem1_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominal Nominal mass flow rate [kg/s]
PressureDifferencedp1_nominal Pressure difference [Pa]
PressureDifferencedp2_nominal Pressure difference [Pa]
Assumptions
BooleanallowFlowReversal1true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 1
BooleanallowFlowReversal2true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 2
Advanced
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed
Flow resistance
Medium 1
BooleancomputeFlowResistance1true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar
Dynamics
Nominal condition
Timetau130Time constant at nominal flow [s]
Timetau230Time constant at nominal flow [s]
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Type of energy balance: dynamic (3 initialization options) or steady state
DynamicsmassDynamicsenergyDynamicsType of mass balance: dynamic (3 initialization options) or steady state
Initialization
Medium 1
AbsolutePressurep1_startMedium1.p_defaultStart value of pressure [Pa]
TemperatureT1_startMedium1.T_defaultStart value of temperature [K]
MassFractionX1_start[Medium1.nX]Medium1.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC1_start[Medium1.nC]fill(0, Medium1.nC)Start value of trace substances
ExtraPropertyC1_nominal[Medium1.nC]fill(1E-2, Medium1.nC)Nominal value of trace substances. (Set to typical order of magnitude.)
Medium 2
AbsolutePressurep2_startMedium2.p_defaultStart value of pressure [Pa]
TemperatureT2_startMedium2.T_defaultStart value of temperature [K]
MassFractionX2_start[Medium2.nX]Medium2.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC2_start[Medium2.nC]fill(0, Medium2.nC)Start value of trace substances
ExtraPropertyC2_nominal[Medium2.nC]fill(1E-2, Medium2.nC)Nominal value of trace substances. (Set to typical order of magnitude.)

Modelica definition

model FourPortHeatMassExchanger "Model transporting two fluid streams between four ports with storing mass or energy" extends Buildings.Fluid.Interfaces.PartialFourPortInterface( port_a1(h_outflow(start=h1_outflow_start)), port_b1(h_outflow(start=h1_outflow_start)), port_a2(h_outflow(start=h2_outflow_start)), port_b2(h_outflow(start=h2_outflow_start))); extends Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters( final computeFlowResistance1=true, final computeFlowResistance2=true); parameter Modelica.SIunits.Time tau1 = 30 "Time constant at nominal flow"; parameter Modelica.SIunits.Time tau2 = 30 "Time constant at nominal flow"; // Advanced parameter Boolean homotopyInitialization = true "= true, use homotopy method"; // Assumptions parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Type of energy balance: dynamic (3 initialization options) or steady state"; parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state"; // Initialization parameter Medium1.AbsolutePressure p1_start = Medium1.p_default "Start value of pressure"; parameter Medium1.Temperature T1_start = Medium1.T_default "Start value of temperature"; parameter Medium1.MassFraction X1_start[Medium1.nX] = Medium1.X_default "Start value of mass fractions m_i/m"; parameter Medium1.ExtraProperty C1_start[Medium1.nC]( final quantity=Medium1.extraPropertiesNames)=fill(0, Medium1.nC) "Start value of trace substances"; parameter Medium1.ExtraProperty C1_nominal[Medium1.nC]( final quantity=Medium1.extraPropertiesNames) = fill(1E-2, Medium1.nC) "Nominal value of trace substances. (Set to typical order of magnitude.)"; parameter Medium2.AbsolutePressure p2_start = Medium2.p_default "Start value of pressure"; parameter Medium2.Temperature T2_start = Medium2.T_default "Start value of temperature"; parameter Medium2.MassFraction X2_start[Medium2.nX] = Medium2.X_default "Start value of mass fractions m_i/m"; parameter Medium2.ExtraProperty C2_start[Medium2.nC]( final quantity=Medium2.extraPropertiesNames)=fill(0, Medium2.nC) "Start value of trace substances"; parameter Medium2.ExtraProperty C2_nominal[Medium2.nC]( final quantity=Medium2.extraPropertiesNames) = fill(1E-2, Medium2.nC) "Nominal value of trace substances. (Set to typical order of magnitude.)"; Modelica.SIunits.HeatFlowRate Q1_flow = vol1.heatPort.Q_flow "Heat flow rate into medium 1"; Modelica.SIunits.HeatFlowRate Q2_flow = vol2.heatPort.Q_flow "Heat flow rate into medium 2"; replaceable Buildings.Fluid.MixingVolumes.BaseClasses.MixingVolumeHeatPort vol1 constrainedby Buildings.Fluid.MixingVolumes.BaseClasses.MixingVolumeHeatPort( redeclare final package Medium = Medium1, nPorts = 2, V=m1_flow_nominal*tau1/rho1_nominal, final allowFlowReversal=allowFlowReversal1, final m_flow_nominal=m1_flow_nominal, energyDynamics=if tau1 > Modelica.Constants.eps then energyDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, massDynamics=if tau1 > Modelica.Constants.eps then massDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, final p_start=p1_start, final T_start=T1_start, final X_start=X1_start, final C_start=C1_start, final C_nominal=C1_nominal, mSenFac=1) "Volume for fluid 1"; replaceable Buildings.Fluid.MixingVolumes.MixingVolume vol2 constrainedby Buildings.Fluid.MixingVolumes.BaseClasses.MixingVolumeHeatPort( redeclare final package Medium = Medium2, nPorts = 2, V=m2_flow_nominal*tau2/rho2_nominal, final allowFlowReversal=allowFlowReversal2, mSenFac=1, final m_flow_nominal = m2_flow_nominal, energyDynamics=if tau2 > Modelica.Constants.eps then energyDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, massDynamics=if tau2 > Modelica.Constants.eps then massDynamics else Modelica.Fluid.Types.Dynamics.SteadyState, final p_start=p2_start, final T_start=T2_start, final X_start=X2_start, final C_start=C2_start, final C_nominal=C2_nominal) "Volume for fluid 2"; Buildings.Fluid.FixedResistances.PressureDrop preDro1( redeclare final package Medium = Medium1, final m_flow_nominal=m1_flow_nominal, final deltaM=deltaM1, final allowFlowReversal=allowFlowReversal1, final show_T=false, final from_dp=from_dp1, final linearized=linearizeFlowResistance1, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp1_nominal) "Flow resistance of fluid 1"; Buildings.Fluid.FixedResistances.PressureDrop preDro2( redeclare final package Medium = Medium2, final m_flow_nominal=m2_flow_nominal, final deltaM=deltaM2, final allowFlowReversal=allowFlowReversal2, final show_T=false, final from_dp=from_dp2, final linearized=linearizeFlowResistance2, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp2_nominal) "Flow resistance of fluid 2"; protected parameter Medium1.ThermodynamicState sta1_nominal=Medium1.setState_pTX( T=Medium1.T_default, p=Medium1.p_default, X=Medium1.X_default); parameter Modelica.SIunits.Density rho1_nominal=Medium1.density(sta1_nominal) "Density, used to compute fluid volume"; parameter Medium2.ThermodynamicState sta2_nominal=Medium2.setState_pTX( T=Medium2.T_default, p=Medium2.p_default, X=Medium2.X_default); parameter Modelica.SIunits.Density rho2_nominal=Medium2.density(sta2_nominal) "Density, used to compute fluid volume"; parameter Medium1.ThermodynamicState sta1_start=Medium1.setState_pTX( T=T1_start, p=p1_start, X=X1_start); parameter Modelica.SIunits.SpecificEnthalpy h1_outflow_start = Medium1.specificEnthalpy(sta1_start) "Start value for outflowing enthalpy"; parameter Medium2.ThermodynamicState sta2_start=Medium2.setState_pTX( T=T2_start, p=p2_start, X=X2_start); parameter Modelica.SIunits.SpecificEnthalpy h2_outflow_start = Medium2.specificEnthalpy(sta2_start) "Start value for outflowing enthalpy"; initial equation // Check for tau1 assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau1 > Modelica.Constants.eps, "The parameter tau1, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau1 = " + String(tau1) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau1 > Modelica.Constants.eps, "The parameter tau1, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau1 = " + String(tau1) + "\n"); // Check for tau2 assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau2 > Modelica.Constants.eps, "The parameter tau2, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau2 = " + String(tau2) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau2 > Modelica.Constants.eps, "The parameter tau2, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau2 = " + String(tau2) + "\n"); equation connect(vol1.ports[2], port_b1); connect(vol2.ports[2], port_b2); connect(port_a1, preDro1.port_a); connect(preDro1.port_b, vol1.ports[1]); connect(port_a2, preDro2.port_a); connect(preDro2.port_b, vol2.ports[1]); end FourPortHeatMassExchanger;

Buildings.Fluid.Interfaces.PartialEightPortInterface Buildings.Fluid.Interfaces.PartialEightPortInterface

Partial model transporting fluid between eight ports without storing mass or energy

Buildings.Fluid.Interfaces.PartialEightPortInterface

Information

This component defines the interface for models that transport four fluid streams between eight ports. It is similar to Buildings.Fluid.Interfaces.PartialTwoPortInterface, but it has eight ports instead of two.

The model is used by other models in this package that add heat transfer, mass transfer and pressure drop equations.

Extends from Buildings.Fluid.Interfaces.EightPort (Partial model with eight ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
replaceable package Medium3PartialMediumMedium 3 in the component
replaceable package Medium4PartialMediumMedium 4 in the component
Nominal condition
MassFlowRatem1_flow_nominalm1_flow_nominal( ...Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominalm2_flow_nominal( ...Nominal mass flow rate [kg/s]
MassFlowRatem3_flow_nominalm3_flow_nominal( ...Nominal mass flow rate [kg/s]
MassFlowRatem4_flow_nominalm4_flow_nominal( ...Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversal1true= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2true= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal3true= true to allow flow reversal in medium 3, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal4true= true to allow flow reversal in medium 4, false restricts to design direction (port_a -> port_b)
Advanced
Initialization
SpecificEnthalpyh_outflow_a1_startMedium1.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b1_startMedium1.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a2_startMedium2.h_defaultStart value for enthalpy flowing out of port a2 [J/kg]
SpecificEnthalpyh_outflow_b2_startMedium2.h_defaultStart value for enthalpy flowing out of port b2 [J/kg]
SpecificEnthalpyh_outflow_a3_startMedium3.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b3_startMedium3.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
SpecificEnthalpyh_outflow_a4_startMedium4.h_defaultStart value for enthalpy flowing out of port a1 [J/kg]
SpecificEnthalpyh_outflow_b4_startMedium4.h_defaultStart value for enthalpy flowing out of port b1 [J/kg]
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem3_flow_small1E-4*abs(m3_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem4_flow_small1E-4*abs(m4_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed

Connectors

TypeNameDescription
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_aport_a3Fluid connector a1 (positive design flow direction is from port_a3 to port_b3)
FluidPort_bport_b3Fluid connector b2 (positive design flow direction is from port_a3 to port_b3)
FluidPort_aport_a4Fluid connector a1 (positive design flow direction is from port_a4 to port_b4)
FluidPort_bport_b4Fluid connector b2 (positive design flow direction is from port_a4 to port_b4)

Modelica definition

partial model PartialEightPortInterface "Partial model transporting fluid between eight ports without storing mass or energy" extends Buildings.Fluid.Interfaces.EightPort; parameter Modelica.SIunits.MassFlowRate m1_flow_nominal(min=0) "Nominal mass flow rate"; parameter Modelica.SIunits.MassFlowRate m2_flow_nominal(min=0) "Nominal mass flow rate"; parameter Modelica.SIunits.MassFlowRate m3_flow_nominal(min=0) "Nominal mass flow rate"; parameter Modelica.SIunits.MassFlowRate m4_flow_nominal(min=0) "Nominal mass flow rate"; parameter Medium1.MassFlowRate m1_flow_small(min=0) = 1E-4*abs(m1_flow_nominal) "Small mass flow rate for regularization of zero flow"; parameter Medium2.MassFlowRate m2_flow_small(min=0) = 1E-4*abs(m2_flow_nominal) "Small mass flow rate for regularization of zero flow"; parameter Medium3.MassFlowRate m3_flow_small(min=0) = 1E-4*abs(m3_flow_nominal) "Small mass flow rate for regularization of zero flow"; parameter Medium4.MassFlowRate m4_flow_small(min=0) = 1E-4*abs(m4_flow_nominal) "Small mass flow rate for regularization of zero flow"; // Diagnostics parameter Boolean show_T = false "= true, if actual temperature at port is computed"; Medium1.MassFlowRate m1_flow = port_a1.m_flow "Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction)"; Modelica.SIunits.Pressure dp1(displayUnit="Pa") "Pressure difference between port_a1 and port_b1"; Medium2.MassFlowRate m2_flow = port_a2.m_flow "Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction)"; Modelica.SIunits.Pressure dp2(displayUnit="Pa") "Pressure difference between port_a2 and port_b2"; Medium3.MassFlowRate m3_flow = port_a3.m_flow "Mass flow rate from port_a3 to port_b3 (m3_flow > 0 is design flow direction)"; Modelica.SIunits.Pressure dp3(displayUnit="Pa") "Pressure difference between port_a3 and port_b3"; Medium4.MassFlowRate m4_flow = port_a4.m_flow "Mass flow rate from port_a4 to port_b4 (m4_flow > 0 is design flow direction)"; Modelica.SIunits.Pressure dp4(displayUnit="Pa") "Pressure difference between port_a4 and port_b4"; Medium1.ThermodynamicState sta_a1= Medium1.setState_phX(port_a1.p, noEvent(actualStream(port_a1.h_outflow)), noEvent(actualStream(port_a1.Xi_outflow))) if show_T "Medium properties in port_a1"; Medium1.ThermodynamicState sta_b1= Medium1.setState_phX(port_b1.p, noEvent(actualStream(port_b1.h_outflow)), noEvent(actualStream(port_b1.Xi_outflow))) if show_T "Medium properties in port_b1"; Medium2.ThermodynamicState sta_a2= Medium2.setState_phX(port_a2.p, noEvent(actualStream(port_a2.h_outflow)), noEvent(actualStream(port_a2.Xi_outflow))) if show_T "Medium properties in port_a2"; Medium2.ThermodynamicState sta_b2= Medium2.setState_phX(port_b2.p, noEvent(actualStream(port_b2.h_outflow)), noEvent(actualStream(port_b2.Xi_outflow))) if show_T "Medium properties in port_b2"; Medium3.ThermodynamicState sta_a3= Medium3.setState_phX(port_a3.p, noEvent(actualStream(port_a3.h_outflow)), noEvent(actualStream(port_a3.Xi_outflow))) if show_T "Medium properties in port_a3"; Medium3.ThermodynamicState sta_b3= Medium3.setState_phX(port_b3.p, noEvent(actualStream(port_b3.h_outflow)), noEvent(actualStream(port_b3.Xi_outflow))) if show_T "Medium properties in port_b3"; Medium4.ThermodynamicState sta_a4= Medium4.setState_phX(port_a4.p, noEvent(actualStream(port_a4.h_outflow)), noEvent(actualStream(port_a4.Xi_outflow))) if show_T "Medium properties in port_a4"; Medium4.ThermodynamicState sta_b4= Medium4.setState_phX(port_b4.p, noEvent(actualStream(port_b4.h_outflow)), noEvent(actualStream(port_b4.Xi_outflow))) if show_T "Medium properties in port_b4"; protected Medium1.ThermodynamicState state_a1_inflow= Medium1.setState_phX(port_a1.p, inStream(port_a1.h_outflow), inStream(port_a1.Xi_outflow)) "state for medium inflowing through port_a1"; Medium1.ThermodynamicState state_b1_inflow= Medium1.setState_phX(port_b1.p, inStream(port_b1.h_outflow), inStream(port_b1.Xi_outflow)) "state for medium inflowing through port_b1"; Medium2.ThermodynamicState state_a2_inflow= Medium2.setState_phX(port_a2.p, inStream(port_a2.h_outflow), inStream(port_a2.Xi_outflow)) "state for medium inflowing through port_a2"; Medium2.ThermodynamicState state_b2_inflow= Medium2.setState_phX(port_b2.p, inStream(port_b2.h_outflow), inStream(port_b2.Xi_outflow)) "state for medium inflowing through port_b2"; Medium3.ThermodynamicState state_a3_inflow= Medium3.setState_phX(port_a3.p, inStream(port_a3.h_outflow), inStream(port_a3.Xi_outflow)) "state for medium inflowing through port_a3"; Medium3.ThermodynamicState state_b3_inflow= Medium3.setState_phX(port_b3.p, inStream(port_b3.h_outflow), inStream(port_b3.Xi_outflow)) "state for medium inflowing through port_b3"; Medium4.ThermodynamicState state_a4_inflow= Medium4.setState_phX(port_a4.p, inStream(port_a4.h_outflow), inStream(port_a4.Xi_outflow)) "state for medium inflowing through port_a4"; Medium4.ThermodynamicState state_b4_inflow= Medium4.setState_phX(port_b4.p, inStream(port_b4.h_outflow), inStream(port_b4.Xi_outflow)) "state for medium inflowing through port_b4"; equation dp1 = port_a1.p - port_b1.p; dp2 = port_a2.p - port_b2.p; dp3 = port_a3.p - port_b3.p; dp4 = port_a4.p - port_b4.p; end PartialEightPortInterface;

Buildings.Fluid.Interfaces.PartialFourPort Buildings.Fluid.Interfaces.PartialFourPort

Partial model with four ports

Buildings.Fluid.Interfaces.PartialFourPort

Information

This model defines an interface for components with four ports. The parameters allowFlowReversal1 and allowFlowReversal2 may be used by models that extend this model to treat flow reversal.

This model is identical to Modelica.Fluid.Interfaces.PartialTwoPort, except for the fowllowing:

  1. it has four ports, and
  2. the parameters port_a_exposesState, port_b_exposesState and showDesignFlowDirection are not implemented.

Parameters

TypeNameDefaultDescription
replaceable package Medium1Modelica.Media.Interfaces.Pa...Medium 1 in the component
replaceable package Medium2Modelica.Media.Interfaces.Pa...Medium 2 in the component
Assumptions
BooleanallowFlowReversal1true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 1
BooleanallowFlowReversal2true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 2

Connectors

TypeNameDescription
replaceable package Medium1Medium 1 in the component
replaceable package Medium2Medium 2 in the component
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)

Modelica definition

partial model PartialFourPort "Partial model with four ports" replaceable package Medium1 = Modelica.Media.Interfaces.PartialMedium "Medium 1 in the component"; replaceable package Medium2 = Modelica.Media.Interfaces.PartialMedium "Medium 2 in the component"; parameter Boolean allowFlowReversal1 = true "= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 1"; parameter Boolean allowFlowReversal2 = true "= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 2"; Modelica.Fluid.Interfaces.FluidPort_a port_a1( redeclare final package Medium = Medium1, m_flow(min=if allowFlowReversal1 then -Modelica.Constants.inf else 0), h_outflow(start = Medium1.h_default, nominal = Medium1.h_default)) "Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_b port_b1( redeclare final package Medium = Medium1, m_flow(max=if allowFlowReversal1 then +Modelica.Constants.inf else 0), h_outflow(start = Medium1.h_default, nominal = Medium1.h_default)) "Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_a port_a2( redeclare final package Medium = Medium2, m_flow(min=if allowFlowReversal2 then -Modelica.Constants.inf else 0), h_outflow(start = Medium2.h_default, nominal = Medium2.h_default)) "Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)"; Modelica.Fluid.Interfaces.FluidPort_b port_b2( redeclare final package Medium = Medium2, m_flow(max=if allowFlowReversal2 then +Modelica.Constants.inf else 0), h_outflow(start = Medium2.h_default, nominal = Medium2.h_default)) "Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)"; end PartialFourPort;

Buildings.Fluid.Interfaces.PartialFourPortInterface Buildings.Fluid.Interfaces.PartialFourPortInterface

Partial model transporting fluid between two ports without storing mass or energy

Buildings.Fluid.Interfaces.PartialFourPortInterface

Information

This component defines the interface for models that transport two fluid streams between four ports. It is similar to Buildings.Fluid.Interfaces.PartialTwoPortInterface, but it has four ports instead of two.

The model is used by other models in this package that add heat transfer, mass transfer and pressure drop equations.

Extends from Buildings.Fluid.Interfaces.PartialFourPort (Partial model with four ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
Nominal condition
MassFlowRatem1_flow_nominalm1_flow_nominal( ...Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominalm2_flow_nominal( ...Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversal1true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 1
BooleanallowFlowReversal2true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 2
Advanced
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed

Connectors

TypeNameDescription
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)

Modelica definition

partial model PartialFourPortInterface "Partial model transporting fluid between two ports without storing mass or energy" extends Buildings.Fluid.Interfaces.PartialFourPort; parameter Modelica.SIunits.MassFlowRate m1_flow_nominal(min=0) "Nominal mass flow rate"; parameter Modelica.SIunits.MassFlowRate m2_flow_nominal(min=0) "Nominal mass flow rate"; parameter Medium1.MassFlowRate m1_flow_small(min=0) = 1E-4*abs(m1_flow_nominal) "Small mass flow rate for regularization of zero flow"; parameter Medium2.MassFlowRate m2_flow_small(min=0) = 1E-4*abs(m2_flow_nominal) "Small mass flow rate for regularization of zero flow"; // Diagnostics parameter Boolean show_T = false "= true, if actual temperature at port is computed"; Medium1.MassFlowRate m1_flow = port_a1.m_flow "Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction)"; Modelica.SIunits.PressureDifference dp1(displayUnit="Pa") = port_a1.p - port_b1.p "Pressure difference between port_a1 and port_b1"; Medium2.MassFlowRate m2_flow = port_a2.m_flow "Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction)"; Modelica.SIunits.PressureDifference dp2(displayUnit="Pa") = port_a2.p - port_b2.p "Pressure difference between port_a2 and port_b2"; Medium1.ThermodynamicState sta_a1= Medium1.setState_phX(port_a1.p, noEvent(actualStream(port_a1.h_outflow)), noEvent(actualStream(port_a1.Xi_outflow))) if show_T "Medium properties in port_a1"; Medium1.ThermodynamicState sta_b1= Medium1.setState_phX(port_b1.p, noEvent(actualStream(port_b1.h_outflow)), noEvent(actualStream(port_b1.Xi_outflow))) if show_T "Medium properties in port_b1"; Medium2.ThermodynamicState sta_a2= Medium2.setState_phX(port_a2.p, noEvent(actualStream(port_a2.h_outflow)), noEvent(actualStream(port_a2.Xi_outflow))) if show_T "Medium properties in port_a2"; Medium2.ThermodynamicState sta_b2= Medium2.setState_phX(port_b2.p, noEvent(actualStream(port_b2.h_outflow)), noEvent(actualStream(port_b2.Xi_outflow))) if show_T "Medium properties in port_b2"; protected Medium1.ThermodynamicState state_a1_inflow= Medium1.setState_phX(port_a1.p, inStream(port_a1.h_outflow), inStream(port_a1.Xi_outflow)) "state for medium inflowing through port_a1"; Medium1.ThermodynamicState state_b1_inflow= Medium1.setState_phX(port_b1.p, inStream(port_b1.h_outflow), inStream(port_b1.Xi_outflow)) "state for medium inflowing through port_b1"; Medium2.ThermodynamicState state_a2_inflow= Medium2.setState_phX(port_a2.p, inStream(port_a2.h_outflow), inStream(port_a2.Xi_outflow)) "state for medium inflowing through port_a2"; Medium2.ThermodynamicState state_b2_inflow= Medium2.setState_phX(port_b2.p, inStream(port_b2.h_outflow), inStream(port_b2.Xi_outflow)) "state for medium inflowing through port_b2"; end PartialFourPortInterface;

Buildings.Fluid.Interfaces.PartialFourPortParallel Buildings.Fluid.Interfaces.PartialFourPortParallel

Partial model with four ports for components with parallel flow

Buildings.Fluid.Interfaces.PartialFourPortParallel

Information

This model defines an interface for components with four ports in which flows occur in parallel. The parameters allowFlowReversal1 and allowFlowReversal2 may be used by models that extend this model to treat flow reversal.

This model is identical to Modelica.Fluid.Interfaces.PartialTwoPort, except for the following:

  1. it has four ports, and
  2. the parameter showDesignFlowDirection is not implemented.

Parameters

TypeNameDefaultDescription
replaceable package Medium1Modelica.Media.Interfaces.Pa...Medium 1 in the component
replaceable package Medium2Modelica.Media.Interfaces.Pa...Medium 2 in the component
Assumptions
BooleanallowFlowReversal1true= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)
BooleanallowFlowReversal2true= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)

Connectors

TypeNameDescription
replaceable package Medium1Medium 1 in the component
replaceable package Medium2Medium 2 in the component
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)

Modelica definition

partial model PartialFourPortParallel "Partial model with four ports for components with parallel flow" replaceable package Medium1 = Modelica.Media.Interfaces.PartialMedium "Medium 1 in the component"; replaceable package Medium2 = Modelica.Media.Interfaces.PartialMedium "Medium 2 in the component"; parameter Boolean allowFlowReversal1 = true "= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)"; parameter Boolean allowFlowReversal2 = true "= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)"; Modelica.Fluid.Interfaces.FluidPort_a port_a1( redeclare final package Medium = Medium1, m_flow(min=if allowFlowReversal1 then -Modelica.Constants.inf else 0), h_outflow(start = Medium1.h_default, nominal = Medium1.h_default)) "Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_b port_b1( redeclare final package Medium = Medium1, m_flow(max=if allowFlowReversal1 then +Modelica.Constants.inf else 0), h_outflow(start = Medium1.h_default, nominal = Medium1.h_default)) "Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_a port_a2( redeclare final package Medium = Medium2, m_flow(min=if allowFlowReversal2 then -Modelica.Constants.inf else 0), h_outflow(start = Medium2.h_default, nominal = Medium2.h_default)) "Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)"; Modelica.Fluid.Interfaces.FluidPort_b port_b2( redeclare final package Medium = Medium2, m_flow(max=if allowFlowReversal2 then +Modelica.Constants.inf else 0), h_outflow(start = Medium2.h_default, nominal = Medium2.h_default)) "Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)"; end PartialFourPortParallel;

Buildings.Fluid.Interfaces.PartialTwoPort Buildings.Fluid.Interfaces.PartialTwoPort

Partial component with two ports

Buildings.Fluid.Interfaces.PartialTwoPort

Information

This partial model defines an interface for components with two ports. The treatment of the design flow direction and of flow reversal are predefined based on the parameter allowFlowReversal. The component may transport fluid and may have internal storage for a given fluid Medium.

Implementation

This model is similar to Modelica.Fluid.Interfaces.PartialTwoPort but it does not use the outer system declaration. This declaration is omitted as in building energy simulation, many models use multiple media, an in practice, users have not used this global definition to assign parameters.

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the component
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to port_b)
FluidPort_bport_bFluid connector b (positive design flow direction is from port_a to port_b)

Modelica definition

partial model PartialTwoPort "Partial component with two ports" replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; parameter Boolean allowFlowReversal = true "= false to simplify equations, assuming, but not enforcing, no flow reversal"; Modelica.Fluid.Interfaces.FluidPort_a port_a( redeclare final package Medium = Medium, m_flow(min=if allowFlowReversal then -Modelica.Constants.inf else 0), h_outflow(start = Medium.h_default, nominal = Medium.h_default)) "Fluid connector a (positive design flow direction is from port_a to port_b)"; Modelica.Fluid.Interfaces.FluidPort_b port_b( redeclare final package Medium = Medium, m_flow(max=if allowFlowReversal then +Modelica.Constants.inf else 0), h_outflow(start = Medium.h_default, nominal = Medium.h_default)) "Fluid connector b (positive design flow direction is from port_a to port_b)"; end PartialTwoPort;

Buildings.Fluid.Interfaces.PartialTwoPortInterface Buildings.Fluid.Interfaces.PartialTwoPortInterface

Partial model transporting fluid between two ports without storing mass or energy

Buildings.Fluid.Interfaces.PartialTwoPortInterface

Information

This component defines the interface for models that transports a fluid between two ports. It is similar to Modelica.Fluid.Interfaces.PartialTwoPortTransport, but it does not include the species balance

  port_b.Xi_outflow = inStream(port_a.Xi_outflow);

Thus, it can be used as a base class for a heat and mass transfer component

The model is used by other models in this package that add heat transfer, mass transfer and pressure drop equations. See for example Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger.

Extends from Buildings.Fluid.Interfaces.PartialTwoPort (Partial component with two ports).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed

Modelica definition

partial model PartialTwoPortInterface "Partial model transporting fluid between two ports without storing mass or energy" extends Buildings.Fluid.Interfaces.PartialTwoPort( port_a(p(start=Medium.p_default)), port_b(p(start=Medium.p_default))); parameter Modelica.SIunits.MassFlowRate m_flow_nominal "Nominal mass flow rate"; parameter Modelica.SIunits.MassFlowRate m_flow_small(min=0) = 1E-4*abs(m_flow_nominal) "Small mass flow rate for regularization of zero flow"; // Diagnostics parameter Boolean show_T = false "= true, if actual temperature at port is computed"; Modelica.SIunits.MassFlowRate m_flow(start=_m_flow_start) = port_a.m_flow "Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction)"; Modelica.SIunits.PressureDifference dp(start=_dp_start, displayUnit="Pa") = port_a.p - port_b.p "Pressure difference between port_a and port_b"; Medium.ThermodynamicState sta_a= Medium.setState_phX(port_a.p, noEvent(actualStream(port_a.h_outflow)), noEvent(actualStream(port_a.Xi_outflow))) if show_T "Medium properties in port_a"; Medium.ThermodynamicState sta_b= Medium.setState_phX(port_b.p, noEvent(actualStream(port_b.h_outflow)), noEvent(actualStream(port_b.Xi_outflow))) if show_T "Medium properties in port_b"; protected final parameter Modelica.SIunits.MassFlowRate _m_flow_start = 0 "Start value for m_flow, used to avoid a warning if not set in m_flow, and to avoid m_flow.start in parameter window"; final parameter Modelica.SIunits.PressureDifference _dp_start(displayUnit="Pa") = 0 "Start value for dp, used to avoid a warning if not set in dp, and to avoid dp.start in parameter window"; end PartialTwoPortInterface;

Buildings.Fluid.Interfaces.PartialTwoPortTransport Buildings.Fluid.Interfaces.PartialTwoPortTransport

Partial element transporting fluid between two ports without storage of mass or energy

Buildings.Fluid.Interfaces.PartialTwoPortTransport

Information

This component transports fluid between its two ports, without storing mass or energy. Energy may be exchanged with the environment though, e.g., in the form of work. PartialTwoPortTransport is intended as base class for devices like orifices, valves and simple fluid machines.

Three equations need to be added by an extending class using this component:

Moreover appropriate values shall be assigned to the following parameters:

Implementation

This is similar to Modelica.Fluid.Interfaces.PartialTwoPortTransport except that it does not use the outer system declaration. This declaration is omitted as in building energy simulation, many models use multiple media, an in practice, users have not used this global definition to assign parameters.

Extends from Buildings.Fluid.Interfaces.PartialTwoPort (Partial component with two ports).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal
Advanced
PressureDifferencedp_start0Guess value of dp = port_a.p - port_b.p [Pa]
MassFlowRatem_flow_start0Guess value of m_flow = port_a.m_flow [kg/s]
MassFlowRatem_flow_small Small mass flow rate for regularization of zero flow [kg/s]
Diagnostics
Booleanshow_Ttrue= true, if temperatures at port_a and port_b are computed
Booleanshow_V_flowtrue= true, if volume flow rate at inflowing port is computed

Connectors

TypeNameDescription
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to port_b)
FluidPort_bport_bFluid connector b (positive design flow direction is from port_a to port_b)

Modelica definition

partial model PartialTwoPortTransport "Partial element transporting fluid between two ports without storage of mass or energy" extends Buildings.Fluid.Interfaces.PartialTwoPort; // Advanced // Note: value of dp_start shall be refined by derived model, // based on local dp_nominal parameter Modelica.SIunits.PressureDifference dp_start(displayUnit="Pa") = 0 "Guess value of dp = port_a.p - port_b.p"; parameter Medium.MassFlowRate m_flow_start = 0 "Guess value of m_flow = port_a.m_flow"; // Note: value of m_flow_small shall be refined by derived model, // based on local m_flow_nominal parameter Medium.MassFlowRate m_flow_small "Small mass flow rate for regularization of zero flow"; // Diagnostics parameter Boolean show_T = true "= true, if temperatures at port_a and port_b are computed"; parameter Boolean show_V_flow = true "= true, if volume flow rate at inflowing port is computed"; // Variables Medium.MassFlowRate m_flow( min=if allowFlowReversal then -Modelica.Constants.inf else 0, start = m_flow_start) "Mass flow rate in design flow direction"; Modelica.SIunits.PressureDifference dp(start=dp_start, displayUnit="Pa") "Pressure difference between port_a and port_b (= port_a.p - port_b.p)"; Modelica.SIunits.VolumeFlowRate V_flow= m_flow/Modelica.Fluid.Utilities.regStep(m_flow, Medium.density( Medium.setState_phX( p = port_a.p, h = inStream(port_a.h_outflow), X = inStream(port_a.Xi_outflow))), Medium.density( Medium.setState_phX( p = port_b.p, h = inStream(port_b.h_outflow), X = inStream(port_b.Xi_outflow))), m_flow_small) if show_V_flow "Volume flow rate at inflowing port (positive when flow from port_a to port_b)"; Medium.Temperature port_a_T= Modelica.Fluid.Utilities.regStep(port_a.m_flow, Medium.temperature( Medium.setState_phX( p = port_a.p, h = inStream(port_a.h_outflow), X = inStream(port_a.Xi_outflow))), Medium.temperature(Medium.setState_phX(port_a.p, port_a.h_outflow, port_a.Xi_outflow)), m_flow_small) if show_T "Temperature close to port_a, if show_T = true"; Medium.Temperature port_b_T= Modelica.Fluid.Utilities.regStep(port_b.m_flow, Medium.temperature( Medium.setState_phX( p = port_b.p, h = inStream(port_b.h_outflow), X = inStream(port_b.Xi_outflow))), Medium.temperature(Medium.setState_phX(port_b.p, port_b.h_outflow, port_b.Xi_outflow)), m_flow_small) if show_T "Temperature close to port_b, if show_T = true"; equation // Pressure drop in design flow direction dp = port_a.p - port_b.p; // Design direction of mass flow rate m_flow = port_a.m_flow; assert(m_flow > -m_flow_small or allowFlowReversal, "Reverting flow occurs even though allowFlowReversal is false"); // Mass balance (no storage) port_a.m_flow + port_b.m_flow = 0; // Transport of substances port_a.Xi_outflow = if allowFlowReversal then inStream(port_b.Xi_outflow) else Medium.X_default[1:Medium.nXi]; port_b.Xi_outflow = inStream(port_a.Xi_outflow); port_a.C_outflow = if allowFlowReversal then inStream(port_b.C_outflow) else zeros(Medium.nC); port_b.C_outflow = inStream(port_a.C_outflow); end PartialTwoPortTransport;

Buildings.Fluid.Interfaces.PartialTwoPortVector Buildings.Fluid.Interfaces.PartialTwoPortVector

Partial component with two ports, one of which being vectorized

Buildings.Fluid.Interfaces.PartialTwoPortVector

Information

This partial model defines an interface for components with two ports, of which one is vectorized.

The treatment of the design flow direction and of flow reversal are determined based on the parameter allowFlowReversal. The component may transport fluid and may have internal storage.

Implementation

This model is similar to Modelica.Fluid.Interfaces.PartialTwoPort but it does not use the outer system declaration. This declaration is omitted as in building energy simulation, many models use multiple media, and in practice, users have not used this global definition to assign parameters.

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the component
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (port_a -> port_b)
Advanced
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to ports_b)
FluidPorts_bports_b[nPorts]Fluid connectors b (positive design flow direction is from port_a to ports_b)

Modelica definition

partial model PartialTwoPortVector "Partial component with two ports, one of which being vectorized" replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; parameter Integer nPorts "Number of ports"; parameter Boolean allowFlowReversal=true "= true to allow flow reversal, false restricts to design direction (port_a -> port_b)"; Modelica.Fluid.Interfaces.FluidPort_a port_a( redeclare final package Medium = Medium, m_flow(min=if allowFlowReversal then -Modelica.Constants.inf else 0), h_outflow(start=Medium.h_default, nominal=Medium.h_default)) "Fluid connector a (positive design flow direction is from port_a to ports_b)"; Modelica.Fluid.Interfaces.FluidPorts_b ports_b[nPorts]( redeclare each package Medium = Medium, each m_flow(max=if allowFlowReversal then +Modelica.Constants.inf else 0), each h_outflow(start=Medium.h_default, nominal=Medium.h_default)) "Fluid connectors b (positive design flow direction is from port_a to ports_b)"; // Diagnostics parameter Boolean show_T = false "= true, if actual temperature at port is computed"; Medium.ThermodynamicState sta_a= Medium.setState_phX(port_a.p, noEvent(actualStream(port_a.h_outflow)), noEvent(actualStream(port_a.Xi_outflow))) if show_T "Medium properties in port_a"; Medium.ThermodynamicState sta_b[nPorts]= Medium.setState_phX(ports_b.p, noEvent(actualStream(ports_b.h_outflow)), noEvent(actualStream(ports_b.Xi_outflow))) if show_T "Medium properties in ports_b"; end PartialTwoPortVector;

Buildings.Fluid.Interfaces.PrescribedOutlet Buildings.Fluid.Interfaces.PrescribedOutlet

Component that assigns the outlet fluid property at port_a based on an input signal

Buildings.Fluid.Interfaces.PrescribedOutlet

Information

This model sets the temperature or the water vapor mass fraction of the medium that leaves port_a to the value given by the input TSet or X_wSet, subject to optional limitations on the capacity for heating and cooling, or limitations on the humidification or dehumidification moisture mass flow rate. Also, optionally the model allows to take into account first order dynamics.

If the parameters energyDynamics or massDynamics are not equal to Modelica.Fluid.Types.Dynamics.SteadyState, the component models the dynamic response using a first order differential equation. The time constant of the component is equal to the parameter tau. This time constant is adjusted based on the mass flow rate using

τeff = τ |ṁ| ⁄ ṁnom

where τeff is the effective time constant for the given mass flow rate and τ is the time constant at the nominal mass flow rate nom. This type of dynamics is equal to the dynamics that a completely mixed control volume would have.

This model has no pressure drop. See Buildings.Fluid.HeatExchangers.PrescribedOutlet for a model that instantiates this model and that has a pressure drop.

In case of reverse flow, the fluid that leaves port_a has the same properties as the fluid that enters port_b.

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
HeatFlowRateQMax_flowModelica.Constants.infMaximum heat flow rate for heating (positive) [W]
HeatFlowRateQMin_flow-Modelica.Constants.infMaximum heat flow rate for cooling (negative) [W]
MassFlowRatemWatMax_flowModelica.Constants.infMaximum water mass flow rate addition (positive) [kg/s]
MassFlowRatemWatMin_flow-Modelica.Constants.infMaximum water mass flow rate removal (negative) [kg/s]
Booleanuse_TSettrueSet to false to disable temperature set point
Booleanuse_X_wSettrueSet to false to disable water vapor set point
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed
Dynamics
Timetau10Time constant at nominal flow rate (used if energyDynamics or massDynamics not equal Modelica.Fluid.Types.Dynamics.SteadyState) [s]
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Type of energy balance: dynamic (3 initialization options) or steady state
DynamicsmassDynamicsenergyDynamicsType of mass balance: dynamic (3 initialization options) or steady state
Initialization
TemperatureT_startMedium.T_defaultStart value of temperature [K]
MassFractionX_start[Medium.nX]Medium.X_defaultStart value of mass fractions m_i/m [1]

Connectors

TypeNameDescription
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to port_b)
FluidPort_bport_bFluid connector b (positive design flow direction is from port_a to port_b)
input RealInputTSetSet point temperature of the fluid that leaves port_b [K]
input RealInputX_wSetSet point for water vapor mass fraction of the fluid that leaves port_b [1]
output RealOutputQ_flowHeat flow rate added to the fluid (if flow is from port_a to port_b) [W]
output RealOutputmWat_flowWater vapor mass flow rate added to the fluid (if flow is from port_a to port_b) [kg/s]

Modelica definition

model PrescribedOutlet "Component that assigns the outlet fluid property at port_a based on an input signal" extends Buildings.Fluid.Interfaces.PartialTwoPortInterface; parameter Modelica.SIunits.HeatFlowRate QMax_flow(min=0) = Modelica.Constants.inf "Maximum heat flow rate for heating (positive)"; parameter Modelica.SIunits.HeatFlowRate QMin_flow(max=0) = -Modelica.Constants.inf "Maximum heat flow rate for cooling (negative)"; parameter Modelica.SIunits.MassFlowRate mWatMax_flow(min=0) = Modelica.Constants.inf "Maximum water mass flow rate addition (positive)"; parameter Modelica.SIunits.MassFlowRate mWatMin_flow(max=0) = -Modelica.Constants.inf "Maximum water mass flow rate removal (negative)"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal "Nominal mass flow rate, used for regularization near zero flow"; parameter Modelica.SIunits.Time tau(min=0) = 10 "Time constant at nominal flow rate (used if energyDynamics or massDynamics not equal Modelica.Fluid.Types.Dynamics.SteadyState)"; parameter Modelica.SIunits.Temperature T_start=Medium.T_default "Start value of temperature"; parameter Modelica.SIunits.MassFraction X_start[Medium.nX] = Medium.X_default "Start value of mass fractions m_i/m"; // Dynamics parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState "Type of energy balance: dynamic (3 initialization options) or steady state"; parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state"; parameter Boolean use_TSet = true "Set to false to disable temperature set point"; parameter Boolean use_X_wSet = true "Set to false to disable water vapor set point"; Modelica.Blocks.Interfaces.RealInput TSet(unit="K", displayUnit="degC") if use_TSet "Set point temperature of the fluid that leaves port_b"; Modelica.Blocks.Interfaces.RealInput X_wSet(unit="1") if use_X_wSet "Set point for water vapor mass fraction of the fluid that leaves port_b"; Modelica.Blocks.Interfaces.RealOutput Q_flow(unit="W") "Heat flow rate added to the fluid (if flow is from port_a to port_b)"; Modelica.Blocks.Interfaces.RealOutput mWat_flow(unit="kg/s") "Water vapor mass flow rate added to the fluid (if flow is from port_a to port_b)"; protected parameter Modelica.SIunits.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp( Medium.setState_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default)) "Specific heat capacity at default medium state"; parameter Boolean restrictHeat = QMax_flow < Modelica.Constants.inf/10.0 "Flag, true if maximum heating power is restricted"; parameter Boolean restrictCool = QMin_flow > -Modelica.Constants.inf/10.0 "Flag, true if maximum cooling power is restricted"; parameter Boolean restrictHumi = mWatMax_flow < Modelica.Constants.inf/10.0 "Flag, true if maximum humidification is restricted"; parameter Boolean restrictDehu = mWatMin_flow > -Modelica.Constants.inf/10.0 "Flag, true if maximum dehumidification is restricted"; parameter Modelica.SIunits.SpecificEnthalpy deltaH= cp_default*1E-6 "Small value for deltaH used for regularization"; parameter Modelica.SIunits.MassFraction deltaXi = 1E-6 "Small mass fraction used for regularization"; Modelica.SIunits.MassFlowRate m_flow_pos "Mass flow rate, or zero if reverse flow"; Modelica.SIunits.MassFlowRate m_flow_non_zero "Mass flow rate bounded away from zero"; Modelica.SIunits.SpecificEnthalpy hSet "Set point for enthalpy leaving port_b"; Modelica.SIunits.Temperature T "Temperature of outlet state assuming unlimited capacity and taking dynamics into account"; Modelica.SIunits.MassFraction Xi "Water vapor mass fraction of outlet state assuming unlimited capacity and taking dynamics into account"; Modelica.SIunits.MassFraction Xi_instream[Medium.nXi] "Instreaming water vapor mass fraction at port_a"; Modelica.SIunits.MassFraction Xi_outflow "Outstreaming water vapor mass fraction at port_a"; Modelica.SIunits.SpecificEnthalpy dhAct "Actual enthalpy difference from port_a to port_b"; Real dXiAct(final unit="1") "Actual mass fraction difference from port_a to port_b"; Real k(start=1) "Gain to take flow rate into account for sensor time constant"; Real mNor_flow "Normalized mass flow rate"; Modelica.Blocks.Interfaces.RealInput TSet_internal(unit="K", displayUnit="degC") "Internal connector for set point temperature of the fluid that leaves port_b"; Modelica.Blocks.Interfaces.RealInput X_wSet_internal(unit="1") "Internal connector for set point for water vapor mass fraction of the fluid that leaves port_b"; initial equation // Set initial conditions, unless use_{T,Xi}Set = false in which case // it is not a state. if use_TSet then if energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then der(T) = 0; elseif energyDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then T = T_start; end if; end if; if use_X_wSet then if massDynamics == Modelica.Fluid.Types.Dynamics.SteadyStateInitial then der(Xi) = 0; elseif massDynamics == Modelica.Fluid.Types.Dynamics.FixedInitial then Xi = X_start[1]; end if; end if; assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau > Modelica.Constants.eps, "The parameter tau, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau = " + String(tau) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau > Modelica.Constants.eps, "The parameter tau, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau = " + String(tau) + "\n"); if use_X_wSet then assert(Medium.nX > 1, "If use_X_wSet = true, require a medium with water vapor, such as Buildings.Media.Air"); end if; equation // Conditional connectors if not use_TSet then TSet_internal = 293.15; end if; connect(TSet, TSet_internal); if not use_X_wSet then X_wSet_internal = 0.01; end if; connect(X_wSet, X_wSet_internal); if (use_TSet and energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or (use_X_wSet and massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) then mNor_flow = port_a.m_flow/m_flow_nominal; k = Modelica.Fluid.Utilities.regStep(x=port_a.m_flow, y1= mNor_flow, y2=-mNor_flow, x_small=m_flow_small); else mNor_flow = 1; k = 1; end if; if use_TSet and energyDynamics <> Modelica.Fluid.Types.Dynamics.SteadyState then der(T) = (TSet_internal-T)*k/tau; else T = TSet_internal; end if; if use_X_wSet and massDynamics <> Modelica.Fluid.Types.Dynamics.SteadyState then der(Xi) = (X_wSet_internal-Xi)*k/tau; else Xi = X_wSet_internal; end if; Xi_instream = inStream(port_a.Xi_outflow); // Set point without any capacity limitation hSet = if use_TSet then Medium.specificEnthalpy( Medium.setState_pTX( p = port_a.p, T = T, X = Xi_instream + fill(dXiAct, Medium.nXi))) else Medium.h_default; m_flow_pos = Buildings.Utilities.Math.Functions.smoothMax( x1=m_flow, x2=0, deltaX=m_flow_small); if not restrictHeat and not restrictCool and not restrictHumi and not restrictDehu then m_flow_non_zero = Modelica.Constants.eps; else m_flow_non_zero = Buildings.Utilities.Math.Functions.smoothMax( x1 = port_a.m_flow, x2 = m_flow_small, deltaX=m_flow_small/2); end if; // Compute mass fraction leaving the component. // Below, we use sum(Xi_instream) as Xi anyway has only one element. // However, scalar(Xi_instream) would not work as dim(Xi_instream) = 0 // if the medium is not a mixture. // Note that the computations for the mass fraction and for the // enthalpy change are identical. In a development version, they were // put in a function, but this led to large nonlinear systems of equations. if use_X_wSet then if not restrictHumi and not restrictDehu then // No capacity limit dXiAct = Xi_outflow-sum(Xi_instream); Xi_outflow = Xi; mWat_flow = m_flow_pos*(Xi - sum(Xi_instream)); else if restrictHumi and restrictDehu then // Capacity limits for heating and cooling dXiAct =Buildings.Utilities.Math.Functions.smoothLimit( x=Xi - sum(Xi_instream), l=mWatMin_flow/m_flow_non_zero, u=mWatMax_flow/m_flow_non_zero, deltaX=deltaXi); elseif restrictHumi then // Capacity limit for heating only dXiAct =Buildings.Utilities.Math.Functions.smoothMin( x1=Xi - sum(Xi_instream), x2=mWatMax_flow/m_flow_non_zero, deltaX=deltaXi); else // Capacity limit for cooling only dXiAct =Buildings.Utilities.Math.Functions.smoothMax( x1=Xi - sum(Xi_instream), x2=mWatMin_flow/m_flow_non_zero, deltaX=deltaXi); end if; Xi_outflow = sum(Xi_instream) + dXiAct; mWat_flow = m_flow_pos*dXiAct; end if; port_b.Xi_outflow = fill(Xi_outflow, Medium.nXi); else Xi_outflow = sum(Xi_instream); mWat_flow = 0; dXiAct = 0; port_b.Xi_outflow = Xi_instream; end if; // Compute enthalpy leaving the component. if use_TSet then if not restrictHeat and not restrictCool then // No capacity limit dhAct = 0; port_b.h_outflow = hSet; Q_flow = m_flow_pos*(hSet - inStream(port_a.h_outflow)); else if restrictHeat and restrictCool then // Capacity limits for heating and cooling dhAct =Buildings.Utilities.Math.Functions.smoothLimit( x=hSet - inStream(port_a.h_outflow), l=QMin_flow/m_flow_non_zero, u=QMax_flow/m_flow_non_zero, deltaX=deltaH); elseif restrictHeat then // Capacity limit for heating only dhAct =Buildings.Utilities.Math.Functions.smoothMin( x1=hSet - inStream(port_a.h_outflow), x2=QMax_flow/m_flow_non_zero, deltaX=deltaH); else // Capacity limit for cooling only dhAct =Buildings.Utilities.Math.Functions.smoothMax( x1=hSet - inStream(port_a.h_outflow), x2=QMin_flow/m_flow_non_zero, deltaX=deltaH); end if; port_b.h_outflow = inStream(port_a.h_outflow) + dhAct; Q_flow = m_flow_pos*dhAct; end if; else port_b.h_outflow = inStream(port_a.h_outflow); Q_flow = 0; dhAct = 0; end if; // Outflowing property at port_a is unaffected by this model. if allowFlowReversal then port_a.h_outflow = inStream(port_b.h_outflow); port_a.Xi_outflow = inStream(port_b.Xi_outflow); port_a.C_outflow = inStream(port_b.C_outflow); else port_a.h_outflow = Medium.h_default; port_a.Xi_outflow = Medium.X_default[1:Medium.nXi]; port_a.C_outflow = zeros(Medium.nC); end if; // No pressure drop dp = 0; // Mass balance (no storage) port_a.m_flow + port_b.m_flow = 0; // Transport of substances port_b.C_outflow = inStream(port_a.C_outflow); if not allowFlowReversal then assert(m_flow > -m_flow_small, "Reverting flow occurs even though allowFlowReversal is false"); end if; end PrescribedOutlet;

Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger

Partial model transporting two fluid streams between four ports without storing mass or energy

Buildings.Fluid.Interfaces.StaticFourPortHeatMassExchanger

Information

This component transports two fluid streams between four ports, without storing mass or energy. It is similar to Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger, but it has four ports instead of two.

If dpN_nominal > Modelica.Constants.eps, where N denotes the fluid 1 or 2, then the model computes pressure drop due to flow friction in the respective fluid stream. The pressure drop is defined by a quadratic function that goes through the point (mN_flow_nominal, dpN_nominal). At |mN_flow| < deltaMN * mN_flow_nominal, the pressure drop vs. flow relation is linearized. If the parameter linearizeFlowResistanceN is set to true, then the whole pressure drop vs. flow resistance curve is linearized.

Implementation

This model uses inputs and constants that need to be set by models that extend or instantiate this model. The following inputs need to be assigned, where N denotes 1 or 2:

Set the constant sensibleOnlyN=true if the model that extends or instantiates this model sets mWatN_flow = 0.

Note that the model does not implement 0 = Q1_flow + Q2_flow or 0 = mXi1_flow + mXi2_flow. If there is no heat or mass transfer with the environment, then a model that extends this model needs to provide these equations.

Extends from Buildings.Fluid.Interfaces.PartialFourPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters (Parameters for flow resistance for models with four ports).

Parameters

TypeNameDefaultDescription
replaceable package Medium1PartialMediumMedium 1 in the component
replaceable package Medium2PartialMediumMedium 2 in the component
BooleansensibleOnly1 Set to true if sensible exchange only for medium 1
BooleansensibleOnly2 Set to true if sensible exchange only for medium 2
Nominal condition
MassFlowRatem1_flow_nominal Nominal mass flow rate [kg/s]
MassFlowRatem2_flow_nominal Nominal mass flow rate [kg/s]
PressureDifferencedp1_nominal Pressure difference [Pa]
PressureDifferencedp2_nominal Pressure difference [Pa]
Assumptions
BooleanallowFlowReversal1true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 1
BooleanallowFlowReversal2true= false to simplify equations, assuming, but not enforcing, no flow reversal for medium 2
Advanced
MassFlowRatem1_flow_small1E-4*abs(m1_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
MassFlowRatem2_flow_small1E-4*abs(m2_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed
Flow resistance
Medium 1
BooleancomputeFlowResistance1(dp1_nominal > Modelica.Cons...=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2(dp2_nominal > Modelica.Cons...=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar

Connectors

TypeNameDescription
FluidPort_aport_a1Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_bport_b1Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)
FluidPort_aport_a2Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)
FluidPort_bport_b2Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)

Modelica definition

model StaticFourPortHeatMassExchanger "Partial model transporting two fluid streams between four ports without storing mass or energy" extends Buildings.Fluid.Interfaces.PartialFourPortInterface; extends Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters( final computeFlowResistance1=(dp1_nominal > Modelica.Constants.eps), final computeFlowResistance2=(dp2_nominal > Modelica.Constants.eps)); constant Boolean prescribedHeatFlowRate1 = false "Set to true if the heat flow rate into fluid 1 is not a function of the component temperature"; constant Boolean prescribedHeatFlowRate2 = false "Set to true if the heat flow rate into fluid 2 is not a function of the component temperature"; parameter Boolean homotopyInitialization = true "= true, use homotopy method"; // Q1_flow is sensible plus latent heat flow rate input Modelica.SIunits.HeatFlowRate Q1_flow "Heat transferred into the medium 1"; input Medium1.MassFlowRate mWat1_flow "Moisture mass flow rate added to the medium 1"; // Q2_flow is sensible plus latent heat flow rate input Modelica.SIunits.HeatFlowRate Q2_flow "Heat transferred into the medium 2"; input Medium2.MassFlowRate mWat2_flow "Moisture mass flow rate added to the medium 2"; constant Boolean sensibleOnly1 "Set to true if sensible exchange only for medium 1"; constant Boolean sensibleOnly2 "Set to true if sensible exchange only for medium 2"; protected Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger bal1( redeclare final package Medium=Medium1, final sensibleOnly = sensibleOnly1, final prescribedHeatFlowRate=prescribedHeatFlowRate1, final m_flow_nominal = m1_flow_nominal, final dp_nominal = dp1_nominal, final allowFlowReversal = allowFlowReversal1, final m_flow_small = m1_flow_small, final homotopyInitialization = homotopyInitialization, final from_dp = from_dp1, final linearizeFlowResistance = linearizeFlowResistance1, final deltaM = deltaM1, final Q_flow = Q1_flow, final mWat_flow = mWat1_flow) "Model for heat, mass, species, trace substance and pressure balance of stream 1"; Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger bal2( redeclare final package Medium=Medium2, final sensibleOnly = sensibleOnly2, final prescribedHeatFlowRate=prescribedHeatFlowRate2, final m_flow_nominal = m2_flow_nominal, final dp_nominal = dp2_nominal, final allowFlowReversal = allowFlowReversal2, final m_flow_small = m2_flow_small, final homotopyInitialization = homotopyInitialization, final from_dp = from_dp2, final linearizeFlowResistance = linearizeFlowResistance2, final deltaM = deltaM2, final Q_flow = Q2_flow, final mWat_flow = mWat2_flow) "Model for heat, mass, species, trace substance and pressure balance of stream 2"; equation connect(bal1.port_a, port_a1); connect(bal1.port_b, port_b1); connect(bal2.port_a, port_a2); connect(bal2.port_b, port_b2); end StaticFourPortHeatMassExchanger;

Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation

Partial model for static energy and mass conservation equations

Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation

Information

This model transports fluid between its two ports, without storing mass or energy. It implements a steady-state conservation equation for energy and mass fractions. The model has zero pressure drop between its ports.

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.

To increase the numerical robustness of the model, the constant prescribedHeatFlowRate can be set. Use the following settings:

If prescribedHeatFlow=true, then energy and mass balance equations are formulated to guard against numerical problems near zero flow that can occur if Q_flow or m_flow are the results of an iterative solver.

Implementation

Input connectors of the model are

The model can only be used as a steady-state model with two fluid ports. For a model with a dynamic balance, and more fluid ports, use Buildings.Fluid.Interfaces.ConservationEquation.

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
Booleanuse_mWat_flowfalseSet to true to enable input connector for moisture mass flow rate
Booleanuse_C_flowfalseSet to true to enable input connector for trace substance
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed

Connectors

TypeNameDescription
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to port_b)
FluidPort_bport_bFluid connector b (positive design flow direction is from port_a to port_b)
input RealInputQ_flowSensible plus latent heat flow rate transferred into the medium [W]
input RealInputmWat_flowMoisture mass flow rate added to the medium [kg/s]
input RealInputC_flow[Medium.nC]Trace substance mass flow rate added to the medium
output RealOutputhOutLeaving specific enthalpy of the component [J/kg]
output RealOutputXiOut[Medium.nXi]Leaving species concentration of the component [1]
output RealOutputCOut[Medium.nC]Leaving trace substances of the component

Modelica definition

model StaticTwoPortConservationEquation "Partial model for static energy and mass conservation equations" extends Buildings.Fluid.Interfaces.PartialTwoPortInterface; constant 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"; constant Boolean prescribedHeatFlowRate = false "Set to true if the heat flow rate is not a function of a temperature difference to the fluid temperature"; parameter Boolean use_mWat_flow = false "Set to true to enable input connector for moisture mass flow rate"; parameter Boolean use_C_flow = false "Set to true to enable input connector for trace substance"; Modelica.Blocks.Interfaces.RealInput Q_flow(unit="W") "Sensible plus latent heat flow rate transferred into the medium"; Modelica.Blocks.Interfaces.RealInput mWat_flow(final quantity="MassFlowRate", unit="kg/s") if use_mWat_flow "Moisture mass flow rate added to the medium"; Modelica.Blocks.Interfaces.RealInput[Medium.nC] C_flow if use_C_flow "Trace substance mass flow rate added to the medium"; // Outputs that are needed in models that extend this model Modelica.Blocks.Interfaces.RealOutput hOut(unit="J/kg", start=Medium.specificEnthalpy_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default)) "Leaving specific enthalpy of the component"; Modelica.Blocks.Interfaces.RealOutput XiOut[Medium.nXi](each unit="1", each min=0, each max=1) "Leaving species concentration of the component"; Modelica.Blocks.Interfaces.RealOutput COut[Medium.nC](each min=0) "Leaving trace substances of the component"; protected final parameter Boolean use_m_flowInv= (prescribedHeatFlowRate or use_mWat_flow or use_C_flow) "Flag, true if m_flowInv is used in the model"; final parameter Real s[Medium.nXi] = {if Modelica.Utilities.Strings.isEqual(string1=Medium.substanceNames[i], string2="Water", caseSensitive=false) then 1 else 0 for i in 1:Medium.nXi} "Vector with zero everywhere except where species is"; Real m_flowInv(unit="s/kg") "Regularization of 1/m_flow of port_a"; Modelica.SIunits.MassFlowRate mXi_flow[Medium.nXi] "Mass flow rates of independent substances added to the medium"; // Parameters for inverseXRegularized. // These are assigned here for efficiency reason. // Otherwise, they would need to be computed each time // the function is invocated. final parameter Real deltaReg = m_flow_small/1E3 "Smoothing region for inverseXRegularized"; final parameter Real deltaInvReg = 1/deltaReg "Inverse value of delta for inverseXRegularized"; final parameter Real aReg = -15*deltaInvReg "Polynomial coefficient for inverseXRegularized"; final parameter Real bReg = 119*deltaInvReg^2 "Polynomial coefficient for inverseXRegularized"; final parameter Real cReg = -361*deltaInvReg^3 "Polynomial coefficient for inverseXRegularized"; final parameter Real dReg = 534*deltaInvReg^4 "Polynomial coefficient for inverseXRegularized"; final parameter Real eReg = -380*deltaInvReg^5 "Polynomial coefficient for inverseXRegularized"; final parameter Real fReg = 104*deltaInvReg^6 "Polynomial coefficient for inverseXRegularized"; final parameter Medium.ThermodynamicState state_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Medium state at default values"; // Density at medium default values, used to compute the size of control volumes final parameter Modelica.SIunits.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=state_default) "Specific heat capacity, used to verify energy conservation"; constant Modelica.SIunits.TemperatureDifference dTMax(min=1) = 200 "Maximum temperature difference across the StaticTwoPortConservationEquation"; // Conditional connectors Modelica.Blocks.Interfaces.RealInput mWat_flow_internal(unit="kg/s") "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput C_flow_internal[Medium.nC] "Needed to connect to conditional connector"; initial equation // Assert that the substance with name 'water' has been found. assert(Medium.nXi == 0 or abs(sum(s)-1) < 1e-5, "If Medium.nXi > 1, then substance 'water' must be present for one component.'" + Medium.mediumName + "'.\n" + "Check medium model."); equation // Conditional connectors connect(mWat_flow, mWat_flow_internal); if not use_mWat_flow then mWat_flow_internal = 0; end if; connect(C_flow, C_flow_internal); if not use_C_flow then C_flow_internal = zeros(Medium.nC); end if; // Species flow rate from connector mWat_flow mXi_flow = mWat_flow_internal * s; // Regularization of m_flow around the origin to avoid a division by zero // m_flowInv is only used if prescribedHeatFlowRate == true, or // if the input connectors mWat_flow or C_flow are enabled. if use_m_flowInv then m_flowInv = Buildings.Utilities.Math.Functions.inverseXRegularized( x=port_a.m_flow, delta=deltaReg, deltaInv=deltaInvReg, a=aReg, b=bReg, c=cReg, d=dReg, e=eReg, f=fReg); else // m_flowInv is not used. m_flowInv = 0; end if; if prescribedHeatFlowRate then assert(noEvent( abs(Q_flow) < dTMax*cp_default*max(m_flow_small/1E3, abs(m_flow))), "In " + getInstanceName() + ": The heat flow rate equals " + String(Q_flow) + " W and the mass flow rate equals " + String(m_flow) + " kg/s, which results in a temperature difference " + String(abs(Q_flow)/ (cp_default*max(m_flow_small/1E3, abs(m_flow)))) + " K > dTMax=" +String(dTMax) + " K. This may indicate that energy is not conserved for small mass flow rates. The implementation may require prescribedHeatFlowRate = false."); end if; if allowFlowReversal then // Formulate hOut using spliceFunction. This avoids an event iteration. // The introduced error is small because deltax=m_flow_small/1e3 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); XiOut = Buildings.Utilities.Math.Functions.regStep(y1=port_b.Xi_outflow, y2=port_a.Xi_outflow, x=port_a.m_flow, x_small=m_flow_small/1E3); COut = Buildings.Utilities.Math.Functions.regStep(y1=port_b.C_outflow, y2=port_a.C_outflow, x=port_a.m_flow, x_small=m_flow_small/1E3); else hOut = port_b.h_outflow; XiOut = port_b.Xi_outflow; COut = port_b.C_outflow; end if; ////////////////////////////////////////////////////////////////////////////////////////// // Energy balance and mass balance // Mass balance (no storage) port_a.m_flow + port_b.m_flow = if simplify_mWat_flow then 0 else -mWat_flow_internal; // Substance balance // a) forward flow if use_m_flowInv then port_b.Xi_outflow = inStream(port_a.Xi_outflow) + mXi_flow * m_flowInv; else // no water is added assert(use_mWat_flow == false, "In " + getInstanceName() + ": Wrong implementation for forward flow."); port_b.Xi_outflow = inStream(port_a.Xi_outflow); end if; // b) backward flow if allowFlowReversal then if use_m_flowInv then port_a.Xi_outflow = inStream(port_b.Xi_outflow) - mXi_flow * m_flowInv; else // no water added assert(use_mWat_flow == false, "In " + getInstanceName() + ": Wrong implementation for reverse flow."); port_a.Xi_outflow = inStream(port_b.Xi_outflow); end if; else // no flow reversal port_a.Xi_outflow = Medium.X_default[1:Medium.nXi]; end if; // Energy balance. // This equation is approximate since m_flow = port_a.m_flow is used for the mass flow rate // at both ports. Since mWat_flow_internal << m_flow, the error is small. if prescribedHeatFlowRate then port_b.h_outflow = inStream(port_a.h_outflow) + Q_flow * m_flowInv; if allowFlowReversal then port_a.h_outflow = inStream(port_b.h_outflow) - Q_flow * m_flowInv; else port_a.h_outflow = Medium.h_default; end if; else // Case with prescribedHeatFlowRate == false. // port_b.h_outflow is known and the equation needs to be solved for Q_flow. // Hence, we cannot use m_flowInv as for m_flow=0, any Q_flow would satisfiy // Q_flow * m_flowInv = 0. // The same applies for port_b.Xi_outflow and mXi_flow. port_a.m_flow * (inStream(port_a.h_outflow) - port_b.h_outflow) = -Q_flow; if allowFlowReversal then port_a.m_flow * (inStream(port_b.h_outflow) - port_a.h_outflow) = +Q_flow; else // When allowFlowReversal = false, the downstream enthalpy does not matter. // Therefore a dummy value is used to avoid algebraic loops port_a.h_outflow = Medium.h_default; end if; end if; // Transport of trace substances if use_m_flowInv and use_C_flow then port_b.C_outflow = inStream(port_a.C_outflow) + C_flow_internal * m_flowInv; else // no trace substance added. assert(not use_C_flow, "In " + getInstanceName() + ": Wrong implementation of trace substance balance for forward flow."); port_b.C_outflow = inStream(port_a.C_outflow); end if; if allowFlowReversal then if use_C_flow then port_a.C_outflow = inStream(port_b.C_outflow) - C_flow_internal * m_flowInv; else port_a.C_outflow = inStream(port_b.C_outflow); end if; else port_a.C_outflow = zeros(Medium.nC); end if; //////////////////////////////////////////////////////////////////////////// // No pressure drop in this model port_a.p = port_b.p; end StaticTwoPortConservationEquation;

Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger

Partial model transporting fluid between two ports without storing mass or energy

Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger

Information

This component transports fluid between its two ports, without storing mass or energy. It is based on Modelica.Fluid.Interfaces.PartialTwoPortTransport but it does use a different implementation for handling reverse flow because in this component, mass flow rate can be added or removed from the medium.

If dp_nominal > Modelica.Constants.eps, this component computes pressure drop due to flow friction. The pressure drop is defined by a quadratic function that goes through the point (m_flow_nominal, dp_nominal). At |m_flow| < deltaM * m_flow_nominal, the pressure drop vs. flow relation is linearized. If the parameter linearizeFlowResistance is set to true, then the whole pressure drop vs. flow resistance curve is linearized.

Implementation

This model uses inputs and constants that need to be set by models that extend or instantiate this model. The following inputs need to be assigned:

Set the constant sensibleOnly=true if the model that extends or instantiates this model sets mWat_flow = 0.

To increase the numerical robustness of the model, the constant prescribedHeatFlowRate can be set. Use the following settings:

If prescribedHeatFlow=true, then energy and mass balance equations are formulated to guard against numerical problems near zero flow that can occur if Q_flow or m_flow are the results of an iterative solver.

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters (Parameters for flow resistance for models with two ports).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
BooleansensibleOnly Set to true if sensible exchange only
BooleanprescribedHeatFlowRate Set to true if the heat flow rate is not a function of the component temperature
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
PressureDifferencedp_nominal Pressure difference [Pa]
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed
Flow resistance
BooleancomputeFlowResistance(abs(dp_nominal) > Modelica....=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistancefalse= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM0.1Fraction of nominal flow rate where flow transitions to laminar

Connectors

TypeNameDescription
FluidPort_aport_aFluid connector a (positive design flow direction is from port_a to port_b)
FluidPort_bport_bFluid connector b (positive design flow direction is from port_a to port_b)
output RealOutputhOutLeaving temperature of the component [J/kg]
output RealOutputXiOut[Medium.nXi]Leaving species concentration of the component [1]
output RealOutputCOut[Medium.nC]Leaving trace substances of the component

Modelica definition

model StaticTwoPortHeatMassExchanger "Partial model transporting fluid between two ports without storing mass or energy" extends Buildings.Fluid.Interfaces.PartialTwoPortInterface; extends Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters( final computeFlowResistance=(abs(dp_nominal) > Modelica.Constants.eps)); constant Boolean sensibleOnly "Set to true if sensible exchange only"; constant Boolean prescribedHeatFlowRate "Set to true if the heat flow rate is not a function of the component temperature"; parameter Boolean homotopyInitialization = true "= true, use homotopy method"; // Model inputs // Q_flow is the sensible plus latent heat flow rate input Modelica.SIunits.HeatFlowRate Q_flow "Heat transferred into the medium"; input Modelica.SIunits.MassFlowRate mWat_flow "Moisture mass flow rate added to the medium"; // Models for conservation equations and pressure drop Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation vol( redeclare final package Medium = Medium, final use_mWat_flow = not sensibleOnly, final prescribedHeatFlowRate = prescribedHeatFlowRate, final m_flow_nominal = m_flow_nominal, final allowFlowReversal=allowFlowReversal, final m_flow_small=m_flow_small) "Control volume for steady-state energy and mass balance"; Buildings.Fluid.FixedResistances.PressureDrop preDro( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final deltaM=deltaM, final allowFlowReversal=allowFlowReversal, final show_T=false, final from_dp=from_dp, final linearized=linearizeFlowResistance, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp_nominal) "Flow resistance"; // Outputs that are needed in models that extend this model Modelica.Blocks.Interfaces.RealOutput hOut(unit="J/kg") "Leaving temperature of the component"; Modelica.Blocks.Interfaces.RealOutput XiOut[Medium.nXi](each unit="1", each min=0, each max=1) "Leaving species concentration of the component"; Modelica.Blocks.Interfaces.RealOutput COut[Medium.nC](each min=0) "Leaving trace substances of the component"; protected Modelica.Blocks.Sources.RealExpression heaInp(y=Q_flow) "Block to set heat input into volume"; Modelica.Blocks.Sources.RealExpression masExc(final y=mWat_flow) "Block to set moisture exchange in volume"; equation connect(vol.hOut, hOut); connect(vol.XiOut, XiOut); connect(vol.COut, COut); connect(port_a,preDro. port_a); connect(preDro.port_b, vol.port_a); connect(vol.port_b, port_b); connect(heaInp.y, vol.Q_flow); connect(masExc.y, vol.mWat_flow); end StaticTwoPortHeatMassExchanger;

Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger

Partial model transporting one fluid stream with storing mass or energy

Buildings.Fluid.Interfaces.TwoPortHeatMassExchanger

Information

This component transports one fluid stream. It provides the basic model for implementing dynamic and steady-state models that exchange heat and water vapor with the fluid stream. The model also computes the pressure drop due to the flow resistance. By setting the parameter dp_nominal=0, the computation of the pressure drop can be avoided. The variable vol.heatPort.T always has the value of the temperature of the medium that leaves the component. For the actual temperatures at the port, the variables sta_a.T and sta_b.T can be used. These two variables are provided by the base class Buildings.Fluid.Interfaces.PartialTwoPortInterface.

For models that extend this model, see for example

Implementation

The variable names follow the conventions used in Modelica.Fluid.Examples.HeatExchanger.BaseClasses.BasicHX .

Extends from Buildings.Fluid.Interfaces.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters (Parameters for flow resistance for models with two ports).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
MixingVolumevolredeclare Buildings.Fluid.Mi...Volume for fluid stream
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
PressureDifferencedp_nominal Pressure difference [Pa]
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal
Advanced
MassFlowRatem_flow_small1E-4*abs(m_flow_nominal)Small mass flow rate for regularization of zero flow [kg/s]
BooleanhomotopyInitializationtrue= true, use homotopy method
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed
Flow resistance
BooleancomputeFlowResistancetrue=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistancefalse= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM0.1Fraction of nominal flow rate where flow transitions to laminar
Dynamics
Nominal condition
Timetau30Time constant at nominal flow (if energyDynamics <> SteadyState) [s]
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Type of energy balance: dynamic (3 initialization options) or steady state
DynamicsmassDynamicsenergyDynamicsType of mass balance: dynamic (3 initialization options) or steady state
Initialization
AbsolutePressurep_startMedium.p_defaultStart value of pressure [Pa]
TemperatureT_startMedium.T_defaultStart value of temperature [K]
MassFractionX_start[Medium.nX]Medium.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC_start[Medium.nC]fill(0, Medium.nC)Start value of trace substances

Modelica definition

model TwoPortHeatMassExchanger "Partial model transporting one fluid stream with storing mass or energy" extends Buildings.Fluid.Interfaces.PartialTwoPortInterface( port_a(h_outflow(start=h_outflow_start)), port_b(h_outflow(start=h_outflow_start))); extends Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters( final computeFlowResistance=true); parameter Modelica.SIunits.Time tau = 30 "Time constant at nominal flow (if energyDynamics <> SteadyState)"; // Advanced parameter Boolean homotopyInitialization = true "= true, use homotopy method"; // Dynamics parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Type of energy balance: dynamic (3 initialization options) or steady state"; parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state"; // Initialization parameter Medium.AbsolutePressure p_start = Medium.p_default "Start value of pressure"; parameter Medium.Temperature T_start = Medium.T_default "Start value of temperature"; parameter Medium.MassFraction X_start[Medium.nX]( final quantity=Medium.substanceNames) = Medium.X_default "Start value of mass fractions m_i/m"; parameter Medium.ExtraProperty C_start[Medium.nC]( final quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC) "Start value of trace substances"; replaceable Buildings.Fluid.MixingVolumes.MixingVolume vol constrainedby Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolume( redeclare final package Medium = Medium, nPorts = 2, V=m_flow_nominal*tau/rho_default, final allowFlowReversal=allowFlowReversal, final mSenFac=1, final m_flow_nominal = m_flow_nominal, 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) "Volume for fluid stream"; Buildings.Fluid.FixedResistances.PressureDrop preDro( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final deltaM=deltaM, final allowFlowReversal=allowFlowReversal, final show_T=false, final from_dp=from_dp, final linearized=linearizeFlowResistance, final homotopyInitialization=homotopyInitialization, final dp_nominal=dp_nominal) "Flow resistance"; protected parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default); parameter Modelica.SIunits.Density rho_default=Medium.density(sta_default) "Density, used to compute fluid volume"; parameter Medium.ThermodynamicState sta_start=Medium.setState_pTX( T=T_start, p=p_start, X=X_start); parameter Modelica.SIunits.SpecificEnthalpy h_outflow_start = Medium.specificEnthalpy(sta_start) "Start value for outflowing enthalpy"; initial algorithm assert((energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau > Modelica.Constants.eps, "The parameter tau, or the volume of the model from which tau may be derived, is unreasonably small. You need to set energyDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau = " + String(tau) + "\n"); assert((massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState) or tau > Modelica.Constants.eps, "The parameter tau, or the volume of the model from which tau may be derived, is unreasonably small. You need to set massDynamics == Modelica.Fluid.Types.Dynamics.SteadyState to model steady-state. Received tau = " + String(tau) + "\n"); equation connect(vol.ports[2], port_b); connect(port_a, preDro.port_a); connect(preDro.port_b, vol.ports[1]); end TwoPortHeatMassExchanger;

Buildings.Fluid.Interfaces.EightPortFlowResistanceParameters

Parameters for flow resistance for models with height ports

Information

This class contains parameters that are used to compute the pressure drop in components that have four fluid streams. Note that the nominal mass flow rate is not declared here because the model PartialHeightPortInterface already declares it.

Parameters

TypeNameDefaultDescription
Nominal condition
Pressuredp1_nominaldp1_nominal( ...Pressure [Pa]
Pressuredp2_nominaldp2_nominal( ...Pressure [Pa]
Pressuredp3_nominaldp3_nominal( ...Pressure [Pa]
Pressuredp4_nominaldp4_nominal( ...Pressure [Pa]
Flow resistance
Medium 1
BooleancomputeFlowResistance1true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar
Medium 3
BooleancomputeFlowResistance3true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp3false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance3false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM30.1Fraction of nominal flow rate where flow transitions to laminar
Medium 4
BooleancomputeFlowResistance4true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp4false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance4false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM40.1Fraction of nominal flow rate where flow transitions to laminar

Modelica definition

record EightPortFlowResistanceParameters "Parameters for flow resistance for models with height ports" parameter Boolean computeFlowResistance1 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp1 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Pressure dp1_nominal(min=0, displayUnit="Pa") "Pressure"; parameter Boolean linearizeFlowResistance1 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM1 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; parameter Boolean computeFlowResistance2 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp2 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Pressure dp2_nominal(min=0, displayUnit="Pa") "Pressure"; parameter Boolean linearizeFlowResistance2 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM2 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; parameter Boolean computeFlowResistance3 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp3 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Pressure dp3_nominal(min=0, displayUnit="Pa") "Pressure"; parameter Boolean linearizeFlowResistance3 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM3 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; parameter Boolean computeFlowResistance4 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp4 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Pressure dp4_nominal(min=0, displayUnit="Pa") "Pressure"; parameter Boolean linearizeFlowResistance4 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM4 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; end EightPortFlowResistanceParameters;

Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters

Parameters for flow resistance for models with four ports

Information

This class contains parameters that are used to compute the pressure drop in components that have two fluid streams. Note that the nominal mass flow rate is not declared here because the model PartialFourPortInterface already declares it.

Parameters

TypeNameDefaultDescription
Nominal condition
PressureDifferencedp1_nominaldp1_nominal( ...Pressure difference [Pa]
PressureDifferencedp2_nominaldp2_nominal( ...Pressure difference [Pa]
Flow resistance
Medium 1
BooleancomputeFlowResistance1true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp1false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance1false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM10.1Fraction of nominal flow rate where flow transitions to laminar
Medium 2
BooleancomputeFlowResistance2true=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dp2false= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistance2false= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM20.1Fraction of nominal flow rate where flow transitions to laminar

Modelica definition

record FourPortFlowResistanceParameters "Parameters for flow resistance for models with four ports" parameter Boolean computeFlowResistance1 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp1 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.PressureDifference dp1_nominal(min=0, displayUnit="Pa") "Pressure difference"; parameter Boolean linearizeFlowResistance1 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM1 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; parameter Boolean computeFlowResistance2 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp2 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.PressureDifference dp2_nominal(min=0, displayUnit="Pa") "Pressure difference"; parameter Boolean linearizeFlowResistance2 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM2 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; end FourPortFlowResistanceParameters;

Buildings.Fluid.Interfaces.LumpedVolumeDeclarations

Declarations for lumped volumes

Information

This class contains parameters and medium properties that are used in the lumped volume model, and in models that extend the lumped volume model.

These parameters are used for example by Buildings.Fluid.Interfaces.ConservationEquation, Buildings.Fluid.MixingVolumes.MixingVolume and Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2.

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the component
Dynamics
Equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Type of energy balance: dynamic (3 initialization options) or steady state
DynamicsmassDynamicsenergyDynamicsType of mass balance: dynamic (3 initialization options) or steady state
RealmSenFac1Factor for scaling the sensible thermal mass of the volume
Initialization
AbsolutePressurep_startMedium.p_defaultStart value of pressure [Pa]
TemperatureT_startMedium.T_defaultStart value of temperature [K]
MassFractionX_start[Medium.nX]Medium.X_defaultStart value of mass fractions m_i/m [kg/kg]
ExtraPropertyC_start[Medium.nC]fill(0, Medium.nC)Start value of trace substances
ExtraPropertyC_nominal[Medium.nC]fill(1E-2, Medium.nC)Nominal value of trace substances. (Set to typical order of magnitude.)

Modelica definition

record LumpedVolumeDeclarations "Declarations for lumped volumes" replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; // Assumptions parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Type of energy balance: dynamic (3 initialization options) or steady state"; parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Type of mass balance: dynamic (3 initialization options) or steady state"; final parameter Modelica.Fluid.Types.Dynamics substanceDynamics=energyDynamics "Type of independent mass fraction balance: dynamic (3 initialization options) or steady state"; final parameter Modelica.Fluid.Types.Dynamics traceDynamics=energyDynamics "Type of trace substance balance: dynamic (3 initialization options) or steady state"; // Initialization parameter Medium.AbsolutePressure p_start = Medium.p_default "Start value of pressure"; parameter Medium.Temperature T_start=Medium.T_default "Start value of temperature"; parameter Medium.MassFraction X_start[Medium.nX]( quantity=Medium.substanceNames) = Medium.X_default "Start value of mass fractions m_i/m"; parameter Medium.ExtraProperty C_start[Medium.nC]( quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC) "Start value of trace substances"; parameter Medium.ExtraProperty C_nominal[Medium.nC]( quantity=Medium.extraPropertiesNames) = fill(1E-2, Medium.nC) "Nominal value of trace substances. (Set to typical order of magnitude.)"; parameter Real mSenFac(min=1)=1 "Factor for scaling the sensible thermal mass of the volume"; end LumpedVolumeDeclarations;

Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters

Parameters for flow resistance for models with two ports

Information

This class contains parameters that are used to compute the pressure drop in models that have one fluid stream. Note that the nominal mass flow rate is not declared here because the model PartialTwoPortInterface already declares it.

Parameters

TypeNameDefaultDescription
Nominal condition
PressureDifferencedp_nominaldp_nominal( ...Pressure difference [Pa]
Flow resistance
BooleancomputeFlowResistancetrue=true, compute flow resistance. Set to false to assume no friction
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
BooleanlinearizeFlowResistancefalse= true, use linear relation between m_flow and dp for any flow rate
RealdeltaM0.1Fraction of nominal flow rate where flow transitions to laminar

Modelica definition

record TwoPortFlowResistanceParameters "Parameters for flow resistance for models with two ports" parameter Boolean computeFlowResistance = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.PressureDifference dp_nominal(min=0, displayUnit="Pa") "Pressure difference"; parameter Boolean linearizeFlowResistance = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; end TwoPortFlowResistanceParameters;