% !TeX spellcheck = en_GB
% !TeX program = lualatex
%
% v 2.3  Feb 2019   Volker RW Schaa
%		# changes in the collaboration therefore updated file "jacow-collaboration.tex"
%		# all References with DOIs have their period/full stop before the DOI (after pp. or year)
%		# in the author/affiliation block all ZIP codes in square brackets removed as it was not %         understood as optional parameter and ZIP codes had bin put in brackets
%       # References to the current IPAC are changed to "IPAC'19, Melbourne, Australia"
%       # font for ‘url’ style changed to ‘newtxtt’ as it is easier to distinguish "O" and "0"
%
\documentclass[a4paper,
               %boxit,        % check whether paper is inside correct margins
               %titlepage,    % separate title page
               %refpage       % separate references
               %biblatex,     % biblatex is used
               keeplastbox,   % flushend option: not to un-indent last line in References
               %nospread,     % flushend option: do not fill with whitespace to balance columns
               %hyphens,      % allow \url to hyphenate at "-" (hyphens)
               %xetex,        % use XeLaTeX to process the file
               %luatex,       % use LuaLaTeX to process the file
               ]{jacow}
%
% ONLY FOR \footnote in table/tabular
%
\usepackage{pdfpages,multirow,ragged2e} %
%
% CHANGE SEQUENCE OF GRAPHICS EXTENSION TO BE EMBEDDED
% ----------------------------------------------------
% test for XeTeX where the sequence is by default eps-> pdf, jpg, png, pdf, ...
%    and the JACoW template provides JACpic2v3.eps and JACpic2v3.jpg which
%    might generates errors, therefore PNG and JPG first
%
\makeatletter%
	\ifboolexpr{bool{xetex}}
	 {\renewcommand{\Gin@extensions}{.pdf,%
	                    .png,.jpg,.bmp,.pict,.tif,.psd,.mac,.sga,.tga,.gif,%
	                    .eps,.ps,%
	                    }}{}
\makeatother

% CHECK FOR XeTeX/LuaTeX BEFORE DEFINING AN INPUT ENCODING
% --------------------------------------------------------
%   utf8  is default for XeTeX/LuaTeX
%   utf8  in LaTeX only realises a small portion of codes
%
\ifboolexpr{bool{xetex} or bool{luatex}} % test for XeTeX/LuaTeX
 {}                                      % input encoding is utf8 by default
 {\usepackage[utf8]{inputenc}}           % switch to utf8

\usepackage[USenglish]{babel}

%
% if BibLaTeX is used
%
\ifboolexpr{bool{jacowbiblatex}}%
 {%
  \addbibresource{jacow-test.bib}
  \addbibresource{biblatex-examples.bib}
 }{}
\listfiles

%%
%%   Lengths for the spaces in the title
%%   \setlength\titleblockstartskip{..}  %before title, default 3pt
%%   \setlength\titleblockmiddleskip{..} %between title + author, default 1em
%%   \setlength\titleblockendskip{..}    %afterauthor, default 1em

\begin{document}

\title{Optimisation of a Permanent Magnet Multi-Energy FFA Arc for the CEBAF Energy Upgrade\thanks{Work supported by Brookhaven Science Associates, LLC under Contract No. DE-SC0012704 with the U.S. Department of Energy.}}

\author{S.J. Brooks\thanks{sbrooks@bnl.gov}, Brookhaven National Laboratory, Upton, NY, USA}
	
\maketitle

%
\begin{abstract}
It is currently planned to increase the energy of the CEBAF recirculating linear accelerator to 20\,GeV or more by adding two new recirculating arcs that contain multiple new energy passes.  The beam is continuous (CW), so no field ramping is desired, making this a fixed-field accelerator (FFA).  The wide energy range requires a low dispersion lattice that can be created with high-gradient permanent magnets.  One constraint is the existing tunnel radius in relation to the fields achievable by practically-sized permanent magnets.  Thus, searching for the most efficient implementation in terms of magnet material volume is important.  In this paper, a lattice cell search and optimisation is conducted that evaluates cells by the magnet volume per unit length, with the permanent magnet designs also produced via an automated code.  The new lattice cells are compared to the previous manually designed cell.
\end{abstract}


