Buildings.Fluid.FixedResistances.BaseClasses

Package with base classes for Buildings.Fluid.FixedResistances

Information

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

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

Package Content

Name Description
Buildings.Fluid.FixedResistances.BaseClasses.Pipe Pipe Model of a pipe with finite volume discretization along the flow path
Buildings.Fluid.FixedResistances.BaseClasses.PlugFlow PlugFlow Lossless pipe model with spatialDistribution plug flow implementation
Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowCore PlugFlowCore Pipe model using spatialDistribution for temperature delay with modified delay tracker
Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss PlugFlowHeatLoss Heat loss model for pipe with delay as an input variable
Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay PlugFlowTransportDelay Delay time for given normalized velocity
Buildings.Fluid.FixedResistances.BaseClasses.Validation Validation Collection of validation models

Buildings.Fluid.FixedResistances.BaseClasses.Pipe Buildings.Fluid.FixedResistances.BaseClasses.Pipe

Model of a pipe with finite volume discretization along the flow path

Buildings.Fluid.FixedResistances.BaseClasses.Pipe

Information

Model of a pipe with flow resistance and optional heat storage. This model can be used for modeling the heat exchange between the pipe and environment. The model consists of a flow resistance Buildings.Fluid.FixedResistances.PressureDrop and nSeg mixing volumes Buildings.Fluid.MixingVolumes.MixingVolume.

Extends from Buildings.Fluid.Interfaces.LumpedVolumeDeclarations (Declarations for lumped volumes), 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
IntegernSeg10Number of volume segments
LengththicknessIns Thickness of insulation [m]
ThermalConductivitylambdaIns Heat conductivity of insulation [W/(m.K)]
Lengthdiameter Pipe diameter (without insulation) [m]
Lengthlength Length of the pipe [m]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
PressureDifferencedp_nominal Pressure difference [Pa]
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.)
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_Ttrue= 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
RealReC4000Reynolds number where transition to turbulent starts

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

model Pipe "Model of a pipe with finite volume discretization along the flow path" extends Buildings.Fluid.Interfaces.LumpedVolumeDeclarations; extends Buildings.Fluid.Interfaces.PartialTwoPortInterface( final show_T=true); extends Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters( final computeFlowResistance=(abs(dp_nominal) > Modelica.Constants.eps)); constant Boolean homotopyInitialization = true "= true, use homotopy method"; parameter Integer nSeg(min=1) = 10 "Number of volume segments"; parameter Modelica.SIunits.Length thicknessIns "Thickness of insulation"; parameter Modelica.SIunits.ThermalConductivity lambdaIns "Heat conductivity of insulation"; parameter Modelica.SIunits.Length diameter "Pipe diameter (without insulation)"; parameter Modelica.SIunits.Length length "Length of the pipe"; parameter Real ReC=4000 "Reynolds number where transition to turbulent starts"; Buildings.Fluid.FixedResistances.PressureDrop preDro( redeclare final package Medium = Medium, final from_dp=from_dp, final show_T=show_T, final m_flow_nominal=m_flow_nominal, final dp_nominal=dp_nominal, final allowFlowReversal=allowFlowReversal, final linearized=linearizeFlowResistance, final homotopyInitialization=homotopyInitialization) "Flow resistance"; Buildings.Fluid.MixingVolumes.BaseClasses.MixingVolumeHeatPort[nSeg] vol( redeclare each final package Medium = Medium, each energyDynamics=energyDynamics, each massDynamics=massDynamics, final initialize_p = {(i == 1 and (not Medium.singleState)) for i in 1:nSeg}, each final V=VPipe/nSeg, each nPorts=2, each final m_flow_nominal=m_flow_nominal, each prescribedHeatFlowRate=true, each p_start=p_start, each T_start=T_start, each X_start=X_start, each C_start=C_start, each C_nominal=C_nominal, each final m_flow_small=m_flow_small, each final allowFlowReversal=allowFlowReversal) "Volume for pipe fluid"; protected parameter Modelica.SIunits.Volume VPipe=Modelica.Constants.pi*(diameter/2.0)^ 2*length "Pipe volume"; parameter Medium.ThermodynamicState state_default = Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]) "Default state"; parameter Modelica.SIunits.Density rho_default = Medium.density(state_default); parameter Modelica.SIunits.DynamicViscosity mu_default = Medium.dynamicViscosity(state_default) "Dynamic viscosity at nominal condition"; initial equation assert(homotopyInitialization, "In " + getInstanceName() + ": The constant homotopyInitialization has been modified from its default value. This constant will be removed in future releases.", level = AssertionLevel.warning); equation connect(port_a, preDro.port_a); connect(preDro.port_b, vol[1].ports[1]); if nSeg > 1 then for i in 1:(nSeg - 1) loop connect(vol[i].ports[2], vol[i + 1].ports[1]); end for; end if; connect(vol[nSeg].ports[2], port_b); end Pipe;

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlow Buildings.Fluid.FixedResistances.BaseClasses.PlugFlow

