\label{ch:mg}

\section{\fboxlib\ Multigrid Philosophy}

Here we describe some of the general ideas behind the \fboxlib\
multigrid (MG).

We solve MG on an AMR hierarchy, which means in places we will encounter
C-F interfaces.  The \fboxlib\ MG will modify the stencil for the Laplacian
at C-F interfaces to ensure the correct solution to the Poisson equation
across these interfaces.  There is no correction step needed in this
case (this differs from \cite{ricker:2008}).

The MG solver always works with jumps of $2\times$ between levels.  In
some codes (but not \maestro) we can have jumps of $4\times$ between
levels.  \fboxlib\ uses a {\tt mini\_cycle} in these cases, effectively
inserting a multigrid level between the two AMR levels and doing a mini
V-cycle.

The MG solvers are located in {\tt FBoxLib/Src/LinearSolvers/F\_MG/}.
There are two MG solvers, for cell-centered and nodal data.
Generally, the routines specific to the cell-centered solver will have
{\tt cc} in their name, and those specific to the nodal solver will have
{\tt nd} in their name.

Support for $\Delta x \ne \Delta y \ne \Delta z$

\subsection{Data Structures}

\subsubsection{\mgtower}

The \mgtower\ is a special Fortran derived type that carries all the
information required for a \fboxlib\ multigrid solve.

The following parameters are specified when building the \mgtower:
\begin{itemize}
\item {\tt smoother}: the type of smoother to use.  Choices are listed
  in {\tt mg\_tower.f90}.  Common options are {\tt
    MG\_SMOOTHER\_GS\_RB} for red-black Gauss-Seidel and {\tt
    MG\_SMOOTHER\_JACOBI} for Jacobi.

\item {\tt nu1}: The number of smoothings at each level on the way down
  the V-cycle.

\item {\tt nu2}: The number of smoothings at each level on the way up
  the V-cycle.

\item {\tt nub}: The number of smoothing before and after the bottom solver.

\item {\tt gamma}: \MarginPar{what does this mean?}

\item {\tt cycle\_type}: The type of multigrid to do, V-cycles ({\tt
  MG\_VCycle}), W-cycles ({\tt MG\_WCycle}), full multigrid ({\tt
  MG\_FCycle}).

\item {\tt omega}:  \MarginPar{description?}

\item {\tt bottom\_solver}: the type of bottom solver to use.  See the next
 section.

\item {\tt bottom\_max\_iter}: the maximum number of iterations for the
  bottom solver

\item {\tt bottom\_solver\_eps}: the tolerance used by the bottom
  solver.  In \maestro, this is set via {\tt mg\_eps\_module}.

\item {\tt max\_iter}: the maximum number of multigrid cycles.

\item {\tt max\_bottom\_nlevel}: additional coarsening if you use
  {\tt bottom\_solver} type 4 (see below)

\item {\tt min\_width}: minimum size of grid at coarsest multigrid level

