.. _section-14.7:

Code Logic Description
----------------------

.. _section-14.7.1:

PLUTO2 Initialization
~~~~~~~~~~~~~~~~~~~~~

For the initialization of PLUTO2, the flow diagrams in :numref:`figure-14.7-1` and
14.7-2 are relevant. The flowchart in :numref:`figure-14.7-1` shows part of the
logic flow in subroutine FUINIT (**FU**EL MOTION **INI**\ TIALIZATION) in
which the decision is made whether PLUTO2 or LEVITATE should be
initialized once subroutine FAILUR (which is called from the DEFORM
Transient driver DFORM3 or from TSTHRM if cladding motion has already
begun) has predicted pin failure. A minimum fuel melt fraction equal to
the input parameter FMELTM must exist in the failing node before PLUTO2
or LEVITATE is allowed to be initiated. The decision which one of the
two modules, PLUTO2 or LEVITATE, is to be initiated depends on the
existence and size of a boiling region at the time of failure and
whether the pins are predicted to fail into a voided or unvoided region
of the channel. If there is no boiling region, as in a TOP accident, or
if the pins fail into the liquid region of a partially voided channel,
PLUTO2 will be initiated because of its capability of treating FCIs and
sweepout of particulate fuel. If there is a large voided region in the
channel, in which cladding motion may already have started, LEVITATE,
which is designed for voided-channel fuel motion analysis, will be
initiated. For the case of fuel pins failing into a multi-bubble boiling
region, PLUTO2 will be initiated if the average void fraction in this
region is below 70% at the time of pin failure. If the average void
fraction is greater than 70%, it will be a LEVITATE case which has to be
started by first initiating PLUTO2. In this case, the flag ILEPLI is set
to 1. The flow diagram in :numref:`figure-14.7-2` shows that a switch to LEVITATE
will be immediately made in this case, once the PLUTO2 driver routine
(PLUDRV) is entered.

The flow diagram shown in :numref:`figure-14.7-2` shows how PLUTO2 and LEVITATE are
actually initiated. In a PLUTO2 case, a check is first made to determine
whether cladding motion has already begun. This is an unlikely situation
that cold only come about if liquid sodium reentered into the boiling
region after cladding motion had begun. This would have prevented the
selection of LEVITATE. Since PLUTO2 cannot handle this situation,
control is returned to subroutine FAILUR, and no fuel motion initiation
will take place until the run has proceeded further and led to a more
extensive boiling region that allows the initiation of LEVITATE.

In subroutine PLSAIN (**PL**\ UTO2 **S**\ AS4A COOLANT CHANNEL
**IN**\ ITIALIZATION), the coolant mass, temperature and velocity
distributions are initialized. In the case of a nonboiling channel, this
is relatively straightforward, whereas it is quite complex to properly
translate these quantities from the Lagrangian grid of a multi-bubble
boiling module to the fixed Eulerian PLUTO2 grid.

In subroutine PLINPT (**PL**\ UTO2 **IN**\ PU\ **T**), the coolant channel
geometry is set up, all arrays relevant for the multi-component flow in
the channels are initialized, and the geometry of the molten fuel cavity
in the pins is established. The size of the latter depends on the radial
and axial extent of fuel melting calculated by TSHTRN (for nonboiling
cases) or TSHTRV (for cases in which boiling had already begun) and on
the fuel-pin grid deformation calculated by DEFORM. The radially
averaged internal fuel energy in the molten cavity is calculated based
on the radial temperature profile in the cavity. The total fuel and
dissolved fission-gas masses in all cavity nodes are also calculated.
The latter are based on the DEFORM calculated values.

In subroutine PLSET (**PL**\ UTO2 **SET**\ UP), the molten cavity pressure,
which is calculated by DEF"ORM and which can also be input (see input
value PCFAIL) for parametric studies, is used to determine the mass of
free fission gas in each cavity node. This was discussed earlier in more
detail in :numref:`section-14.2.2`. All other arrays necessary for the in-pin
calculation are also initialized. Moreover, several channel arrays for
the cladding and *structure* temperature calculations in the interaction
region are initialized in this subroutine.

Subroutine PLSET1 (**PL**\ UTO2 **SET**\ UP\ **1**) initializes parameters
necessary for the temperature calculation in the liquid coolant slugs,
which is performed in subroutine PLCOOL. Moreover, parameters necessary
for the temperature calculation in the structure, plenum cladding and
reflectors outside the PLUTO2 interaction zone (which is performed in
subroutine PLSTR) are initialized in PLSET1.

The flowchart in :numref:`figure-14.7-2` also shows that LEVITAE uses most or all of
the PLUTO2 initialization routines. However, LEVITATE also needs
subroutine LESAIN for the case of a single large initial boiling bubble
and subroutine LECLIN if cladding motion has started prior to pin
failure. It can also be seen in :numref:`figure-14.7-2` that the flag ICALC is set
to 2 on the LEVITATE branch and 3 on the PLUTO2 branch. This flag
controls whether the LEVITATE driver routine LEVDRV or the PLUTO2 driver
routine PLUDRV will be called when the SAS4A transient driver TSTHRM is
executed during the next coolant time step.

.. _figure-14.7-1:

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

	First Part of the Flow Chart of Subroutine FUINIT Showing
	the Logic Used in Determining Whether the PLUTO2 Module of the LEVITATE
	Module is to be Activated. The Branch PLU or LEV Implies that the PLUTO2
	Module of the LEVITATE Module is Respectively Activated. The Details of
	Branches PLU and LEV are Shown in :numref:`figure-14.7-2`.

