\documentclass{article} %[11pt]{amsart}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{tikz}
\usepackage{lscape}
\usepackage{pgfplots}
\usetikzlibrary{
  arrows,
  calc,
  decorations.markings,
  decorations.pathreplacing,
  dsp,
  fit,
  positioning
}
\input{../util/control.tex}

\pgfplotsset{grid style={dashed,gray!25}}

\newcommand{\qhat}{\hat{q}}
\newcommand{\cbar}{\bar{c}}
\newcommand{\qbar}{\bar{q}}
\newcommand{\cmd}{\mathrm{cmd}}
\newcommand{\ff}{\mathrm{ff}}
\newcommand{\eff}{\mathrm{eff}}
\newcommand{\app}{\mathrm{app}}
\newcommand{\wind}{\mathrm{wind}}
\newcommand{\kite}{\mathrm{kite}}
\newcommand{\nom}{\mathrm{nom}}
\newcommand{\aero}{\mathrm{aero}}
\newcommand{\geom}{\mathrm{geom}}

\title{Linear analysis of the path controller}
\date{DRAFT\\Dec 25, 2015}

\begin{document}
\maketitle

\section{Description of the path controller}

The path controller flies the kite along a set, usually circular,
path.  Its main inputs are the current position and velocity of the
kite and its main output is a curvature command, which the inner loop
of the crosswind controller attempts to meet.

The path controller uses a simple kinematic model of the kite's flight
path, which assumes that the kite, starting from its current position
and velocity, follows its current curvature for a period $t_1$ and
then follows a new commanded curvature for a period $t_2$ (see
Fig. \ref{fig:vector_field}).  The separation of the path into current
and commanded curvatures is motivated by the fact that the kite cannot
instantly change its curvature.  Multiple potential commanded
curvatures are projected forward and the one that minimizes a specific
cost function is chosen.

The cost function is the negative of the dot product of the predicted
velocity with a vector defined by the predicted position and a vector
field of ideal velocities.  These ideal velocities are tangent to the
path on the path, while away from the path they steer the kite back
toward the path assuming some minimum turning radius,
$r_{\mathrm{min}}$.

The exact equations defining the vector field are
\begin{eqnarray}
x &=& \frac{\pi}{2} \frac{\delta}{r_{\mathrm{min}}} \\
\vec{v} &=&\left\{
\begin{array}{lrcl}
\hat{e}_r  &                      &\delta& <  -r_{\mathrm{min}} \\
-\sin x \cdot \hat{e}_r - \cos x \cdot \hat{e}_{\theta}
  &\;\;\;\; -r_{\mathrm{min}} \le &\delta& \le r_{\mathrm{min}} \\
-\hat{e}_r & r_{\mathrm{min}} <   &\delta&
\end{array}
\right.
\end{eqnarray}
where $\hat{e}_r$ and $\hat{e}_{\theta}$ are the radial and tangential
unit vectors.

\begin{figure}
\begin{center}
\begin{tikzpicture}[scale=2.5]
  \def\R{1};
  \def\rmin{0.7};
  \def\r{0.1};

  % Draw vector field.
  \begin{scope}[color=lightgray]
    \foreach \x in {-2, -1.79, ..., 2} {
      \foreach \y in {-2, -1.79, ..., 2} {
        \def\norm{max(sqrt(\x*\x + \y*\y), 0.1)};
        \def\radx{(\x / \norm)};
        \def\rady{(\y / \norm)};
        \def\tanx{(\y / \norm)};
        \def\tany{(-\x / \norm)};
        \def\ang{max(min(0.5 * pi * (\norm - \R) / \rmin, pi/2), -pi/2)};
        \def\crad{(-0.1 * sin(deg(\ang)))};
        \def\ctan{( 0.1 * cos(deg(\ang)))};
        \draw [arrows={-latex}] (\x, \y) --
              ({\x + \crad * \radx + \ctan * \tanx},
               {\y + \crad * \rady + \ctan * \tany});
      };
    };
  \end{scope}
  \draw [arrows={latex-latex}] (-2, 0) -- (2, 0);
  \draw [arrows={latex-latex}] (0, -2) -- (0, 2);
  \draw [color=black] (0, 0) circle (\R);
  \draw [color=black, dashed] (0, 0) circle ({\R - \rmin});
  \draw [color=black, dashed] (0, 0) circle ({\R + \rmin});

  \draw [decorate,decoration={brace,amplitude=5pt}]
        ({(\R + \rmin) * cos(30)}, {(\R + \rmin) * sin(30)}) --
        ({\R * cos(30)}, {\R * sin(30)})
        node[midway, below right] {$r_{\mathrm{min}}$};

  % Draw trajectory.
  \def\startangle{60}
  \def\etaone{30}
  \def\epsangle{15};
  \def\headingangle{(\startangle - \epsangle)}
  \coordinate (start) at ({-(\R + \r) * cos(\startangle)},
                          { (\R + \r) * sin(\startangle)});
  \draw [thick, color=black]
        (start)
        arc ({180 - \startangle + \epsangle}:
             {180 - \startangle + \epsangle - \etaone/2}:
             {\R})
        node [above=0.5cm, left] {$t_1$}
        arc ({180 - \startangle + \epsangle - \etaone/2}:
             {180 - \startangle + \epsangle - \etaone}:
             {\R})
        coordinate (midpoint);

  \draw [thick, color=black, arrows={-latex}]
        (start)
        -- ($(start) + ({0.5 * sin(\headingangle)}, {0.5 * cos(\headingangle)})$);

  \foreach \command in {0.6, 0.8, ..., 1.4} {
    \draw [color=blue, arrows={-latex}]
          (midpoint)
          arc ({180 - \startangle + \epsangle - \etaone}:
               {180 - \startangle + \epsangle - \etaone - 50/\command}:
               {\command});
  }
  \path [color=blue]
        (midpoint)
        arc ({180 - \startangle + \epsangle - \etaone}:
             {180 - \startangle + \epsangle - \etaone - 25 / 1.4}:
             {1.4})
        node [above] {$t_2$};
\end{tikzpicture}
\caption{Vector field of ideal headings and the predicted trajectory
  of the kite.  The ideal headings are based around returning to the
  circle path using a minimum turning radius, $r_{\mathrm{min}}$.}
\label{fig:vector_field}
\end{center}
\end{figure}

\section{Kinematics of circular path following}

\begin{figure}[!ht]
\begin{center}
  \begin{tikzpicture}
    \def\R{4}
    \def\axislen{\R * 1.5}
    \def\deltaoffset{\R * 0.2}
    \def\deltar{\R * 0.1}
    \def\epsilondeg{20}
    \def\epsilonrad{\epsilondeg * 3.14159 / 180.0}
    \def\etadeg{50}
    \def\etarad{\etadeg * 3.14 / 180}

    \coordinate (pathorigin) at (0, 0);
    \coordinate (turnorigin) at
                ({-\deltaoffset - \R + (\R + \deltar) * cos(\epsilondeg)},
                 {(\R + \deltar) * sin(\epsilondeg)});
    \coordinate (nominalturnorigin) at
                ({-\deltaoffset - \R + \R * cos(\epsilondeg)},
                 {\R * sin(\epsilondeg)});
    \coordinate (nominalstart) at (-\R, 0);
    \coordinate (start) at (-\deltaoffset - \R, 0);

    % Draw path circle and axes.
    \draw [arrows={latex-latex}] (-\axislen, 0) -- (\axislen, 0);
    \draw [arrows={latex-latex}] (0, -\axislen) -- (0, \axislen);
    \draw (0, 0) circle (\R);

    % Draw turn circle.
    \draw[fill] (turnorigin) circle (0.05);
    \node[below, xshift=5pt] at (turnorigin) {$(x_c, y_c)$};
    \draw [color=gray!25] (nominalturnorigin) circle (\R);
    \draw [color=gray!60] (turnorigin) circle (\R + \deltar);

    \draw [arrows={-latex}] (turnorigin)
          -- ($(turnorigin) + ({(\R + \deltar) * cos(45)},
               {(\R + \deltar) * sin(45)})$)
          node[midway, below right] {$R + \delta r$};

    % Draw turn tradjectory.
    \draw[fill] (start) circle (0.05);
    \node[below left] at (start) {$(x_0, y_0)$};
    \draw (start)
          arc ({180 + \epsilondeg}:{180 + \epsilondeg - \etadeg}:{\R + \deltar})
          coordinate (end);

    \draw [dashed] (end) -- (pathorigin);
    \draw [dashed] (end) -- (turnorigin);
    \draw [dashed] (start) -- (turnorigin);
    \draw[fill] (end) circle (0.05);
    \node[above left] at (end) {$(x(\eta), y(\eta))$};

    \draw [decorate,decoration={brace,amplitude=5pt}]
          (nominalstart) -- (start)
          node[midway, below, yshift=-5pt] {$\delta_0$};

    \coordinate (nominalend) at ($(pathorigin)!\R cm!(end)$);
    \draw [decorate,decoration={brace,amplitude=5pt}]
          ($(nominalend)$) -- ($(end)$)
          node[midway, below left, yshift=-5pt] {$\delta(\eta)$};

    \draw [arrows={-latex}] (pathorigin) -- ({\R * cos(30)}, {\R * sin(30)})
          node[midway, below right] {$R$};

    % Label epsilon angles.
    \def\epsilonmarkerfrac{0.3}
    \draw [dashed] (start) --
          ($(start) + ({-\R/2 * sin(\epsilondeg)}, {\R/2 * cos(\epsilondeg)})$);
    \draw [dashed] (start) -- ($(start) + (0, \R/2)$);
    \draw [arrows={latex-latex}] ($(start) + (0, \R/4)$)
          arc (90:{90 + \epsilondeg}:{\R/4})
          node[left] {$\epsilon_0$};
    \path (start) -- ($(start)!\epsilonmarkerfrac!(pathorigin)$)
          arc (0:{\epsilondeg/2}:{(\R + \deltar) * \epsilonmarkerfrac})
          node {$\epsilon_0$};

    % Label \epsilon(\eta) angle.
    \path (start)
          arc ({180 + \epsilondeg}:
               {180 + \epsilondeg - \etadeg + 5}:
               {\R + \deltar})
          coordinate (turntangent);
    \path [dashed] let \p{end}=(end) in
          (end) -- ($(end) + (\y{end}, -\x{end})$)
          coordinate (pathtangent);
    \draw [dashed] (end)
          -- ($(end)!1.5cm!(pathtangent)$)
          coordinate (epsetapathmarker)
          -- ($(end)!2.5cm!(pathtangent)$);
    \draw [dashed] (end)
          -- ($(end)!-1.5cm!(turntangent)$)
          coordinate (epsetaturnmarker)
          -- ($(end)!-2.5cm!(turntangent)$);
    \draw [arrows={latex-latex}] (epsetaturnmarker)
          arc ({90 + \epsilondeg - \etadeg}:
               {90 + \epsilondeg - \etadeg - 0.6 * \epsilondeg)}:
               1.5cm);
    \path [arrows={-latex}] (epsetaturnmarker)
          arc ({90 + \epsilondeg - \etadeg}:
               {90 + \epsilondeg - \etadeg - 0.3 * \epsilondeg)}:
               1.5cm)
          node [above left] {$\epsilon(\eta)$};

    % Label \eta angle.
    \def\etamarkerfrac{0.15}
    \path (turnorigin) -- ($(turnorigin)!\etamarkerfrac!(start)$)
          coordinate (etamarker);
    \path (etamarker)
          arc ({180 + \epsilondeg}:
               {180 + \epsilondeg - \etadeg / 2}:
               {(\R + \deltar) * \etamarkerfrac})
          node {$\eta$};
  \end{tikzpicture}
  \caption{Geometry of the curvature controller. The dark circle is
    the commanded path.  The lighter circle shows a constant radius
    path with radius $R + \delta r$, that starts at a small crosstrack
    offset, $\delta_0$, and heading offset, $\epsilon_0$.  This
    trajectory is projected forward to the point $(x(\eta), y(\eta))$.
    The lightest circle is a constant radius path with
    radius $R$ for comparison.}
  \label{fig:path_geometry}
