.. _section-5.7:

Cover Gas Flow and Pressure Calculations
----------------------------------------

.. _section-5.7.1:

Introduction
~~~~~~~~~~~~

After the hydraulics calculations for the liquid flows and pressures
have been completed for a time step, then the liquid temperatures are
calculated, and, after they have been completed, the cover gas flows and
pressures are computed. The cover gas treatment is a fully implicit
calculation, ignoring the inertial effects of the gas, and modeling the
flow as quasi-static and isothermal. It may be thought of as a
modification of the liquid flow treatment in which the left side of
:eq:`5.2-1` is set to zero and :math:`\theta_{1}` and :math:`\theta_{2}` set to zero and
one, respectively, in :eq:`5.2-17`.

The gas process may be thought of in the following way. Only
compressible volumes containing cover gas are considered. Some may also
contain liquid and some only gas. For those containing liquid, the
liquid level has risen or dropped, as determined by the hydraulics
calculations earlier in the time step, and the cover gas has been
compressed or expanded by this action. The compression or expansion is
assumed to be adiabatic, and new equilibrium conditions are calculated.
Next, heat transfer between the gas and the liquid is computed, assuming
that the gas temperature approaches that of the liquid without affecting
the liquid temperature. Finally, taking all compressible volumes with
cover gas, the gas flow between compressible volumes through connecting
pipes is computed, and the temperatures, pressures, and masses of the
gases in the compressible volumes are adjusted appropriately.

.. _section-5.7.2:

Basic Equations
~~~~~~~~~~~~~~~

In the compressible volumes with cover gas and liquid, the hydraulics
routines provide the rise or fall in the liquid level during the time
step, thereby giving the change in the cover gas volume during the time
step. Let :math:`V_{03}` be the volume of the cover gas before the
liquid level change and :math:`V_3` after the level change. The
process is assumed to be adiabatic, and the pressure :math:`{p'}_{03}`
after the change in terms of the pressure :math:`p_{03}` before is given
by

