.. _section-5.2:

Hydraulic Calculations
----------------------

.. _section-5.2.1:

Compressible Volumes and Liquid Segments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The primary and intermediate loop thermal hydraulics calculations use a
generalized geometry, as indicated in :numref:`figure-5.2-1`. A number of
compressible volumes are connected by liquid or gas segments, and each
liquid segment can contain one or more elements. The treatment allows
compressible volumes and segments to be connected in an arbitrary
manner. :numref:`table-5.2-1` lists the types of compressible volumes used in
PRIMAR-4. Compressible volumes are characterized by pressure, volume,
mass, and temperature. They can accumulate liquid or gas by compressing
the cover gas or the liquid, and it is the pressure in the compressible
volumes that drives the flows through the liquid and gas segments. :numref:`table-5.2-2` lists the types of elements that can make up a liquid segment.
Liquid flow elements are characterized by incompressible single-phase
flow, with the possible exception of the core element. The core
subassemblies, which are treated by the coolant dynamics modules, are
a special case and are discussed in :numref:`section-5.2.2`.

.. _figure-5.2-1:

..  figure:: media/image3.png
	:align: center
	:figclass: align-center

	PRIMAR-4 Generalized Geometry.

.. _table-5.2-1:

.. list-table:: Compressible Volume Types Used in PRIMAR-4
    :header-rows: 1
    :align: center
    :widths: auto

    * - Type Number
      - Description
    * - 1
      - Inlet plenum
    * - 2
      - Compressible liquid volume, no cover gas
    * - 3
      - Closed outlet plenum, no cover gas
    * - 4
      - Almost incompressible liquid junction, no cover gas
    * - 5
      - Pipe rupture source
    * - 6
      - Pipe rupture sink, guard vessel
    * - 7
      - Outlet plenum with cover gas
    * - 8
      - Pool
    * - 9
      - Pump bowl and cover gas
    * - 10
      - Expansion tank with cover gas
    * - 11
      - Compressible gas volume, no liquid

|

.. _table-5.2-2:

.. list-table:: Liquid Flow Element Types Used in PRIMAR-4
    :header-rows: 1
    :align: center
    :widths: auto

    * - Type Number
      - Description
    * - 1
      - Core subassemblies, SAS channels
    * - 2
      - Core bypass assemblies
    * - 3
      - Pipe
    * - 4
      - Check valve
    * - 5
      - Pump
    * - 6
      - IHX, shell side
    * - 7
      - IHX, tube side
    * - 8
      - Steam generator, sodium side
    * - 9
      - DRACS heat exchanger, tube side
    * - 10
      - DRACS heat exchanger, shell side
    * - 11
      - Valve
    * - 12
      - Air dump heat exchanger, sodium side
    * - 13
      - Annular element
    * - 15
      - Annular pump

The hydraulic equations for the primary and intermediate heat-transport
loops are solved by a semi-implicit or fully implicit time differencing
scheme in which the pressures and flows for all connected compressible
volumes and segments are solved for simultaneously. By linearizing the
equations for each time step, a semi-implicit or fully implicit solution
can be obtained without resorting to iteration techniques. Linearized
semi-implicit or fully implicit methods are most useful for long
transients in which temperatures and flows change slowly, since in such
cases accurate results can be obtained with large time steps so long as
the step sizes are small enough that changes during a step are small.

Three equations are used in calculating the pressures in the
compressible volumes and the flow rates in the connecting liquid
segments. They are the momentum equation for incompressible single-phase
flow in a segment, an expression for the average flow rate in a segment
during a time step, and an expression for the change in pressure in a
compressible volume as a result of flow into it and out from it during a
time step. Each of these equations is taken up in turn.

.. _section-5.2.1.1:

Momentum Equation
^^^^^^^^^^^^^^^^^

The momentum equation for a single-phase incompressible liquid is taken
as

.. math::
    :label: 5.2-1

	\frac{1}{A}\frac{\partial \text{w}}{\partial \text{t}} + \frac{1}{A^{2}}\frac{\partial}{\partial \text{z}}\left( \frac{w^{2}}{\rho} \right) + \frac{\partial \text{p}}{\partial \text{z}} + \left( \frac{\partial \text{p}}{\partial \text{z}} \right)_{\text{loss}} = 0

where

:math:`w` = the mass flow rate

:math:`A` = the flow area

:math:`\rho` = the density of the liquid

:math:`\frac{\partial \text{p}}{\partial \text{z}}` = the pressure gradient driving
the flow