\section{Lattice Constraints}
The fixed-field (FFA) arcs of the CEBAF energy upgrade \cite{CEBAFIPAC23,VasilyIPAC24} will replace the final electromagnetic arcs of the current 12\,GeV CEBAF but allow a wide energy range to be transmitted.  For the east arc studied in this paper, this range will be approximately 10.5--21\,GeV.  Option A in Table~\ref{tab:latticerules} is the baseline as of December 2022, which is a linear field FFA.  All lattices in this study have the simple structure \textbf{BD~o~BF~o} where \textbf{o} is a drift space.

\begin{table}[!hbt]
   \centering
   \caption{Lattice Option Design Rules}
   \begin{tabular}{l|cc|cc}
       \toprule
       \textbf{Option} & \multicolumn{2}{c|}{\textbf{Energy (GeV)}} & \multicolumn{2}{c}{\textbf{Cell tune (cycles)}} \\
        & \textbf{Min.} & \textbf{Max.} & \textbf{Min.} & \textbf{Max.} \\
       \midrule
A & 10.494 & 21.014 & 0.0363* & 0.3943* \\
B & 10.494 & 21.014 & 0.035 & 0.4 \\
C & 10.494 & 21.014 & 0.035 & 0.4 \\
D & 9 & 21 & 0.04 & 0.39 \\
E & 9 & 21 & 0.05 & 0.32 \\
   \end{tabular}
   \begin{tabular}{lccc}
       \toprule
\textbf{Option} & \textbf{Max. Dipole} & \textbf{Gradient} & \textbf{Sextupole} \\
                       & \textbf{(T)} & \textbf{(T/m)} & \textbf{(T/m$^\mathbf2$)} \\
       \midrule
A & 1.2815* & 43.44* & 0 \\
B & 2 & 100 & 0 \\
C & 2 & 100 & 2000 \\
D & 2 & 100 & 400 \\
E & 2 & 100 & 400 \\
       \bottomrule
   \end{tabular}
\\ \footnotesize{* Point design values, rather than optimisation limits.}
   \label{tab:latticerules}
\end{table}

Lines B--E of Table~\ref{tab:latticerules} give constraints for coupled lattice--magnet optimisations that otherwise try to reduce permanent magnet volume.  Option B is a re-optimisation for minimum magnet volume while keeping the same energy and tune ranges.  Option C allows a (potentially large) amount of sextupole to be added to the magnets, this flexibility potentially reducing magnet size further, while otherwise preserving the conditions of B.  Options D and E attempt to use the additional flexibility provided by the sextupole to give an extended lower energy range, which is important for fine-tuning the facility beam energy, or dealing with other situations where the SRF linac energy gain is reduced and the beam enters the FFA arcs at below nominal energy.  Option E tries a narrower cell tune range avoiding the $Q=1/3$ resonance that could be excited by sextupoles.

Lattice cells must also conform to the 80.6\,m CEBAF tunnel radius.  This is enforced by setting magnet bend angles $\theta_m=(L_\mathrm{cell}/80.6$\,m$)L_m/(L_\mathrm{BF}+L_\mathrm{BD})$ where $L_m$ is the magnet length, which is allowed to vary.  The drift spaces are set to a constant 9\,cm in optimisations B--E.

\subsection{Magnet Alignment Details}
Long permanent magnets are generally built in rectangular sections rather than sectors.  The magnet bend angle $\theta$ is therefore implemented (in the layout reference line) as two corners of angle $\theta/2$ at either end of the magnet, with straight lines in between.  A soft-edged fringe field proportional to $\frac12+\frac12\tanh(z/(2.5\,\mathrm{cm}))$ is used at both ends of all magnets.  To deal with orbit curvature within the magnets, they are split into six longitudinal sections, each individually centred on the range of beam orbits.

