\documentstyle{article}    % Specifies the document style.

\headheight 0pt
\headsep 0pt
\topmargin 0pt
\oddsidemargin 0pt

\textheight 9.0in
\textwidth 6.5in

\title{ {\tt ifspppl\_model.tex} \\ The IFS/PPPL Transport Models}

\author{Version 1.31: last edited October 26, 1998 \\ 
Implemented by Aaron J.~Redd, Lehigh University \\ \\
For questions about this routine, please contact: \\
Aaron J.~Redd, Lehigh:  {\tt aredd@plasma.physics.lehigh.edu} \\
Arnold H.~Kritz, Lehigh:  {\tt kritz@plasma.physics.lehigh.edu} \\
or Glenn Bateman, Lehigh:  {\tt bateman@plasma.physics.lehigh.edu} \\ \\
Based on material provided by: \\
Bill Dorland, UMD:  {\tt bdorland@kendall.umd.edu}}

\date{typeset on \today}

\begin{document}           % End of preamble and beginning of text.
\maketitle                 % Produces the title.
\tableofcontents

\section{General Information}

The IFS/PPPL model\cite{mk95model} is an anomalous thermal transport model
based directly upon the predictions of nonlinear gyrofluid (GF) turbulence
simulations, in flux-tube geometry\cite{mbthesis}.
The turbulent ion thermal diffusivities from this nonlinear GF code
were found to correspond to mixing-length estimates based upon the linear
growth rates calculated by the same code.
The ratio $W$ of a particular turbulent $\chi_i^{\rm GF}$ to
its corresponding mixing-length estimate $D^{\rm GF}$
($D^{\rm GF} \equiv {\rm max}[\gamma/{k_\perp}^2]$) is
a weakly varying function.
Therefore, based upon a small set of GF runs, an interpolation formula
could be devised for this ratio $W$ ($\equiv \chi_i^{\rm GF}/D^{\rm GF}$).
Utilizing hundreds of runs with a comprehensive gyrokinetic (GK)
linear stability code\cite{mikek93},
Kotschenreuther, {\it et al}, were able to parametrize the dependence of
the strongly varying $D^{\rm GK}$ on various plasma parameters.
Finally, the interpolation formulas for $W$ and $D^{\rm GK}$ were joined to
form a single expression that, given a set of plasma conditions, would be a
good estimator for the nonlinear turbulent diffusivity:
$$
\chi_i = W D^{\rm GK}
\nonumber
$$
This technique represents a significant savings in human effort and
computational time, as the linear GK code can be run much faster than
the nonlinear GF code.
Furthermore, the linear GK code calculates the ratio of the electron thermal
diffusivity $\chi_e$ to the ion thermal diffusivity $\chi_i$; this ratio was
also parametrized, leading to a seperate expression for $\chi_e$.
The resulting turbulent transport model was published in 1995
as the 1995 IFS/PPPL model\cite{mk95model}.
The same techniques had also resulted in a simpler model,
published the previous year\cite{dorland94}, which is based on
simpler physics (adiabatic electrons, no collisions).

It is important to note, however, that the nonlinear GF runs that produced
the 1995 IFS/PPPL model utilized certain simplifying assumptions:
\begin{itemize}
\itemsep 0pt
\item Only carbon impurities
\begin{itemize}
\itemsep 0pt
\item the effects of low-Z impurities, like helium, are not well-described
by this model
\item it was found that high-Z impurities have little (or no)
effect upon the $\eta_i$ mode
\end{itemize}
\item $Z_{\rm eff}$ constant in space (all density gradients equal)
\item Simplified geometry:  circular flux surfaces, low $\beta$
\item No finite-$\beta$ effects
\item The IFS/PPPL work concentrated on usual ITG branch of the drift
instability.  Other branches of the drift instability ({\it i.e.},
trapped-electron modes, ubiquitous modes\cite{coppi74},
long-wavelength ITG modes (trapped-ion modes))
and finite-$\beta$ ballooning modes were not included.
\end{itemize}
There has been evidence suggesting that both the MHD equilibrium
(analytic vs numerically calculated) and the exact gyrofluid closure
have significant effects on the $\eta_i$-mode linear threshold.
Kotchenreuther, {\it et al}, took these effects into account, at least
in part, by:
\begin{itemize}
\itemsep 0pt
\item calculating the critical temperature gradient and $D^{\rm GK}$ in more
realistic equilibrium geometries
\item utilizing only the critical temperature gradients calculated from
the GK code (not from the GF code)
\end{itemize}
The Cyclone Project (1997-8), although primarily concerned with resolving
differences between the predictions of nonlinear GF and GK simulations,
also considers these last two issues.
Recent refinements of the IFS/PPPL model take account of
low or reversed magnetic shear and elongated MHD equilibria.

This implementation of the 1995 IFS/PPPL model includes the plasma elongation
stabilization factor, as presented at the 1996 Varenna Meeting\cite{varenna},
based on the effects of elongation on $D^{\rm GK}$ and the gyrokinetic
critical temperature gradient.
This coding of the transport model also includes a preliminary model
of rotational stabilization\cite{waltz94}.
Additionally, there have been several small corrections, pointed out
by Bill Dorland\cite{varenna,billd98}, to the model as it had been
presented in the 1995 paper.

Currently, the GF turbulence code, called {\tt Gryffin}, is being maintained
and developed by Mike Beer (PPPL), Bill Dorland (UMD) and Greg Hammett (PPPL).
The linear GK stability code is maintained by Mike Kotschenreuther (IFS),
and has been benchmarked against an eigenvalue kinetic stability code
(the FULL code\cite{rewoldt82,rewoldt87,rewoldt98}, written and maintained
by Gregory Rewoldt of PPPL) for a series of simple cases\cite{mk95comp}.

On a more mundane level, here are some short remarks regarding this module:
\begin{itemize}
\itemsep 0pt
\item This module is re-entrant, in the sense that it does not need to keep
calculation results from one call to the next.  It contains no Fortran
{\tt SAVE} statements.
\end{itemize}

\section{Coordinate System for the Transport Model \\
         Notes provided by Bill Dorland}

There are two important issues that must be noted:
\begin{itemize}
\item First, the formulas were derived using a radial coordinate that
differs from that of some treatments.
\item Second, since the transport coefficients are actually calculated
in general geometry, there are less assumptions regarding the form
of the transport equation to be solved.  
\end{itemize}

Consider first the $\left< | \nabla \rho | \right>$ issue:

The standard ITER database modeling assumptions include the assumption
that the anomalous fluxes for non-circular cross-sections are
simply related to the anomalous fluxes for related circular
cross-section plasmas.
That is, in order to get the factor of $\left< | \nabla \rho |^2 \right>$
that appears as a coefficient of $\chi$ in the energy transport equations,
one assumes that:
$$
\chi^{ANOM}_{\rm general} = \chi^{ANOM}_{\rm circular} \times (\nabla \rho)
\nonumber
$$
where the radial coordinate $\rho$ has units of length.

One need not make this assumption; one can just calculate the quantity 
$\chi^{ANOM}_{\rm general}$ directly.  One would then have a transport equation
of the form:
$$
\frac{d(n T)}{dt} =
\frac{1}{V'} \frac{d}{d\rho} \left[ V'
\left<|\nabla \rho|\right> \chi \left( n \frac{dT}{d\rho} \right) \right]
    + \dots
\nonumber
$$
in which $\nabla \rho$ appears to the first power, rather than the second,
and $\chi$ is the thermal diffusivity from a general geometry theory.

This is arguably the better way to proceed, since 
$$
V' \left<|\nabla \rho|\right> = A,
\nonumber
$$
where A is the surface area.  In this form, the quantity 
$$
-\chi \left( n \frac{dT}{d\rho} \right) 
\nonumber
$$
can be identified as the heat flux per unit area, a natural quantity to
utilize, from a theoretical/simulation point of view.  This $\chi$ is 
the quantity returned by this subroutine.

If you are solving the transport equations in the form that
the ITER Expert Group agreed upon, {\it e.g.},
$$
\frac{d(n T)}{dt} =
\frac{1}{V'} \frac{d}{d\rho} \left[ V'
\left<|\nabla \rho|^2\right> \chi \left( n \frac{dT}{d\rho} \right) \right]
     + \dots