:math:`\left( \frac{\partial \text{p}}{\partial \text{z}} \right)_{\text{loss}}` =
the pressure drop from all of the loss terms

When :eq:`5.2-1` is integrated over a segment containing several elements,
it can be written as the basic equation for the flow in segment :math:`i`:

.. math::
    :label: 5.2-2

	\sum_{\text{k}}{ \frac{L_{\text{k}}}{A_{\text{k}}}} \frac{\text{dw}\left( i \right)}{\text{dt}}  =  p_{\text{in}}\left( i \right)
	-  p_{\text{out}}\left( i \right)  -  \Delta p_{\text{fr}}\left( i \right)  -  \Delta p_{\text{w}2}\left( i \right)  - \Delta p_{K_{in}}\left( i \right) -  \Delta p_{\text{v}}\left( i \right)  -  \Delta p_{\text{gr}}\left( i \right)  + \Delta p_{\text{p}}\left( i \right)

Here, :math:`\text{dw} \left( i \right) / \text{dt}` is the time rate of change of the mass flow
rate through segment :math:`i`. The summation is over the elements in segment
:math:`i`, and :math:`L_{\text{k}}` and :math:`A_{\text{k}}` are the length and flow area of
element :math:`k`. The term :math:`p_{\text{in}} \left( i \right)` is the pressure at the inlet
to segment :math:`i`, which is the pressure in the compressible volume at the
inlet of segment :math:`i`. The term :math:`p_{\text{out}} \left( i \right)` is the pressure at
the outlet of segment :math:`i`, or in the compressible volume at the outlet
of segment :math:`i`. The term :math:`\Delta p_{\text{fr}} \left( i \right)` is the frictional
pressure change for the segment :math:`i`, and with the minus sign in
:eq:`5.2-2`, it is a loss term. However, this frictional loss term for the
segment is actually the sum of similar loss terms for each element in
the segment. The same things can be said about the remaining terms in
:eq:`5.2-2`. Together with their respective signs,
:math:`\Delta p_{\text{w}2} \left( i \right)` is any orifice or bend pressure drop
proportional to the square of the mass flow rate,
:math:`\Delta p_{\text{v}} \left( i \right)` is any valve pressure drop,
:math:`\Delta p_{\text{gr}} \left( i \right)` is the gravity-head pressure drop, and
:math:`\Delta p_{\text{p}} \left( i \right)` is the pump-head pressure increase from all of
the pumps in segment :math:`i`.

In :eq:`5.2-2`, :math:`\Delta p_{K_{in}} \left( i \right)` is the minor pressure loss that occurs at the inlet of the segment.
This term is defined as

.. math::
    :label: 5.2-2b

	\Delta p_{K_{in}}\left( i \right) = K_{in}\left(Re_{in}\right) \frac{w \left| w \right|}{2\rho A_{in}^{2}}

where :math:`K_{out}\left(Re_{out}\right)` is the anisotropic Re-dependent loss coefficient
at the inlet of segment :math:`i`, :math:`Re_{in}` is the Re number at the inlet of segment :math:`i`
and :math:`A_{in}` is the area at the inlet of segment :math:`i`.
Anisotropic Re-dependent loss coefficients at segment inlets are defined using
:sasinp:`SegLossCoefTableID` and additional information can be found in :numref:`section-LossCoeff-P4`.

:eq:`5.2-2` has the form:

.. math::
    :label: 5.2-3

	\sum_{\text{k}}{\frac{L_{\text{k}}}{A_{\text{k}}}} \frac{\text{dw}\left( i \right)}{\text{dt}} = f \left( w,t \right)

which can be written in finite difference form

.. math::
    :label: 5.2-4

	\sum_{\text{k}}\frac{L_{\text{k}}}{A_{\text{k}}}\frac{\Delta w \left( i \right)}{\Delta t} = \theta_{\text{1}}\left( i \right)f_{\text{i}}\left( w,t \right) + \theta_{2}\left( i \right)f_{\text{i}}(w + \Delta w,t + \Delta t)

where :math:`\theta_1 +\theta_2 = 1`. The parameters :math:`\theta_1`
and :math:`\theta_2` determine the degree of implicitness of the solution.
For a fully explicit solution, :math:`\theta_1 = 1` and :math:`\theta_2 = 0`.
For a fully implicit solution :math:`\theta_1 = 0` and :math:`\theta_2 = 1`.
The degree of implicitness is discussed in :numref:`section-5.2.4` and in :numref:`section-A3.1` in :numref:`Chapter %s<section-3>`.

The linearization consists in making the approximation that

