source: TRACY3/trunk/tracy/tracy/doc/soltracy3_userManual_developer.tex @ 32

Last change on this file since 32 was 32, checked in by zhangj, 10 years ago

active the transport of the twiss functions and orbits of the transfer line.

File size: 133.4 KB
Line 
1\documentclass[fleqn]{article}
2\author{Jianfeng Zhang \footnote{LAL, Orsay, France.Email: \href{mailto:zhangj@lal.in2p3.fr}{zhangj@lal.in2p3.fr}}}
3\title{Soltracy3 mannual for developpers}
4
5%% left align the long equations in the 'aligned' enviroment
6\usepackage[fleqn]{amsmath}
7\usepackage{amssymb}
8\usepackage{graphicx}
9\usepackage[colorlinks=true,urlcolor=magenta,citecolor=blue]{hyperref}
10\usepackage{color}
11\usepackage{setspace}
12
13
14%% auto center the sentence in the line
15\newenvironment{tightcenter}{%
16   \vspace{0.02in} 
17 \setlength\topsep{0pt}
18  \setlength\parskip{0pt}
19  \begin{center}
20}{%
21  \end{center}
22\vspace{0.02in} 
23 }
24
25%% auto wrap a long word
26\newcommand*\wrapletters[1]{\wr@pletters#1\@nil}
27\def\wr@pletters#1#2\@nil{#1\allowbreak\if&#2&\else\wr@pletters#2\@nil\fi}
28
29% define the file path font
30\newcommand{\pathfont}[1]{\textit{\wrapletters{#1}}} 
31% define the font and color of the Tracy command in Tracy file
32\newcommand{\tracycommand}[2]{\begin{tightcenter} 
33                               \textsf{\textcolor{red}{#1}} \quad \textsf{\textcolor{blue}{#2}} 
34                              \end{tightcenter}}
35\newcommand{\tracycomm}[1]{\textsf{\textcolor{red}{#1}}}
36\newcommand{\tracypara}[1]{\textsf{\textcolor{blue}{#1}}}
37
38% lattice element definition
39\newcommand{\latticedef}[3]{\begin{tightcenter}
40                               \textsf{\textcolor{black}{#1}}   
41                               \textsf{\textcolor{red}{#2}} \quad \textsf{\textcolor{blue}{#3}} 
42                              \end{tightcenter}}
43\newcommand{\elemname}[1]{\textsf{\textcolor{black}{#1}}}
44\newcommand{\elemkeyword}[1]{\textsf{\textcolor{red}{#1}}}
45\newcommand{\elempara}[1]{\textsf{\textcolor{blue}{#1}}}
46
47\newcommand{\notespace}[1]{\vspace{0.1in}\textbf{#1} \vspace{0.05in}}
48
49
50\begin{document}
51
52\maketitle
53\tableofcontents
54
55\onehalfspacing
56
57\section{Change Log}
58
59\begin{itemize}
60\item[05/10/2012] Add the control flag to control the entrance and exit edge effects and fringe
61field of the dipole, with``edge\_effect1 = 1'' in the dipole definition in the lattice file, the
62entrance edge effect and fringe field of the dipole are turned on, with ``edge\_effect1 = 0'',
63this effects are turned off. These two effects at the exit of the dipole are controlled by
64``edge\_effect2''.
65\end{itemize}
66
67\section{Introduction}
68Tracy is a code to do long term tracking, and is written in the mixture of c and c++ by Johann Bengsston
69and other scientists (???).
70
71This manual is for SOLEIL version Tracy which is maintained and developped by
72L. Nadolski and J. Zhang in Synchrotron SOLEIL. The former manuals of Tracy are in the file folder
73``tracy/tracy/doc'' of the Tracy3 code.
74
75
76
77\begin{description}
78\item[Rotation angle]
79The user can define the design rotation angle 
80of the magnetic lattice element in the lattice file.
81\item{parameters of the lattice element: rotation, field, misalignment errors?}
82The user can define systematic
83and random rotation errors, the systematic and random displacement error, and systematic and random multipole field error
84of the lattice element in an external file (see section.~\ref{}), these
85variables can't be defined in the lattice file as an element parameters.
86
87\item{Simulation method: matrix or tracking?}
88There are two types of simulation in Tracy, Matrix method (Taylor's nonsymplectic map) and symplectic tracking. The default mode is the symplectic tracking. User can active the matrix mode by setting globval.MatMeth in the source code...(Need to update in the input script to active this mode. Be careful, during the
89lattice reading, the t2init() will active the tracking mode...)
90
91\item{Define RING or transfer line type in the lattice file}
92  in Lattice\_Read() of t2lat.cc, it seems like we can define a transfer line
93  in Tracy, using the variable V.Symmetry != 0, how to define a transfer line
94  in the lattice?  ANSWER: RingType = 1;  {define the ring}, or RingType = 0;
95 {define the transfer line}
96
97
98   The variable is: globval.RingType = 1/0, 1: ring, 0: transfer line.
99 
100\end{description}
101
102
103This code is kept on developing. Soleil version of Tracy 3 is a code with more flexibility and easy to use.  User does not need to know the structure of the code, what they need to do is to write an input script, and then run the code.
104
105   Based on the need, user can write the files to define multipole field errors, misalignment errors of the lattice elements, and vacuum chamber, and then provide the file name in the user input script, in order to set the field errors of the lattice elements and the vacuum limit for the different region of the lattice.
106Attention:
107In the user defined file, such as the user input script, the file to define multipole field errors or alignment errors, or the file to define vacuum chambers, the maximum numbers of column is 130 (Not including comment line which starts with symbol \#.), and the spaces between each parameters or variables can’t contain “TAB” key, otherwise the code can’t work properly. This is because the routine to read the user defined input file is written in C. These limits will be improved in the future development.
108Although the user can define the file name whatever they want,  it is suggested to name the file which is used to define multipole field error with the extension “.fe” and name the file which is used to define the misalignment error with the extension “.ae”.   
109
110  There are two versions of Tracy 3, non-parallel version and parallel version.  Non-parallel version Tracy is for the single computer, parallel version of Tracy is for the the cluster. The user defined input script which can be used for both parallel and non-parallel version Tracy. The ascii file with any extension isacceptable for Tracy3, but the extension is suggested to be “.prm”.
111
112\section{ Non-parallel version Tracy}
113\subsection {Compile}
114The make file of Tracy is generated by ``automake''. Based on the compilers used,
115user needs to update “\textsf{\wrapletters{make\_for\_gcc.sh}}” under
116path ``\pathfont{\$HOME/TracyIII/}''
117or the ``Makefile.am'' under path ``\pathfont{\$HOME/TracyIII/tracy/tracy/src}''
118and ``\pathfont{\$HOME/TracyIII/tracy/tools}''. The compilers used on the server
119``metis'' of SOLEIL Synchrotron are ``gfortran'', and ``gcc''.
120
121To compile the code, run the command under the shell terminal:
122\begin{tightcenter}
123 \textsf{make\_for\_gcc.sh}     \qquad   \textsf{opt} 
124\end{tightcenter}
125Then the executive file ``soltracy'' is automatically
126generated under path ``\pathfont{\$HOME/TracyIII/tracy/tools}''.   
127
128\subsection{Run}
129 To execute Tracy, the user needs to define an input file with the
130 the lattice file names and the related commands (section~\ref{}).
131 The name of the input file can be any valid characters. Although
132 there is no limitation to the extension of the file, the extension
133 ``.prm'' is preferred. For example, To run the user defined input file
134 ``Input\_test.prm'', user can type the command:
135\begin{tightcenter}
136  \textsf{soltracy}       \qquad        \textsf{Input\_test.prm}
137\end{tightcenter}
138
139\section{ Parallel version Tracy}
140In order to reduce the tracking time, the parallel version Tracy can be used
141on the cluster. Until now, the following three features of Tracy are
142parallelized:
143\begin{itemize} 
144\item 
145Frequency map analysis for on momentum particle, command ``FmapFlag''.
146\item 
147Frequency map analysis for off momentum particle, command ``FmapdpFlag''.
148\item 
149Track momentum acceptance at lattice elements, command ``MomentumAccFlag''.
150\end{itemize}
151
152\subsection{Compile}
153The commonly used compilers for parallel computation are MPI 2, and Intel
154MPI which is based on MPI 2. For the cluster of SOLEIL Synchrotron, Intel
155MPI is installed. To get the parallel Tracy work, three files of the
156non-parallel version Tracy need to be modified. The details are shown in
157the following steps.
158\begin{enumerate}
159\item
160The path of included files of Intel MPI is added in ``Makefile.am'' under
161path ``\pathfont{\$HOME/TracyIII/tracy/tracy/src}'' (shown in BLUE color):
162
163          \wrapletters{INCLUDES = -I../inc -I\$(NUM\_REC)/inc \quad
164          -I/opt/intel/impi/3.2.2.006/include64}
165
166\item
167 The execute file, source file, paths of included files and library of Intel
168MPI are modified in ``Makefile.am'' under path ``\pathfont{\$HOME/TracyIII/tracy/tools}''
169 (shown in BLUE color):
170
171bin\_PROGRAMS = psoltracy
172
173soltracy\_SOURCES  = \texttt{soltracy.cc  nrutil.c nrcheck.c    }
174\texttt{  nrlinwww.c   nrframe.c ../tracy/src/tracy\_lib.cc $\rightarrow$}
175
176  psoltracy\_SOURCES  = \texttt{psoltracy.cc  nrutil.c  nrcheck.c   
177  nrlinwww.c   nrframe.c   ../tracy/src/tracy\_lib.cc}
178
179  LIBS =  \texttt{\wrapletters{-L\$(NUM\_REC)/lib \quad
180          -L/opt/intel/impi/3.2.2.006/lib64   \quad -L\$(LIBPATH)  \quad
181          -lrecipes\_c\_icc \quad -lstdc++ \quad -lgfortran \quad -lmpichcxx}}
182 
183INCLUDES = \texttt{\wrapletters{-I\$(TRACY\_LIB)/tracy/inc \quad -I\$(NUM\_REC)/inc
184                   \quad  -I/opt/intel/impi/3.2.2.006/include64}}
185
186\item
187The compilers used in the parallel computing are defined in the
188``\wrapletters{make\_for\_psoltracy.sh}'' located in path ``\$HOME/TracyIII''
189as (shown in BLUE color):
190
191                 CC = \texttt{mpiicc}
192
193                CXX = \texttt{mpiicpc}
194
195                F77 = \texttt{mpiifort}
196
197Depending on the compilers used to do parallel computation, user needs to
198update the compilers in ``make\_for\_psoltracy.sh'' and the paths of included
199files and library which are shown above with blue color.
200
201After updating compilers, paths of included files and library for parallel
202computation, user can run
203\begin{tightcenter}
204\textsf{make\_for\_psoltracy.sh}
205\end{tightcenter}
206under the shell script to compile the parallel Tracy. After compilation,
207the execute file ``psoltracy'' is automatically generated under the
208path ``\pathfont{\$HOME/TracyIII/tracy/tools}''.
209\end{enumerate}
210
211
212\subsection{Run}
213As the non-parallel version Tracy, user needs to write the commands in a
214script which must be with the file extension ``.prm''. The syntaxes to define
215the script ``*.prm'' are the same for both non-parallel and parallel
216Tracy.
217
218To run the parallel Tracy, user need to contact the administrator of their
219cluster to know how to run parallel programs on the cluster. For the cluster
220on Synchrotron SOLEIL, the nodes used to do parallel computation are assigned
221by PBS (Portable Batch System), so a script is need. For example, user define
222the input script \texttt{test.prm} to tell Tracy what jobs are need to be done on the
223cluster,  define script \textsf{\wrapletters{lance\_tracy3\_parallel.sh}} to assign
224the numbers of CPUs to do
225parallel computation and lance job to the SOLEIL cluster; and then type the
226following command under the bash shell to submit the job and run the parallel
227Tracy on the cluster:
228\begin{tightcenter}
229  \textsf{lance\_tracy3\_parallel.sh  \qquad   test.prm}
230\end{tightcenter}
231
232
233\section{ User input script}
234There are two types of keywords in the user input script. The first type is
235to set the file, the file names, and define parameters for the related
236calculations; the key words for such definitions are ended with the
237characters ``Flag''. The second type is to define Boolean commands with or
238without parameters to do different calculations. The rules of the definition
239of input scripts are:
240\begin{itemize}
241\item
242The blank lines and lines starting with ``\#'' (comment line) are ignored
243by the code.
244\item
245Keywords without ``Flag'' as the final 4 characters are NOT executed according
246to the defined sequence in user input script. If the same command keywords
247are defined many times in the user script, only the last defined keyword is
248executed.
249\item
250The commands with the last 4 characters as ``Flag'' are executed according
251to the sequence in the code.
252\item
253The definition of lattice file at the beginning of the user script is mandatory.
254\item
255If the horizontal correctors, or vertical correctors, or girders, Beam Position
256Monitors, or skew quadrupoles are defined in the lattice file, user must
257declare the element name at the beginning of Tracy input file.
258\item
259One keyword command uses one line. User can not define more than one command
260at the same line.   
261\item
262Except explanation, all commands with Boolean flag are the generic commands,
263that is, the commands are not machine dependent.
264\end{itemize}
265
266\subsection{File path}
267In the user input script, user can specify the name of the files which are used
268in the calculation, such as the lattice file, multipole field error file,
269misalignment error file, vacuum chamber file. When specifying the file name without
270file path in the Tracy input file, Tracy will look for the file in the current
271work path. Otherwise, user need to provide the absolute path of the file which is
272not located at the current path, such as: ``\texttt{\wrapletters{/home/physmach/Tracy3/tracy/soleil.lat}}''.
273Another method is to provide the filename without absolute path, but put all the
274called external files at a certain directory, and this directory is defined in the
275Tracy input file using the command:
276                \tracycommand{in\_dir}{user\_defined\_path}
277For example,
278                \tracycommand{in\_dir}{/home/zhang/codes/TracyIII/lattice/}
279This example tells the code all the files defined with absolute file path in the Tracy
280input file are located
281at the directory \pathfont{/home/zhang/codes/TracyIII/lattice/}. If user declares the files
282without absolute path and does not set the directory through command \textsf{in\_dir}; or
283the files specified in the script are not found at the current working path,
284the code will give an error message and stop running.
285
286\section{File names}   
287
288\subsection{Lattice file name}
289In the input script, user must define the lattice name, this is mandatory.
290The command is:
291
292\tracycommand{lat\_file}{lattice\_file\_name}
293
294Here \tracypara{lattice\_file\_name} is the lattice file name without the extension ``.lat''.
295For example, the following command sets the lattice file of SOLEIL ring:
296\tracycommand{lat\_file}{solamor2}
297
298n Tracy 3, after reading the lattice, Twiss parameters are automatically printed to the
299file \textsl{linlat.out}.                                 
300 
301If one of these elements (Horizontal/vertical correctors or beam position monitors, or
302girders, or skew quadrupoles.) are defined in the lattice file, for example to read
303the misalignment errors of the lattice element and then do orbit correction, to read multipole
304field errors (SOLEIL lattice), etc.; user MUST specify the names of these elements using the
305corresponding commands in the Tracy input file:
306\tracycommand{h\_corr}{HCM}
307\tracycommand{v\_corr}{VCM}
308\tracycommand{gs}{GS}
309\tracycommand{ge}{GE}
310\tracycommand{bpm\_name}{BPM}
311\tracycommand{qt}{QT}
312Here \tracypara{HCM} is the name of horizontal correctors for horizontal orbit correction,
313or the horizontal correctors on which the multipole field errors are added in SOLEIL lattice;
314\tracypara{VCM} is the name of vertical correctors used for vertical orbit correction, or
315the vertical correctors on which the multipole field errors are added in SOLEIL lattice;
316\tracypara{GS} is the name of the start girder; \tracypara{GE} is the name of the end girder;
317\tracypara{BPM} is the name of beam position monitors defined in the lattice file; the
318                BPM acts as both horizontal BPM and vertical BPM.
319\tracypara{QT} is the name of the skew quadrupoles defined in the lattice.  Generally,
320user needs to define horizontal, vertical correctors and BPMs when reading the misalignment
321errors or correcting closed orbit distortion. 
322
323\subsection{Multipole field error file name (SOLEIL lattice)}
324User can read the multipole field errors on SOLEIL lattice from an external file;
325the file is specified in the user script using the following command:
326\tracycommand{multipole\_file}{multipole\_file\_name}
327Here \tracypara{multipole\_file\_name} is the user defined multipole field error file,
328the format of this file is given in section~\ref{}.
329
330If the multipole field errors of horizontal, vertical correctors and skew quadrupoles
331are defined in the \tracypara{multipole\_file}, user MUST specify the names of these
332lattice elements in the Tracy input file as the following example:
333\tracycommand{h\_corr}{CH}
334\tracycommand{v\_corr}{CV}
335\tracycommand{qt}{QT}
336Here \tracypara{CH}, \tracypara{CV} and \tracypara{QT} are the names of horizontal,
337vertical correctors, and skew quadrupoles respectively which are defined in the lattice file.
338
339\subsection{Files of multipole field errors of correctors and skew quadrupoles (SOLEIL lattice)}
340Horizontal, vertical correctors and skew quadrupoles are integrated with the sextupole quadrupoles
341on SOLEIL storage ring. To define the multipole field errors on these elements, user need to define the orders and relative strengths of multipole field errors in the multipole  field error file (section Error: Reference source not found) and specify the file name in the user input script “*.prm” (section Multipole field error file name), then specify the file names as the following example:
342\tracycommand{fic\_hcorr}{corh.txt}
343\tracycommand{fic\_vcorr}{corv.txt}
344\tracycommand{fic\_skew}{corqt.txt}
345Here \tracypara{corh.txt} and \tracypara{corv.txt} are the files with measured current values corh,
346corv, corqt (with unit [Ampere]) for the horizontal, vertical correctors and skew quadrupoles
347respectively. Based on the measured current values, user can get the integrated field strength as:\\
348\vspace{0.02in}
349\texttt{Hcorr\_strength [T.m] = corh *\_convHcorr /brho; (horizontal correctors) \\}
350\vspace{0.02in}
351\texttt{Vcorr\_strength [T.m] = corv *\_convVcorr /brho;  (vertical correctors)} \\
352\vspace{0.02in}
353\texttt{Qt\_strength [T.m] = corqt *\_convQt /brho;  (skew quadrupoles)} \\
354\vspace{0.02in}
355
356Here brho is the momentum rigidity, and the conversion constants between current and field are \texttt{\_convHcorr} = 8.14e-4, \texttt{\_convVcorr} = 4.642e-4, \texttt{\_convQt} = 93.83e-4.
357 
358For SOLEIL lattice, the SAME ORDER of multipole field errors on the same elements are added together,
359so the SAME ORDER of horizontal/vertical, skew quadrupoles, and sextupoles are added together since
360these elements are integrated at the same magnets.
361
362\subsection{ File to define field strength of virtual coupling source elements (SOLEIL lattice)}
363 On SOLEIL storage ring, the coupling is thought to come from the rotation of quadrupoles
364and vertical displacements of sextupoles. The strengths of these coupling sources are
365written in a file, then read by the following command:
366\tracycommand{virtualskewquad\_file}{virtual\_skew\_quad\_currents.txt}
367
368Here \tracypara{virtual\_skew\_quad\_currents.txt} is the user defined file with strength
369of vertical coupling source.
370
371In order to use this command to read the virtual sources of coupling, user needs to define
372the virtual coupling element as a skew quadrupole in the lattice file:
373\latticedef{SQ:}{quadrupole,}{tilt=45.0, K= 0.0, method=4, N=1;}
374and this virtual coupling element MUST be with the name “SQ”. Now there 152 elements defined as the virtual coupling sources in the SOLEIL lattice. The syntaxs to define skew quadrupole are explained in section .
375  The measured current value qtcorr[i] of the ith coupling source is converted to the corresponding integrated skew quadrupole field strength corr\_strength as
376corr\_strength [m-1] = qtcorr[i]*conv/brho;
377here brho is momentum rigidity, and the conversion constant conv is 93.88e-4 [A-1.T].
378
379\subsection{Cut off value}
380  Set the cut off value of all random distribution (Gaussian distribution) to “n” times of the RMS value sigma:
381normalcut       n
382
383\section{Physics: Hamiltionian}
384The lattice elements in Tracy can be classified into two types: drift and multipoles (thick or thin).
385
386The dynamic motion of a conserved system can be described by a Hamiltonian. For an accelerator system
387without radiation
388damping (energy loss) and RF cavities (energy gain), the motion of a single electron in the magnetic field can be described using the
389following Hamitonian in the curvilinear coordinate system (Merz...)
390\begin{eqnarray}
391H (x,P_x; y, P_y; -t, \delta; s) &=&  L + V  \\
392                                 &=& -(1+h_{\mathrm{ref}}x)[\sqrt(P^2 - (P_x - eA_x)^2 - (P_y - eA_y)^2 ) + eA_z(x,P_x; y, P_y,s)]  \\
393P^2 & =& P_x^2 + P_y^2 + P_z^2
394\end{eqnarray}
395$h_{\mathrm{ref}}$ is the curvature of reference orbit inside the dipole.
396The $(x,P_x; y, P_y; -t, \delta)$ are the canonical cooridinates of the $H$, and $P_x, P_y, P-z$ are respectively the
397horizontal, vertical, and longitudinal mechanical momentums. A more convienent way is to expand the electron motion
398around the motion of a reference particle with total momentum $P_0$, so
399\begin{eqnarray}
400\frac{1}{P_0}H (x,P_x; y, P_y; -t, \delta; s) &=& \\
401H (x,p_x; y, p_y; -t, \delta; s) &=& -(1+h_{\mathrm{ref}}x)\sqrt((1+\delta)^2 - (p_x - \frac{e}{P_0}A_x)^2 - (p_y - \frac{e}{P_0}A_y)^2 ) + \frac{e}{P_0}A_z(x,p_x; y, p_y,s) \\
402                                &=& -(1+h_{\mathrm{ref}}x)\sqrt((1+\delta)^2 - (p_x - \frac{1}{B \rho}A_x)^2 - (p_y - \frac{1}{B \rho}A_y)^2 ) + \frac{1}{B \rho}A_z(x,p_x; y, p_y,s)
403\end{eqnarray}
404with
405\begin{eqnarray}
406p_x &=& \frac{P_x}{P_0}  \\
407p_y &=& \frac{P_y}{P_0}  \\
408p &=& \frac{P}{P_0} = \frac{\Delta P + P_0}{P_0} = (1+\delta)   \\
409\delta &=& \frac{\Delta P}{P_0} \\
410B \rho &=& \frac{P_0}{e} (magnetic rigidity)
411\end{eqnarray}
412
413With some operations (J. Bengtsson's linear transverse dynamics for sotrage ring with applications to the low energy antiproton ring (LEAR) at CERN; Tracy 2 manual.),
414the Hamitonian can be expressed with the canonical coordinates $(x,p_x; y, p_y; -ct, \delta; s)$ (Tracy-2 Manual, J. Bengtsson)
415
416\begin{align*} 
417%\label{Tracy:Exact:H}
418H (x,p_x; y, p_y; -ct, \delta; s) \\
419&=-(1+h_{\mathrm{ref}}x)(\sqrt{(1+\delta)^2 - (p_x - \frac{A_x}{B \rho})^2 - (p_y - \frac{A_y}{B \rho})^2}  + \frac{A_z}{B \rho}) + \delta  \\ 
420&= -(1+h_{\mathrm{ref}}x)(\sqrt{(1+\delta)^2 - (p_x - \frac{A_x}{B \rho})^2 - (p_y - \frac{A_y}{B \rho})^2 }) + h_{\mathrm{ref}} x \frac{A_z}{B \rho}  \\
421& + \frac{A_z}{B \rho} + \delta  \\ 
422&= \underbrace{-(1+h_{\mathrm{ref}}x)\sqrt{(1+\delta)^2 - (p_x - \frac{A_x}{B \rho})^2 - (p_y - \frac{A_y}{B \rho})^2 )}}_\text{kinetic energy} \\
423& + \underbrace{\frac{x}{\rho} +\frac{x}{2\rho^2}}_\text{Gemometic components due to the curvilinear coordinate inside the dipole}\\ 
424& +\underbrace{\frac{A_z}{B \rho}}_\text{magnet contribution}  \\
425& +\underbrace{\delta}_\text{due to the canonical coordinate $-ct$ instead of $-t$}\\ 
426A_z & =A_z(x,p_x; y, p_y,s)
427\end{align*}
428
429The equation is the exact Hamitonian used in Tracy. The $A_x$ are due to the longidutinal fringe field, this is an natural results due to the Maxwell Equation; $h_{\mathrm{ref}}$ is not zero only inside the dipoles.
430
431For the system without fringe field of the magnet, or only consider the field inside the body of the magnet, $A_x = 0$ and $A_y = 0$,
432so the Hamiltonian is
433\begin{align}
434\label{eqn:exact:H:NoFF}
435H (x,p_x; y, p_y; -ct, \delta; s) \\
436&= \underbrace{-(1+h_{\mathrm{ref}}x)\sqrt{(1+\delta)^2 - p_x^2 - p_y^2)}}_\text{kinetic energy} \\
437& + \underbrace{\frac{x}{\rho} +\frac{x}{2\rho^2}}_\text{Gemometic components due to the curvilinear coordinate inside the dipole}\\ 
438& +\underbrace{\frac{A_z}{B \rho}}_\text{magnet contribution}  \\
439& +\underbrace{\delta}_\text{due to the canonical coordinate $-ct$ instead of $-t$}\\ 
440\end{align}
441
442From eqn.~\ref{eqn:exact:H:NoFF}, it is easy to get the map of the particle inside different lattice elements.
443
444
445\subsection{Map of drift}
446\label{H:drift}
447
448In the drift, $A_z = 0$, and $h_{\mathrm{ref}}$ = 0, from eqn.~\ref{eqn:exact:H:NoFF}, we can get the Hamiltonian
449inside a drift is
450\begin{align}
451\label{eqn:H:exact:drift}
452H (x,p_x; y, p_y; -ct, \delta; s) = -\sqrt{(1+\delta)^2 - p_x^2 - p_y^2)} + \delta
453\end{align}
454
455In large ring, in order to increase the tracking speed, we can expand the sqare root in
456eqn.~\ref{eqn:H:exact:drift} to get the approximate Hamitonian.
457That is,
458\begin{align}
459\label{eqn:H:approxi:drift}
460H (x,p_x; y, p_y; -ct, \delta; s) &= -(1+\delta) \left[ 1 - \frac{p_x^2 + p_y^2}{2 (1+\delta)^2} \right] + \delta\\
461                                  &= \frac{p_x^2 + p_y^2}{2(1+\delta)}
462\end{align}
463
464
465From eqn.~\ref{eqn:H:exact:drift}, it is easy to get the map inside the drift for the
466\textbf{small ring}:
467\begin{align}
468x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = \frac{p_{x0}}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\
469y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}= \frac{p_{y0}}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\ 
470(-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} =-\frac{1+\delta_0}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}}+1 \\
471or \\
472(ct)^{'} = \frac{1+\delta_0}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}}-1 \\
473p_x  = p_{x0} \\
474p_y  = p_{y0} \\
475\delta = \delta_0
476\end{align}
477
478From eqn.~\ref{eqn:H:approxi:drift}, it is easy to get the map inside the drift for the
479\textbf{big ring}:
480\begin{align}
481x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = \frac{p_{x0}}{1+\delta_0} \\
482y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}= \frac{p_{y0}}{1+\delta_0} \\ 
483(-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} =-\frac{p_{x0^2}+p_{y0}^2}{2(1+\delta_0)} \\
484or \\
485(ct)^{'} = \frac{p_{x0^2}+p_{y0}^2}{2(1+\delta_0)} \\
486p_x  = p_{x0} \\
487p_y  = p_{y0} \\
488\delta = \delta_0
489\end{align}
490
491\subsection{Map of mutipoles}
492 From eqn.~\ref{eqn:exact:H:NoFF}, we can get the Hamiltonian
493inside a multipole without fringe field is
494\begin{align}
495\label{eqn:H:exact}
496H (x,p_x; y, p_y; -ct, \delta; s) \\
497=& \underbrace{-\sqrt{(1+\delta)^2 - p_x^2 - p_y^2}+\delta}_\text{H drift} \\
498& \underbrace{-h_{\mathrm{ref}}x \sqrt{(1+\delta)^2 - p_x^2 - p_y^2}}_\text{H kick} \\
499& + \underbrace{\frac{x}{\rho} +\frac{x}{2\rho^2}-\frac{A_z}{B \rho}}_\text{H kick} 
500\end{align}
501
502In eqn.~\ref{eqn:H:exact}, the Hamiltonian is decomposed into two part, one is the Hamiltonian
503of the drift which is due to the kinetic energy of the system (section~\ref{H:drift}), another part is the kick
504due to the multipoles which will give the kick to the particle.
505Now we only need to focus on the Hamiltonian of the multipoles which induces the kick map:
506\begin{align}
507\label{eqn:H:exact:multipole}
508H (x,p_x; y, p_y; -ct, \delta; s) \\
509&=-h_{\mathrm{ref}}x \sqrt{(1+\delta)^2 - p_x^2 - p_y^2} \\
510& +\frac{x}{\rho} +\frac{x}{2\rho^2}-\frac{A_z}{B \rho}
511\end{align}
512
513Similarly, by expand the sqare root in eqn.~\ref{eqn:H:exact}, we can get the approximate Hamiltonian
514of the multipole as
515\begin{align}
516\label{eqn:H:approxi:multipole}
517H (x,p_x; y, p_y; -ct, \delta; s) \\
518&=-h_{\mathrm{ref}}x \sqrt{(1+\delta)^2 - p_x^2 - p_y^2} \\
519& +\frac{x}{\rho} +\frac{x}{2\rho^2}-\frac{A_z}{B \rho} \\
520&=-h_{\mathrm{ref}} x \delta + \frac{1}{2}h_{\mathrm{ref}} h_{B} x^2 - \frac{A_z}{B \rho}+(h_B - h_{\mathrm{ref}})x
521\end{align}
522where $h_{\mathrm{ref}}$ is the curvature due to the curlininear coordinates inside the dipole,
523$h_{\mathrm{ref}} = 1/\rho_{ref}$;
524$h_{\mathrm{bend}}$ is due to the bending curvature of the dipole which is determined by the dipole
525field, $h_{\mathrm{bend}} = 1/ \rho_{bend}$. $h_{\mathrm{ref}} \neq 0$ only inside dipoles.
526
527In the dipole, $A_z \neq 0$, and $h_{\mathrm{ref}} \neq $ 0, so
528from eqn.~\ref{eqn:H:exact:multipole}, we can get the kick map due to the dipole
529in the \textbf{small ring} which use the exact Hamiltonian:
530\begin{align}
531\label{eqn:kickmap:exact}
532x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = h_{\mathrm{ref}} x_0 \frac{p_{x0}}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\
533y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}=  h_{\mathrm{ref}} x_0 \frac{p_{y0}}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\ 
534p_x^{'}  = -\frac{\partial H}{\partial y_0} = h_{\mathrm{ref}} \sqrt{(1+\delta_0)^2 - p_{x0}^2 - p_{y0}^2} - h_{\mathrm{bend}} - h_{\mathrm{ref}}h_{\mathrm{bend}}x - \frac{B_y}{B \rho}\\
535p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
536(-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} =-h_{\mathrm{ref}} x_0 \frac{1+\delta_0}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\
537or \\
538(ct)^{'} = h_{\mathrm{ref}} x_0 \frac{1+\delta_0}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\
539\delta = \delta_0 \\
540B \rho = \frac{p_0}{e}
541\end{align}
542where
543\begin{align}
544\frac{\partial A_z}{\partial x} = - B_y \\
545\frac{\partial A_z}{\partial y} = B_x
546\end{align}
547since
548\begin{align}
549A_x = 0 \\
550A_y =0
551\end{align}
552inside the body of the multipoles, and
553\begin{align*}
554\vec{B} = \Delta \times \vec{A}  \\
555\hat{x} & \hat{y} & \hat{z} \\
556\frac{\partial}{x} &  \frac{\partial}{y} &  \frac{\partial}{z} \\
557A_& A_y & A_z \\
558\end{align*}
559
560
561In the dipole, $A_z \neq 0$, and $h_{\mathrm{ref}} \neq $ 0, so
562from eqn.~\ref{eqn:H:approxi:multipole}, we can get the kick map due to the dipole
563in the \textbf{big ring} which use the exact Hamiltonian:
564\begin{align}
565\label{eqn:kickmap:approxi}
566x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = h_{\mathrm{ref}} x_0 \frac{p_{x0}}{1+\delta_0} \\
567y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}=  h_{\mathrm{ref}} x_0 \frac{p_{y0}}{1+\delta_0} \\ 
568p_x^{'}  = -\frac{\partial H}{\partial y_0} = h_{\mathrm{ref}} \delta_0 - (h_{\mathrm{bend}} - h_{\mathrm{ref}}) - h_{\mathrm{ref}}h_{\mathrm{bend}}x - \frac{B_y}{B \rho}\\
569p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
570(-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} =\frac{-h_{\mathrm{ref}} x_0}{1+\delta_0} \frac{-(p_{x0}^2+p_{y0}^2)}{2(1+\delta_0)} \\
571or \\
572(ct)^{'} =-\frac{h_{\mathrm{ref}} x_0}{1+\delta_0} \frac{(p_{x0}^2+p_{y0}^2)}{2(1+\delta_0)} \\ 
573\delta^{'} = 0
574\end{align}
575
576For other multipoles (quadrupoles, sextupole, decapole, octupole, etc), the curvilinear coordinate is
577the cartesian coordinates, that is $h_{ref}$ = 0, so from eqn.~\ref{eqn:kickmap:exact}, the kick map for
578these multipoles in the small ring is: 
579\begin{align}
580\label{eqn:kickmap:exact:multipole}
581x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = 0 \\
582y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}=  0 \\
583p_x^{'}  = -\frac{\partial H}{\partial y_0} = - (h_{\mathrm{bend}} + \frac{B_y}{B \rho})\\
584p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
585(-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} = 0\\
586or \\
587(ct)^{'} = 0 \\
588\delta^{'} = 0
589\end{align}
590
591With $h_{ref} = 0$, from eqn:~\ref{eqn:kickmap:approxi}, the kick map for these
592multipoles (quadrupoles, sextupole, decapole, octupole, etc) in the big ring is:
593\begin{align}
594\label{eqn:kickmap:approxi:multipole}
595x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = 0 \\
596y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}=  0 \\
597p_x^{'}  = -\frac{\partial H}{\partial y_0} = - (h_{\mathrm{bend}} + \frac{B_y}{B \rho})\\
598p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
599(-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} = 0\\
600or \\
601(ct)^{'} = 0 \\
602\delta^{'} = 0
603\end{align}
604
605From the eqn~\ref{eqn:kickmap:exact} to eqn.~\ref{eqn:kickmap:approxi:multipole}, it's clear
606that the kick map from the main body of dipoles are different in the small ring and big ring;
607while the kick map from the main body of other type of multipoles are the same in small
608rings and big rings.
609
610
611
612
613
614
615
616
617\section{Magnetic field}
618
619A. Dragt ....(Lie methods for acceleator........)
620
621\section{FF of dipole}
622\subsection{kick map}
623E. Forest ...........
624
625\section{FF of quadrupole}
626\subsection{kick map}
627
628
629\section{Machine mode}
630\subsection{Transfer line}
631Tracy can simulate the transfer line (TL), to calculate some features
632of this type of the machine, for example, to transfer the twiss functions
633and the orbits. User can define the TL type in the lattice file
634using the command:
635\tracycommand{RingType = 0}{}
636
637Since the symplecticity is not important to the transfer map of a
638TL, the twiss functions and orbits of a TL is calculated using
639a 6-dimensional (6D) linear Taylor transfer matrix.
640
641\begin{itemize}
642\item The initial phase of the TL is 0.
643\item The initial parameters of the TL (alpha, beta, mu, and orbit) are
644      defined in the file ``soleilcommon.cc''.
645      Maybe these parameters can be defined in the lattice file or ``*.prm''
646      in the future.
647\item The calculated optical functions at i-th lattice element can be called
648      using: Cell[i] $\rightarrow$ Alpha, Cell[i] $\rightarrow$ Beta,
649      Cell[i]$\rightarrow$ Nu,Cell[i] $\rightarrow$ Eta,
650      Cell[i] $\rightarrow$ Etap.
651\item The optical functions (alpha, beta, mu), orbits will be automatically
652      calculated and saved in the file ``cod.out''.
653\item
654If the BPMs are defined in the lattice file, and the BPMs names are declared
655in the ``*.prm'' file with the command:
656\tracycommand{bpm\_name}{BPMs names}
657then the 6D orbits at the BPM positions will be saved in the
658file ``6Dcod.out''.
659\item See also section \ref{sec:general:files}.
660\end{itemize}
661
662Called functions: Cell\_Twiss\_M() in t2ring.cc.
663
664The functions with ``...M()'' are for the transfer line.
665
666\subsection{Ring}
667User can define the ring type in the lattice file using the command:
668\tracycommand{RingType = 1}{}
669
670If this machine type is not defined, then the default machine type
671is ring.
672
673\begin{itemize}
674\item
675The momentum compaction factor is calculated and printed to the terminal.
676\item
677 The twiss functions, and COD files will be automatically printed to
678a file ``cod.out''.
679\item
680If the BPMs are defined in the lattice, and the BPMs names are declared
681in the ``*.prm'' file using the command:
682\tracycommand{bpm\_name}{BPM names}
683
684then the 6D closed orbit at the position of the BPMs will be saved in
685a file ``6Dcod.out''.
686\item 
687See also section \ref{sec:general:files}.
688\end{itemize}
689
690\section{General print files}
691\label{sec:general:files}
692
693After reading the lattice file, Tracy will print several files with the general informations of
694the lattice.
695\subsection{*.sum}
696 This file is with the same name as the lattice file but with the file extertion ``*.sum''.
697 This file is with the information:
698
699
700\begin{flushleft}
701\textbf{general inforamtion} \\
702\end{flushleft}
703
704\begin{tabular}{l l l}
705  dPcommon     =  1.000e-10 &dPparticle   =  0.000e+00 &Energy [GeV] = 0.050\\
706  MaxAmplx [m] = 0.000e+00 &MaxAmply [m] = 0.000e+00 &RFAccept [\%] = +/- 100.00 \\
707  MatMeth      =  FALSE&      Cavity\_On    =  FALSE&Radiation\_On = FALSE\\
708  bpm          =  0    &                         qt           = 0 & \\ 
709  hcorr         =  0   &                        vcorr        =  0 & \\
710  Chambre\_On   = FALSE&            &  \\     
711  alphac       =   0.0000e+00 & & \\
712  nux          =   1.382583 &     nuy  =  0.859382 & \\
713  ksix         =    0.000000&      ksiy  =   0.000000 &  \\
714\end{tabular}
715
716
717\begin{description}
718\item[dPcommon]: relative energy spread.
719\item[dPparticle]:
720\item[Energy]: beam energy [GeV].
721\item[MaxAmplx]: maximum horizontal aperture size.
722\item[MaxAmply]: maximum vertical aperture size.
723\item[RFAccept [\%]]: RF acceptance.
724\item[MatMeth]: use linear transfer matrix or tracking? True/false.
725\item[Cavity\_On]: with RF cavity or not?
726\item[Radiation\_On]: synchrotron radiation is on or off?
727\item[bpm]: number of BPMs. If the user doesn't specify the name of the BPM
728  in the ``*.prm'' file, then this value is 0, it means that Tracy think
729  there is no BPMs defined in the lattice? (need to check...)
730\item[qt]: number of skew quadrupoles. If the user doesn't specify the name
731   of the qt in the ``*.prm'' file, then this value is 0, it means that
732   Tracy think there is no skew quadrupoles defined in the lattice? (need to
733check...)
734\item[hcorr]: number of horizontal correctors. If the user doesn't specify the name of the hcorr in the
735            ``*.prm'' file, then this value is 0, it means that Tracy think there
736            is no horizontal correctors defined in the lattice? (need to check...)
737\item[vcorr]: number of vertical correctors. If the user doesn't specify the name of the vcorr in the
738            ``*.prm'' file, then this value is 0, it means that Tracy think there
739            is no vertical correctors defined in the lattice? (need to check...)
740\item[Chambre\_On]: read the vacuum chamber definition from an external file? If it is true, then
741                    an external file with the definition of the vacuum chamber aperture must
742                    be defined in the ``*.prm'' file.
743\item[alphac]: first order momentum compaction factor. For a transfer line, this variable is 0.
744\item[nux]: horizontal phase advance for a transfer line; horizontal tune for the ring. This
745            variable is normalized by 2$\pi$.
746\item[nuy]: vertical phase advance for a transfer line; vertical tune for the ring. This
747            variable is normalized by 2$\pi$.
748\item[ksix]: horizontal chromaticity. This variable is only valid for a ring; it is 0 for a transfer line.
749\item[ksiy]: vertical chromaticity. This variable is only valid for a ring; it is 0 for a transfer line.
750\end{description}
751
752This file also has the 6$\times$6 transfer matrix (one turn map for a ring):
753
754\begin{flushleft} 
755\textbf{OneTurn matrix}: \\
756matrix:
757\end{flushleft}
758
759\begin{tabular}{l l l l l l}
760 -1.397484e+00&   1.028931e+01&   0.000000e+00&   0.000000e+00&  -1.089759e-02&   0.000000e+00\\
761 1.025593e-01&  -1.470689e+00&   0.000000e+00&   0.000000e+00&   1.695979e-01&   0.000000e+00\\
762 0.000000e+00&   0.000000e+00&   5.943899e-01&  -5.866019e+00&   0.000000e+00&   0.000000e+00\\
763 0.000000e+00&   0.000000e+00&   5.043746e-01&  -3.295264e+00&   0.000000e+00&   0.000000e+00\\
764 0.000000e+00&   0.000000e+00&   0.000000e+00&   0.000000e+00&   1.000000e+00&   0.000000e+00\\
765 0.000000e+00&   0.000000e+00&   0.000000e+00&   0.000000e+00&   0.000000e+00&   0.000000e+00\\
766 & & & & & \\
767\end{tabular}
768\\
769
770Finally, the twiss parameters at the entrance of the first element is saved:
771\begin{flushleft}
772\textbf{Twiss parameters at entrance}:\\
773\end{flushleft}
774
775\begin{tabular}{l l l l}
776   Betax [m] =  8.100e+00&  Alphax = -0.000e+00& Etax [m] =  0.000e+00& Etaxp =  0.000e+00\\
777   Betay [m] =  8.100e+00&  Alphay = -0.000e+00& Etay [m] =  0.000e+00& Etayp =  0.000e+00\\
778\end{tabular}
779
780\subsection{Twiss file}
781This file is with the twiss functions at the end of all lattice elements,
782the file name is the same as the lattice file name, but with the file extension
783``*.twi''.
784
785\begin{tabular}{l l l l l l l l l l l l} 
786name & s & alphax & betax & nux & etax & etapx & alphay & betay & nuy & etay & etapy \\
787     &[m]&        & [m]   &     & [m]  &       &        & [m]   &     & [m]  &       \\
788     &   &        &       &     &      &       &        &       &     &      &        \\
789\end{tabular}
790where
791\begin{description}
792\item[name]: name of the lattice element.
793\item[$s$ [m]]: longitudinal position of the element.
794\item[alphax $\alpha_x$]: horizontal alpha.
795\item[betax $\beta_x$ [m]]: horizontal beta functions.
796\item[betay $\beta_y$ [m]]: vertical beta functions.
797\item[etax $\eta_x$ [m]]: horizontal linear dispersion funciton.
798\item[etay $\eta_y$[m]]: vertical linear dispersion funciton.
799\item[etapx $\mathrm{d} \eta_x /mathrm{d}s$]: horizontal linear dispersion
800           funciton $\eta_x$ with respective to longitudinal coordinate $s$.
801\item[etapy $\mathrm{d} \eta_y /mathrm{d}s$]: vertical linear dispersion
802           funciton $\eta_y$ with respective to longitudinal coordinate $s$.
803\item[nux $\nu_x$]: horizontal phase advance of the transfer line, or
804                    horizontal tune of the ring.
805                    This value is normalized by $2 \pi$.
806\item[nuy $\nu_y$]: vertical phase advance of the transfer line, or
807                    vertical tune of the ring.
808                    This value is normalized by $2 \pi$.
809\end{description}
810
811\subsection{Lattice elements property file}
812Each time when running Tracy, the design values of lattice
813elements will be printed to the file ``flat\_file.dat''.
814This file is a very important file to check the Tracy is
815correctly running.
816
817The printed properties of one lattice element are (also see MML)
818different for the elment type: drift and multipoles (thick or thin).
819
820
821
822
823\begin{flushleft}
824\textbf{\color{blue}{drift}}:
825\end{flushleft}
826
827
828\begin{flushleft}
829\textbf{1st line:} \\
830Name; familylist number;  \\
831kid number; \\
832index number in the lattice, for example, ``1'' means the first element; \\
833
834\textbf{2nd line}:
835type; method, N  \\
836
837
838\textbf{type:} type of the lattice element defined in Tracy: \\
839
840\begin{tabular}{l l}
841 marker     &     -1 \\
842 drift      &     0\\
843 multipole  &     1\\
844 cavity     &     2\\
845 thin kick  &     3\\
846 wiggler    &     4\\
847 kick\_map  &      6\\
848\end{tabular}
849
850
851\textbf{method:} symplectic integration method.
852        For drift, method = 0. \\
853
854
855\textbf{N:}   number of pieces of the elements to be cut.
856     For drift, N = 0. \\
857
858
859
860\textbf{3rd line:}
861MaxamplX0, MaxamplX1, MaxamplY0, MaxamplY1. \\
862\begin{tabular}{r l}
863MaxamplX0: & minimum horizontal aperture size;\\
864MaxamplX1: & maximum horizontal aperture size;\\
865MaxamplY0: & minimum vertical aperture size;\\
866MaxamplY1: & maximum vertical aperture size;\\
867\end{tabular}
868
869\textbf{4th line:} 
870Element length. \\
871
872
873
874
875\textit{For example:}  \\
876
877\begin{tabular}{l l l l}
878 sd1l       &        1  &  1  &   2 \\
879   0  &  0 &   0 & \\
880  0.000e+00 & 0.000e+00 &  0.000e+00 &  0.000e+00 \\
881  2.000e-01 & & & \\
882\end{tabular}
883\end{flushleft}
884
885
886\begin{flushleft}
887\textbf{\color{blue}{multipoles:}}
888
889Depending on the elements length, the printed information of thick
890and thin multipoles are different. But both types of multipoles have
891the following general informations as the drift: \\
892
893\textbf{1st line:} \\ 
894Name; familylist number;  kid number; index number in the
895lattice, for example, ``1'' means the first element;\\
896
897Name: element name. \\
898
899
900
901\textbf{2nd line:} 
902type; method, N
903
904\textbf{type:} type of the lattice element defined in Tracy: \\
905\begin{tabular}{l l}
906 marker   &      -1\\
907 drift    &       0\\
908 thick multipole &      1\\
909 cavity    &      2\\
910 thin multipole &     3\\
911 wiggler       &  4\\
912 kick\_map     &   6\\
913\end{tabular}
914
915\textbf{method:} symplectic integration method defined in the lattice, or
916        the default method for this element.\\
917
918\textbf{N:}   number of pieces of the elements to be cut defined in the
919     lattice or the default value ``1''.\\
920
921\textbf{3rd line:} 
922MaxamplX0, MaxamplX1, MaxamplY0, MaxamplY1.\\
923
924\begin{tabular}{r l}
925MaxamplX0:& minimum horizontal aperture size;\\
926MaxamplX1:& maximum horizontal aperture size;\\
927MaxamplY0:& minimum vertical aperture size;\\
928MaxamplY1:& maximum vertical aperture size;\\
929\end{tabular}
930
931\textbf{For a thick multipoles,}  \\
932\textbf{4th line:} 
933DsX, DsY, PdTpar, PdTsys, PdTrms*PdTrnd. \\
934
935
936\textbf{DsX:} horizontal displacement error of the element. \\
937\textbf{DsY:} vertical displacement error of the element. \\
938\textbf{PdTpar:} total designed rotation angle [degree]. \\
939\textbf{PdTsys:} systematic designed rotation angle  \\
940        defined in the lattice.[degree]. \\
941\textbf{PdTrms*PdTrnd:} random rotation errors of the element multiplied
942        by a scale factor PdTrnd. The default value of
943        PdTrnd is 0.  \\
944
945\textbf{For a thin multipole:} \\
946\textbf{4th line:} 
947DsX, DsY, PdTsys+ PdTrms*PdTrnd.\\
948
949\textbf{DsX:} horizontal displacement error of the element. \\
950\textbf{DsY:} vertical displacement error of the element.\\
951\textbf{PdTsys + pdTrm*PdTrnd:} 
952The sum of the systematic field components and random multipole field
953components, field components of the same order are added.\\
954\textbf{PdTsys:} systematic designed rotation angle
955        defined in the lattice.[degree].\\
956\textbf{PdTrms*PdTrnd:} random rotation errors of the element multiplied
957        by a scale factor PdTrnd. The default value of
958        PdTrnd is 0.  \\
959
960   
961
962\textbf{5th line:}  PL, Pirho, PTx1, PTx2, PH1, PH2, Pgap \\
963
964\begin{tabular}{l p{10cm}}
965PL: & length of the element [m]. \\
966Pirho: & curvature of the radius of the dipole,1/rho [1/m]. Pirho
967       denotes the
968       bending angle of the dipole, since Pirho = $\frac{\theta}{180}*\pi/L$\\
969PTx1: & entrance angle of the dipole, [degree].\\
970PTx2: & exit angle of the dipole, [degree].\\
971PH1: & bending curvature of the entrance pole face of dipole, [degree].\\
972PH2: & bending curvature of the exit pole face of dipole, [degree].\\
973Pgap: & full dipole gap, [m].   \\
974\end{tabular}
975
976The definitions of PTx1, PTx2, PH1, PH2, Pgap can be found on P116 SAC-75.
977
978\textbf{6th line:}
979nmpole, n\_design \\
980
981\begin{tabular}{l p{10cm}}
982nmpole: & multipole field order of the element. The value is 0 for dipole. \\
983n\_design:& design order of the multipole field of the element. \\
984\end{tabular}
985
986The value of n\_design is: \\
987\begin{tabular}{l l}
9880: & All \\
9891: & dipole (n = 1).\\
9902: & quadrupole (n = 2).\\
9913: & sextupole (n = 3).\\
9924: & octupole (n = 4).\\
9935: & decuple (n = 5). \\
9946: & dodecapule (n = 6).\\
995\end{tabular}
996
997\textbf{
9987th line and then:}
999i, HOMmax+i,  HOMmax-i \\
1000
1001\begin{tabular}{l l }
1002i: & multipole field order of the element. \\
1003HOMmax+i: & normal multipole field components, normalized by $B\rho$.\\
1004HOMmax-i: & skew multipole field components, normalized by $B\rho$.\\
1005\end{tabular}
1006\textbf{Notes}:\\
1007\begin{itemize}
1008\item For a dipole element, there is no multipole field components.
1009      This is due to the kick map from the expanded Hamiltonian,
1010      the vector component of the dipole is treated separated from
1011      other multipoles, and the contribution of the dipoles are
1012      included in the curvature of radius of the dipole $1/rho$.
1013
1014\item The non-zero multipole field components will be printed from 1-th order to
1015      the maximum order Porder.
1016\end{itemize}
1017
1018
1019\textit{For example:} \\
1020
1021\begin{tabular}{ l l l l l l l}
1022bend1       &      17  &  1 &  15 & & & \\
1023     1 &  4 &  4 & & & &\\
1024  0.0000e+00 &  0.0000e+00 & 0.0000e+00 & 0.0000e+00 & & & \\
1025  0.0000e+00 &  0.0000e+00 & 0.0000e+00 &  0.0000e+00 & & & \\
1026  2.7645e-01 & 2.8409e+00 &  0.0000e+00 &  0.0000e+00 & 0.0000e+00 &  0.0000e+00 & 0.0000e+00 \\
1027    0 & 1 & & & & & \\
1028     &  & & &  & & \\
1029\end{tabular}
1030
1031
1032\begin{tabular}{ l l l l l l l}
1033sx1         &      22  &  1 &  13 \\
1034   1  &  4 &   4 & \\
1035  0.0000e+00 & 0.0000e+00 & 0.0000e+00 &  0.0000e+00& & &  \\
1036  0.0000e+00 & 0.0000e+00 & 0.0000e+00 & 0.0000e+00& & & \\
1037  9.9999e-07 & 0.0000e+00 & 0.0000e+00 & 0.0000e+00 & 0.0000e+00 &   0.0000e+00 & 0.0000e+00 \\
1038   1 & 3 & & & & & \\
1039   3 & -8.9672e+06&  0.0000e+00& & & & \\
1040\end{tabular}
1041
1042\end{flushleft}
1043
1044\begin{flushleft}
1045\textbf{Cavity} \\
1046 RF cavity.
1047\end{flushleft}
1048
1049
1050\textbf{1st line:}
1051Name; familylist number;  kid number; index number in the
1052lattice, for example, ``1'' means the first element; \\
1053
1054\textbf{2nd line:} type; method, N   \\
1055
1056\textbf{type:} type of the lattice element defined in Tracy:  \\
1057 cavity          2
1058
1059\textbf{method:} symplectic integration method defined in the lattice, or
1060        the default method for this element.\\
1061
1062\textbf{N:}   number of pieces of the elements to be cut defined in the
1063     lattice or the default value ``1''.\\
1064
1065\textbf{3rd line:} 
1066MaxamplX0, MaxamplX1, MaxamplY0, MaxamplY1.\\
1067
1068\begin{tabular}{l l}
1069MaxamplX0:& minimum horizontal aperture size;\\
1070MaxamplX1:& maximum horizontal aperture size;\\
1071MaxamplY0:& minimum vertical aperture size;\\
1072MaxamplY1:& maximum vertical aperture size;\\
1073 & \\
1074\end{tabular}
1075
1076\textbf{4th line:}
1077Pvolt/energy, 2*pi*Pfreq/co, phase, energy. \\
1078
1079\begin{tabular}{l l}
1080Pvolt/energy:& RF voltage normalized by beam energy [eV].  \\
10812*pi*pfreq/c0:& RF frequency normalized by the speed of light. \\ 
1082phase:& RF phase [degree]. \\
1083energy:& beam energy [eV].\\
1084& \\
1085\end{tabular}
1086
1087\begin{flushleft}
1088\textbf{marker} \\
1089\end{flushleft}
1090
1091\textbf{1st line:}
1092Name; familylist number;  kid number; index number in the
1093lattice, for example, ``1'' means the first element;\\
1094
1095\textbf{2nd line: }
1096type; method, N  \\
1097 
1098
1099type: type of the lattice element defined in Tracy:
1100marker   -1
1101
1102\textbf{3rd line:} 
1103MaxamplX0, MaxamplX1, MaxamplY0, MaxamplY1.\\
1104
1105\begin{tabular}{l l}
1106MaxamplX0:& minimum horizontal aperture size;\\
1107MaxamplX1:& maximum horizontal aperture size;\\
1108MaxamplY0:& minimum vertical aperture size;\\
1109MaxamplY1:& maximum vertical aperture size;\\
1110& \\
1111\end{tabular}
1112
1113
1114\textit{For example:}\\
1115 \begin{tabular}{l l l l}
1116debut     &        56 &   1 &   1\\
1117  -1 &  0 &  0 & \\
1118  0.0000e+00 & 0.0000e+00 & 0.0000e+00 & 0.0000e+00 \\
1119\end{tabular}
1120
1121\begin{flushleft}
1122\textbf{wiggler}: \\
1123\textbf{insertion device}:
1124\end{flushleft}
1125
1126
1127
1128
1129\subsection{File of the ring closed orbit or orbit of the transfer line}
1130The horizontal and vertical closed orbits of the ring lattice or the orbits
1131of the transfer line
1132at all lattice elements are be printed to the file ``cod.out''.
1133
1134The user can also choose to print the orbit at the position of BPM, but
1135the name of the BPM must be defined at the beginning of the ``*.prm'' file,
1136since both the horizontal and vertical orbits will be printed at the BPM position,
1137it is only needed to define a general BPM in the lattice file.
1138
1139\begin{tabular}{ l l l l l l l l l l l l l l}
1140   i &name &s& code & betax & nux & betay & nuy & xcod & ycod & dSx & dSy & dipx & dipy\\
1141\end{tabular}
1142
1143\begin{tabular}{l p{10cm}}
1144i: & lattice element index. \\
1145name: & name of the lattice element.\\
1146s: & longitudinal position of the element [m].\\
1147code:& code type of the element.  \\
1148               & drift:         0.0 \\
1149              & dipole:          0.5 \\
1150              & focusing quadrupole:  1 \\
1151              & defocusing quadrupole:  -1 \\
1152              &focusing sextupole: 1.5 \\
1153              & defocusing sextupole:  -1.5 \\
1154              & bpm:      2.0; \\
1155               & only when the name of the bpms are defined in
1156                              the ``*.prm'' file, this value is 2.0, otherwise
1157                              Tracy will not find them. \\
1158              others:  &  0.0 \\
1159betax:& horizontal beta function [m].\\
1160nux: & horizontal tune (normalized by $2 \pi$).\\
1161betay:& vertical beta function [m].\\
1162nuy: & vertical tune (normalized by $2 \pi$).\\
1163xcod:& horizontal closed orbit, [mm]. \\
1164ycod:& vertical closed orbit, [mm].\\
1165dSx:& horizontal displacement error, [mm].\\
1166dSy:& vertical displacement error, [mm].\\
1167dipx:& horizontal kick angle, only valid for horizontal correctors, [mrad].\\
1168dipy:& vertical kick angle, only valid for vertical correctors, [mrad].\\
1169 & \\
1170\end{tabular}
1171
1172\textit{For example:} \\
1173\begin{tabular}{l l l l l l l l l l l l l l }
1174\multicolumn{14}{l}{drift:} \\
11752& sd5& 0.78& 0.0&  3.873&  0.033&  2.137&  0.065& -0.002&  0.000&  0.000&  0.000& -0.000&  0.000\\
1176\hline
1177\multicolumn{14}{l}{quadrupole:} \\
11785& qp1& 0.93& -1.0&  4.403&  0.039&  2.035&  0.076& -0.002&  0.000&  0.000&  0.000& -0.000&  0.000\\
1179\hline
1180\multicolumn{14}{l}{dipole:} \\
118110& dip& 2.16&  0.5&  0.126&  0.196&  7.446&  0.148&  0.001&  0.000&  0.000&  0.000& -0.000&  0.000\\
1182\hline
1183\multicolumn{14}{l}{corrector:} \\
118414 & ch01& 2.29&  0.0&  0.127&  0.420&  8.950&  0.150&  0.001&  0.000&  0.000&  0.000&  0.010&  0.000\\
1185\hline
1186\multicolumn{14}{l}{defocusing sextupole:} \\
118719& sx3&  2.59& -1.5&  2.566&  0.523&  7.225&  0.155&  0.005&  0.000&  0.000&  0.000& -0.000&  0.000 \\
1188\hline
1189\multicolumn{14}{l}{focusing sextupole:} \\
119027& sx2&  3.06&  1.5&  9.603&  0.535&  2.375&  0.176&  0.010&  0.000&  0.000&  0.000& -0.000&  0.000\\
1191\end{tabular}
1192
1193
1194
1195
1196\subsection{6-Dimensional (6D) closed orbit or 6D orbit of the transfer line}
1197If the BPMs are defined in the lattice, and the BPM names are defined
1198in the user input file ``*.prm'' using the command:
1199\tracycommand{bpm\_names}{BPMx}
1200
1201then Tracy will print out the 6D closed orbit of the ring or the 6D orbit
1202of the transfer line at the locations of the BPMs to a file ``6Dcod.out''.
1203The printed parameters are:
1204
1205i     name  s     x   px    y   py   delta ct
1206
1207\begin{description}
1208\item[i]: index of the lattice element.
1209\item[name]: name of the lattice element.
1210\item[s]: longitudinal position of the element, [m].
1211\item[x]: horizontal orbit at the end of the element, [mm].
1212\item[px]: derivative of the horizontal orbit $x$ with respective to $s$ at the end of the element.
1213\item[y]: vertical orbit at the end of the element, [mm].
1214\item[py]: derivative of the vertical orbit $y$ with respective to $s$ at the end of the element.
1215\item[delta]: energy spread.
1216\item[ct]: longitudinal displacement with respective to the reference particle.
1217\end{description}
1218
1219\textit{For example:}\\ 
1220\begin{tabular}{l l l l l l l l l}
1221 3&     bpmx&  7.75e-01& -2.09e-03&  1.53e-03&  0.00e+00&  0.00e+00&  0.00e+00&  9.16e-13 \\
1222\end{tabular}
1223
1224
1225\section{Lattice file}
1226In the lattice, RF cavity with the correct harmonic number must be defined!!!
1227Otherwise Tracy will give the error message:
1228\textcolor{red}{Elem\_GetPos: there are no kids in family 0 ()}. This obigatory is for the
1229correct calculation of positive/negtive momentum compaction factor.
1230To deactive the RF cavity, the cavity voltage can be defined as 0.
1231
1232
1233The followings are the rules to define a lattice file used in Tracy 3. The curvelinear coordinates are
1234used. \textbf{The ideal particle or design particle sees the perfect magnetic field in all magnets, and its}
1235\textbf{orbit is used as the reference orbit and base of the curvilinear coordinate}. Since the reference orbit
1236is a curve inside the dipoles and a straight line in other lattice elements (drifts and the magnets except
1237dipoles), so the length of the dipole is the the path length of the reference particle inside the dipole
1238which is equal to $\rho*\theta$ where $\rho$ is the bending radius of the dipole and $theta$ is the bending angle
1239with unit [rad], and all the other magnet lengths are the straight length of the magnets.
1240
1241Due to the same reason, the curvature of the curvilinear cooridnates h = 1/$\rho$ is not zero only inside dipole;
1242in other magnets and drift h = 0, and the curvilinear coordinates goes to cartesian cooridnates.
1243As a result, the independent variable $s$ inside the dipole harmitonian is the arc length, while the staight
1244length in other lattice elements.
1245
1246\subsection{Lattice}
1247The $n^{th}$ field component of the lattice element is defined as in Tracy (n = 1, 2, 3, 4 ...):
1248\begin{eqnarray*}
1249b_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_y }{\partial x ^{n-1}}|_{x=0,y=0} \\
1250a_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_x }{\partial x ^{n-1}}|_{x=0,y=0} \\
1251B \rho & = & \frac{p_0}{e}
1252\end{eqnarray*}
1253$B \rho$ is the magnetic rigidity, $p_0$ is the design beam momentum, $e$ is the electric charge.
1254For example, for sextupole,  n = 3, so $b_3$ and $a_3$ are defined as
1255\begin{eqnarray*}
1256b_3 & = & \frac{1}{B \rho} \frac{1}{2} \frac{\partial^{2} B_y }{\partial x ^{2}}|_{x=0,y=0} \\
1257a_3 & = & \frac{1}{B \rho} \frac{1}{2} \frac{\partial^{2} B_x }{\partial x ^{2}}|_{x=0,y=0} 
1258\end{eqnarray*}.
1259
1260 \notespace{NOTES:} 
1261In \textbf{AT} (Accelerator Toolbox) and \textbf{BETA} code, the definition of are the same as in \textbf{Tracy}.
1262While In \textbf{MAD8}, \textbf{MADX} and \textbf{ELEGANT}, the order of the field compoent start from 0, that is
1263n = 0, 1, 2, 3, ..., and the $n^{th}$ field strength components of the lattice element $b_n$ and $a_n$ are defined as
1264\begin{eqnarray*}
1265b_n & = & \frac{1}{B \rho} \frac{\partial^{n} B_y }{\partial x ^{n}}|_{x=0,y=0} \\
1266a_n & = & \frac{1}{B \rho} \frac{\partial^{n} B_x }{\partial x ^{n}}|_{x=0,y=0} \\
1267B \rho & = & \frac{p_0}{e}
1268\end{eqnarray*}
1269For example, for sextupole,  n = 3, its field component $b_2$ and $a_2$ are defined as
1270\begin{eqnarray*}
1271b_2 & = & \frac{1}{B \rho} \frac{\partial^{2} B_y }{\partial x ^{2}}|_{x=0,y=0} \\
1272a_2 & = & \frac{1}{B \rho} \frac{\partial^{2} B_x }{\partial x ^{2}}|_{x=0,y=0} 
1273\end{eqnarray*}.
1274
1275
1276                               
1277\subsection{Syntax}
1278Every line embraced by “{}” is comment line. For example:
1279
1280          {*****drift space *****} 
1281
1282Each sentence is ended by ‘;’ or no punctuation.
1283Tracy is not sensitive to capital/small letters in the lattice.
1284User can define any lattice element with any valid name (but must start with a character) they want, but the element type is fixed.
1285For the lattice of the ring, the definition of RF cavity is mandatory, and the harmonic number of the RF cavity is also mandatory; for the lattice of the linac, the definition of the RF cavity is optional.
1286
1287\subsection{Variables}
1288  User can define variables in the lattice file. For example:
1289\begin{tightcenter}
1290                   \textsf{Intmeth = 4};
1291\end{tightcenter}
1292Then when the code is running,  the variable \textsf{intmeth} in the lattice
1293file will be replaced by \textsf{4}.
1294
1295Tracy accept math operation. For example,
1296\latticedef{DL1: }{drift,}{L = 0.1*2 + 0.1-0.01;}
1297
1298\subsection{Start line}
1299  The lattice file must begin with the sentence:
1300\begin{tightcenter}
1301                \textsf{define} \quad    \textsf{lattice};
1302\end{tightcenter}
1303This definition is mandatory.
1304
1305\subsection{Global variables}
1306 After define the ring, user needs to define the system parameters of the lattice:
1307\begin{tabular}{l p{10cm}}
1308\textbf{RingType = 1/0;} & define the machine type: ring or transfer line. 1 defines the ring, 0 defines the transfer line. This variable definition is optional, the default machine type is ring. \\
1309\textbf{Energy = ;} & the beam energy with unit [GeV]. This variable definition is
1310mandatory. \\
1311\textbf{dP = ;} & the relative momentum offset of the particle. This variable defintion is mandatory. \\
1312\textbf{CODeps = ;} & the convergence for the algorism to find the closed orbit. This variable definition is mandatory. \\
1313\end{tabular}
1314
1315\vspace{0.05in} 
1316\begin{flushleft}
1317\textit{Example:} \\
1318\end{flushleft}
1319\begin{tabular}{r c l}
1320      Energy &= & 2.739; \\
1321      dP    & = & 1.0d-10; \\
1322     CODeps & = & 1.0d-15; \\
1323\end{tabular}
1324
1325\subsection{DRIFT}
1326
1327                  \latticedef{Name:}{drift,}{L = $\langle \dots \rangle$;}
1328
1329\begin{table}[htbp]
1330\centering
1331\caption{Parameters of dipole in the lattice file.}
1332\label{tab:dipole-para}
1333%\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.1\linewidth} | p{0.6\linewidth} |}
1334\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1335\hline
1336\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description}    \\
1337\hline
1338\textbf{L}  & [m]     & 0.0 & Length.  \\ 
1339\hline
1340\end{tabular}
1341\end{table}
1342The definition of the length of a drift is mandatory.
1343
1344\vspace{0.05in} 
1345\textit{Example:}
1346                      \latticedef{SD1a:}{drift,}{L= 0.900000;}
1347
1348\subsection{DIPOLE}
1349
1350\latticedef{Element\_name:}{bending,}{L = $\langle \dots \rangle$, T = $\langle \dots \rangle$,
1351T1 = $\langle \dots \rangle$, T2=$\langle \dots \rangle$,
1352H1 = $\lbrack \dots \rbrack$, H2= $\lbrack \dots \rbrack$,
1353gap = $\lbrack \dots \rbrack$, edge\_effect1 = $\lbrack \dots \rbrack$
1354edge\_effect2 = $\lbrack \dots \rbrack$, K =$\lbrack \dots \rbrack$,
1355method = $\langle \dots \rangle$, N = $\langle \dots \rangle$;}
1356 
1357
1358
1359 \begin{table}[tbp]
1360 \centering
1361 \caption{Parameters of dipole in the lattice file.}
1362 \label{tab:dipole-para}
1363%% \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|l|c|c|p{0.4\linewidth}|}
1364\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1365 \hline
1366 \textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description}    \\
1367 \hline
1368 \textbf{L}       & [m] & 0.0             &  Curved path length of
1369  the design particle inside the dipole. L = $\rho * \theta$, where $\rho$ is the
1370  bending radius of the dipole, and $\theta$ is the bending angle of the dipole.   \\
1371  \hline
1372 \textbf{T}     &[degree] & 0.0          & Total bending angle                      \\
1373 \hline
1374 \textbf{T1}    &[degree] & 0.0 & Entrance angle                            \\
1375  \hline
1376\textbf{T2}    &[degree] & 0.0 & Exit Angle \\
1377\hline
1378\textbf{K}     &   L $\neq$ 0, m$^{-2}$. \newline  L = 0, m$^{-1}$. & 0.0
1379               & L $\neq$ 0, quadrupole field strength; \newline L = 0, integrated field strength. \\
1380\hline                                             
1381\textbf{Method}  & - & 4 &   1,2,4. Symplectic integration method. The
1382            value ``1'' means $1^{\mathrm{st}}$ order, ``2'' means $2^{\mathrm{nd}}$ order,
1383           and ``4'' means $4^{\mathrm{th}}$ order.    \\ 
1384\hline
1385\textbf{Gap}    &[m] & 0.0 &   Distance between two poles of the dipole,
1386            the gap size determine the fringe field. If the gap size is 0, then the dipole has
1387            no fringe field (\textcolor{red}{??????}).   \\ 
1388\hline
1389\textbf{edge\_effect1} & - & 0 & 1/0.
1390                ``1'' to turn on the edge focusing effect and the fringe field at the entrance of
1391                  the dipole. ``0'' to turn off the two effects. \\
1392\hline
1393 \textbf{edge\_effect2} & - & 0 & 1/0. ``1'' to turn on the edge focusing effect and the
1394  fringe field at the exit of the dipole. ``0'' to turn off the two effects. \\
1395\hline 
1396\textbf{N}      & - & 1 &  number of cut slices. \\
1397 \hline
1398 \end{tabular}
1399 \end{table}
1400
1401\vspace{0.05in} 
1402\textit{Example}:\\
1403\vspace{0.05in}
1404\textsf{beta\_gap=37e-3; tracy\_gap=beta\_gap*2*0.724;}
1405\latticedef{BEND1 :}{ bending,}{L = 1.05243, T = 11.25, T1 = 5.5906,
1406T2 = 5.67658, K = 0.00204, gap=tracy\_gap,
1407edge\_effect1 = 1, edge\_effect2 = 1, N = 4,
1408method = intmeth;}
1409
1410
1411 \begin{figure}
1412\includegraphics[width=0.8\linewidth]{bend_curve}
1413\caption{Field boundaries of the dipoles. $T1$
1414                is the entrance angle; $T2$ is the exit angle; $H1$ is
1415                the radius of curvature of the entrance pole face; $H2$ is
1416                for the exit pole face; $\rho$ is the local radius of the
1417                design
1418                orbit in the dipole.}
1419\label{fig:bend_curve}
1420\end{figure}
1421
1422
1423\vspace{0.05in}
1424\textbf{Attention:}
1425\begin{itemize}
1426\item 
1427The bending magnet in Tracy is a symplectic element.
1428The independent variable $s$ inside the dipole harmitonian is the arc length,
1429so the length of the dipole is defined the curved path length of the design
1430particle inside the dipole.
1431\item 
1432One can refer to the definition of $T1$,$T2$, $H1$, $H2$ on page 116 of SLAC-75 for more
1433information.
1434\item
1435In the lattice files of ELEGANT, MADX and BETA, the dipole angles are defined with the unit [rad].
1436But in TRACY, the unit is [degree].
1437\item
1438BETA dipole gap is the Elegant gap; but Tracy dipole gap is different from
1439the definition in both BETA and Elegant.
1440Tracy definition of dipole with fringe field: \\
1441\textsf{
1442beta\_gap=0.04;
1443{tracy\_gap=beta\_gap*2*1/6;}
1444{Due to the Tanh-like fringe field, K1=0.2, and tracy\_gap = beta\_gap *2* FINT (K brown para.)}
1445tracy\_gap = beta\_gap*2*0.348;}
1446
1447\begin{tabular}{l l l l l l l}
1448 DIP: & bending, & L=0.27646, &T= 45,& T1=0,& T2=0, gap=tracy\_gap, \\
1449& edge\_effect1=1, &edge\_effect2=1,&method=intmeth,& N=4; & &  \\
1450& & & & & & \\
1451\end{tabular} 
1452
1453\textbf{Elegant} definition of dipole with dipole fringe field: \\
1454\textsf{DIP:   csbend, N\_KICKS=100, INTEGRATION\_ORDER=4, L=0.27646, angle= 0.785398, E1=0, E2=0, hgap=0.02, Fint=0.348, nonlinear=1, edge1\_effects=2, edge2\_effects=2, edge\_order=2;}
1455\end{itemize}
1456
1457\subsection{QUADRUPOLE}
1458\textbf{Definition:} \\
1459\latticedef{Element\_Name:}{ quadrupole,}{ L = $\lbrack \dots \rbrack$, tilt = $\lbrack \dots \rbrack$,
1460                            K =$\lbrack \dots \rbrack$, FF1 =  $\lbrack \dots \rbrack$,       
1461                            FF2= $\lbrack \dots \rbrack$, FFscaling =  $\lbrack \dots \rbrack$,
1462                            method = $\lbrack \dots \rbrack$, N= $\langle \dots \rangle$;}
1463
1464\begin{table}[htbp]
1465\centering
1466\caption{Parameters of quadrupoles in the lattice file.}
1467\label{tab:quad-para}
1468\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1469\hline
1470\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description}    \\
1471\hline
1472         L & [m] &  0.0 & Length of the quadrupole \\
1473\hline
1474        Tilt & [degree] & 0.0  & tilt angle of the quadrupole.
1475                                 If ‘tilt’ is non-zero, then the
1476                                 quadrupole is a skew quadruple. \\
1477\hline
1478       K &  L $\neq$ 0, [m$^{-2}$]. \newline L = 0, [m$^{-1}$]. & 0.0 &  L $\neq$ 0, Gradient
1479$\frac{\frac{\partial B_y }{\partial x}}{B \rho}$; \newline  L = 0, integrated field strength
1480$\frac{\frac{\partial B_y }{\partial x} L }{B \rho}$. \\
1481  \hline                 
1482   FF1 & - & 0  & 1 or 0. \newline 
1483                   1: to avtive fringe field at the left edge. \textsf{QuadFringeOnFlag}
1484   should be set in the Tracy input file. 0: left fringe field off. \\
1485\hline
1486   FF2 & - & 0  & 1 or 0. \newline 
1487                   1: to avtive fringe field at the right edge. \textsf{QuadFringeOnFlag}
1488   should be set in the Tracy input file. 0: right fringe field off. \\
1489\hline
1490FFscaling & - & 1 & Scaling factor of the dipole fringe field. \\
1491\hline
1492Method & - & 4 & 1,2,4. Order of symplectic integration method. 
1493Value ``1'' means 1st order, ``2'' means 2nd order, and ``4'' means 4th order. \\
1494\hline
1495N & - & 1 & Pieces of the quadrupole to be cut when it is treated in the code. \\
1496\hline
1497\end{tabular}
1498\end{table}
1499
1500
1501
1502Example: \\
1503
1504\textsf{Nq=8/2; dgsurg=1.00; dgsurgL=1.00; quadfringe=1.0; LQC=0.3602;}
1505\latticedef{QP1a:}{quadrupole,}{ L=LQC/2, K= -1.073038*dgsurg, FF1=quadfringe, FF2=0,
1506              FFscaling =1, method=intmeth, N=Nq;}
1507
1508The parameters of “quadrupole” are optional, the default value for “method” is 4, the default value for “FFscaling” is 1, the default value for the other parameters are 0.
1509
1510\subsection{SKEW QUADRUPOLE}
1511
1512The skew quadrupole is a quadrupole with a 45 [degree] tilt angle. For example:
1513\latticedef{QT:}{quadrupole,}{tilt=45.0, K= 0.0, method=intmeth, N=1;}
1514
1515\notespace{NOTES:} 
1516If skew quadrupoles are defined in the lattice file with a name \tracypara{skewquad},
1517User must specify the name of  skew quadrupole in the tracy input file using
1518the commands:
1519\tracycommand{qt}{skewquad} 
1520
1521\subsection{SEXTUPOLE}
1522
1523\latticedef{Element\_Name:}{sextupole,}{L = $\lbrack \dots \rbrack$, K = $\lbrack \dots \rbrack$,
1524 FF1 = $\lbrack \dots \rbrack$, FF2=$\lbrack \dots \rbrack$,method = $\lbrack \dots \rbrack$,
1525 N=$\lbrack \dots \rbrack$;}
1526
1527
1528 \begin{table}[htpb]
1529 \centering
1530 \caption{Parameters of sextupoles in the lattice file.}
1531 \label{tab:sext-para}
1532\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1533\hline
1534\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description} \\
1535\hline
1536\textbf{L}        [m] &   & 0.0 & Length\\
1537\hline
1538\textbf{K}         &L $\neq$ 0, [m$^{-3}$]. \newline L = 0, [m$^{-2}$]. & 0.0 &
1539                   If L $\neq$ 0,
1540                   $= \frac{1}{2} \frac{1}{B \rho} \frac{\partial^{2} B_y }{\partial x ^{2}}|_{x=0,y=0}$,   
1541                     $B \rho$ is the magnetic rigidity, $p_0$ is the design beam momentum,
1542                     $e$ is the electric charge. If L = 0, K is the integrated field
1543             strength $L\frac{1}{2} \frac{1}{B \rho} \frac{\partial^{2} B_y }{\partial x ^{2}}|_{x=0,y=0}$ \\   
1544\hline
1545 \textbf{FF1}      & - & 0 & \textbf{1} or \textbf{0}. \textbf{1}: tringe on the fringe field at the
1546                      left edge. \textbf{0}: tringe off the fringe field at the     
1547                      left edge.\\
1548 \hline
1549 \textbf{FF2}      & - & 0 & \textbf{1} or \textbf{0}. \textbf{1}: tringe on the fringe field at the
1550                      right edge. \textbf{0}: tringe off the fringe field at the     
1551                      right edge.\\
1552 \hline
1553 \textbf{Method}   & - & 4 & \textbf{1},\textbf{2},\textbf{4}. Order of symplectic integration method.       
1554                      \textbf{1}: 1st order; \textbf{2}: 2nd order; \textbf{4} 4th order. \\
1555 \hline
1556 \textbf{N}       & - & 1 &  Pieces of this element to be cut, used in the symplectic   
1557                      integration. \\
1558
1559 \hline
1560 \end{tabular}
1561 \end{table}
1562
1563
1564
1565\textit{Example:} \\
1566\textsf{NqSx=1; coef=1.0/0.16; method4sextu = 4; sextfringe = 0;} 
1567\latticedef{SX1:}{sextupole,}{ L=0.16, K =  1.719190*coef, method=method4sextu, N = NqSx,
1568                              FF1=sextfringe, FF2=sextfringe;}
1569
1570The parameters of “sextupole” are optional, the default value for “method” is 4,
1571the default value for the other parameters is 0.
1572
1573
1574\notespace{NOTES:} 
1575
1576In \textbf{AT} (Accelerator Toolbox) and \textbf{BETA} code, the european notation of
1577the order of magnetic field is used. That is n = 1, 2, 3, ...n; and the definition of
1578K are the same as in \textbf{Tracy}.
1579While In \textbf{MAD8}, \textbf{MADX} and \textbf{ELEGANT}, the U.S. notation of the
1580order order of the field is used, that is n = 0, 1, 2, 3, ..n. For sextupole,  n = 2,
1581and its gradient is defined as
1582\begin{equation*}
1583K_2  =  \frac{1}{B \rho} \frac{\partial^{2} B_y }{\partial x ^{2}}|_{x=0,y=0} 
1584\end{equation*}
1585
1586\subsection{MULTIPOLE}
1587
1588\latticedef{Element\_Name:}{Multipole,}{L= $\lbrack \dots \rbrack$, T =$\lbrack \dots \rbrack$,
1589               T1=$\lbrack \dots \rbrack$, T2=$\lbrack \dots \rbrack$,
1590tilt=$\lbrack \dots \rbrack$, HOM = (i, $\langle$ $b_i$ $\rangle$, $\langle$ $a_i$ $\rangle$,
1591j, $\langle$ $b_j$ $\rangle$, $\langle$ $a_j$ $\rangle$,
.$n$, $\langle$ $b_n$ $\rangle$, $\langle$ 
1592$a_n$ $\rangle$), $N$ =$\lbrack \dots \rbrack$$\langle$, method =$\lbrack \dots \rbrack$;}
1593
1594\begin{table}[htpb]
1595\centering
1596\caption{Parameters of the multipoles.}
1597\label{tab:mult-para}
1598\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1599\hline
1600\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description} \\
1601\hline
1602\textbf{L}         & [m] & 0.0 & Length \\
1603\hline
1604\textbf{T}         & [degree] & 0.0  & Total bending angle \\
1605\hline
1606\textbf{T1}        & [degree] & 0.0 & Entrance angle \\
1607\hline
1608\textbf{T2}        & [degree] & 0.0 & Exit Angle \\
1609\hline
1610\textbf{Tilt}      & [degree] & 0.0 & Rotation angle of the quadrupole; if \tracypara{Tilt}
1611                     is non-zero, then the quadrupole is a skew quadruple.???? \\
1612\hline
1613\textbf{HOM}       & - & (0, 0, 0) & Multipole field components of the element. The format
1614                     is \textit{n}, \textit{$b_{n}$}, \textit{$a_n$}, etc. \newline 
1615                     \textit{n} is order of the multipole
1616                     field in U.S. notation (?????), n=1 (dipole field),
1617                     n=2 (quadrupole field), n=3 (sextupole field),
1618                     n=4 (octuple field), n=5 (decuple field).
1619                     \textit{$b_n$} is $n^{\mathrm{th}}$ component of the upright multipole
1620                     field with the unit [$\frac{1}{m^{-n}}$];
1621                     \textit{$a_n$} is $n^{\mathrm{th}}$ component
1622                      of the skew multipole field with the
1623                      unit [$\frac{1}{m^-n}$]. \\
1624\hline
1625\textbf{N}         & - & 1 & Pieces of this element to be cut \\
1626\hline
1627\textbf{Method}    & - & 4 & 1,2,4. Symplectic integration method.
1628                      1 is $1^{\mathrm{st}}$ order, 2 is $2^{\mathrm{nd}}$ order, 4 is
1629                      $4\mathrm{th}$ order. \\
1630\hline
1631\end{tabular}
1632\end{table}
1633
1634The multipole field components $a_n$ and $b_n$ are defined as
1635\begin{eqnarray}   
1636\begin{aligned}
1637b_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_y }{\partial x ^{n-1}}|_{x=0,y=0} \\
1638a_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_x }{\partial x ^{n-1}}|_{x=0,y=0} \\
1639B \rho & = & \frac{p_0}{e}
1640\end{aligned}
1641\end{eqnarray}
1642$B \rho$ is the magnetic rigidity, $p_0$ is the design beam momentum, $e$ is the electric charge.
1643
1644If the magnetic field $\vec{B^{tip}}$ is measured at the location with the radius $r_0$, then
1645$b_n$ and $a_n$ are defined as
1646\begin{eqnarray*}
1647b_n & = & \frac{1}{B \rho} \frac{B_y^{tip}}{r_0^{n-1}}\\
1648a_n & = & \frac{1}{B \rho} \frac{B_x^{tip}}{r_0^{n-1}} \\
1649\vec{B^{tip}} & = & B_y^{tip} \hat{y} +  B_x^{tip} \hat{x} 
1650\end{eqnarray*}
1651
1652 The $n^{th}$ order magnetic field is
1653 \begin{equation}
1654 B_y^n + i * B_x^n = (b_n + i*a_n) * (x + i*y)^n
1655 \end{equation}
1656 The total magnetic field with $1^{st}$ to $n^{th}$ order field components can be calculated using 
1657 \begin{equation}
1658\label{eqn:total:field}
1659\begin{aligned}
1660 B_y + i * B_x &= (b_n + i*a_n) * (x+i*y)*(x + i*y)^{n-1} + O(n-1) \\
1661               &=  [(b_n*x - a_n*y) + b_{n-1} + i*(a_n*x + b_n*y + a_{n-1})]*(x+i*y)^{n-1} \\
1662             +& O(n-2) \\
1663              +&...
1664\end{aligned}
1665 \end{equation}
1666
1667
1668
1669
1670The eqn.~\ref{eqn:total:field} is used in Tracy3 to calculate the effective fields of the
1671magnet. This equation clearly shows that, all the field errors gives the same effect the
1672beam: horizontal focusing and vertical decusing. But since the field strength of the
1673$n^{th}$ order magnet is proportial to the $n^{th}$ order of $x/y$ and $x/y$ at the
1674entrance of the magnet is small, so the higher $n$ is, the weak of the $n^{th}$ order
1675multipole field is.
1676
1677\vspace{0.05in}
1678\textit{Example 1: }
1679
1680\latticedef{B:}{multipole,}{L=0.70, T=10.0, T1=5.0, T2=5.0, HOM = (1, -1.0, 0), N=8, Method=2;}
1681
1682In this example, the multipole is a dipole with field component  $b_1$ = -1.0, or the
1683field strength is $B_{y0}$, and the field direction is down. This field gives a horizontal
1684focusing to the electron.
1685
1686\vspace{0.05in}
1687\textit{Example 2:} 
1688
1689 \latticedef{QF:}{multipole,}{L=0.70, HOM = (1, 2.50, 0.0, 4, 1.01e7, 0.0), N=8, Method=4;}
1690
1691In this example, the multipole is a dipole with $4^{th}$ order upright multipole filed errors (octupole),
1692and $b_4$ = 1.01e7. 
1693
1694To add multipole errors in the defined lattice files, user can also define the multipoles
1695inside an external file (Section~\ref{sec:mult:field:error}) (???? To be checked, can this
1696routine mesured with the general one???).
1697
1698 \notespace{NOTES:} \\
1699In \textbf{AT} (Accelerator Toolbox) and \textbf{BETA} code, the definition of are the same
1700as in \textbf{Tracy}. While In \textbf{MAD8}, \textbf{MADX} and \textbf{ELEGANT}, the order
1701of the field compoent start from 0, that is n = 0, 1, 2, 3, ..., and the $n^{th}$ field
1702strength components of the lattice element $b_n$ and $a_n$ are defined as
1703\begin{eqnarray*}
1704b_n & = & \frac{1}{B \rho} \frac{\partial^{n} B_y }{\partial x ^{n}}|_{x=0,y=0} \\
1705a_n & = & \frac{1}{B \rho} \frac{\partial^{n} B_x }{\partial x ^{n}}|_{x=0,y=0} \\
1706B \rho & = & \frac{p_0}{e}
1707\end{eqnarray*}
1708
1709\subsection{SOLENOID (to be updated)}
1710
1711\subsection{WIGGLER (To be updated.)}
1712
1713\latticedef{Element\_Name:}{Wiggler,}{L  = $\langle$ length $\rangle$,BoBrhoV = $\langle$ B/Brho $\rangle$,
1714BoBrhoH = $\langle$ B/Brho $\rangle$, Lambda  = $\langle$ period $\rangle$,kxV= $\langle$ [m] $\rangle$,kxH     = $\langle$ [m] $\rangle$,phi     = $\langle$ phase $\rangle$,
1715               harm(n, kxV, BoBrhoV, kxH, BoBrhoH, phi), N = $\langle$ no of integration steps $\rangle$,
1716               Method  = $\langle$ method $\rangle$;}
1717
1718
1719\begin{table}[htbp]
1720\centering
1721\caption{The parameters of wigglers in a lattice file.}
1722\label{tab:wiggler-para}
1723\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1724\hline
1725\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description} \\
1726\textbf{L} & [m] & 0.0 & Length \\ \hline
1727\textbf{BoBrhoV} & ??? & ??? & the normalized vertical field \\ \hline
1728\textbf{BoBrhoH} & ??? & ??? &  the normalized horizontal field \\ \hline
1729\textbf{Labmda} & [m] & ??? & period length  \\ \hline
1730\textbf{kxV} & [m] & ??? & ??? \\ \hline
1731\textbf{kxH} & [m] & ??? & ??? \\ \hline
1732\textbf{phi} & [degree] & ??? & ??? \\ \hline
1733\textbf{harm} & ??? & ??? & ??? \\ \hline
1734\textbf{N} & - & - & No of integration steps \\ \hline
1735\textbf{Method} & - & - &  Symplectic integration method.
17361 is 1st order, 2 is 2nd order, 4 is 4th order.\\
1737\hline
1738\end{tabular}
1739\end{table}
1740
1741\vspace{0.05in}
1742\textit{ Example 1:}
1743\latticedef{U143:}{wiggler,}{L=4.80, K=0.5, Lambda=0.15, N=20, Method=0;}
1744
1745\vspace{0.05in}   
1746\textit{Example 2:}
1747\latticedef{EPU:}{wiggler,}{L=4.80, Lambda=0.15, N=20, Method=0,
1748                                 harm=(3, kxV\_3, BoBrhoV\_3, kxH\_3, BoBrhoH\_3, phi\_3);}
1749
1750\subsection{FIELD MAP (To be updated

..)}
1751
1752\latticedef{Element\_Name:}{Fieldmap,}{L = $\langle$ length [m] $\rangle$, N = $\langle$ 
1753            no of integration steps $\rangle$, file1 = $\langle$ file name (lower case) $\rangle$};
1754
1755\begin{table}[htbp]
1756\centering
1757\caption{Parameters of field map in the lattice file.}
1758\label{tab:fieldmap-para}
1759\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1760\hline
1761\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description} \\
1762\hline
1763\textbf{L} & [m] & 0.0 & Length \\ \hline
1764\textbf{L} & [m] & 0.0 & Length of the field map \\ 
1765\hline
1766\textbf{N} & - & ??? & the number of integration steps \\
1767\hline
1768\textbf{file1} & - & ??? & field map file \\
1769\hline
1770\end{tabular}
1771\end{table}
1772
1773\vspace{0.05in}
1774\textit{Example:}
1775\latticedef{FM:}{Fieldmap,}{L = 1.0, N = 20, file1 = "U19\_Bxyz.dat";}
1776
1777
1778\subsection{INSERTION DEVICE (to be updated)}
1779
1780\latticedef{Element\_Name:}{insertion,}{scaling1 = 1/0, scaling2=1/0,method = interpolation\_method,
1781         N=Number of slice, file1 = name of the file with 1st order radia map, 
1782         file2 = name of the file with 2nd order radia map;}
1783
1784\begin{table}[htbp]
1785\centering
1786\caption{Parameters of the insertion devices.}
1787\label{tab:insertiondevice-para}
1788\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1789\hline
1790\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description} \\
1791\textbf{scaling1} & - & ??? &  scaling factor for the 1st order field map \\
1792\hline
1793\textbf{scaling2} & - & ??? &  scaling factor for the 2rd order field map \\
1794\hline
1795\textbf{method} & - & ??? & 1, 3. The order of symplectic interpolation method. 1 is linear
1796  interpolation, 3 is spline interpolation.\\
1797\hline
1798\textbf{N} & - & ??? & pieces of this element is cut when it is treated in the code \\
1799\hline
1800\textbf{file1} & - & ??? & The 1st order of insertion device field are read from the
1801files generated by RADIA. If user does not specify the file name with the file path,
1802then the code will look for the files in the current working directory. The path of
1803the Radia map file must be in small letters, otherwise the code can’t find the file. \\
1804\hline
1805\textbf{file2} & - & ??? & 
1806The 2nd order of insertion device field are read from the files generated by RADIA.
1807If user does not specify the file name with the file path, then the code will look
1808for the files in the current working directory. The path of the Radia map file must
1809be in small letters, otherwise the code can’t find the file. \\
1810\hline
1811\end{tabular}
1812\end{table}
1813
1814\vspace{0.05in}
1815\textit{Example:}
1816 \latticedef{WIGSLIC:}{insertion,}{N = 10, scaling1=1.0, scaling2=1.0, method=2, file1="/home/sources/physmach/tracy2.7/w150g11pole60\_oppose\_radia\_pour\_tracy.txt", file2= "/home/sources/physmach/brunelle/tracy-2.7/w150g11pole20\_fin.dat";}
1817     
1818 All the parameters for ‘insertion’ is optional, the default value for scaling1 and scaling2 are 1,
1819the default ‘method’ is 3 which means spline interpolation, the default ‘N’ is 1, the default
1820values for all the other parameters are 0.
1821
1822\subsection{RF CAVITY}
1823
1824\latticedef{Element\_Name}{cavity,}{Frequency = RF frequency, Voltage = RF voltage, Phase = synchrotron 
1825                           Phase, harnum = harmonic number of the RF cavity;}
1826
1827
1828\begin{table}[htbp]
1829\centering
1830\caption{Parameters of RF cacity.}
1831\label{tab:RFCavity-para}
1832\begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
1833\hline
1834\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description} \\
1835\hline
1836\textbf{frequency} & [Hz] & ??? &  RF frequency  \\
1837\hline
1838\textbf{voltage} & [Volt] & ??? &  RF voltage  \\
1839\hline
1840\textbf{phase} & [degree] & ??? & synchrotron phase \\
1841\hline
1842\textbf{harnum} & - & ??? & harmonic number \\
1843\hline
1844\end{tabular}
1845\end{table}
1846
1847
1848\vspace{0.05in}
1849\textit{Example:}
1850\latticedef{CAV:}{Cavity,}{Frequency = 499.95e6, Voltage=1.22e6, phase = 30, harnum=328;}
1851
1852To calculate the stable phase for the lattice with positive or negative
1853momentum compaction factor, the definition of the harmonic number of the
1854RF cavity is mandatory. The other parameters of RF cavity are
1855optional, and their default values are 0.
1856
1857\subsection{CORRECTOR}
1858
1859\latticedef{Element\_Name:}{corrector,}{horizontal/vertical, L = , kick = , roll = ,
1860           N = , method = integrated method;}
1861
1862\begin{table}[htbp]
1863\centering
1864\caption{Parameters of correctors.}
1865\label{tab:corrector-para}
1866\begin{tabular}{| p{0.2\linewidth} | p{0.1\linewidth} | p{0.2\linewidth} | p{0.4\linewidth} |}
1867\hline
1868\textbf{Parameter Name}    &  \textbf{Units}      &\textbf{Default}   & \textbf{Description} \\
1869\hline
1870\textbf{Horizontal / vertical} & - & horizontal & â€œhorizontal”: horizontal corrector; “vertical”: vertical
1871 corrector \\
1872\hline
1873\textbf{L}  & [m] & 0.0 & length of the corrector \\
1874\hline
1875\textbf{kick} & [rad] & 0.0 & kick angle \\
1876\hline
1877\textbf{roll} & - & 0.0 & designed rotation angle  \\
1878\hline
1879\textbf{N} & - & 1 & cut piece of the element \\
1880\hline
1881\textbf{method} & - & 1, first order & 1, 2, 4. Order of symplectic integration method.
1882Value ‘1’ means 1st order, ‘2’ means 2nd order, and ‘4’ means 4th order \\
1883\hline
1884\end{tabular}
1885\end{table}
1886
1887
1888\vspace{0.05in}
1889\textit{Example 1:} 
1890\latticedef{CH:}{corrector,}{horizontal, method=intmeth;}
1891It defines a horizontal corrector.
1892
1893\vspace{0.05in}
1894\textit{Example 2:} 
1895\latticedef{CV:}{corrector,}{vertical, method=intmeth;}
1896It defines a vertical corrector.
1897
1898\notespace{NOTES:} 
1899\begin{itemize}
1900\item
1901The corrector type can be used as a corrector to do both orbit correction or as a
1902kicker to kick the beam.
1903\item
1904The corrector is treated as a multipole in TRACY, that is, if the length
1905of the corrector \textbf{L} is non-zero, then the element is treated as a thick
1906multipole, if \textbf{L} is zero, then the corrector is treated as a
1907thin multipole.
1908\item
1909For a lattice with correctors, user must specify the name of  corrector in the Tracy
1910input file with the commands:
1911           \tracycommand{h\_corr}{HCM}
1912                         or
1913           \tracycommand{v\_corr}{VCM}
1914Here \tracypara{HCM} is the name of the corrector defined in the lattice for horizontal
1915orbit correction (????); \tracypara{VCM} is the name of the corrector defined in the
1916lattice for vertical orbit correction.
1917\end{itemize}
1918
1919
1920\subsection{BEAM POSITION MONITOR (To be updated)}
1921 BPM is a special marker in the lattice; the “symbol” name must be “BPM” (???). User can
1922define the BPM as:????
1923\latticedef{BPM:}{type;}{}
1924
1925Normally Its type is defined as ``Marker'' type, but in order to include the misalignment
1926error of BPM into the lattice, it must be defined as “Beam Position Monitor” type
1927which is in fact multipole type, since only the element with multipole type is saved
1928with displacement error, field error, etc.
1929
1930\notespace{NOTES:}
1931For lattice with BPMs, user must specify the name of  BPM in the Tracy input file
1932 with the command:
1933                    \latticedef{bpm\_name }{beaPosMonitor}{}
1934Here ``beaPosMonitor'' is the name of the BPMs defined in the lattice.
1935
1936\subsection{GIRDER}
1937Girder is a special element, it’s the girder used in the real machine to support the
1938magnetic elements and other elements. It is defined as:
1939                   \latticedef{Symbol:}{ type;}{}
1940
1941Normally Its type is defined as ``Marker'' type, but in order to include the misalignment
1942error of girder into the lattice, it must be defined as ``multipole'' type, since only
1943the element with multipole type is saved with displacement error, field error, etc.
1944 
1945For convenience, it’s better to define the beginning of the girder and also the end of
1946the girder, and the elements between the beginning and end of the girders are the
1947elements who are put on the girder in the real machine.
1948
1949\begin{flushleft}
1950\textbf{Notice:}\\ 
1951For lattice with girders, User must specify the name of  girder in the
1952input file ``*.prm'' with the commands: \\
1953
1954\begin{tabular}{l l}
1955gs &      Girder\_Start \\
1956ge &      Girder\_End \\
1957& \\
1958\end{tabular}
1959
1960Here ``Girder\_Start'' is the name of the start of girder defined in the lattice;
1961``Girder\_End'' is the name of the end of girder defined in the lattice.
1962\end{flushleft}
1963
1964\subsection{MARKER}
1965
1966\latticedef{Element\_Name:}{marker;}{}
1967
1968\subsection{ELEMENT BLOCK}
1969\begin{flushleft}
1970  To construct the element block, use the following format: \\
1971           \latticedef{Symbol:}{ elem1, elem2,
., block1,block2;}{}
1972Here ``Symbol'' is the name of the element block, and ``elem1'',
1973``elem2'', ``block1'', ``block2'' are the element or sub element
1974blocks in this element block.  \\
1975
1976If there are $N$ the same element/block subsequently, user can use
1977``$N$*element/block'' to simply the definition. \\
1978\textbf{For example:} \\
1979                        \latticedef{SINJ:}{ SD1a, ssep, 3*SEP,esep,SD1c,eHU600,SD1d;}{} 
1980In this example element block, there are 9 elements/blocks, and 3 elements/blocks ``SEP'' subsequently.
1981
1982\subsection{LINE}
1983 User can define the cell structure using the command:
1984
1985             \latticedef{CELL :} {$\langle$ block name $\rangle$, SYMMETRY=$\langle$ symmetry $\rangle$;}{}
1986
1987\begin{tabular}{l l}
1988$\langle$block name $\rangle$: & the name of a block; \\
1989$\langle$symmetry $\rangle$: & the number of super symmetry or the number of the block in the ring. \\ 
1990 & \\
1991\end{tabular}
1992
1993\textit{Example:} \\
1994
1995         CELL: BL1, Symmetry = 12; \\
1996
1997This example defines the cell with block ``BL1'', and the number of super
1998symmetry is 12. The output of the Tracy3 with symmetry large than 1 will give the
1999tunes and chromaticities in one symmetric period.
2000
2001\end{flushleft}
2002
2003\subsection{RING}
2004To define the ring, use the command:
2005               \latticedef{RING:}{ elem, block
.}
2006It’s similar to define an element block, but must with the fixed symbol
2007name ``RING''.  \\
2008
2009\textbf{For example:} \\
2010\latticedef{RING:}{ DEBUT,SUP1,SUP2,SUP3,SUP4,CAV,FIN;}{}
2011
2012\subsection{End line}
2013 To end the lattice file, user needs to use the following command at the end of the lattice file:
2014End;
2015This command is mandatory.
2016
2017
2018\section{Commands}
2019The following commands turn on the boolean flags in the code to set the
2020machine parameters and carry on different calculations. All these commands
2021are optional; user can choose whichever they need. If user wants to use
2022the flag, they can write the flag in the script, if they do not want to
2023use it, they can delete or comment out (add ``\#'' at the beginning of command line)
2024the flag. The Boolean flags in the user input script have the following features:
2025\begin{flushleft}
2026\begin{itemize}
2027\item 
2028If the flags are not active, then the default values for all the boolean
2029commands are false.
2030\item
2031The code will execute the command according to the sequence defined in the
2032input script ``*.prm''. For example, \\
2033\begin{tabular}{l l}
2034(1) & \\
2035\hline
2036FitTune4Flag & qp7a qp7b qp9a qp9b 18.18 10.28 \\
2037\hline
2038(2) & \\
2039ReadMultipoleFlag & \\
2040\hline
2041(3) & \\
2042FitTune4Flag & qp7a qp7b qp9a qp9b 18.202 10.317 \\
2043& \\
2044\end{tabular}
2045
2046With the command (1),
2047the code will fit tunes to the target tunes (18.18  10.28);  \\
2048with the command (2), the code
2049then read multipole field errors into the lattice; \\
2050with the command (3), the code
2051 then fit the tunes to a new set of values (18.202 10.317).
2052
2053\item
2054User can define the same Boolean commands as often as they want
2055in the same input script; but user can only define maximum 500
2056commands in one input script. 
2057\item
2058The user defined script can be used both for both the non-parallel
2059and parallel version Tracy; the output files are the same
2060for both versions.
2061\item 
2062The key words in the user defined input file ``*.prm'' is
2063case sensitive, that is, the key word with captical letters
2064is different from the one with small letters.
2065\item 
2066The variables and lattice element names in Tracy lattice file
2067are not case sensitive, user can define the variables and
2068lattice elements names with small or captical letters.
2069
2070\end{itemize}
2071\end{flushleft}
2072
2073\subsection{QuadFringeOnFlag }
2074To activate quadrupole fringe field, use the command:
2075\tracycommand{QuadFringeOnFlag}{}
2076in the ``*.prm'' script. With this command, user can define
2077the fringe field at the entrance or exit of the quadrupole together
2078with the command ``FF1 = 1'' or ``FF2 = 1'' of the quadrupoles
2079which are defined in the lattice file; if FF1 or FF2 not equals to 1,
2080then there is no fringe field at the entrance or exit of the quadrupoles
2081even if QuadFringeOnFlag is active in the ``*.prm'' file.
2082
2083This flag is a global flag, if user set this flag in the input script,
2084it will always have effects until this flag is reset.
2085
2086\subsection{QuadFringeOffFlag }
2087To deactivate quadrupole fringe field, use the command:
2088\tracycommand{QuadFringeOffFlag}{}
2089
2090With this command, user can deactivate the fringe field at the entrance
2091and exit of the quadrupole, even if ``FF1 = 1'' or ``FF2 = 1'' for the
2092quadrupole in the lattice file.
2093 
2094This flag is a global flag, if user set this flag in the input script,
2095it will always have effects until this flag is reset.
2096
2097\subsection{RFvoltageFlag}
2098User can reset the RF voltage by setting ``RFvoltageFlag'' to replace
2099the value of RF voltage which is defined in the lattice. For example:
2100\tracycommand{RFvoltageFlag}{    3000000}
2101
2102Here ``RFvoltageFlag'' is the name of the keyword command, ``3000000'' is
2103the value of RF voltage with the unit [volt].
2104 
2105If the ring has more than one RF cavities, the related parameters
2106are defined as the total values for one RF cavity.
2107
2108\subsection{PrintTrackFlag}
2109To print the coordinates tracked around COD at each element to a file, use the command:
2110\tracycommand{PrintTrackFlag}{           track\_file        x    px   y  py  delta    ctau     nturn}
2111
2112For example:
2113\tracycommand{PrintTrackFlag}{           track.out         0.001     0.0    0.0    0.0    0.0    0.0     50}
2114
2115The parameters and the default values of ``PrintTrackFlag'' are shown in Table \cite{tab:prnttrackflag:para}.
2116
2117\begin{table}[h]
2118\centering
2119\label{tab:prnttrackflag:para}
2120\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.1\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2121\hline
2122Name &  Description & Default value & Unit \\
2123\hline
2124track\_file & File to save the tracked coordinates around each lattice element & track.out & - \\
2125\hline
2126x & Start tracking horizontal coordinate &  0.001 &  [m] \\
2127\hline
2128px & Start tracking horizontal canonical momentum px normalized by
2129      reference momentum p0, that is: px = px/p0.  Normally px is approximate
2130      as horizontal deviation with unit [rad]. & 0.0 & - \\
2131\hline
2132y & Start tracking vertical coordinate &  0.0 &  [m] \\
2133\hline
2134py & Start tracking vertical canonical momentum py normalized by reference
2135      momentum p0, that is: py = py/p0. Normally px is approximate as vertical
2136      deviation with unit [rad]. & 0.0 & - \\
2137\hline
2138delta & Start tracking relative energy offset  & 0.0 & - \\
2139\hline
2140ctau & Start tracking longitudinal coordinate  & 0.0 & [m] \\
2141\hline
2142nturn & Number of turn for tracking & 50 & - \\
2143\hline
2144\end{tabular*}
2145\caption{Parameters of command ``PrintTrackFlag''.}
2146\end{table}
2147
2148
2149
2150\subsection{PrintTrackElemFlag}
2151To print the coordinates tracked (NOT around COD) at a certain element to a file, use the command:
2152\tracycommand{PrintTrackFlag}{track\_file        x    px   y  py  delta    ctau     nelem1 nelem2}
2153
2154For example:
2155\tracycommand{PrintTrackFlag}{track.out         0.001     0.0    0.0    0.0    0.0    0.0     50 1 2}
2156
2157The parameters and the default values of ``PrintTrackElemFlag'' are shown in Table \cite{tab:printtrackelemflag:para}.
2158
2159\begin{table}[h]
2160\centering
2161\label{tab:printtrackelemflag:para}
2162\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.1\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2163\hline
2164Name & Description & Default value & Unit \\
2165\hline
2166track\_file & File to save the tracked coordinates around
2167each lattice element. & track.out & - \\
2168\hline
2169x & Start tracking horizontal coordinate & 0.001 & [m] \\
2170\hline
2171px & Start tracking horizontal canonical momentum px normalized
2172      by reference momentum p0, that is: px = px/p0.  Normally
2173      px is approximate as horizontal deviation with unit [rad]. &
2174      0.0 & - \\
2175y & Start tracking vertical coordinate & 0.0 & [m] \\
2176\hline
2177py & Start tracking vertical canonical momentum py normalized by
2178      reference momentum p0, that is: py = py/p0. Normally px is
2179      approximate as vertical deviation with unit [rad]. & 
2180      0.0 & - \\
2181\hline
2182delta & Start tracking relative energy offset  & 0.0 & - \\
2183\hline
2184ctau &Start tracking longitudinal coordinate  &0.0 & [m] \\
2185nelem1 &index of start lattice element for tracking & - & - \\
2186\hline
2187nelem2 & index of end lattice element for tracking & - & - \\
2188\hline
2189\end{tabular*}
2190\caption{Parameters of command ``PrintTrackElemFlag''.}
2191\end{table}
2192
2193
2194
2195\subsection{PrintTwissFlag}
2196
2197Print Twiss parameters to a user defined file \\
2198
2199With the command ``PrintTwissFlag'', Tracy 3 will print the Twiss
2200parameters to a user defined file. The format is:
2201 \tracycommand{                           PrintTwissFlag}{                user\_defined\_file}
2202
2203If user use the command PrintTwissFlag but without define the file name,
2204then the code will print the Twiss parameters to a default file ``twiss.out''.
2205
2206\subsection{PrintCODFlag}
2207Print COD (Close Orbit Distortion) to a user defined file\\
2208
2209With the command ``PrintCODFlag'', the code will print the close orbit
2210distortion to a user defined file. The format is:
2211 \tracycommand{PrintCODFlag}{                user\_defined\_file}
2212If user use the command PrintCODFlag but without defining the file name,
2213then the closed orbit will be printed to the default file ``printcod.out''.
2214
2215In Tracy 3, close orbit file ``cod.out'' is automatically generated after
2216reading the lattice.
2217
2218See the details in seciton {}...??????????
2219
2220\subsection{ReadChamberFlag}
2221Read vacuum chamber setting from an external file \\
2222
2223  To read the vacuum chamber from the user defined chamber file, use the command:
2224\tracycommand{ReadChamberFlag}{        Chamber\_example.dat}
2225  In the file ``Chamber\_example.dat'', user can specify the vacuum limit at the
2226different region of the lattice; the format of the chamber file is given in section {}.....?????.
2227
2228\subsection{ReadfefileFlag}
2229Read lattice element multipole field errors from an external file \\
2230
2231  To read the multipole field errors of the lattice elements from the user defined file, use the command:
2232\tracycommand{ReadfefileFlag}{             dip.fe}
2233
2234Tracy will read the systematic and random multipole field errors of the
2235lattice elements defined in the file ``dip.fe'', and then replace the
2236corresponding field components of the elements with the new field errors.
2237The formats to specify the systematic and random multipole field errors in
2238a file are given in section Error: Reference source not found.
2239
2240\subsection{ReadaefileFlag}
2241Read lattice element misalignment errors from a file \\
2242
2243  To read the misalignment error of the lattice elements from the user defined file, use the command:
2244\tracycommand{ReadaefileFlag}{             dip.ae}
2245
2246Tracy will read the systematic and random misalignment errors of the
2247lattice elements from the file ``dip.fe'', and replace the misalignment
2248errors of the corresponding components of the elements. The formats to
2249define the systematic and random misalignment errors of the lattice
2250elements in a file are given in section ....??????.
2251
2252\subsection{CODCorrectFlag}
2253\begin{flushleft}
2254Closed orbit (COD) correction \\
2255
2256   The orbit distortion is corrected using SVD (Singular Value Decomposition)
2257 method in Tracy 3. In order to do orbit correction, user needs to call the command
2258\tracycommand{CODCorrectFlag}{}
2259and then specify the following parameters in the user defined ``*.prm'' file.
2260 
2261Specify the element names of horizontal, vertical correctors, and beam position
2262monitors used in the orbit correction as the following examples:
2263\begin{tabular}{l l}
2264h\_corr     &  HC \\
2265v\_corr     &  VC \\
2266BPM     &   bpm \\
2267& \\
2268\end{tabular}
2269
2270User also need to specify the states of the correctors to trigger
2271on/off the correction using the following parameters: \\
2272\begin{tabular}{l l}
2273hcorr\_file    &    hcorr\_56nom.state \\
2274vcorr\_file    &    vcorr\_56nom.state \\
2275& \\
2276\end{tabular}
2277
2278In the file ``hcorr\_56nom.state'',
2279\begin{itemize}
2280\item 
2281a list of numbers (1 or 0) are
2282given to the horizontal correctors, according to the sequence in the lattice;
2283``1'' means the corresponding corrector is used for horizontal orbit correction,
2284``0'' means this corrector is not used in the horizontal orbit correction.
2285The definition rules of vertical corrector states in ``vcorr\_56nom.state'' are
2286the same as ``vcorr\_56nom.state''. 
2287\item 
2288This parameter defines number of iterations to correct the orbit distortion,
2289this value should be an integer number not smaller than 1. \\
2290n\_orbit       3
2291\item
2292This parameter defines number of singular values in H-plane, must be not larger than the number of correctors used for orbit correction \\
2293nwh           60
2294\item
2295This defines number of singular values in V-plane, must be not larger  than the number of correctors used for orbit correction \\
2296nwv           60
2297\end{itemize}
2298
2299 In Tracy 3, during the closed orbit correction:
2300\begin{itemize}
2301\item
2302Beam response matrices between beam position monitors and
2303horizontal/vertical correctors are calculated and written to the
2304files ``svdh.out''/ ``svdv.out'', respectively. The maximum number of
2305horizontal/vertical correctors used for orbit correction is 250.
2306\item
2307The code corrects the closed orbit distortion.
2308\item 
2309Horizontal and vertical orbits at the locations of all beam position monitors
2310during the correction are saved to the files ``horbit.out'' and
2311``vorbit.out'', respectively.
2312\item
2313 A file ``OrScanFile.out'' will be saved with the summaries of the mean
2314and RMS values of the orbits before and after correction.
2315\item
2316Finally, Twiss parameters, closed orbit distortion at the lattice elements
2317are saved to a summary file ``summary\_miserr\_codcorr.out'', the format of
2318this file is explained in Table ....????.
2319\end{itemize}
2320
2321\end{flushleft}
2322
2323\subsection{TuneTracFlag}
2324
2325Get tunes by tracking \\
2326
2327  To get tunes by tracking, use command:
2328\tracycommand{TuneTracFlag}
2329  The tunes obtained by tracking are printed on the screen.
2330
2331\subsection{ChromTracFlag}
2332Get chromaticities by tracking \\
2333
2334  To get chromaticity by tracking, use command:
2335\tracycommand{ChromTracFlag}{}
2336  The chromaticities obtained by tracking are printed on the screen.
2337
2338\subsection{AmplitudeTuneShiftFlag}
2339
2340Tune shift with amplitude \\
2341
2342
2343  To calculate tune shift with amplitude, one needs to use the following command:
2344\tracycommand{AmplitudeTuneShiftFlag}{ nudx\_file nudz\_file nxpoint  nypoint nturn  xmax  ymax  delta}
2345
2346For example:
2347\tracycommand{AmplitudeTuneShiftFlag}{   nudx.out  nudz.out 50  30  516  0.035  0.02  0.0}
2348
2349The meanings of parameters and default values of command ``AmplitudeTuneShiftFlag''
2350are shown in Table \cite{tab:amplitudetuneshiftflag:para}. If user uses the command
2351AmplitudeTuneShiftFlag without parameters, then the code will use all the default values.
2352
2353\begin{table}[h]
2354\centering
2355\caption{Parameters of the command to calculate tune shift with amplitude.}
2356\label{tab:amplitudetuneshiftflag:para}
2357\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2358\hline
2359Parameters & Meaning & Default & units \\
2360\hline
2361nudx\_file & File to save the calculated tune shift with horizontal amplitude & nudx.out & -  \\
2362 \hline
2363 nudz\_file & File to save the calculated tune shift with vertical amplitude &  nudz.out & - \\
2364 \hline
2365 nxpoint &Number of points in horizontal direction & 31 & - \\
2366 \hline
2367 nypoint& Number of points in vertical direction & 21 & - \\
2368\hline
2369nturn& Number of turns to track tune & 516 & - \\
2370\hline
2371xmax & Maximum amplitude of x & 0.025 & [m] \\
2372\hline
2373ymax & Maximum amplitude of y & 0.005 & [m] \\
2374\hline
2375delta& Energy offset of the particle 0.0 & - \\
2376\hline
2377\end{tabular*}
2378\end{table}
2379
2380
2381     
2382\subsection{EnergyTuneShiftFlag}
2383Tune shift with energy \\
2384
2385To calculate tune shift with energy, one needs to use the command:
2386\tracycommand{EnergyTuneShiftFlag}{  nudp\_file  npoint  nturn  deltamax}
2387
2388For example:
2389\tracycommand{EnergyTuneShiftFlag}{   nudptest.out    31    1026    0.06}
2390
2391The meaning of parameters and default values of this command are shown in Table \cite{tab:energytuneshiftflag:para}.
2392If user uses command EnergyTuneShiftFlag without parameters, then the code will use all the default values.
2393
2394\begin{table}[h]
2395\centering
2396\caption{Parameters of the command to calculate tune shift with energy.}
2397\label{tab:energytuneshiftflag:para}.
2398\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2399\hline
2400parameter & meaning & default & units \\
2401\hline
2402nudp\_file & File to save the calculated tune shift with energy &
2403nudp.out & - \\
2404\hline
2405npoint & Number of points & 31 & - \\
2406\hline
2407nturn & Number of turns  for tracking & 516 & - \\
2408\hline
2409deltamax & Maximum energy offset of the particle & 0.06 - \\
2410\hline
2411\end{tabular*}
2412\end{table}
2413
2414
2415   
2416\subsection{FmapFlag}
2417Frequency map analysis for on momentum particle. \\
2418
2419Track the coordinates (x, px, y, py, delta, ctau) of the particle,
2420the coordinates (x, px, y, py) are tracked around the closed orbit;
2421while (delta, ctau) is tracked around the zero orbit.
2422
2423The grid of the particle is x= 1e-6 + xcod ~ xmax + xcod, with the
2424step size xmax/nturn,
2425z= 1e-6 + zcod ~ zmax + zcod, with the
2426step size ymax/nturn; px = 0 + pxcod; pz = 0 + pzcod;
2427ctau = 0; delta = set value.
2428
2429To do frequency map analysis for the on momentum particle, use the command:
2430\tracycommand{FmapFlag}{   fmap\_file    nxpoint   nypoint    nturn  xmax   ymax   delta   diffusion}
2431or
2432\tracycommand{FmapFlag}{   fmap\_file    nxpoint   nypoint    nturn  xmax   ymax   delta   diffusion printloss }
2433
2434 For example:
2435\tracycommand{FmapFlag}{   fmap.out   31   21   516   0.025   0.005   0.0   true  }
2436or
2437\tracycommand{FmapFlag}{   fmap.out   31   21   516   0.025   0.005   0.0   true  true}
2438
2439
2440The meaning of parameters and default values of this command are shown in Table \cite{tab:fmapdpflag:para}.
2441If user uses command FmapFlag without parameters, then the code will use all the default values.
2442
2443\begin{table}[h]
2444\centering
2445\caption{Parameters of the command to do frequency map analysis for on momentum particle.}
2446\label{tab:fmapdpflag:para}
2447\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2448\hline
2449Parameters & meaning & Default & units \\ 
2450\hline
2451fmap\_file & File to save the calculated frequency map analysis &
2452fmap.out & - \\
2453\hline
2454nxpoint & Number of points in the horizontal direction &31 & - \\
2455\hline
2456nypoint &Number of points in the vertical direction & 21 & - \\
2457\hline
2458nturn&Number of turns for tracking; if ``diffusion'' is
2459      true, then the tunes will calculated in the first Nturn
2460      and then the second Nturn, and the tune difference
2461      between these two tunes is the tune diffusion. & 516 & - \\
2462\hline
2463xmax & Maximum amplitude in the horizontal direction & 0.025& [m] \\
2464\hline
2465ymax & Maximum amplitude in the vertical direction & 0.005 & [m] \\
2466\hline
2467delta &Energy offset of the particle & 0.0 & - \\
2468\hline
2469diffusion & Boolean flag, true/false; to compute tune diffusion at
2470the first N turns and second N turns. & true & - \\
2471\hline
2472printloss (optional) & 
2473Boolean flag, true/flase; print out the last information of the tracked
2474particleto and external file? If true, the output file is ``fmap\_file.loss''. & - &- \\
2475\hline
2476\end{tabular*}
2477\end{table}
2478
2479
2480
2481\subsection{FmapdpFlag}
2482Frequency map analysis for off momentum particle \\
2483
2484To do frequency map analysis for the off momentum particle, use the command:
2485FmapdpFlag   fmapdp\_file    nxpoint    nepoint    nturn    xmax  emax  y  diffusion
2486or
2487FmapdpFlag   fmapdp\_file    nxpoint    nepoint    nturn    xmax  emax  y  diffusion printloss
2488
2489The meaning of parameters and default values are shown in Table \cite{tab:fmapdpflag:para}
2490If user only uses the command ``FmapdpFlag'' but without defining all the parameters,
2491then the code uses the default values.
2492
2493\begin{table}[h]
2494\centering
2495\label{tab:fmapdpflag:para}
2496\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.45\linewidth} |p{0.15\linewidth} | p{0.1\linewidth} |}
2497\hline
2498parameters & meaning & default & units \\
2499\hline
2500fmapdp\_file & File to save the calculated frequency map analysis &
2501fmapdp.out & - \\
2502\hline
2503nxpoint & Number of points in the horizontal direction &31 & - \\
2504\hline
2505nepoint &Number of points for the energy & 21 & - \\
2506\hline
2507nturn &Number of turns for tracking&516&-\\
2508\hline
2509xmax &Maximum amplitude in the horizontal direction &0.025 & [m]\\
2510\hline
2511emax &Maximum energy offset of the particle&0.005 & -\\
2512\hline
2513y &Amplitude in the vertical direction& 0.0& [m] \\
2514\hline
2515diffusion & Boolean flag to compute tune diffusion & true & - \\
2516\hline
2517printloss (optional) &
2518Boolean flag, true/flase; print out the last information of the tracked
2519particle to and external file? If true, the output file
2520is ``fmapdp\_file.loss''. & - & \\
2521\hline
2522\end{tabular*}
2523\caption{Parameters of the command ``FmapdpFlag''.}
2524\end{table}
2525
2526
2527
2528\subsection{ErrorCouplingFlag}
2529Add coupling by the random rotation of the full quadrupoles \\
2530
2531To simulate coupling in the lattice, use can add the random rotation
2532error to all the full quadrupole, using the command as the following example:
2533\tracycommand{ErrorCouplingFlag}{         0    0.0007}
2534
2535In this example, ``0'' is the random seed number; ``0.0007'' is the RMS value
2536of the rotation angles of all the quadrupoles with the unit [rad].
2537 
2538After setting the rotation error in the lattice, the code will generate a file
2539with the file name ``flat\_file\_errcoupling\_full.dat'' at the current working
2540directory, user can check the error setting of quadrupoles in this file; then
2541the coupling will be calculated and Twiss parameters after adding the random
2542rotation errors will be saved to the file ``linlat\_errcoupling.out''.
2543
2544\subsection{ErrorCoupling2Flag}
2545Add coupling by random rotation of the half quadrupoles \\
2546
2547In order to get the beam parameters in the middle of the quadrupoles, each
2548quadrupole in the lattice can be cut into two parts. In such case,
2549the coupling of the lattice can be generated by random rotation of all the
2550half quadrupoles in the lattice, using the command as the following example:
2551\tracycommand{ErrorCoupling2Flag}{         0    0.0007}
2552
2553In this example, ``0'' is the random seed number; ``0.0007'' is the RMS value
2554of the rotation angle of the quadrupole with the unit [rad].
2555
2556After setting the errors in the lattice, the code will generate a file at
2557the current working directory with the file name ``flat\_file\_errcoupling\_half.dat'',
2558user can check the error setting of quadrupoles in this file. After adding
2559the random rotation errors, the coupling will be calculated and Twiss parameters
2560will be saved to the file ``linlat\_errcoupling2.out''.
2561
2562This command is dedicated for Soleil lattice in which each quadrupole
2563is cut into two half quadrupoles.
2564
2565\subsection{CouplingFlag}
2566Calculate coupling and emittance \\
2567
2568To calculate coupling and emittance, use command:
2569\tracycommand{CouplingFlag}{}
2570
2571After calculation, the coupling and the emittance will be printed on the
2572screen, and the Twiss parameters will be automatically saved to the
2573file ``linlat\_coupling.out''.
2574
2575\subsection{MomentumAccFlag}
2576Calculate momentum acceptance by tracking \\
2577
2578The following command calculate momentum acceptance at a predefined
2579lattice region by tracking:
2580\tracycommand{MomentumAccFlag}{   MomAccFile   TrackDim     istart    istop     deltaminp
2581Deltamaxp     nstepp    deltaminn    deltamaxn   nstepn   turns  zinitial}
2582
2583\textit{For example:}
2584\tracycommand{MomentumAccFlag}{   momacc.out      4D     1   209     0.01     0.05    100       -0.01       
2585-0.05   100   1026   0.0001}
2586
2587The meaning of parameters and default values are shown in Table \cite{tab:momentumaccflag:para}.
2588If user uses MomentumAccFlag without parameters, then the code will use
2589the default values.
2590
2591\begin{table}[h]
2592\centering
2593\label{tab:momentumaccflag:para}
2594\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2595\hline
2596parameter & meaning & Default & units \\
2597\hline
2598MomAccFile & File to save the tracked momentum acceptance at each
2599element; saved in the current directory.& momentumacceptance.out & - \\
2600\hline
2601TrackDim & 4D/6D  tracking to get the momentum acceptance & 6D & - \\
2602\hline
2603istart &Start element in the lattice for the tracking & 1 & - \\
2604\hline
2605istop &End element in the lattice for tracking &108 & - \\
2606\hline
2607nstepp &Number of steps to do tracking in the positive energy range &
2608100 & - \\
2609\hline
2610nstepn&Number of steps to do tracking in the negative energy range &100 & - \\
2611\hline
2612Deltaminp&Positive start energy of the tracking & 0.01 & - \\
2613\hline
2614Deltamaxp & Positive end energy of the tracking & 0.05 & - \\
2615\hline
2616Deltaminn & Negative start energy of the tracking & -0.01 & - \\
2617\hline
2618Deltamaxn & Negative end energy of the tracking & -0.05 & - \\
2619\hline
2620nturns &Number of turn & 1026 & - \\
2621\hline
2622zinitial & The initial vertical coordinate which is used to search for
26236D closed orbit. This value should be a small value. & 0.0003 &  [m] \\
2624\hline
2625\end{tabular*}
2626\caption{Parameters of the command to calculate momentum acceptance.}
2627\end{table}
2628
2629
2630         
2631\subsection{ReadMultipoleFlag}
2632Read multipole field error from a file (SOLEIL lattice) \\
2633
2634 After defining the file names of multipole field errors on SOLEIL storage
2635ring (see section \cite{} and \cite{}), use the command:
2636\tracycommand{ReadMultipoleFlag}{}
2637to read multipole field errors and set the corresponding values to SOLEIL
2638lattice. The multipole field errors of correctors and skew quadrupoles
2639are added on the thick sextupoles which are integrated at the same magnets.
2640The format of multipole errors file is given in section \cite{}.
2641
2642 After setting the multipole field errors in the lattice, the code will
2643generate a file at the current working directory, and the file name is
2644``flat\_file\_errmultipole.dat'', user can check the field components of
2645the lattice elements in this file to verify the multipole field errors.
2646
2647\subsection{ReadVirtualSkewquadFlag}
2648Read the sources of coupling from a file (SOLEIL lattice) \\
2649
2650The sources of coupling on SOLEIL storage ring can be read from an external
2651file.  Use the command:
2652\tracycommand{ReadVirtualSkewquadFlag}{} 
2653to read and set the field strength to the virtual skew quadrupoles. Currently
2654this command only works for Soleil lattice.
2655
2656The coupling sources MUST be defined as the skew quadrupoles with the name
2657``SQ'', the rules and related information are explained in section \cite{}.
2658
2659\subsection{FitTuneFlag}
2660Fit tunes for the lattice with full quadrupole \\
2661
2662Betatron tunes can be fit using two families of quadrupoles. The command is:
2663\tracycommand{FitTuneFlag}{      Quad1   Quad2   nux   nuz}
2664
2665\textit{For example:}
2666\tracycommand{FitTuneFlag}{      q7 q9   18.202   10.317}
2667
2668The parameters of this command are shown in Table \cite{tab:fittuneflag:paras}.
2669
2670\begin{table}[h]
2671\centering
2672\label{tab:fittuneflag:paras}
2673\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2674\hline
2675Parameters & Meaning & Default & Units \\
2676\hline
2677Quad1 & Quadrupole family used to fit the tunes & - & - \\
2678\hline
2679Quad2 & Quadrupole family used to fit the tunes & - & - \\
2680\hline
2681nux & Target horizontal tune & 0.0 & - \\
2682\hline
2683nuz & Target vertical tune & 0.0 & - \\
2684\hline
2685\end{tabular*}
2686\caption{Parameters of the command ``FitTuneFlag''.}
2687\end{table}
2688
2689\begin{itemize}
2690\item
2691After fitting the tunes, field strengths of the fitted quadrupoles
2692before and after the fitting are printed to the screen; user can
2693copy the new quadrupole field strengths to the lattice file for
2694further analysis.
2695\item
2696``FitTuneFlag'' is a generic command; it works for the lattices with
2697full qudrupoles.
2698\end{itemize}
2699
2700\subsection{FitTune4Flag}
2701Fit tunes for the lattice with half quadrupoles \\
2702
2703For the lattice with each quadrupole cut into two pieces, betatron
2704tunes can be fit using two families of quadrupoles. The command is:
2705\tracycommand{FitTune4Flag}{      Q1a  Q1b  Q2a  Q2b  nux  nuz}
2706
2707The parameters of this command are shown in Table \cite{tab:fittune4flag:paras}.
2708
2709\begin{table}[h]
2710\centering
2711\label{tab:fittune4flag:paras}
2712\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2713\hline
2714Parameters & Meaning  & Default & Units \\
2715\hline
2716Q1a &First half of the quadrupole family used to fit the tunes &- & - \\
2717\hline
2718Q1b &Second half of the quadrupole family used to fit the tunes & - & - \\
2719\hline
2720Q2a &First half of the quadrupole family used to fit the tunes& - & - \\
2721\hline
2722Q2b &Second half of the quadrupole family used to fit the tunes &- & - \\
2723\hline
2724nux &Target horizontal tune&0.0 & - \\
2725\hline
2726nuz & Target vertical tune & 0.0 & - \\
2727\hline
2728\end{tabular*}
2729\caption{Parameters of the command ``FitTune4Flag''.}
2730\end{table}
2731
2732
2733
2734\textit{For example:}
2735\tracycommand{FitTune4Flag}{      qp7a  qp7b   qp9a  qp9b  18.202 10.317}
2736
2737In this example, all the variables have the same meaning as the ones
2738in the command ``FitTuneFlag'', except ``qp7a'' and ``qp7b'' are the
2739two half pieces of the full quadrupole ``qp7'', and ``qp9a'' and ``qp9b''
2740are the two half pieces of the full quadrupole ``qp9''.
2741
2742\begin{itemize}
2743\item
2744 After fitting the tunes, the field strengths of fitted quadrupole
2745before and after the fitting are printed to the screen; user can
2746copy the new field strengths of quadrupoles to the lattice file
2747for further analysis. 
2748\item 
2749``FitTune4Flag'' is a command that works for the lattices in
2750which each quadrupole are cut into two halves.
2751\end{itemize}
2752
2753\subsection{FitChromFlag}
2754Fit chromaticity \\
2755
2756Chromaticities can be fit using two families of sextupoles, the command is:
2757\tracycommand{FitChromFlag}{     SX1    SX2    epsilon\_x    epsilon\_z}
2758
2759The parameters of this command are shown in Table \cite{tab:fitchromflag:paras}.
2760
2761\begin{table}[h]
2762\centering
2763\label{tab:fitchromflag:paras}
2764\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.15\linewidth}|p{0.5\linewidth} |p{0.1\linewidth} | p{0.1\linewidth} |}
2765\hline
2766Parameters & Meaning & Default & Unit \\
2767\hline
2768SX1 & First sextupole family used to fit the chromaticities & - & - \\
2769\hline
2770SX2 & Second sextupole family used to fit the chromaticities & - & - \\
2771\hline
2772epsilon\_x & Target horizontal chromaticity & 0.0 & - \\
2773\hline
2774epsilon\_z & Target vertical chromaticity & 0.0 & - \\
2775\hline
2776\end{tabular*}
2777\caption{Parameters of the command ``FitChromFlag''.}
2778\end{table}
2779
2780\textit{For example:}
2781\tracycommand{FitChromFlag}{     sx9 sx10   2.0    2.6}
2782
2783After fitting the chromaticites, the field strengths of fitted
2784sextupoles before and after the fitting are printed to the screen;
2785user can copy the new field strengths of sextupoles to the lattice
2786file for further analysis. 
2787
2788\subsection{TouschekFlag (TO BE UPDATED)??????}
2789Touschek lifetime determined by RF acceptance \\
2790
2791To calculate Touschek lifetime, use the following command:
2792\tracycommand{TouschekFlag}{}
2793
2794Here the momentum acceptance is limited by the RF acceptance.
2795
2796\subsection{IBSFlag (TO BE UPDATED) ????}
2797Intra Beam Scattering (IBS)  \\
2798
2799
2800To calculate Intra Beam Scattering, use the command:
2801\tracycommand{IBSFlag}{}
2802
2803\subsection{TousTrackFlag (TO BE UPDATED)}
2804Touschek lifetime determined by the minimum value of RF acceptance
2805and momentum acceptance. \\
2806
2807Touschek lifetime can be calculated by 
2808\tracycommand{TousTrackFlag}{}
2809
2810In this case, the energy acceptance at each lattice element is
2811limited by the minimum value of RF acceptance and momentum acceptance
2812obtained by tracking, and the chamber file MUST be defined in
2813the user script.
2814
2815\subsection{PhaseSpaceFlag}
2816Obtain phase space by tracking \\
2817
2818To calculate phase space, use the command:
2819\tracycommand{PhaseSpaceFlag}{      Phase\_phase\_file      Phase\_Dim     Phase\_X      Phase\_Px
2820                                           Phase\_Y     Phase\_Py   Phase\_delta   Phase\_ctau               
2821                                           Phase\_nturn     damping\_flag}
2822
2823\textit{For example:}
2824\tracycommand{PhaseSpaceFlag}{   phasespace.out    6D   1e-6    0.0    1e-6   0.0   0.012   0.0   1000   false}
2825
2826The meanings of parameters and defaults values of PhaseSpaceFlag are shown in Table~\ref{tab:phasespace-para}.
2827If user uses PhaseSpaceFlag without parameters, then the code will use the default values.
2828
2829\begin{table}[h]
2830\centering
2831\label{tab:phasespace-para}
2832\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth}|p{0.48\linewidth} |p{0.12\linewidth} | p{0.05\linewidth} |}
2833\hline
2834Parameters & Meaning & Default & Unit \\
2835\hline
2836Phase\_phase\_file & File to save tracked phase space;
2837                              saved in the current directory.     &    phase.out & -\\
2838\hline
2839Phase\_Dim  &  4D~/~6D tracking                            &    4D & -\\
2840\hline
2841Phase\_X    &  Horizontal coordinate at the start
2842                        point of tracking.                        &    0.0  & -\\
2843\hline
2844Phase\_Px   &  Horizontal canonical momentum~/~derivative
2845                        at the start point of tracking.           &    0.0 & -\\
2846\hline
2847Phase\_Y    &  Vertical coordinate at the start point
2848                        of tracking.                              &    0.0 & -\\
2849\hline
2850Phase\_Py   &  Vertical canonical momentum~/~derivative
2851                        at the start point of tracking.           &    0.0 & -\\
2852\hline
2853Phase\_delta&  Energy at the start point of tracking     &    0.0 & -\\
2854\hline
2855Phase\_ctau &  Longitudinal position at the start point
2856                        of tracking.                              &    0.0 & -\\
2857\hline
2858Phase\_nturn&  Number of turns for tracking              &    512 & -\\
2859\hline
2860Damping\_flag& Boolean flag to turn on~/~off the radiation
2861                        damping during the tracking.              &    false & - \\
2862\hline
2863\end{tabular*}
2864\caption{Parameters of the command ``PhaseSpaceFlag'' to calculate phase space.}
2865\end{table}
2866
2867
2868\subsection{IDCorrFlag (Tested for TaiWan light source; TO BE CONTINUE DEVELOPPED.)?????}
2869Insertion device (ID) compensation  \\
2870
2871To compensate the beta beat introduced by the insertion devices, several
2872families of Quadruoples can be used. Defining the following command in
2873the ``*.prm'' can active this action:
2874\tracycommand{IDCorrFlag}{}
2875
2876User also needs to define the following parameters used for the
2877compensation of insertion device like the following example
2878in Table \ref{tab:idcorrflag:example}:
2879
2880\begin{table}
2881\begin{tabular}{l p{10cm}}
2882\hline
2883\hline
2884N\_calls &     1 \\
2885N\_steps&    1\\
2886N\_Fam &    11\\
2887IDCquads& qs1 qs2 qs3 qs4 qs5 ql1 ql2 ql3 q1 q2 q3\\
2888scl\_dbetax&  5e-1\\
2889scl\_dbetay&  5e-1\\
2890scl\_dnux&    0.1\\
2891scl\_dnuy&    0.1\\
2892scl\_nux&     1e1\\
2893scl\_nuy&     1e1\\
2894ID\_step&    0.7\\
2895\hline
2896\hline
2897\end{tabular}
2898\label{tab:idcorrflag:example}
2899\caption{One example to define the parameters to compensate nonlinear dynamics from the
2900          insertion device.}
2901\end{table}
2902
2903The meanings of the above commands and the default values used
2904to do ID compensation using quadrupoles are shown in Table \ref{tab:idcorrflag:paras}.
2905
2906\begin{table}[h]
2907\centering
2908\label{tab:idcorrflag:paras}
2909\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth}|p{0.48\linewidth} |p{0.12\linewidth} | p{0.05\linewidth} |}
2910\hline
2911Parameters & Meanings & Default & Units \\
2912\hline
2913N\_calls &Number of calls to do ID compensation & 1 & - \\
2914\hline
2915N\_steps &Number of steps.& 1 & - \\
2916\hline
2917N\_Fam & Number of quadrupole families used to do ID correction.
2918& 15 & - \\
2919\hline
2920IDCquads & Name of quadrupole families used to do ID correction. & - & - \\
2921\hline
2922scl\_dbetax & Scaling weight factor of the change step of horizontal
2923beta function during the ID correction. & 1 & - \\
2924\hline
2925scl\_dbetay & Scaling weight factor of the change step of vertical beta
2926function during the ID correction. & 1 & - \\
2927\hline
2928scl\_dnux & Scaling weight factor of the change step of horizontal
2929tune during the ID correction. & 0.1 & - \\
2930\hline
2931scl\_dnuy & Scaling weight factor of the change step of vertical
2932tune during the ID correction. & 0.1 & - \\
2933\hline
2934scl\_nux & Scaling weight factor of horizontal tune during the
2935ID correction. & 100 & - \\
2936\hline
2937scl\_nuy &Scaling weight factor of vertical tune during the ID correction.& 100 & - \\
2938ID\_step & 0.7 & - & - \\
2939\hline
2940\end{tabular*}
2941\caption{Parameters of commands to do ID compensation using quadrupoles.}
2942\end{table}
2943
2944
2945
2946
2947\section{Multipole field error file}
2948\label{sec:mult:field:error}
2949The multipole field errors of the lattice elements can be defined
2950in a file, and then the file is read into the lattice. User can
2951define the systematic or random multipole field error of the
2952lattice elements.
2953 
2954There are two ways to define the multipole field errors, one way
2955is to define the errors for all the families with the same type,
2956for example, the error for all the quadrupoles; another way is
2957to define the error for each family, for example, the ``Q1'' family
2958of the quadrupoles.
2959 
2960\subsection{Systematic errors}
2961To define the systematic multipole field error of the element,
2962the user just need to follow the rules as below.
2963       
2964This command is commonly used to add the mangets design errors
2965in the lattice.
2966
2967Input format of multipole error:
2968\tracycommand{keywords/name}{   sys   $r0$, $n$, $An$, $Bn$} 
2969
2970The parameters of the errors are:
2971\begin{description}
2972\item[keywords:]
2973type of lattice elements or the family name; the keywords of the
2974type of lattice elements are:
2975\begin{tabular}{l l}
2976                                dip &        dipole \\
2977                              quad  &     quadrupole \\
2978                               sext &      sextupole \\
2979                              hcorr &     horizontal corrector \\
2980                              vcorr &     vorizontal corrector \\
2981                              qt    &       skew quadrupole \\
2982
2983\end{tabular}
2984
2985\item[sys:] keyword to denote that user are setting the
2986systematic multipole error.
2987\item[$r0:$]
2988radius where the multipole field error is measured.
2989If $r0$ = 0, then the An and Bn are the integrated
2990multipole field strength at the position $x$ = $z$ = 0.
2991
2992\item[$n$:]
2993order of multipole field error, in US. notation.
2994Dip errors is 1, quadrupole error is 2, sextupole field
2995 error is 3, decaper field error is 4, octoper field error
2996is 5, etc.
2997\item[$Bn$:] 
2998$n^{\mathrm{th}}$
2999integrated upright component of the multipole field.
3000For the component of a skew quadrupole or a vertical
3001corrector, $Bn$ = 0
3002\item[$An$:] 
3003$n^{\mathrm{th}}$
3004integrated skew component of the multipole field.
3005For the component of a dipole or upright quadrupole, $An$ = 0.
3006\end{description}
3007
3008There are two ways to define the multipole field errors strength,
3009\begin{itemize}
3010\item
3011one is to define the measured field errors at the pole tip
3012location $r_0$, then $b_n$ and $a_n$ are respectively the scale
3013coefficient of the main magnetic field coeffeicient.
3014
3015For example, to define the decupole field errors inside a
3016horizontal bending dipole with coefficient $b_1$, we define the
3017normal scale coefficience as $c_5$ and skew scale coefficience
3018as $d_5$, then the $b_5$ component of this decupole is $c_5$ * $b_1$ 
3019and the skew coefficience $a_5$ is $d_5$ * $b_1$; that is
3020\begin{eqnarray*}
3021 b_5 &=& \frac{1}{B \rho} \frac{c_5 * B_0}{r_0^5}  \\
3022 a_5 &=& \frac{1}{B \rho} \frac{d_5 * B_0}{r_0^5} \\
3023\end{eqnarray*}
3024where
3025\begin{equation}
3026 b_1 = \frac{1}{B \rho} B_0.
3027\end{equation}
3028
3029This method is the simplest way to define the multipole errors
3030inside a lattice element. The default scaling factors $c_n$ and $d_n$ are 1.
3031
3032\item
3033Another way is to direct define the multipole field coefficiences $b_n$ 
3034and $a_n$, that is, set $r_0 = 0$. If the multipole field $\vec{B^{tip}}$ 
3035are measured at the tips with radius $r_0$, then $b_n$ and $a_n$ can
3036be calculated using
3037\begin{eqnarray*}   
3038b_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_y }{\partial x ^{n-1}}|_{x=0,y=0}  =  \frac{1}{B \rho} \frac{B_y^{tip}}{r_0^{n-1}} \\
3039a_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_x }{\partial x ^{n-1}}|_{x=0,y=0}  =  \frac{1}{B \rho} \frac{B_x^{tip}}{r_0^{n-1}} \\
3040\vec{B^{tip}} & = &  B_x^{tip} \hat{x} + B_y^{tip} \hat{y}
3041\end{eqnarray*}
3042
3043\end{itemize}
3044
3045
3046\begin{itemize}
3047\item
3048The line start with ``\#'' is a comment line.
3049\item
3050The blank lines in the multipole definition file are neglected by the code.
3051\item
3052The assigned multipoles errors will be added to the corresponding $n^{th}$ 
3053order multipole errors of the lattice element.
3054\end{itemize}
3055
3056
3057For the soleil lattice, the use can define the multipole errors for
3058the type or each family. But to define the multipole error for all the
3059quadrupoles, user can NOT define the multipole errors by the type. There
3060are two choice:
3061\begin{itemize}
3062\item
3063one is to define the multipole errors for each quadrupole family;
3064\item 
3065second is to define the field errors by quadrupole type, and then define
3066the multipole errors on Q2 and Q7 families (the lattice with full quadrupoles)
3067or  QP2a, QP2b, QP7a and QP7b families (lattice with quadrupoles which are
3068cut into two halves). This is due to that Q2/QP2a/QP2b and Q7/QP7a/QP7b are
3069the quadrupoles which have lengths larger than other quadrupoles in the lattice,
3070and the multipole errors on them are different from the ones on the
3071other short quadrupoles.
3072\end{itemize}
3073   
3074The following is an example file to define systematic multipole errors on
3075Soleil lattice:
3076\begin{flushleft}
3077
3078\begin{tabular}{ l l l l l l l l l l l l }   
3079\#dipole  & & & & & & & & & & & \\
3080 dip & sys & 20e-3 & 2 & 2.2e-40 & 0.0 & 3 & -3.0e-4 & 0.0  &  & & \\
3081       4 & 2.0e-5 & 0.0 &  5 &  -1.0e-4 & 0.0 &  6 & -6.0e-5 & 0.0 &  7 & -1.0e-4 & 0.0 \\
3082& & & & & & & & & & & \\
3083\end{tabular}
3084
3085
3086\#quadrupole  \\
3087\#for all short quadrupoles \\
3088\begin{tabular}{ l l l l l l l l l l l l}
3089quad & sys & 30e-3 & 6& 2.4e-4&  0.0&  10& 0.7e-4& 0.0&    14&   0.9e-4&  0.0  \\
3090& & & & & & & & & & & \\
3091\end{tabular}
3092
3093\#for all long quadrupoles qp2 and qp7 \\
3094\begin{tabular}{ l l l l l l l l l l l l}
3095  qp2a & sys & 30e-3 & 6 & 0.7e-4 & 0.0 & 10 & 1.9e-4 &  0.0 &  14 & 1.0e-4 & 0.0\\ 
3096  qp2b & sys & 30e-3 & 6 & 0.7e-4 & 0.0 & 10 & 1.9e-4 &  0.0 &  14 & 1.0e-4 & 0.0\\
3097  qp7a & sys & 30e-3 & 6 & 0.7e-4 & 0.0 & 10 & 1.9e-4 &  0.0 &  14 & 1.0e-4 & 0.0\\
3098  qp7b & sys & 30e-3 & 6 & 0.7e-4 & 0.0 & 10 & 1.9e-4 &  0.0 &  14 & 1.0e-4 & 0.0\\
3099& & & & & & & & & & & \\
3100\end{tabular}
3101
3102\#for all short quadrupoles,sextupole mesure quadrupoles longs \\
3103\begin{tabular}{l l l l l l l l l}
3104   quad & sys & 30e-3& 3& -1.6e-4&  0.0&   4&  -3.4e-4&   0.0 \\
3105   & & & & & & & & \\
3106\end{tabular}
3107
3108\#for long quadrupoles qp2 and qp7
3109\begin{tabular}{l l l l l l l l l}
3110  qp2a &sys& 30e-3& 3&  2.9e-4&  0.0&   4&  -8.6e-4&   0.0\\
3111  qp2b& sys& 30e-3& 3&  2.9e-4&  0.0&   4&  -8.6e-4&   0.0\\
3112  qp7a& sys& 30e-3& 3&  2.9e-4&  0.0&   4&  -8.6e-4&   0.0\\
3113  qp7b& sys& 30e-3& 3&  2.9e-4&  0.0&   4&  -8.6e-4&   0.0 \\
3114   & & & & & & & & \\
3115\end{tabular}
3116
3117\# for sextupoles\\
3118\begin{tabular}{l l l l l l l l l l l l l l l}
3119sext& sys&  32e-3&  5&  5.4e-4&   0.0&  7&  3.3e-4& 0.0&  9& -4.7e-4& 0.0&  15& -9.0e-4& 0.0 \\ 
3120    &    &       & 21& -20.9e-4& 0.0&  27&  0.8e-4& 0.0& & & & & &   \\
3121   & & & & & & & &  & & & & & &  \\
3122\end{tabular}
3123
3124\# for horizontal correctors, all An=0
3125\begin{tabular}{l l l l l l l l l l l l}
3126hcorr& sys& 35e-3& 5& 0.430& 0.0&   7& 0.063& 0.0&  11& -0.037& 0.0\\ 
3127   & & & & & & & &  & & &   \\
3128\end{tabular}
3129
3130\# for vertical correctors, all Bn=0
3131\begin{tabular}{l l l l l l l l l l l l}
3132  vcorr&  sys&  35e-3&  5&  0.0&  -0.430&   7&   0.0&   0.063&   11&  0.0&   0.037\\ 
3133& & & & & & & &  & & &   \\
3134\end{tabular}
3135
3136\# for sextupole associated skew quadrupole, all Bn=0
3137\begin{tabular}{l l l l l l}
3138 qt& sys& 35e-3&  4&  0.0&  -0.0\\
3139  qt& sys& 35e-3&    4&  0.0&  -0.680\\
3140\end{tabular}
3141
3142
3143\end{flushleft}
3144
3145\subsection{Ramdom error}
3146To define random multipole field errors on the lattice elements,
3147user needs to define the seed of the random errors, and then follow
3148the same rule as the ones to define systematic multipole error except
3149replacing ``sys'' by ``rms''.
3150
3151\textit{For example:}
3152\tracycommand{seed}{seed\_number}
3153\tracycommand{quad}{rms    30e-3 6 2.4e-4  0.0  10 0.7e-4 0.0    14   0.9e-4  0.0}
3154
3155The random multipole error is multiplied by the random scale factor; the new
3156value is added to the corresponding components of the magnetic field.
3157The random scale factor is generated by a random function which follows
3158the normal distribution (mean value is 0 and standard deviation is 1).
3159The cut off value for the normal distribution function is 2 times of
3160the RMS value. If user does not define seed for the random function
3161before the setting of errors, then the code will stop and give an
3162error message.
3163
3164 Here is example file to define random multipole error in the lattice:
3165
3166\begin{flushleft}
3167\#define seed for the ramdom multipole error \\ 
3168\begin{tabular}{ l l}
3169 seed     &  1000000 \\
3170 & \\
3171\end{tabular}
3172
3173\#dipole
3174\begin{tabular}{l l l l l l l l l l l l}
3175dip& rms&  20e-3& 2& 2.2e-40& 0.0& 3& -3.0e-4& 0.0&  4& 2.0e-5& 0.0 \\
3176   &    &       & 5&  -1.0e-4& 0.0&  6& -6.0e-5& 0.0&  7& -1.0e-4& 0.0 \\
3177& & & & & & & & & & & \\
3178\end{tabular}
3179
3180\#quadrupole
3181\begin{tabular}{l l l l l l l l l l l l }
3182quad& rms&  30e-3& 3& -1.6e-4&  0.0&   4&  -3.4e-4&   0.0&  6& 2.4e-4&  0.0\\
3183    &    &       & 10& 0.7e-4& 0.0&    14&   0.9e-4&  0.0& & & \\ 
3184Q2&  rms& 30e-3& 3&  2.9e-4&  0.0&   4&  -8.6e-4&   0.0&   6& 0.7e-4&  0.0\\
3185  &     &      &10&  1.9e-4&   0.0&   14& 1.0e-4&  0.0& & & \\
3186Q7&  rms& 30e-3& 3&  2.9e-4&  0.0&   4&  -8.6e-4&   0.0&   6& 0.7e-4&  0.0\\
3187  &     &      &10&  1.9e-4&   0.0&   14& 1.0e-4&  0.0& & & \\
3188& & & & & & & & & & & \\
3189\end{tabular}
3190\end{flushleft}
3191
3192
3193\section{ Misalignment error file}
3194The misalignment error of the lattice elements can be defined in a file,
3195and then the file is read into the lattice. User can define the systematic
3196or random misalignment error of the lattice elements.
3197
3198There are two ways to define the misalignment error, one way is to
3199define the error for all the families in one type, for example, the error
3200for all the quadrupoles; another way is to define the error for each family,
3201for example, the “Q1” family of the quadrupoles.
3202
3203The systermatic misalignment error file works for the lattices with full
3204or half quadrupoles; the random misalignment error file only works for
3205lattice with full quadrupoles.
3206
3207\subsection{Systematic errors}
3208To define the systematic misalignment error of the element, user
3209just needs to follow the rules as below.       
3210
3211input format of misalignment error:
3212\tracycommand{type/family}{name  sys  dx     dy  dr}
3213
3214\begin{flushleft}
3215\begin{description}
3216\item[keywords:]
3217type of lattice elements or the name of the family.
3218
3219Keywords of the type of lattice elements are: \\
3220\begin{tabular}{l l}
3221  All &                  all the elements in the lattice\\
3222  girder &            girder\\
3223  dipole &            dipole\\
3224  quad   &             quadrupole\\
3225  sext   &              sextupole\\
3226  bpm    &              beam position monitor\\
3227  family name &    family name of the elements\\
3228\end{tabular}
3229
3230\item[sys:]
3231denote that user are setting the systematic displacement error.
3232
3233\item[dx:] 
3234defines the displacement in x direction with unit [m].
3235
3236\item[dy:] 
3237defines the displacement in y direction with unit [m].
3238
3239\item[dr:] 
3240defines the rotation angle with unit [rad]).
3241\end{description}
3242
3243\end{flushleft}
3244
3245\begin{itemize}
3246\item
3247The line start with ‘\#’ is comment line.
3248\item
3249The blank line in the misalignment error file is neglected by the code.
3250\end{itemize}
3251
3252
3253\begin{flushleft}
3254The following is an example file to define systematic multipole error on Soleil lattice: \\
3255\#  systematic  alignment error for SOLEIL \\
3256\end{flushleft}
3257\begin{tabular}{l l l l l}
3258\#  name&      keyword &  x(m)&          y(m)&      r (rad)   \\
3259girder& sys&   100.0e-6&        100.0e-6&           0.5e-03 \\
3260quad&   sys&    30.0e-6&         30.0e-6&       80.0e-06\\
3261sext&   sys&    30.0e-6&         30.0e-6&      100.0e-06\\
3262dipole& sys&   500.0e-6&        500.0e-6&           0.2e-03\\
3263\end{tabular}
3264
3265\subsection{Random errors}
3266To define random misalignment errors on the lattice elements, user
3267need to follow the same rule as the ones to define systematic
3268misalignment error except replacing ``sys'' by ``rms''. That is:
3269input format of misalignment error:
3270\tracycommand{seed}{seed\_number}
3271\tracycommand{type/family}{  name  rms  dx  dy  dr}
3272
3273The random misalignment error is multiplied by the random scale factor;
3274the new value is added to the corresponding components of the misalignment
3275components. The random scale factor is generated by a random function which
3276follows the normal distribution (mean value is 0 and standard deviation is 1),
3277the cut off value for the normal distribution function is 2 times of the
3278RMS value.       
3279
3280If user does not define seed for the random function before the setting of errors,
3281then the code will stop and give an error message.
3282
3283\begin{flushleft}
3284Here is example file to define random misalignment error in the lattice: \\
3285\#  random  alignment error for SOLEIL \\
3286\begin{tabular}{l l l l l}
3287\#  name  & keyword &   x(m)&    y(m)&      r (rad)\\ 
3288girder& rms&   100.0e-6&        100.0e-6&           0.5e-03\\
3289quad&   rms&    30.0e-6&         30.0e-6&       80.0e-06\\
3290sext&   rms&    30.0e-6&         30.0e-6&      100.0e-06\\
3291dipole& rms&   500.0e-6&        500.0e-6&           0.2e-03\\
3292\end{tabular}
3293\end{flushleft}
3294
3295\subsection{Vacuum chamber file}
3296User can define the script to set the vacuum chamber limitation
3297around the ring.
3298The format of the vacuum chamber definition is
3299\tracycommand{MK1, MK2,}{ minimum x, maximum x, minimum y, maximum y}
3300
3301\begin{itemize} 
3302\item
3303To set the vacuum chamber, it is needed to add two markers in the lattice,
3304such as MK1 and MK2, MK1 is before the first element and MK2 is after
3305the end element of the vacuum chamber region.
3306The numbers of MK1 and MK2 are the same in the lattice.
3307\item
3308The units are [meter] for minimum x, maximum x, minimum y, maximum y.
3309\item 
3310The first line is to define the global vacuum chamber limit around the ring,
3311and the key words should be "Start","All".
3312\item
3313Lines start with “\#” are comment.
3314\end{itemize}
3315
3316
3317
3318The following is one example of the user vacuum chamber script:
3319\begin{flushleft}
3320         \#*********************************************\\
3321         \# Script to set the vacuum chamber \\
3322         \#\\
3323         \#**********************************************\\
3324\begin{tabular}{l l l l l l}
3325         \# MK1& MK2&  dxmin&  dxmax&  dymin&   dymax  \\
3326         Start&  All&    -35e-3&  35e-3&  -12.5e-3&   12.5e-3\\
3327        \#sdm1& esdm&  -21e-3&  21e-3&   -5e-3&     5e-3\\
3328          debut& ehu600&  -35e-3&  35e-3&  -7e-3&    7e-3\\
3329          ssep&  esep&   -20e-3&  35e-3&  -7e-3&    7e-3\\
3330          ssdm&  esdm&   -21e-3&  21e-3&  -5e-3&    5e-3\\
3331           ssdac& esdac & -35e-3&  25e-3&  -2.5e-3&   2.5e-3\\
3332\end{tabular}
3333\end{flushleft}
3334\end{document}
3335
3336 
3337
Note: See TracBrowser for help on using the repository browser.