Buildings.Fluid.Sources.BaseClasses

Package with base classes for Buildings.Fluid.Sources

Information

This package contains base classes that are used to construct the models in Buildings.Fluid.Sources.

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

Package Content

Name Description
Buildings.Fluid.Sources.BaseClasses.Outside Outside Boundary that takes weather data, and optionally trace substances, as an input
Buildings.Fluid.Sources.BaseClasses.PartialPropertySource PartialPropertySource Partial model for overriding fluid properties that flow through the component
Buildings.Fluid.Sources.BaseClasses.PartialSource PartialSource Partial component source with one fluid connector
Buildings.Fluid.Sources.BaseClasses.PartialSource_T PartialSource_T Boundary with prescribed temperature
Buildings.Fluid.Sources.BaseClasses.PartialSource_Xi_C PartialSource_Xi_C Partial component source with parameter definitions for Xi and C
Buildings.Fluid.Sources.BaseClasses.PartialSource_h PartialSource_h Boundary with prescribed enthalpy
Buildings.Fluid.Sources.BaseClasses.PartialSource_m_flow PartialSource_m_flow Partial source with prescribed flow rate
Buildings.Fluid.Sources.BaseClasses.PartialSource_p PartialSource_p Partial source with prescribed pressure

Buildings.Fluid.Sources.BaseClasses.Outside Buildings.Fluid.Sources.BaseClasses.Outside

Boundary that takes weather data, and optionally trace substances, as an input

Buildings.Fluid.Sources.BaseClasses.Outside

Information

This is the base class for models that describes boundary conditions for pressure, enthalpy, and species concentration that can be obtained from weather data, and that may be modified based on the wind pressure.

If the parameter use_C_in is false (default option), the C parameter is used as the trace substance for flow that leaves the component, and the C_in input connector is disabled; if use_C_in is true, then the C parameter is ignored, and the value provided by the input connector is used instead.

Note that boundary temperature, mass fractions and trace substances have only an effect if the mass flow is from the boundary into the port. If mass is flowing from the port into the boundary, the boundary definitions, with exception of boundary pressure, do not have an effect.

Extends from Modelica.Fluid.Sources.BaseClasses.PartialSource (Partial component source with one fluid connector).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model within the source
Booleanuse_C_infalseGet the trace substances from the input connector
ExtraPropertyC[Medium.nC]fill(0, Medium.nC)Fixed values of trace substances

Connectors

TypeNameDescription
FluidPorts_bports[nPorts] 
input RealInputC_in[Medium.nC]Prescribed boundary trace substances
BusweaBusBus with weather data

Modelica definition

partial model Outside "Boundary that takes weather data, and optionally trace substances, as an input" extends Modelica.Fluid.Sources.BaseClasses.PartialSource; parameter Boolean use_C_in = false "Get the trace substances from the input connector"; parameter Medium.ExtraProperty C[Medium.nC]( final quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC) "Fixed values of trace substances"; Modelica.Blocks.Interfaces.RealInput C_in[Medium.nC]( final quantity=Medium.extraPropertiesNames) if use_C_in "Prescribed boundary trace substances"; Buildings.BoundaryConditions.WeatherData.Bus weaBus "Bus with weather data"; protected final parameter Boolean singleSubstance = (Medium.nX == 1) "True if single substance medium"; Buildings.Utilities.Psychrometrics.X_pTphi x_pTphi if not singleSubstance "Block to compute water vapor concentration"; Modelica.Blocks.Interfaces.RealInput X_in_internal[Medium.nX]( each final unit="kg/kg", final quantity=Medium.substanceNames) "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput T_in_internal(final unit="K", displayUnit="degC") "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput p_in_internal(final unit="Pa") "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput C_in_internal[Medium.nC]( quantity=Medium.extraPropertiesNames) "Needed to connect to conditional connector"; equation // Check medium properties Modelica.Fluid.Utilities.checkBoundary(Medium.mediumName, Medium.substanceNames, Medium.singleState, true, medium.X, "Boundary_pT"); // Conditional connectors for trace substances connect(C_in, C_in_internal); if not use_C_in then C_in_internal = C; end if; // Connections to input. This is required to obtain the data from // the weather bus in case that the component x_pTphi is conditionally removed connect(weaBus.TDryBul, T_in_internal); // Connections to compute species concentration connect(p_in_internal, x_pTphi.p_in); connect(T_in_internal, x_pTphi.T); connect(weaBus.relHum, x_pTphi.phi); connect(X_in_internal, x_pTphi.X); if singleSubstance then X_in_internal = ones(Medium.nX); end if; // Assign medium properties medium.p = p_in_internal; medium.T = T_in_internal; medium.Xi = X_in_internal[1:Medium.nXi]; ports.C_outflow = fill(C_in_internal, nPorts); end Outside;

