\chapter{Introduction}\label{chap-1}

High-intensity particle accelerators are important to many areas of scientific research; for example, they serve as drivers for bright secondary beam production (neutrons, neutrinos, muons, etc.) \cite{Geer2009} and could be used for nuclear waste processing \cite{Yee-Rendon2021}. In particular, spallation neutron sources have become vital to material science \cite{Garoby2017}.

The maximum beam intensity in these machines is often limited by nonlinear space charge forces — forces between the charged particles in the beam \cite{Hofmann2017Book}. Such forces lead to beam loss that is difficult to predict and minimize. If the uncontrolled beam loss is significant, it can lead to radio-activation of the accelerator components, making hands-on maintenance unsafe \cite{Bungau2014}; thus, reducing uncontrolled losses is of primary concern. The present standard design criterion is to keep losses below one watt per meter; for beam pulses in current spallation neutron sources, which contain more than $10^{14}$ particles per pulse at a beam power above 1 megawatt, this corresponds to a fractional loss of $\approx 10^{-6}$ \cite{Henderson2014}. The prediction and mitigation of space charge effects will become even more important in the design of future ten-megawatt accelerators \cite{Wei2014}.

One method to produce a high-intensity hadron beam is to repeatedly inject particles from a linear accelerator (linac) into a circular accelerator (ring), accumulating charge in the ring over many turns. Rings are designed to produce stable motion, but the combination of the periodic electromagnetic fields of the accelerator \textit{and beam} may produce unstable motion. Additionally, if the beam's electric field has a strong nonlinear dependence on the particle coordinates, the number of stable machine configurations decreases. This places an upper limit on the beam intensity. Thus, it is desirable to produce a beam in which the electric field has a linear dependence on the particle coordinates; for example, a uniform density ellipsoid.

Uniform density beams producing linear space charge forces are frequently used in analytical and computational studies of high-intensity beam dynamics \cite{Lund2004}. These studies are possible because of the existence of special distributions of particles in position-momentum space (phase space) that maintain linear space charge forces as they are transported through arbitrary linear focusing fields. We refer to these distributions as \textit{self-consistent}.

It is, however, difficult to produce such a distribution: real beam transport involves nonlinear external fields, for which no known self-consistent distributions exist, and control of the phase space distribution at early stages of acceleration is limited. Nonetheless, several recently derived self-consistent distributions are possible to produce in a circular accelerator in the linear approximation \cite{Danilov2003}. Furthermore, simulations predict that one of these distributions — the Danilov distribution — could be approximately produced in a real machine \cite{Holmes2018}. This dissertation contributes to efforts to test this prediction in the Spallation Neutron Source (SNS).

The structure of this introductory chapter is as follows: the relevant theory of beam dynamics is reviewed in Section \ref{sec:High-intensity beam dynamics}; the definition and properties of self-consistent distributions are discussed in Section \ref{sec:Self-consistent phase space distributions}; a method to generate an approximate Danilov distribution in a ring, as well as the implementation of the method in the SNS, is presented in Section \ref{sec:Producing a self-consistent distribution}; the structure and goals of this dissertation are laid out in Section \ref{sec:Goals of this dissertation}.

\section{Beam dynamics}\label{sec:High-intensity beam dynamics}

\subsection{Single-particle motion}

We begin by describing the motion of a single particle in a ring. We assume the existence of a closed orbit and use coordinates in which $s$ is the location along the orbit and $x$ and $y$ are the horizontal and vertical transverse displacements. We then study oscillations in the transverse plane with the assumption of constant longitudinal velocity $\beta_s c$, where $c$ is the speed of light.

Magnetic fields are preferred for transverse steering and focusing when the kinetic energy is significant. The magnetic field $\mathbf{B} = (B_x, B_y)$ in a vacuum may be written as an infinite sum:
%
\begin{equation}\label{eq:magnetic_field_expansion}
    B_x - iB_y = \sum_{n = 1}^{\infty}{(b_n - i a_n) \left({\frac{x + i y}{r_0}}\right)^{n - 1}},
\end{equation}
%
where $r_0$ is a constant, $i = \sqrt{-1}$, $\left\{ b_n \right\}$ are the multipole coefficients, and $\left\{ a_n \right\}$ are the skew multipole coefficients. The $b_n$ term in the expansion is produced by $2n$ symmetrically arranged magnetic poles; the skew terms are obtained by a $\pi / 2n$ rotation. Assuming the transverse velocities are much smaller than $\beta_s c$, the equations of motion for $x$ and $y$ are
%
\begin{equation}\label{eq:transverse_eom}
\begin{aligned}
    x'' &= -\frac{q}{m c \beta_s \gamma_s} B_y, \\
    y'' &= +\frac{q}{m c \beta_s \gamma_s} B_x,
\end{aligned}
\end{equation}
%
where $q$ is the particle charge, $m$ is the particle mass, $\gamma_s = (1 - \beta_s^2)^{-1/2}$, and the prime represents differentiation with respect to $s$.\footnote{Since the small-angle approximation is used, $x'$ is usually reported in radians.} A curved coordinate system modifies the horizontal equation of motion, but we have assumed a straight coordinate system here for simplicity.

\subsubsection{Linear dynamics}

 Accelerators employ dipole fields ($b_1$) for bending and quadrupole fields ($b_2$) for focusing. Keeping only these terms, Eq.~\eqref{eq:transverse_eom} becomes
%
 \begin{equation}\label{eq:Hill}
     x'' + k(s)x = 0.
 \end{equation}
%
Eq.~\eqref{eq:Hill} is of general interest \cite{Hill1886, Qin2007}. It describes a one-dimensional (1D) parametric oscillator — an oscillator whose physical properties change with time. Its solution in the Courant-Snyder theory \cite{Courant1958} is
%
\begin{equation}\label{eq:Hill_solution}
    x(s) = \sqrt{2 J \beta(s)} \cos{\left({\mu(s) + \delta}\right)},
\end{equation}
%
with $J$ constant, $\delta$ constant, and the phase advance $\mu(s)$ given by
%
\begin{equation}
    \mu(s) = \int_{0}^{s}{\frac{ds'}{\beta(s')}}.
\end{equation}
%
$\beta(s)$ is referred to as the ``beta function". In a ring of length $C$, $k(s) = k(s + C)$ and there is a unique periodic solution with $\beta(s) = \beta(s + C)$; otherwise, $\beta(s)$ depends on the initial conditions.

It is helpful to view the motion in phase space ($x$-$x'$) at a fixed location in the ring on a turn-by-turn basis as in Fig.~\ref{fig:cs_ellipse_a}.
%
\begin{figure}[!p]
    \centering
    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/cs_ellipse.png}
        \caption{}
        \label{fig:cs_ellipse_a}
    \end{subfigure}
    \vfill
    \vspace*{1.5cm}
    \vfill
    \begin{subfigure}{\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/norm_coords.png}
        \caption{}
        \label{fig:cs_ellipse_b}
    \end{subfigure}
    \caption{(a) Turn-by-turn motion of a single particle along the Courant-Snyder ellipse in horizontal phase space. (b) Alternative view of the motion using the factored transfer matrix.}
    \label{fig:cs_ellipse}