\nonumber
$$
then you need to multiply the $\chi_i$ and $\chi_e$ reported by this 
subroutine by the factor
$\left<|\nabla \rho|\right>/\left<|\nabla \rho|^2\right>$.  This should
result in only small corrections to the predicted profiles.

The exact choice of radial coordinate, however, is more difficult to resolve:

We did not use the square root of the toroidal flux as the radial coordinate
in our  non-circular cross-section simulations.  Instead, we used $\rho_d$,
where $\rho_d$ is defined to be the average horizontal minor radius 
at the elevation of the magnetic axis.

In other words, denote by $d$ the horizontal diameter of a given flux
surface measured at the elevation of the magnetic axis (the midplane
width of the flux surface).  Denote by $D$ the horizontal diameter of
the last closed flux surface at the elevation of the magnetic axis.
Then, for each flux surface, $\rho_d/2 = d$ so that $0 \le \rho_d \le
D/2$.  The variable $d/2$ corresponds to variable number 68 ({\tt
RMINOR}) in the two-dimensional ITER Profile Database Standard List.

It is not difficult to allow for an arbitrary radial coordinate in
one's transport code.  One must obtain all of the radial quantities as
functions of $\rho_d$ rather than $\rho$, via interpolation.

However, not everyone is expected to go to this length to test the
IFS/PPPL model, since the sqrt(toroidal flux) definition of the radial
coordinate $\rho$ is the agreed-upon standard.  Hence, there is the
following alternative: Simply use the $\rho_d$ coordinate to define
the scale lengths that appear in the formulas below.  For most
quantities (such as $R/L_T$), this simply amounts to including an
additional factor of $d \rho/d \rho_d$ in the expressions passed to
this subroutine.  While not completely correct, this workaround
captures the dominant effect, related to evaluating the flux near the
critical gradient.

So, to summarize:
\begin{enumerate}
\item
The general geometry extensions to the IFS/PPPL model were derived 
using $\rho = \rho_d = {\tt RMINOR}$ as the radial coordinate.  To be 
most accurate, the transport equation should be solved using $\rho_d$
as the radial coordinate.

If you use $\rho$ proportional to sqrt(toroidal flux) instead of $\rho_d$
as your radial coordinate, you should at least carefully define the 
scale lengths as indicated (using $\rho_d$).

\item
This routine should be used to return the thermal transport
coefficients ($\chi_i$, $\chi_e$) for energy transport equations of the form
$$
\frac{d(n T)}{dt} =
\frac{1}{V'} \frac{d}{d\rho} \left[ V'
\left<|\nabla \rho|\right> \chi \left( n \frac{dT}{d\rho} \right) \right]
     + \dots
\nonumber
$$
Note that $\left<|\nabla \rho|\right>$ only appears to the first power,
according to this definition of $\chi$.  If your code is hardwired to solve an
equation of the form:
$$
\frac{d(n T)}{dt} =
\frac{1}{V'} \frac{d}{d\rho} \left[ V'
\left<|\nabla \rho|^2\right> \chi \left( n \frac{dT}{d\rho} \right) \right]
      + \dots
\nonumber
$$
then multiply the $\chi_i$ and $\chi_e$ obtained from this routine by 
the factor $\left<|\nabla \rho|\right>/\left<|\nabla \rho|^2\right>$.

\end{enumerate}

\section{Initial Coding}

The IFS/PPPL model routine begins as follows:

\begin{verbatim}
c
c     The 1995 and 1994 IFS/PPPL transport models
c     as implemented by Aaron J Redd, February 1998
c
c     For problems with this routine, please contact:
c        Aaron Redd, Lehigh U:  aredd@plasma.physics.lehigh.edu
c        Arnold Kritz, Lehigh U:  kritz@plasma.physics.lehigh.edu
c     or Glenn Bateman, Lehigh U:  bateman@plasma.physics.lehigh.edu
c
c     Last revision:  July 7, 1998
c
      subroutine IFSPPPL( znine, zncne, znbne, zrlt, zrln,
     &                    zq, zshat, zeps, zkappa, omegaexb,
     &                    ne19, tekev, tikev, rmajor, btesla,
     &                    switches, grhoi, gvti, gnu, gtau,
     &                    chii, chie,
     &                    zchiicyc, zchii1, zchii2, zchie1, zchie2,
     &                    zrlt1, zrlt2, ierr )
c
      IMPLICIT NONE
c
\end{verbatim}

\subsection{Input/Output Variables}

The inputs to the IFS/PPPL model can be summarized in five groups:
run I/O parameters, dimensionless inputs, dimensional inputs,
dimensional outputs and dimensionless outputs.

Currently, the run parameters consist only of the integer array
{\tt switches} and the integer flag {\tt ierr}.
Only elements 1--5 and 30--32 of {\tt switches} are actually used
by this subroutine.
{\tt ierr} is a general error flag -- it is 0 initially, but is
reset to 1 if there is a problem (input parameters outside their valid range,
for instance).
The {\tt switches} array is fully described by the following:
\begin{itemize}
\itemsep 0pt

\item {\bf switches(1)} controls the production of output directly from this
routine.
\begin{itemize}
\itemsep 0pt
\item {\tt switches(1) = 0} produces no output.
\item {\tt switches(1) = 1} produces one page of diagnostic output, writing
this information to up to three output channels (passed into the routine as
the inputs {\tt switches(30)}, {\tt switches(31)} and {\tt switches(32)}).
\end{itemize}

\item {\bf switches(2)} controls the choice of dimensioned input used by
the IFS/PPPL module.
\begin{itemize}
\itemsep 0pt
\item If {\tt switches(2) = 0} the module uses inputs {\tt ne19}, {\tt tekev},
{\tt tikev} and {\tt btesla}.
\item If {\tt switches(2) = 1} the module uses inputs {\tt grhoi}, {\tt gvti},
{\tt gnu} and {\tt gtau}.  These variables are identical to those used by
Dorland's IFS/PPPL routine, making the results from this module directly
comparable to his.
However, this method somewhat obscures the dependence of the
IFS/PPPL diffusivities upon the physical parameters of the problem
($T_i$, $T_e$, $n_e$,\dots).

Note that, in either scheme, the major radius {\tt rmajor} is required.
\end{itemize}

\item {\bf switches(3)} controls which IFS/PPPL model will be used in the
calculations (the 1995 model or the 1994 model).
\begin{itemize}
\itemsep 0pt
\item {\tt switches(3) = 0}: The module will use the
1995 model\cite{mk95model,varenna}
\item {\tt switches(3) = 1}: Module will use the 1994 model\cite{dorland94}
\end{itemize}

\item {\bf switches(4)} can modify the input value of {\tt gnu}.  The 
definition of the collisionality, $\nu$, in the fortran coding that Dorland
provided is different from that in the 1995 IFS/PPPL paper.  This switch
allows one to use for $\nu$ the value as given or to convert it to 
the comparable value that would be used in Dorland's code.
\begin{itemize}
\itemsep 0pt
\item {\tt switches(4) = 0} Use {\tt gnu} as given, if applicable.
\item {\tt switches(4) = 1} Mulitply {\tt gnu} by 0.84, in order to match
the definition in Dorland's IFS/PPPL fortran routine.
\end{itemize}

\item {\bf switches(5)} controls the restrictions on the value of {\tt znu},
the collisionality.
\begin{itemize}
\itemsep 0pt
\item {\tt switches(5) = 0} Will not relax the restrictions on {\tt znu}.
\item {\tt switches(5) = 1} Allows {\tt znu} to be larger than 10.0.
\end{itemize}

\item {\bf switches(30)}, {\bf switches(31)} and {\bf switches(32)}
are the channel numbers for diagnostic output.  These are set to zero when
not in use.  The channels are assumed to be open.

\end{itemize}