.. _figure-14.7-2:

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

	Second Part of the Flow Chart of Subroutine FUINIT Showing the Initialization of the PLUTO2 and LEVITATE Modules

.. _section-14.7.2:

Time Step Considerations and Auxiliary Subroutines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The PLUTO2 flow logic has already been described in considerable detail
in :numref:`section-14.1.2`. Here, only the different time steps involved and the
calling of auxiliary subroutines will be discussed.

The flow diagram of the PLUTO2 driver routine PLUDRV, which already
appeared in :numref:`section-14.1.2`, is also shown in :numref:`figure-14.7-3` in order to
have a complete set of PLUTO2 flow diagrams in this section.

The PLUTO2 driver routine can be called by the SAS4A transient driver
TSTHRM at the beginning or at any time during a primary loop time step.
The latter is common for all SAS4A calculational channels and is smaller
than or equal to the main (point kinetics) time step, which is also
common for all SAS4A channels.

Before PLUDRV is called for the first time in a given channel, the
PLUTO2 time (TIMEPL), which is counted from the time of pin failure, is
set to zero in the FAILUR routine. Moreover, the time of pin failure
relative to the time of the accident initiation is recorded in the
channel-dependent variable TMPLIN.

When PLUDRV is entered, TIMEPL is advanced by adding the PLUTO2 time
step right after subroutine PLSET2 (which initializes temporary
variables) has been called (see fig. 14.7-3). The very first PLUTO2
time-step size used is the input constant DTPLIN which is the initial
and the minimum PLUTO2 time-step size. After the subroutines PLIPIN and
PL2PIN have performed the in-pin calculation, a new time-step size for
the in-pin motion is calculated as described in :numref:`section-14.2.8`. Once all
the subroutines calculating the channel fuel and sodium/gas dynamics
have been called, a new time-step size for the in-pin motion is
calculated as described in :numref:`section-14.2.8`. Once all the subroutines
calculating the channel fuel and sodium/gas dynamics have been called,
a new time-step is calculated for the channel hydrodynamics (see :numref:`section-14.4.6.4`). This is compared with the time-step size calculated for the
in-pin motion and the smaller of the two will be used as the new PLUTO2
time-step size if it is larger than the above-mentioned input value
DTPLIN. If it is smaller than DTPLIN, the latter will be used as the new
PLUTO2 time-step size. Also, if it is larger than :math:`2 \times 10^{-4}` s,
it will be set to this value. Moreover, if the newly determined time
step extends beyond the end of a heat-transfer time step, it will be cut
back such that the new PLUTO2 time will coincide with the end of the
heat-transfer time step. This is possible since the heat-transfer
subroutine PLHTR calculates only the fuel temperatures in the region
determined by the interaction region (see :numref:`figure-14.1-4` in :numref:`section-14.1`)
and the fuel and cladding temperatures outside the interaction region.
None of these temperatures are changing rapidly relative to PLUTO2
time-step sizes.

The determination of the heat-transfer time step is made using a series
of tests. First, the initial and maximum heat-transfer time step is set
to 1 ms, which is about an order of magnitude smaller than the
characteristic heat-transfer time for cladding. If the initial or any
later time step is larger than the current primary loop time step, it is
set equal to the latter. Since the primary loop time step has to be less
than or equal to the main (point kinetics) time step, it is, of course,
also limited by the main time step.

The heat-transfer time step is not only used for the heat-transfer
calculation of all the fuel and the cladding reflector, and the
structure temperature calculation outside the interaction region, but
also for the temperature calculation in the liquid sodium slugs. Since
the latter involves not only heat conduction from the walls but also
heat convection from the coolant cells above and below the one
considered, the heat-transfer time step is also limited by a Courant
condition based on the liquid slug velocity.

The flow diagram in :numref:`figure-14.7-3` shows that PLUTO2 retains control and
advances the solution using PLUTO2 time steps until the end of the
primary loop time step is reached. This is different from the
single-phase hydraulics driver TSCL0 and the boiling module driver
TSBOIL, which return control to the SAS4A transient driver TSTHRM after
every coolant time step. The latter is the basic time step in the
modules controlled by TSCL0 and TSBOIL. In PLUTO2 (and LEVITATE) the
coolant time step is set equal to the primary loop time step. PLUTO2 or
LEVITATE thus also return control to the transient SAS4A driver at the
end of this "artificial" coolant time step.

Several auxiliary subroutines used in the PLUTO2 module are not shown in
the flow chart in :numref:`figure-14.7-3`. These include the function subroutine
TEFUES, which calculates fuel temperatures for a given internal fuel
energy and TESEEG which calculates steel temperatures for a given
internal steel energy. Function subroutines EGFUTE and EGSETE perform
the inverse operation for fuel and steel, respectively, i.e.,
calculating internal energies for a given temperature.

Several auxiliary subroutines and subroutine functions are called by the
subroutine PLHTR performing the heat-transfer calculation in the solid
annulus of the fuel pin and in the cladding outside the interaction
region. PLHTR is a derivative of subroutine TSHTN3 described in more
detail in :numref:`section-3.3.1` of :numref:`Chapter %s<section-3>`. The most important auxiliary
subroutine called by PLHTR is INVRT3, which inverts a tri-diagonal
matrix. Subroutines KFUEL and KCLAD calculate the fuel and cladding
conductivity, respectively. Subroutine CFUEL calculates the heat
capacity of the fuel and TSHTN5 corrects fuel and cladding temperatures
for the heat of fusion, if melting is occurring. Subroutine HBSMPL and
function subroutine HBFND calculate the gap conductance.

.. _figure-14.7-3:

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

	Flow Chart of the PLUTO2 Driver Sub routine PLUDRV