\end{figure}
%
The particle jumps around an ellipse. The so-called Twiss parameters $\beta$, $\alpha = -\beta' / 2$, and $\gamma = (1 + \alpha^2) / \beta$ determine the ellipse dimensions. $J$, which is proportional to the area of the ellipse, is called the Courant-Snyder invariant:
%
\begin{equation}\label{eq:CS invariant}
    J = \frac{x^2 + (\alpha x + \beta x')^2}{\beta}.
\end{equation}
%
We define the tune $\nu$ as the number of phase space oscillations per turn; i.e.,
%
\begin{equation}
    \nu = \frac{1}{2\pi}\oint{\frac{ds}{\beta(s)}},
\end{equation}
%
where the integral is around the entire ring.

Thus, motion between two locations in the ring is equivalent to an area-preserving linear transformation of a phase space ellipse, plus rotation of the particle around the ellipse. This is more clear in the transfer matrix formulation of the dynamics, writing $\mathbf{x}(s) = \mathbf{M}(s)\mathbf{x}(0)$ where
%
\begin{equation} \label{eq:CS_parameterization}
\begin{aligned}
    \mathbf{M}(s) &=
    \begin{bmatrix}
        \sqrt{\beta(s)} & 0 \\
        -\frac{\alpha(s)}{\sqrt{\beta(s)}} & \sqrt{\frac{1}{\beta(s)}}
    \end{bmatrix}
    \begin{bmatrix}
        \cos\mu(s) & \sin\mu(s)
        \\ -\sin\mu(s) & \cos\mu(s)
    \end{bmatrix}
    \begin{bmatrix}
        \sqrt{\frac{1}{\beta(0)}} & 0 \\
        \frac{\alpha(0)}{\sqrt{\beta(0)}} & \sqrt{\beta(0)}
    \end{bmatrix} \\
    &= \mathbf{V}(s) \, \mathbf{P}(s) \, \mathbf{V}(0)^{-1}
\end{aligned}
\end{equation}
%
and $\mathbf{x} = (x, x')^T$. As illustrated in Fig.~\ref{fig:cs_ellipse_b}, $\mathbf{V(0)}^{-1}$ transforms the phase space ellipse into a circle while preserving its area, $\mathbf{P(s)}$ rotates the coordinates around the circle according to the phase advance, and $\mathbf{V(s)}$ transforms the circle back into an ellipse \cite{Lee2011}. Eq.~\eqref{eq:CS_parameterization} motivates the definition of normalized phase space coordinates $\mathbf{x}_n(s) = \mathbf{V}(s)^{-1} \mathbf{x}(s)$ in which the particle performs simple harmonic oscillations, i.e., rotates in a circle of area $J$ at frequency $2\pi\nu$.

\subsubsection{Linear (coupled) dynamics}

In the presence of linear coupling, the equations of motion take the following form:
%
\begin{equation}\label{eq:single_particle_eom_coupled}
    \mathbf{x}'' + \mathbf{K_0}(s) \mathbf{x} + \mathbf{K_1}(s) \mathbf{x}' = 0,
\end{equation}
%
where $\mathbf{x} = (x, y)^T$ and $\mathbf{K}_{0, 1}$ are $2 \times 2$ matrices.\footnote{I will occasionally switch between $\mathbf{x} = (x, x', y, y')^T$ and $\mathbf{x} = (x, y)^T$. The correct definition should be clear from context.} The particle now moves on an ellipsoid in 4D phase space ($x$-$x'$-$y$-$y'$), the volume of which is conserved. For example, Fig.~\ref{fig:skew_quad_single_particle_tbt} shows the turn-by-turn trajectory of a single particle in the presence of linear coupling from a rotated (skew) quadrupole.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=0.85\textwidth]{Images/chapter1/skew_quad_single_particle_tbt.png}
    \caption{Turn-by-turn trajectory of a particle in a linear focusing system with the addition of a skew quadrupole.}
    \label{fig:skew_quad_single_particle_tbt}
\end{figure}
%
The motion is most simply described using transfer matrices. Consider the eigenvectors and eigenvalues of the $4 \times 4$ symplectic one-turn transfer matrix $\mathbf{M}$. There are four eigenvectors — $\mathbf{v}_1$, $\mathbf{v}_2$, $\mathbf{v}_1^*$, $\mathbf{v}_2^*$ — and four eigenvalues — $\lambda_1$, $\lambda_2$, $\lambda_1^*$, $\lambda_2^*$ — with $\lambda_i\lambda_j^* = 1$ (* denotes the complex conjugate). The eigenvalue equation is written
%
\begin{equation} \label{eq:transfer_matrix_eig}
    \mathbf{M} \mathbf{v}_l = e^{-i\mu_l} \mathbf{v}_l,
\end{equation}
%
with $l = 1,2$. The phase space coordinate vector $\mathbf{x} = (x, x', y, y')^T$ at one position in the ring is a linear combination of the eigenvectors:
%
\begin{equation}
    \mathbf{x} = Re \left\{
        \sqrt{2 J_1} \, \mathbf{v}_1 \, e^{-i\psi_1}
        + \sqrt{2 J_2} \, \mathbf{v}_2 \, e^{-i\psi_2}
    \right\},
\end{equation}
%
where $J_{1,2}$ are constant amplitudes, $\psi_{1,2}$ are initial phases, and $Re\{z\}$ selects the real component of $z$. Application of the transfer matrix advances the phases:
%
\begin{equation}\label{eq:eigvec_coords}
    \mathbf{Mx} = Re \left\{
        \sqrt{2 J_1} \, \mathbf{v}_1 \, e^{-i(\psi_1 + \mu_1)}
        + \sqrt{2 J_2} \, \mathbf{v}_2 \, e^{-i(\psi_2 + \mu_2)}
    \right\}.
\end{equation}
%
The old invariants $J_{x,y}$ are replaced by $J_{1,2}$ and the phase advances $\mu_{x,y}$ are replaced by $\mu_{1,2}$. A new normalized phase space is defined by rewriting Eq.~\eqref{eq:eigvec_coords} as $\mathbf{x}_n = \mathbf{V}^{-1} \mathbf{x}$ with
%
\begin{equation}\label{eq:V_from_eigvecs}
    \mathbf{V} =
    \begin{bmatrix}
        Re\{\mathbf{v}_1\}, & -Im\{\mathbf{v}_1\}, & Re\{\mathbf{v}_2\}, & -Im\{\mathbf{v}_2\}
    \end{bmatrix}.
\end{equation}
%
Particles perform simple harmonic oscillations in normalized phase space, moving in circles of area $J_1$ in the $x_n$-$x_n'$ plane and $J_2$ in the $y_n$-$y_n'$ plane.

We would like to parameterize the eigenvectors as in the uncoupled case. There are currently several parameterizations in existence \cite{Edwards1973, Ripken1989, Wolski2006, Lebedev2010, Qin2009}; we will use the parameterization of Lebedev and Bogacz \cite{Lebedev2010}:
%
\begingroup
\renewcommand*{\arraystretch}{1.5}
\begin{equation}
\begin{aligned}
    \mathbf{v}_1 =
    \begin{bmatrix}
        \sqrt{\beta_{1x}} \\
        -\frac{\alpha_{1x} + i(1-u)}{\sqrt{\beta_{1x}}} \\
        \sqrt{\beta_{1y}}e^{i\nu_1} \\
        -\frac{\alpha_{1y} + iu}{\sqrt{\beta_{1y}}} e^{i\nu_1} \\
    \end{bmatrix} ,\quad
    \mathbf{v}_2 =
    \begin{bmatrix}
        \sqrt{\beta_{2x}}e^{i\nu_2} \\
        -\frac{\alpha_{2x} + iu}{\sqrt{\beta_{2x}}}e^{i\nu_2} \\
        \sqrt{\beta_{2y}} \\
        -\frac{\alpha_{2y} + i(1-u)}{\sqrt{\beta_{2y}}} \\
    \end{bmatrix}.
\end{aligned}
\end{equation}
\endgroup
%
The meaning of the new parameters is illustrated in Fig.~\ref{fig:twiss4D}.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=\textwidth]{Images/chapter1/twiss4D.png}
    \vspace*{0.1cm}
    \caption{Lebedev-Bogacz parameterization of coupled motion. The grey markers are the turn-by-turn trajectory of a single particle. The red and blue lines are the ellipses traced by the transfer matrix eigenvectors.}
    \label{fig:twiss4D}
\end{figure}
%
The motion is the sum of two eigenvectors, each of which traces an ellipse when projected onto any 2D subspace. The horizontal and vertical amplitudes $J_x$ and $J_y$ are exchanged because the eigenvectors rotate at different frequencies. The parameterization assigns a $\beta$ and $\alpha$ parameter to each ellipse. The parameters $\nu_1$ and $\nu_2$ are the phase differences between the horizontal ($x$-$x'$) and vertical ($y$-$y'$) parts of the eigenvectors, which determines the tilt angle of the ellipses traced in the cross-plane projections ($x$-$y$, $x$-$y'$, $y$-$x'$, $x'$-$y'$). Finally, $u$ determines the area of the ellipse traced by the eigenvectors in horizontal phase space relative to the ellipse in vertical phase space.

\subsubsection{Nonlinear resonances}

Nonlinear terms in Eq.~\eqref{eq:magnetic_field_expansion} are generally small but nonzero in reality. Furthermore, they are periodic since they occur once per turn. As detailed in Appendix \ref{app-A}, perturbation analysis shows that these terms may drive a resonance when
%
\begin{equation}\label{eq:resonance_lines}
    M_x \nu_x + M_y \nu_y = N,
\end{equation}
%
where $\nu_{x, y}$ are the single-particle tunes, $M_x$, $M_y$, and $N$ are integers, and $|M_x| + |M_y|$ is the order of the resonance. The single-particle tunes must be precisely controlled to avoid these resonance lines; otherwise, particles may be driven to large amplitudes and eventually fall outside the machine aperture. The strength of the resonance varies inversely with the order: fourth-order and below are the primary concern in most machines, but higher-order effects may be important when the number of stored turns is large.

\subsection{Collective beam description}

A beam is a distribution of particles in phase space. In the limit of many particles, we define a distribution function $f(\mathbf{x})$ such that $f(\mathbf{x}) d\mathbf{x}$ is the number of particles in an infinitesimal volume of phase space $d\mathbf{x}$. It is often sufficient to characterize a distribution by its covariance matrix {$\bm{\Sigma} = \langle{\mathbf{x}\mathbf{x}^T}\rangle$}, where $\langle{\dots}\rangle$ represents the expected value. In the transverse plane:
%
\begin{equation}\label{eq:covariance_matrix}
\begin{aligned}
    \bm{\Sigma} &=
    \begin{bmatrix}
        \langle{xx}\rangle & \langle{xx'}\rangle & \langle{xy}\rangle & \langle{xy'}\rangle \\
        \langle{xx'}\rangle & \langle{x'x'}\rangle & \langle{x'y}\rangle & \langle{x'y'}\rangle \\
        \langle{xy}\rangle & \langle{x'y}\rangle & \langle{yy}\rangle & \langle{yy'}\rangle \\
        \langle{xy'}\rangle & \langle{x'y'}\rangle & \langle{yy'}\rangle & \langle{y'y'}\rangle
    \end{bmatrix}
    &=
    \begin{bmatrix}
        \bm{\sigma}_{xx} & \bm{\sigma}_{xy} \\
        \bm{\sigma}^T_{xy} & \bm{\sigma}_{yy}
    \end{bmatrix}.
\end{aligned}
\end{equation}
%
If a symplectic linear transformation $\mathbf{x} \rightarrow \mathbf{M}\mathbf{x}$ is applied to the coordinates, the covariance matrix transforms as
%
\begin{equation}\label{covariance_matrix_transport}
    \bm{\Sigma}
    \rightarrow
    \mathbf{M} \, \bm{\Sigma} \, \mathbf{M}^T.
\end{equation}
%
There are several invariant quantities under such a transformation. The first is the 4D emittance $\varepsilon_{4D}$, which is proportional to the volume of the ellipsoid defined by the covariance matrix:
%
\begin{equation}
    \varepsilon_{4D} = \left|{\bm{\Sigma}}\right|^{1/2} = \varepsilon_1\varepsilon_2 \le \varepsilon_x\varepsilon_y,
\end{equation}
%
where $|...|$ is the determinant. The \textit{intrinsic} emittances $\varepsilon_{1,2}$ are individually conserved; they are found by a symplectic diagonalization of $\bm{\Sigma}$; i.e., they are the imaginary components of the eigenvalues of $\bm{\Sigma}\mathbf{U}$, where $\mathbf{U}$ is the unit symplectic matrix:
%
\begin{equation}
    \mathbf{U} =
    \begin{bmatrix}
        0 & 1 & 0 & 0 \\
        -1 & 0 & 0 & 0 \\
        0 & 0 & 0 & 1 \\
        0 & 0 & -1 & 0
    \end{bmatrix}.
\end{equation}
%
Equivalently \cite{Xiao2013},
%
\begin{equation}
    \varepsilon_{1, 2} = \frac{1}{2}\sqrt{
      -tr\left[(\bm{\Sigma} \mathbf{U})^2\right] \pm \sqrt{tr^2\left[(\bm{\Sigma} \mathbf{U})^2\right] - 16|{\bm{\Sigma}}|}.
    }
\end{equation}
%
In the absence of cross-plane correlations ($\bm{\sigma}_{xy} = 0$), the intrinsic emittances are equal to the \textit{apparent} emittances $\varepsilon_x = \left|{\bm\sigma}_{xx}\right|^{1/2}$ and $\varepsilon_y = \left|{\bm\sigma}_{yy}\right|^{1/2}$ \cite{Buon1993}. The apparent emittances correspond to the areas of the projected ellipses in the $x$-$x'$ and $y$-$y'$ planes and are only conserved if $\mathbf{M}$ is block-diagonal, i.e., if there is no coupling between the horizontal and vertical motion.

It is challenging to generate realistic initial distributions for simulations due to the current lack of high-resolution 6D phase space measurements \cite{Lund2009, Ruisard2020}; however, a simple and often-justified strategy is to assume elliptical symmetry and construct a distribution from the single-particle invariants $J_{x,y}$.\footnote{Alternatively, the generalized invariants $J_{1, 2}$ can be used.} We define the ellipsoid parameter $T = {J_x}/{\varepsilon_x} + {J_y}/{\varepsilon_y}$ and stack ellipsoids to create the distribution, writing $f = f(T)$. One option is a Gaussian distribution: $f \propto \exp(-T/2)$; another is the Waterbag distribution, which is a uniformly filled ellipsoid: $f \propto \Theta(1 - T)$, where $\Theta$ is the Heaviside step function; another is the KV distribution, which is a uniformly populated ellipsoidal shell: $f \propto \delta(1 - T)$. The 1D and 2D projections of these 4D distributions are shown in Fig.~\ref{fig:distributions_gaussian}, Fig.~\ref{fig:distributions_waterbag}, and Fig.~\ref{fig:distributions_kv}.
%
\begin{figure}[!p]
    \begin{subfigure}{0.49\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/Gaussian_dist.png}
        \caption{Gaussian distribution}
        \label{fig:distributions_gaussian}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.49\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/Waterbag_dist.png}
        \caption{Waterbag distribution}
        \label{fig:distributions_waterbag}
    \end{subfigure}
    \vfill
    \begin{subfigure}{0.49\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/KV_dist.png}
        \caption{KV distribution}
        \label{fig:distributions_kv}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.49\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/Danilov_dist.png}
        \caption{Danilov distribution}
        \label{fig:distributions_danilov}
    \end{subfigure}
    \caption{1D and 2D projections of various 4D phase space distributions. The black ellipses are defined by four times the distribution covariance matrix.}
    \label{fig:distributions}