.. math::
    :label: 5.7-1

	{p'}_{03} = p_{03} \left( \frac{V_{03}}{V_{3}} \right)^{\gamma}

and the accompanying new gas temperature :math:`T_{\text{g}}` is given by the
ideal gas law as:

.. math::
    :label: 5.7-2

	T_{\text{g}} = {p'}_{03} \frac{V_{3}}{m_{3} R}

where

:math:`\gamma` = the ratio of the specific heat at constant pressure to that at
constant volume for the gas

:math:`m_3` = the cover gas mass at the beginning of the time step

:math:`R` = the universal gas constant

Heat transfer between the cover gas and the liquid is also accounted
for. Since the heat capacity of the gas is much less than that of the
liquid, it is assumed that the gas temperature approaches the liquid
temperature with a time constant :math:`\tau` without affecting the liquid
temperature. The time constant :math:`\tau` is a user-supplied input quantity.
The adjusted gas temperature :math:`T_{3}` is taken as

.. math::
    :label: 5.7-3

	T_{3} = T_{\text{g}} \frac{\tau}{\tau + \Delta t} + T_{1} \frac{\Delta t}{\tau + \Delta t}

where

:math:`T_{\text{l}}` = the temperature of the liquid

:math:`\Delta t` = the time step

The new gas temperature means a new gas pressure :math:`p_{3}`, which is
computed again by the ideal gas law as

.. math::
    :label: 5.7-4

	p_{3} = m_{3} \frac{RT_{3}}{V_{3}}

With :math:`p_{3}`, :math:`V_3`, :math:`T_{3}`, and :math:`m_{3}` now
known for compressible volumes with or without liquid present, we turn
to the gas flow through the pipes between compressible volumes. The
difference in pressure between two connected compressible volumes causes
gas flow from one to the other, and the amount of gas delivered to or
withdrawn from a compressible volume in turn modifies the gas pressure
in it. As a result, the pressure changes in all of the compressible
volumes are solved for simultaneously.

The gas mass flow rate, :math:`F_{\text{ij}}`, from compressible volume :math:`i` to
compressible volume :math:`j` is approximated at the end of the time step as

.. math::
    :label: 5.7-5

	F_{\text{ij}} = F_{\text{oij}} + F_{1\text{ij}} \Delta p\left( j \right) + F_{2\text{ij}} \Delta p\left( i \right)

Here :math:`F_{\text{oij}}` is the gas mass flow rate at the beginning of the
time step from compressible volume :math:`i` to compressible volume :math:`j`. This
flow rate is modified by the pressure changes in the compressible
volumes :math:`i` and :math:`j` as a result of the flow during the time step. The
coefficients of the pressure changes are taken as

.. math::
    :label: 5.7-6

	F_{1\text{ij}} =  \frac{- F_{\text{oij}}}{\left\lbrack p\left( i \right) - p\left( j \right) \right\rbrack}

.. math::
    :label: 5.7-7

	F_{2\text{ij}} = \frac{F_{\text{oij}}}{\left\lbrack p\left( i \right) - p\left( j \right) \right\rbrack}

where :math:`p \left(i \right) - p \left( j \right)` is the pressure difference between
compressible volumes :math:`i` and :math:`j` at the beginning of the time step. Also

.. math::
    :label: 5.7-8

	\Delta p\left( i \right) = p_{4}\left( i \right) - p_{3}\left( i \right)

where

:math:`p_{3} \left( i \right)` = the gas pressure in compressible volume :math:`i` at
the beginning of the time step

:math:`p_{4} \left( i \right)` = the gas pressure in compressible volume :math:`i` at
the end of the time step

The flow equation for isothermal unchoked flow of an ideal gas is given
by Shapiro [5-3] as:

.. math::
    :label: 5.7-9

	f \frac{L}{D_{\text{h}}} = \frac{1 - \left\lbrack \frac{p \left( i \right)}{p\left( j \right)} \right\rbrack^{2}}{\gamma  M^{2}} \ln{\left\lbrack \frac{p \left( i \right)}{p\left( j \right)} \right\rbrack}^{2}

where

:math:`f` = the Moody friction factor

:math:`L` = the length of the pipe

:math:`D_{\text{h}}` = the hydraulic diameter of the pipe

:math:`p \left( i \right)` = the inlet pressure

:math:`p \left( j \right)` = the outlet pressure

:math:`\gamma` = the ratio of the specific heat at constant pressure to that at
constant volume for the gas

:math:`M` = the Mach number

The Moody [5-2] friction factor is given by:

.. math::
    :label: 5.7-10

	f = 0.0055 \left\lbrack 1 + \left( 20000 \frac{\varepsilon}{D} + \frac{10^{6}}{\text{Re}} \right)^{1/3} \right\rbrack

where

:math:`\varepsilon` = the pipe roughness

:math:`D` = the pipe diameter

:math:`\text{Re}` = the Reynolds number

In addition the Reynolds number can be written as

.. math::
    :label: 5.7-11

	\text{Re} = \frac{F_{\text{oij}}}{A} \frac{D}{\mu}

where

:math:`A` = the pipe area

:math:`\mu` = the viscosity of the gas

and the Mach number is related to the gas mass flow rate :math:`F_{\text{oij}}`
by

.. math::
    :label: 5.7-12

	\gamma M^{2} = \left( \frac{F_{\text{oij}}}{A} \right)^{2} \frac{RT}{\gamma}

For turbulent flow, the gas mass flow rate is determined by an iterative
process. With an initial built-in guessed value for :math:`f`, :eq:`5.7-9` and
:eq:`5.7-12` determine a value for :math:`F_{\text{oij}}`, which is used in
:eq:`5.7-10` to calculate a new value for :math:`f`, and the iteration is continued
until consistency is achieved. For laminar flow, :math:`F_{\text{oij}}` is
determined from :eq:`5.7-9` and :eq:`5.7-12` using the laminar flow value for
:math:`f` of

.. math::
    :label: 5.7-13

	f = \frac{64}{\text{Re}}

.. _section-5.7.3:

Solution
~~~~~~~~

The results of the gas flow between compressible volumes, where a
compressible volume may be connected by gas segments to several other
compressible volumes, can be written as:

.. math::
    :label: 5.7-14

	p_{4}\left( i \right) = p_{3}\left( i \right) \left( 1 + \varepsilon_{\text{i}} \right)

.. math::
    :label: 5.7-15

	m_{4} \left( i \right) = m_{3}\left( i \right) + \delta m_{\text{i}}

.. math::
    :label: 5.7-16

	T_{4}\left( i \right) = \frac{p_{4} \left( i \right) V_{4} \left( i \right)}{m_{4} \left( i \right) R}

where

.. math::
    :label: 5.7-17

	\varepsilon_{\text{i}} = \frac{\gamma}{m_{3} \left( i \right) T_{3}\left( i \right)} \sum_{\text{j}}{T_{\text{ji}} \Delta m_{\text{ji}}}

.. math::
    :label: 5.7-18

	\delta m_{\text{i}} = m_{4} \left( i \right) - m_{3} \left( i \right) = \sum_{\text{j}}{\Delta m_{\text{ji}}}

.. math::
    :label: 5.7-19

	\Delta m_{\text{i}} = \Delta t \left\lbrack F_{\text{oji}} + F_{1\text{ji}} \Delta p \left( i \right) + F_{2\text{ji}} \Delta p\left( j \right) \right\rbrack

and :math:`T_{\text{ji}}` is the temperature of the gas flowing from
compressible volume :math:`j` to compressible volume :math:`i`. Combining :eq:`5.7-14`,
:eq:`5.7-8`, :eq:`5.7-17`, and :eq:`5.7-19` yields a matrix equation of the form

.. math::
    :label: 5.7-20

	\begin{pmatrix}
    c_{11} & c_{12} & \text{......} \\
    c_{21} & c_{22} & \text{......} \\
    \text{......} & \text{......} & \text{......} \\
    \text{......} & \text{......} & \text{......} \\
    \end{pmatrix} \begin{pmatrix}
    \Delta p\left( 1 \right) \\
    \Delta p\left( 2 \right) \\
    \text{......} \\
    \text{......} \\
    \end{pmatrix} = \ \begin{pmatrix}
    d_{1} \\
    d_{2} \\
    \text{......} \\
    \text{......} \\
    \end{pmatrix}

where

.. math::
    :label: 5.7-21

	c_{\text{ij}} = \delta_{\text{ij}} \left\lbrack 1 - \frac{p_{3} \left( i \right) \gamma \Delta t}{m_{3} \left( i \right) T_{3} \left( i \right)} \sum_{\text{k}}{T_{\text{ki}} F_{1\text{ki}}} \right\rbrack
	- \frac{p_{3} \left( i \right) \gamma \Delta t}{m_{3} \left( i \right) T_{3} \left( i \right)} T_{\text{ji}} F_{2\text{ji}}

and

.. math::
    :label: 5.7-22

	d_{\text{i}} = \frac{p_{3} \left( i \right) \gamma \Delta t}{m_{3} \left( i \right) T_{3} \left( i \right)} \sum_{\text{j}}{T_{\text{ji}} F_{\text{oji}}}

Here :math:`\delta_{\text{ij}}` is the Kronecker delta.

The matrix equation 5.7-20 is solved by Gaussian elimination for the
:math:`\Delta p \left( i \right)`. These are added to the pressures at the beginning of the time
step to obtain the corresponding pressures at the end of the time step.
The cover gas mass at the end of the time step :math:`m_4 \left( i \right)` in
each compressible volume is computed using :eq:`5.7-18` and :eq:`eq-5.4-19`, and
finally the gas temperatures at the end of the time step
:math:`T_{4} \left( i \right)` are computed for each compressible volume using the
equation

.. math::
    :label: 5.7-23

	T_{4}\left( i \right) = \frac{p_{4} \left( i \right) V_{4} \left( i \right)}{m_{4} \left( i \right) R}

All of the final values are then stored in COMMON blocks.

A solution algorithm for the entire cover gas treatment is given in
:numref:`section-A5.3`.