Buildings.Fluid.Sources.BaseClasses.PartialPropertySource Buildings.Fluid.Sources.BaseClasses.PartialPropertySource

Partial model for overriding fluid properties that flow through the component

Buildings.Fluid.Sources.BaseClasses.PartialPropertySource

Information

Model that changes the properties, but not the mass flow rate, of the fluid that passes through it.

Typical use and important parameters

If allowFlowReversal=true, then the properties are changed for both flow directions, i.e., from port_a to port_b and from port_b to port_a.

Dynamics

This model has no dynamics.

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

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Inputs
Booleanuse_Xi_infalseSet to true to get the composition from the input connector
Booleanuse_C_infalseSet to true to get the trace substances from the input connector
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal

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 RealInputXi_in[Medium.nXi]Prescribed values for composition
input RealInputC_in[Medium.nC]Prescribed values for trace substances

Modelica definition

partial model PartialPropertySource "Partial model for overriding fluid properties that flow through the component" extends Buildings.Fluid.Interfaces.PartialTwoPort; parameter Boolean use_Xi_in= false "Set to true to get the composition from the input connector"; parameter Boolean use_C_in= false "Set to true to get the trace substances from the input connector"; Modelica.Blocks.Interfaces.RealInput Xi_in[Medium.nXi] if use_Xi_in "Prescribed values for composition"; Modelica.Blocks.Interfaces.RealInput C_in[Medium.nC]( final quantity=Medium.extraPropertiesNames) if use_C_in "Prescribed values for trace substances"; protected Modelica.Blocks.Interfaces.RealOutput h_internal_a "Internal outlet value of port_a.h_outflow"; Modelica.Blocks.Interfaces.RealOutput h_internal_b "Internal outlet value of port_b.h_outflow"; Modelica.Blocks.Interfaces.RealOutput h_in_a = inStream(port_a.h_outflow) "Connector for inStream value of port_a.h_outflow"; Modelica.Blocks.Interfaces.RealOutput h_in_b = inStream(port_b.h_outflow) "Connector for inStream value of port_b.h_outflow"; Modelica.Blocks.Interfaces.RealOutput[Medium.nXi] Xi_internal_a "Internal outlet value of port_a.Xi_outflow"; Modelica.Blocks.Interfaces.RealOutput[Medium.nXi] Xi_internal_b "Internal outlet value of port_b.Xi_outflow"; Modelica.Blocks.Interfaces.RealOutput[Medium.nXi] Xi_in_a = inStream(port_a.Xi_outflow) "Connector for inStream value of port_a.Xi_outflow"; Modelica.Blocks.Interfaces.RealOutput[Medium.nXi] Xi_in_b = inStream(port_b.Xi_outflow) "Connector for inStream value of port_b.Xi_outflow"; Modelica.Blocks.Interfaces.RealInput[Medium.nC] C_internal_a "Internal outlet value of port_a.C_outflow"; Modelica.Blocks.Interfaces.RealInput[Medium.nC] C_internal_b "Internal outlet value of port_b.C_outflow"; Modelica.Blocks.Interfaces.RealOutput[Medium.nC] C_in_a = inStream(port_a.C_outflow) "Connector for inStream value of port_a.C_outflow"; Modelica.Blocks.Interfaces.RealOutput[Medium.nC] C_in_b = inStream(port_b.C_outflow) "Connector for inStream value of port_b.C_outflow"; equation connect(Xi_internal_a, Xi_in); connect(Xi_internal_b, Xi_in); if not (use_Xi_in) then connect(Xi_internal_a,Xi_in_b); connect(Xi_internal_b,Xi_in_a); end if; connect(C_internal_a, C_in); connect(C_internal_b, C_in); if not (use_C_in) then connect(C_internal_a,C_in_b); connect(C_internal_b,C_in_a); end if; port_a.h_outflow = if allowFlowReversal then h_internal_a else Medium.h_default; port_b.h_outflow = h_internal_b; port_a.Xi_outflow = if allowFlowReversal then Xi_internal_a else Medium.X_default[1:Medium.nXi]; port_b.Xi_outflow = Xi_internal_b; port_a.C_outflow = if allowFlowReversal then C_internal_a else zeros(Medium.nC); port_b.C_outflow = C_internal_b; port_a.p = port_b.p; port_a.m_flow + port_b.m_flow = 0; end PartialPropertySource;