\end{figure}
%
The black ellipses show the projections of the covariance matrix ellipsoid (multiplied by a factor of four).

\subsection{Space charge}\label{sec:Space charge}

Particle motion is also influenced by space charge — the charge density of the beam in free space. The beam's electric field $\mathbf{E} = (E_x, E_y)^T$ modifies the single-particle equation of motion:
%
\begin{equation}\label{eq:eom_with_spacecharge}
    \mathbf{x}'' + \mathbf{K_0}(s) \mathbf{x} + \mathbf{K_1}(s) \mathbf{x}' = \frac{q}{m\gamma_s^3\beta_s^2c^2} \mathbf{E}.
\end{equation}
%
Due to the attractive magnetic force between co-moving charges in the lab frame, the space charge force approaches zero as $\beta_s \rightarrow 1$. We will make the coasting beam approximation — infinite length, uniform density, and constant momentum in the longitudinal plane — to reduce the problem to two dimensions.\footnote{This is generally invalid for linacs but locally valid for a transverse slice of a long distribution in a ring. It is equivalent to replacing particles with infinitely long uniform density charged rods.}

Following Hofmann \cite{Hofmann2017Book}, we divide space charge effects into two categories: incoherent effects involving the motion of single particles, and coherent effects involving the self-consistent motion of the entire beam. Although the two effects may be difficult to isolate during the beam evolution \cite{Hofmann2021}, the distinction is clear in some cases.