\end{center}
\end{figure}
%
Figure \ref{fig:path_geometry} shows the geometry of the circular
flight path and the trajectory of a wing flying at constant curvature,
$(R + \delta r)^{-1}$, with a small crosstrack offset, $\delta_0$, and
heading offset, $\epsilon_0$.  The center of the kite trajectory is
given by:
\begin{alignat}{2}
x_c &= -R - \delta_0 + (R + \delta r) \cos \epsilon_0
& \; &\approx -\delta_0 + \delta r \\
y_c &= (R + \delta r) \sin \epsilon_0 & \; &\approx R \epsilon_0
\end{alignat}
%
To determine the kinematics, the crosstrack offset and heading offset
are expressed in terms of the $\eta$ angle parameter, which is related
to time as follows:
%
\begin{equation}
\eta = \frac{v t}{R + \delta r}
\end{equation}
%
A point on the trajectory projected out for a time $t$ is then:
\begin{eqnarray}
x(\eta) &=& x_c - (R + \delta r)
(\cos \eta \cos \epsilon_0 + \sin \eta \sin \epsilon_0) \\
y(\eta) &=& y_c + (R + \delta r)
(\sin \eta \cos \epsilon_0 - \cos \eta \sin \epsilon_0)
\end{eqnarray}
or approximately
\begin{eqnarray}
x(\eta) &\approx&
-R \cos \eta - \delta_0 + (1 - \cos \eta - \eta \sin \eta) \delta r -
R \sin \eta \cdot \epsilon_0 \\
y(\eta) &\approx& R \sin \eta + (\sin \eta - \eta \cos \eta) \delta r +
R (1 - \cos \eta) \epsilon_0
\end{eqnarray}
%
The crosstrack offset and heading offset at time $t$ are then:
%
\begin{eqnarray}
\delta(\eta) &=& \cos \eta \cdot \delta_0 + (1 - \cos \eta) \delta r +
R \sin \eta \cdot \epsilon_0
\label{eqn:delta_eta} \\
\epsilon(\eta) &=& -\frac{\sin \eta}{R} \delta_0 + \frac{\sin \eta}{R} \delta r +
\cos \eta \cdot \epsilon_0
\label{eqn:epsilon_eta}
\end{eqnarray}

The kinematics of the system may be found by first taking the small
$\eta$ approximation of Eq. \ref{eqn:delta_eta} and
Eq. \ref{eqn:epsilon_eta}.
%
\begin{eqnarray}
\delta(\eta) &\approx& \delta_0 + R \eta \epsilon_0 \\
\epsilon(\eta) &\approx& -\frac{\eta}{R} \delta_0 + \frac{\eta}{R} \delta r +
\epsilon_0
\end{eqnarray}
%
Then, taking the time derivative:
%
\begin{eqnarray}
\dot{\delta} &=& v \epsilon \\
\dot{\epsilon} &=& -\frac{v}{R^2} \delta - v \delta \kappa_{\mathrm{cmd}}
\end{eqnarray}
%
Here $\delta r$ is replaced by $\delta \kappa$ using the relation
$\delta \kappa = -\delta r / R^2$.  Finally, these equations are
combined to arrive at\footnote{There should be a $\frac{a}{v} \dot{\delta}$
on the right-hand side if it is not assumed that velocity is constant.}:
%
\begin{equation}
\ddot{\delta} = -\frac{v^2}{R^2} \delta - v^2 \delta \kappa_{\mathrm{cmd}}
\label{eqn:delta_diffeq}
\end{equation}

If the curvature command takes the form of the typical crosstrack PD
controller:
%
\begin{equation}
v^2 \delta \kappa_{\mathrm{cmd}} = k_p \delta + k_d v \epsilon
\end{equation}
%
then the closed-loop system is:
%
\begin{equation}
\ddot{\delta} + k_d \dot{\delta} + \left(\frac{v^2}{R^2} + k_p \right) \delta = 0
\end{equation}
%
The closed-loop system is stable if $k_d > 0$ and $k_p > -v^2/R^2$.
The characteristic frequency and damping ratio of this system are:
%
\begin{eqnarray}
\omega_0 &=& \sqrt{\frac{v^2}{R^2} + k_p} \label{eqn:omega0} \\
\zeta &=& \frac{k_d}{2 \sqrt{\frac{v^2}{R^2} + k_p}} \label{eqn:zeta}
\end{eqnarray}

\section{Analysis of basic path control ($t_1 = 0$)}

In the simplest form of the path controller, it is assumed that the
kite instantly meets the commanded curvature.  Thus, when predicting
the future position and heading of the kite, the time spent at the
current curvature is set to zero ($t_1 = 0$).

The curvature command is chosen to minimize a cost function, which we
define as the negative of the dot product between the final velocity
vector and the ideal velocity vector as defined by the vector field
(see Fig. \ref{fig:vector_field}).  More simply put, the command is
chosen to align the final velocity vector with the ideal velocity
vector as much as possible.  Obviously, this minimum occurs when these
vectors are aligned, or more specifically when:
%
\begin{equation}
\epsilon(\eta) = -k \delta(\eta)\;\;\;\; k = \frac{\pi}{2 r_{\mathrm{min}}}
\label{eqn:cost_func_solution}
\end{equation}
%
Thus Eq. \ref{eqn:delta_eta} and Eq. \ref{eqn:epsilon_eta} can be
combined with Eq. \ref{eqn:cost_func_solution} to find the analytic,
linearized form of the curvature command:
\begin{equation}
\delta \kappa_{\mathrm{cmd}} = \frac{1}{R^2} \left[
\frac{\cos \eta - \frac{\sin \eta}{kR}}
{1 - (\cos \eta - \frac{\sin \eta}{kR})} \delta +
\frac{\sin \eta + \frac{\cos \eta}{kR}}
{1 - (\cos \eta - \frac{\sin \eta}{kR})} R \epsilon
\right]
\end{equation}
The equivalent linear crosstrack PD gains are:
\begin{eqnarray}
k_p &=& \frac{v^2}{R^2}
\frac{\cos \eta - \frac{\sin \eta}{kR}}
{1 - (\cos \eta - \frac{\sin \eta}{kR})} \\
k_d &=& \frac{v}{R}
\frac{\sin \eta + \frac{\cos \eta}{kR}}
{1 - (\cos \eta - \frac{\sin \eta}{kR})}
\end{eqnarray}

The characteristic frequency and damping ratio can be expressed in
terms of $\eta$, $r_{\mathrm{min}}$, $v$, and $R$ by substituting
these gains into Eq. \ref{eqn:omega0} and Eq. \ref{eqn:zeta}.
\begin{equation}
\omega_0 = \frac{v}{R}
\left( 1 - (\cos \eta - \frac{\sin \eta}{kR}) \right)^{-1/2}
\label{eqn:path_omega0}
\end{equation}
%
\begin{equation}
\zeta = \frac{\sin \eta + \frac{\cos \eta}{kR}}
{2 \sqrt{1 - (\cos \eta - \frac{\sin \eta}{kR})}}
\label{eqn:path_zeta}
\end{equation}
%
These equations may be combined to eliminate $k$ as follows:
\begin{equation}
kR = \frac{\omega_0^2 \sin \eta}{v^2/R^2 - \omega_0^2 (1 - \cos \eta)}
\label{eqn:kr}
\end{equation}
%
\begin{equation}
(1 - \cos \eta) (\omega_0 R / v)^2 - 2 \zeta \sin \eta \cdot (\omega_0 R /v) +
\cos \eta = 0
\end{equation}
%
\begin{equation}
\omega_0 = \frac{v}{R} \frac{
\zeta \sin \eta - \sqrt{\zeta^2 \sin^2 \eta - \cos \eta (1 - \cos \eta)}
}{
1 - \cos \eta
}
\label{eqn:omega_zeta_eta}
\end{equation}