.. math::
    :label: 5.2-5

	f\left( w + \Delta w,t + \Delta t \right) = f\left( w,t \right) + \Delta t\frac{\partial \text{f}}{\partial \text{t}} + \Delta w\frac{\partial \text{f}}{\partial \text{w}}

so the flow equation becomes

.. math::
    :label: 5.2-6

	\sum_{\text{k}}{\frac{L_{\text{k}}}{A_{\text{k}}}} \Delta w \left( i \right) = \Delta t \left\{ f \left( w,t \right) + \theta_{2}\left( i \right) \left\lbrack \Delta t \frac{\partial \text{f}}{\partial \text{t}} + \Delta w\frac{\partial \text{f}}{\partial \text{w}} \right\rbrack \right\}

which takes the form

.. math::
    :label: 5.2-7

	a_{0}\left( i \right) \Delta w\left( i \right)  =  a_{1}\left( i \right)  +  \theta_{2}\left( i \right) \left\{ a_{2}\left( i \right)  +  \Delta t \left\lbrack \Delta p\left( ji \right)  -  \Delta p\left( jo \right)  \right\rbrack  +  a_{3}\left( i \right) \Delta w\left( i \right)  \right\}

or

.. math::
    :label: 5.2-8

	\Delta w \left( i \right)  =  \frac{a_{1}\left( i \right)  +  \theta_{2}\left( i \right) \left\{ a_{2} \left( i \right)  +  \Delta t \left\lbrack \Delta p\left( ji \right)  -  \Delta p\left( jo \right) \right\rbrack  \right\}}{a_{0}\left( i \right)  -  \theta_{2}\left( i \right) a_{3}\left( i \right)}

where :math:`ji` and :math:`jo` are the compressible volumes at the inlet and outlet
of the liquid segment.

In general, the :math:`a`'s are sums of contributions from each element, :math:`k`,
in the segment. The terms are

.. math::
    :label: 5.2-9

	a_{0} = \sum_{\text{k}}{\Delta a_{0}\left( k \right)}

.. math::
    :label: 5.2-10

	\Delta a_{0}\left( k \right) = \frac{L_{\text{k}}}{A_{\text{k}}}

.. math::
    :label: 5.2-11

	a_{1} = \Delta t\left\lbrack p\left( ji,t \right) - p\left( jo,t \right) \right\rbrack - \Delta t \Delta p_{K_{in}} + \sum_{\text{k}}{\Delta a_{1}\left( k \right)}

.. math::
    :label: 5.2-12

	\Delta a_{1}\left( k \right) = \left\lbrack - \Delta p_{\text{fr}}\left( k,t \right) - \Delta p_{\text{gr}}\left( k,t \right) - \Delta p_{\text{w}2}\left( k,t \right) -  \Delta p_{\text{v}}\left( k,t \right) + \Delta p_{\text{p}}\left( k,t \right) \right\rbrack \Delta t

.. math::
    :label: 5.2-13

	a_{2} = \sum_{\text{k}}{\Delta a_{2}\left( k \right)}

.. math::
    :label: 5.2-14

	\Delta a_{2}\left( k \right) = \Delta t^{2}\frac{\partial}{\partial \text{t}}\lbrack\Delta p_{\text{P}}\left( k \right) - \Delta p_{\text{fr}}\left( k \right) - \Delta p_{\text{w}2}\left( k \right) - \Delta p_{\text{v}}\left( k \right) - \Delta p_{\text{gr}}\left( k \right)\rbrack

.. math::
    :label: 5.2-15

	a_{3} = - \Delta t \frac{\partial \Delta p_{K_{in}}}{\partial w} + \sum_{\text{k}}{\Delta a_{3}\left( k \right)}

and

.. math::
    :label: 5.2-16

    \frac{\partial \Delta p_{K_{in}}}{\partial w}  =   2\frac{\Delta p_{K_{in}}}{w} + \frac{\Delta p_{K_{in}}}{K_{in}(Re_{in})} \frac{\partial Re_{in}}{\partial \text{w}}   \frac{\partial K_{in}}{\partial Re_{in}}

    \Delta a_{3}\left( k \right) = \Delta t \frac{\partial}{\partial \text{w}} \left\lbrack  \Delta p_{\text{p}}\left( k \right) - \Delta p_{\text{fr}}\left( k \right) - \Delta p_{\text{w}2}\left( k \right) -  \Delta p_{\text{v}} \left( k \right) -  \Delta p_{\text{gr}}\left( k \right) \right\rbrack