Buildings.Fluid.Sources.BaseClasses.PartialSource Buildings.Fluid.Sources.BaseClasses.PartialSource

Partial component source with one fluid connector

Buildings.Fluid.Sources.BaseClasses.PartialSource

Information

Partial model for a fluid source that either prescribes pressure or mass flow rate. Models that extend this partial model need to prescribe the outflowing specific enthalpy, composition and trace substances. This partial model only declares the ports and ensures that the pressures at all ports are equal.

Implementation

If the parameter verifyInputs is set to true, then a protected instance of medium base properties is enabled. This instance verifies that the medium temperature is within the bounds T_min and T_max, where T_min and T_max are constants of the Medium. If the temperature is outside these bounds, the simulation will stop with an error.

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium model within the source
Advanced
BooleanverifyInputsfalseSet to true to stop the simulation with an error if the medium temperature is outside its allowable range

Connectors

TypeNameDescription
replaceable package MediumMedium model within the source
FluidPorts_bports[nPorts] 

Modelica definition

partial model PartialSource "Partial component source with one fluid connector" replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model within the source"; parameter Integer nPorts=0 "Number of ports"; parameter Boolean verifyInputs = false "Set to true to stop the simulation with an error if the medium temperature is outside its allowable range"; Modelica.Fluid.Interfaces.FluidPorts_b ports[nPorts]( redeclare each package Medium = Medium, m_flow(each max=if flowDirection == Modelica.Fluid.Types.PortFlowDirection.Leaving then 0 else +Modelica.Constants.inf, each min=if flowDirection == Modelica.Fluid.Types.PortFlowDirection.Entering then 0 else -Modelica.Constants.inf)); protected parameter Modelica.Fluid.Types.PortFlowDirection flowDirection=Modelica.Fluid.Types.PortFlowDirection.Bidirectional "Allowed flow direction"; Modelica.Blocks.Interfaces.RealInput p_in_internal(final unit="Pa") "Needed to connect to conditional connector"; Medium.BaseProperties medium if verifyInputs "Medium in the source"; Modelica.Blocks.Interfaces.RealInput Xi_in_internal[Medium.nXi]( each final unit = "kg/kg") "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput X_in_internal[Medium.nX]( each final unit = "kg/kg") "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput C_in_internal[Medium.nC]( final quantity=Medium.extraPropertiesNames) "Needed to connect to conditional connector"; initial equation // Only one connection allowed to a port to avoid unwanted ideal mixing for i in 1:nPorts loop assert(cardinality(ports[i]) <= 1," Each ports[i] of boundary shall at most be connected to one component. If two or more connections are present, ideal mixing takes place in these connections, which is usually not the intention of the modeller. Increase nPorts to add an additional port. "); end for; equation connect(medium.p, p_in_internal); end PartialSource;