\section{Optimisation Method}
Candidate lattice cells were tracked with the \texttt{Muon1} code~\cite{Muon1} and optimised with its built-in genetic algorithm.  The optimiser started from random designs with no manually-set starting point, so the following scoring ranges were used to guide it towards viable designs.
\begin{enumerate}
\item If the first energy is unstable or has an unacceptable tune, the cell is scored by how far $\cos \phi$ (calculated from the trace of the transfer matrix) deviates from the desired tune range limits, where $\phi$ is the phase advance.
\item If the first energy has correct tunes but later ones do not, the cell is scored by the percentage of the FFA energy range that is acceptable.
\item If all energies have correct tunes, the \texttt{HalbachArea} code~\cite{HalbachArea} is called to attempt magnet designs.  If the magnet design fails, the cell is scored by peak field in the bore of the accelerator, with lower being better.
\item If all energies have correct tunes and magnets exist, the cell is scored by the average magnet area $(\sum_{\mathrm{Elements\ }e}A_e L_e)/\sum_e L_e$ weighted by length through the cell, with lower being better.
\end{enumerate}

\section{Magnet Constraints}
When 2D permanent magnet designs are generated with the \texttt{HalbachArea} tool~\cite{HalbachArea}, they use the design rules given in Table~\ref{tab:magnetrules}, which ensure there is an open midplane to allow synchrotron radiation to escape, as well as allowing enough vertical room for the beam pipe.  Cross sections of the resulting magnets are shown in Fig.~\ref{fig:magnetscollage}.

\begin{table}[!hbt]
   \centering
   \caption{Permanent Magnet Design Rules}
   \begin{tabular}{lc}
       \toprule
       \textbf{Parameter} & \textbf{Value} \\
       \midrule
Number of wedges & 24 (12 per side) \\
Midplane anglular gap & $\pm$12$^\circ$ \\
       \midrule
Vertical aperture & $\pm$8\,mm \\
Minimum midplane gap & $\pm$3\,mm \\
       \midrule
Material & NdFeB \\
Grade & N42EH \\
$B_r$ (real) & 1.28--1.33\,T \\
$B_{r1}$ (for $\mu_r=1$ model) & 1.248\,T \\
$\mu_0H_{cJ}$ & 2.9\,T \\
       \bottomrule
   \end{tabular}
   \label{tab:magnetrules}
\end{table}

The magnet geometry is made of multiple wedges around the aperture, as used in CBETA~\cite{CBETAmagnets} and adapted in geometry for the CEBAF upgrade use case, including a recently constructed prototype~\cite{MagnetIPAC23}.  The material selected is one of the highest field grades that still admits reasonably good radiation resistance judged from its $H_{cJ}$ value, although this is also being tested experimentally at CEBAF~\cite{RyanRadiation}.  

\section{Lattice Results}
The geometries of the optimised lattice cells are given in Table~\ref{tab:latticegeom} and the magnetic fields are given in Table~\ref{tab:latticefields}.

\begin{table*}[!hbt]
   \centering
   \caption{Lattice Geometries}
   \begin{tabular}{l|cccc|ccc}
       \toprule
       \textbf{Option} & \multicolumn{4}{c|}{\textbf{Lengths (m)}} & \multicolumn{3}{c}{\textbf{Angles (mrad)}} \\
        & \textbf{BD} & \textbf{BF} & \textbf{Drifts} & \textbf{Cell} & \textbf{BD} & \textbf{BF} & \textbf{Cell}\\
       \midrule
A & 1.2448 & 1.6731 & 0.1162 & 3.1504 & -7.11 & -31.98 & -39.09 \\
B & 1.1832 & 1.1892 & 0.09 & 2.5524 & 15.79 & 15.87 & 31.67 \\
C & 1.5195 & 1.4505 & 0.09 & 3.1500 & 20.00 & 19.09 & 39.08 \\
D & 1.4625 & 1.9760 & 0.09 & 3.6184 & 19.09 & 25.80 & 44.89 \\
E & 1.3814 & 1.7898 & 0.09 & 3.3512 & 18.11 & 23.47 & 41.58 \\
       \bottomrule
   \end{tabular}
   \label{tab:latticegeom}