In the above equations, it should be recognized that :math:`\Delta` is used in three
different ways. First :math:`\Delta t` is the time step, :math:`\Delta w \left( i \right)` is the
change in the mass flow rate in the liquid segment :math:`i` during the time
step, and :math:`\Delta p \left( ij \right)` and :math:`\Delta p \left( jo \right)` are the changes in pressures
in the compressible volumes at the inlet and outlet ends of liquid
segment :math:`i` during the time step. Second, the :math:`\Delta p`'s in :eq:`5.2-2`
represent pressure differences, increases or decreases, along liquid
segment :math:`i`. And third, as seen in :eq:`5.2-9`, :eq:`5.2-11`, :eq:`5.2-13`, and :eq:`5.2-15`,
the :math:`\Delta a`'s are incremental contributions form each of the elements to
the :math:`a`'s for the whole segment.

The denominator in :eq:`5.2-8` should never be zero because :math:`a_3`
is negative or zero, since friction increases with increased flow and
pump head decreases with increased flow.

.. _section-5.2.1.2:

Average Flow Rate
^^^^^^^^^^^^^^^^^

The second main equation used in the hydraulics calculation is an
expression for the average mass flow rate in a liquid segment during a
time step. The average mass flow rate  for segment :math:`i` is taken as a
simple average of the flow rate at the beginning of the time step and
that at the end of the time step.

.. math::
    :label: 5.2-17

	\overline{w}\left( i \right) = \frac{\left\lbrack w \left( i,t \right) + w \left( i,t + \Delta t \right) \right\rbrack}{2}

Linearization consists in expanding :math:`w \left( i,t + \Delta t \right)` to two terms
and finite differencing the time derivative to give

.. math::
    :label: 5.2-18

	\overline{w} \left( i \right) = \frac{2 w \left( i,t \right) + \Delta w \left( i \right)}{2}

:eq:`5.2-18` relates the average mass flow rate in a segment during a
time step to the change in the mass flow rate during that time step.

.. _section-5.2.1.3:

Compressible Volume Pressure Changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The third main equation in the hydraulics calculations is an expression
for the change in pressure in a compressible volume during a time step.
The pressure in a compressible volume can be affected in several ways.
Liquid can flow in or out through the segments connecting the
compressible volumes. The entering liquid may be at a higher or lower
temperature than that already there, and the liquid flowing out removes
liquid at the compressible volume temperature. In addition to the
changes related to the liquid flows, the compressible volumes can be
heated or cooled externally, or liquid can be added or withdrawn by an
external agent. The flow of cover gas into or out of the compressible
volume will also affect the pressure. The cover gas flows are treated
separately, as in :numref:`section-5.7`.

The pressure in a compressible volume is assumed to vary linearly with
changes in the mass or temperature of the liquid. Therefore, the change
:math:`\Delta p \left( j \right)` in pressure in the compressible volume :math:`j` during a time
step is taken as a linear approximation in the average mass flow rates
into and out from that compressible volume as:

.. math::
    :label: 5.2-19

    \Delta p\left( j \right) = b_{0}\left( j \right) + b_{1}\left( j \right)\left\lbrack \sum{{\overline{w}}_{\text{in}}\left( j \right)
    - \sum{{\overline{w}}_{\text{out}}\left( j \right) }} \right\rbrack + b_{2}\left( j \right) \left\lbrack \sum{{\overline{w}}_{\text{in}}\left( j \right) T_{\text{in}} - \sum{{\overline{w}}_{\text{out}} T_{\text{out}}\left( j \right)}} \right\rbrack

Here
:math:`\sum{\overline{w}}_{\text{in}}\left( j \right)`
is the sum of the average mass flow rates into compressible volume :math:`j`
from all of the attached liquid segments flowing into it. It should be
noticed that :eq:`5.2-18` is the expression for the average mass flow rate
in a segment, and if that segment flows into compressible volume :math:`j`,
then it is included with all of the other segment contributions to
compressible volume :math:`j`.
Similarly, :math:`\sum{\overline{w}}_{\text{out}}\left( j \right)`
is the sum of the average mass flow rates out of the compressible volume
:math:`j` from all of the attached liquid segments flowing out. The last two
sums in :eq:`5.2-19` are the same as the ones just described except that
all of the mass flow rates are multiplied by the temperatures of the
flows: the average mass flow rates flowing into the compressible volume
are multiplied by the temperatures in the respective segments, whereas
the average mass flow rates flowing out are each multiplied by the
temperature in the compressible volume. The coefficients
:math:`b_1 \left( j \right)` and :math:`b_2 \left( j \right)` include the time-step size
and are computed for each type of compressible volume. The remaining
term :math:`b_0 \left( j \right)` also contains the time step size and can be
used to account for the effects of heat transfer to the compressible
volume liquid from the compressible volume wall or from other
components.