\begin{table}
\begin{center}
\begin{tabular}{ccccccc}
\hline
\hline
$v$ & $R$ & $\zeta$ & $\omega_0/2 \pi$ & $\eta$ & $t$ & $r_{\mathrm{min}}$ \\\
[m/s] & [m] & [\#] & [Hz] & [\#] & [s] & [m] \\
\hline
30 & 110 & 0.707 & 0.1 & 0.462 & 1.69 & 32 \\
60 & 110 & 0.616 & 0.117 & 0.924 & 1.69 & 32 \\
90 & 110 & 0.508 & 0.13 & 1.386 & 1.69 & 32 \\
\hline
30 & 110 & 0.918 & 0.075 & 0.364 & 1.33 & 130 \\
60 & 110 & 0.707 & 0.1 & 0.727 & 1.33 & 130 \\
90 & 110 & 0.562 & 0.119 & 1.09 & 1.33 & 130 \\
\hline
30 & 110 & 1.30 & 0.059 & 0.298 & 1.09 & 293 \\
60 & 110 & 0.926 & 0.08 & 0.596 & 1.09 & 293 \\
90 & 110 & 0.707 & 0.1 & 0.894 & 1.09 & 293 \\
\hline
\hline
\end{tabular}
\caption{Selecting path controller parameters with fixed $\zeta$ or
  look-ahead time ($t = \eta / (v/R)$).}
\label{tbl:choose_parameters}
\end{center}
\end{table}

Now the various tunable parameters ($r_{\mathrm{min}}$ and $\eta$) may
be chosen by first selecting a desired damping ratio $\zeta$ and
bandwidth.  Then, Eq. \ref{eqn:omega_zeta_eta} is used to select an
$\eta$ that meets the desired bandwidth.  Finally, these values are
converted to $k$ and thus $r_{\mathrm{min}}$ through Eq. \ref{eqn:kr}.
Examples of selecting parameters with this method are shown in
Tbl. \ref{tbl:choose_parameters}.

\begin{figure}[!ht]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
    scale=1.3,
    xlabel=$\eta$,
    xmin=0,
    xmax=3,
    ymin=-1.3,
    ymax=4,
    grid=both
  ]
  \def\R{110};
  \def\rmin{75};
  \def\kR{(pi/2/\rmin * \R)};
  \def\z{(cos(deg(x)) - sin(deg(x)) / \kR)};
  \def\kp{(\z / (1 - \z))};
  \def\kd{((sin(deg(x)) + cos(deg(x)) / \kR) / (1 - \z))};
  \def\omegafunc{sqrt(1 + \kp)};
  \def\zetafunc{(\kd / (2 * \omegafunc))};
  \addplot [smooth, color=blue, mark=none, domain=0:3] {\kp};
  \addplot [smooth, color=green, mark=none, domain=0:3] {\kd};
  \addplot [smooth, color=red, mark=none, domain=0:3] {\omegafunc};
  \addplot [smooth, color=cyan, mark=none, domain=0:3] {\zetafunc};
  \addplot [smooth, color=black, domain=0:3] {0};
  %\addplot [smooth, color=gray, domain=0:3] {sqrt(2)/2};
  \legend{$k_p / (v/R)^2$, $k_d / (v/R)$, $\omega_0 / (v/R)$, $\zeta$};
\end{axis}
\end{tikzpicture}
\caption{Gains and parameters of the linearized curvature controller
  without the current curvature look-ahead ($R = 110, r_{\mathrm{min}} = 75$).
  Typically, $\eta \sim 1$ in normal flight conditions. All values are
  expressed in non-dimensional form.}
\label{fig:simple_gains}
\end{center}
\end{figure}

\section{Analysis of general path control}

In the general form of the path controller, the future position of the
kite is based on projecting the current measured curvature for a time
$t_1$ and then projecting a future commanded curvature for a time
$t_2$.  This is modeled by breaking up $\eta$ into two components:
%
\begin{equation}
\eta = \eta_1 + \eta_2
\end{equation}
%
and then applying Eq. \ref{eqn:delta_eta} and \ref{eqn:epsilon_eta}
twice.  The outputs of the first application of these equations are
the inputs to the next application.  Thus, the crosstrack offset and
heading offset at time $t_1$ is:
%
\begin{eqnarray}
\delta(\eta_1) &=& \cos \eta_1 \cdot \delta_0 + (1 - \cos \eta_1) \delta r_0 +
R \sin \eta_1 \cdot \epsilon_0 \\
\epsilon(\eta_1) &=& -\frac{\sin \eta_1}{R} \delta_0 +
\frac{\sin \eta_1}{R} \delta r_0 +
\cos \eta_1 \cdot \epsilon_0
\end{eqnarray}
%
And, the crosstrack offset and heading offset at time $t = t_1 + t_2$
is:
%
\begin{eqnarray}
\delta(\eta) &=& \cos \eta_2 \left(
\cos \eta_1 \cdot \delta_0 + (1 - \cos \eta_1) \delta r_0 +
R \sin \eta_1 \cdot \epsilon_0 \right) \\
&+& (1 - \cos \eta_2) \delta r \nonumber \\
&+& R \sin \eta_2 \left(-\frac{\sin \eta_1}{R} \delta_0 +
\frac{\sin \eta_1}{R} \delta r_0 +
\cos \eta_1 \cdot \epsilon_0 \right) \nonumber \\
\epsilon(\eta) &=& -\frac{\sin \eta_2}{R} \left(
\cos \eta_1 \cdot \delta_0 + (1 - \cos \eta_1) \delta r_0 +
R \sin \eta_1 \cdot \epsilon_0 \right) \\
&+& \frac{\sin \eta_2}{R} \delta r \nonumber \\
&+& \cos \eta_2 \left(-\frac{\sin \eta_1}{R} \delta_0 +
\frac{\sin \eta_1}{R} \delta r_0 +
\cos \eta_1 \cdot \epsilon_0 \right) \nonumber
\end{eqnarray}

From these equations, it is possible to extract the linearized form of
the curvature command:
%
\begin{alignat}{3}
\delta \kappa_{\mathrm{cmd}} &= -\frac{1}{R^2} \bigg[&\bigg(&
-k \cos \eta_2 \cos \eta_1 + k \sin \eta_2 \sin \eta_1 \\
& && + \sin \eta_2 \cos \eta_1/R + \cos \eta_2 \sin \eta_1/R
\bigg) \cdot \delta \nonumber \\
%
& &+& \bigg(-k \cos \eta_2 (1 - \cos \eta_1) -
k \sin \eta_2 \sin \eta_1 \nonumber \\
& && + \sin \eta_2 (1 - \cos \eta_1)/R -
\cos \eta_2 \sin \eta_1 / R \bigg) \cdot \delta r \nonumber \\
%
& &+& \bigg(-kR \cos \eta_2 \sin \eta_1 -
kR \sin \eta_2 \cos \eta_1 \nonumber \\
& && + \sin \eta_2 \sin \eta_1 - \cos \eta_2 \cos \eta_1
\bigg) \cdot \epsilon \bigg] \nonumber \\
%
& &\bigg/& \left( \frac{\sin \eta_2}{R} + k (1 - \cos \eta_2) \right) \nonumber
\end{alignat}
%
which simplifies to:
\begin{alignat}{3}
\delta \kappa_{\mathrm{cmd}} &= \frac{1}{R^2} \bigg[&\bigg(&
\cos \eta - \frac{\sin \eta}{kR} \bigg) \cdot \delta \\
%
& &+& \bigg(-\cos \eta + \cos \eta_2
+ \frac{\sin \eta}{kR} - \frac{\sin \eta_2}{kR} \bigg) \cdot \delta r \nonumber \\
%
& &+& \bigg(\sin \eta + \frac{\cos \eta}{kR} \bigg) \cdot R \epsilon \bigg] \nonumber \\
%
& &\bigg/& \left( 1 - (\cos \eta_2 - \frac{\sin \eta_2}{kR}) \right) \nonumber
\end{alignat}
%

\begin{figure}[!ht]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
    scale=1.3,
    xlabel=$\eta$,
    xmin=0,
    xmax=3,
    ymin=-1.3,
    ymax=4,
    grid=both
  ]
  \def\R{110};
  \def\rmin{75};
  \def\kR{(pi/2/\rmin * \R)};
  \def\neta{(x)};
  \def\netaone{(0.2 * x)};
  \def\netatwo{(0.8 * x)};
  \def\den{(1 - (cos(deg(\netatwo)) - sin(deg(\netatwo)) / \kR))};
  \def\kp{((cos(deg(\neta)) - sin(deg(\neta)) / \kR) / \den)};
  \def\kd{((sin(deg(\neta)) + cos(deg(\neta)) / \kR) / \den)};
  \def\ka{((-cos(deg(\neta)) + sin(deg(\neta)) / \kR +
            cos(deg(\netatwo)) - sin(deg(\netatwo)) / \kR) /
            \den)};
  \def\omegafunc{sqrt(1 + \kp / (1 + \ka))}
  \def\omegaorig{sqrt(1 + \kporig)}
  \def\zetafunc{((\kd / (1 + \ka)) / (2 * \omegafunc))};
  \addplot [smooth, color=blue, mark=none, domain=0:3] {\kp};
  \addplot [smooth, color=green, mark=none, domain=0:3] {\kd};
  \addplot [smooth, color=yellow, mark=none, domain=0:3] {\ka};
  \addplot [smooth, color=red, mark=none, domain=0:3] {\omegafunc};
  \addplot [smooth, color=cyan, mark=none, domain=0:3] {\zetafunc};
  \addplot [smooth, color=black, domain=0:3] {0};
  %\addplot [smooth, color=gray, domain=0:3] {sqrt(2)/2};
  \legend{$k_p / (v/R)^2$, $k_d / (v/R)$, $k_a$, $\omega_0 / (v/R)$, $\zeta$};
\end{axis}
\end{tikzpicture}
\caption{Gains and parameters of the linearized curvature controller
  {\it with} the current curvature look-ahead
  ($R = 110, r_{\mathrm{min}} = 75, \eta_1 = \eta/5$).
  All values are expressed in non-dimensional form.}
\label{fig:general_gains}
\end{center}
\end{figure}
%
In addition to the PD terms, the curvature command also has an
acceleration (i.e. curvature) term:
%
\begin{equation}
v^2 \delta \kappa_{\mathrm{cmd}} =
k_p \delta + k_d v \epsilon - k_a v^2 \delta \kappa
\label{eqn:crosstrack_with_accel}
\end{equation}
%
The proportional, derivative, and acceleration gains are:
%
\begin{eqnarray}
k_p &=& \frac{v^2}{R^2} \frac{
\cos \eta - \frac{\sin \eta}{k R}}
{1 - (\cos \eta_2 - \frac{\sin \eta_2}{k R})} \\
%
k_d &=& \frac{v}{R} \frac{\sin \eta + \frac{\cos \eta}{kR}}
{1 - (\cos \eta_2 - \frac{\sin \eta_2}{kR})} \nonumber \\
k_a &=& \frac{-\cos \eta + \frac{\sin \eta}{kR} + \cos \eta_2 -
  \frac{\sin \eta_2}{kR}}
{1 - (\cos \eta_2 - \frac{\sin \eta_2}{kR})}
\end{eqnarray}

