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_Xi_C PartialSource_Xi_C Partial component source with parameter definitions for Xi and C

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 Buildings.Fluid.Sources.BaseClasses.PartialSource (Partial component source with one fluid connector).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_C_infalseGet the trace substances from the input connector
ExtraPropertyC[Medium.nC]fill(0, Medium.nC)Fixed values of trace substances
Advanced
BooleanverifyInputstrueSet to true to stop the simulation with an error if the medium temperature is outside its allowable range

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 Buildings.Fluid.Sources.BaseClasses.PartialSource(final verifyInputs=true); 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"; Modelica.Blocks.Interfaces.RealInput h_internal = Medium.specificEnthalpy( Medium.setState_pTX(p_in_internal, T_in_internal, X_in_internal)); equation // Check medium properties Modelica.Fluid.Utilities.checkBoundary(Medium.mediumName, Medium.substanceNames, Medium.singleState, true, X_in_internal, "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; connect(X_in_internal[1:Medium.nXi], Xi_in_internal); ports.C_outflow = fill(C_in_internal, nPorts); if not verifyInputs then h_internal = Medium.h_default; p_in_internal = Medium.p_default; X_in_internal = Medium.X_default; T_in_internal = Medium.T_default; end if; // Assign medium properties connect(medium.h, h_internal); connect(medium.Xi, Xi_in_internal); for i in 1:nPorts loop ports[i].p = p_in_internal; ports[i].h_outflow = h_internal; ports[i].Xi_outflow = Xi_in_internal; end for; 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 in the component
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 in the component
FluidPorts_bports[nPorts] 

Modelica definition

partial model PartialSource "Partial component source with one fluid connector" replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; 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_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 in the component
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;