%% Manual / derivations for preconditioning in BOUT++

\documentclass[12pt]{article}
\usepackage[nofoot]{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{color}
\usepackage{textcomp}
\definecolor{listinggray}{gray}{0.9}
\definecolor{lbcolor}{rgb}{0.95,0.95,0.95}
\lstset{
	backgroundcolor=\color{lbcolor},
        language=C++,
	keywordstyle=\bfseries\ttfamily\color[rgb]{0,0,1},
	identifierstyle=\ttfamily,
	commentstyle=\color[rgb]{0.133,0.545,0.133},
	stringstyle=\ttfamily\color[rgb]{0.627,0.126,0.941},
	showstringspaces=false,
	basicstyle=\small,
	numberstyle=\footnotesize,
	numbers=left,
	stepnumber=1,
	numbersep=10pt,
	tabsize=2,
	breaklines=true,
	prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
	breakatwhitespace=false,
	aboveskip={1.5\baselineskip},
        columns=fixed,
        upquote=true,
        extendedchars=true,
        morekeywords={Field2D,Field3D,Vector2D,Vector3D,real,FieldGroup},
}

%% Modify margins
\addtolength{\oddsidemargin}{-.25in}
\addtolength{\evensidemargin}{-.25in}
\addtolength{\textwidth}{0.5in}
\addtolength{\textheight}{0.25in}
%% SET HEADERS AND FOOTERS

\pagestyle{fancy}
\fancyfoot{}
\renewcommand{\sectionmark}[1]{         % Lower case Section marker style
  \markright{\thesection.\ #1}}
\fancyhead[LE,RO]{\bfseries\thepage}    % Page number (boldface) in left on even
                                        % pages and right on odd pages 
\renewcommand{\headrulewidth}{0.3pt}

\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\file}[1]{\texttt{\bf #1}}

%% commands for boxes with important notes
\newlength{\notewidth}
\addtolength{\notewidth}{\textwidth}
\addtolength{\notewidth}{-3.\parindent}
\newcommand{\note}[1]{
\fbox{
\begin{minipage}{\notewidth}
{\bf NOTE}: #1
\end{minipage}
}}

\newcommand{\pow}{\ensuremath{\wedge} }

\newcommand{\deriv}[2]{\ensuremath{\frac{\partial #1}{\partial #2}}}
\newcommand{\dderiv}[2]{\ensuremath{\frac{\partial^2 #1}{\partial {#2}^2}}}
\newcommand{\Div}[1]{\ensuremath{\nabla\cdot #1 }}
\newcommand{\Curl}[1]{\ensuremath{\nabla\times #1 }}
\newcommand{\Bvec}{\ensuremath{\underline{B}}}
\newcommand{\bvec}{\ensuremath{\underline{b}}}
\newcommand{\kvec}{\ensuremath{\underline{\kappa}}}
\newcommand{\apar}{\ensuremath{A_{||}}}

\begin{document}

\title{DALF3 model}

\maketitle

\section{Overview}

In SI units the equations solved are:
\begin{align}
\rho\frac{d\omega}{dt} &= B^2\nabla_{||}\frac{J_{||}}{B} - B\mathcal{K}\left(p_e\right) \\
\deriv{\apar}{t} + \frac{m_e}{e^2n}\frac{dJ_{||}}{dt} &= \frac{1}{en}\nabla_{||}P_e - \nabla_{||}\phi - \eta J_{||} \\
\rho\frac{du_{||}}{dt} &= -\nabla_{||}p_e + \mu_{||}\nabla_{||}^2u_{||} \\
\frac{d}{dt}\left(p_{e0}+p_e\right) &= \left(p_{e0}+p_e\right)\left[\mathcal{K}\left(\phi\right) - \frac{1}{en}\mathcal{K}\left(p_e\right) + B\nabla_{||}\left(\frac{J_{||}/\left(en\right) - u_{||}}{B}\right)\right]
\end{align}

where 
\[
\frac{d}{dt} = \deriv{}{t} + \frac{1}{B}\bvec\times\nabla\phi\cdot\nabla
\]
\[
J_{||} = -\frac{1}{\mu_0}\nabla_\perp^2 A_{||} \qquad \omega = \bvec\cdot\nabla\times \mathbf{v}_E \simeq \frac{1}{B}\nabla_\perp^2\phi
\]
The curvature operator $\mathcal{K}$ is
\[
\mathcal{K} \simeq -\frac{2}{B}\bvec\times\kvec\cdot\nabla
\]
The parallel derivative is
\[
\nabla_{||} = \bvec_0\cdot\nabla - \frac{1}{B}\bvec_0\times\nabla A_{||}\cdot\nabla
\]

\subsection{Normalisation}

Normalised quantities are denoted with a hat, and typical values with a bar. {\bf Note}: the normalisation used
here is different to that used in the dalf3 papers.
Starting with equation for total derivative:
\[
\frac{d}{dt} = \deriv{}{t} + \frac{1}{B}\bvec\times\nabla \phi \cdot\nabla
\]
The electrostatic potential is normalised to:
\[
\boxed{\hat{\phi} = \frac{\phi}{\overline{T}}}
\]
where $\overline{T}$ is a typical temperature (in eV). Normalising spatial derivatives to the drift scale $\rho_s$
\[
\boxed{\hat{\nabla} = \rho_s\nabla}
\]
given by
\[
\rho_s = \frac{C_s M_i}{e\overline{B}} = \frac{C_s}{\omega_{ci}} \qquad \rho_sC_s = \overline{T} / \overline{B} \qquad 
\]
where $C_s$ is a typical sound speed $C_s = \sqrt{e\overline{T}/M_i}$, $\omega_{ci} = e\overline{B}/M_i$ is the ion
cyclotron angular frequency, and $\overline{B}$ is a typical magnetic field strength. Normalising the magnetic field
as $\boxed{\hat{B} = B / \overline{B}}$ and time to 
\[
\boxed{\hat{t} = t\omega_{ci}} \qquad \deriv{}{t} = \omega_{ci}\deriv{}{\hat{t}}
\]
gives the normalise equation
\[
\frac{d}{d\hat{t}} = \deriv{}{\hat{t}} + \frac{1}{\hat{B}}\bvec\times\hat{\nabla} \phi \cdot\hat{\nabla}
\]

The vorticity is given by $\omega = \bvec\cdot\nabla\times \mathbf{v}_E \simeq \frac{1}{B}\nabla_\perp^2\phi$ and so
vorticity $\omega$ is therefore normalised as
\[
\boxed{\hat{\omega} = \omega / \omega_{ci}} \quad \rightarrow \hat{\omega} = \frac{1}{\hat{B}}\hat{\nabla}_\perp^2\hat{\phi}
\]

The vorticity equation in SI units is
\[
\rho\frac{d\omega}{dt} = B^2\nabla_{||}\frac{J_{||}}{B} - B\mathcal{K}\left(p_e\right)
\]
where $\mathcal{K}$ is the curvature operator which has units of $1/\left(L^2B\right)$.
This is normalised using a typical number density $\overline{n}$, and assuming that the mass density is constant
$\rho = \overline{n}M_i$.
\[
\overline{n}M_i\omega_{ci}^2\frac{d\hat{\omega}}{d\hat{t}} = \frac{\overline{B}}{\rho_s}\hat{B}^2\hat{\nabla}_{||}^2\frac{J_{||}}{\hat{B}} - \frac{\hat{B}}{\rho_s^2}\hat{\mathcal{K}}\left(p_e\right)
\]
re-aranging:
\[
\frac{d\hat{\omega}}{d\hat{t}} = \frac{1}{e\overline{n}C_s}\hat{B}^2\hat{\nabla}_{||}^2\frac{J_{||}}{\hat{B}} - \frac{\hat{B}}{\overline{n}\overline{T}e}\hat{\mathcal{K}}\left(p_e\right)
\]

The parallel current and pressure are therefore normalised as
\[
\boxed{\hat{J}_{||} = \frac{J_{||}}{e\overline{n}C_s}} \qquad \boxed{\hat{p}_e = \frac{p_e}{e\overline{T}\overline{n}}}
\]
whilst the curvature operator is normalised as
\[
\boxed{\hat{\mathcal{K}} = \mathcal{K}\rho_s^2\overline{B}}
\]
to give a normalised equation
\[
\frac{d\hat{\omega}}{d\hat{t}} = \hat{B}^2\hat{\nabla}_{||}^2\frac{\hat{J}_{||}}{\hat{B}} - \hat{B}\hat{\mathcal{K}}\left(\hat{p}_e\right)
\]

The parallel vector potential $A_{||}$ is related to the perturbed current by
\[
J_{||} = -\frac{1}{\mu_0}\nabla_\perp^2 A_{||}
\]
and so normalising:
\[
e\overline{n}C_s\hat{J}_{||} = -\frac{1}{\mu_0}\frac{1}{\rho_s^2}\hat{\nabla}_\perp^2A_{||}
\]
rearranging:
\[
\hat{J}_{||} = -\underbrace{\frac{\overline{B}^2}{\mu_0 e\overline{n}\overline{T}}}_{1/\beta}\frac{1}{\rho_s\overline{B}}\hat{\nabla}_\perp^2 A_{||}
\]
$A_{||}$ is therefore normalised to:
\[
\boxed{\hat{A}_{||} = \frac{A_{||}}{\rho_s\overline{B}\beta}} \quad \rightarrow \hat{J}_{||} = -\hat{\nabla}_\perp^2 \hat{A}_{||}
\]
with $\beta = \mu_0 e\overline{n}\overline{T}/\overline{B}^2$

Ohm's law in SI units can be written:
\[
\deriv{\apar}{t} + \frac{m_e}{e^2n}\frac{dJ_{||}}{dt} = \frac{1}{en}\nabla_{||}P_e - \nabla_{||}\phi - \eta J_{||}
\]
Normalising, and again making the assumption that the density $n$ is constant, this simplifies to
to
\[
\beta\deriv{\hat{\apar}}{\hat{t}} + \mu\frac{d\hat{J}_{||}}{d\hat{t}} = \hat{\nabla}_{||}\left(\hat{p}_e - \hat{\phi}\right) - \hat{\eta}\hat{J}_{||}
\]
where the normalised resistivity are parameter $\mu$ are
\[
\boxed{\hat{\eta} = \eta\frac{e\overline{n}}{\overline{B}}} \qquad \mu = \frac{m_e}{m_i}
\]

The parallel momentum equation in SI units is
\[
\rho\frac{du_{||}}{dt} = -\nabla_{||}p_e + \mu_{||}\nabla_{||}^2u_{||}
\]
the parallel velocity and parallel viscosity are normalised as:
\[
\boxed{\hat{u}_{||} = \frac{u_{||}}{C_s}} \qquad \boxed{\hat{\mu} = \mu\frac{\omega_{ci}}{e\overline{n}\overline{T}}}
\]
to give a normalised equation (again assuming $n$ is constant)
\[
\frac{d\hat{u}_{||}}{d\hat{t}} = -\hat{\nabla}_{||}\hat{p}_e + \hat{\mu}_{||}\hat{\nabla}_{||}^2\hat{u}_{||}
\]
Finally, the pressure equation normalises to give
\[
\frac{d}{d\hat{t}}\left(\hat{p}_{e0} + \hat{p}_e\right) = \left(\hat{p}_{e0} + \hat{p}_e\right)\left[ \hat{\mathcal{K}}\left(\hat{\phi} - \hat{p}_e\right) + \hat{B}\hat{\nabla}_{||}\left(\frac{\hat{J}_{||} - \hat{u}_{||}}{\hat{B}}\right)\right]
\]

\subsection{Summary}

The normalised equations are
\begin{align}
\frac{d\hat{\omega}}{d\hat{t}} &= \hat{B}^2\hat{\nabla}_{||}^2\frac{\hat{J}_{||}}{\hat{B}} - \hat{B}\hat{\mathcal{K}}\left(\hat{p}_e\right) \\
\beta\deriv{\hat{\apar}}{\hat{t}} + \mu\frac{d\hat{J}_{||}}{d\hat{t}} &= \hat{\nabla}_{||}\left(\hat{p}_e - \hat{\phi}\right) - \hat{\eta}\hat{J}_{||} \\
\frac{d\hat{u}_{||}}{d\hat{t}} &= -\hat{\nabla}_{||}\hat{p}_e + \hat{\mu}_{||}\hat{\nabla}_{||}^2\hat{u}_{||} \\
\frac{d}{d\hat{t}}\left(\hat{p}_{e0} + \hat{p}_e\right) &= \left(\hat{p}_{e0} + \hat{p}_e\right)\left[ \hat{\mathcal{K}}\left(\hat{\phi} - \hat{p}_e\right) + \hat{B}\hat{\nabla}_{||}\left(\frac{\hat{J}_{||} - \hat{u}_{||}}{\hat{B}}\right)\right]
\end{align}

\[
\hat{\nabla}_{||} = \bvec_0\cdot\hat{\nabla} - \frac{\beta}{\hat{B}}\bvec_0\times\hat{\nabla} \hat{A}_{||}\cdot\hat{\nabla}
\]

\end{document}