Buildings.Fluid.Sources.BaseClasses.PartialSource_T Buildings.Fluid.Sources.BaseClasses.PartialSource_T

Boundary with prescribed temperature

Buildings.Fluid.Sources.BaseClasses.PartialSource_T

Information

Partial model that defines ports.h_outflow using an optional input for the temperature. Otherwise the parameter value is used.

Extends from Buildings.Fluid.Sources.BaseClasses.PartialSource (Partial component source with one fluid connector).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model within the source
Conditional inputs
Booleanuse_T_infalseGet the temperature from the input connector
Fixed inputs
TemperatureTMedium.T_defaultFixed value of temperature [K]
Advanced
BooleanverifyInputsfalseSet to true to stop the simulation with an error if the medium temperature is outside its allowable range

Connectors

TypeNameDescription
FluidPorts_bports[nPorts] 
input RealInputT_inPrescribed boundary temperature [K]

Modelica definition

model PartialSource_T "Boundary with prescribed temperature" extends Buildings.Fluid.Sources.BaseClasses.PartialSource; parameter Boolean use_T_in= false "Get the temperature from the input connector"; parameter Medium.Temperature T = Medium.T_default "Fixed value of temperature"; Modelica.Blocks.Interfaces.RealInput T_in(final unit="K", displayUnit="degC") if use_T_in "Prescribed boundary temperature"; protected Modelica.Blocks.Interfaces.RealInput T_in_internal(final unit="K", displayUnit="degC") "Needed to connect to conditional connector"; Modelica.Blocks.Interfaces.RealInput h_internal = Medium.specificEnthalpy(Medium.setState_pTX(p_in_internal, T_in_internal, X_in_internal)); equation connect(T_in, T_in_internal); if not use_T_in then T_in_internal = T; end if; for i in 1:nPorts loop ports[i].h_outflow = h_internal; end for; connect(medium.h, h_internal); end PartialSource_T;

Buildings.Fluid.Sources.BaseClasses.PartialSource_Xi_C Buildings.Fluid.Sources.BaseClasses.PartialSource_Xi_C

Partial component source with parameter definitions for Xi and C

Buildings.Fluid.Sources.BaseClasses.PartialSource_Xi_C

Information

Partial model that defines outflowing properties ports.Xi_outflow and ports.C_outflow using an optional input for both. Otherwise the parameter value is used.

Extends from Buildings.Fluid.Sources.BaseClasses.PartialSource (Partial component source with one fluid connector).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model within the source
Conditional inputs
Booleanuse_Xi_infalseGet the composition (independent fractions) from the input connector
Booleanuse_C_infalseGet the trace substances from the input connector
Fixed inputs
MassFractionX[Medium.nX]Medium.X_defaultFixed value of composition [kg/kg]
ExtraPropertyC[Medium.nC]fill(0, Medium.nC)Fixed values of trace substances
Advanced
BooleanverifyInputsfalseSet to true to stop the simulation with an error if the medium temperature is outside its allowable range
Booleanuse_X_infalseGet the composition (all fractions) from the input connector

Connectors

TypeNameDescription
FluidPorts_bports[nPorts] 
input RealInputX_in[Medium.nX]Prescribed boundary composition [kg/kg]
input RealInputXi_in[Medium.nXi]Prescribed boundary composition [kg/kg]
input RealInputC_in[Medium.nC]Prescribed boundary trace substances

Modelica definition