\item {\tt rel\_solver\_eps}: the relative tolerance of the solver (in
  \maestro, this is set via {\tt mg\_eps\_module}.

\item {\tt abs\_solver\_eps}: the absolute tolerance of the solver (in
  \maestro, this is set via {\tt mg\_eps\_module}.

\item {\tt verbose}: the verbosity of the multigrid solver.  In \maestro,
  this is set via the {\tt mg\_verbose} runtime parameter.  Higher
  numbers give more verbosity.

\item {\tt cg\_verbose}: the verbosity of the bottom solver.  In \maestro,
  this is set via the {\tt cg\_verbose} runtime parameter.  Higher
  numbers give more verbosity.

\end{itemize}

In addition to these parameters, the \mgtower\ carries a number of
\multifab s that carry the solution and stencil for the multigrid
solve.

\begin{itemize}

\item {\tt ss}: The stencil itself---for each zone, this gives the
  coefficients of the terms in the Laplacian, with the convention that
  the `0' term is located in the current cell and the other terms are
  the $\pm 1$ off the current cell in each direction.

\item {\tt cc}: scratch space (?)

\item {\tt ff}: The source (righthand side) of the elliptic equation
  we are solving.

\item {\tt dd}: The residual/defect, $f - L\phi$

\item {\tt uu}: The solution variable ($\phi$ when on the finest level)

\item {\tt mm}: For cell-centered, {\tt mm} takes a direction and
   tells you whether we are at a Dirichlet or Neumann boundary, or if
   we are skewed in that direction.

   For nodal, {\tt mm} simply tells us whether a point is Dirichlet
   or Neumann.  There is no skew in nodal.

\end{itemize}

\subsubsection{\bndryreg}

There are two types of \bndryreg\ objects, each of which is a set of
{\tt dim} multifabs.  The first, which is built with the {\tt
bndry\_reg\_build} call, is defined on all cells immediately outside
of each grid.  Each multifab within the \bndryreg\ contains all the
fabs on both the low and high faces for a given direction.  In the
context of multigrid, we fill the \bndryreg\ with coarse data before
interpolating the data to the correct locations to be used in the
multigrid stencil.  The second type of \bndryreg\ object is defined on
the coarse cells immediately outside each fine grid, and is defined
with the {\tt bndry\_reg\_rr\_build} call, is defined on all cells
immediately outside.  For this latter type, the option is available
to include only cells not covered by a different fine grid, but this
is left as an option because it requires additional calculations of
box intersections.

In multigrid, we use the latter type of \bndryreg\ to calculate the
residual at coarse cells adjacent to fine grids that is used as the
right hand side in the relaxation step at the coarse level on the way
down the V-cycle (or other).  The first type of \bndryreg is used to
hold boundary conditions for the fine grids that are interpolated from
the coarse grid solution; this is filled on the way back up the
V-cycle.

To compute the residual in a coarse cell adjacent to a fine grid, we
first compute the pure coarse residual, then subtract the contribution
from the coarse face underlying the coarse-fine interface, and add the
contribution of the fine faces at the coarse-fine interface.
The \bndryreg\ holds the cell-centered contribution from the
difference of these edge fluxes and is added to the coarse residual
multifab.

\subsection{Stencils}

There are several different stencil types that we can use for
the discretization.  For cell-centered, these are:
\begin{itemize}
\item {\tt CC\_CROSS\_STENCIL}: this is the standard cross-stencil---5 points
in 2-d and 7 points in 3-d.  For cell-centered MG, this is the default, and
is usually the best choice.

\item {\tt HO\_CROSS\_STENCIL}: this is a cross-stencil that uses 9 points
in 2-d and 11-points in 3-d.  For instance, it will use $(i,j)$;
$(i\pm1,j)$; $(i\pm2,j)$; $(i,j\pm1)$; $(i,j\pm2)$.  This is
higher-order accurate that {\tt CC\_CROSS\_STENCIL}.

\item {\tt HO\_DENSE\_STENCIL}: this is a dense-stencil---it uses all the
points (including corners) in $(i\pm1,j\pm1)$, resulting in a 9-point stencil
in 2-d and 27-point stencil in 3-d.
\end{itemize}

For the nodal solver, the choices are:
\begin{itemize}
\item {\tt ND\_CROSS\_STENCIL}: this is the standard cross-stencil.

\item {\tt ND\_DENSE\_STENCIL}: this is a dense stencil, using
  all the points in $(i\pm1,j\pm1)$.  The
  derivation of this stencil is based on finite-element ideas, defining
  basis functions on the nodes.  This is developed in 2-d in
  \cite{almgrenBellSzymczak:1996}.

\item {\tt ND\_VATER\_STENCIL}: this is an alternate dense stencil derived
  using a similar finite-element idea as above, but a different control
  volume.
\end{itemize}
For the cell-centered solve, the coefficients for the stencil are computed
once, at the beginning of the solve.  For the nodal solver, the coefficients
are hard-coded into the smoothers.

\subsection{Smoothers}

The following smoothers are available (but not necessarily for both the
cell-centered and nodal solvers):
\begin{itemize}
\item {\tt MG\_SMOOTHER\_GS\_RB}: a red-black Gauss-Seidel smoother

\item {\tt MG\_SMOOTHER\_JACOBI}: a Jacobi smoother (not implemented for
the dense nodal stencil)

\item {\tt MG\_SMOOTHER\_MINION\_CROSS}

\item {\tt MG\_SMOOTHER\_MINION\_FULL}

\item {\tt MG\_SMOOTHER\_EFF\_RB}
\end{itemize}

\subsection{Cycling}

The default cycling is a V-cycle, but W-cycles and full multigrid are
supported as well.

\subsection{Bottom Solvers}

The multigrid cycling coarsens the grids as part of the solve.  When
the coarsest grid is reached, the individual boxes that comprise that
level are coarsened as much as then can, down to $2^3$ zones.  Depending
on the distribution of sizes of the grids, it may not be possible for
everything to reach this minimum size.  At this point, the bottom
solver is invoked.  Most of these will solve the linear system
on this collection of grids directly.  There is one special bottom
solver that will define a new box encompassing all of the coarsened
grids and then put the data on fewer boxes and processors and further
coarsen the problem, again until we get as close to $2^3$ as possible.
At that point, one of the other bottom solvers will be called upon
to solve the problem.

There are several bottom solvers available in \fboxlib.  For \maestro.
These are set through the {\tt mg\_bottom\_solver} (MAC/cell-centered)
and {\tt hg\_bottom\_solver} (nodal) runtime parameters.
The allowed values are:
\begin{itemize}

\item {\tt mg\_bottom\_solver} / {\tt hg\_bottom\_solver = 0}: smoothing only.

\item {\tt mg\_bottom\_solver} / {\tt hg\_bottom\_solver = 1}: biconjugate
  gradient stabilized---this is the default.

\item {\tt mg\_bottom\_solver} / {\tt hg\_bottom\_solver = 2}: conjugate
  gradient method

\item {\tt mg\_bottom\_solver} / {\tt hg\_bottom\_solver = 4}: a special
  bottom solver that extends the range of the multigrid coarsening
  by aggregrating coarse grids on the original mesh together and
  further coarsening.

\end{itemize}

You should use the special bottom solver (4) whenever possible, even
if it means changing your gridding strategy (as discussed below) to
make it more efficient.

\MarginPar{any simple discussion on why we might choose one of the
  other bottom solvers?}

\subsubsection{Special Bottom Solver}

The special solver takes the data from the coarsest level of the
original multigrid V-cycle and copies it onto a new grid structure with
the same number of total cells in each direction, but with a fewer
number of larger grids.  A new V-cycle begins from this point, so we
are essentially coarsening this ``new'' problem.  Now, the coarsest
level of the multigrid V-cycle in the ``new'' problem has fewer cells
and fewer grids as compared to the original coarsest level.

To enable this solver, set {\tt hg\_bottom\_solver = 4} (for the nodal
projections) and/or {\tt mg\_bottom\_solver = 4} (for the
cell-centered projections) in your inputs file.

To understand how this bottom solver works, the first thing you need
to know is what the grid structure of the coarsest level of your
multigrid V-cycle looks like.  Next, figure out the size of the box you
would need if you wanted it to fit all the data on the coarsest level.
Finally, figure out what the largest integer $n$ is so that you can evenly
divide the length of this box by $2^n$ in every coordinate direction.
If $n < 2$, the program will abort since the grid structure is not
suitable for this bottom solver.

The code will set up a ``new'' problem, using the data at the
coarsest level of the original problem as the initial data.  The grid
structure for this new problem has the same number of cells as the
coarsest level of the original problem, but the data is copied onto a
grid structure where each grid has $2^n$ cells on each side.  The new
V-cycle continues down to the new coarsest level, in which each grid
has 2 cells on each side.  If you wish to impose a limit on the
maximum value that $n$ can have, you can do so by setting {\tt
max\_mg\_bottom\_nlevs} equal to that value.

Some grid examples help make this clear:
\begin{itemize}
\item {\bf Example 1:} A 3D problem with $384^3$ cells divided into $32^3$
grids, i.e., there is a $12\times 12\times 12$ block of $32^3$ grids.
The coarsest level of the multigrid V-cycle contains $12\times
12\times 12$ grids that have $2^3$ cells, so the entire problem domain
has $24^3$ cells.  We see that $n=3$, and create a new problem domain
with a $3\times 3\times 3$ block of $8^3$ grids.  The coarsest level
of the multigrid V-cycle for the ``new'' problem will be a $3\times
3\times 3$ block of $2^3$ grids.

\item {\bf Example 2:} A 2D problem with $96\times 384$ cells divided into
$48^2$ grids, i.e., there is a $2\times 8$ block of $48^2$ grids.  The
coarsest level of the multigrid V-cycle contains $2\times 8$ grids
that have $3^2$ cells, so the entire problem domain has $6\times 24$
cells.  We see that $n=0$, so the program aborts since this grid
structure is not appropriate for the fancy bottom solver.
\end{itemize}

\section{Flowchart}

\maestro\ multigrid solves always involve the full AMR hierarchy.

\subsection{Cell-Centered MG}

The flowchart below shows the structure of a cell-centered multigrid
solve using pure V-cycles.

\begin{itemize}

\item {\tt stencil\_fill\_cc\_all\_mglevels} / {\tt stencil\_fill\_cc}:
  Compute all of the stencil coefficients
  for the Laplacian operator at all cells.  At the C-F interfaces, the
  stencil coefficients are modified to know this.

\item {\tt ml\_cc}: The main driver for the cell-centered multigrid.
   Among other things, this computes the norm that will be used
   for convergence testing.

\item {\tt mg\_tower\_v\_cycle} (recursive):
\begin{itemize}

  \item {\em recursively descend V-cycle}
\MyArrow[1em]{start1}{end1}{colorii,line width=2pt}
  \begin{itemize}
  \item \tikzmark{end1} {\tt cc\_mg\_tower\_smoother}: Smooth the
    problem at the current MG level using the desired smoother.

  \item {\tt compute\_defect}: Construct $f - L\phi$.

  \item\tikzmark{start1} {\tt mg\_tower\_restriction}:  Restrict
    the defect to the coarser level by conservative averaging.
  \end{itemize}

  \item {\tt mg\_tower\_bottom\_solve}:  Solve the coarsened problem
    using the chosen bottom solver.

  \item {\em ascend V-cycle}
\MyArrow[1em]{start2}{end2}{colorii,line width=2pt}
  \begin{itemize}
  \item\tikzmark{end2} {\tt mg\_tower\_prolongation}: Take the solution at level $n-1$ and use it to
     correct the solution at level $n$ by representing the data on the finer grid.  This uses
     linear reconstruction for jumps by $2\times$ and piecewise-constant otherwise.

  \item\tikzmark{start2} {\tt cc\_mg\_tower\_smoother}:
  \end{itemize}

\end{itemize}
\item {\tt compute\_defect}: This is called multiple times, checking for
   convergence at each level.

\end{itemize}

\subsection{Nodal MG}

The flowchart below shows the structure of a cell-centered multigrid
solve using pure V-cycles.

\begin{itemize}

\item {\tt stencil\_fill\_cc\_all\_mglevels} / {\tt stencil\_fill\_cc}:
  For the nodal solver, this applies the weights to the
  coefficients. \MarginPar{nodal does things differently than cc---need more here}

\item {\tt ml\_nd}: The main driver for the nodal multigrid.

\item {\tt mg\_tower\_v\_cycle} (recursive):
\begin{itemize}

  \item {\em recursively descend V-cycle}
\MyArrow[1em]{start3}{end3}{colorii,line width=2pt}
  \begin{itemize}
  \item \tikzmark{end3} {\tt nodal\_smoother\_?d}: Smooth the
    problem at the current MG level using the desired smoother.

  \item {\tt compute\_defect}: Construct $f - L\phi$.

  \item\tikzmark{start3} {\tt mg\_tower\_restriction}:  Restrict
    the defect to the coarser level by simply taking the fine value that
    lies at the same place as the coarse data.
  \end{itemize}

  \item {\tt mg\_tower\_bottom\_solve}:  Solve the coarsened problem
    using the chosen bottom solver.

  \item {\em ascend V-cycle}
\MyArrow[1em]{start4}{end4}{colorii,line width=2pt}
  \begin{itemize}
  \item\tikzmark{end4} {\tt mg\_tower\_prolongation}: For nodal data, the fine grid
     will have some points at exactly the same place as the coarse data---these are
     simply copied to the fine grid.  The remain data is interpolated.

  \item\tikzmark{start4} {\tt modal\_smoother\_?d}:
  \end{itemize}

\end{itemize}
\item {\tt compute\_defect}: This is called multiple times, checking for
   convergence at each level.

\end{itemize}

\section{\maestro's Multigrid Use}

\maestro\ uses multigrid to enforce the velocity constraint through
projections at the half-time (the MAC projection) and end of the time
step (the HG projection).  Two multigrid solvers are provided by
\fboxlib---one for cell-centered data and one for node-centered (nodal)
data.  Both of these are used in \maestro.

The MAC projection operates on the advective velocities predicted at
the cell-interfaces at the half-time.  The edge-centered velocities
are shown in Figure~\ref{fig:mg:MAC}.  If we consider purely
incompressible flow, the projection appears as:
\begin{equation}
D G \phi = D U
\end{equation}
where $D$ is the divergence operator and $G$ is the gradient operator.
In this discretization, $\phi$ is cell-centered (see
Figure~\ref{fig:mg:MAC}).  The remaining quantities are discretized as:
\begin{itemize}
\item $DU$ is cell-centered,
  \begin{equation}
  (DU)_{i,j} = \frac{u_{i+1/2,j} - u_{i-1/2,j}}{\Delta x} +
               \frac{v_{i,j+1/2} - v_{i,j-1/2}}{\Delta y}
  \end{equation}

\item $G\phi$ is edge-centered, on the MAC grid, as shown in
  Figure~\ref{fig:mg:MAC}.

\item $DG\phi$ is cell-centered, also shown in Figure~\ref{fig:mg:MAC},
  computed from $G\phi$ using the same differencing as $DU$.

\end{itemize}

\begin{figure}[t]
\centering
\includegraphics[width=5.5in]{\mgfigpath/MAC_mg2}
\caption{\label{fig:mg:MAC} Data centerings for the MAC projection}
\end{figure}

The HG projection projects the cell-centered velocities at the end of
the timestep.  Here, $\phi$ is node-centered.  Figure~\ref{fig:mg:HG}
shows the locations of the various quantities involved in the HG
projection.  Again considering simple incompressible flow, we now
solve:
\begin{equation}
L \phi = D U
\end{equation}
where $L$ is a discretization of the Laplacian operator.  In this
sense, the HG projection is an {\em approximate projection}, that is,
$L \neq DG$ (in discretized form).  The various operations have the
following centerings:
\begin{itemize}

\item $DU$ is node-centered.  This is computed as:
  \begin{equation}
  (DU)_{i-1/2,j-1/2} = \frac{\frac{1}{2} (u_{i,j} + u_{i,j-1}) -
                             \frac{1}{2} (u_{i-1,j} + u_{i-1,j-1})}{\Delta x} +
                       \frac{\frac{1}{2} (v_{i,j} + v_{i-1,j}) -
                             \frac{1}{2} (v_{i,j-1} + v_{i-1,j-1})}{\Delta y}
  \end{equation}

\item $G\phi$ is cell-centered, as shown in Figure~\ref{fig:mg:HG}.

\item $L\phi$ is node-centered.  This is a direct discretization of
the Laplacian operator.  By default, \maestro\ uses a dense stencil
(9-points in 2-d, 27-points in 3-d).  Alternately, a {\em cross}
stencil can be used (by setting {\tt hg\_dense\_stencil = F}).  This
uses 5-points in 2-d, 7-points in 3-d.

\begin{figure}[t]
\centering
\includegraphics[width=5.5in]{\mgfigpath/HG_mg2}
\caption{\label{fig:mg:HG} Data centerings for the HG projection}
\end{figure}

\end{itemize}

\section{Convergence Criteria}

All \maestro\ multigrid solves consist of pure V-cycles.

\subsection{Multigrid Solver Tolerances}

\label{sec:mgtol}

Beginning at the start of execution, there are several places where
either cell-centered multigrid or node-centered multigrid solves are
performed.  The outline below lists the solves one encounters, in order,
from the start of execution.  The values of the tolerances lists here
are defined in the {\tt mg\_eps} module.  To set problem-specific values
of these tolerances, place a local copy of {\tt mg\_eps.f90} in your
problem directory.

In the initialization, multigrid comes in during the initial projection
and the ``divu'' iterations.

\begin{itemize}

\item {\em initial projection} ({\tt initial\_proj} called from {\tt varden})

  The initial projection creates a first approximation to the velocity
  field by forcing the initial velocity field set by {\tt initveldata}
  to satisfy the elliptic constraint equation.  Since the initial
  velocity may be zero, there is no guarantee that a well-defined
  timestep can be computed at this point, so the source term, $S$,
  used here only involves thermal diffusion and any external heating
  term, $\Hext$---no reactions are included (see paper~III, \S 3.3).

  The initial projection can be disabled with the {\tt do\_initial\_projection}
  runtime parameter.

  The tolerances, {\tt eps\_init\_proj\_cart} and {\tt eps\_init\_proj\_sph}
  (for Cartesian and spherical respectively) are set in {\tt mg\_eps.f90}
  and have the default values of:
   \begin{center}
   \begin{tabular}{lll}
   Cartesian:   &  {\tt eps\_init\_proj\_cart} &= $10^{-12}$ \\
   spherical:   &  {\tt eps\_init\_proj\_sph}  &= $10^{-10}$
   \end{tabular}
   \end{center}

\item {\em ``divu'' iterations} ({\tt divu\_iter} called from {\tt varden})

  The ``divu'' iterations projects the velocity field from the initial
  projection to satisfy the full constraint (including reactions).
  This is an iterative process since the reactions depend on the
  timestep and the timestep depends on the velocity field (see
  paper~III, \S 3.3).  The number of iterations to take is set through
  the {\tt init\_divu\_iter} runtime parameter.

  The overall tolerance, $\epsilon_\mathrm{divu}$ depends on the iteration, $i$.
  We start with a loose tolerance and progressively get tighter.  The
  tolerances (set in {\tt divu\_iter}) are, for Cartesian:
  {\small
   \begin{center}
   \begin{tabular}{lll}
   $\epsilon_\mathrm{divu} = \left  \{ \begin{array}{lll}
                   \min\, \{& \!\!\!\mathtt{eps\_divu\_cart} \cdot \mathtt{divu\_iter\_factor}^2 \cdot \mathtt{divu\_level\_factor}^{(\mathtt{nlevs}-1)}, \\
                            & \!\!\!\mathtt{eps\_divu\_cart} \cdot \mathtt{divu\_iter\_factor}^2 \cdot \mathtt{divu\_level\_factor}^2 \, \} &
                           \quad \mathrm{for}~ i \le \mathtt{init\_divu\_iter} - 2 \\[2mm]
                   \min\, \{& \!\!\!\mathtt{eps\_divu\_cart} \cdot \mathtt{divu\_iter\_factor} \cdot \mathtt{divu\_level\_factor}^{(\mathtt{nlevs}-1)}, \\
                            & \!\!\!\mathtt{eps\_divu\_cart} \cdot \mathtt{divu\_iter\_factor} \cdot \mathtt{divu\_level\_factor}^2 \, \} &
                           \quad \mathrm{for}~ i = \mathtt{init\_divu\_iter} - 1  \\[2mm]
                   \min\, \{& \!\!\!\mathtt{eps\_divu\_cart} \cdot \mathtt{divu\_level\_factor}^{(\mathtt{nlevs}-1)}, \\
                            & \!\!\!\mathtt{eps\_divu\_cart} \cdot \mathtt{divu\_level\_factor}^2 \, \} &
                           \quad \mathrm{for}~ i = \mathtt{init\_divu\_iter}   \\
                                 \end{array}
                  \right .$ \\[10mm]
   \end{tabular}
   \end{center}
   }
   and for spherical:
   {\small
   \begin{center}
   \begin{tabular}{ll}
   $\epsilon_\mathrm{divu} = \left  \{ \begin{array}{ll}
                     \mathtt{eps\_divu\_sph} \cdot \mathtt{divu\_iter\_factor}^2 &
                           \quad \mathrm{for}~ i \le \mathtt{init\_divu\_iter} - 2 \, \\[2mm]
                    \mathtt{eps\_divu\_sph} \cdot \mathtt{divu\_iter\_factor}  &
                           \quad \mathrm{for}~ i = \mathtt{init\_divu\_iter} - 1 \, \\[2mm]
                    \mathtt{eps\_divu\_sph}  &
                           \quad \mathrm{for}~ i = \mathtt{init\_divu\_iter} \, )\\
                  \end{array}
                  \right .$ \\
   \end{tabular}
   \end{center}
   }
   The various parameters are set in {\tt mg\_eps.f90} and have the default values of:
   \begin{center}
   \begin{tabular}{ll}
   {\tt eps\_divu\_cart}     &= $10^{-12}$ \\
   {\tt eps\_divu\_sph}      &= $10^{-10}$ \\
   {\tt divu\_iter\_factor}  &= 100 \\
   {\tt divu\_level\_factor} &= 10
   \end{tabular}
   \end{center}

\end{itemize}

In the main algorithm, mulitgrid solves come in during the two MAC projections,
two (optional) thermal diffusion solves, and the final velocity projection.

\begin{itemize}

\item {\em MAC projection}

  The MAC projection forces the edge-centered, half-time advective
  velocities to obey the elliptic constraint.  This is done both in
  the predictor and corrector portions of the main algorithm.

  There are two tolerances here.  The norm of the residual is required
  to be reduced by a relative tolerance of $\epsilon =
  \min \{ \mathtt{eps\_mac\_max}, \mathtt{eps\_mac} \cdot
  \mathtt{mac\_level\_factor}^{(\mathtt{nlevs}-1)} \}$. A separate
  tolerance is used for the bottom
  solver, $\epsilon_\mathrm{bottom} =
  \mathtt{eps\_mac\_bottom}$.  These parameters are set in {\tt
    mg\_eps.f90} and have the default values:
   \begin{center}
   \begin{tabular}{ll}
   {\tt eps\_mac}           &= $10^{-10}$ \\
   {\tt eps\_mac\_max}           &= $10^{-8}$ \\
   {\tt mac\_level\_factor} &= 10 \\
   {\tt eps\_mac\_bottom}   &= $10^{-3}$
   \end{tabular}
   \end{center}

  %an absolute tolerance of $\epsilon_\mathrm{abs} =
  %\epsilon \cdot ||U^\mathrm{ADV}||_\infty / \Delta x$

\item {\em thermal diffusion}

  This uses the same {\tt mac\_multigrid} routine as the MAC
  projection, so it uses the same tolerances.  The only difference is
  that the absolute tolerance is based on the norm of $h$ now, instead
  of $U^\mathrm{ADV}$.

\item {\em velocity projection}

  The final velocity projection uses a tolerance of $\epsilon = \min \{
  \mathtt{eps\_hg\_max}, \mathtt{eps\_hg} \cdot \mathtt{hg\_level\_factor}^{(\mathtt{nlevs} - 1)} \}$.  This tolerance
  is set in {\tt hgproject} using the parameter values specified in {\tt mg\_eps.f90}.  A separate
  tolerance is used for the bottom
  solver, $\epsilon_\mathrm{bottom} = \mathtt{eps\_hg\_bottom}$.

  The default parameter values are:
   \begin{center}
   \begin{tabular}{ll}
   {\tt eps\_hg}     &= $10^{-12}$ \\
   {\tt eps\_hg\_max}      &= $10^{-10}$ \\
   {\tt hg\_level\_factor}  &= 10 \\
   {\tt eps\_hg\_bottom}   &= $10^{-4}$
   \end{tabular}
   \end{center}

\end{itemize}

\section{General Remarks}

If \maestro\ has trouble converging in the multigrid solves, try
setting the verbosity {\tt mg\_verbose} or {\tt cg\_verbose} to
higher values to get more information about the solve.


\chapter{Introduction}\label{chap:introduction}

In programming, dependent types are the next step in the unification of language constructs. Not only values and functions but also types are first class constructs. When declaring types, it is now possible to depend on values, e.\,g. in addition to type \emph{Integer}, one may define a type $(Integer~n)$, only accepting a value $x \in \mathbb{Z}$ when $x \leq n$.

This goes along with practical advantages: more precise typing, consequently better correctness guarantees and more expressive power when describing programs. Nevertheless, such power comes at a cost: As the difference between proof and program grows hazy, type checking will face similar problems as program execution. The additional complexity of fully dependent types implies \emph{Turing completeness}. Hence, type checking will be subject to the \emph{halting problem}.

\section{Label Dependent Types}

Over the years, different approaches to dependent types surfaced, mitigating such disadvantages. This work is based on a subset of ``Label Dependent Session Types'' by \cite{thiemann2019}. Ignoring session types, we focus on the \emph{Label Dependent Lambda Calculus} (LDLC) it introduces, extending it during this thesis. In general, types in LDLC refer to finite sets of labels. For example, it is easy to define type \textbf{Bool} with two labels representing \emph{True} and \emph{False} respectively:

\begin{equation}\label{eqn:bool}
\Bool    := \{\ell_{T}, \ell_{F}\}
\end{equation}

Elimination is done using a \textbf{case} construct, matching labels with expressions or types. In equation~\ref{eqn:ldlc}, a function accepting two arguments $x$ and $y$ is given. While $x$ is of type \textbf{Bool}, $y$ depends on the value of $x$, hence $y$ may have type \textbf{Int} or type \textbf{Bool}. The same holds for the function's body as seen in the whole function's type annotation, given as $\Pi$-type. This quickly results in unwieldy type annotations.

\begin{equation}\label{eqn:ldlc}
\begin{split}
&\lambda (x: \Bool) \\
&\quad . \lambda (y: \case x \{\ell_T: \Int, \ell_F: \Bool\} ) \\
&\qquad . \case x \{\ell_T: 17+y,\ell_F: \notf y\} \\
: & \Pi(x : \Bool) \\
&\quad . \Pi (y: \case x \{\ell_T: \Int, \ell_F: \Bool\} ) \\
&\qquad . \case x \{\ell_T: \Int, \ell_F: \Bool \}
\end{split}
\end{equation}

Label-dependency strikes a middle ground between full dependent typing and its complete absence. Thus, it comes with similar advantages. It is not as complex. The compiler has more options to check type safety, resulting in a more reliable program. Furthermore, types can serve as a machine-readable and machine-verifiable documentation since they give hints about the workings of the code.
As a disadvantage, the code above is quite verbose. Adding all these type annotations can be cumbersome for a programmer, especially when still exploring a given task and trying out different approaches.

\section{Gradual Typing}

\emph{Gradual Typing} mitigates this problem since it allows mixing static and dynamic typing. In their paper, \cite{fu2021} propose an extension, the \emph{Gradual Label Dependent Lambda Calculus} (GLDLC), introducing the dynamic type $\star$. Annotating terms with $\star$ results in type checking at runtime, still preserving the guarantees of statically typed code at its boundaries. One possibility for rewriting equation~\ref{eqn:ldlc} is by replacing the \case construct describing the type of variable $y$ by dynamic type $\star$.

\begin{equation}\label{eqn:gldlc}
\begin{split}
&\lambda (x: \Bool)
. \lambda (y: \star)
. \case x \{\ell_T: 17+y,\ell_F: \notf y\} \\
: & \Pi(x : \Bool)
. \Pi (y: \star)
. \case x \{\ell_T: \Int, \ell_F: \Bool \}
\end{split}
\end{equation}

The original paper lists more advantages and applications of GLDLC, whereas this work focuses on implementation aspects. Therefore, the methods used for evaluating type $\star$ are of interest. This leads to an intermediate representation, describing the cast from arbitrary type $A$ to $\star$ and from $\star$ to an arbitrary type $B$. These casts are part of the \emph{Cast Calculus Label Dependent Lambda Calculus} (CCLDLC). The \emph{Cast Calculus} adds an explicit type cast expression $(M : A \Rightarrow B)$, casting the value of evaluated expression $M$ of type $A$ to type $B$. Naturally, type $\star$ may occur on both sides. Rewriting equation~\ref{eqn:gldlc} results in a more verbose and more explicit formulation.

\begin{equation}\label{eqn:ccldlc}
\begin{split}
&\lambda (x: \Bool) . \lambda (y: \star ) \\
&\quad . \case x \{\ell_T: 17+(y:\star \Rightarrow \Int),\ell_F: \notf (y:\star \Rightarrow \Bool)\} \\
: & \Pi(x : \Bool) . \Pi (y: \star ) \\
&\quad . \case x \{\ell_T: \Int, \ell_F: \Bool \}
\end{split}
\end{equation}

In CCLDLC, a cast must always happen in such an explicit manner. The same is true for function application. When passing an expression for variable $y$, there must be an explicit cast to the dynamic type, e.\,g. $(\ell_F : \Bool \Rightarrow \star)$.

We contribute an implementation of CCLDLC by extending LDGV, an existing interpreter for Label Dependent Session Types in the Haskell programming language.
\\
The full source code is available at \url{https://github.com/leyhline/ldgv/}.

First, we describe the \emph{Label Dependent Lambda Calculus}, its rules and its interpreter LDGV since these provide the foundation for our extension. Next, we formally describe the rules of CCLDLC including a section on the current implementation's structure and a top-level overview of necessary adjustments. Finally, we document the implementation in a detailed manner.

\section{Notation}

Since this work is about building an implementation, there needs to be a distinction between concepts and code. Often, both will be quite similar. Concepts like formulas and rules are conveyed using mathematical notation. This is not necessarily identical to the actual syntax of LDGV.

\begin{align*}
 x &:= \ell_T & \text{variable definition} \\
 A &:= \{ \ell_T \} & \text{type definition}
\end{align*}

Then again, actual code precisely reflects the capabilities of LDGV. One can feed it verbatim to the interpreter. It is written in a monospaced font.

\begin{lstlisting}[language=ldgv,caption=LDGV: Source code example]
val x = 'foo
type A : ~un = { 'foo }
\end{lstlisting}


\section{Motivation}

Gas centrifuge cascades are usually designed to operate in an ideal manner, with
no losses in separative work. To achieve such ideal configuration, the cascade
is designed to be fed with a specific feed assay and produce the target
enrichment while rejecting tails at a fixed assay.

With the current international tensions regarding enrichment capabilities, this
work aims to measure the effectiveness of a symmetric enrichment cascade when
used outside of its designed scope and to quantify the attractiveness %Katie: I would be VERY VERY careful using the word attractiveness.
of such ways
to build up a \gls{SQ} of \gls{HEU}, defined by the \gls{IAEA} as \(25 \ kilograms\)\cite{noauthor_iaea_2001}.

The present work investigates the performance of an enrichment cycle when chaining
gas centrifuge enrichment cascades tuned for \gls{LEU} production from natural uranium to instead produce \gls{HEU}. Literature on the subject is limited due to its
internationally and politically sensitive nature. Three behavior models have been
implemented and used to evaluate the response of an enrichment cascade when fed
with different assays than originally designed. This work also takes advantage
of the \Cyclus \cite{cyclus} fuel cycle simulator's capabilities to evaluate the
assay values at equilibrium.


\chapter{Electronic couplings}
\label{sec:transfer_integrals}

The electronic transfer integral\index{electronic coupling}\index{transfer integral|see{electronic coupling}} element $J_{ij}$ entering the Marcus rates in \equ{marcus} is defined as
\begin{equation}
   J_{ij} = \left\langle \phi_i \left\vert \hat{H} \right\vert \phi_j \right\rangle ,
\label{equ:TI}
\end{equation}
where $\phi_i$ and $\phi_j$ are diabatic wavefunctions, localized on molecule $i$ and $j$ respectively, participating in the charge transfer, and $\hat{H}$ is the Hamiltonian of the formed dimer. Within the frozen-core approximation, the usual choice for the diabatic wavefunctions $\phi_i$\index{diabatic states} is the highest occupied molecular orbital (HOMO) in case of hole transport, and the lowest unoccupied molecular orbital (LUMO) in the case of electron transfer, while $\hat{H}$ is an effective single particle Hamiltonian, e.g. Fock or Kohn-Sham operator of the dimer. As such, $J_{ij}$ is a measure of the strength of the electronic coupling of the frontier orbitals of monomers mediated by the dimer interactions.

Intrinsically, the transfer integral is very sensitive to the molecular arrangement, i.e. the distance and the mutual orientation of the molecules participating in charge transport. Since this arrangement can also be significantly influenced by static and/or dynamic disorder~\cite{baessler_charge_1993,troisi_charge-transport_2006,troisi_charge_2009,mcmahon_organic_2010,vehoff_charge_2010},
it is essential to calculate $J_{ij}$ explicitly for each hopping pair within a realistic morphology. Considering that the number of dimers for which \equ{TI} has to be evaluated is proportional to the number of molecules times their coordination number, computationally efficient and at the same time quantitatively reliable schemes are required.

\input{theory/dipro}

\input{theory/dft}

\input{theory/moo}


\section{Constant Subcritical flow}

This is a very simple test of constant (subcritical) flow down a channel. The constant state should be preserved.

\subsection{Results}
For our test we consider the initial condition
\begin{equation}
u(x,y,0)=v(x,y,0)=0\,, \quad
w(x,y,0)= 1.5\,,
\end{equation}
and the Dirichlet boundary conditions at $x=0^{-}$ and $25^{+}$ to be
\begin{equation}
[w,hu,hv]=[2, 4.42, 0]\,.
\end{equation}
Representatives of the simulation results are given in the following three figures.
We should see a very accurate reproduction of the steady flow $w=2$ $u=2.21$, $q=4.42$ by 50secs.

\begin{figure}
\begin{center}
\includegraphics[width=0.9\textwidth]{stage_plot.png}
\end{center}
\caption{Stage results}
\end{figure}

\begin{figure}
\begin{center}
\includegraphics[width=0.9\textwidth]{xmom_plot.png}
\end{center}
\caption{Xmomentum results}
\end{figure}

\begin{figure}
\begin{center}
\includegraphics[width=0.9\textwidth]{xvel_plot.png}
\end{center}
\caption{Xvelocity results}
\end{figure}

\endinput


\section{Models}

We need to aproximate things because solving the general Hamiltonian would take an unreasonable amount of data, so we use approximations to make the calculations easier % 26

\subsection{The Hartree Fock Method}

In the Hartree Fock method, the wavefunction {\qs{(of what?)}} is approximated by a Slater determinant, effectively treating the effects of all of the electrons as an averaged potential.

\paragraph{Slater Determinant}
{\na{this is an expression that describes the wave function of a multi-fermionic system that satisfies anti-symmetry requirements and consequently the Pauli principle by changing sign upon exchange of two electrons (or other fermions). \cite{Slater-wiki}}}

However, as each electron would be repelled from each other, there is a motion of electrons relative to each other.
This is called the electronic correlation

Because the hartree fock method ignores this correlation, it consistently gives a large overestimate of the energy.
To combat this, we use {\qs{what exactly?}}

\pagebreak
\section{Electron Correlations}

\pagebreak
\section{Calculation of Electron Correlations}
}}

\pagebreak
\section{Anderson Impurity Model}

In the Anderson Impurity Problem, a single impurity is placed in a bath of {\qs{how many?}} atoms.

\subsection{Monte Carlo Simulations}

\pagebreak

\section{Quantum Monte Carlo Simulation}

{\com{
We're going to use a quantum monte carlo simulation to solve the Anderson Impurity problem \cite{QISolvers}

To do this, we will input a Self-Consistency equation
$$\mathcal{G}=G_i(i\omega_n)+\Sigma(i\omega_n)$$

and the program should output a lattice Green's function
$$G_i(i\omega_n)=\frac{1}{N}\sum_k{\frac{1}{i\omega_n-(\epsilon(k)-\mu)-\Sigma(i\omega_n)}}$$

which can be used to get another self-consistency equation with
$$G_{i\sigma}^{-1}(i\omega_n)+\Sigma_\sigma(i\omega_n)=\mathcal{G}_\sigma(i\omega_n)$$
}}

A quantum monte carlo simulation is one that{\qs{does what?}}

\paragraph{Main steps} In this program, we:
\begin{itemize}
    \item make a one dimensional lattice of $N$ spins, denoted by $\pm 1$
    \item this lattice extends into imaginary time, in l time slices
        {\qs{
        \begin{itemize}
            \item would each spin stretching in imaginary time be the same as the initial spin?
            \item or would each point on each time slice also be randomly generated?
        \end{itemize}
        }}
    \item sweeping across each lattice point, and then across each time slices, the spins will be flipped
    \item whether the spin stays flipped depends on the calculated weight
    \item this weight depends on the spins of all of the points in the lattice, according to this equation
        \begin{equation}
            \\
        \end{equation}
    \item if this weight is above 1, the change in spin is accepted automatically.
    \item if this spin is below 1, a random number is generated.
    \item the flip is then accepted if the weight is above this random number
    \item during this process, different metrics are recorded about the lattice
    \item first, we record the average spins of the lattice points
\end{itemize}

This simulation was written and run to calculate the correlations between electrons.

\bib

\end{document}


\hypertarget{structIir_1_1Butterworth_1_1BandPass}{}\doxysubsection{Iir\+::Butterworth\+::Band\+Pass$<$ Filter\+Order, State\+Type $>$ Struct Template Reference}
\label{structIir_1_1Butterworth_1_1BandPass}\index{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}}

{\ttfamily \#include $<$Butterworth.\+h$>$}

Inheritance diagram for Iir\+::Butterworth\+::Band\+Pass$<$ Filter\+Order, State\+Type $>$\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.434783cm]{structIir_1_1Butterworth_1_1BandPass}
\end{center}
\end{figure}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass_a73d7b106f2da5ccd5defe5e86f7b8ffd}{setup}} (double sample\+Rate, double center\+Frequency, double width\+Frequency)
\item
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass_a4e01abd204275ae2223e5197bfc149dc}{setup}} (int req\+Order, double sample\+Rate, double center\+Frequency, double width\+Frequency)
\item
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass_ac33b003f6c77021f90a998d0e03b0e4d}{setupN}} (double center\+Frequency, double width\+Frequency)
\item
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass_a50e74a28deeaaa6d4df4c68b3ae562a7}{setupN}} (int req\+Order, double center\+Frequency, double width\+Frequency)
\end{DoxyCompactItemize}

\doxysubsubsection{Detailed Description}
\subsubsection*{template$<$int Filter\+Order = 4, class State\+Type = Direct\+Form\+II$>$\newline
struct Iir\+::\+Butterworth\+::\+Band\+Pass$<$ Filter\+Order, State\+Type $>$}

\mbox{\hyperlink{namespaceIir_1_1Butterworth}{Butterworth}} Bandpass filter.
\begin{DoxyParams}{Parameters}
{\em Filter\+Order} & Reserves memory for a filter of the order Filter\+Order \\
\hline
{\em State\+Type} & The filter topology\+: \mbox{\hyperlink{classIir_1_1DirectFormI}{Direct\+FormI}}, \mbox{\hyperlink{classIir_1_1DirectFormII}{Direct\+Form\+II}}, ... \\
\hline
\end{DoxyParams}

\doxysubsubsection{Member Function Documentation}
\mbox{\Hypertarget{structIir_1_1Butterworth_1_1BandPass_a73d7b106f2da5ccd5defe5e86f7b8ffd}\label{structIir_1_1Butterworth_1_1BandPass_a73d7b106f2da5ccd5defe5e86f7b8ffd}}
\index{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}!setup@{setup}}
\index{setup@{setup}!Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}}
\doxyparagraph{\texorpdfstring{setup()}{setup()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily template$<$int Filter\+Order = 4, class State\+Type  = Direct\+Form\+II$>$ \\
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass}{Iir\+::\+Butterworth\+::\+Band\+Pass}}$<$ Filter\+Order, State\+Type $>$\+::setup (\begin{DoxyParamCaption}\item[{double}]{sample\+Rate,  }\item[{double}]{center\+Frequency,  }\item[{double}]{width\+Frequency }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

Calculates the coefficients with the filter order provided by the instantiation
\begin{DoxyParams}{Parameters}
{\em sample\+Rate} & Sampling rate \\
\hline
{\em center\+Frequency} & Centre frequency of the bandpass \\
\hline
{\em width\+Frequency} & Width of the bandpass \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{structIir_1_1Butterworth_1_1BandPass_a4e01abd204275ae2223e5197bfc149dc}\label{structIir_1_1Butterworth_1_1BandPass_a4e01abd204275ae2223e5197bfc149dc}}
\index{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}!setup@{setup}}
\index{setup@{setup}!Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}}
\doxyparagraph{\texorpdfstring{setup()}{setup()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily template$<$int Filter\+Order = 4, class State\+Type  = Direct\+Form\+II$>$ \\
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass}{Iir\+::\+Butterworth\+::\+Band\+Pass}}$<$ Filter\+Order, State\+Type $>$\+::setup (\begin{DoxyParamCaption}\item[{int}]{req\+Order,  }\item[{double}]{sample\+Rate,  }\item[{double}]{center\+Frequency,  }\item[{double}]{width\+Frequency }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

Calculates the coefficients
\begin{DoxyParams}{Parameters}
{\em req\+Order} & The actual order which can be less than the instantiated one \\
\hline
{\em sample\+Rate} & Sampling rate \\
\hline
{\em center\+Frequency} & Centre frequency of the bandpass \\
\hline
{\em width\+Frequency} & Width of the bandpass \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{structIir_1_1Butterworth_1_1BandPass_ac33b003f6c77021f90a998d0e03b0e4d}\label{structIir_1_1Butterworth_1_1BandPass_ac33b003f6c77021f90a998d0e03b0e4d}}
\index{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}!setupN@{setupN}}
\index{setupN@{setupN}!Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}}
\doxyparagraph{\texorpdfstring{setupN()}{setupN()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily template$<$int Filter\+Order = 4, class State\+Type  = Direct\+Form\+II$>$ \\
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass}{Iir\+::\+Butterworth\+::\+Band\+Pass}}$<$ Filter\+Order, State\+Type $>$\+::setupN (\begin{DoxyParamCaption}\item[{double}]{center\+Frequency,  }\item[{double}]{width\+Frequency }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

Calculates the coefficients with the filter order provided by the instantiation
\begin{DoxyParams}{Parameters}
{\em center\+Frequency} & Normalised centre frequency (0..1/2) of the bandpass \\
\hline
{\em width\+Frequency} & Width of the bandpass in normalised freq \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{structIir_1_1Butterworth_1_1BandPass_a50e74a28deeaaa6d4df4c68b3ae562a7}\label{structIir_1_1Butterworth_1_1BandPass_a50e74a28deeaaa6d4df4c68b3ae562a7}}
\index{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}!setupN@{setupN}}
\index{setupN@{setupN}!Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$@{Iir::Butterworth::BandPass$<$ FilterOrder, StateType $>$}}
\doxyparagraph{\texorpdfstring{setupN()}{setupN()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily template$<$int Filter\+Order = 4, class State\+Type  = Direct\+Form\+II$>$ \\
void \mbox{\hyperlink{structIir_1_1Butterworth_1_1BandPass}{Iir\+::\+Butterworth\+::\+Band\+Pass}}$<$ Filter\+Order, State\+Type $>$\+::setupN (\begin{DoxyParamCaption}\item[{int}]{req\+Order,  }\item[{double}]{center\+Frequency,  }\item[{double}]{width\+Frequency }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

Calculates the coefficients
\begin{DoxyParams}{Parameters}
{\em req\+Order} & The actual order which can be less than the instantiated one \\
\hline
{\em center\+Frequency} & Normalised centre frequency (0..1/2) of the bandpass \\
\hline
{\em width\+Frequency} & Width of the bandpass in normalised freq \\
\hline
\end{DoxyParams}

The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item
iir/Butterworth.\+h\end{DoxyCompactItemize}


%!TEX root = ../thesis.tex
%*******************************************************************************
%****************************** Second Chapter *********************************
%*******************************************************************************

\chapter{Computational methods \label{chap:2}}
%
\ifpdf
    \graphicspath{{Chapter2/Figs/Raster/}{Chapter2/Figs/PDF/}{Chapter2/Figs/}{Chapter2/Figs/Vector/}}
\else
    \graphicspath{{Chapter2/Figs/Vector/}{Chapter2/Figs/}}
\fi
%
Theories behind the calculations are the core component in the theoretical determination of material properties. Its correctness, accuracy and implementation directly influence the quality of its predictions. In this chapter, I will introduce relevant theoretical models, approximations and their implementations in commonly used software packages.
%
\section{Theory}
\subsection{Density Functional Theory}
%
Density functional theory (DFT) is one of the most widely used quantum mechanical methods to calculate the properties of materials. Its applicable length and time scales are in nanometre and picoseconds, respectively. These scales are longer than that for quantum Monte Carlo simulations but lower than that for semi- or full-empirical methods. This is also true in the accuracy verse size-of-the-system plot in \autoref{fig:dft_ac}. In this figure, four types of popular computational methods are compared. They each have a total number of atoms that they can handle and a typical magnitude of error that can be expected in the total energy of the system under study. For these methods, generally, the more atoms that can be simulated, the larger the error it contains. However, this is less important to make some qualitative conclusions or to study properties at a larger length scale. However, the accuracy of the different methods can be higher than what is shown in the figure, this is because a large part of the error can also be attributed to uncertainties of the experimental results with which these methods are compared\cite{Kirklin2015}. As I will discuss further, if a DFT method is compared with a highly accurate theoretical benchmark method, DFT will have typically a precision around 1 meV/atom. Particularly, for bulk or nanostructures, DFT can be therefore used to even quantitatively predict the properties of materials. Since DFT is based on the Hohenberg-Kohn theorems\cite{Hohenberg1964} and Kohn-Sham equations\cite{Kohn1965}, I will briefly give an overview of them without putting too much stress on their derivations which have been extensively documented in textbooks.
%
\begin{figure}[htbp!]
\centering
\includegraphics[width=0.9\textwidth]{dft1.jpg}
\caption[Comparison of different electronic structure calculation methods]{ Comparison of the accuracy and the size of different electronic structure calculation methods. Image source: Ref. \cite{dft_ac}}
\label{fig:dft_ac}
\end{figure}
%

Materials are made from atoms that contain electrons and nuclei. The type of nuclei and the interactions between these give rise to various materials and their properties. The interactions are mainly electrostatic or Coulombic. While electrons must be described with quantum mechanics, the nuclei can be treated as classical particles. The equation governing the electron behaviour is the Schr\"{o}dinger equation. It can be written as follows:\footnote{Equations in this chapter are written using atomic units: fundamental constants $\hbar$, $e$ and $m_e$ are set to unity.}
\begin{equation}\begin{aligned}
\hat{H}\mathit{\Psi}_\alpha &(\vec{r_1}\sigma_1,\ldots,\vec{r_N}\sigma_N) \\
&=\left[ -\frac{1}{2}\sum^N_{i=1}\nabla_i^2+\sum^N_{i=1}\upsilon(\vec{r}_i)+\frac{1}{2}\sum_{i=1}\sum_{j\neq i}\frac{1}{|\vec{r}_i-\vec{r}_j|}\right]\mathit{\Psi}_\alpha(\vec{r_1}\sigma_1,\ldots,\vec{r_N}\sigma_N)  \\
&=\left( \hat{T} + \hat{V}_{ext} + \hat{V}_{ee}\right)\mathit{\Psi}_\alpha(\vec{r_1}\sigma_1,\ldots,\vec{r_N}\sigma_N) \\
&=E_\alpha\mathit{\Psi}_\alpha(\vec{r_1}\sigma_1,\ldots,\vec{r_N}\sigma_N) .
\end{aligned}\end{equation}
In the above equation, $\hat{H}$ is the total Hamiltonian, $\hat{T}$ is the kinetic energy, $\hat{V}_{ext}$ is the interaction between electrons and nuclei. Here we already started with the first approximation: Born–Oppenheimer approximation\cite{Born1927}. This approximation neglects the dynamics of nuclei, thus electrons are considered moving in a static potential generated by their interaction with all nuclei. $\hat{V}_{ee}$ is the Coulomb interaction between electrons. The first two terms sum over all $N$ electrons, and the last one sums over all pairs of $N$ electrons. $\vec{r}$ is the electron position, and $\sigma$ is the z-component of the electron spin (+$\frac{1}{2}$,-$\frac{1}{2}$). $\mathit{\Psi}$ is the $N$-electron wave function, which should be antisymmetric under the interchange of the orbital and the spin coordinates of two electrons (i.e. fermionic character of electrons) and it should also satisfy the boundary condition of the system (e.g. quantum confinement in a low-dimensional system). $E$ is the total energy, and $\alpha$ is the complete set of $N$-electron quantum numbers.

Following the constrained search algorithm introduced by M. Levy\cite{Levy1979}, the ground-state energy $E$ can be found by minimizing the expectation value of the total Hamiltonian with respect to the wave function:
\begin{equation}
E=\min_\mathit{\Psi}\bra{\mathit{\Psi}}\hat{H}\ket{\mathit{\Psi}}.
\end{equation}
Here we take two steps for the minimization. For the first step, we minimize with respect to all wave functions that give the same density $n(\vec{r})$:
\begin{equation}
E=\min_{\mathit{\Psi}\rightarrow n}\bra{\mathit{\Psi}}\hat{T}+\hat{V}_{ee}\ket{\mathit{\Psi}}+\int dr^3\upsilon(\vec{r})n(\vec{r}).
\end{equation}
Then with the resulting wave function $\mathit{\Psi}^{min}_n$ that yields the minimum energy $E$, an overall electron density $n(\vec{r})$ is associated. We can construct the universal functional $F[n(\vec{r})]$:
\begin{equation}
\min_{\mathit{\Psi}\rightarrow n}\bra{\mathit{\Psi}}\hat{T}+\hat{V}_{ee}\ket{\mathit{\Psi}}=\bra{\mathit{\Psi}^{min}_n}\hat{T}+\hat{V}_{ee}\ket{\mathit{\Psi}^{min}_n}=F[n(\vec{r})].
\end{equation}
For the second step, we minimize with respect to the density $n(\vec{r})$:
\begin{equation}
E=\min_n \left\lbrace F[n(\vec{r})] + \int dr^3\upsilon(\vec{r})n(\vec{r}) \right\rbrace,
\end{equation}
where $\upsilon(\vec{r})$ is kept fixed during the minimization. The resulting density is the ground-state density that gives the ground state energy. This is known as the density variational principle, which is also the main idea of the Hohenberg-Kohn theorems. For completeness I present the theorems below:
\begin{theorem}
The external potential, $V_{ext}(\vec{r})$, of any system of interacting particles is uniquely determined (up to a constant) by the particle density, $n_0(\vec{r})$, of the ground state.
\end{theorem}
\begin{theorem}
The ground state energy of a system with an external potential $V_{ext}(\vec{r})$ is given by the minimum value of the energy functional $E_{HK} [n]$ and the density for which this minimum is reached corresponds with the ground state density $n_0(\vec{r})$.
\end{theorem}
Now, the main problem is to find an approximate expression for $F[n(\vec{r})]$. The Kohn-Sham equation is an elegant way to do this. It aims to construct a non-interacting system where the kinetic energy can be calculated exactly, and a local external potential $V_{KS}(\vec{r})$ is added. The functional $F[n]$ decomposes into the following, where $E_{XC}[n]$ is the exchange-correlation (XC) energy:
\begin{equation}
F[n]=T_s[n]+E_H[n]+E_{XC}[n],
\end{equation}
where $T_s[n]$ is the non-interacting kinetic energy functional, and $E_H[n]$ is the Hartree energy functional:
\begin{equation}
E_H[n]=\frac{1}{2}\int d^3r\int d^3r'\frac{n(\vec{r})n(\vec{r'})}{|\vec{r}-\vec{r'}|}.
\end{equation}
Apart from the last term, $E_{XC}[n]$, everything else can be calculated exactly for a non-interacting system for given density. By imposing a normalisation constraint on the electron density, $\int n(\vec{r})d\vec{r}=N$, we have
\begin{equation}
\frac{\delta F[n]}{\delta n(\vec{r})}=-\upsilon(\vec{r}).
\end{equation}
Therefore, the effective local potential $V_{KS}(\vec{r})$ will be
\begin{equation}
V_{KS}(\vec{r})=\upsilon(\vec{r})+\frac{\delta E_H[n]}{\delta n(\vec{r})}+\frac{\delta E_{XC}[n]}{\delta n(\vec{r})},
\end{equation}
and the Kohn-Sham equation reads
\begin{equation}\label{eq:1}
\left[ -\frac{1}{2}\nabla_i^2+\upsilon(\vec{r})+\frac{\delta E_H[n]}{\delta n(\vec{r})}+\frac{\delta E_{XC}[n]}{\delta n(\vec{r})}\right]\mathit{\psi}_\alpha(\vec{r}\sigma)=\varepsilon_\alpha\mathit{\psi}_\alpha(\vec{r}\sigma),
\end{equation}
with ground-state electron density given by
\begin{equation}\label{eq:2}
n(\vec{r})=\sum_\alpha^{occ.}\sum_\sigma|\mathit{\psi}_\alpha(\vec{r}\sigma)|^2.
\end{equation}
These set of equations can be solved self-consistently. An initial guess of the density $n(\vec{r})$ determines the effective potential $V_{KS}(\vec{r})$, then the wave functions $\mathit{\psi}_\alpha(\vec{r}\sigma)$ can be calculated from \autoref{eq:1}, a new density is calculated through \autoref{eq:2}. This procedure is repeated until self-consistency is reached.
\subsection{Exchange-correlation functional}
The XC energy functional is not known exactly and therefore needs to be approximated. The choice of it directly influences the accuracy of the results. This is because, although it is often a small fraction of the total energy, its contribution to the chemical bonding and the formation energy is relatively important. For the XC approximation, the generalized gradient approximation (GGA) has become popular in solid state calculations. It is a further upgrade of its previous version, the local density approximation (LDA). The LDA has the following form:
\begin{equation}
E_{XC}^{LDA}[n]=\int n(\vec{r})\epsilon_{XC}[n(\vec{r})]d\vec{r}.
\end{equation}
$\epsilon_{XC}[n(\vec{r})]$ is the XC energy for an homogeneous electron gas having density $n$, and it is usually taken from quantum Monte Carlo calculations. The GGA further includes the derivative of the density, $\nabla n(\vec{r})$, as an argument for $\epsilon_{XC}$, thus it reads
\begin{equation}
E_{XC}^{GGA}[n]=\int \epsilon_{XC}[n(\vec{r}),\nabla n(\vec{r})]d\vec{r}.
\end{equation}
In contrast to LDA, there is no unique input for $\epsilon_{XC}[n(\vec{r}),\nabla n(\vec{r})]$. Different constructions for GGA usually named after the corresponding authors, e.g. PW91-GGA stands for Perdew and Wang's GGA construction in 1991\cite{Perdew1991,Perdew1992} and PBE-GGA stands for \citet{GGA-PBE2}'s construction. They are the most popular GGA approximations for solid state systems.
\subsubsection{Jacob's ladder}
Jacob's ladder is a ladder connecting earth and heaven that biblical Patriarch Jacob dreamed about. Professor John P. Perdew, who is known for his profound contributions to DFT and XC functionals, used it analogously to describe the hierarchy of density functional approximations in terms of their accuracies\cite{van2001density}, see \autoref{fig:dft_jl}.
\begin{figure}[htb]
\centering
\includegraphics[width=0.7\textwidth]{jacobs.png}
\caption[Jacob's ladder for DFT approximations]{ Jacob's ladder for DFT approximations. Image source: Ref. \cite{Peng2016}}
\label{fig:dft_jl}
\end{figure}
Each rung is a level of approximation constructed with different formalisms. From LDA and GGA as mentioned before to meta-GGA which includes the Kohn-Sham kinetic energy density. The next method up the ladder is the hybrid functionals which incorporate a part of the exact exchange from Hartree-Fock (HF) theory and result in Heyd-Scuseria-Ernzerhof (HSE) functionals. For example, the PBE0 functional\cite{Carlo1999} has the following definition:
\begin{equation}
E_{XC}^{PBE0}=\frac{1}{4}E_X^{HF}+\frac{3}{4}E_X^{PBE}+E_C^{PBE}.
\end{equation}
The HSE06\cite{Jochen2003} takes into account the screened Coulomb potential for the exact part:
\begin{equation}
E_{XC}^{HSE}=\beta E_X^{HF,SR}(\omega)+(1-\beta)E_X^{PBE,SR}(\omega)+E_X^{PBE,LR}(\omega)+E_C^{PBE},
\end{equation}
where $\beta$ is the mixing parameter and $\omega$ is the parameter to control the screening range which defines the short-range, SR, and long-range, LR, parts. The values $\beta=1/4$ and $\omega=0.2$ are typically used in the HSE06 functional which turns out to give accurate band gaps and lattice constants, see the mean absolute error (MAE) of different functionals in \autoref{fig:dft_ex}.
\begin{figure}[htbp!]
\centering
\includegraphics[width=0.9\textwidth]{lat_ex.eps}
\caption[The MAE of the equilibrium lattice constant and band gap of different functionals]{ MAE of the equilibrium lattice constants and band gaps of different functionals on SC40 solid test set\protect\footnotemark[1]. Data source: \cite{Lucero2012}}
\label{fig:dft_ex}
\end{figure}
\footnotetext[1]{The SC40 test set is a collection of 40 elementary and binary solid compounds of various structures having a wide range of band gaps.}
The highest ranked funcional is the double hybrid which includes the unoccupied orbitals as well, e.g. Random Phase Approximation\cite{Langreth1980}.
\subsubsection{Band gap problem}
As shown in \autoref{fig:dft_ex}, band gaps estimated in LDA and GGA are quite poor. This can be attributed to the highly non-analytical and non-local behaviour of the XC energy functional. To understand this, let's look at the definition of the band gap $E_{g}$:
\begin{equation}
E_{g}=I-A=\varepsilon_{N+1}^{KS,HOMO}-\varepsilon_N^{KS,HOMO},
\end{equation}
where $I$ is the ionization energy, which is the energy change by removing one valence electron. $A$ is the electron affinity, which is the energy change by adding one electron to a neutral system. $\varepsilon_N^{KS}$ is the Kohn-Sham orbital energy for N-electron system. $HOMO$ and $LUMO$ stand for the highest and the lowest occupied molecular orbital, respectively. For a non-interacting Kohn-Sham system, $E_{g}^{KS}$ can be calculated as follows:
\begin{equation}
E_{g}^{KS}=\varepsilon_{N}^{KS,LUMO}-\varepsilon_{N}^{KS,HOMO}.
\end{equation}
This leads to
\begin{equation}
E_{g}=E_{g}^{KS}+\Delta_{XC},
\end{equation}
where $\Delta_{XC}$ is the orbital shift caused by adding an extra electron: $\varepsilon_{N+1}^{KS,HOMO}-\varepsilon_{N}^{KS,LUMO}$.
\begin{figure}[htbp!]
\centering
\includegraphics[width=0.9\textwidth]{Eg.eps}
\caption[Schematic illustration of the relation between $E_g$ and $E^{KS}_g$]{ Schematic illustration of the relation between $E_g$ and $E^{KS}_g$. Image is adapted from Ref. \cite{fiolhais2008primer}.}
\label{fig:dft_eg}
\end{figure}
The $\Delta_{XC}$ exclusively depends on the non-analyticity of the XC potential $\frac{\delta E_{XC}[n]}{\delta n(\vec{r})}$, since the Hartree potential explicitly depends on the density. In other words, it means the energy increase by adding an extra electron in the extended system is of the order of 1 eV, even though, it is an infinitesimal density change. If the XC energy functional were analytic, the infinitesimal density variation would not introduce a large potential change, hence $\Delta_{XC}$ is small or equals to zero, and $E_g \approx E^{KS}_g$. The accuracy of the band gap, when compared to experiment, would has been only limited by the error that is inherent to the different functionals. However, $\Delta_{XC}$ usually is not zero in reality and it is responsible for the 80\% of the LDA band gap error\cite{Godby1988}.
\section{Implementation}
The implementations of the above theory are crucial and not straightforward. Many of the quantities are represented with technically easy-implemented functions, and they have to be finite in size or quantity. A question will rise on how large the size or the resolution has to be. This is equivalent to the computational convergence. Here we review two of the most important convergence parameters: number of $\mathbf{k}$ points and cut-off energy of the basis set.
\subsubsection{k points}
According to Bloch's theorem, the solution of the Schr\"{o}dinger equation for a periodic system, e.g. a crystal with a well-defined unit cell, can be expressed as follows:
\begin{equation}\label{imp:bloch}
\phi_{\mathbf{k}}(\mathbf{r})=e^{i\mathbf{k}\cdot\mathbf{r}}u_{\mathbf{k}}(\mathbf{r}),
\end{equation}
where $\phi$ is the wave function, $u$ is a function having the same periodicity as the crystal. The vectors $\mathbf{r}$ and $\mathbf{k}$ are associated with the real and the reciprocal space ($\mathbf{k}$ space), respectively. Particularly, each point in $\mathbf{k}$ space is associated with a unique $\mathbf{k}$ vector and is usually called a $\mathbf{k}$ point. Making use of the translational symmetry of the system, all inequivalent $\mathbf{k}$ points are contained inside a finite subspace of $\mathbf{k}$ space, called the first Brillouin zone (FBZ). Quantity evaluations are mostly done through the integration of wave functions, or other functions having $\mathbf{k}$ dependence, over the FBZ. This integration has to be done numerically since the explicit relation of $\phi$ and $\mathbf{k}$ is unknown. In practice, the FBZ is discretized into a grid defined by the mesh of the k-points. This mesh has to be large enough for accurate sampling of the FBZ, yet it should be small enough to reduce the computational time and computer memory. This is one of the convergence tests that need to be done in order to obtain reliable results. Usually, metals need more k-points than semiconductors. This is because the highest occupied valence band crosses the Fermi energy in metals, hence the integration for all occupied states is done for a discontinuous function that excludes unoccupied states.  Whereas for a semiconductor or insulator, the highest occupied valence band is completely occupied, therefore the integration is for a continuous function. Smearing is one of the ways to transform a discontinuous function in a metal into a continuous one by smearing out the edge using a smearing function, e.g. a Fermi-Dirac function. The range of smearing has to compromise between the computation efficiency and correctness: Too large will give wrong integration results of the total energy, while too small becomes useless, therefore one again needs more k-points.
\subsubsection{Basis set, cut-off energy }
Now let us look back at \autoref{imp:bloch}. There we can identify $e^{i\mathbf{k}\cdot\mathbf{r}}$ as a plane wave, $u_{\mathbf{k}}(\mathbf{r})$ is periodic in space and it can be expanded in terms of a set of plane waves as well:
\begin{equation}
u_{\mathbf{k}}(\mathbf{r})=\sum_{\mathbf{G}}c_{\mathbf{G}}e^{i\mathbf{G}\cdot\mathbf{r}},
\end{equation}
where $c_{\mathbf{G}}$ is the coefficient that determines the magnitude of the plane wave $e^{i\mathbf{G}\cdot\mathbf{r}}$. \hyperref[imp:bloch]{Equation (\ref*{imp:bloch})} can now exclusively be represented as a sum over plane waves:
\begin{equation}
\phi_{\mathbf{k}}(\mathbf{r})=\sum_{\mathbf{G}}c_{\mathbf{k+G}}e^{i\mathbf{k+G}\cdot\mathbf{r}}.
\end{equation}
The summation in the above equation, for practical reasons, has to be truncated. The truncation is usually done for the kinetic energy:
\begin{equation}
E=\frac{1}{2}|\mathbf{k+G}|^2.
\end{equation}
The maximum kinetic energy, $E_{cut}$, is associated with a $\mathbf{G}$ vector and defines the limit of the summations. Here we arrived at another convergence parameter: the plane wave cut-off energy. Similar to the number of $\mathbf{k}$ points, it has to be large enough for the total energy to be converged in an acceptable precision range.  While too large will cost more computational resources without additional benefits.
\subsubsection{Pseudopotentials and projected augmented-wave method}
Considering the chemical inertness of the core electrons and their highly oscillating wave functions, their impact on the valence electrons is generally approximated by pseudopotentials in order to optimize the computational efficiency. It is a smooth function and has the ability to reconstruct the original core electron properties. Transferability of a pseudopotential is one of the most important factors that determine the performance of the potentials. In practice, a pseudopotential is usually constructed for one isolated atom of one element, while being used in complex multi-elements systems, the potentials with higher transferability can simulate a real atom within different environments. Ultrasoft \cite{Ultrasoft1} and projected augmented-wave (PAW) \cite{PAW1,Kresse1999} are two types of the most popular pseudopotentials-based methods used in materials simulations. They are well-balanced between accuracy and computational cost. In this thesis, the PAW method is exclusively used for all calculations. This method combines the ideas of the pseudopotential methods and all-electron methods. Similar as in the case of pseudopotentials, in PAW, the true wave function $\ket{\Psi_n}$ that is obtained from all-electron methods can be transformed into a smooth auxiliary function $\ket{\tilde{\Psi}_n}$ by a linear transformation operator $\mathcal{T}$. The partial waves $\ket{\phi_i}$ form the complete basis set in which the wave function is expanded and it can be also related to auxiliary partial waves $\ket{\tilde{\phi}_i}$:
\begin{equation}
\ket{\phi_i}=\mathcal{T}\ket{\tilde{\phi}_i},
\end{equation}
where $i$ is a complete set of quantum numbers. The true and the auxiliary wave functions are identical outside the cut-off radius $r_c$:
\begin{equation}
\phi_i(\mathbf{r})=\tilde{\phi}_i(\mathbf{r})\text{, for }|\mathbf{r}-\mathbf{R}|>r_c,
\end{equation}
where $\mathbf{R}$ is the position of the atom. The transformation operator $\mathcal{T}$ takes the following form:
\begin{equation}
\mathcal{T}=1+\sum_i(\ket{\phi_i}-\ket{\tilde{\phi}_i})\bra{\tilde{p}_i},
\end{equation}
where $\tilde{p}_i$ are the projector functions that capture the character of the true wave function within a radius of $r_c$. Now the all-electron wave functions can be reconstructed through the smooth auxiliary functions and projector functions :
\begin{equation}
\ket{\Psi_n}=\ket{\tilde{\Psi}_n}+\sum_i(\ket{\phi_i}-\ket{\tilde{\phi}_i})\braket{\tilde{p}_i|\tilde{\Psi}_n}.
\end{equation}
The PAW method expresses the true all-electron wave functions with smooth functions that can be easily implemented and perform more efficiently as compared to the all-electron wave functions. Moreover, the accuracy of the calculations are comparable to that for the all-electron ones.
\subsection{Software Packages}
There are more than 70 different software packages capable of performing density functional theory calculations according to Wikipedia\cite{dft_sws}. They mainly differ in the type of pseudopotentials, the type of basis set that is used to expand the wave function, in which programming language it is written and whether or not it is free or commercial etc. \citet{Lejaeghereaad3000} have compared 40 different implementations and their accuracy by comparing their results to a highly accurate all-electron method. They concluded that all codes or methods yield generally consistent results. The accuracy of the codes which were developed in recent years is higher than the earlier ones. The Vienna $Ab$ $initio$ Simulation Package (VASP)\cite{VASP1,VASP2} with its PAW method is one of the most accurate codes that was investigated in this study. Its well-optimized performance on supercomputers gives good results in less time as compared with the others. Therefore, this code will be used as the main tool for all the calculations done in this thesis.


\chapter{Numerical results}

The chargino production cross-section at tree-level given by~\rf{chargeCross}
depends on the parameters $\mu$, $\beta$, $m_{\tilde\Lambda}$ and the mass $m_{\tilde{\nu}}$
of the lightest scalar neutrino. It also depends on
the sneutrino decay rate because the possibility to have stable
sneutrinos is excluded by a combination of the bound
obtained from precise measurements of the decay width
of the $Z$ boson at LEP~\cite{LEPConstrainOnStableSneutrino}
and the limits derived from the unsuccessful search for relic
sneutrinos~\cite{GermaniumConstrainOnStableSneutrino}. In principle
such decay rate can be calculated by means of the radiative corrections
and would eventually depend on almost all MSSM parameters, but I treat it
as an independent parameter. I also will mostly consider the cases of a heavy
scalar neutrino, $m_{\tilde\nu} \approx 500$ GeV.

\footnote{
The source of C++ code that I have used to calculate the numerical
results of this chapter is available on WWW as the compressed tar archive at
``http://www.fi.uib.no/{\char126}boukanov/dipl/prog/thesis-prog-source.tgz''.
}

\P
If CP symmetry is violated in the chargino sector it would mean that
$\Im(\mu) \ne 0$. This effect would influence on the chargino masses
given by~\rf{charginoMasses} and the production cross section
through its dependence on the matrices $X$ and $Y$, see~\rf{lagran-X-andY-is}.
According to ~\rf{charginoMasses} and~\rf{lagran-X-andY-is} the contribution
from $\Arg(\mu)$ would be most noticeable in the case when
$\tan\beta \approx 1$ and $\abs\mu \approx M_{\tilde\Lambda}$.
It is illustrated on the Fig.~5.1 where
$m_\chi$ and $\sigma^T$ are given as functions
of $\abs\mu$ and $\Arg(\mu)$.
The graphs also show the rather general property
that the value of $\sigma(\mu)$ lies in the interval
between $\sigma(-\abs{\mu})$ and $\sigma(\abs{\mu})$. The same holds for
the dependence of $m_\chi$ on $\mu$.
Thus although in principle chargino mass measurements may be used to
test the level of the CP violation if it is present, the accuracy requirements
for these experiments goes far beyond the level that will be available
in the nearest future.
I will assume in the following that $\Im(\mu) = 0$.

\P
To illustrate the contributions from different reaction channels
to the chargino production cross section given by~\rf{chargeCross}
I present in Fig.~5.2  $\sigma^T_{\gamma\gamma}$,
$\sigma^T_{ZZ}$, $\sigma^T_{\tilde{\nu}\tilde{\nu}}$ as functions of
the center-of-mass energy. This plot shows a typical behavior
for the cross section,
i.e. at the threshold the cross section is dominated by boson
channels of the reaction and at high energies
$\sigma^T \approx \sigma^T_{\tilde{\nu}\tilde{\nu}}$. It follows
from the assumption of heavy sneutrino and the asymptotic behavior
of the cross section in the region where $s \gg m_\chi, m_{\tilde{\nu}}$.
In this case every component but $\sigma^T_{\nu\nu}$ in~\rf{chargeCross}
goes to zero and according to~\rf{charge-total-nu-nu}
and~\rf{charge-t-plus-minus-is} I have
\bem
\lim_{s \rightarrow \infty } \sigma^T_{\nu\nu}
& = &
\lim_{s \rightarrow \infty }
{g^4 \cos^4\theta_X\over 64 \pi s^2}
\Biggl\{
{s^2 \over m_{\tilde{\nu}}\Gamma_{\tilde{\nu}}}
\arctg{m_{\tilde{\nu}}\Gamma_{\tilde{\nu}}  \over m_{\tilde{\nu}}^2}
+ 2s\ln\abs{t_+ \over t_- }
+ s
\Biggr\}
\nel
& = &
{g^4 \cos^4\theta_X\over 64 \pi m_{\tilde{\nu}}\Gamma_{\tilde{\nu}}}
\arctg{\Gamma_{\tilde{\nu}} \over m_{\tilde{\nu}}}
.
\ee

Thus at the high $s$ the cross section will approach its limit given by
\be
\lim_{s \rightarrow \infty } \sigma^T
=
{g^4 \cos^4\theta_X\over 64 \pi m_{\tilde{\nu}}\Gamma_{\tilde{\nu}}}
\arctg{\Gamma_{\tilde{\nu}} \over m_{\tilde{\nu}}}
.
\ee

\P
The plots given in Fig.~5.3--5.5
demonstrates different aspects of the cross section dependence
on the theory parameters.

\begin{figure}
    \begin{center}
        \leavevmode
        \epsfxsize 138 mm
        \epsfbox{\bodyFigure{mass.mu_re-mu_im.eps}}
    \end{center}
    \begin{center}
        \label{of-mu-re-im}

        \leavevmode
        \epsfxsize 138 mm
        \epsfbox{\bodyFigure{tcs.mu_re-mu_im.eps}}

        \caption{
            Dependence of the chargino mass and cross section
            on complex value of $\mu$.
            For both cases (a) and (b)
            $\tan \beta = 1.0$ and $M_{\tilde\Lambda} = 300$ GeV.
            Part (a) shows the chargino mass, part (b)
            shows the total cross section $\sigma^T$ for
            $m_{\tilde\nu} = 500$ GeV, $\Gamma_{\tilde\nu} = 10$ GeV
            and $E_{\rm c.m.} = 500$ GeV.
        }

    \end{center}
\end{figure}

\begin{figure}
    \begin{center}
        \label{num-channels}
        \leavevmode
        \epsfxsize 138 mm
        \epsfbox{\bodyFigure{channels.eps}}
        \caption{Contribution to the cross-section of
            $e^+e^-\rightarrow \chi^+\chi^-$
            from $\gamma$, $Z^0$ and $\tilde\nu$ channels at
            $\mu = 200$ GeV, $\tan\beta = 1$, $M_{\tilde\Lambda} = 300$ GeV,
            $m_{\tilde\nu} = 500$ GeV and $\Gamma_{\tilde\nu} = 10$ GeV.
        }
    \end{center}
\end{figure}

\begin{figure}
    \begin{center}
        \label{fig-picture-A}
        \epsfxsize 138 mm
        \epsfbox{\bodyFigure{tcs.mu-beta.eps}}
        \caption{
            $\sigma^T$ as a function of $\mu$, $\tan\beta$.
            The rest set of parameters
            are fixed by $M_{\tilde\Lambda} = 300$ GeV,
            $m_{\tilde\nu} = 500$ GeV,
            $\Gamma_{\tilde\nu} = 10$ GeV
            and
            $E_{\rm c.m.} = 500$ GeV.
        }
    \end{center}
\end{figure}

\begin{figure}
    \begin{center}
        \label{fig-picture-B}
        \epsfxsize 138 mm
        \epsfbox{\bodyFigure{tcs.mu-lambda.eps}}
        \caption{
        $\sigma^T$ as a function of $\mu$, $M_{\tilde\Lambda}$ with
        $\tan\beta = 1$,
        $m_{\tilde\nu} = 500$ GeV,
        $\Gamma_{\tilde\nu} = 10$ GeV
        and
        $E_{\rm c.m.} = 500$ GeV.
        }
    \end{center}
\end{figure}

\begin{figure}
    \begin{center}
        \label{fig-Picture-N}
        \epsfxsize 138 mm
        \epsfbox{\bodyFigure{tcs.nu-E.eps}}
        \caption{
            $\sigma^T$ as a function of $m_{\tilde\nu}$, $E_{\rm c.m.}$
            with
            $\mu=300$ GeV,
            $\tan\beta = 1$,
            $M_{\tilde\Lambda} = 300$ GeV
            and
            $\Gamma_{\tilde\nu} = 10$ GeV.

        }
    \end{center}
\end{figure}


\chapter*{Abstract}
This thesis deals with the problem of generating test data for indoor localization and mapping systems using acoustic sources (speakers) and receivers (microphones) in a given environment.
In particular methods of ray tracing and ultrasonic path evaluation will be explored and presented.
The suggested methods have been implemented in an Acoustic Ray Tracing Simulator (ARTS).
\newline ARTS is able to generate test sample data for a set of receivers by approximating the propagation of sound waves from acoustic sources as rays in a 3D modeled environment.
The geometry of the environment is provided by 3D data from tools which support the Wavefront OBJ file format.
Using this data and the geometric ray tracing method, reflections up to third order are being computed and sampled at the receivers end.
The sampled data can then be used in localization or mapping systems to evaluate different environments and setups.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Restoring the Dynamic Gradual Guarantee with Type Parameters}
\label{chap:Dynamic}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

In \Cref{sec:gradual:type:trans} we have seen an example where a single source expression could
produce two different target expressions with different runtime behaviors. As we
explained, this is due to the guessing nature of the declarative system, and,
from the (source) typing point of view, no guessed type is particularly better than
any other. As a consequence, this breaks the dynamic gradual guarantee as discussed in \cref{sec:gradual:criteria}.

To alleviate this situation, we introduce \textit{static type parameters}, which
are placeholders for monotypes, and \textit{gradual type parameters}, which are
placeholders for monotypes that are consistent with the unknown type. The
concept of static type parameters and gradual type parameters in the context of
gradual typing was first introduced by \citet{garcia:principal}, and later
played a central role in the work of \citet{yuu2017poly}. In our type system,
type parameters mainly help capture the notion of \textit{representative
  translations}, and should not appear in a source program.
With them we are able to recast the dynamic gradual guarantee in terms
of representative translations, and to prove that every well-typed source expression
possesses at least one representative translation. With a
coherence conjecture regarding representative translations, the dynamic gradual
guarantee of our extended source language now can be reduced to that of \pbc.

\input{Gen/Dynamic/declarative}
\input{Gen/Dynamic/algorithm}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../Thesis"
%%% org-ref-default-bibliography: "../Thesis.bib"
%%% End:


\chapter{Joint energy-angle probability density tables}
\label{Sec:joint-table}
It is also possible to give energy-angle probability densities
as tables in \xendl.  Traditionally, the data for these tables
had to be in the laboratory coordinate system, but \xendl\ also
permits center-of-mass data.  For such data in the laboratory frame,
the \ENDL~\cite{Omega} and \ENDF\
\texttt{MF = 6, LAW = 7}~\cite{ENDFB} forms
differ slightly, and \gettransfer\ supports both formats.

The \ENDF\ manual~\cite{ENDFB} includes the format
\texttt{MF = 6, LAW = 1}, which
may be used for energy-angle probability density tables in either
the laboratory or center-of-mass frames, but the
\ENDFdata~\cite{ENDFdata} library contains no data of this form.
The \xendl\ tables of energy-angle probability density in the
center-of-mass frame are normalized differently from the
\ENDF\  \texttt{MF = 6, LAW = 1} tables, and \gettransfer\ supports only the
\xendl\ version.

The \ENDF\ \texttt{MF = 6, LAW = 7} format for tables
of values of $\pi(\Elab', \mulab \mid E)$ in the laboratory frame is as arrays
\begin{equation}
  \{ E, \{ \mulab, \{ \Elab', \pi(\Elab', \mulab \mid E) \} \} \}.
 \label{ENDF-E-mu-table}
\end{equation}
The data for the lowest incident energy $E$ are given first,
and data for a given incident energy are ordered by increasing direction cosine $\mulab$.
For fixed $E$ and $\mulab$, the data consist of pairs $\{ \Elab', \pi(\Elab', \mulab \mid E) \}$
for values of the energy $\Elab'$ of the outgoing particle.
The normalization of the data $\pi(\Elab', \mulab \mid E)$ is such that
for each incident energy $E$
the total probability is
$$
  \int_0^\infty d\Elab' \, \int_{-1}^1 d\mulab \, \pi(\Elab', \mulab \mid E) = 1.
$$

The \ENDL\ energy-angle probability density data tables
are given in the form of the product
\begin{equation}
  \pi(\Elab', \mulab \mid E) =
  \pi_\mu(\mulab \mid E)\pi_{E'}(\Elab' \mid E, \mulab),
   \label{correlated}
\end{equation}
in which $\pi_{E'}(\Elab' \mid E, \mulab)$ is normalized so that
$$
  \int_0^\infty d\Elab' \, \pi_{E'}(\Elab' \mid E, \mulab) = 1
$$
for each of the tabulated values of $E$ and~$\mulab$.

The \xendl\ format for joint energy-angle probability tables in the
center-or-mass frame is of the form
\begin{equation}
  \{ E, \{ \Ecm', \{ \mucm, \pi(\Ecm', \mucm \mid E) \} \} \}.
 \label{ENDF-E-mu-cm-table}
\end{equation}
For each incident energy~$E$, the data in Eq.~(\ref{ENDF-E-mu-cm-table})
are normalized so that
$$
  \int_0^\infty d\Ecm' \, \int_{-1}^1 d\mucm \, \pi(\Ecm', \mucm \mid E) = 1.
$$

For the sake of completeness, a description of the
\ENDF\  \texttt{MF = 6, LAW = 1} format energy-angle probability density
data is given here.  In this case, $\pi(\Ecm', \mucm \mid E)$
is represented as a product
$$
  \pi(\Ecm', \mucm \mid E) = \pi_{E'}(\Ecm' \mid E)
   \pi_\mu(\mucm \mid E, \Ecm', ).
$$
The values of $\pi_{E'}(\Ecm' \mid E)$ are given separately.
The order for the data $\pi_\mu( \mucm \mid E, \Ecm')$ is as
in Eq.~(\ref{ENDF-E-mu-cm-table}), and the normalization is
such that
$$
  \int_{-1}^1 d\mucm \, \pi_\mu(\mucm \mid E, \Ecm') = 1
$$
for each value of $E$ and $\Ecm'$.

\section{Processing of energy-angle probability density tables}
\label{Sec:joint-table-process}
The processing of joint energy-angle probability density tabulated
data by the \gettransfer\ code depends on the format of the data.
The treatment of data given in  the laboratory frame is discussed first.
In \gettransfer, energy-angle probability density
tables in the format of Eq.~(\ref{ENDF-E-mu-table}) are converted to
the format of Eq.~(\ref{correlated}) via the formulas
$$
  \pi_\mu(\mulab \mid E) = \int_0^\infty d\Elab' \, \pi(\Elab', \mulab \mid E)
$$
and
$$
  \pi_E(\Elab' \mid E, \mulab) = \frac
    {\pi(\Elab', \mulab \mid E)} {\pi_\mu(\mulab \mid E)}.
$$

With the correlated energy-angle probability density
Eq.~(\ref{correlated}), the number-preserving integral Eq.~(\ref{Inum}) is
\begin{multline}
   \Inum_{gh,\ell} =
        \int_{\calE_g} dE \, \sigma ( E ) M(E) w(E) \widetilde \phi_\ell(E)
       \, \int_{\calE_h' } d\Elab' \, \\
       \, \int_{\mulab} d\mulab \,  P_\ell( \mulab ) \pi_\mu(\mulab \mid E)\pi_E(\Elab' \mid E, \mulab),
  \label{Inum-corr}
\end{multline}
and the energy-preserving integral Eq.~(\ref{Ien}) becomes
\begin{multline}
  \Ien_{gh,\ell} =
     \int_{\calE_g} dE \, \sigma ( E ) M(E) w(E) \widetilde \phi_\ell(E)
     \, \int_{\calE_h' } d\Elab' \,  \Elab' \\
     \, \int_{\mulab} d\mulab  \,  P_\ell ( \mulab ) \pi_\mu(\mulab \mid E)\pi_E(\Elab' \mid E, \mulab).
  \label{Ien-corr}
\end{multline}

The method used by \gettransfer\ to evaluate the integrals Eqs.~(\ref{Inum-corr})
and~(\ref{Ien-corr}) is to first compute the Legendre coefficients
\begin{equation}
  \pi_\ell(\Elab' \mid E) =
  \int_{-1}^1 d\mulab  \,  P_\ell ( \mulab ) \pi_\mu(\mulab \mid E)\pi_E(\Elab' \mid E, \mulab).
  \label{get-I4}
\end{equation}
In the evaluation of this integral, the functions~$\pi_\mu(\mulab \mid E)$
and~$\pi_E(\Elab' \mid E, \mulab)$ are interpolated separately with respect to~$\mulab$
before being multiplied.
The coding for the integration of Eqs.~(\ref{InumI4})
and~(\ref{IenI4}) is then applied to obtain the transfer matrix.

The treatment of center-of-mass energy-angle probability tables
of the form Eq.~(\ref{ENDF-E-mu-cm-table}) is as described in
Section~\ref{Ch:Legendre-cm}.

\section{Input of tables of energy-angle probability densities}
The form of the input files for energy-angle probability tables
depends on whether the data is as in Eqs.~(\ref{ENDF-E-mu-table}),
(\ref{correlated}), or~(\ref{ENDF-E-mu-cm-table}).

\subsection{Input of $\pi(\Elab', \mulab \mid E)$ in the form of Eq.~(\ref{ENDF-E-mu-table})}
For tables of the energy-angle probability density $\pi(\Elab', \mulab \mid E)$
in the format Eq.~(\ref{ENDF-E-mu-table}), the identification line in
Section~\ref{model-info} is\\
      \Input{Process: ENDF Double differential EMuEpP data}{}\\
These data are always in the laboratory frame,\\
  \Input{Product Frame: lab}{}

The first lines in the data for Section~\ref{model-info} give the number~$K$
of incident energies along with the interpolation rules\\
  \Input{EMuEpPData:}{$n = K$}\\
  \Input{Incident energy interpolation:}{probability interpolation flag}\\
  \Input{Outgoing cosine interpolation:}{probability interpolation flag}\\
  \Input{Outgoing energy interpolation:}{list interpolation flag}\\
The flags for interpolation with respect to incident energy~$E$ and
direction cosine~$\mulab$ are those for probability density tables in
Section~\ref{interp-flags-probability}, and that for outgoing energy~$E'$ is
one for simple lists.

For each incident energy~$E$ there is a data section of the form\\
    \Input{ Ein:}{$E$: \quad \texttt{n = $N$}}\\
indicating that data are given for $N$ values of $\mulab$.  The block of
data corresponding to a value of $\mulab$ is of the form\\
    \Input{ mu:}{$\mulab$: \quad \texttt{n = $J$}}\\
followed by $J$ pairs of values of outgoing energy $\Elab'$ and
probability density~$\pi(\Elab', \mulab \mid E)$ .

An example of such data with energy in MeV is\\
  \Input{EMuEpPData: n = 18}{}\\
  \Input{Incident energy interpolation: lin-lin unitbase}{}\\
  \Input{Outgoing cosine interpolation: lin-lin unibase}{}\\
  \Input{Outgoing energy interpolation: lin-lin }{}\\
  \Input{ Ein: 1.748830e+00:  n = 21}{}\\
  \Input{  mu: -1.000000e+00:  n = 15}{}\\
  \Input{ \indent   1.092990e-03  0.000000e+00}{}\\
  \Input{ \indent   1.093000e-03  7.406740e-01}{}\\
  \Input{ \indent   3.278900e-03  1.166140e+00}{}\\
  \Input{ \indent   7.650800e-03  1.466540e+00}{}\\
  \Input{ \indent   1.202300e-02  1.585880e+00}{}\\
  \Input{ \indent   2.076600e-02  1.610940e+00}{}\\
   \Input{ \indent 2.951000e-02  1.546240e+00}{}\\
\Input{ \indent  5.574100e-02  1.071950e+00}{}\\
\Input{ \indent  7.104300e-02  7.097100e-01}{}\\
\Input{ \indent  8.197300e-02  4.021720e-01}{}\\
 \Input{ \indent 9.071600e-02  1.795810e-01}{}\\
\Input{ \indent  9.508800e-02  9.526480e-02}{}\\
\Input{ \indent  9.946000e-02  2.867760e-02}{}\\
 \Input{ \indent 1.016500e-01  4.692750e-03}{}\\
\Input{ \indent  1.016510e-01  0.000000e+00}{}\\
\Input{ $\cdots$}{}\\
\Input{ Ein: 2.000000e+01:  n = 21}{}\\
 \Input{  mu: -1.000000e+00:  n = 76}{}\\
\Input{ \indent  4.606790e-02  0.000000e+00}{}\\
\Input{ \indent  4.606800e-02  3.837140e-02}{}\\
\Input{ \indent  9.213400e-02  4.393050e-02}{}\\
\Input{ \indent  1.842700e-01  4.977660e-02}{}\\
\Input{ \indent  2.764100e-01  4.806820e-02}{}\\
\Input{ \indent  3.685400e-01  4.385540e-02}{}\\
\Input{ \indent  6.449500e-01  2.695920e-02}{}\\
\Input{ \indent  7.370900e-01  2.255450e-02}{}\\
 \Input{ \indent }{ etc.}

\subsection{Input of $\pi(\Elab', \mulab \mid E)$ as a product, Eq.~(\ref{correlated})}
For tables of the energy-angle probability density $\pi(\Elab', \mulab \mid E)$
given as the product in Eq.~(\ref{correlated}), the identification line in
Section~\ref{model-info} is\\
      \Input{Process: Double differential EMuEpP data transfer matrix}{}\\
These data are always in the laboratory frame,\\
  \Input{Product Frame: lab}{}

The model-dependent portion of the input file in Section~\ref{model-info}
contains a section for the angular probability density $\pi_\mu(\mulab \mid E)$
and another for the conditional probability density $\pi_E(\Elab' \mid E, \mulab)$.

The section for angular probability density starts with the lines\\
  \Input{Angular data:}{$n = K$}\\
  \Input{Incident energy interpolation:}{probability interpolation flag}\\
  \Input{Outgoing cosine interpolation:}{list interpolation flag}\\
where $K$ is the number of incident energies~$E$.  The flag for
interpolation with respect to incident energy is one of those for
probability density tables in Section~\ref{interp-flags}, and that for
the direction cosine $\mulab$ is one of those
for simple lists.  There follows $K$ blocks of data,
one for each incident energy\\
    \Input{ Ein:}{$E$: \quad \texttt{n = $N$}}\\
indicating that data are given for $N$ pairs of values of $\mulab$
and $\pi_\mu(\mulab \mid E)$.

The section for conditional probability density of outgoing energy
$\pi_E(\Elab' \mid E, \mulab)$ gives the number~$K$
of incident energies along with the interpolation rules\\
  \Input{EMuEpPData:}{$n = K$}\\
  \Input{Incident energy interpolation:}{probability interpolation flag}\\
  \Input{Outgoing cosine interpolation:}{probability interpolation flag}\\
  \Input{Outgoing energy interpolation:}{list interpolation flag}\\
The flags for interpolation with respect to incident energy~$E$ and
direction cosine~$\mulab$ are those for probability density tables in
Section~\ref{interp-flags-probability}, and that for outgoing energy~$E$ is one of those
for simple lists.

For each incident energy~$E$ there is a data section of the form\\
    \Input{ Ein:}{$E$: \quad \texttt{n = $N$}}\\
indicating that data are given for $N$ values of $\mulab$.  The block of
data corresponding to a value of $\mulab$ is of the form\\
    \Input{ mu:}{$\mulab$: \quad \texttt{n = $J$}}\\
followed by $J$ pairs of values of outgoing energy $E$ and
probability density~$\pi_E(\Elab' \mid E, \mulab)$.

An example of this type of data with energy in MeV is given by\\
  \Input{Angular data: n = 13}{}\\
  \Input{Incident energy interpolation: lin-lin unitbase}{}\\
  \Input{Outgoing cosine interpolation: lin-lin}{}\\
  \Input{ Ein:   7.78148000e+00:  n = 5}{}\\
  \Input{ \indent   9.99788143e-01   5.88016882e+01}{}\\
  \Input{ \indent   9.99841107e-01   1.03998708e+03}{}\\
  \Input{ \indent   9.99894071e-01   1.70086214e+03}{}\\
  \Input{ \indent   9.99947036e-01   2.60922780e+03}{}\\
  \Input{ \indent   1.00000000e+00   2.70023193e+04}{}\\
  \Input{ $\cdots$}{}\\
   \Input{ Ein: 2.00000000e+02: n = 5}{}\\
 \Input{ \indent -1.00000000e+00  3.26136085e-01}{}\\
 \Input{ \indent -5.00000000e-01  3.82892835e-01}{}\\
  \Input{ \indent 0.00000000e+00  4.64096868e-01}{}\\
  \Input{ \indent 5.00000000e-01  5.89499334e-01}{}\\
  \Input{ \indent 1.00000000e+00  8.00885838e-01}{}\\
   \Input{EMuEpPData: n = 13}{}\\
  \Input{Incident energy interpolation: lin-lin unitbase}{}\\
  \Input{Outgoing cosine interpolation: lin-lin unitbase}{}\\
  \Input{Outgoing energy interpolation: lin-lin}{}\\
  \Input{ Ein:   7.78148000e+00:  n = 5}{}\\
  \Input{ mu:   9.99788143e-01:  n = 4}{}\\
  \Input{ \indent   2.35390141e-03  1.62759930e+05}{}\\
  \Input{ \indent   2.35697064e-03  1.62877493e+05}{}\\
  \Input{ \indent   2.35697074e-03  1.62877496e+05}{}\\
  \Input{ \indent   2.36004196e-03  1.62892892e+05}{}\\
  \Input{ mu:   9.99841107e-01:  n = 16}{}\\
  \Input{ \indent   2.30884914e-03  9.56657064e+03}{}\\
   \Input{ \indent  2.32094195e-03  9.99310479e+03}{}\\
   \Input{ \indent}{ etc.}\\
 \Input{ Ein:  2.00000000e+02: n = 5}{}\\
\Input{  mu: -1.00000000e+00: n = 501}{}\\
  \Input{ \indent 1.00000000e-18  5.38736174e-10}{}\\
  \Input{ \indent 1.00563208e-17  1.70842412e-09}{}\\
  \Input{ \indent 1.91126417e-17  2.35524717e-09}{}\\
  \Input{ \indent 2.81689625e-17  2.85931206e-09}{}\\
  \Input{ \indent 3.72252834e-17  3.28696542e-09}{}\\
  \Input{ $\cdots$}{}\\
  \Input{ mu: 1.00000000e+00: n = 993}{}\\
  \Input{ \indent 1.00000000e-18  2.19383712e-10}{}\\
  \Input{ \indent 7.55831305e-18  6.03138181e-10}{}\\
  \Input{ \indent }{ $\cdots$}\\
  \Input{ \indent 1.32751551e+01  1.88436981e-03}{}\\
  \Input{ \indent 1.38015128e+01  1.90038969e-03}{}

 \subsection{Input of $\pi(\Ecm', \mucm \mid E)$ in the form of Eq.~(\ref{ENDF-E-mu-cm-table})}
For tables of the energy-angle probability density $\pi(\Ecm', \mucm \mid E)$
in the format Eq.~(\ref{ENDF-E-mu-cm-table}), the identification line in
Section~\ref{model-info} is\\
      \Input{Process: pointwise energy-angle data}{}\\
These data are always in the center-of-mass frame,\\
  \Input{Product Frame: centerOfMass}{}

The first lines in the data for Section~\ref{model-info} give the number~$K$
of incident energies along with the interpolation rules.  Currently,
\gettransfer\ handles only linear-linear unit-base interpolation with
respect to incident energy~$E$, linear-linear direct interpolation
with respect to outgoing energy~$\Ecm'$, and linear-linear interpolation
for the direction cosine~$\mucm$.  The input format is therefore of the form\\
  \Input{EEpMuPData:}{$n = K$}\\
  \Input{Incident energy interpolation: lin-lin unitbase}{}\\
  \Input{Outgoing energy interpolation: lin-lin direct}{}\\
  \Input{Outgoing cosine interpolation: lin-lin}{}\\

For each incident energy~$E$ there is a data section of the form\\
    \Input{ Ein:}{$E$: \quad \texttt{n = $N$}}\\
indicating that data are given for $N$ values of $\Ecm'$.  The block of
data corresponding to a value of $\Ecm'$ is of the form\\
    \Input{ Ep:}{$\Ecm'$: \quad \texttt{n = $J$}}\\
followed by $J$ pairs of values of direction cosine $\mucm$ and
probability density~$\pi(\Ecm', \mucm \mid E)$ .

An example of such data with energy in MeV is\\
  \Input{EEpMuPData: n = 15}{}\\
  \Input{Incident energy interpolation: lin-lin unitbase}{}\\
  \Input{Outgoing energy interpolation: lin-lin direct}{}\\
  \Input{Outgoing cosine interpolation: lin-lin}{}\\
 \Input{\# Start sub data}{}\\
  \Input{E:  1.002700000000e+01: n = 44}{}\\
  \Input{\# Start sub data}{}\\
  \Input{ Ep: 0.000000000000e+00 : n = 21}{}\\
   \Input{ \indent -1.000000000000e+00  1.078178702711e-01}{}\\
   \Input{ \indent -9.000000000000e-01  1.071148616947e-01}{}\\
  \Input{  \indent -8.000000000000e-01  1.064935902862e-01}{}\\
   \Input{ \indent -7.000000000000e-01  1.059535819660e-01}{}\\
  \Input{  \indent -6.000000000000e-01  1.054944246648e-01}{}\\
   \Input{ \indent -5.000000000000e-01  1.051157680091e-01}{}\\
   \Input{ \indent }{ $\cdots$}\\
  \Input{\# Start sub data}{}\\
  \Input{ Ep: 6.870524931290e-03 : n = 21}{}\\
  \Input{  \indent -1.000000000000e+00  1.078230802439e-01}{}\\
  \Input{  \indent -9.000000000000e-01  1.071184528032e-01}{}\\
   \Input{ \indent -8.000000000000e-01  1.064957460252e-01}{}\\
   \Input{ \indent -7.000000000000e-01  1.059544836844e-01}{}\\
  \Input{  \indent -6.000000000000e-01  1.054942518410e-01}{}\\
   \Input{ \indent }{ $\cdots$}\\
  \Input{\# Start sub data}{}\\
  \Input{ Ep: 4.122315000000e-01 : n = 21}{}\\
  \Input{  \indent -1.000000000000e+00  0.000000000000e+00}{}\\
  \Input{  \indent -9.000000000000e-01  0.000000000000e+00}{}\\
  \Input{  \indent -8.000000000000e-01  0.000000000000e+00}{}\\
  \Input{ $\cdots$}{}\\
  \Input{\# Start sub data}{}\\
 \Input{E =  1.100000000000e+01: n = 62}{}\\
  \Input{\# Start sub data}{}\\
  \Input{ Ep: 0.000000000000e+00 : n = 21}{}\\
  \Input{ \indent }{ $\cdots$}\


\chapter{Continuous Random Variables}

\section{Continuous random variables}
\section{Probability density functions}
\section{Cumulative distribution functions}


% !TEX root=/home/tavant/these/manuscript/src/manuscript.tex

\chapter{Evolution of the azimuthal instability and generalized dispersion relation (DR)}
\label{ch-5}

\headerchaptername{Evolution of the instability and general DR}

\begin{Chabstract}

As briefly mentioned previously, the $E \times B$ configuration of the \ac{HET} gives rise to azimuthal instabilities.
These instabilities are important for the behavior of the \ac{HET}, as they are responsible for the electron cross-field transport.
Even if these instabilities have been the subject of numerous studies, they are still not well understood.
Using the \ac{PIC} simulations, we propose new insights for the understanding of the instability.
In particular, we develop a dispersion relation solver that uses the velocity distribution function measured in the simulations.
Then, we compare the simulation instability characteristics with the dispersion relations.
A special care is taken with the boundary condition and the instability non-linear saturation.
\end{Chabstract}

%
%
% {\bf V. analyse of the instability } 30 pages
% \begin{zzz}
%   \begin{itemize}
% \item Instability dispersion relation
% \item Kinetic solver for Ion and ECDI using VDFs
% \item Impact of the difference w/r Maxwellian
% \item Wall Boundary condition, 3D dispertion relation vs 1D and 2D relations
% \item Linear stage as ECDI and Saturation toward IAW
% \end{itemize}
% \end{zzz}

\minitoc

\input{Chapitre5/50-PICresults}
\input{Chapitre5/51-DR}
\input{Chapitre5/52-solver}
\input{Chapitre5/53-results}
\input{Chapitre5/54-radialBC}
\input{Chapitre5/55-conclusion}