\documentstyle[aps,12pt]{revtex}
\begin{document}
\author{R. Correll, M. Huq, S. Klasky}
\maketitle
The evolution equations that the {\tt TCODE} solves are as follows:
\begin{eqnarray}
\label{evolg.eqn}
\partial_t g_{ij} & = & - 2 \alpha K_{ij} + D_i \beta_j + D_j \beta_i \\
\label{evolk.eqn}
\partial_t K^i_j  & = & {\cal L}_{\beta} K^i_j - D^i D_j \alpha +
\alpha \left( R^i_j + K K^i_j \right) 
\label{evol.eqn}
\end{eqnarray}
where $g_{ij}$ is the 3-metric, $K^i_j$ is the extrinsic curvature, $D_i$ is
the covariant derivative compatible with $g_{ij}$, $\alpha$ is the lapse 
function, $\beta^i$ is the shift vector and ${\cal L}_{\beta}$ is the Lie
derivative along the vector field $\beta$. ${\cal L}_{\beta} K^i_j$ is given
by the following equation:
\begin{equation}
{\cal L}_{\beta} K^i_j = \beta^k D_k K^i_j - K^k_j D_k \beta^i
+ K^i_k D_j \beta_k 
\label{lie.term}
\end{equation}
In order to eliminate redundant variables we examine the structure of the
equations to see which quantities can be computed with the use of temporary
arrays/functions. The variables that will be stored in the tcode are as 
follows: 
\hspace{0.5in}
\begin{tabular}{ll}
\hline
Grid Function & Number of independent components \\ \hline
$g_{ij}$  & $6\times 2$ independent components(multiply by two for n+1 timestep) \\
$g^{ij}$  & 6 independent components(required for various stages) \\
$K^i_j$   & $9\times 2$ components (multiply by two for n+1 timestep) \\
$\Gamma^i_{jk}$ & 18 components (stored instead of $g_{ij,k}$) \\
$R_{ij}$  & 6 components (Raised when needed in eqn.~(\ref{evolk.eqn})) \\
$\alpha$  & scalar function \\
$\beta^i$ & 3 components ($\beta_i$ can be obtained using $g_{ij}$) \\
\hline
\end{tabular}

Hence the lower limit on required variables for the solution to the evolution
is $64$ grid variables. For a $65^3$ grid at one word a point for each grid
function this comes to a minimum of $\sim 18$Mwords of memory. Of course in the
real code this number will be higher once additional variables temporary 
variables are figured in.

For the solution of the evolution equations we examine
eqns~(\ref{evolg.eqn},\ref{evolk.eqn}) to see what sort of temporary variables 
we can use to evaluate the right-hand-sides. We can reuse a set of $9$ 
temporary grid functions throughout the code. We shall proceed with first
calculation of the connection coefficients, the Ricci tensor and then term
by term in the evolution equations.
\subsection{Connection coefficients}
The calculation of the connection coefficients can be broken up into several
stages. This obviates the necessity for storing the first derivatives of the
3-metric which saves us $18$ grid functions. 

The connection coefficients are given by
\begin{equation}
\Gamma^i_{jk} = \frac{1}{2} g^{il} \left( g_{lj,k} + g_{lk,j} - g_{jk,l} 
\right)
\label{connect.1}
\end{equation}
The calculation can be broken up into three separate sets using $9$ temporary
variables. The choice of $9$ will be more apparent as we deal with each of
the terms in eqns.~(\ref{evolg.eqn},\ref{evolk.eqn}). For each of the 18 
connection coefficients we calculate using the following steps:
For the first term in eqn.~(\ref{connect.1})
\begin{eqnarray}
\Gamma^i_{jk} & = & \frac{1}{2} g^{il} g_{lj,k} \nonumber \\
& = & \frac{1}{2} \left(g^{i1} g_{1j,k} + g^{i2} g_{2j,k} + g^{i3} g_{3j,k}
\right) \label{connect.2}\\
\end{eqnarray}
For the second term in eqn.~(\ref{connect.1})
\begin{eqnarray}
\Gamma^i_{jk} & = & \Gamma^i_{jk} + \frac{1}{2} g^{il} g_{lk,j} \nonumber \\
& = & \Gamma^i_{jk} + \frac{1}{2} \left(g^{i1} g_{1k,j} + g^{i2} g_{2k,j} 
+ g^{i3} g_{3k,j} \right) \label{connect.3}\\
\end{eqnarray}
For the third term in eqn.~(\ref{connect.1})
\begin{eqnarray}
\Gamma^i_{jk} & = & \Gamma^i_{jk} - \frac{1}{2} g^{il} g_{jk,l} \nonumber \\
& = & \Gamma^i_{jk} - \frac{1}{2} \left(g^{i1} g_{jk,1} + g^{i2} g_{jk,2} 
+ g^{i3} g_{jk,3} \right) \label{connect.4}\\
\end{eqnarray}