The dimensionless input quantities are as follows:
\begin{itemize}
\itemsep 0pt
\item {\bf znine} The ratio of thermal deuterium density to electron density;
${\tt znine} = n_D/n_e$
\item {\bf zncne} The ratio of thermal carbon density to electron density;
${\tt zncne} = n_C/n_e$
\item {\bf znbne} The ratio of beam deuterium density to electron density;
${\tt znbne} = n_{bD}/n_e$
\item {\bf zrlt} The ratio of major radius to ion temperature scale length;
${\tt zrlt} = R/L_{T_i} \equiv - (R/T_i)(dT_i/dr)$
\item {\bf zrln} The ratio of major radius to electron density scale length;
${\tt zrln} = R/L_{n_e} \equiv - (R/n_e)(dn_e/dr)$
\item {\bf zq} The plasma safety factor $q$
\item {\bf zshat} Magnetic shear; ${\tt zshat} \equiv (r/q) (dq/dr)$
\item {\bf zeps} Local inverse aspect ratio
\item {\bf zkappa} Local plasma elongation
\item {\bf gnu} Direct-input collisionality parameter
\item {\bf gtau} Direct-input ratio of $T_i/T_e$
\end{itemize}

The dimensional input quantities are as follows:
\begin{itemize}
\itemsep 0pt
\item {\bf ne19} Electron density $n_e$, in $10^{19}~{\rm meters}^{-3}$
\item {\bf tekev} Electron temperature $T_e$, in keV
\item {\bf tikev} Ion temperature $T_i$, in keV
\item {\bf rmajor} Major radius $R$, in meters
\item {\bf btesla} Toroidal magnetic field, in Tesla
\item {\bf grhoi} Ion gyroradius $\rho_i$, in meters.  Note, this is defined
as $v_{ti}/\omega_{ci}$ with the somewhat not standard definition for 
$v_{ti}$, namely $v_{ti}=\sqrt{T_i/m_i}$.  In the IFS/PPPL work $\omega_{ci}$
is calculated only for deuterium.
\item {\bf gvti} Ion thermal speed $v_{ti}$, in meters/second, defined
as $\sqrt{T_i/m_i}$.  Note that this is a nonstandard definition.
\end{itemize}

There are only two dimensional output quantities:
\begin{itemize}
\itemsep 0pt
\item {\bf chii} Final ion thermal diffusivity, in ${\rm m}^2/{\rm s}$
\item {\bf chie} Final electron thermal diffusivity, in ${\rm m}^2/{\rm s}$
\end{itemize}

The dimensionless output quantities are as follows:
\begin{itemize}
\itemsep 0pt
\item {\bf zchiicyc} Final ion thermal diffusivity,
normalized by $L_n/\rho_i^2 v_{ti}$
(this is the normalization used by Cyclone when $T_e=T_i$ and
there are impurities).
\item {\bf zrlt1} Critical gradient for the hydrogenic-driven $\eta_i$-mode
\item {\bf zrlt2} Critical gradient for the impurity-driven $\eta_i$-mode
\item {\bf zchii1} Ion thermal diffusivity, normalized by $R/\rho_i^2 v_{ti}$,
from the hydrogenic-driven $\eta_i$-mode
\item {\bf zchii2} Ion thermal diffusivity, normalized by $R/\rho_i^2 v_{ti}$,
due to the impurity-driven $\eta_i$-mode
\item {\bf zchie1} Electron thermal diffusivity,
normalized by $R/\rho_i^2 v_{ti}$, from the hydrogenic-driven $\eta_i$-mode
\item {\bf zchie2} Electron thermal diffusivity,
normalized by $R/\rho_i^2 v_{ti}$, due to the impurity-driven $\eta_i$-mode
\end{itemize}

For the sake of redundancy, some of the run parameter and input variable
information has been duplicated in the form of comment statements
in the fortran coding.
This information will always be available to someone who
is in possession of the routine.

These comments are:

\begin{verbatim}
c
c     switches(j) settings:
c
c        switches(1) = 0  No output
c                    = 1  Print page of inputs, computational steps and output
c        switches(2) = 0  Use first set of dimensioned input
c                         (ne19, tekev, tikev, btesla)
c                    = 1  Use second set of dimensioned/dimensionless input
c                         (grhoi, gvti, gnu, gtau)
c                         Note that, with either approach, rmajor is required.
c        switches(3) = 0  Use 1995 IFS/PPPL model
c                    = 1  Use 1994 IFS/PPPL model (IAEA paper)
c        switches(4) = 0  Use the value of gnu as given (if applicable)
c                    = 1  Multiply gnu by 0.84; this allows direct comparison
c                         with the fortran code provided by B. Dorland.
c                         There is a factor of 0.84 difference between the
c                         definition of collisionality in the 1995 published 
c                         paper and the coded implementation provided by 
c                         B. Dorland
c        switches(5) = 0  Do not relax restrictions on the value of znu
c                    = 1  Allow the value of znu to be larger than 10.0
c
c        switches(30), switches(31), switches(32)
c                       Reserved as output channel numbers
c
c        switches(j) should be defaulted to zero.
c
c     Dimensionless input parameters:
c        znine:     Ratio of thermal deuterium density to electron density
c        zncne:     Ratio of thermal carbon density to electron density
c        znbne:     Ratio of beam deuterium density to electron density
c        zrlt:      Ratio of major radius to ion temperature scale length
c        zrln:      Ratio of major radius to electron density scale length
c        zq:        Plasma safety factor
c        zshat:     Magnetic shear (defined as r/q dq/dr)
c        zeps:      Local inverse aspect ratio
c        zkappa:    Local plasma elongation
c        gtau:      Ratio of Ti/Te (used only when switches(2)=1)
c        gnu:       Local collisionality (used only when switches(2)=1)
c
c     Dimensioned input parameters:
c        ne19:      Electron density, in 10^19 meters^-3
c        tekev:     Electron temperature, in keV
c        tikev:     Deuterium ion temperature, in keV
c        rmajor:    Major radius, in meters
c        btesla:    Toroidal magnetic field, in Tesla
c        grhoi:     Local ion gyroradius, in meters (used when switches(2)=1)
c                   Input to replace calculated value for vthermi/omegaci
c        gvti:      Ion thermal speed, in m/s (used only when switches(2)=1),
c                      defined as sqrt(Ti/mi) -- nonstandard definition
c        omegaexb:  The E x B shearing rate, in inverse seconds
c
c     Dimensioned outputs:
c        chii:      Ion thermal diffusivity, in m^2/sec
c        chie:      Electron thermal diffusivity, in m^2/sec
c
c     Dimensionless outputs:
c        zchiicyc:  \chi_i, normalized by L_n/(\rho_i^2 v_{ti})
c        zchii1:    Hydrogenic \chi_i, normalized by R/(\rho_i^2 v_{ti})
c        zchii2:    Carbon-driven \chi_i, normalized by R/(\rho_i^2 v_{ti})
c        zchie1:    Hydrogenic \chi_e, normalized by R/(\rho_i^2 v_{ti})
c        zchie2:    Carbon-driven \chi_e, normalized by R/(\rho_i^2 v_{ti})
c        zrlt1:     Normalized threshold gradient for hydrogenic mode
c        zrlt2:     Normalized threshold gradient for carbon-driven mode
c        ierr:      Error code = 0 if all is OK
c                              = 1 if inputs are outside the ranges prescribed
c                                    in Kotschenreuther, et al,
c                                    Physics of Plasmas, v2, p2381 (1995)
c
\end{verbatim}

All of the variables described above must be explicitly declared.
Also declared here are the variables that are intermediate calculation steps
in the IFS/PPPL model.

\begin{verbatim}
c
c     Declare variables
c     NAMING CONVENTION: Dimensionless variables begin with a 'z'
c                        Dorland-style input variables begin with a 'g'
c
      INTEGER switches(32), ierr
      REAL znine, zncne, znbne, zrlt, zrln, zq, zshat, zeps,
     &       ne19, tekev, tikev, rmajor, rhoi, vthermi, omegaexb,
     &       ztau, znu, zzeffstr, zrlnstr, ztaub, zkappa,
     &       zchii, zchii1, zchii2, zscriptg1, zscriptg2, zx,
     &       zscriptz, zf, zg, zh, zscriptd, zscripte,
     &       zrlt1, zrlt2, zchie, zchie1, zchie2, zscriptj,
     &       btesla, chie, chii, omegaci, zcorrect, zkapfact,
     &       grhoi, gvti, gtau, gnu, zscripty, gamma,
     &       zc1, zc2, zc3, zscriptg, zchiicyc, zscripts
      CHARACTER*35 calcflag
c
\end{verbatim}

\subsection{Validate Input}

First, set some initial values:

\begin{verbatim}
c
c     Set some initial values
c
      ierr = 0
      omegaexb = abs(omegaexb)
      calcflag = '                                   '
      if ( switches(2) .eq. 1)
     &     calcflag = '* Calcd from gnu,gvti,gtau,grhoi * '
c
\end{verbatim}

In the 1995 paper, Kotschenreuther, {\it et al}, indicate that the IFS/PPPL
model is only valid for a particular range of input parameters.
Specifically, these parameters are:
$0.7<q<8.0$, $0.5<\hat{s}<2.0$, $0.0<R/L_n<6.0$, $0.5<T_i/T_e<4.0$,
$1.0<Z_{\rm eff}<4.0$, $0.5<\nu<10.0$ and $0.1<\epsilon<0.3$.
Throughout this first section, each of these parameters will be checked for
validity; if a parameter lies outside the range, it value will be reset
to the appropriate bounding value and {\tt ierr} will be set to 1.
Hence, this coding of the IFS/PPPL will be robust to peculiar values
of the input parameters.

Here, check $q$, $\hat{s}$, $R/L_n$ and $\epsilon$ for validity:
\begin{verbatim}
c
c     Check some of the inputs for validity
c
      if (zq .lt. 0.7) then
         zq = 0.7
         ierr = 1
      end if
      if (zq .gt. 8.0) then
         zq = 8.0
         ierr = 1
      end if
      if (zshat .lt. 0.5) then
         zshat = 0.5
         ierr = 1
      end if
      if (zshat .gt. 2.0) then
         zshat = 2.0
         ierr = 1
      end if
      if (zeps .lt. 0.1) then
         zeps = 0.1
         ierr = 1
      end if
      if (zeps .gt. 0.3) then
         zeps = 0.3
         ierr = 1
      end if
      if (zrln .lt. 1.0e-6) then
         zrln = 1.0e-6
         ierr = 1
      end if
      if (zrln .gt. 6.0) then
         zrln = 6.0
         ierr = 1
      end if
c
\end{verbatim}

\subsection{Initial Calculations}

The first set of calculations find quantities ({\it e.g.},
$T_i/T_e$, collisionality $\nu$) that are used
throughout the IFS/PPPL formulation.
Wherever possible, the naming conventions used in
Ref.\cite{mk95model} have been kept.
The ratio of ion temperature to electron temperature is denoted by $\tau$:
$$
\tau \equiv T_i/T_e  \eqno{\tt ztau}
$$
The modified temperature ratio is denoted by $\tau_b$
$$
\tau_b \equiv \tau/(1 - n_{bD}/n_e)  \eqno{\tt ztaub}
$$
The collisionality is denoted by $\nu$, and defined in a somewhat
nonstandard way:
$$
\nu \equiv (2.1) R n_{e19} / (T_e^{1.5} T_i^{0.5})  \eqno{\tt znu}
$$
Note that, in the coded implementation of the IFS/PPPL model provided
by Dorland,
$\nu$ is related to the input parameter {\tt gnu} by:
$\nu = (0.84)({\tt gnu})$ where
This relationship can be preserved in this module by setting
{\tt switches(4)=1}.  This option allows one to directly use the
test cases for Dorland's coded implementation in this module,
or perhaps even to compare the results of both implementations
(the definitiion as it appeared in the 1995 published paper 
or the definition as it appeared in the coded implementation) 
in the same module.
By default, however, the relationship is $\nu = {\tt gnu}$.

The modified effective ion charge is denoted by $Z_{\rm eff}^*$:
$$
Z_{\rm eff}^* \equiv (n_D + 36n_C)/(n_D + 6n_C)
\eqno{\tt zzeffstr}
$$
Depending upon the exact content of the plasma, of course, $Z_{\rm eff}^*$
could be quite different from the actual effective charge $Z_{\rm eff}$.

The modified electron density scale length is denoted by $R/L_n^*$
$$
R/L_n^* \equiv {\rm min} \left[ 6, R/L_n \right] \eqno{\tt zrlnstr}
$$
Note that the 1995 paper had $R/L_n^*$ defined with the ``max'' function.
This is the most substantial typographical error in the 1995 paper.

The ion thermal speed $v_{ti}$ is calculated in units of meters per second:
$$
v_{ti} \equiv \sqrt{T_i/m_i}
\eqno{\tt vthermi}
$$
Note that this is a somewhat nonstandard definition of $v_{ti}$.

The ion gyroradius $\rho_i$, in meters, is defined as:
$$
\rho_i \equiv v_{ti}/\omega_{ci}
\eqno{\tt rhoi}
$$
where $\omega_{ci}$ is the ion cyclotron frequency in inverse seconds,
defined in the standard way:
$$
\omega_{ci} \equiv Z_i eB/m_i
$$
Notice that the plasma ions are explicitly assumed to be deuterons,
having a mass of $m_i = 3.3436 \times 10^{-27} {\rm kg}$.

If using the ``direct input'' method ({\tt switches(2)=1}),
then the input values of $\rho_i$, $v_{ti}$, $\tau$ and $\nu$ will be used
to find the corresponding physical parameters:
$T_i$, $T_e$, $\omega_{ci}$, \dots.

The relevant coding is as follows:

\begin{verbatim}
c
c     Initial calculations (check tau, nu, zeff for validity)
c
      if ( switches(2) .eq. 0 ) then
         vthermi = sqrt(tikev*1.6022e-16/3.3436e-27)
         omegaci = 1.6022e-19 * btesla / 3.3436e-27
         rhoi = vthermi/omegaci
         if ( (tikev .lt. 1.0e-4) .or. (tekev .lt. 1.0e-4) ) then
            znu = 10.0
            ierr = 1
         else
            znu = 2.1*rmajor*ne19/(tekev**1.5 * tikev**0.5)
            if ((znu .lt. 0.5) .and. (switches(3) .eq. 0)) then
               znu = 0.5
               ierr = 1
            end if
            if ( (znu .gt. 10.0) .and. (switches(5) .eq. 0) ) then
               znu = 10.0
               ierr = 1
            end if
         end if
         if ( tekev .lt. 1.0e-4 ) then
            ztau = 4.0
            ierr = 1
         else
            ztau = tikev/tekev
            if (ztau .lt. 0.5) then
               ztau = 0.5
               ierr = 1
            end if
            if (ztau .gt. 4.0) then
               ztau = 4.0
               ierr = 1
            end if
         end if
         gvti = vthermi
         grhoi = rhoi
         gtau = ztau
         gnu = znu
      end if
c
      if ( switches(2) .eq. 1 ) then
         vthermi = gvti
         rhoi = grhoi
         if (rhoi .lt. 1.0e-10) then
            rhoi = 1.0e-10
            ierr = 1
         end if
         znu = gnu
         if (switches(4) .eq. 1) znu = 0.84*gnu
         if ((znu .lt. 0.5) .and. (switches(3) .eq. 0)) then
            znu = 0.5
            ierr = 1
         end if
         if ( (znu .gt. 10.0) .and. (switches(5) .eq. 0) ) then
            znu = 10.0
            ierr = 1
         end if
         ztau = gtau
         if (ztau .lt. 0.5) then
            ztau = 0.5
            ierr = 1
         end if
         if (ztau .gt. 4.0) then
            ztau = 4.0
            ierr = 1
         end if
         tikev = 3.3436e-27*gvti*gvti/(1.6022e-16)
         tekev = tikev/ztau
         omegaci = gvti/grhoi
         btesla = omegaci*3.3436e-27/1.6022e-19
         ne19 = znu*tekev**1.5*tikev**0.5/(2.1*rmajor)
      end if
c
      ztaub = ztau/(1.0 - znbne)
      zzeffstr = 1.0 + 30.0*zncne/(znine + 6.0*zncne)
      if (zzeffstr .lt. 1.0) then
         zzeffstr = 1.0
         ierr = 1
      end if
      if (zzeffstr .gt. 4.0) then
         zzeffstr = 4.0
         ierr = 1
      end if
      zrlnstr = min(6.0,zrln)
c
\end{verbatim}

\section{The 1995 IFS/PPPL Model}

\subsection{Calculations}