.. _section-5.2.2:

Estimated Core Flow
~~~~~~~~~~~~~~~~~~~

The liquid segments representing the core channels are a special case.
In principle, the coolant mass flow rates in the core channels could be
calculated simultaneously along with the other segments in the primary
loop. But after the onset of boiling in the core, this would unduly
complicate the boiling model. Instead, an estimate of the core mass
flow rates is made from information stored by the core channel coolant
dynamics routines during the previous time step, and this estimated flow
is included in the primary loop calculation. After the primary and
intermediate loop hydraulics calculations have been done, the core
channel coolant dynamics routines compute the actual channel flows for
each channel independently, using the newly calculated inlet and outlet
plenum pressures as boundary conditions. Then, the differences between
the estimated core flow and the actual computed core flow for a time
step is used to adjust the coolant masses in the inlet and outlet
plenums before the start of the calculations for the next time step.

The mass flow rate for core channel :math:`ic` at the end :math:`L`, where :math:`L = 1`
is the inlet and :math:`L = 2` is the outlet, is estimated by the momentum
equation

.. math::
    :label: 5.2-20

    \frac{dw_{\text{c}}\left( L,ic \right)}{\text{dt}} = C_{0}\left( L,ic \right) + C_{1}\left( L,ic \right) p\left( \text{JIN} \right) + C_{2}\left( L,ic \right) p \left( \text{JX} \right) + C_{3} \left( L,ic \right)  dp_c\left( L,ic \right)

where :math:`p \left( \text{JIN} \right)` is the pressure in the compressible volume
representing the inlet plenum, :math:`p \left( \text{JX} \right)` is the pressure in the
compressible volume representing the outlet plenum, and :math:`dp_c\left( L,ic \right)`
is the pressure drop from the core channel inlet to outlet. The rate of change
of the mass flow rate is taken as proportional to the inlet and outlet
pressures and the pressure drop across the core channel. The
coefficients :math:`C_0`, :math:`C_1`, :math:`C_2`, and
:math:`C_3` are the information stored during the previous time step,
and are described in :numref:`section-3.12` of :numref:`Chapter %s<section-3>`. The channel mass flow
rate :math:`w_{\text{c}} \left( L,ic \right)` is evaluated at the beginning of the time
step.

:eq:`5.2-20` can be written in finite difference form as

.. math::
    :label: 5.2-21-a

    \frac{\Delta w_{\text{c}}\left( L,ic \right)}{\Delta \text{t}} = C_{0}\left( L,ic \right)
    + C_{1} \left( L,ic \right) \left( \theta_{1c} p \left( \text{JIN} \right) + \theta_{2c} \left(p\left( \text{JIN} \right) + \Delta p\left( \text{JIN} \right) \right) \right) \\
    + C_{2} \left( L,ic \right) \left( \theta_{1c} p \left( \text{JX}  \right) + \theta_{2c} \left(p\left( \text{JX}  \right) + \Delta p\left( \text{JX}  \right) \right)  \right) \\
    + C_{3} \left( L,ic \right) \left( \theta_{1c} dp_c\left( L,ic \right) + \theta_{2c} \left(  dp_c\left( L,ic \right) + \Delta dp_c\left( L,ic \right)\right)\right)

By redefining  :math:`C_{0}\left( L,ic \right)` and :math:`C_{3}\left( L,ic \right)`,

.. math::
    :label: 5.2-21-b

    C_{0}'\left( L,ic \right) = C_{0}\left( L,ic \right) + C_{3} dp_c\left( L,ic \right)

and

.. math::
    :label: 5.2-21-c

    C_{3}'\left( L,ic \right) = \frac{C_{3}\left( L,ic \right)}{2 w_{\text{c}}\left( L,ic \right)} \frac{\Delta dp_c\left( L,ic \right)}{\Delta w_{\text{c}}\left( L,ic \right)}

:eq:`5.2-21-a` can be simplified to

.. math::
    :label: 5.2-21-d

    \frac{\Delta w_{\text{c}}\left( L,ic \right)}{\Delta \text{t}} = C_{0}'\left( L,ic \right)
    + C_{1} \left( L,ic \right) \left( p \left( \text{JIN} \right) + \theta_{2c}  \Delta p\left( \text{JIN} \right)  \right) \\
    + C_{2} \left( L,ic \right) \left( p \left( \text{JX}  \right) + \theta_{2c}  \Delta p\left( \text{JX}  \right)  \right) \\
    + 2 \theta_{2c} C_{3}' \left( L,ic \right) w_{\text{c}}\left( L,ic \right) \Delta w_{\text{c}}\left( L,ic \right)

