# Pipe (MA)

Rigid conduit for moist air flow

**Library:**Simscape / Foundation Library / Moist Air / Elements

## Description

The Pipe (MA) block models pipe flow dynamics in a moist air network due to viscous friction losses and convective heat transfer with the pipe wall. The pipe contains a constant volume of moist air. The pressure and temperature evolve based on the compressibility and thermal capacity of this moist air volume. Liquid water condenses out of the moist air volume when it reaches saturation. Choked flow occurs when the outlet reaches sonic condition.

**Caution**

Air flow through this block can choke. If a Mass Flow Rate Source (MA) block or a Controlled Mass Flow Rate Source (MA) block connected to the Pipe (MA) block specifies a greater mass flow rate than the possible choked mass flow rate, the simulation generates an error. For more information, see Choked Flow.

The block equations use these symbols. Subscripts `a`

,
`w`

, and `g`

indicate the properties of dry air,
water vapor, and trace gas, respectively. Subscript `ws`

indicates
water vapor at saturation. Subscripts `A`

, `B`

,
`H`

, and `S`

indicate the appropriate port.
Subscript `I`

indicates the properties of the internal moist air
volume.

$$\dot{m}$$ | Mass flow rate |

Φ | Energy flow rate |

Q | Heat flow rate |

p | Pressure |

ρ | Density |

R | Specific gas constant |

V | Volume of moist air inside the pipe |

c_{v} | Specific heat at constant volume |

c_{p} | Specific heat at constant pressure |

h | Specific enthalpy |

u | Specific internal energy |

x | Mass fraction
(x_{w} is specific humidity,
which is another term for water vapor mass fraction) |

y | Mole fraction |

φ | Relative humidity |

r | Humidity ratio |

T | Temperature |

t | Time |

### Mass and Energy Balance

The net flow rates into the moist air volume inside the pipe are

$$\begin{array}{l}{\dot{m}}_{net}={\dot{m}}_{A}+{\dot{m}}_{B}-{\dot{m}}_{condense}+{\dot{m}}_{wS}+{\dot{m}}_{gS}\\ {\Phi}_{net}={\Phi}_{A}+{\Phi}_{B}+{Q}_{H}-{\Phi}_{condense}+{\Phi}_{S}\\ {\dot{m}}_{w,net}={\dot{m}}_{wA}+{\dot{m}}_{wB}-{\dot{m}}_{condense}+{\dot{m}}_{wS}\\ {\dot{m}}_{g,net}={\dot{m}}_{gA}+{\dot{m}}_{gB}+{\dot{m}}_{gS}\end{array}$$

where:

$$\dot{m}$$

_{condense}is the rate of condensation.*Φ*_{condense}is the rate of energy loss from the condensed water.*Φ*_{S}is the rate of energy added by the sources of moisture and trace gas. $${\dot{m}}_{wS}$$ and $${\dot{m}}_{gS}$$ are the mass flow rates of water and gas, respectively, through port**S**. The values of $${\dot{m}}_{wS}$$, $${\dot{m}}_{gS}$$, and*Φ*_{S}are determined by the moisture and trace gas sources connected to port**S**of the pipe.

Water vapor mass conservation relates the water vapor mass flow rate to the dynamics of the moisture level in the internal moist air volume:

$$\frac{d{x}_{wI}}{dt}{\rho}_{I}V+{x}_{wI}{\dot{m}}_{net}={\dot{m}}_{w,net}$$

Similarly, trace gas mass conservation relates the trace gas mass flow rate to the dynamics of the trace gas level in the internal moist air volume:

$$\frac{d{x}_{gI}}{dt}{\rho}_{I}V+{x}_{gI}{\dot{m}}_{net}={\dot{m}}_{g,net}$$

Mixture mass conservation relates the mixture mass flow rate to the dynamics of the pressure, temperature, and mass fractions of the internal moist air volume:

$$\left(\frac{1}{{p}_{I}}\frac{d{p}_{I}}{dt}-\frac{1}{{T}_{I}}\frac{d{T}_{I}}{dt}\right){\rho}_{I}V+\frac{{R}_{a}-{R}_{w}}{{R}_{I}}\left({\dot{m}}_{w,net}-{x}_{w}{\dot{m}}_{net}\right)+\frac{{R}_{a}-{R}_{g}}{{R}_{I}}\left({\dot{m}}_{g,net}-{x}_{g}{\dot{m}}_{net}\right)={\dot{m}}_{net}$$

Finally, energy conservation relates the energy flow rate to the dynamics of the pressure, temperature, and mass fractions of the internal moist air volume:

$${\rho}_{I}{c}_{vI}V\frac{d{T}_{I}}{dt}+\left({u}_{wI}-{u}_{aI}\right)\left({\dot{m}}_{w,net}-{x}_{w}{\dot{m}}_{net}\right)+\left({u}_{gI}-{u}_{aI}\right)\left({\dot{m}}_{g,net}-{x}_{g}{\dot{m}}_{net}\right)+{u}_{I}{\dot{m}}_{net}={\Phi}_{net}$$

The equation of state relates the mixture density to the pressure and temperature:

$${p}_{I}={\rho}_{I}{R}_{I}{T}_{I}$$

The mixture specific gas constant is

$${R}_{I}={x}_{aI}{R}_{a}+{x}_{wI}{R}_{w}+{x}_{gI}{R}_{g}$$

### Momentum Balance

The momentum balance for each half of the pipe models the pressure drop due to momentum flux and viscous friction:

$$\begin{array}{l}{p}_{A}-{p}_{I}={\left(\frac{{\dot{m}}_{A}}{S}\right)}^{2}\cdot \left(\frac{{T}_{I}}{{p}_{I}}-\frac{{T}_{A}}{{p}_{A}}\right){R}_{I}+\Delta {p}_{AI}\\ {p}_{B}-{p}_{I}={\left(\frac{{\dot{m}}_{B}}{S}\right)}^{2}\cdot \left(\frac{{T}_{I}}{{p}_{I}}-\frac{{T}_{B}}{{p}_{B}}\right){R}_{I}+\Delta {p}_{BI}\end{array}$$

where:

*p*is the pressure at port**A**, port**B**, or internal node I, as indicated by the subscript.*ρ*is the density at port**A**, port**B**, or internal node I, as indicated by the subscript.*S*is the cross-sectional area of the pipe.*Δp*_{AI}and*Δp*_{BI}are pressure losses due to viscous friction.

The pressure losses due to viscous friction,
*Δp*_{AI} and
*Δp*_{BI}, depend on the flow regime. The
Reynolds numbers for each half of the pipe are defined as:

$$\begin{array}{l}{\mathrm{Re}}_{A}=\frac{\left|{\dot{m}}_{A}\right|\cdot {D}_{h}}{S\cdot {\mu}_{I}}\\ {\mathrm{Re}}_{B}=\frac{\left|{\dot{m}}_{B}\right|\cdot {D}_{h}}{S\cdot {\mu}_{I}}\end{array}$$

where:

*D*_{h}is the hydraulic diameter of the pipe.*μ*_{I}is the dynamic viscosity at the internal node.

If the Reynolds number is less than the value of the **Laminar flow upper
Reynolds number limit** parameter, then the flow is in the laminar flow
regime. If the Reynolds number is greater than the value of the **Turbulent
flow lower Reynolds number limit** parameter, then the flow is in the
turbulent flow regime.

In the laminar flow regime, the pressure losses due to viscous friction are:

$$\begin{array}{l}\Delta {p}_{A{I}_{lam}}={f}_{shape}\frac{{\dot{m}}_{A}\cdot {\mu}_{I}}{2{\rho}_{I}\cdot {D}_{h}^{2}\cdot S}\cdot \frac{L+{L}_{eqv}}{2}\\ \Delta {p}_{B{I}_{lam}}={f}_{shape}\frac{{\dot{m}}_{B}\cdot {\mu}_{I}}{2{\rho}_{I}\cdot {D}_{h}^{2}\cdot S}\cdot \frac{L+{L}_{eqv}}{2}\end{array}$$

where:

*f*_{shape}is the value of the**Shape factor for laminar flow viscous friction**parameter.*L*_{eqv}is the value of the**Aggregate equivalent length of local resistances**parameter.

In the turbulent flow regime, the pressure losses due to viscous friction are:

$$\begin{array}{l}\Delta {p}_{A{I}_{tur}}={f}_{Darc{y}_{A}}\frac{{\dot{m}}_{A}\cdot \left|{\dot{m}}_{A}\right|}{2{\rho}_{I}\cdot {D}_{h}\cdot {S}^{2}}\cdot \frac{L+{L}_{eqv}}{2}\\ \Delta {p}_{B{I}_{tur}}={f}_{Darc{y}_{B}}\frac{{\dot{m}}_{B}\cdot \left|{\dot{m}}_{B}\right|}{2{\rho}_{I}\cdot {D}_{h}\cdot {S}^{2}}\cdot \frac{L+{L}_{eqv}}{2}\end{array}$$

where *f*_{Darcy} is the Darcy friction
factor at port **A** or **B**, as indicated by the
subscript.

The Darcy friction factors are computed from the Haaland correlation:

$$\begin{array}{l}{f}_{Darc{y}_{A}}={\left[-1.8\mathrm{log}\left(\frac{6.9}{{\mathrm{Re}}_{A}}+{\left(\frac{{\epsilon}_{rough}}{3.7{D}_{h}}\right)}^{1.11}\right)\right]}^{-2}\\ {f}_{Darc{y}_{B}}={\left[-1.8\mathrm{log}\left(\frac{6.9}{{\mathrm{Re}}_{B}}+{\left(\frac{{\epsilon}_{rough}}{3.7{D}_{h}}\right)}^{1.11}\right)\right]}^{-2}\end{array}$$

where *ε*_{rough} is the value of the
**Internal surface absolute roughness** parameter.

When the Reynolds number is between the **Laminar flow upper Reynolds
number limit** and the **Turbulent flow lower Reynolds number
limit** parameter values, the flow is in transition between laminar
flow and turbulent flow. The pressure losses due to viscous friction during the
transition region follow a smooth connection between those in the laminar flow
regime and those in the turbulent flow regime.

The heat exchanged with the pipe wall through port **H** is added
to the energy of the moist air volume represented by the internal node via the
energy conservation equation (see Mass and Energy Balance). Therefore,
the momentum balances for each half of the pipe, between port **A**
and the internal node and between port **B** and the internal node,
are assumed to be adiabatic processes. The adiabatic relations are:

$$\begin{array}{l}{h}_{A}-{h}_{I}={\left(\frac{{R}_{I}{\dot{m}}_{A}}{S}\right)}^{2}\left[{\left(\frac{{T}_{I}}{{p}_{I}}\right)}^{2}-{\left(\frac{{T}_{A}}{{p}_{A}}\right)}^{2}\right]\\ {h}_{B}-{h}_{I}={\left(\frac{{R}_{I}{\dot{m}}_{B}}{S}\right)}^{2}\left[{\left(\frac{{T}_{I}}{{p}_{I}}\right)}^{2}-{\left(\frac{{T}_{B}}{{p}_{B}}\right)}^{2}\right]\end{array}$$

where *h* is the specific enthalpy at port
**A**, port **B**, or internal node I, as
indicated by the subscript.

### Convective Heat Transfer

The convective heat transfer equation between the pipe wall and the internal moist air volume is:

$${Q}_{H}={Q}_{conv}+\frac{{k}_{I}{S}_{surf}}{{D}_{h}}\left({T}_{H}-{T}_{I}\right)$$