The derivatives of the 3-metric in each of the three steps is stored in 
$9$ different temporary grid functions and is used to calculate each term 
as given by eqns.~(\ref{connect.2},\ref{connect.3},\ref{connect.4}). These
temporary variables will be reused in other parts of the evolution program.
One can make use of equivalence statements to make the code more easily 
readable.
$9$ additional variables amounts to $2.5$Mwords of additional storage for a 
$65^3$ run.
\subsection{Ricci tensor}
The calculation of the Ricci tensor can be similarly broken up into several
segments with the use of $9$ temporary grid functions once more. The Ricci
tensor is given by
\begin{equation}
R_{ij} = \Gamma^a_{ij,a} - \Gamma^a_{ia,j} +
\Gamma^a_{ab} \Gamma^b_{ij} - \Gamma^a_{bj} \Gamma^b_{ia}
\label{ricci.1}
\end{equation}
The last two terms in eqn.~(\ref{ricci.1}) are simple combinations of the
$\Gamma$'s. The first two terms can be evaluated with the use of temporary
grid functions without storing derivatives of the connection coefficients
throughout the program. This saves us a total of $54$ grid functions which is
a total of $15$Mwords for a $65^3$ grid. The evaluation of the Ricci tensor 
is broken as follows:
\begin{eqnarray}
R_{ij} & = & \Gamma^a_{ij,a} \nonumber \\
& = & \Gamma^1_{ij,1} + \Gamma^2_{ij,2} + \Gamma^3_{ij,3} 
\label{ricci.2}
\end{eqnarray}
\begin{eqnarray}
R_{ij} & = & R_{ij} - \Gamma^a_{ia,j} \nonumber \\
& = & R_{ij} - \left(\Gamma^1_{i1,j} + \Gamma^2_{i2,j} + \Gamma^3_{i3,j} 
\right)
\label{ricci.3}
\end{eqnarray}
\begin{eqnarray}
R_{ij} & = & R_{ij} + \Gamma^a_{ab} \Gamma^b_{ij} - \Gamma^a_{bj} \Gamma^b_{ia}
\label{ricci.3}
\end{eqnarray}
where in eqns.~(\ref{ricci.1},\ref{ricci.2}) terms like $\Gamma^1_{ij,1}$ and
$ \Gamma^1_{i1,j}$ are calculating using temporary arrays.  
\subsection{Evolution equation for 3-metric}
The evolution equation for the 3-metric is given as before,
\begin{eqnarray}
\nonumber
\partial_t g_{ij} & = & - 2 \alpha K_{ij} + D_i \beta_j + D_j \beta_i. \\
\end{eqnarray}
The evaluation of the second and third terms is carried out by once again
using $9$ temporary grid functions. Recall that $\beta^i$, the contravariant
form of the shift, is stored. Since $g_{ij}$ is compatible with $D_i$ we can
rewrite $D_i \beta_j = g_{jk} D_i \beta^k$. Hence we are left with calculating
\begin{equation}
D_i \beta_j = g_{jk} \left( \partial_i \beta^k - \Gamma^k_{il}\beta^l \right).
\label{gshift.eqn}
\end{equation}
Here once again we use a $9$ grid functions to store the components of 
$\partial_i \beta^k$ first and then add $\Gamma^k_{il}\beta^l$ to form
eqn.~(\ref{gshift.eqn}). Then evaluating eqn.~(\ref{evolg.eqn}) becomes a
matter of using the temporary variables for $D_i \beta_j$.
\subsection{Evolution equation for extrinsic curvature}
\begin{eqnarray}
\nonumber
\partial_t K^i_j  & = & {\cal L}_{\beta} K^i_j - D^i D_j \alpha +
\alpha \left( R^i_j + K K^i_j \right)
\end{eqnarray}
\end{document}



