| Name | Description |
|---|---|
| Collection of models that illustrate model use and test models | |
| Source with mass flow that does not take part in medium mass balance (such as CO2) |
Buildings.Fluids.Sources.PrescribedExtraPropertyFlowRate
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nPorts | 1 | Number of ports |
| replaceable package Medium | Modelica.Media.Interfaces.Pa... | Medium model within the source | |
| String | substanceName | "CO2" | Name of trace substance |
| Boolean | use_m_flow_in | false | Get the trace substance mass flow rate from the input connector |
| MassFlowRate | m_flow | 0 | Fixed mass flow rate going out of the fluid port [kg/s] |
| Type | Name | Description |
|---|---|---|
| FluidPorts_b | ports[nPorts] | |
| input RealInput | m_flow_in | Prescribed mass flow rate for extra property |
model PrescribedExtraPropertyFlowRate
"Source with mass flow that does not take part in medium mass balance (such as CO2)"
extends Modelica_Fluid.Sources.BaseClasses.PartialSource(nPorts=1);
parameter String substanceName = "CO2" "Name of trace substance";
parameter Boolean use_m_flow_in = false
"Get the trace substance mass flow rate from the input connector";
parameter Medium.MassFlowRate m_flow = 0
"Fixed mass flow rate going out of the fluid port";
Modelica.Blocks.Interfaces.RealInput m_flow_in if
use_m_flow_in "Prescribed mass flow rate for extra property";
protected
Modelica.Blocks.Interfaces.RealInput m_flow_in_internal
"Needed to connect to conditional connector";
parameter Medium.ExtraProperty C_in_internal[Medium.nC](
fixed=false,
quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC)
"Boundary trace substances";
initial algorithm
for i in 1:Medium.nC loop
if ( Modelica.Utilities.Strings.isEqual(Medium.extraPropertiesNames[i], substanceName)) then
C_in_internal[i] := 1;
else
C_in_internal[i] := 0;
end if;
end for;
assert(sum(C_in_internal) > 0, "Trace substance '" + substanceName + "' is not present in medium '"
+ Medium.mediumName + "'.\n"
+ "Check source parameter and medium model.");
equation
connect(m_flow_in, m_flow_in_internal);
if not use_m_flow_in then
m_flow_in_internal = m_flow;
end if;
assert(sum(m_flow_in_internal) >= 0, "Reverse flow for species source is not yet implemented.");
sum(ports.m_flow) = -m_flow_in_internal;
medium.T = Medium.T_default;
medium.Xi = Medium.X_default[1:Medium.nXi];
ports.C_outflow = fill(C_in_internal, nPorts);
end PrescribedExtraPropertyFlowRate;