partial model PartialSource_Xi_C "Partial component source with parameter definitions for Xi and C" extends Buildings.Fluid.Sources.BaseClasses.PartialSource; parameter Boolean use_X_in = false "Get the composition (all fractions) from the input connector"; parameter Boolean use_Xi_in = false "Get the composition (independent fractions) from the input connector"; parameter Boolean use_C_in = false "Get the trace substances from the input connector"; parameter Medium.MassFraction X[Medium.nX]( final quantity=Medium.substanceNames) = Medium.X_default "Fixed value of composition"; parameter Medium.ExtraProperty C[Medium.nC]( final quantity=Medium.extraPropertiesNames) = fill(0, Medium.nC) "Fixed values of trace substances"; Modelica.Blocks.Interfaces.RealInput X_in[Medium.nX]( each final unit = "kg/kg", final quantity=Medium.substanceNames) if use_X_in "Prescribed boundary composition"; Modelica.Blocks.Interfaces.RealInput Xi_in[Medium.nXi]( each final unit = "kg/kg", final quantity=Medium.substanceNames[1:Medium.nXi]) if use_Xi_in "Prescribed boundary composition"; Modelica.Blocks.Interfaces.RealInput C_in[Medium.nC]( final quantity=Medium.extraPropertiesNames) if use_C_in "Prescribed boundary trace substances"; initial equation assert(not use_X_in or not use_Xi_in, "Cannot use both X and Xi inputs, choose either use_X_in or use_Xi_in."); if not use_X_in and not use_Xi_in then Modelica.Fluid.Utilities.checkBoundary(Medium.mediumName, Medium.substanceNames, Medium.singleState, true, X_in_internal, "Boundary_pT"); end if; equation if use_X_in or use_Xi_in then Modelica.Fluid.Utilities.checkBoundary(Medium.mediumName, Medium.substanceNames, Medium.singleState, true, X_in_internal, "Boundary_pT"); end if; connect(X_in[1:Medium.nXi], Xi_in_internal); connect(X_in,X_in_internal); connect(Xi_in, Xi_in_internal); connect(C_in, C_in_internal); connect(medium.Xi, Xi_in_internal); if not use_X_in and not use_Xi_in then Xi_in_internal = X[1:Medium.nXi]; end if; if not use_X_in then X_in_internal[1:Medium.nXi] = Xi_in_internal[1:Medium.nXi]; X_in_internal[Medium.nX] = 1-sum(X_in_internal[1:Medium.nXi]); end if; if not use_C_in then C_in_internal = C; end if; for i in 1:nPorts loop ports[i].Xi_outflow = Xi_in_internal; ports[i].C_outflow = C_in_internal; end for; end PartialSource_Xi_C;

Buildings.Fluid.Sources.BaseClasses.PartialSource_h Buildings.Fluid.Sources.BaseClasses.PartialSource_h

Boundary with prescribed enthalpy

Buildings.Fluid.Sources.BaseClasses.PartialSource_h

Information

Partial model that defines ports.h_outflow using an optional input for the specific enthalpy. Otherwise the parameter value is used.

Extends from Buildings.Fluid.Sources.BaseClasses.PartialSource (Partial component source with one fluid connector).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model within the source
Conditional inputs
Booleanuse_h_infalseGet the specific enthalpy from the input connector
Fixed inputs
SpecificEnthalpyhMedium.h_defaultFixed value of specific enthalpy [J/kg]
Advanced
BooleanverifyInputsfalseSet to true to stop the simulation with an error if the medium temperature is outside its allowable range

Connectors

TypeNameDescription
FluidPorts_bports[nPorts] 
input RealInputh_inPrescribed boundary specific enthalpy [J/kg]

Modelica definition

model PartialSource_h "Boundary with prescribed enthalpy" extends Buildings.Fluid.Sources.BaseClasses.PartialSource; parameter Boolean use_h_in= false "Get the specific enthalpy from the input connector"; parameter Medium.SpecificEnthalpy h = Medium.h_default "Fixed value of specific enthalpy"; Modelica.Blocks.Interfaces.RealInput h_in(final unit="J/kg") if use_h_in "Prescribed boundary specific enthalpy"; protected Modelica.Blocks.Interfaces.RealInput h_in_internal(final unit="J/kg") "Needed to connect to conditional connector"; equation connect(h_in, h_in_internal); if not use_h_in then h_in_internal = h; end if; for i in 1:nPorts loop ports[i].h_outflow = h_in_internal; end for; connect(medium.h, h_in_internal); end PartialSource_h;