\end{table*}

\begin{table*}[!hbt]
   \centering
   \caption{Lattice Magnetic Field Specifications}
   \begin{tabular}{l|cc|cc|cc}
       \toprule
       \textbf{Option} & \multicolumn{2}{c|}{\textbf{Dipole (T)}} & \multicolumn{2}{c|}{\textbf{Gradient (T/m)}} & \multicolumn{2}{c}{\textbf{Sextupole (T/m$^\mathbf2$)}} \\
        & \textbf{BD} & \textbf{BF} & \textbf{BD} & \textbf{BF} & \textbf{BD} & \textbf{BF} \\
       \midrule
A & -0.3828 & -1.2815 & 43.44 & -41.13 & 0 & 0 \\
B & 0.8629 & 0.8629 & 55.155 & -69.369 & 0 & 0 \\
C & 0.9590 & 0.9590 & 59.960 & -89.189 & -1411.41 & 974.97 \\
D & 0.8228 & 0.8228 & 45.345 & -48.549 & -400 & 339.94 \\
E & 0.8148 & 0.8148 & 47.548 & -50.951 & -400 & 351.95 \\
       \bottomrule
   \end{tabular}
   \label{tab:latticefields}
\end{table*}

\begin{table*}[!hbt]
   \centering
   \caption{Lattice Results and Figures of Merit}
   \begin{tabular}{l|cc|ccc|ccc}
       \toprule
       \textbf{Option} & \multicolumn{2}{c|}{\textbf{Cell tune (cycles)}} & \textbf{$|\mathbf B|_\mathrm{max}$} & \textbf{Orbit excursion} & \textbf{Path length change} & \multicolumn{3}{c}{\textbf{Magnet areas (cm$^\mathrm2)$}} \\
         & \textbf{min.} & \textbf{max.} & \textbf{(T)} & \textbf{(mm)} & \textbf{(mm)} & \textbf{Average} & \textbf{BD} & \textbf{BF} \\
       \midrule
A & 0.0363 & 0.3943 & 1.5346 & 44.968 & 1.233 & 84.69 & 87.43 & 94.41 \\
B & 0.0357 & 0.3994 & 1.6140 & 28.607 & 0.525 & 75.75 & 104.56 & 58.54 \\
C & 0.0352 & 0.3993 & 1.4922 & 23.602 & 0.344 & 44.29 & 59.32 & 34.04 \\
D & 0.0426 & 0.3898 & 1.4689 & 41.739 & 0.916 & 54.38 & 72.18 & 46.16 \\
E & 0.0500 & 0.3194 & 1.5438 & 42.966 & 0.910 & 64.24 & 86.07 & 53.86 \\
       \bottomrule
   \end{tabular}
   \label{tab:latticeresults}
\end{table*}

Table~\ref{tab:latticeresults} shows some performance statistics for the optimised cells.  Option C has the smallest average magnet area, which is also the optimiser's figure of merit: 48\% below the baseline A.  This makes sense as option C was the least constrained.

\begin{figure}[!htb]
   \centering
   \includegraphics*[width=0.95\columnwidth]{TUPC22_f1}
   \caption{Cell tunes of the optimised linear field option B compared to the baseline option A.}
   \label{fig:compareAB}
\end{figure}

Figure~\ref{fig:compareAB} shows the cell tunes as a function of energies within the range.  Option B has nearly identical tunes to the baseline A, with its 36\% reduction in orbit excursion and 11\% reduction in magnet area mainly coming from shortening the cell length from 3.15 to 2.55\,m.

\begin{figure}[!htb]
   \centering
   \includegraphics*[width=0.95\columnwidth]{TUPC22_f2}
   \caption{Cell tunes of the optimised lattice with sextupole (option C) compared to the baseline option A.}
   \label{fig:compareAC}