Once the initial calculations are complete, we find the threshold
gradients used in the IFS/PPPL model.
There are two such thresholds: one for
the hydrogenic $\eta_i$ mode (the usual ITG mode) and
one for the carbon-driven $\eta_i$ mode.
Note that both instabilities drive thermal transport in the deuterium ions,
and that one mode is strongly destabilized by the presence of carbon ions
(hence the name, carbon-driven mode).
The IFS/PPPL model is concerned {\it only} with the thermal transport
among the deuterium ions; hence, the carbon-driven mode should not be
misinterpreted as giving the thermal transport among the carbon ions.

The hydrogenic mode threshold is given by the product:
$$
R/{L_{T ~\rm crit}}^{(1)} = f \times g \times h
\eqno{\tt zrlt1}
$$
where
$$
f = 1. - \frac{(0.942)(Z_{\rm eff}^*)^{0.516}}{(\hat{s})^{0.671}}
\left( \frac{(2.95)\epsilon^{1.257}}{\nu^{0.235}} - 0.2126 \right)
\eqno{\tt zf}
$$
$$
g = \left( 0.671 + (0.570)\hat{s} - (0.189)(R/L_n^*) \right)^2
+ 0.392 + (0.335)(R/L_n^*) - (0.779)\hat{s} + (0.210)\hat{s}^2
\eqno{\tt zg}
$$
and
$$
h = (2.46) \left( \frac{Z_{\rm eff}^*}{2.0} \right)^{0.7} (\tau_b)^{0.52}
\left( 1. + \frac{2.78}{q^2} \right)^{0.26}
\eqno{\tt zh}
$$
All of the symbols used here are defined above.
The relevant coding is:

\begin{verbatim}
c
c     Are we using the 1994 IFS/PPPL model?
c     If so, go to the start of that section
c
      if ( switches(3) .eq. 1 ) go to 2000
c
c     The 1995 IFS/PPPL model
c
c     The threshold temperature gradient for the hydrogenic mode
c
      zf = 1. - ( 0.942*zzeffstr**0.516/zshat**0.671 )*
     &          ( 2.95*zeps**1.257/znu**0.235 - 0.2126 )
      zg = ( 0.671 + 0.570*zshat - 0.189*zrlnstr )**2 + 0.392 +
     &          0.335*zrlnstr - 0.779*zshat + 0.210*zshat*zshat
      zh = 2.46 * (zzeffstr/2.0)**0.7 * ztaub**0.52 *
     &          (1.0 + 2.78/(zq*zq))**0.26
c
      zrlt1 = zf*zg*zh
c
\end{verbatim}

The carbon mode threshold is given by the expression:
$$
R/{L_{T ~\rm crit}}^{(2)} = 0.75 (1+\tau_b)(1+\hat{s})
\mbox{$\mathcal{D}$} (R/L_n^*) \mbox{$\mathcal{E}$} (Z_{\rm eff}^*)
\eqno{\tt zrlt2}
$$
where
$$
\mbox{$\mathcal{D}$} (R/L_n^*) = {\rm max} \left[ 1, 3-0.6667R/L_n^* \right]
\eqno{\tt zscriptd}
$$
and
$$
\mbox{$\mathcal{E}$} (Z_{\rm eff}^*) = 1 +
6 \times {\rm max} \left[ 0, 2.9 - Z_{\rm eff}^* \right]
\eqno{\tt zscripte}
$$

The relevant coding is:

\begin{verbatim}

c
c     The threshold temperature gradient for the carbon mode
c
      zscriptd = max( 1.0, 3.0-0.6667*zrlnstr )
      zscripte = 1.0 + 6.0*max( 0.0, 2.9-zzeffstr )
c
      zrlt2 = 0.75*(1.0+ztaub)*(1.0+zshat)*zscriptd*zscripte
c

\end{verbatim}