The inner loop, which controls tether roll to meet a commanded
curvature, may be modeled as a simple low-pass filter with cut-off
frequency $\omega_{\kappa}$.
\begin{equation}
  \delta \dot{\kappa} = \omega_{\kappa}
  (\delta \kappa_{\mathrm{cmd}} - \delta \kappa)
  \label{eqn:inner_loop_model}
\end{equation}
%
Then, from combining Eq. \ref{eqn:delta_diffeq},
\ref{eqn:crosstrack_with_accel}, and \ref{eqn:inner_loop_model}, the
closed loop dynamics of the system are:
\begin{equation}
  \dddot{\delta} + (k_d + \omega_{\kappa} (1 + k_a)) \ddot{\delta} +
  (v^2/R^2 + \omega_{\kappa} k_d + k_p) \dot{\delta} +
  \omega_{\kappa} (v^2/R^2 (1 + k_a) + k_p) \delta = 0
\end{equation}
%
It is useful to examine the $\omega_{\kappa} \gg 1$ case to compare
this system with the basic path control case.
\begin{equation}
  \ddot{\delta} + \frac{k_d}{1 + k_a} \dot{\delta} +
  \left(\frac{v^2}{R^2} + \frac{k_p}{1 + k_a} \right) \delta = 0
\end{equation}
%
It is clear that the proportional and derivative gains must be
increased to account for the acceleration gain.  However, $\omega$ and
$\zeta$ still only depend on $\eta$ and are given by the same formulas
as the basic case (Eq. \ref{eqn:path_omega0} and
Eq. \ref{eqn:path_zeta}).  Note that the acceleration gain cannot be
increased to the point where $\eta = \eta_1$ or the controller will
run into issues with saturations and other nonlinearities due to the
high proportional and derivative gains.

The acceleration gain does two things.  First, it increases the
disturbance rejection on the curvature inner loop.  This may be seen
by separating the acceleration gain from the proportional and
derivative gains as shown in Fig. \ref{fig:path_inner_outer}.
Increasing the disturbance rejection in the manner is important
because the inner loop actually controls tether roll, which is related
to but is not identical to curvature.  Second, the acceleration gain
makes the nonlinear, anticipatory aspects of the curvature control
more accurate.

\begin{figure}[!ht]
\begin{center}
\begin{tikzpicture}
  \matrix [row sep=4mm, column sep=8mm] {
    \node[dspnodeopen, dsp/label=above] (n00) {$\delta_{\mathrm{cmd}}$}; &[-4mm]
    \node[vdspadder] (n01) {}; &[-4mm]
    \node[dspfilter] (n02) {$C_{\mathrm{path}}$}; &[-8mm]
    \node[vdspadder] (n03) {}; &[4mm]
    \node[dspfilter] (n05) {$\kappa \rightarrow \phi_t$}; &[-4mm]
    \node[dspfilter] (n06) {$G^{\mathrm{closed}}_{\mathrm{lateral}}$}; &[-4mm]
    \node[dspfilter] (n07) {$\phi_t \rightarrow \kappa$}; &
    \node[dspnodefull] (n08) {}; &[-4mm]
    \node[dspfilter] (n09) {$G_{\mathrm{path}}$}; &[-4mm]
    \node[dspnodefull] (n0a) {}; &
    \node[dspnodeopen, dsp/label=above] (n0b) {$\delta$}; \\
    \node[coordinate] (n10) {}; &
    \node[coordinate] (n11) {}; &
    \node[coordinate] (n12) {}; &
    \node[coordinate] (n13) {}; &
    \node[coordinate] (n15) {}; &
    \node[dspsquare] (n16) {$k_a$}; &
    \node[coordinate] (n17) {}; &
    \node[coordinate] (n18) {}; &
    \node[coordinate] (n19) {}; &
    \node[coordinate] (n1a) {}; &
    \node[coordinate] (n1b) {}; & \\
    \node[coordinate] (n20) {}; &
    \node[coordinate] (n21) {}; &
    \node[coordinate] (n22) {}; &
    \node[coordinate] (n23) {}; &
    \node[coordinate] (n25) {}; &
    \node[coordinate] (n26) {}; &
    \node[coordinate] (n27) {}; &
    \node[coordinate] (n28) {}; &
    \node[coordinate] (n29) {}; &
    \node[coordinate] (n2a) {}; &
    \node[coordinate] (n2b) {}; & \\
  };

  \draw[dspconn] (n00) -- (n01);
  \draw[dspconn] (n01) -- (n02) -- (n03);
  \draw[dspconn] (n03) -- node[above] {$\delta \kappa_{\cmd}$} (n05)
                       -- (n06) -- (n07)
                       -- node[above] {$\delta \kappa$} (n08)
                       -- (n09) -- (n0a) -- (n0b);
  \draw[dspconn] (n08) |- (n16) -| (n03);
  \draw[dspconn] (n0a) |- (n2a) -| (n01);
\end{tikzpicture}
\caption{Schematic of the path control loop.}
\label{fig:path_inner_outer}
\end{center}
\end{figure}

\section{Final notes}

This analysis shows that the nonlinear path controller is equivalent
to a more traditional linear crosstrack controller for small
crosstrack and heading offsets.  And also, that the parameters
($\zeta$ and $\omega_0$) of the equivalent linear crosstrack
controller may be set using the parameters of the nonlinear path
controller (i.e. $\eta$ and $r_{\mathrm{min}}$).

However, it remains to be shown whether the nonlinear path controller
actually offers any advantages over the simple linear crosstrack
controller or over other nonlinear path tracking schemes
\cite{park2004}.

\begin{thebibliography}{1}
\bibitem{park2004} Park, Sanghyuk, John Deyst, and Jonathan
  P. How. ``A new nonlinear guidance logic for trajectory tracking.''
  {\it Proceedings of the AIAA Guidance, Navigation and Control
    Conference}. 2004.
\end{thebibliography}

\end{document}