\subsubsection{Incoherent effects}

We first assume that the beam is matched — i.e., oscillates with the same periodicity as the external focusing — and track a particle in the field of the matched beam. This may be justified if space charge is weak or if the particle is very far from the beam core. If the beam's electric field has a linear dependence on the transverse coordinates, it will simply modify the external linear focusing, reducing the single-particle tunes. A primary concern in rings is that the depressed tunes cross one of the low-order resonance lines in Fig.~\ref{fig:resonance_lines}. Approximate analytical formulas for the tune shift can be obtained \cite{Ng2005} but are not presented here.

If the electric field is nonlinear, the tune shift will depend on the particle amplitude, leading to a spread of tunes. An intuitive explanation is that large-amplitude particles experience a weaker average electric field throughout one turn in the ring \cite{Franchetti2017}. A recent study of the space charge tune spread in rings is found in \cite{Hotchi2020}; Fig.~\ref{fig:jparc_montague}, taken from the paper, shows the simulated tune spread in the Japan Proton Accelerator Research Center (J-PARC).
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=0.6\textwidth]{Images/chapter1/montague.png}
    \caption{Simulated tune footprint in the JPARC accelerator. (From \cite{Hotchi2020}.)}
    \label{fig:jparc_montague}
\end{figure}
%

Thus, the beam intensity in a circular accelerator is limited by the incoherent space charge tune shift/spread. A rough guideline is that the maximum tune shift should be kept below 0.25 to avoid fourth-order resonance lines \cite{book:Reiser}, but specific requirements depend on the application.\footnote{This condition is likely too conservative, and research in the area of intensity limits in circular accelerators is ongoing \cite{Cousineau2003, Hofmann2017Book, Kojima2019, Kojima2022}. As described in Appendix \ref{app-B}, it is also possible for the beam's electric field to drive single-particle resonances in the frozen-beam model, or for the entire beam to resonantly oscillate when space charge is strong.}

\subsubsection{Coherent effects}

Coherent space charge effects involve self-consistent oscillations of the entire beam \cite{book:Reiser, Wangler2008, Cousineau2003}. We may model the beam as a smooth distribution in phase space $f(\mathbf{x}, \mathbf{x}', s)$; neglecting collisions between particles, the evolution of $f$ is given by the Vlasov equation \cite{Vlasov1961}:
%
\begin{equation} \label{eq:Vlasov}
    \frac{d}{ds}{f(\mathbf{x}, \mathbf{x}', s)} =
    \frac{\partial{f}}{\partial{s}} +
    \mathbf{x}' \cdot \frac{\partial{f}}{\partial{\mathbf{x}}} +
    \mathbf{x}'' \cdot \frac{\partial{f}}{\partial{\mathbf{x'}}}
    = 0,
\end{equation}
%
Hidden in Eq.~\eqref{eq:Vlasov} is the single-particle equation of motion, which we rewrite as:
%
\begin{equation}
    \mathbf{x}'' + \mathbf{K_0} \mathbf{x} + \mathbf{K_1} \mathbf{x}'
    =
    -\frac{q}{m\gamma_s^3\beta_s^2c^2} \frac{\partial{\Phi}}{\partial\mathbf{x}},
\end{equation}
%
with the space charge potential $\Phi$ determined from the Poisson equation \cite{Jackson1975}:
%
\begin{equation} \label{eq:Poisson}
    \frac{\partial^2{\Phi}}{\partial{\mathbf{x}^2}} = -\frac{q}{\epsilon_0}
    \int_{-\infty}^{\infty}{f}d\mathbf{x}'.
\end{equation}
%

Analysis of the Vlasov equation is difficult in the general case of time-dependent external forces; thus, computer simulation must be used to understand the beam evolution. Solutions exist, but are rare (see Section \ref{sec:Self-consistent phase space distributions}). Perturbations of the Vlasov equation around these solutions can be used to derive stability conditions for the coherent oscillations of the beam, albeit this is only feasible in simple cases. This idea is explored in Appendix \ref{app-B}.

\section{Self-consistent phase space distributions}\label{sec:Self-consistent phase space distributions}

\subsection{Definition and properties}

Any function constructed from single-particle invariants $\{C_i\}$ is a solution of the Vlasov equation:
%
\begin{equation}\label{eq:vlasov_equilibria}
    \frac{d}{ds} f(\{C_i\}) = \sum_{i}{\frac{df}{dC_i}\frac{dC_i}{ds}} = 0.
\end{equation}
%
One example of a single-particle invariant when the focusing is linear and time-dependent is the Courant-Snyder invariant of Eq.~\eqref{eq:CS invariant}. The inclusion of space charge complicates the identification of invariants. Known solutions are found by the following procedure: (1) identify single-particle invariants $\{C_i\}$ in the presence of time-dependent linear forces; (2) construct a distribution from $\{C_i\}$ such that the distribution produces linear space charge forces under any linear transformation of the phase space coordinates. In this way, $\{C_i\}$ remain invariant even with space charge, and the linearity of the space charge force is conserved as the beam is transported through arbitrary linear focusing fields. We label such distributions as \textit{self-consistent} \cite{Danilov2003}.

Self-consistent distributions possess several notable properties. First, the integro-differential system of equations in Eq.~\eqref{eq:Vlasov} is reduced to a system of ordinary differential equations. Second, nonlinear space charge effects are minimized: the emittance is conserved, the maximum space charge tune shift is minimized, and the space charge tune spread is eliminated. Third, known self-consistent distributions have a uniform charge density. Fourth, higher-order coherent instabilities may be present in self-consistent distributions due to their small tune spread.

\subsection{Known solutions}

Danilov et al. enumerated a class of self-consistent distributions in $2n$-dimensional phase space \cite{Danilov2003}:
%
\begin{equation}\label{eq:scdist_general_form}
    f\left({\mathbf{x}, \mathbf{x}'}\right) =
    g\left({H - H_b}\right)
    \prod_{i=1}^{m}\delta\left({\mathbf{e}_i \cdot \mathbf{x}
    + \mathbf{e}'_i \cdot \mathbf{x}'}\right),
\end{equation}
%
where $\mathbf{x}$, $\mathbf{x}'$ are the $n$ dimensional vector coordinates and momenta, $g$ is a function of $H$ — a quadratic positively defined function of the phase space coordinates — and $H_b$ — an upper bound on $H$ — $\delta$ is the Dirac delta function, and $\mathbf{e}_i$ and $\mathbf{e}'_i$ are vectors of constants. This is labeled as the $\{n,m\}$ case. It was proven that the electric field within any uniformly filled ellipsoid is linear, and that any distribution of the form of $\eqref{eq:scdist_general_form}$ that produces a linear electric field will do so under any linear transformation of the phase space coordinates.

In other words, one class of self-consistent distributions consists of those that generate linear space charge forces and are constructed from quantities that are invariant in the presence of linear focusing. We now focus on the \{2, 0\} and \{2, 2\} cases.\footnote{Qin and Davidson derived a self-consistent distribution in two spatial dimensions in \cite{Qin2013} using their recent parameterization of coupled motion but did not refer to \cite{Danilov2003}. The connection between Danilov's work and Qin and Davidson's work should be explored in the future.}

\subsubsection{The KV distribution}

The $\{2, 0\}$ case corresponds to the KV distribution derived by Kapchinskij and Vladimirskij in 1959 \cite{Kapchinskij1959}. The distribution is a function of the Courant-Snyder invariants $J_x$ and $J_y$:
%
\begin{equation}
    f(\mathbf{x}, \mathbf{x}') = \frac{\lambda}{\pi^2 \varepsilon_x\varepsilon_y}
    \delta \left(\frac{J_x}{\varepsilon_x} + \frac{J_y}{\varepsilon_y} -1 \right),
\end{equation}
%
where $\lambda$ is the longitudinal particle density. Particles in the KV distribution are evenly distributed on an ellipsoidal shell in 4D phase space. As shown in Fig.~\ref{fig:distributions_kv}, any 2D projection of the distribution is a uniform density ellipse. Of particular importance is the $x$-$y$ projection, which remains upright and uniform density under any uncoupled transformation. The electric field within such an ellipse is
%
\begin{equation}  \label{eq:field_in_upright_ellipse}
    \mathbf{E}(x, y) =
    \frac{\lambda}{\pi\epsilon_0}
    \left[
        \frac{x}{c_x\left(c_x+c_y\right)} \hat{x}
        + \frac{y}{c_y\left(c_x+c_y\right)} \hat{y}
    \right],
\end{equation}
%
where $c_x$ and $c_y$ are the horizontal and vertical semi-axes and $\epsilon_0$ is the permittivity of free space. Since the space charge force is linear and uncoupled, $J_{x,y}$ remains invariant for every particle, and the emittances $\varepsilon_{x,y}$ are conserved. The KV distribution does not exist in three spatial dimensions \cite{Sacherer1968}.

As mentioned in the previous section, the preservation of the linearity of the space charge force leads to a self-consistent set of differential equations for the evolution of the beam envelope. The KV envelope equations read:
%
\begin{align} \label{eq:KV_envelope}
    \tilde{x}'' + k_{x}(s)\tilde{x} - \frac{\varepsilon_x^2}{\tilde{x}^3} - \frac{Q}{2\left(\tilde{x} + \tilde{y}\right)} &= 0, \\
    \tilde{y}'' + k_{y}(s)\tilde{y} - \frac{\varepsilon_y^2}{\tilde{y}^3} - \frac{Q}{2\left(\tilde{x} + \tilde{y}\right)} &= 0. \nonumber
\end{align}
%
The RMS widths of the beam $\tilde{x} = \sqrt{\langle{{x^2}}\rangle}$ and $\tilde{y} = \sqrt{\langle{{y^2}}\rangle}$ are used instead of the true widths $c_x$ and $c_y$. They are related by a factor of two for a uniform density ellipse. The perveance $Q$ is a dimensionless measure of space charge strength:
%
\begin{equation}\label{eq:perveance}
    Q = \frac{2\lambda r_0}{\beta^2\gamma^3},
\end{equation}
%
where $r_0 = e^2 / 4\pi\epsilon_0mc^2$ is the classical proton radius. Eqs.~\eqref{eq:KV_envelope} provide many insights into dynamical beam behavior and serve as a benchmark for computer simulations. A remarkable fact is that Eqs.~\eqref{eq:KV_envelope} are exact for distributions with elliptical symmetry even if the space charge force is nonlinear \cite{Sacherer1968}, although they are not closed since the root-mean-square emittances become time-dependent; thus, the KV envelope equations provide a good approximation to the evolution of more realistic distributions in the limit of elliptical symmetry and small emittance growth \cite{Lund2004}.

\subsubsection{The Danilov distribution}

The focus of this dissertation is on the $\{2, 2\}$ case of Eq.~\eqref{eq:scdist_general_form} which will be referred to as the Danilov distribution:
%
\begin{equation}
    f(\mathbf{x}, \mathbf{x}') \propto
    \Theta\left({1 - \mathbf{x}^T\bm{\mathbf{\sigma}^{-1}}\mathbf{x}}\right)
    \delta\left({\mathbf{x} - \mathbf{D}\mathbf{x}'}\right)
\end{equation}
%
with
%
\begin{equation}
    \bm{\sigma} =
    4
    \begin{bmatrix}
        \langle{xx}\rangle & \langle{xy}\rangle \\
        \langle{xy}\rangle & \langle{yy}\rangle
    \end{bmatrix}
\end{equation}
%
and $\mathbf{D}$ a $2 \times 2$ matrix. Similar to the KV distribution, any 2D projection of the Danilov distribution is a uniform density ellipse; however, the ellipses in the cross-plane projections ($x$-$y$, $x$-$y'$, $y$-$x'$, $x'$-$y'$) are not necessarily upright and may collapse to lines. For example, the projections are shown in Fig.~\ref{fig:distributions_danilov} for $\mathbf{D}_{11}=\mathbf{D}_{22}=0$ and $\mathbf{D}_{12} = -\mathbf{D}_{21}=1$, which corresponds to a rigidly rotating disk. The electric field in a uniform density ellipse with semi-axes $c_{x,y}$ tilted at an angle $\phi$ in the $x$-$y$ plane is:
%
\begin{equation}
\begin{aligned}
    E_x &\propto
    \left({\frac{\cos^2\phi}{c_x} + \frac{\sin^2\phi}{c_y}}\right) \frac{x}{c_x + c_y}
    +
    \sin\phi\cos\phi \left({\frac{1}{c_y} - \frac{1}{c_x}}\right) \frac{y}{c_x + c_y}, \\
    E_y &\propto
    \left({\frac{\cos^2\phi}{c_y} + \frac{\sin^2\phi}{c_x}}\right) \frac{y}{c_x + c_y}
    +
    \sin\phi\cos\phi \left({\frac{1}{c_y} - \frac{1}{c_x} }\right) \frac{x}{c_x + c_y}.
\end{aligned}
\end{equation}
%
The field is linear in $x$ and $y$, as required. And it is worth repeating: the linearity of the electric field is maintained under any linear transformation of the phase space coordinates. The key difference from the KV distribution is that space charge linearly couples the horizontal and vertical motion of individual particles. The Courant-Snyder invariants $J_{x,y}$ are therefore replaced by the more general invariants $J_{1, 2}$, which are conserved even with the inclusion of space charge.

The delta functions in the Danilov distribution function cause the four-dimensional emittance, and therefore one of the intrinsic emittances, to be zero. The following relationship has been found to hold:
%
\begin{equation}
    \varepsilon_1 = \varepsilon_x + \varepsilon_y, \quad
    \varepsilon_2 = 0
\end{equation}
%
or vice versa.

Discussion of the Danilov envelope equations is reserved for Chapter \ref{chap-2}.

\section{Producing a self-consistent distribution}\label{sec:Producing a self-consistent distribution}

\subsection{Motivation and previous work}

The following points motivate the physical realization of a Danilov distribution.

\begin{enumerate}
\item
The properties listed in section~\ref{sec:Self-consistent phase space distributions} — conservation of emittance, reduced space charge tune shift, and reduced space charge tune spread — have the potential to increase the maximum beam intensity in a ring.

\item
It is an interesting challenge to bring a real distribution closer to a self-consistent analytical model which is generally taken to be unrealistic.

\item
Beams with a uniform charge density are ideal for fixed-target applications such as spallation neutron production. SNS targets are complex and expensive \cite{Haines2014} and considerable research and development go into reducing the peak density on the target. This issue will become even more important if future machines are built on the intensity horizon with similar targets.

\item
There has been recent interest in angular-momentum-dominated (AMD) beams — beams with a small 4D emittance. Such a beam can be transformed to a round state ($\varepsilon_x \approx \varepsilon_y$) or a flat state ($\varepsilon_x \ll \varepsilon_y$) using coupled linear optics that preserve the intrinsic emittances $\cite{Kim2003}$. They may find use in colliders, relativistic electron cooling, low-energy hadron cooling, muon ionization cooling, and/or radiation generation \cite{Burov2002}. The Danilov distribution is an AMD beam with the special property of self-consistency.

The application that is most relevant to this work is the use of an AMD beam in a collider, as suggested by Burov in \cite{Burov2013} for the Large Hadron Collider (LHC). The primary benefit would be the increase in luminosity when the beam is converted to a flat state.\footnote{Consider the head-on collision of two Gaussian beams, each with $\varepsilon_x = \varepsilon_y$, with equal $\beta$ functions at the interaction point, The luminosity in this case is inversely proportional to $\sqrt{\varepsilon_x \varepsilon_y}$ \cite{Herr2006}. Now suppose the cross-plane correlations in the beam are removed before the collision: the new luminosity is inversely proportional to $\sqrt{\varepsilon_1 \varepsilon_2}$. Thus, the fractional increase in luminosity is $\sqrt{{\varepsilon_x\varepsilon_y} / {\varepsilon_1\varepsilon_2}}$, which diverges as $\varepsilon_{4D} = \varepsilon_1\varepsilon_2 \rightarrow 0$.} Flat beams could also suppress beam-beam resonances and allow for luminosity leveling \cite{Burov2013}. A promising approach to generating such a distribution is to maintain a round state at lower energies, such as in the LHC booster rings, then transform to a flat state at higher energies. The challenge is to accumulate the initial round AMD beam, which is complicated by nonlinear focusing fields and space charge forces. One way to address this challenge is to maintain an approximate Danilov distribution to linearize the space charge force during accumulation.
\end{enumerate}

Luiten et al. proposed a method to create a self-consistent \{3, 3\} distribution (see Eq.~\eqref{eq:scdist_general_form}) of electrons \cite{Luiten2004}. They observed that since a uniform density oblate spheroid\footnote{$(x/A)^2 + (y/B)^2 + (z/C)^2 = 1$ with $A = B > C$} will collapse under its own gravity into a flat disk \cite{Lin1965}, a flat transverse disk of electrons will longitudinally expand into a uniform density ellipsoid. This ``pancake" distribution can be created using ultrashort pulsed-laser photoemission with an appropriate radial intensity profile. Musumeci et al. experimentally demonstrated this method in \cite{Musumeci2008}.

Unfortunately, these methods do not apply to high-intensity proton rings where distributions are much longer, often resembling 2D coasting beams, and are built up over many turns. A method to produce an approximate Danilov distribution in a high-intensity proton ring was identified in \cite{Danilov2003}. Before describing this method, we must introduce the concept of phase space painting.

\subsection{Phase space painting}

Accelerators are often broken into stages. A common pattern is the injection of a beam from a linac into a ring followed by eventual extraction to a different section of the machine. Injection and extraction are accomplished using kicker magnets — dipole magnets with fast rise times.

In direct multi-turn injection, multiple beam pulses are injected into the same stable region of longitudinal phase space in the ring. This process is limited by Liouville's theorem in the sense that the phase space density in the ring cannot be increased. In charge-exchange injection, an ion beam from the linac is stripped of its electrons upon entering the ring, leaving only protons.\footnote{Electrons are currently stripped using foils. Laser stripping is a potential alternative \cite{Cousineau2017}.} This produces a higher phase space density because charge-exchange is a non-Liouvillian process. While normal multi-turn injection is usually performed over tens of turns, charge-exchange injection is performed over hundreds of turns \cite{Bracco2017}.\footnote{There is, however, renewed interest in direct multi-turn injection for future accelerators to avoid the issues associated with charge exchange injection, such as foil scattering and unstripped particles, and it seems possible to extend the number of injected turns into the hundreds using novel techniques \cite{Prior2016}.}

Phase space painting, or simply ``painting", is the time-dependent variation of the transverse distance and angle between the injected beam and the circulating beam; as such, it allows time-dependent control over the phase space distribution in the ring. Painting is a vital tool for space charge mitigation. The free parameters are the painting path — the path of the injection point in phase space — and the speed at which this path is traversed.

\subsubsection{Correlated painting}

Correlated painting proceeds as
%
\begin{equation}
\begin{aligned}
    {x}(t) &= {x}_{max}\sqrt{t}, \\
    {y}(t) &= {y}_{max}\sqrt{t}, \\
    x'(t) &= y'(t) = 0,
\end{aligned}
\end{equation}
%
where $x$, $x'$, $y$, and $y'$ are the coordinates of the injected beam in the phase space of the circulating beam and $t$ is a time variable normalized to the range [0, 1]. In the linear approximation and without space charge, correlated painting generates uniform density ellipses in the $x$-$x'$ and $y$-$y'$ planes and a rectangular distribution in the $x$-$y$ plane. This is illustrated in Fig.~\ref{fig:correlated_painting}, in which non-interacting particles are tracked in the linear approximation and plotted during accumulation in normalized phase space. New particles are injected at the intersection of the faint horizontal and vertical lines.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=\textwidth]{Images/chapter1/snapshots_corr.png}
    \caption{Correlated painting (linear approximation, non-interacting particles).}
    \label{fig:correlated_painting}
\end{figure}
%
Notice that this method produces a non-uniform density in the $x$-$y$ plane. At the SNS, where the size and peak density of the $x$-$y$ distribution on the spallation target is a concern \cite{Riemer2010}, a modified correlated painting scheme is used:
%
\begin{equation}
\begin{aligned}
    {x}(t) &= x_0 + x_{max}\sqrt{t}, \\
    {y}(t) &= y_0 + y_{max}\sqrt{t}, \\
    x'(t) &= y'(t) = 0.
\end{aligned}
\end{equation}
%
The initial distribution is a donut in the $x$-$x'$ and $y$-$y'$ planes. Space charge and other nonlinear forces eventually cause the distribution to fill in its hollow center, reducing the peak density.

\subsubsection{Anti-correlated painting}

Anti-correlated painting is equivalent to correlated painting reversed in one of the planes:
%
\begin{equation}
\begin{aligned}
    {x}(t) &= x_{max}\sqrt{t}, \\
    {y}(t) &= y_{max}\sqrt{1 - t}. \\
\end{aligned}
\end{equation}
%
The initial distribution is a point in the $x$-$x'$ plane and a donut in the $y$-$y'$ plane. The painting path in this method follows the line $J_x + J_y = constant$, which is the condition of particles in the KV distribution; thus, in the linear approximation without space charge, the final distribution is a KV distribution. This is illustrated in Fig.~\ref{fig:anti-correlated_painting}.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=\textwidth]{Images/chapter1/snapshots_anticorr.png}
    \caption{Anti-correlated painting (linear approximation, non-interacting particles).}
    \label{fig:anti-correlated_painting}
\end{figure}
%
However, the space charge forces are nonlinear throughout injection and the KV structure will not be maintained \cite{Crosbie1996}. How to overcome this limitation is an open question. Nonetheless, anti-correlated painting can have benefits over correlated painting \cite{Hotchi2020}.

\subsubsection{Elliptical painting}

We now present a method called elliptical painting that produces a Danilov distribution in the linear approximation, even with space charge. Refer back to Eq.~\eqref{eq:eigvec_coords} in which the single-particle motion is written as the sum of two modes. Elliptical painting proceeds by scaling the injection point $\mathbf{x} = (x, x', y, y')$ along one of the eigenvectors:
%
\begin{equation}\label{eq:elliptical_painting}
    \mathbf{x}(t) =
    Re \left\{ \sqrt{2 J_l} \, \mathbf{v}_l \, e^{-i\psi_l} \right\} \sqrt{t},
\end{equation}
%
with $l = 1,2$. The first injected pulse does not move since it is injected onto the closed orbit. The second pulse traces a small ellipse in every 2D projection of the phase space on a turn-by-turn basis. The third pulse traces a slightly larger ellipse enclosing the second, and so on. The square root time-dependence ensures that the beam is always a uniform density ellipse in every 2D projection of the 4D phase space. Thus, in the linear approximation, a Danilov distribution is maintained at all times, even with space charge.\footnote{The method is limited even in the linear approximation due to the finite emittance of the beam from the linac.} This is illustrated in Fig.~\ref{fig:elliptical_painting}.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=\textwidth]{Images/chapter1/snapshots_ell.png}
    \caption{Elliptical painting (linear approximation, non-interacting particles).}
    \label{fig:elliptical_painting}
\end{figure}
%

The final distribution depends strongly on the eigenvectors (modes) of the ring transfer matrix. If the ring is uncoupled, the two modes correspond to horizontal and vertical motion — we refer to these modes as \textit{planar} \cite{Burov2002}. Injection into a planar mode results in a flat beam. If the ring is coupled, each mode corresponds to elliptical motion in the transverse plane — we refer to these modes as \textit{elliptical}. Finally, there is the special case of circular motion in the transverse plane — we refer to these modes as \textit{circular}. Injection into an elliptical/circular mode results in an elliptical/circular beam.

One way to generate elliptical modes in a ring is to use coupled focusing elements such as skew quadrupoles and solenoids. To create circular modes, locally rotational-invariant optics can be used \cite{Burov2002}. The second way to generate elliptical modes in a ring is to equate the horizontal and vertical tunes, keeping all focusing elements uncoupled. In this case, the transfer matrix has degenerate eigenvalues and any linear combination of eigenvectors is itself an eigenvector; i.e., the turn-by-turn coordinates of a single particle will trace an ellipse no matter the initial coordinates.

\subsection{Elliptical painting in the Spallation Neutron Source}

Elliptical painting is possible in the SNS. The requirements are (i) the generation of elliptical modes in the ring and (ii) time-dependent control of the position and angle of the injected beam relative to the circulating beam. Before discussing how to implement (i) and (ii), a brief description of the SNS is warranted.\footnote{Experiments at the SNS will be relevant to the production of a flat beam in a collider; LHC booster rings now use H$^-$ charge-exchange injection and phase space painting \cite{Abelleira2015, Bracco2011}.}

\subsubsection{Description of the Spallation Neutron Source}

The SNS is a neutron scattering facility. Sixty times per second, a microsecond-long proton beam collides with a liquid mercury target at 1 GeV kinetic energy, producing neutrons by the process of spallation \cite{Russell1990}. The original beam is a continuous wave of H$^-$ ions which is chopped and then bunched in a 402.5 MHz radio-frequency quadrupole (RFQ), forming microsecond-long minipulses. Each minipulse is accelerated to 1 GeV through a normal-conducting, then superconducting linac, then transported to the injection region through the high-energy beam transport (HEBT). The electrons are stripped using a carbon foil, and the remaining protons continue their journey in the ring. A second minipulse is injected after the first minipulse completes one turn, and so on until one thousand minipulses, or $1.5 \times 10^{14}$ protons, are accumulated over $10^{-3}$ seconds. Finally, the beam is extracted and guided through the ring-target beam transport line (RTBT) to the target. A comprehensive description of the SNS is given in \cite{Henderson2014}. Fig.~\ref{fig:SNS} shows an overview of the machine.
%
\begin{figure}[!p]
    \centering
    \includegraphics[angle=-90, width=0.6\textwidth]{Images/chapter1/SNS.png}
    \caption{The Spallation Neutron Source (SNS).}
    \label{fig:SNS}
\end{figure}
%

Fig.~\ref{fig:SNS_injection_region} zooms in on the injection region.
%
\begin{figure}[!p]
    \centering
    \vspace*{5cm}
    \includegraphics[width=\textwidth]{Images/chapter1/SNS_injection_region1.png}
    \caption{The SNS injection region.}
    \label{fig:SNS_injection_region}
    \vspace*{5cm}
\end{figure}
%
Four Chicane dipole magnets provide a time-independent bump to align the horizontal orbit with the H$^-$ trajectory at the foil. Painting is performed by eight time-dependent kicker magnets — four per plane — which modify the transverse position and angle of the circulating beam. The injected beam trajectory is held fixed so that remaining H$^0$ or H$^-$ particles can be reliably guided to a dump.

\subsubsection{Generation of elliptical modes in the ring}

Although the transfer matrix of the SNS ring is uncoupled, elliptical modes can be created by setting equal horizontal and vertical tunes. Tune measurement and control is standard practice in most accelerators \cite{book:Minty2003} and is not described here. For reasons described in later chapters, it is advantageous to add solenoid magnetic fields to the ring. Solenoids are planned to be installed in the SNS ring in late 2022.

\subsubsection{Ring Injection Control}

Once elliptical modes are created in the ring, particles must be injected into one of the modes. Recall the free parameters: the painting path and the time-dependence with which this path is traversed. Eq.~\ref{eq:elliptical_painting} requires fixed ratios between the injected coordinates ($x$, $x'$, $y$, $y'$) — the coordinates of the injected beam in the frame of the circulating beam at the injection point — and square root scaling of every coordinate. In the SNS, these coordinates are determined by the eight injection kicker magnet voltages. Once the correct initial and final voltages are determined, each kicker is given a waveform that scales its voltage during injection. The square root scaling of each coordinate is ensured by using a square root waveform. Thus, what remains is to determine the initial and final kicker voltages.

It is first necessary to measure the phase space coordinates at the injection point. This can be done indirectly as follows. A single minipulse is injected and stored in the ring, and its turn-by-turn mean transverse position is measured using a beam-position-monitor (BPM). This is repeated for several minipulses and the average is taken. In the linear approximation, the mean position performs the pseudo-harmonic oscillations of Eq.~\eqref{eq:Hill_solution}; however, energy spread in the minipulse eventually sends the mean position to zero. A damped sine wave is an accurate model of this process for Gaussian energy spread \cite{Pelaia2016}:
%
\begin{equation}\label{eq:damped_sinusoid}
    x(t) = A_0 + A e^{kt^2} \cos{\left(\mu + \mu_0\right)},
\end{equation}
%
where $t$ is the turn number. The parameter $A$ gives the betatron amplitude, $\mu / 2\pi$ gives the fractional tune, and $\mu_0$ gives the particle phase at the BPM. The phase space coordinates are recovered by combining these parameters with the linear ring model:
%
\begin{equation}
\begin{aligned}
    x_{bpm} &= A \cos\mu_0 \\
    x'_{bpm} &= -A\left({\sin\mu_0 + \frac{\alpha}{\beta}\cos\mu_0}\right).
\end{aligned}
\end{equation}
%
The coordinates are then transported to the injection point using the model transfer matrix. Repeating this for each BPM gives an estimated mean and standard deviation of the phase space coordinates at the injection point. Examples of measured individual and averaged BPM signals in the SNS ring are shown in Fig.~\ref{fig:bpm_avg} along with the damped-sinusoid fit. Additionally, a simulated minipulse in the (linearized) SNS ring is shown in Fig.~\ref{fig:minipulse}.
%
\begin{figure}[!p]
    \centering
    \begin{subfigure}{\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/bpm_avg.png}
        \caption{}
        \label{fig:bpm_avg}
    \end{subfigure}
    \vfill
    \vspace*{0.5cm}
    \vfill
    \begin{subfigure}{\textwidth}
         \includegraphics[width=\textwidth]{Images/chapter1/minipulse_chromaticity_black.png}
        \caption{}
        \label{fig:minipulse}
    \end{subfigure}
    \caption{(a) Measured turn-by-turn BPM signal in the SNS ring — averaged over 50 pulses and fit with Eq.~\eqref{eq:damped_sinusoid}. (b) Simulated minipulse in the (linearized) SNS ring. The $x$-$x'$ distribution is plotted at the injection point along with the Courant-Snyder ellipse.}
    \label{fig:bpm_fits}
\end{figure}
%

The next issue is how to control the phase space coordinates at the injection point. Each kicker magnet is calibrated by applying a voltage difference to the magnet, measuring the orbit response using the ring BPMs, and varying the angular kick associated with the magnet until the model orbit agrees with the measured orbit. It was found that slight quadrupole corrections are necessary for this to occur. The standard deviation of the measured phase space coordinates is usually small after this calibration. One can then ask the model for a change in coordinates, update the kickers accordingly, and measure the new coordinates, iterating if necessary. This is currently done manually, and kicker power supplies need to be visually checked to make sure they are not beyond physical limits. Once this setup is complete, the kicker voltages are saved to a file and fed to a different script which scales sets the kicker waveforms. These steps were implemented as part of the Ring Injection Control (RIC) application in the OpenXAL framework \cite{Milas2021} prior to this work.

The SNS injection kicker magnets have limited strengths and are unipolar, which limits the maximum injection angle. This is potentially disadvantageous because it could restrict the final apparent beam emittances, which should be maximized to reduce the effect of space charge and better approximate a pencil-beam from the linac, i.e., a small ratio of the minipulse emittances to the final pulse emittances. For example, one painting scheme is to vary the relative horizontal distance and vertical angle between the beams while fixing the vertical distance and horizontal angle; in this case, the final vertical emittance depends only on the maximum vertical angle. Previous simulations indicate that this angle will be quite small at the nominal beam energy of 1.0 GeV. Several tricks to increase the effective strength of the injection kicker magnets are discussed in Chapter \ref{chap-5}. An example trajectory using this painting scheme is shown in Fig.~\ref{fig:injection_region_trajectory}.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=\textwidth]{Images/chapter1/inj_region_elements.pdf}
    \caption{Example initial/final trajectories of the closed orbit in the SNS injection region for the elliptical painting method. The initial injected coordinates are ($x$, $x'$, $y$, $y'$) $=$ (0 mm, 0 mrad, 0 mm, 0 mrad) and the final injected coordinates are ($x$, $x'$, $y$, $y'$) $=$ (31 mm, 0 mrad, 0 mm, 1.5 mrad). The bottom plot shows the elements along the beamline (excluding the Chicane dipoles): stripper foil (gold), quadrupoles (black), horizontal kickers (blue), vertical kickers (orange), and vertical orbit corrector dipoles (green). The vertical orbit corrector dipoles provide a closed bump to assist the kickers.}
    \label{fig:injection_region_trajectory}
\end{figure}
%

\section{Structure and goals of this dissertation}\label{sec:Goals of this dissertation}.

The primary goal of this dissertation is to contribute to efforts to produce an approximate Danilov distribution in the SNS ring. The secondary goal is to improve the current understanding of the dynamics of the Danilov distribution with space charge.

In Chapter \ref{chap-2}, the envelope equations describing the linear transport of the Danilov distribution are used to calculate the matched beam envelope with the inclusion of space charge forces. Such a calculation is critical to producing a Danilov distribution in a ring using the elliptical painting method. In Chapter \ref{chap-3}, the computational model used for realistic simulations of beam dynamics in the SNS ring is described. Previously published simulation results are re-examined and the significance of updated experimental constraints is discussed. In Chapter \ref{chap-4}, several methods to measure the similarity between a painted distribution and a Danilov distribution are identified, implemented using existing diagnostics in the SNS, and optimized. In Chapter \ref{chap-5}, the results of three initial experimental studies of elliptical painting in the SNS are presented. Simulations are provided for comparison. In Chapter \ref{chap-6}, implications and extensions of this work are discussed.


\documentclass[10pt,a4paper,oneside]{scrartcl}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage[
	authordate,
	strict,
	backend=biber
]
{biblatex-chicago}
\usepackage{mathtools}
\author{}
\title{Total Difficulty}
\date{}
\addbibresource{~/modules/References.bib}
\begin{document}
\maketitle
\paragraph{Notation}: \texttt{difficulty}
\paragraph{Description}: The \textit{Total Difficulty} of a block is defined recursively by a function which calculates the difficulty of all blocks prior to the header in the present block.
        	\par
                \begin{tabular}{rl}
           \toprule
           \textbf{Pseudocode} & \textbf{Definition} \\
           \midrule
           \texttt{presentstate(total.difficulty)} & Total difficulty of the \texttt{presentstate}. \\
	   \texttt{presentstate(block.parent)}     & This block's \texttt{parent}. \\
           \texttt{presentstate(block.difficulty)} & \textsl{This block's} difficulty. \\
           \bottomrule
                  \end{tabular}

\end{document}