Lossless pipe model with spatialDistribution plug flow implementation

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlow

Information

Model that computes the temperature propagation of a fluid flow through a pipe, idealized as a plug flow.

Main equation

The transport delay is computed using the one-dimensional wave equation without source or sink terms,

∂z(x,t)/∂t + v(t) ∂z(x,t)/∂x = 0,

where z(x,t) is the spatial distribution as a function of time of any property z of the fluid. For the temperature propagation, z will be replaced by T.

Assumptions

This model is based on the following assumptions:

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

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Lengthdh Hydraulic diameter (assuming a round cross section area) [m]
Lengthlength Pipe length [m]
Initialization
TemperatureT_start_inMedium.T_defaultInitial temperature in pipe at inlet [K]
TemperatureT_start_outMedium.T_defaultInitial temperature in pipe at outlet [K]
Assumptions
BooleanallowFlowReversaltrue= false to simplify equations, assuming, but not enforcing, no flow reversal
Advanced
MassFlowRatem_flow_small Small mass flow rate for regularization of zero flow [kg/s]

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

model PlugFlow "Lossless pipe model with spatialDistribution plug flow implementation" extends Buildings.Fluid.Interfaces.PartialTwoPort; parameter Modelica.SIunits.Length dh "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.SIunits.Length length(min=0) "Pipe length"; final parameter Modelica.SIunits.Area A=Modelica.Constants.pi*(dh/2)^2 "Cross-sectional area of pipe"; parameter Medium.MassFlowRate m_flow_small "Small mass flow rate for regularization of zero flow"; parameter Modelica.SIunits.Temperature T_start_in=Medium.T_default "Initial temperature in pipe at inlet"; parameter Modelica.SIunits.Temperature T_start_out=Medium.T_default "Initial temperature in pipe at outlet"; Modelica.SIunits.Length x "Spatial coordinate for spatialDistribution operator"; Modelica.SIunits.Velocity v "Flow velocity of medium in pipe"; Modelica.SIunits.VolumeFlowRate V_flow= port_a.m_flow/Modelica.Fluid.Utilities.regStep(port_a.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) "Volume flow rate at inflowing port (positive when flow from port_a to port_b)"; protected parameter Modelica.SIunits.SpecificEnthalpy h_ini_in=Medium.specificEnthalpy( Medium.setState_pTX( T=T_start_in, p=Medium.p_default, X=Medium.X_default)) "For initialization of spatialDistribution inlet"; parameter Modelica.SIunits.SpecificEnthalpy h_ini_out=Medium.specificEnthalpy( Medium.setState_pTX( T=T_start_out, p=Medium.p_default, X=Medium.X_default)) "For initialization of spatialDistribution outlet"; Medium.MassFraction Xi_inflow_a[Medium.nXi] = inStream(port_a.Xi_outflow) "Independent mixture mass fractions m_i/m close to the connection point flow into the component"; Medium.MassFraction Xi_inflow_b[Medium.nXi] = inStream(port_b.Xi_outflow) "Independent mixture mass fractions m_i/m close to the connection point flow into the component"; Medium.ExtraProperty C_inflow_a[Medium.nC] = inStream(port_a.C_outflow) "Properties c_i/m close to the connection point if flow into the component"; Medium.ExtraProperty C_inflow_b[Medium.nC] = inStream(port_b.C_outflow) "Properties c_i/m close to the connection point if flow into the component"; initial equation x = 0; equation // No pressure drop port_a.p = port_b.p; // Mass balance (no storage) port_a.m_flow + port_b.m_flow = 0; der(x) = v; v = V_flow/A; (port_a.h_outflow, port_b.h_outflow) = spatialDistribution( inStream(port_a.h_outflow), inStream(port_b.h_outflow), x/length, v >= 0, {0.0, 1.0}, {h_ini_in, h_ini_out}); // Transport of substances for i in 1:Medium.nXi loop (port_a.Xi_outflow[i], port_b.Xi_outflow[i]) = spatialDistribution( Xi_inflow_a[i], Xi_inflow_b[i], x/length, v >= 0, {0.0, 1.0}, {0.01, 0.01}); end for; for i in 1:Medium.nC loop (port_a.C_outflow[i], port_b.C_outflow[i]) = spatialDistribution( C_inflow_a[i], C_inflow_b[i], x/length, v >= 0, {0.0, 1.0}, {0, 0}); end for; end PlugFlow;

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowCore Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowCore

Pipe model using spatialDistribution for temperature delay with modified delay tracker

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowCore

Information

Pipe with heat loss using the time delay based heat losses and plug flow for the transport delay of the fluid.

Implementation

The spatialDistribution operator is used for the temperature wave propagation through the length of the pipe. This operator is contained in BaseClasses.PlugFlow.

This model does not include thermal inertia of the pipe wall. The wall inertia is implemented in PlugFlowPipe, which uses this model.
The removal of the thermal inertia with a mixing volume can be desirable in the case where mixing volumes are added manually at the pipe junctions.

The model PlugFlowHeatLoss implements a heat loss in design direction, but leaves the enthalpy unchanged in opposite flow direction. Therefore it is used in front of and behind the time delay.

References

Full details on the model implementation and experimental validation can be found in:

van der Heijde, B., Fuchs, M., Ribas Tugores, C., Schweiger, G., Sartor, K., Basciotti, D., Müller, D., Nytsch-Geusen, C., Wetter, M. and Helsen, L. (2017).
Dynamic equation-based thermo-hydraulic pipe model for district heating and cooling systems.
Energy Conversion and Management, vol. 151, p. 158-169. doi: 10.1016/j.enconman.2017.08.072.

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

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Lengthdh Hydraulic diameter (assuming a round cross section area) [m]
Lengthlength Pipe length [m]
RealR Thermal resistance per unit length from fluid to boundary temperature [(m.K)/W]
RealC Thermal capacity per unit length of pipe [J/(K.m)]
Realfac1Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal
Lengththickness Pipe wall thickness [m]
RealReC4000Reynolds number where transition to turbulent starts
Nominal condition
Velocityv_nominal Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh) [m/s]
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Geometry
Heightroughness2.5e-5Average height of surface asperities (default: smooth steel pipe) [m]
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]
Booleanfrom_dpfalse= true, use m_flow = f(dp) else dp = f(m_flow)
Booleanlinearizedfalse= true, use linear relation between m_flow and dp for any flow rate
Initialization
TemperatureT_start_inMedium.T_defaultInitialization temperature at pipe inlet [K]
TemperatureT_start_outMedium.T_defaultInitialization temperature at pipe outlet [K]
BooleaninitDelayfalseInitialize delay for a constant mass flow rate if true, otherwise start from 0
MassFlowRatem_flow_start0[kg/s]

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)
HeatPort_aheatPortHeat port to connect environment (positive heat flow for heat loss to surroundings)