Buildings.Fluid.Sources.BaseClasses.PartialSource_m_flow Buildings.Fluid.Sources.BaseClasses.PartialSource_m_flow

Partial source with prescribed flow rate

Buildings.Fluid.Sources.BaseClasses.PartialSource_m_flow

Information

Partial model that defines the sum of ports.m_flow using an optional input for the total mass flow rate. All port pressures are assumed equal. Otherwise the parameter value is used.

Extends from Buildings.Fluid.Sources.BaseClasses.PartialSource (Partial component source with one fluid connector).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model within the source
Conditional inputs
Booleanuse_m_flow_infalseGet the mass flow rate from the input connector
Fixed inputs
MassFlowRatem_flow0Fixed mass flow rate going out of the fluid port [kg/s]
Advanced
BooleanverifyInputsfalseSet to true to stop the simulation with an error if the medium temperature is outside its allowable range

Connectors

TypeNameDescription
FluidPorts_bports[nPorts] 
input RealInputm_flow_inPrescribed mass flow rate [kg/s]

Modelica definition

model PartialSource_m_flow "Partial source with prescribed flow rate" extends Buildings.Fluid.Sources.BaseClasses.PartialSource; parameter Boolean use_m_flow_in = false "Get the mass flow rate from the input connector"; parameter Modelica.SIunits.MassFlowRate m_flow = 0 "Fixed mass flow rate going out of the fluid port"; Modelica.Blocks.Interfaces.RealInput m_flow_in(final unit="kg/s") if use_m_flow_in "Prescribed mass flow rate"; protected Modelica.Blocks.Interfaces.RealInput m_flow_in_internal(final unit="kg/s") "Needed to connect to conditional connector"; equation connect(m_flow_in, m_flow_in_internal); if not use_m_flow_in then m_flow_in_internal = m_flow; end if; for i in 1:nPorts loop ports[i].p = p_in_internal; end for; sum(ports.m_flow) = -m_flow_in_internal; end PartialSource_m_flow;

Buildings.Fluid.Sources.BaseClasses.PartialSource_p Buildings.Fluid.Sources.BaseClasses.PartialSource_p

Partial source with prescribed pressure

Buildings.Fluid.Sources.BaseClasses.PartialSource_p

Information

Partial model that defines ports.p using an optional input for the pressure. Otherwise the parameter value is used.

Extends from Buildings.Fluid.Sources.BaseClasses.PartialSource (Partial component source with one fluid connector).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium model within the source
Conditional inputs
Booleanuse_p_infalseGet the pressure from the input connector
Fixed inputs
AbsolutePressurepMedium.p_defaultFixed value of pressure [Pa]
Advanced
BooleanverifyInputsfalseSet to true to stop the simulation with an error if the medium temperature is outside its allowable range

Connectors

TypeNameDescription
FluidPorts_bports[nPorts] 
input RealInputp_inPrescribed boundary pressure [Pa]

Modelica definition

model PartialSource_p "Partial source with prescribed pressure" extends Buildings.Fluid.Sources.BaseClasses.PartialSource; parameter Boolean use_p_in = false "Get the pressure from the input connector"; parameter Medium.AbsolutePressure p = Medium.p_default "Fixed value of pressure"; Modelica.Blocks.Interfaces.RealInput p_in(final unit="Pa") if use_p_in "Prescribed boundary pressure"; equation connect(p_in, p_in_internal); if not use_p_in then p_in_internal = p; end if; for i in 1:nPorts loop ports[i].p = p_in_internal; end for; end PartialSource_p;