or

.. math::
    :label: 5.2-21

    \Delta w_{\text{c}}\left( L,ic \right) = \frac{\Delta t}{1 - 2\theta_{2\text{c}}\left( L,ic \right)C_{3}'\left( L,ic \right)w_{\text{c}}\left( L,ic \right)\Delta t} \left\{ C_{0}' \left( L,ic \right) \right. \\ \left.
    + C_{1}\left( L,ic \right)\left\lbrack p\left( \text{JIN},t \right) + \theta_{2\text{c}}\left( L,ic \right) \Delta p \left( \text{JIN} \right) \right\rbrack \right. \\ \left.
    + C_{2}\left( L,ic \right)\left\lbrack p\left( \text{JX},t \right) + \theta_{2\text{c}}\left( L,ic \right) \Delta p \left( \text{JX} \right) \right\rbrack \right\}

where :math:`\theta_{2\text{c}}` is the degree of implicitness for core channel
:math:`ic`. :eq:`5.2-21` plays the role for each core channel that
:eq:`5.2-8` does for all the other liquid segments in the primary loop.

Before boiling begins in the core channels, the differences between the
estimated and the actual core flows are very small, largely because
:eq:`5.2-20` is equivalent to the equation used by the pre-boiling core
channel coolant dynamics routines, except that the coefficients in
:eq:`5.2-20` do not account for the effects of coolant temperature changes
during the current time step. After boiling begins, rapid changes in
vapor pressures cause rapid changes in the inlet plenum pressure,
necessitating a decrease in the time step size.

.. _section-5.2.3:

Method of Solution
~~~~~~~~~~~~~~~~~~

:eq:`5.2-8`, :eq:`5.2-18`, :eq:`5.2-19`, and :eq:`5.2-21` constitute a set of
simultaneous equations for changes in the mass flow rates :math:`\Delta w \left( i \right)`
in the liquid segments and for changes in the pressures :math:`\Delta p \left( j \right)` in
the compressible volumes during a time step. Eliminating the :math:`\Delta w`'s,
these equations can be written as a single matrix equation for the
:math:`\Delta p`'s:

.. math::
    :label: 5.2-22

	\sum_{\text{J}}{c\left( I,J \right) \Delta p\left( J \right) = d\left( I \right)}

The coefficients :math:`c \left( I,J \right)` and :math:`d \left( I \right)` are sums of contributions
:math:`\Delta c \left( I,J \right)` and :math:`\Delta d \left( I \right)` from each segment. From segment :math:`i`,
in which the flow is from compressible volume :math:`I` to compressible volume
:math:`J`, the contribution to :math:`c \left( I,J \right)` is

.. math::
    :label: 5.2-23

	\Delta c\left( I,J \right) = \frac{- \theta_{2}\left( i \right) \left\lbrack b_{1}\left( J \right) + b_{2}\left( J \right) T_{\text{out}}\left( i \right) \right\rbrack \Delta t}{2 \left\lbrack a_{0}\left( i \right) - a_{3}\left( i \right) \theta_{2}\left( i \right) \right\rbrack}

and the contribution to :math:`c \left( J,I \right)` is

.. math::
    :label: 5.2-24

	\Delta c\left( J,I \right) = \frac{- \theta_{2}\left( i \right) \left\lbrack b_{1}\left( I \right) + b_{2}\left( I \right) T_{\text{in}}\left( i \right) \right\rbrack \Delta t}{2 \left\lbrack a_{0}\left( i \right) - a_{3}\left( i \right) \theta_{2}\left( i \right) \right\rbrack}

The contribution to :math:`d \left( J \right)` is

.. math::
    :label: 5.2-25

	\Delta d \left( J \right) = w\left( i,t \right) + \frac{a_{1}\left( i \right) + \theta_{2}\left( i \right) a_{2}\left( i \right)}{2 \left\lbrack a_{0}\left( i \right) - \theta_{2}\left( i \right) a_{3}\left( i \right) \right\rbrack} \left\lbrack b_{1}\left( J \right) + b_{2}\left( J \right) T_{\text{out}}\left( i \right) \right\rbrack

and the contribution to :math:`d \left( I \right)` is

