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.PlugFlowHeatLoss PlugFlowHeatLoss Heat loss model for pipe with delay as an input variable
Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowPipe PlugFlowPipe Pipe model using spatialDistribution for temperature delay
Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay PlugFlowTransportDelay Delay time for given normalized velocity

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
Conservation equations
DynamicsenergyDynamicsModelica.Fluid.Types.Dynamic...Type of energy balance: dynamic (3 initialization options) or steady state
RealmSenFac1Factor for scaling the sensible thermal mass of the volume
Advanced
Dynamics
DynamicsmassDynamicsenergyDynamicsType of mass balance: dynamic (3 initialization options) or steady state, must be steady state if energyDynamics is steady state
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
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
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 turbulence 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.Units.SI.Length thicknessIns "Thickness of insulation"; parameter Modelica.Units.SI.ThermalConductivity lambdaIns "Heat conductivity of insulation"; parameter Modelica.Units.SI.Length diameter "Pipe diameter (without insulation)"; parameter Modelica.Units.SI.Length length "Length of the pipe"; parameter Real ReC=4000 "Reynolds number where transition to turbulence 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.Units.SI.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.Units.SI.Density rho_default=Medium.density(state_default); parameter Modelica.Units.SI.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.Units.SI.Length dh "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.Units.SI.Length length(min=0) "Pipe length"; final parameter Modelica.Units.SI.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.Units.SI.Temperature T_start_in=Medium.T_default "Initial temperature in pipe at inlet"; parameter Modelica.Units.SI.Temperature T_start_out=Medium.T_default "Initial temperature in pipe at outlet"; Modelica.Units.SI.Length x "Spatial coordinate for spatialDistribution operator"; Modelica.Units.SI.Velocity v "Flow velocity of medium in pipe"; Modelica.Units.SI.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.Units.SI.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.Units.SI.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.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.Units.SI.MassFlowRate m_flow_nominal "Nominal mass flow rate"; parameter Modelica.Units.SI.Temperature T_start "Initial output temperature"; final parameter Modelica.Units.SI.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.Units.SI.Temperature T_a_inflow(start=T_start) "Temperature at port_a for inflowing fluid"; Modelica.Units.SI.Temperature T_b_outflow(start=T_start) "Temperature at port_b for outflowing fluid"; Modelica.Units.SI.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.Units.SI.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.PlugFlowPipe Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowPipe

Pipe model using spatialDistribution for temperature delay

Buildings.Fluid.FixedResistances.BaseClasses.PlugFlowPipe

Information

Pipe with heat loss using the time delay based heat losses and transport of the fluid using a plug flow model, applicable for simulation of long pipes such as in district heating and cooling systems.

This model takes into account transport delay along the pipe length idealized as a plug flow. The model also includes thermal inertia of the pipe wall.

Implementation

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

The model Buildings.Fluid.FixedResistances.BaseClasses.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.

The pressure drop is implemented using Buildings.Fluid.FixedResistances.HydraulicDiameter. This instance is replaceable to allow Buildings.Fluid.FixedResistances.PlugFlowPipeDiscretized to compute the pressure drop only once rather than for each segment.

The thermal capacity of the pipe wall is implemented as a mixing volume of the fluid in the pipe, of which the thermal capacity is equal to that of the pipe wall material. In addition, this mixing volume allows the hydraulic separation of subsequent pipes.
The mixing volume is either split between the inlet and outlet ports (port_a and port_b) or lumped in at the outlet (port_b) if have_symmetry is set to false. This mixing volume can be removed from this model with the Boolean parameter have_pipCap, in cases where the pipe wall heat capacity is negligible and a state is not needed at the pipe outlet (see the note below about numerical Jacobians).

Note that in order to model a branched network it is recommended to use Buildings.Fluid.FixedResistances.Junction at each junction and to configure that junction model with a state (energyDynamics <> Modelica.Fluid.Types.Dynamics.SteadyState), see for instance Buildings.Fluid.FixedResistances.Validation.PlugFlowPipes.PlugFlowAIT. This will avoid the numerical Jacobian that is otherwise created when the inlet ports of two instances of the plug flow model are connected together.