\end{figure}

Figure~\ref{fig:compareAC} shows that the tune dependence changes radically when a large amount of sextupole is allowed.  This may be a problem for the FFA orbit correction scheme, which relies on the multiple beams being linearly independent by having different tunes.  This is the reason for the 400\,T/m$^2$ sextupole limit used in optimisations D and E.

\begin{figure}[!htb]
   \centering
   \includegraphics*[width=0.95\columnwidth]{TUPC22_f3}
   \caption{Cell tunes of the extended energy range sextupole lattices (D and E) compared to the baseline option A.}
   \label{fig:compareADE}
\end{figure}

Figure~\ref{fig:compareADE} shows that a smaller amount of sextupole has a less drastic impact on the tunes.  The attempt at keeping the tunes below 1/3 has had the side effect of making option E's horizontal tunes nearly constant, which is bad for orbit correction.  However, option D looks more reasonable.

%\section{Magnet Results}
The automatically-produced designs for all the magnets in options A--E are shown in Fig.~\ref{fig:magnetscollage}.

\begin{figure*}[!htb]
   \centering
   \includegraphics*[width=\textwidth]{TUPC22_f4}
   \caption{Cross-sections of both permanent magnets for all five lattice options.  Arrows indicate magnetisation direction, grid spacing is 1\,cm.}
   \label{fig:magnetscollage}
\end{figure*}

\clearpage

%
% only for "biblatex"
%
\ifboolexpr{bool{jacowbiblatex}}%
	{\printbibliography}%
	{%
	% "biblatex" is not used, go the "manual" way
	
	%\begin{thebibliography}{99}   % Use for  10-99  references
	\begin{thebibliography}{9} % Use for 1-9 references

\bibitem{CEBAFIPAC23} K.E. Deitrick \emph{et al.}, ``CEBAF 22\,GeV FFA Energy Upgrade'', Proc. IPAC 2023.
\url{doi:10.18429/JACoW-IPAC2023-MOPL182}
\bibitem{VasilyIPAC24} V.S. Morozov \emph{et al.}, ``Development of FFA RLA design concept'', Proc. IPAC 2024 (this conference).
\bibitem{Muon1} \texttt{Muon1} tracking code, described in chapters 2 and 7 of S. Brooks, University of Oxford DPhil thesis “Muon capture schemes for the neutrino factory” (2010), available from \url{https://ora.ox.ac.uk/objects/uuid:7b724028-e4ef-4248-9d42-505e571c9e19}
\bibitem{HalbachArea} S. Brooks, \texttt{HalbachArea} permanent magnet tool, available from \url{https://stephenbrooks.org/ap/halbacharea/}
\bibitem{CBETAmagnets} S. Brooks, G. Mahler, J. Cintorino, J. Tuozzolo, and R. Michnoff, ``Permanent magnets for the return loop of the Cornell-Brookhaven energy recovery linac test accelerator'', Phys. Rev. Accel. Beams \textbf{23}, 112401 (2020).
\url{doi:10.1103/PhysRevAccelBeams.23.112401}
\bibitem{MagnetIPAC23} S. Brooks, ``Open-Midplane Gradient Permanent Magnet with 1.53T Peak Field'', Proc. IPAC 2023.
\url{doi:10.18429/JACoW-IPAC2023-WEPM128}
\bibitem{RyanRadiation} R.M. Bodenstein \emph{et al.}, ``Permanent Magnet Resiliency in Jefferson Lab’s Radiation Environment: LDRD Grant Status and Plan'', Proc. IPAC 2024 (this conference).

% Perhaps a collab CEBAF paper from last IPAC and this?

	\end{thebibliography}
} % end \ifboolexpr
%
% for use as JACoW template the inclusion of the ANNEX parts have been commented out
% to generate the complete documentation please remove the "%" of the next two commands
% 
%%%\newpage

%%%\include{annexes-A4}

\end{document}