.. math::
    :label: 5.2-26

	\Delta d\left( I \right) = - w \left( i,t \right) -  \frac{a_{1}\left( i \right) + \theta_{2}\left( i \right) a_{2}\left( i \right)}{2 \left\lbrack a_{0}\left( i \right) - \theta_{2}\left( i \right) a_{3}\left( i \right) \right\rbrack} \left\lbrack b_{1}\left( I \right) + b_{2}\left( I \right) T_{\text{in}}\left( i \right) \right\rbrack

The contributions to diagonal terms are

.. math::
    :label: 5.2-27

	\Delta c\left( I,I \right) = \frac{\theta_{2}\left( i \right) \left\lbrack b_{1}\left( I \right) + b_{2}\left( I \right) T_{\text{in}}\left( i \right) \right\rbrack \Delta t}{2 \left\lbrack a_{0}\left( i \right) - \theta_{2}\left( i \right) a_{3}\left( i \right) \right\rbrack}

and

.. math::
    :label: 5.2-28

	\Delta c \left( J,J \right) = \frac{\theta_{2}\left( i \right) \left\lbrack b_{1}\left( J \right) + b_{2}\left( J \right) T_{\text{out}}\left( i \right) \right\rbrack \Delta t}{2 \left\lbrack a_{0}\left( i \right) - \theta_{2}\left( i \right) a_{3}\left( i \right) \right\rbrack}

Also, :math:`b_0 \left( J \right)` is added to :math:`d \left( J \right)` and 1.0 is added to
the diagonal terms in :math:`c`. In these equations :math:`T_{\text{in}} \left( i \right)` and
:math:`T_{\text{out}} \left( i \right)` are the temperatures at the inlet and outlet of
the liquid segment.

The contributions to the coefficients :math:`c \left( I,J \right)` and :math:`d \left( I \right)` from
the segments representing the core channel flows are obtained from
:eq:`5.2-21`, which is re-written as

.. math::
    :label: 5.2-29

	\Delta w_{\text{c}}\left( L,ic \right) = e_{0}\left( L,ic \right) + e_{1}\left( L,ic \right) \Delta p \left( \text{JIN} \right) + e_{2}\left( L,ic \right) \Delta p \left( \text{JX} \right)

where

.. math::
    :label: 5.2-30

    e_{0} \left( L,ic \right) = \frac{\Delta t}{d_{\text{n}}}\left\lbrack C_{0}\left( L,ic \right) + C_{1}\left( L,ic \right) p \left( \text{JIN},t \right) + C_{2}\left( L,ic \right) p \left( \text{JX},t \right) \right. \\ \left.
    + C_{3}\left( L,ic \right) w_{\text{c}}\left( L,ic \right) \left| w_{\text{c}}\left( L,ic \right) \right| \right\rbrack

.. math::
    :label: 5.2-31

    e_{1} \left( L,ic \right) = \frac{\theta_{2\text{c}}\left( L,ic \right) \Delta t C_{1} \left( L,ic \right)}{d_{\text{n}}}

.. math::
    :label: 5.2-32

    e_{2} \left( L,ic \right) = \frac{\theta_{2\text{c}}\left( L,ic \right) \Delta t C_{2} \left( L,ic \right)}{d_{\text{n}}}

and

.. math::
    :label: 5.2-33

    d_{\text{n}} = 1 - 2 \theta_{2 \text{c}} \left( L,ic \right) C_{3} \left( L,ic \right) \left|  w_{\text{c}} \left( L,ic \right)  \right| \Delta t

The contribution to :math:`d \left( \text{JIN} \right)` is then

.. math::
    :label: 5.2-34

    \Delta d \left( \text{JIN} \right) = - \left\lbrack b_{1}\left( \text{JIN} \right) + b_{2} \left( \text{JIN} \right) T_{\text{in}} \left( ic \right) \right\rbrack \left\lbrack w_{\text{c}} \left( 1,ic \right) + \frac{e_{0}\left( 1,ic \right)}{2} \right\rbrack

also,

.. math::
    :label: 5.2-35

    \Delta d \left( \text{JX} \right) = \left\lbrack b_{1}\left( \text{JX} \right) + b_{2} \left( \text{JX} \right) T_{\text{out}} \left( ic \right) \right\rbrack \left\lbrack w_{\text{c}}\left( 2,ic \right) + \frac{e_{0} \left( 2,ic \right)}{2} \right\rbrack

.. math::
    :label: 5.2-36

    \Delta c \left( \text{JIN},\text{JIN} \right) = \left\lbrack b_{1}\left( \text{JIN} \right) + b_{2}\left( \text{JIN} \right) T_{\text{in}} \left( ic \right) \right\rbrack \frac{e_{1}\left( 1,ic \right)}{2}