*S*_{surf} is the pipe surface area,
*S*_{surf} =
4*S**L*/*D*_{h}.
Assuming an exponential temperature distribution along the pipe, the convective heat
transfer is

$${Q}_{conv}=\left|{\dot{m}}_{avg}\right|{c}_{{p}_{avg}}\left({T}_{H}-{T}_{in}\right)\left(1-\mathrm{exp}\left(-\frac{{h}_{coeff}{S}_{surf}}{\left|{\dot{m}}_{avg}\right|{c}_{{p}_{avg}}}\right)\right)$$

where:

*T*_{in}is the inlet temperature depending on flow direction.$${\dot{m}}_{avg}=\left({\dot{m}}_{A}-{\dot{m}}_{B}\right)/2$$ is the average mass flow rate from port

**A**to port**B**.$${c}_{{p}_{avg}}$$ is the specific heat evaluated at the average temperature.

The heat transfer coefficient, *h*_{coeff}, depends
on the Nusselt number:

$${h}_{coeff}=Nu\frac{{k}_{avg}}{{D}_{h}}$$

where *k*_{avg} is the thermal conductivity evaluated
at the average temperature. The Nusselt number depends on the flow regime. The Nusselt
number in the laminar flow regime is constant and equal to the value of the
**Nusselt number for laminar flow heat transfer** parameter. The
Nusselt number in the turbulent flow regime is computed from the Gnielinski
correlation:

$$N{u}_{tur}=\frac{\frac{{f}_{Darcy}}{8}\left({\mathrm{Re}}_{avg}-1000\right){\mathrm{Pr}}_{avg}}{1+12.7\sqrt{\frac{{f}_{Darcy}}{8}}\left({\mathrm{Pr}}_{avg}^{2/3}-1\right)}$$

where *Pr*_{avg} is the Prandtl number evaluated at
the average temperature. The average Reynolds number is

$${\mathrm{Re}}_{avg}=\frac{\left|{\dot{m}}_{avg}\right|{D}_{h}}{S{\mu}_{avg}}$$

where *μ*_{avg} is the dynamic viscosity evaluated at
the average temperature. When the average Reynolds number is between the **Laminar
flow upper Reynolds number limit** and the **Turbulent flow lower
Reynolds number limit** parameter values, the Nusselt number follows a smooth
transition between the laminar and turbulent Nusselt number values.

### Saturation and Condensation

When the moist air volume reaches saturation, condensation may occur. The specific humidity at saturation is

$${x}_{wsI}={\phi}_{ws}\frac{{R}_{I}}{{R}_{w}}\frac{{p}_{wsI}}{{p}_{I}}$$

where:

*φ*_{ws}is the relative humidity at saturation (typically 1).*p*_{wsI}is the water vapor saturation pressure evaluated at*T*_{I}.

The rate of condensation is

$${\dot{m}}_{condense}=\{\begin{array}{ll}0,\hfill & \text{if}{x}_{wI}\le {x}_{wsI}\hfill \\ \frac{{x}_{wI}-{x}_{wsI}}{{\tau}_{condense}}{\rho}_{I}V,\hfill & \text{if}{x}_{wI}{x}_{wsI}\hfill \end{array}$$

where *τ*_{condense} is the value of the
**Condensation time constant** parameter.

The condensed water is subtracted from the moist air volume, as shown in the conservation equations. The energy associated with the condensed water is

$${\Phi}_{condense}={\dot{m}}_{condense}\left({h}_{wI}-\Delta {h}_{vapI}\right)$$

where *Δh*_{vapI} is the specific enthalpy of
vaporization evaluated at *T*_{I}.

Other moisture and trace gas quantities are related to each other as follows:

$$\begin{array}{l}{\phi}_{wI}=\frac{{y}_{wI}{p}_{I}}{{p}_{wsI}}\\ {y}_{wI}=\frac{{x}_{wI}{R}_{w}}{{R}_{I}}\\ {r}_{wI}=\frac{{x}_{wI}}{1-{x}_{wI}}\\ {y}_{gI}=\frac{{x}_{gI}{R}_{g}}{{R}_{I}}\\ {x}_{aI}+{x}_{wI}+{x}_{gI}=1\end{array}$$

### Choked Flow

The unchoked pressure at port **A** or **B** is
the value of the corresponding Across variable at that port:

$$\begin{array}{l}{p}_{{A}_{unchoked}}=\text{A}\text{.p}\\ {p}_{{B}_{unchoked}}=\text{B}\text{.p}\end{array}$$

However, the port pressure variables used in the momentum balance equations,
*p*_{A} and
*p*_{B}, do not necessarily coincide with
the pressure across variables `A.p`

and `B.p`

because the pipe outlet may choke. Choked flow occurs when the downstream pressure
is sufficiently low. At that point, the flow depends only on the conditions at the
inlet. Therefore, when choked, the outlet pressure
(*p*_{A} or
*p*_{B}, whichever is the outlet) cannot
decrease further even if the pressure downstream, represented by
`A.p`

or `B.p`

, continues to decrease.

Choking can occur at the pipe outlet, but not at the pipe inlet. Therefore, if
port **A** is the inlet, then
*p*_{A} = `A.p`

. If port
**A** is the outlet, then

$${p}_{A}=\{\begin{array}{ll}A.p,\hfill & \text{if}A.p\ge {p}_{{A}_{choked}}\hfill \\ {p}_{{A}_{choked}},\hfill & \text{if}A.p{p}_{{A}_{choked}}\text{}\hfill \end{array}$$

Similarly, if port **B** is the inlet, then
*p*_{B} = `B.p`

. If port
**B** is the outlet, then

$${p}_{B}=\{\begin{array}{ll}B.p,\hfill & \text{if}B.p\ge {p}_{{B}_{choked}}\hfill \\ {p}_{{B}_{choked}},\hfill & \text{if}B.p{p}_{{B}_{choked}}\text{}\hfill \end{array}$$

The choked pressures at ports **A** and **B**
are derived from the momentum balance by assuming the outlet velocity is equal to
the speed of sound:

$$\begin{array}{l}{p}_{{A}_{choked}}-{p}_{I}={p}_{{A}_{choked}}\left(\frac{{p}_{{A}_{choked}}{T}_{I}}{{p}_{I}{T}_{A}}-1\right)\frac{{c}_{{p}_{A}}}{{c}_{{v}_{I}}}+\Delta {p}_{AI}\\ {p}_{{B}_{choked}}-{p}_{I}={p}_{{B}_{choked}}\left(\frac{{p}_{{B}_{choked}}{T}_{I}}{{p}_{I}{T}_{B}}-1\right)\frac{{c}_{{p}_{B}}}{{c}_{{v}_{I}}}+\Delta {p}_{BI}\end{array}$$

### Variables

To set the priority and initial target values for the block variables prior to simulation, use
the **Initial Targets** section in the block dialog box or Property
Inspector. For more information, see Set Priority and Initial Target for Block Variables and Initial Conditions for Blocks with Finite Moist Air Volume.

### Assumptions and Limitations

The pipe wall is perfectly rigid.

The flow is fully developed. Friction losses and heat transfer do not include entrance effects.

The effect of gravity is negligible.

Fluid inertia is negligible.

This block does not model supersonic flow.

## Ports

### Output

### Conserving

## Parameters

## Model Examples

## References

[1] White, F. M., *Fluid
Mechanics*. 7th Ed, Section 6.8. McGraw-Hill, 2011.

[2] Cengel, Y. A., *Heat
and Mass Transfer – A Practical Approach*. 3rd Ed, Section 8.5.
McGraw-Hill, 2007.

## Extended Capabilities

## Version History

**Introduced in R2018a**