Modelica definition

model PlugFlowCore "Pipe model using spatialDistribution for temperature delay with modified delay tracker" extends Buildings.Fluid.Interfaces.PartialTwoPort; constant Boolean homotopyInitialization = true "= true, use homotopy method"; parameter Modelica.SIunits.Length dh "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.SIunits.Velocity v_nominal "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)"; parameter Modelica.SIunits.Length length(min=0) "Pipe length"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal(min=0) "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"; parameter Modelica.SIunits.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)"; parameter Real R(unit="(m.K)/W") "Thermal resistance per unit length from fluid to boundary temperature"; parameter Real C(unit="J/(K.m)") "Thermal capacity per unit length of pipe"; parameter Real fac=1 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal"; parameter Boolean from_dp=false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Length thickness(min=0) "Pipe wall thickness"; parameter Modelica.SIunits.Temperature T_start_in=Medium.T_default "Initialization temperature at pipe inlet"; parameter Modelica.SIunits.Temperature T_start_out=Medium.T_default "Initialization temperature at pipe outlet"; parameter Boolean initDelay=false "Initialize delay for a constant mass flow rate if true, otherwise start from 0"; parameter Modelica.SIunits.MassFlowRate m_flow_start=0; parameter Real ReC=4000 "Reynolds number where transition to turbulent starts"; parameter Boolean linearized = false "= true, use linear relation between m_flow and dp for any flow rate"; Buildings.Fluid.FixedResistances.HydraulicDiameter res( redeclare final package Medium = Medium, final dh=dh, final m_flow_nominal=m_flow_nominal, final from_dp=from_dp, final length=length, final roughness=roughness, final fac=fac, final ReC=ReC, final v_nominal=v_nominal, final allowFlowReversal=allowFlowReversal, final show_T=false, final homotopyInitialization=homotopyInitialization, final linearized=linearized, dp(nominal=fac*200*length)) "Pressure drop calculation for this pipe"; Buildings.Fluid.FixedResistances.BaseClasses.PlugFlow del( redeclare final package Medium = Medium, final m_flow_small=m_flow_small, final dh=dh, final length=length, final allowFlowReversal=allowFlowReversal, final T_start_in=T_start_in, final T_start_out=T_start_out) "Model for temperature wave propagation"; Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss heaLos_a( redeclare final package Medium = Medium, final C=C, final R=R, final m_flow_small=m_flow_small, final T_start=T_start_in, final m_flow_nominal=m_flow_nominal, final m_flow_start=m_flow_start, final show_T=false, final show_V_flow=false) "Heat loss for flow from port_b to port_a"; Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss heaLos_b( redeclare final package Medium = Medium, final C=C, final R=R, final m_flow_small=m_flow_small, final T_start=T_start_out, final m_flow_nominal=m_flow_nominal, final m_flow_start=m_flow_start, final show_T=false, final show_V_flow=false) "Heat loss for flow from port_a to port_b"; Buildings.Fluid.Sensors.MassFlowRate senMasFlo( redeclare final package Medium = Medium) "Mass flow sensor"; Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay timDel( final length=length, final dh=dh, final rho=rho_default, final initDelay=initDelay, final m_flow_nominal=m_flow_nominal, final m_flow_start=m_flow_start) "Time delay"; Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat port to connect environment (positive heat flow for heat loss to surroundings)"; protected parameter Modelica.SIunits.Density rho_default=Medium.density_pTX( p=Medium.p_default, T=Medium.T_default, X=Medium.X_default) "Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)"; initial equation assert(homotopyInitialization, "In " + getInstanceName() + ": The constant homotopyInitialization has been modified from its default value. This constant will be removed in future releases.", level = AssertionLevel.warning); equation connect(senMasFlo.m_flow, timDel.m_flow); connect(heaLos_a.heatPort, heatPort); connect(heaLos_b.heatPort, heatPort); connect(timDel.tauRev, heaLos_a.tau); connect(timDel.tau, heaLos_b.tau); connect(port_a, heaLos_a.port_b); connect(heaLos_a.port_a, senMasFlo.port_a); connect(heaLos_b.port_b, port_b); connect(del.port_a, res.port_b); connect(senMasFlo.port_b, res.port_a); connect(heaLos_b.port_a, del.port_b); end PlugFlowCore;

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss

Heat loss model for pipe with delay as an input variable

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss

Information

Component that calculates the heat losses at the end of a plug flow pipe when the flow goes in the design direction.

Main equations

The governing equations are

Tout = Tb + (Tin - Tb) exp((tout - tin)/tauchar)

with

tauchar = R C

Assumptions and limitations

This model is based on the following assumptions:

Implementation

Heat losses are only considered in design flow direction. For heat loss consideration in both directions, use one of these models at both ends of a Buildings.Fluid.FixedResistances.BaseClasses.PlugFlow model. The outlet temperature is calculated as in the equation above, using the inlet temperature at port_a and the instantaneous time delay and boundary temperature. The boundary temperature can be either the air temperature or the undisturbed ground temperature, depending on the definition of the thermal resistance R.

This component requires the delay time and the instantaneous ambient temperature as an input. This component is to be used in single pipes or in more advanced configurations where no influence from other pipes is considered.

Extends from Fluid.Interfaces.PartialTwoPortTransport (Partial element transporting fluid between two ports without storage of mass or energy).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
RealC Thermal capacity per unit length of pipe [J/(K.m)]
RealR Thermal resistance per unit length from fluid to boundary temperature [(m.K)/W]
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
TemperatureT_start Initial output temperature [K]
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)
input RealInputtauTime delay at pipe level [s]
HeatPort_aheatPortHeat port to connect environment (negative if heat is lost to ambient)

Modelica definition

model PlugFlowHeatLoss "Heat loss model for pipe with delay as an input variable" extends Fluid.Interfaces.PartialTwoPortTransport( final allowFlowReversal=true, final dp_start=0); // allowFlowReversal set to true because this model is used for inlet and outlets parameter Real C(unit="J/(K.m)") "Thermal capacity per unit length of pipe"; parameter Real R(unit="(m.K)/W") "Thermal resistance per unit length from fluid to boundary temperature"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal "Nominal mass flow rate"; parameter Modelica.SIunits.Temperature T_start "Initial output temperature"; final parameter Modelica.SIunits.Time tau_char=R*C "Characteristic delay time"; Modelica.Blocks.Interfaces.RealInput tau(unit="s") "Time delay at pipe level"; Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat port to connect environment (negative if heat is lost to ambient)"; Modelica.SIunits.Temperature T_a_inflow(start=T_start) "Temperature at port_a for inflowing fluid"; Modelica.SIunits.Temperature T_b_outflow(start=T_start) "Temperature at port_b for outflowing fluid"; Modelica.SIunits.Temperature TAmb=heatPort.T "Environment temperature"; protected parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default) "Default medium state"; parameter Modelica.SIunits.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=sta_default) "Heat capacity of medium"; equation dp = 0; port_a.h_outflow = inStream(port_b.h_outflow); port_b.h_outflow =Medium.specificEnthalpy( Medium.setState_pTX( port_a.p, T_b_outflow, port_b.Xi_outflow)) "Calculate enthalpy of output state"; T_a_inflow = Medium.temperature( Medium.setState_phX( port_a.p, inStream(port_a.h_outflow), port_b.Xi_outflow)); // Heat losses T_b_outflow = TAmb + (T_a_inflow - TAmb)*Modelica.Math.exp(-tau/tau_char); heatPort.Q_flow = -Buildings.Utilities.Math.Functions.spliceFunction( pos=(T_a_inflow - T_b_outflow)*cp_default, neg=0, x=port_a.m_flow, deltax=m_flow_nominal/1000)*port_a.m_flow; end PlugFlowHeatLoss;

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay

Delay time for given normalized velocity

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay

Information

Calculates time delay at both sides of the pipe as the difference between the current simulation time and the inlet time of the fluid at both ends of the pipe.

Main equation

∂z(x,t)/∂t + v(t) ∂z(x,t)/∂x = 0,

where z(x,t) is the spatial distribution as a function of time of any property z of the fluid. For the inlet time propagation, z will be replaced by the inlet time of the fluid tin.

Implementation

The inlet time is approached as a fluid property and its propagation follows the one-dimensional wave equation, implemented using the spatialDistribution function. This components requires the mass flow through the pipe and the pipe dimensions in order to derive information about the fluid propagation.

The component calculates the delay time at both in/outlet ports of the pipe and therefore has two outlets. During forward flow, only the forward Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay component in Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowCore will be active and uses the forward output of PlugFlowTransportDelay. During reverse, the opposite is true and only the reverse output is used.

Assumption

It is assumed that no axial mixing takes place in the pipe.

Parameters

TypeNameDefaultDescription
Lengthlength Pipe length [m]
Lengthdh Hydraulic diameter (assuming a round cross section area) [m]
Densityrho Standard density of fluid [kg/m3]
Initialization
BooleaninitDelayfalseInitialize delay for a constant m_flow_start if true, otherwise start from 0
MassFlowRatem_flow_start0Initialization of mass flow rate to calculate initial time delay [kg/s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]

Connectors

TypeNameDescription
input RealInputm_flowMass flow of fluid
output RealOutputtauTime delay for design flow direction
output RealOutputtauRevTime delay for reverse flow

Modelica definition

model PlugFlowTransportDelay "Delay time for given normalized velocity" parameter Modelica.SIunits.Length length "Pipe length"; parameter Modelica.SIunits.Length dh "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.SIunits.Density rho "Standard density of fluid"; parameter Boolean initDelay=false "Initialize delay for a constant m_flow_start if true, otherwise start from 0"; parameter Modelica.SIunits.MassFlowRate m_flow_start=0 "Initialization of mass flow rate to calculate initial time delay"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate"; final parameter Modelica.SIunits.Time t_in_start= if initDelay and (abs(m_flow_start) > 1E-10*m_flow_nominal) then min(length/m_flow_start*(rho*dh^2/4*Modelica.Constants.pi), 0) else 0 "Initial value of input time at inlet"; final parameter Modelica.SIunits.Time t_out_start= if initDelay and (abs(m_flow_start) > 1E-10*m_flow_nominal) then min(-length/m_flow_start*(rho*dh^2/4*Modelica.Constants.pi), 0) else 0 "Initial value of input time at outlet"; Modelica.SIunits.Time time_out_rev "Reverse flow direction output time"; Modelica.SIunits.Time time_out_des "Design flow direction output time"; Real x(start=0) "Spatial coordinate for spatialDistribution operator"; Modelica.SIunits.Frequency u "Normalized fluid velocity (1/s)"; Modelica.Blocks.Interfaces.RealInput m_flow "Mass flow of fluid"; Modelica.Blocks.Interfaces.RealOutput tau "Time delay for design flow direction"; Modelica.Blocks.Interfaces.RealOutput tauRev "Time delay for reverse flow"; protected parameter Modelica.SIunits.Time t0(fixed = false) "Start time of the simulation"; initial equation x = 0; t0 = time; equation u = m_flow/(rho*(dh^2)/4*Modelica.Constants.pi)/length; der(x) = u; (time_out_rev, time_out_des) = spatialDistribution( time, time, x, u >= 0, initialPoints = {0.0, 1.0}, initialValues = {t0 + t_in_start, t0 + t_out_start}); tau = time - time_out_des; tauRev = time - time_out_rev; end PlugFlowTransportDelay;