.. math::
    :label: 5.2-37

    \Delta c \left( \text{JX},\text{JX} \right) =  - \left\lbrack b_{1}\left( \text{JIN} \right) + b_{2}\left( \text{JX} \right) T_{\text{out}} \left( ic \right) \right\rbrack \frac{e_{2}\left( 2,ic \right)}{2}

.. math::
    :label: 5.2-38

    \Delta c \left( \text{JIN},\text{JX} \right) = \left\lbrack b_{1}\left( \text{JIN} \right) + b_{2}\left( \text{JIN} \right) T_{\text{in}} \left( ic \right) \right\rbrack \frac{e_{2}\left( 1,ic \right)}{2}

and

.. math::
    :label: 5.2-39

    \Delta c\left( \text{JX},\text{JIN} \right) = \left\lbrack b_{1}\left( \text{JX} \right) + b_{2}\left( \text{JX} \right) T_{\text{out}} \left( ic \right) \right\rbrack \frac{e_{1}\left( 2,ic \right)}{2}

The contributions to the coefficients :math:`c \left( I,J \right)` and :math:`d \left( J \right)` from all the
liquid segments in a loop have been made at this point, and :eq:`5.2-22`
is solved by Gaussian elimination to yield the pressure changes in all
the compressible volumes in the loop during the time step. With the
pressure changes now known, :eq:`5.2-8` is solved for the mass flow-rate
changes in the liquid segments in the loop, and :eq:`5.2-21` is solved for
the estimated channel flow changes during the time step. The pressure
changes and the mass flow rate changes are then added to the values of
the pressures and flow rates at the beginning of the time step to obtain
the respective values at the end of the time step.

The above procedure is carried out separately for the primary loops and
for the intermediate loops. The core channel flow segments are included
only in the primary loops.

.. _section-5.2.4:

Degree of Implicitness
~~~~~~~~~~~~~~~~~~~~~~

As mentioned in :numref:`section-5.2.1`, the parameters :math:`\theta_1` and
:math:`\theta_2` determine the degree of implicitness of the calculation.
For small time steps, a semi-implicit treatment with :math:`\theta_1 =
\theta_2 = .5` is most accurate. For large time steps, a fully
implicit calculation with :math:`\theta_1 = 0` and :math:`\theta_2 = 1` is
more accurate and numerically more stable. As discussed in :numref:`section-A3.1`,
the degree of implicitness is computed separately for each liquid
segment, :math:`i`, as

.. math::
    :label: 5.2-40

    \theta_{2} \left( j \right) = \frac{a + b\gamma\left( i \right) + \gamma\left( i \right)^{2}}{2a + c\gamma\left( i \right) + \gamma\left( i \right)^{2}}

where

.. math::
    :label: 5.2-41

    \gamma\left( i \right) = - \frac{a_{3}\left( i \right)}{a_{0}\left( i \right)}

:math:`a = 6.12992`

:math:`b = 2.66054`

and

:math:`c = 3.56284`

Then

.. math::
    :label: 5.2-42

    \theta_{1}\left( i \right) = 1 - \theta_{2}\left( i \right)

Note that :math:`a_3 \left( i \right)` is always negative and is proportional to
:math:`\Delta t`, the time-step size. :eq:`5.2-40` and :eq:`5.2-41` give the results
that :math:`\theta_2` approaches 0.5 for small time steps, :math:`\theta_2`
approaches 1.0 for large time steps, and :math:`\theta_2` makes a smooth
transition between 0.5 and 1.0 for intermediate-sized time steps.

Liquid segments attached to an almost incompressible liquid junction are a
special case. Because such compressible volumes are much smaller than
other compressible volumes, their time constants for changes of all
kinds are short; and because of it, these liquid segments are treated
with a fully implicit (:math:`\theta_2 = 1.0`) flow calculation regardless
of time-step size.

The degree of implicitness used in the calculated estimated channel flow
for channel :math:`ic` is

.. math::
    :label: 5.2-43

    \theta_{2\text{c}}\left( L,ic \right) = \frac{a + b\gamma_{\text{c}}\left( L,ic \right) + \gamma_{\text{c}}\left( L,ic \right)^{2}}{2a + c\gamma_{\text{c}} \left( L,ic \right) + \gamma_{\text{c}} \left( L,ic \right)^{2}}

where :math:`\gamma_{\text{c}}` is given by

.. math::
    :label: 5.2-44

    \gamma_{\text{c}} = \frac{2\Delta t}{w_{\text{c}}\left( L,ic \right)C_{3}\left( L,ic \right)}