\subsection{Perceptual Losses for Real-Time Style Transfer and Super-Resolution}
\label{seq:johnson}
\textit{Perceptual Losses for Real-Time Style Transfer and Super-Resolution} is a paper written by Johnson et al. \cite{Johnson:1}. They take a new approach to solve the optimization problem proposed by Gatys et al \cite{Gatys:1}. Instead of doing a forward and backward pass through the pretrained VGG-network to solve every step of the optimization problem, which is computationally expensive, Johnson et al. train an \textit{image transformation network} to approximate solutions to the optimization problem. The loss function for this network is based on the pretrained VGG-network, the \textit{loss network}. The feature maps which were discussed in Section \ref{sec:vgg} are used to train the image transformation network on high-level features, which in turn define the \textit{perceptual loss functions}. This model just has to do one forward-pass to style an image, thus being much faster to style an image than the method of Gatys et al. \cite{Gatys:1}. On the other hand, it is costly to train the model, as it is trained on a large dataset of different images, and it is not so flexible as it is trained to style an image with a particular style.
\subsubsection{Image transformation network}
\label{sec:neuralnetwork}
Johnson et. al. define an image transformation network $f_W$ which consists of $5$ residual blocks using the architecture described in Figure \ref{fig:residual}\newline\newline
\begin{figure}[!ht]
\begin{center}
\includegraphics[scale=0.30]{report/Background/images/residualblock.png}
\caption{A residual block which adds an input $x$ to $x'$, where $x'$ is the result after doing some convolution, batch-normalization, and ReLU - operations on $x$. Then the ReLU-operation is performed on $x+x'.$}
\label{fig:residual}
\end{center}
\end{figure}\newline
All the layers non-residual layers are followed up by spatial batch normalizations and ReLU operations, except of the output layer, which is followed up by a scaled $\tanh$ operation. This is to ensure that the transformed image has pixels in the range $[0, 255].$\newline\newline
The main function of the image transformation network is to take an input image $x$, and produce the styled image $\hat{y}=f_W(x).$ The perceptual loss functions in the loss network calculate the loss, which will be discussed in Section \ref{sec:loss}. The loss is propagated back the network using back-propagation, and stochastic gradient descent is used to update the weights $W$ of the network.
\subsubsection{Perceptual loss functions}
\label{sec:loss}
Johnson et al. define a loss network $\phi$, which defines several loss function $l_1,l_2,\dots,\l_k$. These loss functions can be categorized as two loss functions, one as the \textit{feature reconstruction loss} $l_{feat}^\phi,$ which is described by Equation (\ref{eq:content_loss}), and the other as the \textit{style reconstruction loss} $l_{style}^\phi,$ which is described by Equation (\ref{eq:style_loss}). So $l_i\in\{l_{feat}^\phi,l_{style}^\phi\}.$ When the image $\hat{y}$ has been produced by the image transformation network, a perceptual loss function calculates a scalar value $l_i(\hat{y}, y_i),$ where $y_i$ is a target image, either the content image or the style image. This loss is based on how equal the higher-dimensional feature maps of $\hat{y}$ and $y_i$ are, not $\hat{y}$ and $y_i$ themselves. These feature maps are extracted from the pre-trained loss network $\phi.$
\subsubsection{Architecture}
Johnson et al. designed the following architecture, where they combine their fully-connected deep convolutional image transformation network $f_W$ with the pre-trained VGG loss network $\phi.$\newline
\begin{figure}[!ht]
\begin{center}
\includegraphics[scale=0.50]{report/Background/images/architecture.png}
\caption{The image transformation network $f_W$ transforms the image $x$ into $\hat{y}=f_W(x).$ After that, $\hat{y}$ is passed through the loss network $\phi$ to extract high-dimensional features. These features are compared with the features of $y_s$, the style target, and $y_c$, the content target.}
\label{fig:architecture}
\end{center}
\end{figure}\newline\newline
The image transformation network is trained with stochastic gradient descent, and the goal is to minimize
\begin{equation}
    W^*=\arg\min_W{\boldsymbol{E}_{x,\{y_i\}}\left[\sum_{i=1}{\lambda_il_i(f_W(x),y_i)}\right]}
\end{equation}
which is a weighed combination $(\lambda_i)$ of the perceptual loss functions $l_i$.
\subsubsection{Instance normalization}
\label{sec:instance_normalization}
Instance normalization is a normalization method in used to train a model effectively. Although Johnson et al do not use instance normalization when they train their model, it is still worth to examine this normalization method, as it can be used to speed up the optimization of the image transformation network. Instance normalization was first introduced by Ulyanov et al. in the paper \textit{Instance Normalization: The Missing Ingredient for Fast Stylization} \cite{Ulyanov:1}.\newline\newline
Before discussing instance normalization, let's look at Batch normalization. Batch normalization normalizes all the data across the batch and spatial locations. This normalization helps the network to converge faster, as the activations in the network converge towards unit Gaussian distribution. This prevents the \textit{vanishing gradient problem}, which means that the gradient of the loss function converges to $0$, making the model harder to train. The data $x_i$ is normalized in the following manner:
\begin{equation}
    x\leftarrow\frac{x-\mu_i}{\sqrt{\sigma_i+\epsilon}}
\end{equation}
where
\begin{equation}
\mu_i=\frac{1}{HWT}\sum_{t=1}^T\sum_{l=1}^W\sum_{m=1}^H{x_{tilm}}
\end{equation}
and
\begin{equation}
\sigma_i^2=\frac{1}{HWT}\sum_{t=1}^T\sum_{l=1}^W\sum_{m=1}^H{(x_{tilm}-mu_i)^2}
\end{equation}
Here $T$ is the number of batches. The downside with batch normalization is that it adds noise to the model, since it normalizes across the whole batch, so one instance depends on the neighboring instances.\newline\newline
Instance normalization, however, normalizes each batch independently:
\begin{equation}
\mu_i=\frac{1}{HW}\sum_{l=1}^W\sum_{m=1}^H{x_{ilm}}
\end{equation}
and
\begin{equation}
\sigma_i^2=\frac{1}{HW}\sum_{l=1}^W\sum_{m=1}^H{(x_{ilm}-mu_i)^2}
\end{equation}
Here the model does not get extra noise, since the normalization is only happening across spatial locations. The calculation of instance normalization for a $x_i$ is $O(WH),$ while for batch normalization it is $O(TWH),$ where $O$ is Big $O$. This makes instance normalization both faster to compute, and the results get better because the noise is reduced.


%\documentclass[10pt,conference]{IEEEtran}

\documentclass{article}% default font size: 10pt

\usepackage{amssymb} \usepackage{amsmath} \usepackage{amsthm} \usepackage{algorithm} \usepackage{algorithmic} \usepackage{url}

\usepackage{subfigure}

\newtheorem{theorem}{Theorem} \newtheorem{lemma}{Lemma} \newtheorem{corollary}{Corollary} \newtheorem{definition}{Definition} \newtheorem{assumption}{Assumption} \newtheorem{example}{Example}
\newtheorem{observation}[theorem]{Observation}
%\newtheorem{theorem}{Theorem} \newtheorem{definition}{Definition} \newtheorem{remark}{Remark} \newtheorem{lemma}{Lemma} \newtheorem{corollary}{Corollary} \newtheorem{fact}{Fact} \newtheorem{invariant}{Invariant}

\usepackage{color}
\newcounter{todocounter}
\newcommand{\todo}[1]{\stepcounter{todocounter}\textcolor{red}{to-do\#\arabic{todocounter}: #1}}
\newcommand{\newadded}[1]{{\color{magenta} #1}}
\newcommand{\question}[1]{{\color{blue} #1}}

\usepackage{graphicx}
\graphicspath{{./Figures/}}

\begin{document}

\title{Multi-Label Text Classification}
\date{Jul 18, 2014}
\author{Huangxin Wang, Zhonghua Xi\thanks{Department of Computer Science, George Mason University. Fairfax, VA 22030. Email: \textsf{hwang14@gmu.edu, zxi@gmu.edu}}}

\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem Statement}

\section{Algorithm}
\subsection{ReWeight} We use a variant of TF.IDF model to reweight the word vector of  each document. The TF.IDF variants is defined as:
\begin{displaymath}
w_{t,d} = log(tf_{t,d}+1)*idf_t
\end{displaymath}

where $w_{t,d}$ is the reweight word frequency, $tf_{t,d}$ is the original frequency of term $t$ in document $d$, and $idf_t$ is inverse document frequency which is defined as follows,

\begin{displaymath}
idf_t = \frac{|D|}{df_t}
\end{displaymath}
where $|D|$ is the number of documents in the training set, and $df_t$ is number of documents contains  term $t$.

\subsection{Build Classifiers}
We build classifier for each class, the classifier is calculated by using the average of each instances in the class.

\subsection{Similarity Calculation}
We calculate the similarity of a test instance with the classifier using the cosine similarity.
\begin{displaymath}
cossim(d_i,d_j) = \frac{d_i*d_j}{|d_i|*|d_j|} = \frac{\sum^N_{k=1} w_{k,i}*w_{k,j}}{\sqrt{\sum^N_{k=1} w^2_{k,i}*\sqrt{\sum^N_{k=1}w^2_{k,j}}}}
\end{displaymath}

where $d_i$ is feature vector of document $i$ and $d_j$ is the feature vector of class $j$. We denote $cossim(d_i,d_j)$ as the score document $i$ achieves in class $j$.

\subsection{Multi-Label Classify}
\paragraph{First Label} The first label document $i$ assigned is the class in which it gets the highest score.

\paragraph{Second Label} Similar to the chosen of label 1, for the second label, we choose the class have the second highest score of document $i$. However, we accept the second label only when $score(label_1)/score(label_2) \leq \alpha$, which means document $i$ have almost the same degree of similarity to label 2 as to label 1.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\subsection{Gaussian basis sets}
\label{sec:gaussianbasis}

In this section we describe the use of localized basis sets to expand the \ixml{sposet}. The general form of a single particle orbital in this case is given by:
\begin{equation}
\phi_i(\vec{r}) = \sum_k C_{i,k} \ \eta_k(\vec{r}),
\end{equation}
where $\{\eta_k(\vec{r})\}$ is a set of M atom-centered basis
functions and $C_{i,k}$ is a coefficient matrix. This \ixml{sposet}
should be used in calculations of finite systems employing an
atom-centered basis set and is typically generated by the
\textit{convert4qmc} converter.  Examples include calculations of
molecules using Gaussian basis sets or Slater-type basis
functions. Initial support for periodic systems is described in Section
\ref{chap:LCAO}. Even though this section is called "Gaussian basis
sets" (by far the most common atom-centered basis set), QMCPACK works
with any atom-centered basis set based on either spherical
harmonic angular functions or Cartesian angular expansions. The radial
functions in the basis set can be expanded in either Gaussian
functions, Slater-type functions, or numerical radial functions.

In this section we describe the input sections for the atom-centered basis set and the \ixml{sposet} for a single Slater determinant trial wavefunction. The input sections for multideterminant trial wavefunctions are described in Section~\ref{sec:multideterminants}. The basic structure for the input block of a single Slater determinant is given in Listing~\ref{listing:lcaosposet}.
A list of options for \ixml{determinantset} associated with this \ixml{sposet} is given in Table~\ref{table:determinantset}.

\begin{minipage}{\linewidth}
\begin{lstlisting}[style=QMCPXML,caption=Basic input block for a single determinant trial wavefunction using a \ixml{sposet} expanded on an atom-centered basis set. \label{listing:lcaosposet}]
<wavefunction id="psi0" target="e">
    <determinantset>
      <basisset>
        ...
      </basisset>
      <slaterdeterminant>
        ...
      </slaterdeterminant>
    </determinantset>
</wavefunction>
\end{lstlisting}
\end{minipage}

\begin{table}[h]
\begin{center}
\begin{tabularx}{\textwidth}{l l l l l X }
\hline
\multicolumn{6}{l}{\texttt{determinantset} element} \\
\hline
\multicolumn{2}{l}{Parent elements:} & \multicolumn{4}{l}{\texttt{wavefunction}}\\
\multicolumn{2}{l}{Child  elements:} & \multicolumn{4}{l}{\texttt{basisset,slaterdeterminant,sposet,multideterminant}}\\
\multicolumn{2}{l}{Attribute:} & \multicolumn{4}{l}{}\\
   &   \bfseries Name              & \bfseries Datatype & \bfseries Values & \bfseries Default   & \bfseries Description \\
   &   \texttt{name}/\texttt{id}   &  Text              &  \textit{Any}    &  ""             & Name of determinant set \\
   &   \texttt{type}                    &  Text               &   See below   &   ""            &  Type of \texttt{sposet} \\
   &   \texttt{keyword}             &  Text               &   NMO,GTO,STO   &  NMO        & Type of orbital set generated \\
   &   \texttt{transform}           &  Text               &   Yes/no          &  Yes         &  Transform to numerical radial functions?  \\
   &   \texttt{source}               &  Text               &   \textit{Any}    &  Ion0        & Particle set with the position of atom centers \\
   &   \texttt{cuspCorrection}  &  Text               &   Yes/no          &  No         & Apply cusp correction scheme to \texttt{sposet}? \\
%   &   \texttt{cuspInfo}               &  text               &   \textit{any}    &  ""             & File with saved cusp data. \\
  \hline
\end{tabularx}
\end{center}
\caption{Options for the \ixml{determinantset} xml-block associated with atom-centered single particle orbital sets.}
\label{table:determinantset}
\end{table}

The definition of the set of atom-centered basis functions is given by the \ixml{basisset} block, and the \ixml{sposet} is defined within \ixml{slaterdeterminant}. The \ixml{basisset} input block is composed from a collection of \ixml{atomicBasisSet} input blocks, one for each atomic species in the simulation where basis functions are centered. The general structure for \ixml{basisset} and \ixml{atomicBasisSet} are given in Listing~\ref{listing:basisset}, and the corresponding lists of options are given in Tables~\ref{table:basisset} and~\ref{table:atomicBasisSet}.

\begin{minipage}{\linewidth}
\begin{lstlisting}[style=QMCPXML,caption=Basic input block for \ixml{basisset}.\label{listing:basisset}]
      <basisset name="LCAOBSet">
        <atomicBasisSet name="Gaussian-G2" angular="cartesian" elementType="C" normalized="no">
          <grid type="log" ri="1.e-6" rf="1.e2" npts="1001"/>
          <basisGroup rid="C00" n="0" l="0" type="Gaussian">
            <radfunc exponent="5.134400000000e-02" contraction="1.399098787100e-02"/>
            ...
          </basisGroup>
          ...
        </atomicBasisSet>
        <atomicBasisSet name="Gaussian-G2" angular="cartesian" type="Gaussian" elementType="C" normalized="no">
          ...
        </atomicBasisSet>
        ...
      </basisset>
\end{lstlisting}
\end{minipage}

\begin{table}[h]
\begin{center}
\begin{tabularx}{\textwidth}{l l l l l X }
\hline
\multicolumn{6}{l}{\texttt{basisset} element} \\
\hline
\multicolumn{2}{l}{Parent elements:} & \multicolumn{4}{l}{\texttt{determinantset}}\\
\multicolumn{2}{l}{Child  elements:} & \multicolumn{4}{l}{\texttt{atomicBasisSet}}\\
\multicolumn{2}{l}{Attribute:} & \multicolumn{4}{l}{}\\
   &   \bfseries Name              & \bfseries Datatype & \bfseries Values & \bfseries Default   & \bfseries Description \\
   &   \texttt{name}/\texttt{id}   &  Text              &  \textit{Any}    &  ""                & Name of atom-centered basis set \\
  \hline
\end{tabularx}
\end{center}
\caption{Options for the \texttt{basisset} xml-block associated with atom-centered single particle orbital sets.}
\label{table:basisset}
\end{table}

\begin{table}[h]
\begin{center}
\begin{tabularx}{\textwidth}{l l l l l X }
\hline
\multicolumn{6}{l}{\texttt{atomicBasisSet} element} \\
\hline
\multicolumn{2}{l}{Parent elements:} & \multicolumn{4}{l}{\texttt{basisset}}\\
\multicolumn{2}{l}{Child  elements:} & \multicolumn{4}{l}{\texttt{grid,basisGroup}}\\
\multicolumn{2}{l}{Attribute:} & \multicolumn{4}{l}{}\\
   &   \bfseries Name              & \bfseries Datatype & \bfseries Values & \bfseries Default   & \bfseries Description \\
   &   \texttt{name}/\texttt{id}   &  Text              &  \textit{Any}    &  ""                & Name of atomic basis set \\
   &   \texttt{angular}               &  Text              &  See below    &  Default       & Type of angular functions  \\
%   &   \texttt{type}                    &  text              &  see below    &  ""                &  Type of input radial function. \\
   &   \texttt{expandYlm}         &  Text              &  See below   &  Yes                &  Expand Ylm shells? \\
   &   \texttt{expM}                  &  Text              &  See below   &  Yes                &  Add sign for $(-1)^{m}$? \\
   &   \texttt{elementType/species}   &  Text  &  \textit{Any}    &  e                &  Atomic species where functions are centered \\
   &   \texttt{normalized}         &  Text              &  Yes/no   &  Yes                &  Are single particle functions normalized? \\
  \hline
\end{tabularx}
\end{center}
\caption{Options for the \texttt{atomicBasisSet} xml-block.}
\label{table:atomicBasisSet}
\end{table}

\begin{table}[h]
\begin{center}
\begin{tabularx}{\textwidth}{l l l l l X }
\hline
\multicolumn{6}{l}{\texttt{basisGroup} element} \\
\hline
\multicolumn{2}{l}{Parent elements:} & \multicolumn{4}{l}{\texttt{atomicBasisSet}}\\
\multicolumn{2}{l}{Child  elements:} & \multicolumn{4}{l}{\texttt{radfunc}}\\
\multicolumn{2}{l}{Attribute:} & \multicolumn{4}{l}{}\\
   &   \bfseries Name              & \bfseries Datatype & \bfseries Values & \bfseries Default   & \bfseries Description \\
   &   \texttt{rid}/\texttt{id}   &  Text              &  \textit{Any}    &  ""                & Name of the basisGroup \\
   &   \texttt{type}                    &  Text            &  \textit{Any}    &  ""                & Type of basisGroup \\
   &   \texttt{n/l/m/s}                 &  Integer           &  \textit{Any}    &  0                & Quantum numbers of basisGroup \\
  \hline
\end{tabularx}
\end{center}
\caption{Options for the \texttt{basisGroup} xml-block.}
\label{table:basisGroup}
\end{table}

\begin{minipage}{\linewidth}
\begin{lstlisting}[style=QMCPXML,caption=Basic input block for \texttt{slaterdeterminant} with an atom-centered \texttt{sposet}.\label{listing:slaterdeterminant}]
      <slaterdeterminant>
      </slaterdeterminant>
\end{lstlisting}
\end{minipage}

\begin{table}[h]
\begin{center}
\begin{tabularx}{\textwidth}{l l l l l X }
\hline
\multicolumn{6}{l}{\texttt{} element} \\
\hline
\multicolumn{2}{l}{Parent elements:} & \multicolumn{4}{l}{\texttt{}}\\
\multicolumn{2}{l}{Child  elements:} & \multicolumn{4}{l}{\texttt{}}\\
\multicolumn{2}{l}{Attribute:} & \multicolumn{4}{l}{}\\
   &   \bfseries Name              & \bfseries Datatype & \bfseries Values & \bfseries Default   & \bfseries Description \\
   &   \texttt{name}/\texttt{id}   &  Text              &  \textit{Any}    &  ""                & Name of determinant set \\
   &   \texttt{}                    &  Text              &  \textit{Any}    &  ""                &  \\
  \hline
\end{tabularx}
\end{center}
\end{table}

\subsubsection{Detailed description of attributes:}

In the following, we give a more detailed description of all the options presented in the various xml-blocks described in this section. Only nontrivial attributes are described. Those with simple yes/no options and whose previous description is enough to explain the intended behavior are not included.

\hspace{1mm} \\

\ixml{determinantset} attributes:

\begin{itemize}
\item \ixml{type} \\
Type of \ixml{sposet}. For atom-centered based \ixml{sposets}, use type=``MolecularOrbital" or type=``MO." Other options described elsewhere in this manual are ``spline," ``composite," ``pw," ``heg," ``linearopt," etc.
\item \ixml{keyword}/\ixml{key} \\
Type of basis set generated, which does not necessarily match the type of basis set on the input block. The three possible options are: NMO (numerical molecular orbitals), GTO (Gaussian-type orbitals), and STO (Slater-type orbitals). The default option is NMO. By default, QMCPACK will generate numerical orbitals from both GTO and STO types and use cubic or quintic spline interpolation to evaluate the radial functions. This is typically more efficient than evaluating the radial functions in the native basis (Gaussians or exponents) and allows for arbitrarily large contractions without any additional cost. To force use of the native expansion (not recommended), use GTO or STO for each type of input basis set.
\item \ixml{transform}\\
Request (or avoid) a transformation of the radial functions to NMO type. The default and recommended behavior is to transform to numerical radial functions. If \ixml{transform} is set to \textit{``yes,"} the option \ixml{keyword} is ignored.
\item \ixml{cuspCorrection}\\
Enable (disable) use of the cusp correction algorithm (CASINO REFERENCE) for a \ixml{basisset} built with GTO functions. The algorithm is implemented as described in (CASINO REFERENCE) and works only with transform=``yes" and an input GTO basis set. No further input is needed.
\end{itemize}

\ixml{atomicBasisSet} attributes:

\begin{itemize}
\item \ixml{name/id}\\
Name of the basis set. Names should be unique.
\item \ixml{angular}\\
Type of angular functions used in the expansion. In general, two angular basis functions are allowed: ``spherical" (for spherical Ylm functions) and ``Cartesian" (for functions of the type $x^{n}y^{m}z^{l}$).
%\item \ixml{type}\\ Type of input radial functions. Options are: "Numerical" (for radial functions on a numerical radial grid), "Gaussian" (for an expansion in gaussian functions) and ""
\item \ixml{expandYlm}\\
Determines whether each basis group is expanded across the corresponding shell of m values (for spherical type) or consistent powers (for Cartesian functions). Options:
\begin{itemize}
\item ``No": Do not expand angular functions across corresponding angular shell.
\item ``Gaussian": Expand according to Gaussian03 format. This function is compatible only with angular=``spherical." For a given input (l,m), the resulting order of the angular functions becomes (1,-1,0) for l=1 and (0,1,-1,2,-2,...,l,-l) for general l.
\item ``Natural": Expand angular functions according to (-l,-l+1,...,l-1,l).
\item ``Gamess": Expand according to Gamess' format for Cartesian functions. Notice that this option is compatible only with angular=``Cartesian." If angular=``Cartesian" is used, this option is not necessary.
\end{itemize}
\item \ixml{expM}\\
Determines whether the sign of the spherical Ylm function associated with m ($-1^{m}$) is included in the coefficient matrix or not.
\item \ixml{elementType/species}\\
Name of the species where basis functions are centered. Only one \ixml{atomicBasisSet} block is allowed per species. Additional blocks are ignored. The corresponding species must exist in the \ixml{particleset} given as the \ixml{source} option to \ixml{determinantset}. Basis functions for all the atoms of the corresponding species are included in the basis set, based on the order of atoms in the \ixml{particleset}.
\end{itemize}

\ixml{basisGroup} attributes:

\begin{itemize}
\item \ixml{type}\\
  Type of input basis radial function. Note that this refers to the type of radial function in the input xml-block, which might not match the radial function generated internally and used in the calculation (if \ixml{transform} is set to ``yes"). Also note that different \ixml{basisGroup} blocks within a given \ixml{atomicBasisSet} can have different \ixml{types}.
\item \ixml{n/l/m/s}\\
  Quantum numbers of the basis function. Note that if
\ixml{expandYlm} is set to \textit{``yes"} in \ixml{atomicBasisSet}, a
full shell of basis functions with the appropriate values of
\textit{``m"} will be defined for the corresponding value of
\textit{``l."} Otherwise a single basis function will be given for the
specific combination of \textit{``(l,m)."}
\end{itemize}

\ixml{radfunc} attributes for \ixml{type}=\textit{``Gaussian"}:

\begin{itemize}
\item \ixml{TBDoc}\\
\end{itemize}a

\ixml{slaterdeterminant} attributes:

\begin{itemize}
\item \ixml{TBDoc}\\
\end{itemize}


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

\section{Effect of electron emission}
  \label{sec-see}

  In \Cref{sec-canonical}, the walls are not emissive.
  However, the dielectric ceramic used in \ac{HET} can emit electrons \citep{villemant2018,barral2003a}.
  The electron emission model used, introduced in \cref{sec-modelused}, has three parameters $\proba_0, \crover, \probamax$, such that the emission probability depends on the kinetic energy of the incident electron $\ek$ as
  \begin{equation} \label{eq-barral_second}
    \proba = \min \lp \proba_0 + (1 -  \proba_0) \frac{\ek}{\crover}, \probamax    \rp.
  \end{equation}

  The value of parameters are summarized in \cref{tab-tabe_parameters_see}.
  The crossover energy $\crover$ is varied from as low as 4~V, corresponding to a very emissive material, to as high as 200~V, a weakly emissive material.

  \begin{table}[hbt]
  \ra{1.3}
    \centering
    \caption{Parameters of the electron emission probability model}
    \label{tab-tabe_parameters_see}
    \begin{tabular}{@{}ll@{}} \toprule
    Parameter & value  \\ \midrule
    $\proba_0$ & 0.5  \\
    $\probamax$ & 2.9 \\
    $\crover$   &  4  -- 200 V\\
    \bottomrule
    \end{tabular}
  \end{table}

  \begin{figure}[hbt]
    \centering
    \includegraphics[width=\defaultwidth]{SEE_models}
    \caption{Energy dependence of the electron emission model of \cref{eq-barral_second} superimposed to a Maxwellian energy distribution function of temperature of 45~V, with $\crover=35.04$~V.}
    \label{fig-see_illustration}
  \end{figure}

  \Cref{fig-see_illustration} shows the electron emission probability for $\crover=35.04$~V (corresponding to \ac{BN}) superimposed to a Maxwellian \ac{EEDF} of temperature $\Te=45$~V (typical value obtained in the simulations).
  We can see that the saturation of $\proba$ at $\probamax$ happens only for the very high energy tail.
  In the simulation, we can evaluate the average electron emission yield, also named emission rate, defined as\string:
  \begin{equation} \label{eq-seeyield}
    \rate = \frac{\Gamma_{\rm emitted}}{\Gamma_{\rm incident}} = \frac{\iiint v_r \proba(\vect{v}) f(\vect{v}) d^3v}{\iiint v_r  f(\vect{v}) d^3v}.
  \end{equation}
  In general, \cref{eq-seeyield} cannot be calculated analytically.
  However, if we assume that the \ac{EEDF} is Maxwellian and we neglect the saturation at $\probamax$, \cref{eq-seeyield} can be integrated to give
  \begin{equation} \label{eq-seemaxw}
    \ratemaxw(\Te) = \proba_0 + (1 - \proba_0) \frac{2 \Te}{\crover}.
  \end{equation}
  The saturation at $\probamax$ can be neglected as we have seen that it only affects a small part of the electron population, see \cref{fig-see_illustration}.
  The exact calculation and the relative error is given in \cref{an-SEE_exact}.

  \subsection{Impact of the electron emission on the mobility} \label{subsec-param-mob}

  The effects of the electron emission at the wall on the electron axial mobility are presented in \Cref{fig-mob-epsstar}.
  The measured mobility $\mobpic$ is shown, as well as the effective mobility $\mobeff$, the saturation estimate $\mobeffsat$ and the classical mobility $\mobcla$, defined in \cref{sec-transport} respectively by \cref{eq-mudef}, \cref{eq-defmobeff}, \cref{eq-mobeffsat} and \cref{eq-mobclas}.
  The values are averaged in time between $t=5 \mus$ and $t=10\mus$, and in space over the azimuthal and radial directions.
  For the canonical case, without electron emission, the values are presented in \cref{tab-canonical_mobility}.
  \begin{figure}[hbt]
    \centering
    \includegraphics[width=\defaultwidth]{parametric_mobs_eps_complete.pdf}
    \caption{Evolution of the electron mobility as a function of the crossover energy $\crover$. In blue $\mobpic$ is the mobility measured in the simulations, while $\mobcla, \mobeff$ and $\mobeffsat$ in purple, red and green respectively are calculated with \cref{eq-mudef,eq-mobclas,eq-defmobeff,eq-mobeffsat}. The three regimes {\bf I, II} and {\bf III}, described in \cref{subsec-regimes} are identified.}
    \label{fig-mob-epsstar}
  \end{figure}

  As expected, the classical mobility in  \cref{fig-mob-epsstar} is underestimated by more than one order of magnitude compared to $\mobpic$.
  The effective mobility $\mobeff$ and the effective mobility at saturation $\mobeffsat$  are much closer to $\mobpic$, with an underestimation of roughly 10\% and 30\% respectively.
  The mobility measured in the simulation does not evolve much with the electron emission, even for very high emission rate, i.e very low values of $\crover$.

  On the other hand, $\mobeffsat$ decreases slightly when $\crover$ decreases from around 40V to lower values.
  However, it still provides a reasonable approximation of the electron enhanced mobility, even with high electron emission rate.

  \subsection{Near-wall conductivity}

  The results presented in \cref{subsec-param-mob} are spatially averaged.
  However, the mobility coming from the  instability is expected to be higher where the instability is larger, hence at the center of the channel.
  On the other hand, the mobility due to wall emission is located close to the wall \citep{morozov1972}.

  \Cref{fig-radial-data} presents the radial profiles of the mobility measured in the \ac{PIC}  simulations without electron emission and for three values of $\crover$.
  On the left, the measured mobility $\mobpic$ is shown and on the right it is the effective mobility $\mobeff$ given by \cref{eq-defmobeff}.

  \begin{figure}[hbt]
    \centering
    \includegraphics[width=\textwidth]{both_Mobility_SEE}
    \caption{Radial profile of the electron mobility (left) measured in the \acs{PIC} simulations, and (right) given by \cref{eq-defmobeff}, for different wall emissivities. }
    \label{fig-radial-data}
  \end{figure}

  We can see in \cref{fig-radial-data} that the mobility measured $\mobpic$  in the center decreases by roughly 20\% as the emission rate increases.
  This observation is in agreement with $\mobeffsat$ observed in \cref{fig-radial-data,fig-mob-epsstar}.
  This is due the electron temperature $\Te$ which decreases from around $\Te=45$V at $\crover=200$V to $\Te=30$V at low $\crover$ (the evolution of $\Te$ can be seen in \cref{fig-Tevsproba}).

  On the other hand, the near-wall mobility increases on $\mobpic$ almost by a factor of two between the case withour emission and $\crover=38\,\volt$.
  However, we do not see this evolution on $\mobeffsat$ which was derived from a theory with no \ac{SEE}, meaning that it indeed comes from another physical mechanism than the \ac{ECDI}.

  \subsection{Three different regimes}
  \label{subsec-regimes}

  In \Cref{fig-mob-epsstar}, three regimes have been identified.
  Regime {\bf I} corresponds to low values of $\crover$ (lower than 38V), during which $\mobeffsat$ increases with $\crover$ but $\mobpic$ and $\mobeff$ decreases.
  Regime {\bf III} corresponds to high values of $\crover$ (higher than 50V), during which $\mobeffsat$, and  $\mobpic$ are roughly constants, but $\mobeff$ increases slightly.
  Regime {\bf II} is a short transition regime, for $38 < \crover < 50$V.

  The different regimes appear clearly on the temporal evolution of the different variables.
  \Cref{fig-threeregimes}  presents the temporal evolution of the space average $\ratepic$ for three different
  values of $\crover$ , corresponding to the three different regimes we have identified.
  In regimes {\bf I} and {\bf III}, $\ratepic$ reaches a quasi steady-state after a few microseconds.

  \begin{figure}[hbt]
    \centering
    \includegraphics[width=\defaultwidth]{comparaison_3_regimes}
    \caption{Evolution as a function of time of the averaged electron emission rate $\ratepic$ in the three regimes observed (two stable ones, one with oscillations). The light green zones correspond to the periods when $\ratepic > \ratecr$}
    \label{fig-threeregimes}
  \end{figure}

  Regime {\bf I}, with low $\crover$, is characterized by a saturation of $\ratepic$ at a value between $\ratecr$ and 1, which leads to a non-monotonic potential profile.
  Regime {\bf III}, for higher $\crover$, is characterized by a quasi steady-state with a SEE rate lower than $\ratecr$.

  The transition between these two stable regimes (monotonic and non-monotonic sheath) passes by regime {\bf II}, an oscillating mode between the two stable regimes.
 As shown in \cref{fig-mob-epsstar}, regime {\bf II} is observed only in a narrow range of $\crover$.
 The oscillations of regime {\bf II} are shown in \cref{fig-threeregimes} up to $10\mus$ but have been observed for more than $40\mus$.
 Note that regimes {\bf I} and {\bf III} in \cref{fig-threeregimes} are obtained for $\crover = 38$~V and $\crover = 50$~V respectively, i.e. near the boundary of the unstable window (see \cref{fig-mob-epsstar}).
 Consequently, we observe a few oscillations before the quasi steady-state is reached, as these cases are close to the bifurcation.

   The physical origin of the bifurcation can be seen with the help of \cref{fig-dphivsTe}, which shows the evolution of the potential drop to the wall as a function of the electron temperature.
   It is computed using \cref{eq-seemaxw} for $\rate$ and \cref{eq-sheathhobbs} for the potential drop, which is summarized as
   \begin{equation} \label{eq-dphi_vs_Te_Maxw}
     \begin{cases}
       \rate = \ratemaxw = \proba_0 + (1- \proba_0) \frac{2 \Te}{\crover} \\
       \dphi = \Te \ln \lp [1 - \rate] \sqrt{ \frac{m_i}{2 \pi m_e}}  \rp
     \end{cases}
   \end{equation}

   \begin{figure}[hbt]
     \centering
     \includegraphics[width=\defaultwidth]{RSO_theo_sheath_bis}
     \caption{Plasma potential drop to the wall as a function of the electron temperature for different values of the cross-over energy $\crover$ using \cref{eq-dphi_vs_Te_Maxw}. The dashed line is $\dphi=\Te$. }
     \label{fig-dphivsTe}
   \end{figure}

   \Cref{fig-dphivsTe} shows the evolution of $\dphi$ as a function of $\Te$ obtained with \cref{eq-dphi_vs_Te_Maxw} using four different values of $\crover$.
   We can see that, starting from low electron temperature, the potential drop increases with the electron temperature, resulting in a better screening of the electrons.
   This corresponds to regime {\bf III}.
   However, the $\dphi$ reaches a maximum, after which it drops sharply to zero and below.

   When the potential passes the maximum and decreases, the electrons are less screened by the sheath.
   Hence, the electrons reach the wall with a higher energy, resulting in a higher electron emission from the wall, hence a smaller potential drop.
   The sheath is unstable, and quickly attains a \ac{SCL} regime \citep{raitses2005}.
   In this regime, the sheath is not monotonic, and the model of \cref{eq-sheathhobbs} is no more valid, and the potential drop tends toward $\dphi \simeq \Te$ \citep{hobbs1967,goebel2008} \footnote{see \cref{sec-sheath} for more details}, shown with the blue dotted line in \cref{fig-dphivsTe}.
   This corresponds to regime {\bf I}.

   However, during regime {\bf I}, the electron power loss to the wall is very high, and can exceed the gain.
   Hence, the electron temperature decreases.
   If $\Te$ decreases too much, the sheath can come back to the previous regime {\bf III}.
   The oscillations between regimes {\bf I} and {\bf III} define regimes {\bf II}.

   We can try to predict the threshold value of $\crover$ between regimes {\bf III} and {\bf II}.
   We have seen in \cref{fig-canon_Te_all} that without electron emission, $\Te$ is of the order of $45\,\volt$.
   Using the different curves in \cref{fig-dphivsTe}, we can expect to observe the transition between regime {\bf III} and {\bf II} for $\crover > 60$~V, as we have for $\crover = 60$~V the maximum of $\dphi$ is at $\Te\sim 25$~V, which is significantly lower than 45~V.
   However, we see in \cref{fig-threeregimes} that the transition appears at $\crover=50$~V.

   The reason for the discrepancy between the expected and the observed threshold values of $\crover$ could be that when $\rate$ increases, the electron power losses increase, and hence cause the electron temperature at equilibrium to decrease.
   The evolution of the temperature with  $\rate$ is shown later in \cref{fig-Tevsproba}.
   We can see that even for very large \ac{SEE} rates, the electron temperature only decreases down to $\Te=30\,\volt$.
   However, the curves of \cref{fig-dphivsTe} still predict for $\Te=30\,\volt$ a threshold value at $\crover=60\,\volt$.
   Consequently, even if $\Te$ does indeed decrease when increasing $\crover$, it remains too large to explain the discrepancy between the observed transition between regime {\bf III} and {\bf II} in \cref{fig-threeregimes} and the curves in \cref{fig-dphivsTe}.

   Hence, the cause of the difference in the threshold value for regime {\bf II} will be discussed again in \cref{ch-4}, using a modified plasma-wall interaction model.


\documentclass[12pt,oneside]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[T1]{fontenc}
\usepackage[a4paper, left=4cm, right=2cm, top=3cm, bottom=2.1cm]{geometry}
\usepackage{amssymb}
\usepackage{mathptmx}
\usepackage{amsmath}
\usepackage[scaled=.90]{helvet}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{siunitx}
\AtBeginDocument{\sisetup{
  detect-all, % auto config
  math-sf=\mathrm, % serif in equations
  text-rm=\sffamily, % sans serif in text
  locale = DE, % 1,000.99 -> 1.000,99
  per-mode = symbol, % ms^-1 -> m/s
}}

\begin{document}

\section{Inline}

Show different representations of the number \enquote{123.45}. Sans serif font is used in text and serif inside math environments.

\bigskip

Num: \num{123.45}

Math: $123.45$

\section{Align}

\begin{align}
no formatting &= 123.45 \\
num &= \num{123.45}
\end{align}

\section{Equation}

\begin{equation}
\begin{split}
no formatting = 123.45 \\
num = \num{123.45}
\end{split}
\end{equation}

\section{Multiline}

\begin{multline}
no formatting = 123.45 \\
num = \num{123.45}
\end{multline}

\end{document}


\chapter{Growth Curve}

\textbf{NOTE}: This part is heavily based on \texttt{StetsonPB 1990 PASP 102 932}.

Selecting an appropriate aperture radius for circular PSF photometry is not an easy task. Since 1960s, it has been extensively studied including Moffat, and it was blooming in 1990s thanks to many pioneers who tried to combine the analytical description of stellar profile and empirical counterparts. Here I will summarize the most powerful technique called the \textbf{growth curve (GC) analysis}, which maybe out of scope for undergraduate courses, but conceptually easy.

\section{Introduction}
In photometry, we need to set the aperture as large as possible if we want to collect all the flux from the star. But wait, how large is large? It should be ``sufficiently large that seeing, tracking, and focus errors do not affect the fraction of the star's flux which falls \textit{outside} the aperture. $ \cdots $ The computer-defined ``aperture'' within which the pixel values are summed in the two-dimensional data array is a direct analog to the physical aperture placed at the telescope focus in a standard photometer.'' (from Stetson 1990).

Ststson further describes ``$ \cdots $ to measure as many stars as possible through a series of \textit{several} concentric apertures of increasing radius and to calculate the observed magnitude differences between successive apertures for each star. These are plotted as a function of radius, and a smooth curve is sketched through them to yield the average ``growth curve'' of the frame. The average magnitude differences between successive apertures are then read from this curve and summed from the outside inward to yield cumulative corrections from each of the smaller apertures to the system of the largest. This multiple-aperture technique offers several advantages over the simpler two-aperture method.'' (Stetson 1990) The earliest description about the growth curve analysis is, Stetson notes, \texttt{Rich+ 1984, ApJ, 286, 517}.

In short, what we do in GC analysis is like this. First, assume the PSF is circular. If $ i $ is the frame number ($ i $-th CCD frame) and $ j $ is the star id ($ j $-th star):
\begin{enumerate}
\item Find the center of the star and fix it ($ \vb{r}_{0, i, j} $)
\item Set the sky annulus for the frame (say inner/outer radii $ r_{\mathrm{in}, i} $ and $ r_{\mathrm{out}, i} $, respectively, and you may fix it identical for all stars if you want).
\item Do aperture photometry for many $ r_k $, e.g., $ r_k = 1, 2, \cdots, r_\mathrm{in} $ pixels.
\item Plot the sky-subtracted delta-magnitude $ \delta_{i, j, k} = m_{i, j}(r_k) - m_{i, j}(r_{k-1}) $ as a function of $ (r_k + r_{k-1})/2 $ for many bright stars.
\item Find a smooth function which describes this curve (discussed below).
\item Find, e.g., $ \Delta $ value such that $ \mathrm{True~mag} = m(r = \infty) = m(r = r_k) - \Delta(r_k) $.
\item Do photometry for $ j $-th star with $ r_{k'} $ (where the SNR gets maximum), and get the true magnitude by $ \Delta(r_{k'}) $.
\end{enumerate}

\section{Stellar Profile}
We have discussed the stellar profiles like Gaussian and Moffat. Stetson 1990 describes a more general stellar profile\footnote{The original notation was $ I(r, X_i; R_i, A, B, C, D, E) = (B + E X_i) M(r; A) + (1 - B - EX_i) [ C G(r; R_i) + (1 - C) H(r; DR_i) ] $, i.e., $ R_i = \sigma_i $, $ A = \beta $, $ B = a $, $ C = c $, $ D = s $, $ E = b $. I made a more generalization by adding the core width $ R $, which was set to 1 in Stetson's paper.}:
\begin{equation*}
  I(r, X_i | R_i)
    = [a + b X_i] M(r | R, \beta)
      + [1 - (a + b X_i)] \left \{ c G(r | \sigma_i) + [1 - c] H(r | s\sigma_i) \right \} ~.
\end{equation*}
Here, using the notations in \cref{eq: profile gauss flux,eq: profile moffat flux},
\begin{equation*}
\begin{aligned}
  M(r | R, \beta)
    &= f_\mathrm{Moffat}(r | I = 1, R, \beta)
    &&= \frac{\beta - 1}{\pi R^2} \left [ 1 + \left (\frac{r}{R} \right )^2 \right ]^{-A} ~, \\
  G(r | \sigma_i)
    &= f_\mathrm{Gauss}(r | I = 1, \sigma_i)
    &&= \frac{1}{2\pi \sigma_i^2} e^{-r^2/2\sigma_i^2} ~, \\
  H(r | r_0)
    &= \frac{1}{2\pi r_0^2} e^{-r/r_0} ~. &&
\end{aligned}
\end{equation*}
Actually there is no reason to introduce $ s \sigma_i $ instead of a totally new parameter, say $ \tilde{s} $, but Stetson used $ s\sigma_i $. These functions have simple integral form:
\begin{equation}\label{eq: growth_curve_integral}
\begin{aligned}
  M_I(r_k | R, \beta)
    &= \int_{0}^{r_k} M(r | I = 1, R, \beta) (2 \pi r) dr
    &&= 1 - \frac{1}{ \left (1 + (r_k/R)^2 \right )^{\beta - 1}} ~, \\
  G_I(r_k | \sigma)
    &= \int_{0}^{r_k} G(r| I = 1, \sigma_i) (2 \pi r) dr
    &&= 1 - e^{-r_k^2/2\sigma_i^2} ~, \\
  H_I(r_k | r_0)
    &= \int_{0}^{r_k} H(r | I = 1, r_0) (2 \pi r) dr
    &&= 1 - \left [ 1 + \frac{r_k}{r_0} \right ] e^{-r_k/r_0} ~, \\
\end{aligned}
\end{equation}
and all have integral of unity if $ r_k \rightarrow \infty $ (As noted with \cref{eq: profile moffat flux}, $ A > 1 $ is required). The GC is basically an azimuthally averaged profile, so the integrated version of $ I $ is required:
\begin{equation}\label{eq: daogrowth_profile}
  I_I(r, X_i)
    = [a + b X_i] M_I(r | R, \beta)
      + [1 - (a + bX_i)] \left \{ c G_I(r | \sigma_i) + [1 - c] H_I(r | s\sigma_i) \right \} ~.
\end{equation}