Assumptions

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.PartialTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
RealReC4000Reynolds number where transition to turbulence starts
Realfac1Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal
HydraulicDiameterresres(final dh=dh, final from_...Pressure drop calculation for this pipe
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate [kg/s]
Velocityv_nominal1.5Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh) [m/s]
Material
Lengthdhsqrt(4*m_flow_nominal/rho_de...Hydraulic diameter (assuming a round cross section area) [m]
Heightroughness2.5e-5Average height of surface asperities (default: smooth steel pipe) [m]
Lengthlength Pipe length [m]
SpecificHeatCapacitycPip2300Specific heat of pipe wall material. 2300 for PE, 500 for steel [J/(kg.K)]
DensityrhoPip930Density of pipe wall material. 930 for PE, 8000 for steel [kg/m3]
Lengththickness0.0035Pipe wall thickness [m]
Thermal resistance
LengthdIns Thickness of pipe insulation, used to compute R [m]
ThermalConductivitykIns Heat conductivity of pipe insulation, used to compute R [W/(m.K)]
RealR1/(kIns*2*Modelica.Constants...Thermal resistance per unit length from fluid to boundary temperature [(m.K)/W]
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)
Booleanhave_pipCaptrue= true, a mixing volume is added that corresponds to the heat capacity of the pipe wall
Booleanhave_symmetrytrue= false, the mixing volume is only on port_b, which improve performances, but reduces dynamic accuracy.
Booleanlinearizedfalse= true, use linear relation between m_flow and dp for any flow rate
Diagnostics
Booleanshow_Tfalse= true, if actual temperature at port is computed
Initialization
TemperatureT_start_inMedium.T_defaultInitialization temperature at pipe inlet [K]
TemperatureT_start_outT_start_inInitialization temperature at pipe outlet [K]
BooleaninitDelayfalseInitialize delay for a constant mass flow rate if true, otherwise start from 0
MassFlowRatem_flow_start0Initial value of mass flow rate through pipe [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 transfer to or from surroundings (positive if pipe is colder than surrounding)

Modelica definition

model PlugFlowPipe "Pipe model using spatialDistribution for temperature delay" extends Buildings.Fluid.Interfaces.PartialTwoPortInterface( m_flow(start=m_flow_start)); constant Boolean homotopyInitialization = true "= true, use homotopy method"; parameter Boolean from_dp=false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Boolean have_pipCap=true "= true, a mixing volume is added that corresponds to the heat capacity of the pipe wall"; parameter Boolean have_symmetry=true "= false, the mixing volume is only on port_b, which improve performances, but reduces dynamic accuracy."; parameter Modelica.Units.SI.Length dh=sqrt(4*m_flow_nominal/rho_default/ v_nominal/Modelica.Constants.pi) "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.Units.SI.Velocity v_nominal=1.5 "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)"; parameter Real ReC=4000 "Reynolds number where transition to turbulence starts"; parameter Modelica.Units.SI.Height roughness=2.5e-5 "Average height of surface asperities (default: smooth steel pipe)"; parameter Modelica.Units.SI.Length length "Pipe length"; parameter Modelica.Units.SI.Length dIns "Thickness of pipe insulation, used to compute R"; parameter Modelica.Units.SI.ThermalConductivity kIns "Heat conductivity of pipe insulation, used to compute R"; parameter Modelica.Units.SI.SpecificHeatCapacity cPip=2300 "Specific heat of pipe wall material. 2300 for PE, 500 for steel"; parameter Modelica.Units.SI.Density rhoPip(displayUnit="kg/m3") = 930 "Density of pipe wall material. 930 for PE, 8000 for steel"; parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness"; parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet"; parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= T_start_in "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.Units.SI.MassFlowRate m_flow_start=0 "Initial value of mass flow rate through pipe"; parameter Real R(unit="(m.K)/W")=1/(kIns*2*Modelica.Constants.pi/ Modelica.Math.log((dh/2 + thickness + dIns)/(dh/2 + thickness))) "Thermal resistance per unit length from fluid to boundary temperature"; parameter Real fac=1 "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal"; parameter Boolean linearized = false "= true, use linear relation between m_flow and dp for any flow rate"; Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort "Heat transfer to or from surroundings (positive if pipe is colder than surrounding)"; // QEnv_flow is introduced because in discretized pipes, heatPort.Q_flow must be summed over all ports. // By introducing this variable, both models have the same variable. Modelica.Units.SI.HeatFlowRate QEnv_flow=heatPort.Q_flow "Heat transfer to or from surroundings (positive if pipe is colder than surrounding)"; Modelica.Units.SI.Velocity v=del.v "Flow velocity of medium in pipe"; replaceable Buildings.Fluid.FixedResistances.HydraulicDiameter res( final dh=dh, final from_dp=from_dp, final length=length, final roughness=roughness, final fac=fac, final ReC=ReC, final v_nominal=v_nominal, final homotopyInitialization=homotopyInitialization, final linearized=linearized, dp(nominal=fac*200*length)) constrainedby Buildings.Fluid.Interfaces.PartialTwoPortInterface ( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final allowFlowReversal=allowFlowReversal, final show_T=false) "Pressure drop calculation for this pipe"; protected parameter Modelica.Units.SI.HeatCapacity CPip=length*((dh + 2*thickness)^2 - dh^2)*Modelica.Constants.pi/4*cPip*rhoPip "Heat capacity of pipe wall"; final parameter Modelica.Units.SI.Volume VEqu=if have_symmetry then CPip/( rho_default*cp_default)/2 else CPip/(rho_default*cp_default) "Equivalent water volume to represent pipe wall thermal inertia"; 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.Units.SI.SpecificHeatCapacity cp_default= Medium.specificHeatCapacityCp(state=sta_default) "Heat capacity of medium"; parameter Real C(unit="J/(K.m)")= rho_default*Modelica.Constants.pi*(dh/2)^2*cp_default "Thermal capacity per unit length of water in pipe"; parameter Modelica.Units.SI.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)"; parameter Boolean have_pipCap_a = have_pipCap and have_symmetry; 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"; 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"; 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"; Sensors.MassFlowRate senMasFlo( redeclare final package Medium = Medium) "Mass flow sensor"; 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"; // In the volume, below, we scale down V and use // mSenFac. Otherwise, for air, we would get very large volumes // which affect the delay of water vapor and contaminants. // See also Buildings.Fluid.FixedResistances.Validation.PlugFlowPipes.TransportWaterAir // for why mSenFac is 10 and not 1000, as this gives more reasonable // temperature step response Fluid.MixingVolumes.MixingVolume vol_b( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final V=if rho_default > 500 then VEqu else VEqu/1000, final nPorts=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac=if rho_default > 500 then 1 else 10) if have_pipCap "Control volume connected to port_b. Represents equivalent pipe wall thermal capacity."; LosslessPipe noMixPip_b( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final m_flow_small=m_flow_small, final allowFlowReversal=allowFlowReversal) if not have_pipCap "Lossless pipe for connecting the outlet port when have_pipCap=false"; MixingVolumes.MixingVolume vol_a( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final V=if rho_default > 500 then VEqu else VEqu/1000, final nPorts=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac=if rho_default > 500 then 1 else 10) if have_pipCap_a "Control volume connected to port_a. Represents equivalent pipe wall thermal capacity."; LosslessPipe noMixPip_a( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final m_flow_small=m_flow_small, final allowFlowReversal=allowFlowReversal) if not have_pipCap_a "Lossless pipe for connecting the outlet port when have_pipCap=false or have_symmetry=false"; 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(timDel.tauRev,heaLos_a. tau); connect(timDel.tau,heaLos_b. tau); connect(heaLos_a.port_a,senMasFlo. port_a); connect(del.port_a,res. port_b); connect(senMasFlo.port_b,res. port_a); connect(heaLos_b.port_a,del. port_b); connect(heaLos_b.heatPort, heatPort); connect(heaLos_a.heatPort, heatPort); connect(heaLos_b.port_b, vol_b.ports[1]); connect(vol_b.ports[2], port_b); connect(heaLos_b.port_b, noMixPip_b.port_a); connect(noMixPip_b.port_b, port_b); connect(port_a, vol_a.ports[1]); connect(vol_a.ports[2], heaLos_a.port_b); connect(port_a, noMixPip_a.port_a); connect(noMixPip_a.port_b, heaLos_a.port_b); end PlugFlowPipe;

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 the inlet and the outlet port of the pipe. For the forward flow, the time delay is exposed at the output tau, and for the backward flow, the time delay is exposed at the output tauRev.

Assumption

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.Units.SI.Length length "Pipe length"; parameter Modelica.Units.SI.Length dh "Hydraulic diameter (assuming a round cross section area)"; parameter Modelica.Units.SI.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.Units.SI.MassFlowRate m_flow_start=0 "Initialization of mass flow rate to calculate initial time delay"; parameter Modelica.Units.SI.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate"; final parameter Modelica.Units.SI.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.Units.SI.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"; final parameter Real conUM(unit="1/kg") = 4/rho/dh/dh/Modelica.Constants.pi/length "Constant to convert mass flow rate into velocity normalized by the pipe length"; Modelica.Units.SI.Time time_out_rev "Reverse flow direction output time"; Modelica.Units.SI.Time time_out_des "Design flow direction output time"; Real x(start=0) "Spatial coordinate for spatialDistribution operator"; Real u(unit="1/s") "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.Units.SI.Time t0(fixed=false) "Start time of the simulation"; initial equation x = 0; t0 = time; equation u = m_flow * conUM; 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 = max(0, time - time_out_des); tauRev = max(0, time - time_out_rev); end PlugFlowTransportDelay;