Once the thresholds are calculated, we must determine the ion thermal
diffusivity $\chi_i$.
This diffusivity is given by the expression:
$$
\chi_i = \left( \frac{\rho_i^2 v_{ti}}{R} \right)
{\rm max} \left[ \chi_i^{(1)}, \chi_i^{(2)} \right]
\eqno{\tt chii, zchii}
$$
The hydrogenic and carbon-driven mode diffusivities are defined,
respectively, as follows:
$$
\chi_i^{(1)} \equiv \frac{11.8(q^{1.13}/\tau_b^{1.07})}{1+\hat{s}^{0.84}}
\left( 1 + \frac{6.72\epsilon}{q^{0.96}\nu^{0.26}} \right)
\mbox{$\mathcal{Z}$} (Z_{\rm eff}^*)
\mbox{$\mathcal{G}$}^{(1)}\left( \frac{R}{L_T} \right)
\mbox{$\mathcal{K}$} (\kappa, q)
\mbox{$\mathcal{S}$}
\eqno{\tt zchii1}
$$
and
$$
\chi_i^{(2)} \equiv \frac{7.88 \tau_b^{-0.8}}{1+\hat{s}}
{\rm max} \left[ 0.25, Z_{\rm eff}^*-3 \right]
\mbox{$\mathcal{G}$}^{(2)}\left( \frac{R}{L_T} \right)
\mbox{$\mathcal{K}$} (\kappa, q)
\mbox{$\mathcal{S}$}
\eqno{\tt zchii2}
$$
Once again, it should be noted that the carbon-driven mode is an instability
driving thermal transport among the deuterium ions, {\it not} among the
carbon ions.
These two formulas involve previously undefined functions:
$$
\mbox{$\mathcal{Z}$} (Z_{\rm eff}^*) \equiv
{\rm min} \left[ 1, (3/Z_{\rm eff}^*)^{1.8} \right]
\eqno{\tt zscriptz}
$$
and
$$
\mbox{$\mathcal{G}$}^{(j)}\left( \frac{R}{L_T} \right) \equiv
G \left( \frac{R}{L_T} - \frac{R}{{L_{T~{\rm crit}}}^{(j)}} \right)
\eqno{\tt zscriptg1, zscriptg2}
$$
in which
$$
G(x) = \left\{
\begin{array}{ll} \openup 4\jot
0.0      &     \mbox{if $x < 0.0$} \\
x        &     \mbox{if $0.0 \leq x \leq 1.0$ } \\
\sqrt{x} &     \mbox{if $x > 1.0$ }
\end{array}  \right.
\nonumber
$$
$\mbox{$\mathcal{K}$} (\kappa, q)$ is a correction factor for
elongated plasmas, defined as follows:
$$
\mbox{$\mathcal{K}$} (\kappa, q) \equiv
\frac{1.}{1. + \left( (\kappa-1.)q/3.6 \right)^2}
\eqno{\tt zkapfact}
$$
The rotational shear stabilization factor $\mbox{$\mathcal{S}$}$
is defined as:
$$
\mbox{$\mathcal{S}$} \equiv
\left\{
\begin{array}{ll}
0.0                        &     \mbox{if $\gamma < \omega_{ExB}$} \\
1.0 - \omega_{ExB}/\gamma  &     \mbox{if $\omega_{ExB} < \gamma$ }
\end{array}  \right.
\eqno{\tt zscripts}
$$
where $\omega_{ExB}$ is the $ExB$ shearing rate in inverse seconds
and $\gamma$ is the linear growth rate of the mode, defined as follows:
$$
\gamma \equiv
\left( \frac{v_{ti}}{R} \right)
\left( \frac{25}{ \tau ( 1. + 0.5 \hat{s}^2)} \right)
\left( \frac{ 1. + (3.) {\rm max} \left[ 0., \epsilon-0.16667 \right] }
            { 1. + {\rm max} \left[ 0., q-3 \right] / 15. } \right)
\left( \frac{R}{L_T} - \frac{R}{{L_{T~{\rm crit}}}^{(1)}} \right)
\eqno{\tt gamma}
$$

The relevant coding is:

\begin{verbatim}
c
c     Calculate zkapfact (=1.0 when kappa=1.0 -- circular)
c
      zkapfact = 1.0  / ( 1. + ((zkappa-1.)*zq/3.6)**2 )
c
c     Calculate the shear flow stabilization factor
c
      gamma = (vthermi/rmajor)*(0.25/(ztau*(1.+0.5*zshat*zshat)))*
     &     ((1.+3.*max(0.0,zeps-0.16667)) / (1.+max(0.,zq-3.)/15.))*
     &     (zrlt-zrlt1)
      zscripts = 0.0
      if (gamma .gt. omegaexb) zscripts = 1.0 - omegaexb/gamma
c
c     Calculate zchii1
c
      zx = zrlt - zrlt1
      zscriptg1 = zx
      if ( zx .lt. 0.0 ) zscriptg1 = 0.0
      if ( zx .gt. 1.0 ) zscriptg1 = sqrt(zx)
c
      zscriptz = min( 1.0, (3.0/zzeffstr)**1.8 )
c
      zchii1 = ( 11.8*zq**1.13/ztaub**1.07) / (1.0 + zshat**0.84) *
     &        (1.0 + 6.72*zeps/(zq**0.96*znu**0.26)) *
     &        zscriptz * zscriptg1 * zkapfact * zscripts
c
c     Calculate zchii2
c
      zx = zrlt - zrlt2
      zscriptg2 = zx
      if ( zx .lt. 0.0 ) zscriptg2 = 0.0
      if ( zx .gt. 1.0 ) zscriptg2 = sqrt(zx)
c
      zchii2 = (7.88)/( ztaub**0.8 * (1.0 + zshat) )*
     &        max( 0.25, zzeffstr-3.0 ) * zscriptg2 *
     &        zkapfact * zscripts
c
c     Now calculate chii
c
      zchii = max(zchii1,zchii2)
      chii = (rhoi*rhoi*vthermi/rmajor)*zchii
c
c     Get chii normalized in Cyclone units
c
      zchiicyc = zchii/zrln
c
\end{verbatim}

Once the ion thermal diffusivity has been calculated, we turn our attention
to the electron thermal diffusivity $\chi_e$.
The expressions for $\chi_e$ were found from the ratios $\chi_e/\chi_i$
determined by the linear gyrokinetic code, and consequently can be said to
include non-adiabatic electron effects.
The expression for the final electron thermal diffusivity is almost identical
to that for $\chi_i$:
$$
\chi_e =
\left( \frac{\rho_i^2 v_{ti}}{R} \right)
{\rm max} \left[ \chi_e^{(1)}, \chi_e^{(2)} \right]
\mbox{$\mathcal{X}$} (Z_{\rm eff}^*)
\eqno{\tt chie, zchie}
$$
The correction factor $\mbox{$\mathcal{X}$} (Z_{\rm eff}^*)$ is necessary
because the original gyrokinetic stability runs calculated the ratios of
the thermal fluxes, rather than the ratios of the thermal diffusivities.
This correction factor is defined as follows:
$$
\mbox{$\mathcal{X}$} (Z_{\rm eff}^*) \equiv
\left( \frac{7.0 - Z_{\rm eff}^*}{6.0} \right)
\eqno{\tt zcorrect}
$$
The electron thermal diffusivities due to the hydrogenic mode ($\chi_e^{(1)}$)
and the carbon-driven mode ($\chi_e^{(2)}$) are found
from the following expressions:
$$
\chi_e^{(1)}/\chi_i^{(1)} = 0.72 ~{\rm max} \left[ 0.1667, \epsilon \right]
\nu^{0.14} (q/\hat{s})^{0.3} \tau^{0.4}
\left( 1. + \frac{1}{3} R/L_n^* \right)
\eqno{\tt zchie1}
$$
and
$$
\chi_e^{(2)}/\chi_i^{(2)} = 0.263 \tau \nu^{0.22}
\mbox{$\mathcal{J}$}_2 (R/L_n^*)
\eqno{\tt zchie2}
$$
Where $\mbox{$\mathcal{J}$}_2 (x)$ is defined as:
$$
\mbox{$\mathcal{J}$}_2 (x) \equiv {\rm max} \left[ 2., 1. + 0.333x \right]
\eqno{\tt zscriptj}
$$

The relevant coding is:

\begin{verbatim}
c
c     Calculate chie correction factor
c
      zcorrect = (7.0 - zzeffstr)/6.0
c
c     Calculate zscriptj
c
      zscriptj = max ( 2.0, (1.0 + 0.3333*zrlnstr) )
c
c     Calculate zchie1 and zchie2
c
      zchie1 = zchii1 * 0.72 * max( 0.1667, zeps ) * znu**0.14 *
     &        (zq/zshat)**0.3 * ztau**0.4 *
     &        ( 1. + 0.333 * zrlnstr)
c
      zchie2 = zchii2 * 0.263 * ztau * znu**0.22 * zscriptj
c
c     Finally, calculate chie
c
      zchie = max(zchie1,zchie2) * zcorrect
      chie = (rhoi*rhoi*vthermi/rmajor)*zchie
c
\end{verbatim}

\subsection{Output (Optional)}

Now that the thermal diffusivities have been calculated, there is an option
to produce additional output before exiting the subroutine.
If the user has set {\tt switches(1) = 1}, print out a page of diagnostic
output.
Otherwise, exit immediately.

\begin{verbatim}
c
c     (Optional) Print out page of calculation results
c
      if ( switches(1) .eq. 1 ) then

         if ( switches(30) .gt. 0) then
            write (switches(30),1000) chii, ierr, chie,
     &           rhoi, vthermi,
     &           omegaci, calcflag,
     &           tikev, calcflag,
     &           tekev, calcflag,
     &           ne19, calcflag,
     &           btesla, calcflag,
     &           omegaexb,
     &           zchiicyc,
     &           zchii1, zchii2,
     &           zchie1, zchie2, zrlt, zrlt1, zrlt2,
     &           zkapfact, zcorrect,
     &           gamma, zscripts,
     &           zscriptj, zscriptz,
     &           zscriptg1, zscriptg2,
     &           zscriptd, zscripte, zf, zg, zh,
     &           ztau, ztaub, znu, zzeffstr, zrlnstr
         end if

         if ( switches(31) .gt. 0) then
            write (switches(31),1000) chii, ierr, chie,
     &           rhoi, vthermi,
     &           omegaci, calcflag,
     &           tikev, calcflag,
     &           tekev, calcflag,
     &           ne19, calcflag,
     &           btesla, calcflag,
     &           omegaexb,
     &           zchiicyc,
     &           zchii1, zchii2,
     &           zchie1, zchie2, zrlt, zrlt1, zrlt2,
     &           zkapfact, zcorrect,
     &           gamma, zscripts,
     &           zscriptj, zscriptz,
     &           zscriptg1, zscriptg2,
     &           zscriptd, zscripte, zf, zg, zh,
     &           ztau, ztaub, znu, zzeffstr, zrlnstr
         end if

         if ( switches(32) .gt. 0) then
            write (switches(32),1000) chii, ierr, chie,
     &           rhoi, vthermi,
     &           omegaci, calcflag,
     &           tikev, calcflag,
     &           tekev, calcflag,
     &           ne19, calcflag,
     &           btesla, calcflag,
     &           omegaexb,
     &           zchiicyc,
     &           zchii1, zchii2,
     &           zchie1, zchie2, zrlt, zrlt1, zrlt2,
     &           zkapfact, zcorrect,
     &           gamma, zscripts,
     &           zscriptj, zscriptz,
     &           zscriptg1, zscriptg2,
     &           zscriptd, zscripte, zf, zg, zh,
     &           ztau, ztaub, znu, zzeffstr, zrlnstr
         end if

 1000    format (/,' Results from the 1995 IFS/PPPL Model',/,
     &       /,' Dimensional:',
     &       /,' chi-i =',1pe21.14,' (m^2/s)','   error code =',i2,
     &       /,' chi-e =',1pe21.14,' (m^2/s)',/,
     &       /,' rho-i =',1pe21.14,' meters',
     &       /,' v-therm-i =',1pe21.14,' m/s',
     &       /,' omega-ci =',1pe21.14,' rad/s  ',a35,
     &       /,' T-i =',1pe21.14,' keV         ',a35,
     &       /,' T-e =',1pe21.14,' keV         ',a35,
     &       /,' n-e =',1pe21.14,' 10^19 m^-3  ',a35,
     &       /,' B-tor =',1pe21.14,' Tesla     ',a35,
     &       /,' omega-ExB =',1pe21.14,' rad/s  ',/,
     &       /,' Dimensionless:',
     &       /,' chi-i =',1pe21.14,' in Cyclone units',
     &       /,' zchi-i1 =',1pe21.14,' zchi-i2 =',1pe21.14,
     &       /,' zchi-e1 =',1pe21.14,' zchi-e2 =',1pe21.14,/,
     &       /,' R/L_T =',1pe21.14,
     &       /,' R/L_Tcrit1 =',1pe21.14,' R/L_Tcrit2 =',1pe21.14,/,
     &       /,'  zkapfact =',1pe21.14,'  zcorrect =',1pe21.14,
     &       /,' gamma s^-1=',1pe21.14,'  zscripts =',1pe21.14,
     &       /,'  zscriptj =',1pe21.14,'  zscriptz =',1pe21.14,
     &       /,' zscriptg1 =',1pe21.14,' zscriptg2 =',1pe21.14,
     &       /,'  zscriptd =',1pe21.14,'  zscripte =',1pe21.14,/,
     &       /,'       zf =',1pe21.14,'      zg =',1pe21.14,
     &       /,'       zh =',1pe21.14,'    ztau =',1pe21.14,
     &       /,'    ztaub =',1pe21.14,'     znu =',1pe21.14,
     &       /,' zzeffstr =',1pe21.14,' zrlnstr =',1pe21.14,
     &       /)

      end if
c
      go to 3000
c
\end{verbatim}

\section{The 1994 IFS/PPPL Model}

\subsection{Calculations}

The 1994 IFS/PPPL model has a simpler functional form than the 1995 model,
and is based upon turbulence simulations with simpler physics:
the electron response is assumed to be adiabatic and
the plasma is collisionless.

The model begins with the calculation of three numerical
parameters that will be used in the diffusivity calculations.
For convenience, these parameters will be called $C_1$, $C_2$ and $C_3$.
The first parameter, $C_1$, is defined as:
$$
C_1 = {\rm max} \left[ 0.57,
\left( 1.26 + \left| Z_{\rm eff}^* - 3. \right| \left(
-0.27 + 0.075 Z_{\rm eff}^* - 0.044 ( Z_{\rm eff}^* )^2 \right) \right)
\right]
\eqno{\tt zc1}
$$
The second, $C_2$, is defined as:
$$
C_2 = \left\{
\begin{array}{ll}
1.0 + 0.1/\tau                       & \mbox{if $Z_{\rm eff}^* < 3.0$} \\
(2.)(3.5 - Z_{\rm eff}^*) + 0.1/\tau & \mbox{if $3.0 < Z_{\rm eff}^* < 3.5$} \\
(0.1 + 0.2(Z_{\rm eff}^* - 3.5))/\tau & \mbox{if $3.5 < Z_{\rm eff}^*$}
\end{array} \right.
\eqno{\tt zc2}
$$
The expression for the third parameter is somewhat simpler:
$$
C_3 = 0.61 - 0.27 /
\left( 1. + {\rm exp} \left[ (8.)(3.3 - Z_{\rm eff}^*) \right] \right)
\eqno{\tt zc3}
$$

The relevant coding for this part of the 1994 model is:

\begin{verbatim}
c
c     The 1994 IFS/PPPL model
c
 2000 continue
c
      zc1 = 1.26 + abs(zzeffstr-3.)*
     &             (-0.27+0.075*zzeffstr-0.044*zzeffstr*zzeffstr) 
      zc1 = max(0.57,zc1)
c
      zc2 = 2.0*(3.5-zzeffstr) + 0.1/ztau
      if ( zzeffstr .lt. 3.0) zc2 = 1.0 + 0.1/ztau
      if ( zzeffstr .gt. 3.5) zc2 = (0.1 + 0.2*(zzeffstr-3.5))/ztau
c
      zc3 = 0.61 - 0.27/( 1.0 + exp( 8.0*(3.3-zzeffstr) ) )
c
\end{verbatim}

Once the preliminaries are taken care of, we can calculate the critical
temperature gradient.
This gradient is defined as:
$$
R/L_{T~{\rm crit}} = (2.778) C_1 (\tau_b^{C_3}) \sqrt{0.5+\frac{1}{q}}
\left| 1. - \frac{0.85 \epsilon}{\hat{s}^{0.25}} \right|
\mbox{$\mathcal{Y}$} \left( R/L_n, \hat{s} \right)
\eqno{\tt zrlt1}
$$
where the function $\mbox{$\mathcal{Y}$} \left( R/L_n, \hat{s} \right)$
is defined as:
$$
\mbox{$\mathcal{Y}$} \left( R/L_n, \hat{s} \right) \equiv
\left| 0.1976 - 0.4550 \hat{s} + 0.1616 R/L_n \right|^{0.769}
+ 0.7813 + 0.2762 \hat{s} + 0.3967 \hat{s}^2
\eqno{\tt zscripty}
$$

The relevant coding is:

\begin{verbatim}
c
c     Calculate zscripty
c
      zscripty = abs(0.1976-0.4550*zshat+0.1616*zrln)**0.769
     &           + 0.7813 + 0.2762*zshat + 0.3967*zshat*zshat
c
c     Calculate the critical temperature gradient
c
      zrlt1 = 2.778 * zc1 * ztaub**zc3 * sqrt(0.5+1./zq) *
     &         abs(1. - 0.85*zeps/zshat**0.25) * zscripty
c
\end{verbatim}

Now, calculate the ion thermal diffusivity, defined as:
$$
\chi_i = \left( \frac{\rho_i^2 v_{ti}}{R} \right)
\left( \frac{(14.) q C_2}{(2. + \hat{s}) \tau_b}
       \left( 1. + \frac{\epsilon}{3.} \right) \right)
\mbox{$\mathcal{G}$} \left( \frac{R}{L_T} \right)
\eqno{\tt zchii1, chii}
$$
where
$$
\mbox{$\mathcal{G}$} \left( \frac{R}{L_T} \right) \equiv
G \left( \frac{R}{L_T} - \frac{R}{{L_{T~{\rm crit}}}} \right)
\eqno{\tt zscriptg}
$$
and
$$
G(x) = \left\{
\begin{array}{ll}
0.0      &     \mbox{if $x < 0.0$} \\
x        &     \mbox{if $0.0 \leq x \leq 1.0$ } \\
\sqrt{x} &     \mbox{if $x > 1.0$ }
\end{array}  \right.
\nonumber
$$

The relevant coding is as follows:

\begin{verbatim}
c
c     Calculate zscriptg and chii
c
      zx = zrlt - zrlt1
      zscriptg = zx
      if ( zx .lt. 0.0 ) zscriptg = 0.0
      if ( zx .gt. 1.0 ) zscriptg = sqrt(zx)
c
      zchii1 = 14.*zq*zc2/(ztaub*(2.+zshat))
     &         * (1. + zeps/3.) * zscriptg
      chii = zchii1 * rhoi*rhoi*vthermi/rmajor
c
c     Get chii normalized in Cyclone units
c
      zchiicyc = zchii1/zrln
c
c     Zero out zchii2, zchie2 and zrlt2 (they are not used in the 1994 model)
c
      zchii2 = 0.0
      zchie2 = 0.0
      zrlt2 = 0.0
c
\end{verbatim}

The ratio of the electron thermal diffusivity $\chi_e$ to the ion thermal
diffusivity $\chi_i$ is given by the following expression:
$$
\chi_e/\chi_i = 0.27 \tau^{0.7}
\eqno{\tt zchie1, chie}
$$

With the following simple coding:

\begin{verbatim}
c
c     Calculate chie and zchie
c
      zchie1 = zchii1 * 0.27 * ztau**0.7
      chie = chii * 0.27 * ztau**0.7
c
\end{verbatim}

\subsection{Output (Optional)}

\begin{verbatim}
c
c     (Optional) Print out page of calculation results
c
      if ( switches(1) .eq. 1 ) then

         if ( switches(30) .gt. 0) then
            write (switches(30),5000) chii, ierr, chie,
     &           rhoi, vthermi,
     &           omegaci, calcflag,
     &           tikev, calcflag,
     &           tekev, calcflag,
     &           ne19, calcflag,
     &           btesla, calcflag,
     &           zchiicyc, zrlt, zrlt1,
     &           zscriptg, zc1, zc2, zc3,
     &           ztau, ztaub, znu, zzeffstr, zrlnstr
         end if

         if ( switches(31) .gt. 0) then
            write (switches(31),5000) chii, ierr, chie,
     &           rhoi, vthermi,
     &           omegaci, calcflag,
     &           tikev, calcflag,
     &           tekev, calcflag,
     &           ne19, calcflag,
     &           btesla, calcflag,
     &           zchiicyc, zrlt, zrlt1,
     &           zscriptg, zc1, zc2, zc3,
     &           ztau, ztaub, znu, zzeffstr, zrlnstr
         end if

         if ( switches(32) .gt. 0) then
            write (switches(32),5000) chii, ierr, chie,
     &           rhoi, vthermi,
     &           omegaci, calcflag,
     &           tikev, calcflag,
     &           tekev, calcflag,
     &           ne19, calcflag,
     &           btesla, calcflag,
     &           zchiicyc, zrlt, zrlt1,
     &           zscriptg, zc1, zc2, zc3,
     &           ztau, ztaub, znu, zzeffstr, zrlnstr
         end if

 5000    format (/,' Results from the 1994 IFS/PPPL Model',/,
     &       /,' Dimensional:',
     &       /,' chi-i =',1pe21.14,' (m^2/s)','   error code=',i2,
     &       /,' chi-e =',1pe21.14,' (m^2/s)',/,
     &       /,' rho-i =',1pe21.14,' meters',
     &       /,' v-therm-i =',1pe21.14,' m/s',
     &       /,' omega-ci =',1pe21.14,' rad/s  ',a35,
     &       /,' T-i =',1pe21.14,' keV         ',a35,
     &       /,' T-e =',1pe21.14,' keV         ',a35,
     &       /,' n-e =',1pe21.14,' 10^19 m^-3  ',a35,
     &       /,' B-tor =',1pe21.14,' Tesla     ',a35,/,
     &       /,' Dimensionless:',
     &       /,' chi-i =',1pe21.14,' in Cyclone units',
     &       /,' R/L_T =',1pe21.14,'  R/L_Tcrit1 =',1pe21.14,/,
     &       /,'  zscriptg =',1pe21.14,/,
     &       /,' zc1 =',1pe21.14,' zc2 =',1pe21.14,
     &       /,' zc3 =',1pe21.14,/,
     &       /,'    ztau =',1pe21.14,'    ztaub =',1pe21.14,
     &       /,'     znu =',1pe21.14,' zzeffstr =',1pe21.14,
     &       /,' zrlnstr =',1pe21.14,
     &       /)

      end if
c
\end{verbatim}

\section{Conclusion}

Nothing more to do.

\begin{verbatim}
c
 3000 continue
      return
      end
c
\end{verbatim}


%**********************************************************************c

\begin{thebibliography}{99}

\bibitem{mk95model} M.~Kotschenreuther, W.~Dorland, M.~A.~Beer and
G.~W.~Hammett,
{\it Quantitative Predictions of Tokamak Energy Confinement from
First-Principles Simulations with Kinetic Effects},
Phys.~Plasmas {\bf 2}, 2381 (1995).

\bibitem{mbthesis} M.~A.~Beer,
PhD Thesis, Princeton University (1995).

\bibitem{mikek93} M.~Kotschenreuther, H.~L.~Berk, M.~LeBrun, J.~Q.~Dong,
W.~Horton, J.-Y.~Kim, Y.~Kishimoto, D.~W.~Ross, T.~Tajima, P.~M.~Valanju,
H.~V.~Wong, W.~Miner, D.~C.~Barnes, J.~U.~Brackbill, K.~M.~Ling, R.~A.~Nebel,
W.~D.~Nystrom, J.~A.~Byers, T.~J.~Cohen, G.~D.~Kerbel, J.~M.~Dawson,
R.~D.~Sydora, B.~A.~Carreras, N.~Dominguez, C.~L.~Hedrick, J.-N.~Leboeuf,
H.~Naitou and T.~Kamimura,
in {\it Plasma Physics and Controlled Nuclear Fusion Research 1992},
(International Atomic Energy Agency, Vienna, 1993), Vol.~2, p.~11.

\bibitem{dorland94}
W.~Dorland, M.~Kotschenreuther, M.~A.~Beer, G.~W.~Hammett, R.~E.~Waltz,
R.~R.~Dominguez, P.~M.~Valanju, J.~W.~H.~Miner, J.~Q.~Dong, W.~Horton,
F.~L.~Waelbrock, T.~Tajima and M.~J.~LeBrun,
{\it Comparisons of Nonlinear Toroidal Turbulence Simulations with Experiment},
in {\it Plasma Physicsand Controlled Nuclear Fusion Research 1994},
(International Atomic Energy Agency, Vienna), Vol.~3, p.~463.

\bibitem{coppi74}
B.~Coppi and G.~Rewoldt,
{\it New Trapped-Electron Instability},
Physical Review Letters {\bf 33}, 1329 (1974).

\bibitem{varenna}
W.~Dorland, M.~Kotschenreuther, Q.~P.~Liu, M.~A.~Beer and G.~W.~Hammett,
{\it 3D Simulations of Tokamak Plasma Turbulence: Experimental Tests and
Predictions},
Invited Paper, in {\it Proceedings of the Joint Varenna-Lausanne International
Workshop on the Theory of Fusion Plasmas},
Varenna, Italy, August 1996,
(Editrice Compositori, Bologna, Italy, 1996), p.~185.

\bibitem{waltz94}
R.~E.~Waltz, G.~D.~Kerbel and J.~Milovich,
{\it Toroidal gyro-Landau Fluid Model Turbulence Simulations in a Nonlinear
Ballooning Mode Representation with Radial Modes},
Physics of Plasmas {\bf 1}, 2229 (1994).

\bibitem{billd98}
W.~Dorland, University of Maryland, private communication (February 1998).

\bibitem{rewoldt82} G.~Rewoldt, W.~M.~Tang and M.~S.~Chance,
{\it Electromagnetic kinetic toroidal eigenmodes for general
magnetohydrodynamic equilibria},
Physics of Fluids {\bf 25}, 480 (1982).

\bibitem{rewoldt87} G.~Rewoldt, W.~M.~Tang and R.~J.~Hastie,
{\it Collisional Effects on Kinetic Electromagnetic Modes and Associated
Quasilinear Transport},
Physics of Fluids {\bf 30}, 807 (1987).

\bibitem{rewoldt98} G.~Rewoldt, M.~A.~Beer, M.~S.~Chance, T.~S.~Hahm,
Z.~Lin and W.~M.~Tang,
{\it Sheared Rotation Effects on Kinetic Stability in Enhanced Confinement
Tokamak Plasmas, and Nonlinear Dynamics of Fluctuations and Flows in
Axisymmetric Plasmas},
Invited Paper for 1997 APS Meeting,
Physics of Plasmas {\bf 5}, 1815 (1998).

\bibitem{mk95comp} M.~Kotschenreuther, G.~Rewoldt and W.~M.~Tang,
{\it Comparison of Initial Value and Eigenvalue Codes for Kinetic Toroidal
Plasma Instabilities},
Computer Physics Communications {\bf 88}, 128 (1995).

\end{thebibliography}

\section{Modification History}

Since this module was first written, there have been a number of small changes
made to the text or the fortran code.
What follows is an abbreviated list of the modifications that have been made
to this module, along with the initials of the person who made each change and
the date upon which the change occurred.

The initials refer to the following people:
\begin{center}
\begin{tabular}{lll}
    &               &             \\
\underline{Abbreviation} & \underline{Name} & \underline{Affiliation}\\
ajr & Aaron J.~Redd & Lehigh University \\
\end{tabular}
\end{center}

\begin{verbatim}
c--------1---------2---------3---------4---------5---------6---------7-
c
c Modification History
c
c ajr 08-Jul-98 Fixed reference rewoldt98.  Changed an if condition on
c         switches(2) from .ne.1 to .eq.0.  More wordsmithing.
c ajr 07-Jul-98 Added table of contents, more section headings.
c         Changed variable declarations so that compiler controls precision.
c         Added more digits to diagnostic output (1pe12.4 -> 1pe21.14).
c         Added some opening remarks re: the 1994 model, including citation.
c         Added better descriptions of I/O parameters.  Some wordsmithing.
c
c--------1---------2---------3---------4---------5---------6---------7-
\end{verbatim}


\end{document}             % End of document.
