Changeset 32 in TRACY3


Ignore:
Timestamp:
Apr 9, 2014, 3:50:11 PM (10 years ago)
Author:
zhangj
Message:

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

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/make_for_gcc.sh

    r25 r32  
    2727./bootstrap
    2828
    29 FFLAGS="-g -O2  -Wall -fbounds-check" CXXFLAGS="-g -O2  -Wall -fno-implicit-templates" CC=gcc F77=gfortran CXX=g++ ./configure --prefix=$dir/$TRACY/tracy
     29FFLAGS="-g -O2 -Wall  -fbounds-check" CXXFLAGS="-g -O2 -Wall -fno-implicit-templates" CC=gcc F77=gfortran CXX=g++ ./configure --prefix=$dir/$TRACY/tracy
    3030
    3131
  • trunk/tracy/autom4te.cache/requests

    r17 r32  
    7070                        'AM_PROG_CC_C_O' => 1,
    7171                        '_AM_MANGLE_OPTION' => 1,
     72                        'AM_SET_LEADING_DOT' => 1,
    7273                        'AM_CONDITIONAL' => 1,
    73                         'AM_SET_LEADING_DOT' => 1,
    7474                        'AM_SET_DEPDIR' => 1,
    7575                        '_AM_DEPENDENCIES' => 1,
     76                        'm4_include' => 1,
    7677                        'AM_PROG_INSTALL_SH' => 1,
    77                         'm4_include' => 1,
    7878                        '_AC_AM_CONFIG_HEADER_HOOK' => 1,
    7979                        'AU_DEFUN' => 1,
     
    9393                      ],
    9494                      {
     95                        '_LT_AC_TAGCONFIG' => 1,
    9596                        'AM_PROG_F77_C_O' => 1,
    96                         '_LT_AC_TAGCONFIG' => 1,
     97                        'AC_INIT' => 1,
    9798                        'm4_pattern_forbid' => 1,
    98                         'AC_INIT' => 1,
     99                        'AC_CANONICAL_TARGET' => 1,
    99100                        '_AM_COND_IF' => 1,
    100                         'AC_CANONICAL_TARGET' => 1,
     101                        'AC_CONFIG_LIBOBJ_DIR' => 1,
    101102                        'AC_SUBST' => 1,
    102                         'AC_CONFIG_LIBOBJ_DIR' => 1,
     103                        'AC_CANONICAL_HOST' => 1,
    103104                        'AC_FC_SRCEXT' => 1,
    104                         'AC_CANONICAL_HOST' => 1,
    105105                        'AC_PROG_LIBTOOL' => 1,
    106106                        'AM_INIT_AUTOMAKE' => 1,
     107                        'AC_CONFIG_SUBDIRS' => 1,
    107108                        'AM_PATH_GUILE' => 1,
    108                         'AC_CONFIG_SUBDIRS' => 1,
    109109                        'AM_AUTOMAKE_VERSION' => 1,
    110110                        'LT_CONFIG_LTDL_DIR' => 1,
     111                        'AC_REQUIRE_AUX_FILE' => 1,
    111112                        'AC_CONFIG_LINKS' => 1,
    112                         'AC_REQUIRE_AUX_FILE' => 1,
     113                        'LT_SUPPORTED_TAG' => 1,
    113114                        'm4_sinclude' => 1,
    114                         'LT_SUPPORTED_TAG' => 1,
    115115                        'AM_MAINTAINER_MODE' => 1,
    116116                        'AM_NLS' => 1,
    117117                        'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
     118                        '_m4_warn' => 1,
    118119                        'AM_MAKEFILE_INCLUDE' => 1,
    119                         '_m4_warn' => 1,
    120120                        'AM_PROG_CXX_C_O' => 1,
     121                        '_AM_COND_ENDIF' => 1,
    121122                        '_AM_MAKEFILE_INCLUDE' => 1,
    122                         '_AM_COND_ENDIF' => 1,
    123123                        'AM_ENABLE_MULTILIB' => 1,
    124124                        'AM_PROG_MOC' => 1,
    125125                        'AM_SILENT_RULES' => 1,
    126126                        'AC_CONFIG_FILES' => 1,
     127                        'include' => 1,
    127128                        'LT_INIT' => 1,
    128                         'include' => 1,
     129                        'AM_PROG_AR' => 1,
    129130                        'AM_GNU_GETTEXT' => 1,
    130                         'AM_PROG_AR' => 1,
    131131                        'AC_LIBSOURCE' => 1,
     132                        'AC_CANONICAL_BUILD' => 1,
    132133                        'AM_PROG_FC_C_O' => 1,
    133                         'AC_CANONICAL_BUILD' => 1,
    134134                        'AC_FC_FREEFORM' => 1,
    135135                        'AH_OUTPUT' => 1,
     136                        '_AM_SUBST_NOTMAKE' => 1,
    136137                        'AC_CONFIG_AUX_DIR' => 1,
    137                         '_AM_SUBST_NOTMAKE' => 1,
     138                        'AM_PROG_CC_C_O' => 1,
     139                        'sinclude' => 1,
    138140                        'm4_pattern_allow' => 1,
    139                         'sinclude' => 1,
    140                         'AM_PROG_CC_C_O' => 1,
     141                        'AM_CONDITIONAL' => 1,
     142                        'AC_CANONICAL_SYSTEM' => 1,
    141143                        'AM_XGETTEXT_OPTION' => 1,
    142                         'AC_CANONICAL_SYSTEM' => 1,
    143                         'AM_CONDITIONAL' => 1,
    144144                        'AC_CONFIG_HEADERS' => 1,
    145145                        'AC_DEFINE_TRACE_LITERAL' => 1,
  • trunk/tracy/tools/soltracy.cc

    r11 r32  
    127127  //print flat file with all the design values of the lattice,
    128128  prtmfile("flat_file.dat");
    129   // print location, twiss parameters and close orbit at all elements position to a file
    130   getcod(dP, lastpos);
    131   prt_cod("cod.out", globval.bpm, true);
    132 
     129 
     130  //find the closed orbit of a ring
     131  if(globval.RingType == 1){
     132    getcod(dP, lastpos);
     133   
     134    // compute up to 3rd order momentum compact factor
     135    get_alphac2();
     136  }
     137 
     138 
     139  // print location, twiss parameters and close orbit/orbit at the BPM positions to a file
     140    if(globval.bpm !=0){
     141      prt_beampos("6Dcod.out");
     142    }
     143 
     144   
     145   
     146   
     147 
     148 
     149   
     150 
    133151  //get_matching_params_scl(); // get tunes and beta functions at entrance
    134   // compute up to 3rd order momentum compact factor
    135   get_alphac2();
     152 
    136153  //cout << endl << "computing tune shifts" << endl;
    137154  //dnu_dA(10e-3, 5e-3, 0.002);
  • trunk/tracy/tracy/doc/soltracy3_userManual_developer.tex

    r11 r32  
    1 \documentclass{article}
    2 \author{Jianfeng Nadolski \footnote{LAL, Orsay, France.Email: \href{mailto:zhangj@lal.in2p3.fr}{zhangj@lal.in2p3.fr}}}
     1\documentclass[fleqn]{article}
     2\author{Jianfeng Zhang \footnote{LAL, Orsay, France.Email: \href{mailto:zhangj@lal.in2p3.fr}{zhangj@lal.in2p3.fr}}}
    33\title{Soltracy3 mannual for developpers}
    44
    5 \usepackage{amsmath}
     5%% left align the long equations in the 'aligned' enviroment
     6\usepackage[fleqn]{amsmath}
    67\usepackage{amssymb}
    78\usepackage{graphicx}
     
    5253\tableofcontents
    5354
    54 %\onehalfspacing
    55 
    56 \section{Log}
     55\onehalfspacing
     56
     57\section{Change Log}
    5758
    5859\begin{itemize}
     
    6566
    6667\section{Introduction}
    67   Tracy is a code to do long term tracking, and is written in the mixture of c and c++.
     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
    68103This 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
    69105   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.
    70106Attention:
     
    76112\section{ Non-parallel version Tracy}
    77113\subsection {Compile}
    78 The make file of Tracy is generated by “automake”. Based on the compilers used,
     114The make file of Tracy is generated by ``automake''. Based on the compilers used,
    79115user needs to update “\textsf{\wrapletters{make\_for\_gcc.sh}}” under
    80116path ``\pathfont{\$HOME/TracyIII/}''
     
    279315the vertical correctors on which the multipole field errors are added in SOLEIL lattice;
    280316\tracypara{GS} is the name of the start girder; \tracypara{GE} is the name of the end girder;
    281 \tracypara{BPM} is the name of beam position monitors defined in the lattice file;
     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.
    282319\tracypara{QT} is the name of the skew quadrupoles defined in the lattice.  Generally,
    283320user needs to define horizontal, vertical correctors and BPMs when reading the misalignment
     
    345382
    346383\section{Physics: Hamiltionian}
    347 The dynamic motion of a conserved system can be described by a Hamiltonian. For an accelerator system without radiation
     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
    348388damping (energy loss) and RF cavities (energy gain), the motion of a single electron in the magnetic field can be described using the
    349389following Hamitonian in the curvilinear coordinate system (Merz...)
     
    587627
    588628
    589 \section{ Lattice file}
     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}
    5901226In the lattice, RF cavity with the correct harmonic number must be defined!!!
    5911227Otherwise Tracy will give the error message:
     
    6501286
    6511287\subsection{Variables}
    652   User can define the variables in the lattice file. For example:
     1288  User can define variables in the lattice file. For example:
    6531289\begin{tightcenter}
    6541290                   \textsf{Intmeth = 4};
     
    6681304
    6691305\subsection{Global variables}
    670   After define the ring, user needs to define the system parameters of the lattice:
    671 Energy, the beam energy with unit [GeV].
    672  dP, the relative momentum offset of the particle.
    673 CODeps, the convergence for the algorism to find the closed orbit.
    674  For example:
    675                 Energy = 2.739;
    676 dP    = 1.0d-10;
    677                                                            CODeps= 1.0d-15;
    678 These definitions are mandatory.
     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}
    6791324
    6801325\subsection{DRIFT}
     
    7041349
    7051350\latticedef{Element\_name:}{bending,}{L = $\langle \dots \rangle$, T = $\langle \dots \rangle$,
    706 \textbf{T1} = $\langle \dots \rangle$, \textbf{T2}=$\langle \dots \rangle$,
    707 \textbf{H1} = $\lbrack \dots \rbrack$, \textbf{H2}= $\lbrack \dots \rbrack$,
    708 \textbf{gap} = $\lbrack \dots \rbrack$, \textbf{edge\_effect1} = $\lbrack \dots \rbrack$, 
    709 \textbf{edge\_effect2} = $\lbrack \dots \rbrack$, \textbf{K} =$\lbrack \dots \rbrack$,
    710 \textbf{method} = $\langle \dots \rangle$, \textbf{N} = $\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$;}
    7111356 
    7121357
     
    7551400
    7561401\vspace{0.05in}
    757 For example:\\
     1402\textit{Example}:\\
    7581403\vspace{0.05in}
    7591404\textsf{beta\_gap=37e-3; tracy\_gap=beta\_gap*2*0.724;}
    760 \latticedef{BEND1 :}{ \textbf{bending},}{ \textbf{L} = 1.05243, \textbf{T} = 11.25, \textbf{T1} = 5.5906,
    761 \textbf{T2} = 5.67658, \textbf{K} = 0.00204,gap=tracy\_gap,
    762 \textbf{edge\_effect1} = 1, \textbf{edge\_effect2} = 1, \textbf{N} = 4,
    763 \textbf{method} = intmeth;}
    764 
    765 The parameters of ``bending'' are optional, the default values for the missing parameters are 0,
    766  and the default value for ``method'' is also 0.
     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}
    7671421
    7681422
     
    7911445tracy\_gap = beta\_gap*2*0.348;}
    7921446
    793 
    794  \latticedef{DIP:}{bending,}{L=0.27646,T= 45, T1=0, T2=0,gap=tracy\_gap,edge\_effect1=1,edge\_effect2=1,method=intmeth,N=4;}
    795 
    796 Elegant definition of dipole with dipole fringe field: \\
    797 \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;}
     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;}
    7981455\end{itemize}
    7991456
     
    9771634The multipole field components $a_n$ and $b_n$ are defined as
    9781635\begin{eqnarray}   
     1636\begin{aligned}
    9791637b_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_y }{\partial x ^{n-1}}|_{x=0,y=0} \\
    9801638a_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_x }{\partial x ^{n-1}}|_{x=0,y=0} \\
    9811639B \rho & = & \frac{p_0}{e}
     1640\end{aligned}
    9821641\end{eqnarray}
    9831642$B \rho$ is the magnetic rigidity, $p_0$ is the design beam momentum, $e$ is the electric charge.
     
    9961655 \end{equation}
    9971656 The total magnetic field with $1^{st}$ to $n^{th}$ order field components can be calculated using 
    998  \begin{eqnarray}
     1657 \begin{equation}
    9991658\label{eqn:total:field}
    1000  B_y + i * B_x & = & (b_n + i*a_n) * (x+i*y)*(x + i*y)^{n-1} + O(n-1) \\
    1001              & = & [(b_n*x - a_n*y) + b_{n-1} + i*(a_n*x + b_n*y + a_{n-1})]*(x+i*y)^{n-1} + O(n-2) \\
    1002               & ...&
    1003  \end{eqnarray}
     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
    10041669
    10051670The eqn.~\ref{eqn:total:field} is used in Tracy3 to calculate the effective fields of the
     
    10421707\end{eqnarray*}
    10431708
    1044 \subsection{ wiggler (To be updated.)}
     1709\subsection{SOLENOID (to be updated)}
     1710
     1711\subsection{WIGGLER (To be updated.)}
    10451712
    10461713\latticedef{Element\_Name:}{Wiggler,}{L  = $\langle$ length $\rangle$,BoBrhoV = $\langle$ B/Brho $\rangle$,
     
    11091776
    11101777
    1111 \subsection{INSERTION DEVICE}
     1778\subsection{INSERTION DEVICE (to be updated)}
    11121779
    11131780\latticedef{Element\_Name:}{insertion,}{scaling1 = 1/0, scaling2=1/0,method = interpolation\_method,
     
    11831850\latticedef{CAV:}{Cavity,}{Frequency = 499.95e6, Voltage=1.22e6, phase = 30, harnum=328;}
    11841851
    1185 The harmonic number of the RF cavity is mandatory, and the other parameters of “cavity” are
    1186 optional, the default values are 0.
     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.
    11871856
    11881857\subsection{CORRECTOR}
    11891858
    1190 \latticedef{Element\_Name:}{corrector,}{horizontal/vertical, method = integrated method;}
     1859\latticedef{Element\_Name:}{corrector,}{horizontal/vertical, L = , kick = , roll = ,
     1860           N = , method = integrated method;}
    11911861
    11921862\begin{table}[htbp]
     
    11941864\caption{Parameters of correctors.}
    11951865\label{tab:corrector-para}
    1196 \begin{tabular}{| p{0.2\linewidth} | p{0.2\linewidth} | p{0.1\linewidth} | p{0.4\linewidth} |}
    1197 \hline
    1198 \textbf{Horizontal / vertical} & - & ??? & “horizontal”: horizontal corrector; “vertical”: vertical
     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
    11991871 corrector \\
    12001872\hline
    1201 \textbf{method} & - & ??? & 1, 2, 4. Order of symplectic integration method.
     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.
    12021882Value ‘1’ means 1st order, ‘2’ means 2nd order, and ‘4’ means 4th order \\
    12031883\hline
     
    12161896It defines a vertical corrector.
    12171897
    1218 The parameters of “corrector” are optional, the default value for ‘method’ is 0.
    1219 
    12201898\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
    12211909For a lattice with correctors, user must specify the name of  corrector in the Tracy
    12221910input file with the commands:
     
    12271915orbit correction (????); \tracypara{VCM} is the name of the corrector defined in the
    12281916lattice for vertical orbit correction.
    1229 
    1230 
    1231 \subsection{MARKER}
    1232 
    1233 \latticedef{Element\_Name:}{marker;}{}
     1917\end{itemize}
     1918
    12341919
    12351920\subsection{BEAM POSITION MONITOR (To be updated)}
     
    12381923\latticedef{BPM:}{type;}{}
    12391924
    1240 Normally Its type is defined as “Marker” type, but in order to include the misalignment
     1925Normally Its type is defined as ``Marker'' type, but in order to include the misalignment
    12411926error of BPM into the lattice, it must be defined as “Beam Position Monitor” type
    12421927which is in fact multipole type, since only the element with multipole type is saved
     
    12461931For lattice with BPMs, user must specify the name of  BPM in the Tracy input file
    12471932 with the command:
    1248                     \latticedef{bpm}{beaPosMonitor}
    1249 Here “beaPosMonitor” is the name of the BPMs defined in the lattice.
     1933                    \latticedef{bpm\_name }{beaPosMonitor}{}
     1934Here ``beaPosMonitor'' is the name of the BPMs defined in the lattice.
    12501935
    12511936\subsection{GIRDER}
    1252   Girder is a special element, it’s the girder used in the real machine to support the magnetic elements and other elements. It is defined as:
    1253                    Symbol: type;
    1254 
    1255   Normally Its type is defined as “Marker” type, but in order to include the misalignment error of girder into the lattice, it must be defined as “multipole” type, since only the element with multipole type is saved with displacement error, field error, etc.
    1256   For convenience, it’s better to define the beginning of the girder and also the end of the girder, and the elements between the beginning and end of the girders are the elements who are put on the girder in the real machine.
    1257 
    1258 Notice:
    1259 For lattice with girders,
    1260  User must specify the name of  girder in the input file “*.prm” with the commands:
    1261                                    gs       Girder\_Start
    1262                                    ge       Girder\_End
    1263 
    1264 Here ‘Girder\_Start’ is the name of the start of girder defined in the lattice; ‘Girder\_End’ is the name of the end of girder defined in the lattice.
    1265 
    1266 \subsection{SOLENOID...TO BE UPDATED...}
    1267 
     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;}{}
    12681967
    12691968\subsection{ELEMENT BLOCK}
    1270   To construct the element block, use the following format:
    1271            Symbol: elem1, elem2,
., block1,block2;
    1272 Here “Symbol” is the name of the element block, and “elem1”, “elem2”, “block1”, “block2” are the element or sub element blocks in this element block.
    1273   If there are N the same element/block subsequently, user can use ‘N*element/block’ to simply the definition. For example:
    1274                         SINJ: SD1a, ssep, 3*SEP,esep,SD1c,eHU600,SD1d;
    1275 In this example element block, there are 9 elements/blocks, and 3 elements/blocks “SEP” subsequently.
     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.
    12761981
    12771982\subsection{LINE}
    12781983 User can define the cell structure using the command:
    12791984
    1280              CELL : $\langle$ block name $\rangle$, SYMMETRY=$\langle$ symmetry $\rangle$;
    1281 
    1282 $\langle$ block name $\rangle$ is the name of a block; $\langle$ symmetry $\rangle$ is the number of super symmetry or the number of the block in the ring.
    1283 
    1284 Example:
    1285 
    1286          CELL: BL1, Symmetry=12;
    1287 
    1288 This example defines the cell with block “BL1”, and the number of super symmetry is 12. The output of the Tracy3 with symmetry large than 1 will give the
     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
    12891999tunes and chromaticities in one symmetric period.
     2000
     2001\end{flushleft}
    12902002
    12912003\subsection{RING}
    12922004To define the ring, use the command:
    1293                RING: elem, block
.
    1294 It’s similar to define an element block, but must with the fixed symbol name “RING”. For example:
    1295 RING: DEBUT,SUP1,SUP2,SUP3,SUP4,CAV,FIN;
    1296 5.1.23  End line
     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}
    12972013 To end the lattice file, user needs to use the following command at the end of the lattice file:
    12982014End;
     
    13012017
    13022018\section{Commands}
    1303   The following commands turn on the boolean flags in the code to set the machine parameters and carry on different calculations. All these commands are optional; user can choose whichever they need. If user wants to use the flag, they can write the flag in the script, if they do not want to use it, they can delete or comment out (add “\#” at the beginning of command line) the flag. The Boolean flags in the user input script have the following features:
    1304 If the flags are not active, then the default values for all the boolean commands are false.
    1305 The code will execute the command according to the sequence defined in the input script “*.prm”. For example,
    1306 FitTune4Flag     qp7a qp7b  qp9a qp9b  18.18 10.28
    1307                           ReadMultipoleFlag
    1308                        FitTune4Flag     qp7a qp7b  qp9a qp9b  18.202 10.317
    1309 The code will fit tunes to the target tunes (18.18  10.28), and then read multipole field errors into the lattice, then fit the tunes to a new set of values (18.202 10.317).
    1310 User can define the same Boolean commands as often as they want in the same input script; but user can only define maximum 500 commands in one input script. 
    1311 The user defined script can be used both for the non-parallel and parallel version Tracy; the output files are the same for both versions.
     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}
    13122072
    13132073\subsection{QuadFringeOnFlag }
    1314 To activate quadrupole fringe field, use the command:\\
    1315 QuadFringeOnFlag\\
    1316 in the “*.prm” script. With this command, user can define the fringe field at the entrance or exit of the quadrupole together with the command FF1 = 1 or FF2 = 1 of the quadrupoles which are defined in the lattice file; if FF1 or FF2 not equals to 1, then there is no fringe field at the entrance or exit of the quadrupoles even if QuadFringeOnFlag is active in the “*.prm” file.
    1317  This flag is a global flag, if user set this flag in the input script, it will always have effects until this flag is reset.
     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.
    13182085
    13192086\subsection{QuadFringeOffFlag }
    13202087To deactivate quadrupole fringe field, use the command:
    1321 QuadFringeOffFlag
    1322 With this command, user can deactivate the fringe field at the entrance and exit of the quadrupole, even if FF1 = 1 or FF2 = 1 for the quadrupole in the lattice file.
    1323   This flag is a global flag, if user set this flag in the input script, it will always have effects until this flag is reset.
     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.
    13242096
    13252097\subsection{RFvoltageFlag}
    1326   User can reset the RF voltage by setting “RFvoltageFlag” to replace the value of RF voltage which is defined in the lattice. For example:
    1327 RFvoltageFlag    3000000
    1328 Here “RFvoltageFlag” is the name of the keyword command, ‘3000000’ is the value of RF voltage with the unit [volt].
    1329   If the ring has more than one RF cavities, the related parameters are defined as the total values for one RF cavity.
     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.
    13302107
    13312108\subsection{PrintTrackFlag}
    13322109To print the coordinates tracked around COD at each element to a file, use the command:
    1333 PrintTrackFlag           track\_file        x    px   y  py  delta    ctau     nturn
     2110\tracycommand{PrintTrackFlag}{           track\_file        x    px   y  py  delta    ctau     nturn}
    13342111
    13352112For example:
    1336 PrintTrackFlag           track.out         0.001     0.0    0.0    0.0    0.0    0.0     50
    1337 
    1338 The parameters and the default values of “PrintTrackFlag” are shown in Table .
     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}.
    13392116
    13402117\begin{table}[h]
    13412118\centering
    1342 \caption{}
    1343 \label{}
    1344 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1345 \hline
     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 & - \\
    13462376\hline
    13472377\end{tabular*}
    13482378\end{table}
    13492379
    1350 Table   Parameters of command "PrintTrackFlag".
    1351 Name
    1352 Description
    1353 Default value
    1354 Unit
    1355 track\_file
    1356 File to save the tracked coordinates around each lattice element
    1357 track.out
    1358 -
    1359 x
    1360 Start tracking horizontal coordinate
    1361 0.001
    1362 [m]
    1363 px
    1364 Start tracking horizontal canonical momentum px normalized by reference momentum p0, that is: px = px/p0.  Normally px is approximate as horizontal deviation with unit [rad].
    1365 0.0
    1366 
    1367 -
    1368 y
    1369 Start tracking vertical coordinate
    1370 0.0
    1371 [m]
    1372 py
    1373 Start tracking vertical canonical momentum py normalized by reference momentum p0, that is: py = py/p0. Normally px is approximate as vertical deviation with unit [rad].
    1374 0.0
    1375 
    1376 -
    1377 delta
    1378 Start tracking relative energy offset
    1379 0.0
    1380 -
    1381 ctau
    1382 Start tracking longitudinal coordinate
    1383 0.0
    1384 [m]
    1385 nturn
    1386 Number of turn for tracking
    1387 50
    1388 -
    1389 
    1390 \subsection{PrintTrackElemFlag}
    1391 To print the coordinates tracked (NOT around COD) at a certain element to a file, use the command:
    1392 PrintTrackFlag           track\_file        x    px   y  py  delta    ctau     nelem1 nelem2
    1393 
    1394 For example:
    1395 PrintTrackFlag           track.out         0.001     0.0    0.0    0.0    0.0    0.0     50 1 2
    1396 
    1397 The parameters and the default values of “PrintTrackElemFlag” are shown in Table .
    1398 
    1399 \begin{table}[h]
    1400 \centering
    1401 \caption{}
    1402 \label{}
    1403 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1404 \hline
    1405 \hline
    1406 \end{tabular*}
    1407 \end{table}
    1408 
    1409 Table   Parameters of command "PrintTrackElemFlag".
    1410 Name
    1411 Description
    1412 Default value
    1413 Unit
    1414 track\_file
    1415 File to save the tracked coordinates around each lattice element
    1416 track.out
    1417 -
    1418 x
    1419 Start tracking horizontal coordinate
    1420 0.001
    1421 [m]
    1422 px
    1423 Start tracking horizontal canonical momentum px normalized by reference momentum p0, that is: px = px/p0.  Normally px is approximate as horizontal deviation with unit [rad].
    1424 0.0
    1425 
    1426 -
    1427 y
    1428 Start tracking vertical coordinate
    1429 0.0
    1430 [m]
    1431 py
    1432 Start tracking vertical canonical momentum py normalized by reference momentum p0, that is: py = py/p0. Normally px is approximate as vertical deviation with unit [rad].
    1433 0.0
    1434 
    1435 -
    1436 delta
    1437 Start tracking relative energy offset
    1438 0.0
    1439 -
    1440 ctau
    1441 Start tracking longitudinal coordinate
    1442 0.0
    1443 [m]
    1444 nelem1
    1445 index of start lattice element for tracking
    1446 
    1447 nelem2
    1448 index of end lattice element for tracking
    1449 
    1450 \subsection{PrintTwissFlag}
    1451 
    1452 Print Twiss parameters to a user defined file \\
    1453 
    1454 With the command “PrintTwissFlag”, Tracy 3 will print the Twiss parameters to a user defined file. The format is:
    1455                             PrintTwissFlag                user\_defined\_file
    1456 
    1457 If user use the command PrintTwissFlag but without define the file name, then the code will print the Twiss parameters to a default file “twiss.out”.
    1458 
    1459 \subsection{PrintCODFlag}
    1460 Print COD (Close Orbit Distortion) to a user defined file\\
    1461 
    1462 With the command “PrintCODFlag”, the code will print the close orbit distortion to a user defined file. The format is:
    1463                             PrintCODFlag                user\_defined\_file
    1464 If user use the command PrintCODFlag but without defining the file name, then the closed orbit will be printed to the default file “printcod.out”.
    1465 In Tracy 3, close orbit file “cod.out” is automatically generated after reading the lattice.
    1466    In the outuput file of the command PrintCODFlag, the data is saved in the following format:
    1467   \# i    name  s  code  betax   nux   betay   nuy  xcod   ycod      dSx     dSy      dipx   dipy
    1468   \#               [m]          [m]              [m]            [mm]   [mm]    [mm]   [mm] [mrad]  [mrad]
    1469  \#
    1470 Where “\#” denotes the command line, the meanings of the above parameters are shown in Table .
    1471 
    1472 \begin{table}[h]
    1473 \centering
    1474 \caption{}
    1475 \label{}
    1476 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1477 \hline
    1478 \hline
    1479 \end{tabular*}
    1480 \end{table}
    1481 
    1482 Table   Parameters in the output file of close orbit.
    1483 Name
    1484 Description
    1485 Unit
    1486 i
    1487   Number of the element
    1488 -
    1489 name
    1490   Element name defined in lattice
    1491 -
    1492 s
    1493   Longitudinal length
    1494 [m]
    1495 code
    1496 Symbol for the element:
    1497  0.5   dipole
    1498 -1.0   defocusing quadrupole
    1499  1.0   focusing quadrupole
    1500 -1.5   defocusing sextupole
    1501  1.5   focusing sextupole
    1502  0      other element
    1503 
    1504 
    1505 
    1506 -
    1507 betax
    1508 Horizontal beta function
    1509 [m]
    1510 nux
    1511 Horizontal tune
    1512 -
    1513 betay
    1514 Vertical beta function
    1515 [m]
    1516 nuy
    1517 Vertical tune
    1518 -
    1519 xcod
    1520 Horizontal closed orbit distortion
    1521 [mm]
    1522 ycod
    1523 Vertical closed orbit distortion
    1524 [mm]
    1525 dSx
    1526 Horizontal displacement of the element
    1527 [mm]
    1528 dSy
    1529 vertical displacement of the element
    1530 [mm[
    1531 dipx
    1532 Horizontal dipole strength of the element
    1533 [mrad]
    1534 dipy
    1535 vertical dipole strength of the element
    1536 [mrad]
    1537 
    1538 \subsection{ReadChamberFlag}
    1539 Read vacuum chamber setting from an external file \\
    1540 
    1541   To read the vacuum chamber from the user defined chamber file, use the command:
    1542 ReadChamberFlag        Chamber\_example.dat
    1543   In the file ‘Chamber\_example.dat’, user can specify the vacuum limit at the different region of the lattice; the format of the chamber file is given in section .
    1544 
    1545 \subsection{ReadfefileFlag}
    1546 Read lattice element multipole field errors from an external file \\
    1547 
    1548   To read the multipole field errors of the lattice elements from the user defined file, use the command:
    1549 ReadfefileFlag             dip.fe
    1550 Tracy will read the systematic and random multipole field errors of the lattice elements defined in the file “dip.fe”, and then replace the corresponding field components of the elements with the new field errors. The formats to specify the systematic and random multipole field errors in a file are given in section Error: Reference source not found.
    1551 
    1552 \subsection{ReadaefileFlag}
    1553 Read lattice element misalignment errors from a file \\
    1554 
    1555   To read the misalignment error of the lattice elements from the user defined file, use the command:
    1556 ReadaefileFlag             dip.ae
    1557 Tracy will read the systematic and random misalignment errors of the lattice elements from the file “dip.fe”, and replace the misalignment errors of the corresponding components of the elements. The formats to define the systematic and random misalignment errors of the lattice elements in a file are given in section .
    1558 
    1559 \subsection{CODCorrectFlag}
    1560 Closed orbit (COD) correction \\
    1561 
    1562    The orbit distortion is corrected using SVD (Singular Value Decomposition) method in Tracy 3. In order to do orbit correction, user needs to call the command
    1563 CODCorrectFlag
    1564 and then specify the following parameters in the user defined “*.prm” file.
    1565 Specify the element names of horizontal, vertical correctors, and beam position monitors used in the orbit correction as the following examples:
    1566 h\_corr       HC
    1567 v\_corr      VC
    1568 BPM        bpm
    1569 User also need to specify the states of the correctors to trigger on/off the correction using the following parameters:
    1570 hcorr\_file        hcorr\_56nom.state
    1571 vcorr\_file        vcorr\_56nom.state
    1572   In the file “hcorr\_56nom.state”, a list of numbers (1 or 0) are given to the horizontal correctors, according to the sequence in the lattice; “1” means the corresponding corrector is used for horizontal orbit correction, “0” means this corrector is not used in the horizontal orbit correction. The definition rules of vertical corrector states in “vcorr\_56nom.state” are the same as “vcorr\_56nom.state”. 
    1573  
    1574 This parameter defines number of iterations to correct the orbit distortion, this value should be an integer number not smaller than 1.
    1575 n\_orbit       3
    1576 This parameter defines number of singular values in H-plane, must be not larger than the number of correctors used for orbit correction
    1577 nwh           60
    1578 This defines number of singular values in V-plane, must be not larger  than the number of correctors used for orbit correction
    1579 nwv           60
    1580 
    1581   In Tracy 3, during the closed orbit correction:
    1582 1) Beam response matrices between beam position monitors and horizontal/vertical correctors are calculated and written to the files “svdh.out”/ “svdv.out”, respectively. The maximum number of horizontal/vertical correctors used for orbit correction is 250.
    1583 2) The code corrects the closed orbit distortion.
    1584 3) Horizontal and vertical orbits at the locations of all beam position monitors during the correction are saved to the files “horbit.out” and “vorbit.out”, respectively.
    1585 4) A file “OrScanFile.out” will be saved with the summaries of the mean and RMS values of the orbits before and after correction.
    1586 5) Finally, Twiss parameters, closed orbit distortion at the lattice elements are saved to a summary file “summary\_miserr\_codcorr.out”, the format of this file is explained in Table .
    1587 
    1588 \subsection{TuneTracFlag}
    1589 
    1590 Get tunes by tracking \\
    1591 
    1592   To get tunes by tracking, use command:
    1593 TuneTracFlag
    1594   The tunes obtained by tracking are printed on the screen.
    1595 
    1596 \subsection{ChromTracFlag}
    1597 Get chromaticities by tracking \\
    1598 
    1599   To get chromaticity by tracking, use command:
    1600 ChromTracFlag
    1601   The chromaticities obtained by tracking are printed on the screen.
    1602 
    1603 \subsection{AmplitudeTuneShiftFlag}
    1604 
    1605 Tune shift with amplitude \\
    1606 
    1607 
    1608   To calculate tune shift with amplitude, one needs to use the following command:
    1609 AmplitudeTuneShiftFlag nudx\_file nudz\_file nxpoint  nypoint nturn  xmax  ymax  delta
    1610 For example:
    1611 AmplitudeTuneShiftFlag   nudx.out  nudz.out 50  30  516  0.035  0.02  0.0
    1612 
    1613 The meanings of parameters and default values of command “AmplitudeTuneShiftFlag” are shown in Table . If user uses the command AmplitudeTuneShiftFlag without parameters, then the code will use all the default values.
    1614 
    1615 \begin{table}[h]
    1616 \centering
    1617 \caption{}
    1618 \label{}
    1619 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1620 \hline
    1621 \hline
    1622 \end{tabular*}
    1623 \end{table}
    1624 
    1625 Table     Parameters of the command to calculate tune shift with amplitude
    1626 Parameters
    1627 Meaning
    1628 Default values
    1629 nudx\_file
    1630 File to save the calculated tune shift with horizontal  amplitude
    1631 nudx.out
    1632 nudz\_file
    1633 File to save the calculated tune shift with vertical amplitude
    1634 nudz.out
    1635 nxpoint
    1636 Number of points in horizontal direction
    1637 31
    1638 nypoint
    1639 Number of points in vertical direction
    1640 21
    1641 nturn
    1642 Number of turns to track tune
    1643 516
    1644 xmax
    1645 Maximum amplitude of x with the unit [m]
    1646 0.025
    1647 ymax
    1648 Maximum amplitude of y with the unit [m]
    1649 0.005
    1650 delta
    1651 Energy offset of the particle
    1652 0.0
     2380
    16532381     
    16542382\subsection{EnergyTuneShiftFlag}
    16552383Tune shift with energy \\
    16562384
    1657 
    16582385To calculate tune shift with energy, one needs to use the command:
    1659 EnergyTuneShiftFlag  nudp\_file  npoint  nturn  deltamax
     2386\tracycommand{EnergyTuneShiftFlag}{  nudp\_file  npoint  nturn  deltamax}
     2387
    16602388For example:
    1661 EnergyTuneShiftFlag   nudptest.out    31    1026    0.06
    1662 The meaning of parameters and default values of this command are shown in Table .
     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}.
    16632392If user uses command EnergyTuneShiftFlag without parameters, then the code will use all the default values.
    16642393
    16652394\begin{table}[h]
    16662395\centering
    1667 \caption{}
    1668 \label{}
    1669 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1670 \hline
     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 - \\
    16712410\hline
    16722411\end{tabular*}
    16732412\end{table}
    16742413
    1675 Table   Parameters of the command to calculate tune shift with energy
    1676 parameter
    1677 meaning
    1678 default value
    1679 nudp\_file
    1680 File to save the calculated tune shift with energy
    1681 nudp.out
    1682 npoint
    1683 Number of points
    1684 31
    1685 nturn
    1686 Number of turns  for tracking
    1687 516
    1688 deltamax
    1689 Maximum energy offset of the particle
    1690 0.06
     2414
    16912415   
    16922416\subsection{FmapFlag}
    1693 Frequency map analysis for on momentum particle.
     2417Frequency map analysis for on momentum particle. \\
     2418
    16942419Track the coordinates (x, px, y, py, delta, ctau) of the particle,
    16952420the coordinates (x, px, y, py) are tracked around the closed orbit;
     
    17032428
    17042429To do frequency map analysis for the on momentum particle, use the command:
    1705 FmapFlag   fmap\_file    nxpoint   nypoint    nturn  xmax   ymax   delta   diffusion \\
     2430\tracycommand{FmapFlag}{   fmap\_file    nxpoint   nypoint    nturn  xmax   ymax   delta   diffusion}
    17062431or
    1707 FmapFlag   fmap\_file    nxpoint   nypoint    nturn  xmax   ymax   delta   diffusion printloss \\
     2432\tracycommand{FmapFlag}{   fmap\_file    nxpoint   nypoint    nturn  xmax   ymax   delta   diffusion printloss }
    17082433
    17092434 For example:
    1710 FmapFlag   fmap.out   31   21   516   0.025   0.005   0.0   true 
     2435\tracycommand{FmapFlag}{   fmap.out   31   21   516   0.025   0.005   0.0   true  }
    17112436or
    1712 FmapFlag   fmap.out   31   21   516   0.025   0.005   0.0   true  true
    1713 
    1714 
    1715 The meaning of parameters and default values of this command are shown in Table . If user uses command FmapFlag without parameters, then the code will use all the default values.
     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.
    17162442
    17172443\begin{table}[h]
    17182444\centering
    1719 \caption{}
    1720 \label{}
    1721 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1722 \hline
     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''. & - &- \\
    17232475\hline
    17242476\end{tabular*}
    17252477\end{table}
    17262478
    1727 Table   Parameters of the command to do frequency map analysis for on momentum particle.
    1728 Parameters
    1729 meaning
    1730 Default values
    1731 fmap\_file
    1732 File to save the calculated frequency map analysis
    1733 fmap.out
    1734 nxpoint
    1735 Number of points in the horizontal direction
    1736 31
    1737 nypoint
    1738 Number of points in the vertical direction
    1739 21
    1740 nturn
    1741 Number of turns for tracking; if ``diffusion'' is
    1742 true, then the tunes will calculated in the first Nturn
    1743 and then the second Nturn, and the tune difference
    1744 between these two tunes is the tune diffusion.
    1745 516
    1746 xmax
    1747 Maximum amplitude in the horizontal direction with the unit [m]
    1748 0.025
    1749 ymax
    1750 Maximum amplitude in the vertical direction with the unit [m]
    1751 0.005
    1752 delta
    1753 Energy offset of the particle
    1754 0.0
    1755 diffusion
    1756 Boolean flag, true/false; to compute tune diffusion at the first N turns and second N turns.
    1757 true
    1758 
    1759 printloss (optional)
    1760 Boolean flag, true/flase; print out the last information of the tracked particleto and external file? If true, the output file is ``fmap\_file.loss''.
     2479
     2480
    17612481\subsection{FmapdpFlag}
    17622482Frequency map analysis for off momentum particle \\
     
    17672487FmapdpFlag   fmapdp\_file    nxpoint    nepoint    nturn    xmax  emax  y  diffusion printloss
    17682488
    1769 The meaning of parameters and default values are shown in Table .  If user only uses the command FmapdpFlag but without defining all the parameters, then the code uses the default values.
     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.
    17702492
    17712493\begin{table}[h]
    17722494\centering
    1773 \caption{}
    1774 \label{}
    1775 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1776 \hline
     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''. & - & \\
    17772521\hline
    17782522\end{tabular*}
     2523\caption{Parameters of the command ``FmapdpFlag''.}
    17792524\end{table}
    17802525
    1781 Table  Parameters of the command “FmapdpFlag”.
    1782 parameters
    1783 meaning
    1784 default value
    1785 fmapdp\_file
    1786 File to save the calculated frequency map analysis
    1787 fmapdp.out
    1788 nxpoint
    1789 Number of points in the horizontal direction
    1790 31
    1791 nepoint
    1792 Number of points for the energy
    1793 21
    1794 nturn
    1795 Number of turns for tracking
    1796 516
    1797 xmax
    1798 Maximum amplitude in the horizontal direction with the unit [m]
    1799 0.025
    1800 emax
    1801 Maximum energy offset of the particle
    1802 0.005
    1803 y
    1804 Amplitude in the vertical direction with the unit [m]
    1805 0.0
    1806 diffusion
    1807 Boolean flag to compute tune diffusion
    1808 true
    1809 
    1810 printloss (optional)
    1811 Boolean flag, true/flase; print out the last information of the tracked particleto and external file? If true, the output file is ``fmapdp\_file.loss''.
    18122526
    18132527
     
    18152529Add coupling by the random rotation of the full quadrupoles \\
    18162530
    1817   To simulate coupling in the lattice, use can add the random rotation error to all the full quadrupole, using the command as the following example:
    1818 ErrorCouplingFlag         0    0.0007
    1819 In this example, “0” is the random seed number; “0.0007” is the RMS value of the rotation angles of all the quadrupoles with the unit [rad].
    1820   After setting the rotation error in the lattice, the code will generate a file with the file name “flat\_file\_errcoupling\_full.dat” at the current working directory, user can check the error setting of quadrupoles in this file; then the coupling will be calculated and Twiss parameters after adding the random rotation errors will be saved to the file “linlat\_errcoupling.out”.
     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''.
    18212543
    18222544\subsection{ErrorCoupling2Flag}
    18232545Add coupling by random rotation of the half quadrupoles \\
    18242546
    1825   In order to get the beam parameters in the middle of the quadrupoles, each quadrupole in the lattice can be cut into two parts. In such case, the coupling of the lattice can be generated by random rotation of all the half quadrupoles in the lattice, using the command as the following example:
    1826 ErrorCoupling2Flag         0    0.0007
    1827 In this example, “0” is the random seed number; “0.0007” is the RMS value of the rotation angle of the quadrupole with the unit [rad].
    1828   After setting the errors in the lattice, the code will generate a file at the current working directory with the file name “flat\_file\_errcoupling\_half.dat”, user can check the error setting of quadrupoles in this file. After adding the random rotation errors, the coupling will be calculated and Twiss parameters will be saved to the file “linlat\_errcoupling2.out”.
    1829   This command is dedicated for Soleil lattice in which each quadrupole is cut into two half quadrupoles.
     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.
    18302564
    18312565\subsection{CouplingFlag}
    18322566Calculate coupling and emittance \\
    18332567
    1834   To calculate coupling and emittance, use command:
    1835 CouplingFlag
    1836   After calculation, the coupling and the emittance will be printed on the screen, and the Twiss parameters will be automatically saved to the file “linlat\_coupling.out”.
     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''.
    18372574
    18382575\subsection{MomentumAccFlag}
    18392576Calculate momentum acceptance by tracking \\
    18402577
    1841 The following command calculate momentum acceptance at a predefined lattice region by tracking:
    1842 MomentumAccFlag   MomAccFile   TrackDim     istart    istop     deltaminp
    1843 Deltamaxp     nstepp    deltaminn    deltamaxn   nstepn   turns  zinitial
    1844 For example:
    1845 MomentumAccFlag   momacc.out      4D     1   209     0.01     0.05    100       -0.01       
    1846 -0.05   100   1026   0.0001
    1847 The meaning of parameters and default values are shown in Table . If user uses MomentumAccFlag without parameters, then the code will use the default values.
     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.
    18482590
    18492591\begin{table}[h]
    18502592\centering
    1851 \caption{}
    1852 \label{}
    1853 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1854 \hline
     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] \\
    18552624\hline
    18562625\end{tabular*}
     2626\caption{Parameters of the command to calculate momentum acceptance.}
    18572627\end{table}
    18582628
    1859 Table   Parameters of the command to calculate momentum acceptance
    1860 parameter
    1861 meaning
    1862 Default value
    1863 MomAccFile
    1864 File to save the tracked momentum acceptance at each element; saved in the current directory.
    1865 momentumacceptance.out
    1866 TrackDim
    1867 4D/6D  tracking to get the momentum acceptance
    1868 6D
    1869 istart
    1870 Start element in the lattice for the tracking
    1871 1
    1872 istop
    1873 End element in the lattice for tracking
    1874 108
    1875 nstepp
    1876 Number of steps to do tracking in the positive energy range
    1877 100
    1878 nstepn
    1879 Number of steps to do tracking in the negative energy range
    1880 100
    1881 Deltaminp
    1882 Positive start energy of the tracking
    1883 0.01
    1884 Deltamaxp
    1885 Positive end energy of the tracking
    1886 0.05
    1887 Deltaminn
    1888 Negative start energy of the tracking
    1889 -0.01
    1890 Deltamaxn
    1891 Negative end energy of the tracking
    1892 -0.05
    1893 nturns
    1894 Number of turn
    1895 1026
    1896 zinitial
    1897 The initial vertical coordinate which is used to search for 6D closed orbit. This value should be a small value.
    1898 0.0003   [m]
    18992629
    19002630         
     
    19022632Read multipole field error from a file (SOLEIL lattice) \\
    19032633
    1904 
    1905   After defining the file names of multipole field errors on SOLEIL storage ring (section  and ), use the command:
    1906 ReadMultipoleFlag
    1907 to read multipole field errors and set the corresponding values to SOLEIL lattice. The multipole field errors of correctors and skew quadrupoles are added on the thick sextupoles which are integrated at the same magnets. The format of multipole errors file is given in section  .
    1908 
    1909   After setting the multipole field errors in the lattice, the code will generate a file at the current working directory, and the file name is “flat\_file\_errmultipole.dat”, user can check the field components of the lattice elements in this file to verify the multipole field errors.
     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.
    19102646
    19112647\subsection{ReadVirtualSkewquadFlag}
    19122648Read the sources of coupling from a file (SOLEIL lattice) \\
    19132649
    1914   The sources of coupling on SOLEIL storage ring can be read from an external file.  Use the command:
    1915 ReadVirtualSkewquadFlag
    1916 to read and set the field strength to the virtual skew quadrupoles. Currently this command only works for Soleil lattice.
    1917 The coupling sources MUST be defined as the skew quadrupoles with the name “SQ”, the rules and related information are explained in section.
     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{}.
    19182658
    19192659\subsection{FitTuneFlag}
     
    19212661
    19222662Betatron tunes can be fit using two families of quadrupoles. The command is:
    1923 FitTuneFlag      Quad1   Quad2   nux   nuz
    1924 For example:
    1925 FitTuneFlag      q7 q9   18.202   10.317
    1926 The parameters of this command are shown in Table .
    1927 Table   Parameters of the command “FitTuneFlag”.
    1928 Parameters
    1929 Meaning
    1930 Default values
    1931 Quad1
    1932 Quadrupole family used to fit the tunes
    1933 -
    1934 Quad2
    1935 Quadrupole family used to fit the tunes
    1936 -
    1937 nux
    1938 Target horizontal tune
    1939 0.0
    1940 nuz
    1941 Target vertical tune
    1942 0.0
    1943 
    1944   After fitting the tunes, field strengths of the fitted quadrupoles before and after the fitting are printed to the screen; user can copy the new quadrupole field strengths to the lattice file for further analysis.
    1945 FitTuneFlag is a generic command; it works for the lattices with full qudrupoles.
     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}
    19462699
    19472700\subsection{FitTune4Flag}
    19482701Fit tunes for the lattice with half quadrupoles \\
    19492702
    1950 For the lattice with each quadrupole cut into two pieces, betatron tunes can be fit using two families of quadrupoles. The command is:
    1951 FitTune4Flag      Q1a  Q1b  Q2a  Q2b  nux  nuz
    1952 The parameters of this command are shown in Table .
     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}.
    19532708
    19542709\begin{table}[h]
    19552710\centering
    1956 \caption{}
    1957 \label{}
    1958 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    1959 \hline
     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 & - \\
    19602727\hline
    19612728\end{tabular*}
     2729\caption{Parameters of the command ``FitTune4Flag''.}
    19622730\end{table}
    19632731
    1964 Table  Parameters of the command “FitTune4Flag”.
    1965 Parameters
    1966 Meaning
    1967 Default values
    1968 Q1a
    1969 First half of the quadrupole family used to fit the tunes
    1970 -
    1971 Q1b
    1972 Second half of the quadrupole family used to fit the tunes
    1973 -
    1974 Q2a
    1975 First half of the quadrupole family used to fit the tunes
    1976 -
    1977 Q2b
    1978 Second half of the quadrupole family used to fit the tunes
    1979 -
    1980 nux
    1981 Target horizontal tune
    1982 0.0
    1983 nuz
    1984 Target vertical tune
    1985 0.0
    1986 
    1987 For example:
    1988 FitTune4Flag      qp7a  qp7b   qp9a  qp9b  18.202 10.317
    1989 In this example, all the variables have the same meaning as the ones in the command “FitTuneFlag”, except “qp7a” and “qp7b” are the two half pieces of the full quadrupole “qp7”, and “qp9a” and “qp9b” are the two half pieces of the full quadrupole 'qp9'.
    1990   After fitting the tunes, the field strengths of fitted quadrupole before and after the fitting are printed to the screen; user can copy the new field strengths of quadrupoles to the lattice file for further analysis. 
    1991   FitTune4Flag is a command that works for the lattices in which each quadrupole are cut into two halves.
     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}
    19922752
    19932753\subsection{FitChromFlag}
    19942754Fit chromaticity \\
    19952755
    1996  Chromaticities can be fit using two families of sextupoles, the command is:
    1997 FitChromFlag     SX1    SX2    epsilon\_x    epsilon\_z
    1998 The parameters of this command are shown in Table .
     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}.
    19992760
    20002761\begin{table}[h]
    20012762\centering
    2002 \caption{}
    2003 \label{}
    2004 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    2005 \hline
     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 & - \\
    20062775\hline
    20072776\end{tabular*}
     2777\caption{Parameters of the command ``FitChromFlag''.}
    20082778\end{table}
    20092779
    2010 Table    Parameters of the command “FitChromFlag”.
    2011 Parameters
    2012 Meaning
    2013 Default values
    2014 SX1
    2015 First sextupole family used to fit the chromaticities
    2016 -
    2017 SX2
    2018 Second sextupole family used to fit the chromaticities
    2019 -
    2020 epsilon\_x
    2021 Target horizontal chromaticity
    2022 0.0
    2023 epsilon\_z
    2024 Target vertical chromaticity
    2025 0.0
    2026 
    2027  For example:
    2028 FitChromFlag     sx9 sx10   2.0    2.6
    2029   After fitting the chromaticites, the field strengths of fitted sextupoles before and after the fitting are printed to the screen; user can copy the new field strengths of sextupoles to the lattice file for further analysis. 
    2030 
    2031 \subsection{TouschekFlag (TO BE UPDATED)}
     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)??????}
    20322789Touschek lifetime determined by RF acceptance \\
    20332790
    2034   To calculate Touschek lifetime, use the following command:
    2035 TouschekFlag
    2036   Here the momentum acceptance is limited by the RF acceptance.
    2037 
    2038 \subsection{IBSFlag (TO BE UPDATED)}
     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) ????}
    20392797Intra Beam Scattering (IBS)  \\
    20402798
    20412799
    2042   To calculate Intra Beam Scattering, use the command:
    2043 IBSFlag
     2800To calculate Intra Beam Scattering, use the command:
     2801\tracycommand{IBSFlag}{}
    20442802
    20452803\subsection{TousTrackFlag (TO BE UPDATED)}
    2046 Touschek lifetime determined by the minimum value of RF acceptance and momentum acceptance \\
    2047 
    2048   Touschek lifetime can be calculated by 
    2049 TousTrackFlag
    2050 In this case, the energy acceptance at each lattice element is limited by the minimum value of RF acceptance and momentum acceptance obtained by tracking, and the chamber file MUST be defined in the user script.
     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.
    20512814
    20522815\subsection{PhaseSpaceFlag}
    20532816Obtain phase space by tracking \\
    20542817
    2055   To calculate phase space, use the command:  \\
    2056 \textbf{PhaseSpaceFlag}      Phase\_phase\_file      Phase\_Dim     Phase\_X      Phase\_Px
     2818To calculate phase space, use the command:
     2819\tracycommand{PhaseSpaceFlag}{      Phase\_phase\_file      Phase\_Dim     Phase\_X      Phase\_Px
    20572820                                           Phase\_Y     Phase\_Py   Phase\_delta   Phase\_ctau               
    2058                                            Phase\_nturn     damping\_flag
    2059 
    2060 For example:
    2061 \textbf{PhaseSpaceFlag}   phasespace.out    6D   1e-6    0.0    1e-6   0.0   0.012   0.0   1000   false
    2062 
    2063 The meanings of parameters and defaults values of PhaseSpaceFlag are shown in Table \ref{tab:phasespace-para}.
     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}.
    20642827If user uses PhaseSpaceFlag without parameters, then the code will use the default values.
    20652828
    20662829\begin{table}[h]
    20672830\centering
    2068 \caption{Parameters of the command \textbf{PhaseSpaceFlag} to calculate phase space.}
    20692831\label{tab:phasespace-para}
    2070 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} p{0.2\linewidth}  p{0.5\linewidth}   p{0.15\linewidth} }
    2071 \hline
    2072 \hline
    2073 \textbf{Symbol}    &  \textbf{Units}               & \textbf{Parameter}    \\
    2074 \hline
    2075 \textbf{Phase\_phase\_file} & File to save tracked phase space;
    2076                               saved in the current directory.     &    phase.out \\
    2077 \textbf{Phase\_Dim}  &  4D~/~6D tracking                            &    4D \\
    2078 \textbf{Phase\_X}    &  Horizontal coordinate at the start
    2079                         point of tracking.                        &    0.0 \\
    2080 \textbf{Phase\_Px}   &  Horizontal canonical momentum~/~derivative
    2081                         at the start point of tracking.           &    0.0 \\
    2082 \textbf{Phase\_Y}    &  Vertical coordinate at the start point
    2083                         of tracking.                              &    0.0 \\
    2084 \textbf{Phase\_Py}   &  Vertical canonical momentum~/~derivative
    2085                         at the start point of tracking.           &    0.0 \\
    2086 \textbf{Phase\_delta}&  Energy at the start point of tracking     &    0.0 \\
    2087 \textbf{Phase\_ctau} &  Longitudinal position at the start point
    2088                         of tracking.                              &    0.0 \\
    2089 \textbf{Phase\_nturn}&  Number of turns for tracking              &    512 \\
    2090 \textbf{Damping\_flag}& Boolean flag to turn on~/~off the radiation
    2091                         damping during the tracking.              &    false \\
    2092 \hline
     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 & - \\
    20932862\hline
    20942863\end{tabular*}
     2864\caption{Parameters of the command ``PhaseSpaceFlag'' to calculate phase space.}
    20952865\end{table}
    20962866
    20972867
    2098 \subsection{IDCorrFlag (Tested for TaiWan light source; TO BE CONTINUE DEVELOPPED.)}
     2868\subsection{IDCorrFlag (Tested for TaiWan light source; TO BE CONTINUE DEVELOPPED.)?????}
    20992869Insertion device (ID) compensation  \\
    21002870
    2101    To compensate the beta beat introduced by the insertion devices, several families of Quadruoples can be used. Defining the following command in the “*.prm” can active this action:
    2102 IDCorrFlag
    2103   User also needs to define the following parameters used for the compensation of insertion device:
    2104 N\_calls      1
    2105 N\_steps    1
    2106 N\_Fam     11
    2107 IDCquads qs1 qs2 qs3 qs4 qs5 ql1 ql2 ql3 q1 q2 q3
    2108 scl\_dbetax  5e-1
    2109 scl\_dbetay  5e-1
    2110 scl\_dnux    0.1
    2111 scl\_dnuy    0.1
    2112 scl\_nux     1e1
    2113 scl\_nuy     1e1
    2114 ID\_step    0.7
    2115 
    2116 The meanings of the above commands and the default values used to do ID compensation using quadrupoles are shown in Table .
     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}.
    21172905
    21182906\begin{table}[h]
    21192907\centering
    2120 \caption{}
    2121 \label{}
    2122 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    2123 \hline
     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 & - & - \\
    21242939\hline
    21252940\end{tabular*}
     2941\caption{Parameters of commands to do ID compensation using quadrupoles.}
    21262942\end{table}
    21272943
    2128 Table   Parameters of commands to do ID compensation using quadrupoles.
    2129 Parameters
    2130 Meanings
    2131 Default values
    2132 N\_calls
    2133 Number of calls to do ID compensation
    2134 1
    2135 N\_steps   
    2136 Number of steps.
    2137 1
    2138 N\_Fam     
    2139 Number of quadrupole families used to do ID correction.
    2140 15
    2141 IDCquads
    2142 Name of quadrupole families used to do ID correction.
    2143 -
    2144 scl\_dbetax 
    2145 Scaling weight factor of the change step of horizontal beta function during the ID correction.
    2146 1
    2147 scl\_dbetay 
    2148 Scaling weight factor of the change step of vertical beta function during the ID correction.
    2149 1
    2150 scl\_dnux   
    2151 
    2152 Scaling weight factor of the change step of horizontal tune during the ID correction.
    2153 0.1
    2154 scl\_dnuy   
    2155 Scaling weight factor of the change step of vertical tune during the ID correction.
    2156 0.1
    2157 scl\_nux     
    2158 
    2159 Scaling weight factor of horizontal tune during the ID correction.
    2160 100
    2161 scl\_nuy     
    2162 
    2163 Scaling weight factor of vertical tune during the ID correction.
    2164 100
    2165 ID\_step   
    2166 
    2167 
    2168 0.7
    2169 
    2170 
    2171 
    2172 
    2173 
    2174 
    2175 
    2176 
    2177 
    2178 Frequency map analysis for on momentum particle, command ``FmapFlag''.
    2179 \begin{itemize}
    2180 \item
    2181 Frequency map analysis for off momentum particle, command ``FmapdpFlag''.
    2182 \item
    2183 Track momentum acceptance at lattice elements, command ``MomentumAccFlag''.
    2184 \end{itemize}
    2185 
    2186 \subsection{Compile}
    2187 The commonly used compilers for parallel computation are MPI 2, and Intel MPI which is based on MPI 2. For the cluster of SOLEIL Synchrotron, Intel MPI is installed. To get the parallel Tracy work, three files of the non-parallel version Tracy need to be modified.
    2188 The details are shown in the following steps.
    2189 \begin{enumerate}
    2190 \item
    2191 The path of included files of Intel MPI is added in ``Makefile.am'' under
    2192 path ``\$HOME/TracyIII/tracy/tracy/src'' (shown in BLUE color):
    2193 
    2194           INCLUDES = -I../inc -I\$(NUM\_REC)/inc
    2195           -I/opt/intel/impi/3.2.2.006/include64 
    2196 \item
    2197  The execute file, source file, paths of included files and library of Intel
    2198 MPI are modified in ``Makefile.am'' under path ``\$HOME/TracyIII/tracy/tools''
    2199  (shown in BLUE color):
    2200 
    2201 bin\_PROGRAMS = psoltracy
    2202 
    2203 soltracy\_SOURCES  = soltracy.cc  nrutil.c nrcheck.c   
    2204   nrlinwww.c   nrframe.c ../tracy/src/tracy\_lib.cc   ->
    2205   psoltracy\_SOURCES  = psoltracy.cc  nrutil.c  nrcheck.c   
    2206   nrlinwww.c   nrframe.c   ../tracy/src/tracy\_lib.cc
    2207 
    2208   LIBS = -L\$(NUM\_REC)/lib
    2209   -L/opt/intel/impi/3.2.2.006/lib64   -L\$(LIBPATH) 
    2210     -lrecipes\_c\_icc -lstdc++ -lgfortran -lmpichcxx
    2211  
    2212 INCLUDES = -I\$(TRACY\_LIB)/tracy/inc -I\$(NUM\_REC)/inc
    2213   -I/opt/intel/impi/3.2.2.006/include64
    2214 \item
    2215 The compilers used in the parallel computing are defined in the ``make\_for\_psoltracy.sh'' located in path ``\$HOME/TracyIII'' as (shown in BLUE color):
    2216 
    2217 CC = mpiicc
    2218 
    2219                 CXX = mpiicpc
    2220 
    2221                 F77 = mpiifort
    2222 
    2223 Depending on the compilers used to do parallel computation, user needs to
    2224 update the compilers in ``make\_for\_psoltracy.sh'' and the paths of included
    2225 files and library which are shown above with blue color.
    2226 
    2227  After updating compilers, paths of included files and library for parallel
    2228 computation, user can run
    2229 
    2230 make\_for\_psoltracy.sh
    2231 
    2232 under the shell script to compile the parallel Tracy. After compilation,
    2233 the execute file ``psoltracy'' is automatically generated under the
    2234 path ``\$HOME/TracyIII/tracy/tools''.
    2235 
    2236 
    2237 \end{enumerate}
    2238 
    2239 \subsection{Run}
    2240   As the non-parallel version Tracy, user needs to write the commands in a script which must be with the file extension “.prm”. The syntaxes to define the script “*.prm” are the same for both non-parallel and parallel Tracy.
    2241   To run the parallel Tracy, user need to contact the administrator of their cluster to know how to run parallel programs on the cluster. For the cluster on Synchrotron SOLEIL, the nodes used to do parallel computation are assigned by PBS (Portable Batch System), so a script is need. For example, user define the input script “test.prm” to tell Tracy what jobs are need to be done on the cluster,  define script “lance\_tracy3\_parallel.sh” to assign the numbers of CPUs to do parallel computation and lance job to the SOLEIL cluster. and then type the following command under the bash shell to submit the job and run the parallel Tracy on the cluster:
    2242 
    2243     lance\_tracy3\_parallel.sh     test.prm
    2244 
    2245 \section{ User input script}
    2246   There are two types of keywords in the user input script. The first type is to set the file, the file names, and define parameters for the related calculations; the key words for such definitions are ended with the characters “Flag”. The second type is to define Boolean commands with or without parameters to do different calculations. The rules of the definition of input scripts are:
    2247 The blank lines and lines starting with "\#" (comment line) are ignored by the code.
    2248 Keywords without “Flag” as the final 4 characters are NOT executed according to the defined sequence in user input script. If the same command keywords are defined many times in the user script, only the last defined keyword is executed.
    2249 The commands with the last 4 characters as “Flag” are executed according to the sequence in the code.
    2250 The definition of lattice file at the beginning of the user script is mandatory. If the lattice file is with any of the following elements: horizontal correctors, vertical correctors, girders, BPM, skew quadrupoles, user must declare the element name at the beginning of input script.
    2251 One keyword command uses one line. User can not define more than one command at the same line.   
    2252 Except explanation, all commands with Boolean flag are the generic commands, and can be used on all the lattice of the ring.
    2253 \subsection{  File path}
    2254    In the user input script, user can specify the name of the files which are used in the calculation, such as the lattice file, multipole field error file, misalignment error file, vacuum chamber file. When specifying the file name, user can provide the absolute path for the file which is not located at the current path, such as: “/home/physmach/Tracy3/tracy/soleil.lat”; or for convenience, user provides the filename without absolute path, but put the files at a certain directory and then specific this directory using the command:
    2255                        in\_dir            user\_defined\_path
    2256         For example:
    2257                        in\_dir                /home/zhang/codes/TracyIII/lattice/
    2258 
    2259 This command tells the code all the files specified in the script are located at the directory “/home/zhang/codes/TracyIII/lattice/”. If user declares the files without absolute path and does not set the directory through command in\_dir; or the files specified in the script are not found at the current working path, the code will give an error message and stop running.
    2260 
    2261 \section{  File names}   
    2262 
    2263 \subsection{Lattice file name}
    2264 In the input script, user must define the lattice name, this is mandatory. The command is:   
    2265 lat\_file            lattice\_file\_name
    2266 Here “lattice\_file\_name” is the lattice file name without “.lat” extension. For example, the following command sets the lattice file of SOLEIL ring:
    2267 lat\_file   solamor2\_reglage\_focalisation\_chcvqt\_thicksextu\_LQPintermediaire\_QFF
    2268   In Tracy 3, after reading the lattice, Twiss parameters are automatically printed to the file “linlat.out”.                                 
    2269   If one of these elements (Horizontal/vertical correctors or beam position monitors, or girders, or skew quadrupoles.) are defined in the lattice file, for example to read the misalignment errors of the lattice element and then do orbit correction, to read multipole field errors (SOLEIL lattice), etc.; user MUST specify the names of these elements using the corresponding commands in the “*.prm” script:
    2270 h\_corr             HCM
    2271 v\_corr             VCM
    2272 gs                     GS
    2273 ge                     GE
    2274 bpm\_name     BPM
    2275 qt                     QT
    2276 Here “HCM” is the name of horizontal correctors used for horizontal orbit correction, or the horizontal correctors on which the multipole field errors are added in SOLEIL lattice;  “VCM” is the name of vertical correctors used for vertical orbit correction, or the vertical correctors on which the multipole field errors are added in SOLEIL lattice; “GS” is the name of the start girder;  ‘GE’ is the name of the end girder; “BPM” is the name of beam position monitors defined in the lattice file; “QT” is the name of the skew quadrupoles defined in the lattice.  Generally, user needs to define horizontal, vertical correctors and BPMs when reading the misalignment errors or correcting closed orbit distortion 
    2277 
    2278 \subsection{Multipole field error file name (SOLEIL lattice)}
    2279   User can read the multipole field errors on SOLEIL lattice from an external file; the file is specified in the user script using the following command:
    2280 multipole\_file           multipole\_file\_name
    2281 Here “multipole\_file\_name” is the user defined multipole field error file, the format of this file is given in section Error: Reference source not found.
    2282 
    2283 If the multipole field errors of horizontal, vertical correctors and skew quadrupoles are defined in the “multipole\_file”, user MUST specify the names of these lattice elements in the “*.prm” file as the following example:
    2284 h\_corr      CH
    2285 v\_corr      CV
    2286 qt              QT
    2287 Here “CH”, “CV” and “QT” are the names of horizontal, vertical correctors, and skew quadrupoles respectively which are defined in the lattice file.
    2288 
    2289 \subsection{Files of multipole field errors of correctors and skew quadrupoles (SOLEIL lattice)}
    2290   Horizontal, vertical correctors and skew quadrupoles are integrated with the sextupole quadrupoles on 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:
    2291 fic\_hcorr         corh.txt
    2292 fic\_vcorr         corv.txt
    2293 fic\_skew          corqt.txt
    2294 Here “corh.txt” and “corv.txt” are the files with measured current values corh, corv, corqt (with unit [Ampere]) for the horizontal, vertical correctors and skew quadrupoles respectively. Based on the measured current values, user can get the integrated field strength as:
    2295 Hcorr\_strength [T.m] = corh *\_convHcorr /brho; (horizontal correctors)
    2296 Vcorr\_strength [T.m] = corv *\_convVcorr /brho;  (vertical correctors)
    2297 Qt\_strength [T.m] = corqt *\_convQt /brho;  (skew quadrupoles)
    2298 here brho is the momentum rigidity, and the conversion constants between current and field are \_convHcorr = 8.14e-4, \_convVcorr = 4.642e-4, \_convQt = 93.83e-4.
    2299   For SOLEIL lattice, the SAME ORDER of multipole field errors on the same elements are added together, so the SAME ORDER of horizontal/vertical, skew quadrupoles, and sextupoles are added together since these elements are integrated at the same magnets.
    2300 
    2301 \subsection{ File to define field strength of virtual coupling source elements (SOLEIL lattice)}
    2302   On SOLEIL storage ring, the coupling is thought to come from the rotation of quadrupoles and vertical displacements of sextupoles. The strengths of these coupling sources are written in a file, then read by the following command:
    2303 virtualskewquad\_file   virtual\_skew\_quad\_currents.txt
    2304 
    2305 Here “virtual\_skew\_quad\_currents.txt” is the user defined file with strength of vertical coupling source.
    2306   In order to use this command to read the virtual sources of coupling, user needs to define the virtual coupling element as a skew quadrupole in the lattice file:
    2307 SQ: quadrupole, tilt=45.0, K= 0.0, method=4, N=1;
    2308 and 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 .
    2309   The measured current value qtcorr[i] of the ith coupling source is converted to the corresponding integrated skew quadrupole field strength corr\_strength as
    2310 corr\_strength [m-1] = qtcorr[i]*conv/brho;
    2311 here brho is momentum rigidity, and the conversion constant conv is 93.88e-4 [A-1.T].
    2312 
    2313 \subsection{Cut off value}
    2314   Set the cut off value of all random distribution (Gaussian distribution) to “n” times of the RMS value sigma:
    2315 normalcut       n
    2316 
    2317 \section{Physics: Hamiltionian}
    2318 The dynamic motion of a conserved system can be described by a Hamiltonian. For an accelerator system without radiation
    2319 damping (energy loss) and RF cavities (energy gain), the motion of a single electron in the magnetic field can be described using the
    2320 following Hamitonian in the curvilinear coordinate system (Merz...)
    2321 \begin{eqnarray}
    2322 H (x,P_x; y, P_y; -t, \delta; s) &=&  L + V  \\
    2323                                  &=& -(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)]  \\
    2324 P^2 & =& P_x^2 + P_y^2 + P_z^2
    2325 \end{eqnarray}
    2326 $h_{\mathrm{ref}}$ is the curvature of reference orbit inside the dipole.
    2327 The $(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
    2328 horizontal, vertical, and longitudinal mechanical momentums. A more convienent way is to expand the electron motion
    2329 around the motion of a reference particle with total momentum $P_0$, so
    2330 \begin{eqnarray}
    2331 \frac{1}{P_0}H (x,P_x; y, P_y; -t, \delta; s) &=& \\
    2332 H (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) \\
    2333                                 &=& -(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)
    2334 \end{eqnarray}
    2335 with
    2336 \begin{eqnarray}
    2337 p_x &=& \frac{P_x}{P_0}  \\
    2338 p_y &=& \frac{P_y}{P_0}  \\
    2339 p &=& \frac{P}{P_0} = \frac{\Delta P + P_0}{P_0} = (1+\delta)   \\
    2340 \delta &=& \frac{\Delta P}{P_0} \\
    2341 B \rho &=& \frac{P_0}{e} (magnetic rigidity)
    2342 \end{eqnarray}
    2343 
    2344 With 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.),
    2345 the Hamitonian can be expressed with the canonical coordinates $(x,p_x; y, p_y; -ct, \delta; s)$ (Tracy-2 Manual, J. Bengtsson)
    2346 
    2347 \begin{align*}
    2348 %\label{Tracy:Exact:H}
    2349 H (x,p_x; y, p_y; -ct, \delta; s) \\
    2350 &=-(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  \\
    2351 &= -(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}  \\
    2352 & + \frac{A_z}{B \rho} + \delta  \\
    2353 &= \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} \\
    2354 & + \underbrace{\frac{x}{\rho} +\frac{x}{2\rho^2}}_\text{Gemometic components due to the curvilinear coordinate inside the dipole}\\
    2355 & +\underbrace{\frac{A_z}{B \rho}}_\text{magnet contribution}  \\
    2356 & +\underbrace{\delta}_\text{due to the canonical coordinate $-ct$ instead of $-t$}\\ 
    2357 A_z & =A_z(x,p_x; y, p_y,s)
    2358 \end{align*}
    2359 
    2360 The 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.
    2361 
    2362 For 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$,
    2363 so the Hamiltonian is
    2364 \begin{align}
    2365 \label{eqn:exact:H:NoFF}
    2366 H (x,p_x; y, p_y; -ct, \delta; s) \\
    2367 &= \underbrace{-(1+h_{\mathrm{ref}}x)\sqrt{(1+\delta)^2 - p_x^2 - p_y^2)}}_\text{kinetic energy} \\
    2368 & + \underbrace{\frac{x}{\rho} +\frac{x}{2\rho^2}}_\text{Gemometic components due to the curvilinear coordinate inside the dipole}\\
    2369 & +\underbrace{\frac{A_z}{B \rho}}_\text{magnet contribution}  \\
    2370 & +\underbrace{\delta}_\text{due to the canonical coordinate $-ct$ instead of $-t$}\\ 
    2371 \end{align}
    2372 
    2373 From eqn.~\ref{eqn:exact:H:NoFF}, it is easy to get the map of the particle inside different lattice elements.
    2374 
    2375 
    2376 \subsection{Map of drift}
    2377 \label{H:drift}
    2378 
    2379 In the drift, $A_z = 0$, and $h_{\mathrm{ref}}$ = 0, from eqn.~\ref{eqn:exact:H:NoFF}, we can get the Hamiltonian
    2380 inside a drift is
    2381 \begin{align}
    2382 \label{eqn:H:exact:drift}
    2383 H (x,p_x; y, p_y; -ct, \delta; s) = -\sqrt{(1+\delta)^2 - p_x^2 - p_y^2)} + \delta
    2384 \end{align}
    2385 
    2386 In large ring, in order to increase the tracking speed, we can expand the sqare root in
    2387 eqn.~\ref{eqn:H:exact:drift} to get the approximate Hamitonian.
    2388 That is,
    2389 \begin{align}
    2390 \label{eqn:H:approxi:drift}
    2391 H (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\\
    2392                                   &= \frac{p_x^2 + p_y^2}{2(1+\delta)}
    2393 \end{align}
    2394 
    2395 
    2396 From eqn.~\ref{eqn:H:exact:drift}, it is easy to get the map inside the drift for the
    2397 \textbf{small ring}:
    2398 \begin{align}
    2399 x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = \frac{p_{x0}}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\
    2400 y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}= \frac{p_{y0}}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\
    2401 (-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 \\
    2402 or \\
    2403 (ct)^{'} = \frac{1+\delta_0}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}}-1 \\
    2404 p_x  = p_{x0} \\
    2405 p_y  = p_{y0} \\
    2406 \delta = \delta_0
    2407 \end{align}
    2408 
    2409 From eqn.~\ref{eqn:H:approxi:drift}, it is easy to get the map inside the drift for the
    2410 \textbf{big ring}:
    2411 \begin{align}
    2412 x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = \frac{p_{x0}}{1+\delta_0} \\
    2413 y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}= \frac{p_{y0}}{1+\delta_0} \\
    2414 (-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} =-\frac{p_{x0^2}+p_{y0}^2}{2(1+\delta_0)} \\
    2415 or \\
    2416 (ct)^{'} = \frac{p_{x0^2}+p_{y0}^2}{2(1+\delta_0)} \\
    2417 p_x  = p_{x0} \\
    2418 p_y  = p_{y0} \\
    2419 \delta = \delta_0
    2420 \end{align}
    2421 
    2422 \subsection{Map of mutipoles}
    2423  From eqn.~\ref{eqn:exact:H:NoFF}, we can get the Hamiltonian
    2424 inside a multipole without fringe field is
    2425 \begin{align}
    2426 \label{eqn:H:exact}
    2427 H (x,p_x; y, p_y; -ct, \delta; s) \\
    2428 =& \underbrace{-\sqrt{(1+\delta)^2 - p_x^2 - p_y^2}+\delta}_\text{H drift} \\
    2429 & \underbrace{-h_{\mathrm{ref}}x \sqrt{(1+\delta)^2 - p_x^2 - p_y^2}}_\text{H kick} \\
    2430 & + \underbrace{\frac{x}{\rho} +\frac{x}{2\rho^2}-\frac{A_z}{B \rho}}_\text{H kick} 
    2431 \end{align}
    2432 
    2433 In eqn.~\ref{eqn:H:exact}, the Hamiltonian is decomposed into two part, one is the Hamiltonian
    2434 of the drift which is due to the kinetic energy of the system (section~\ref{H:drift}), another part is the kick
    2435 due to the multipoles which will give the kick to the particle.
    2436 Now we only need to focus on the Hamiltonian of the multipoles which induces the kick map:
    2437 \begin{align}
    2438 \label{eqn:H:exact:multipole}
    2439 H (x,p_x; y, p_y; -ct, \delta; s) \\
    2440 &=-h_{\mathrm{ref}}x \sqrt{(1+\delta)^2 - p_x^2 - p_y^2} \\
    2441 & +\frac{x}{\rho} +\frac{x}{2\rho^2}-\frac{A_z}{B \rho}
    2442 \end{align}
    2443 
    2444 Similarly, by expand the sqare root in eqn.~\ref{eqn:H:exact}, we can get the approximate Hamiltonian
    2445 of the multipole as
    2446 \begin{align}
    2447 \label{eqn:H:approxi:multipole}
    2448 H (x,p_x; y, p_y; -ct, \delta; s) \\
    2449 &=-h_{\mathrm{ref}}x \sqrt{(1+\delta)^2 - p_x^2 - p_y^2} \\
    2450 & +\frac{x}{\rho} +\frac{x}{2\rho^2}-\frac{A_z}{B \rho} \\
    2451 &=-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
    2452 \end{align}
    2453 where $h_{\mathrm{ref}}$ is the curvature due to the curlininear coordinates inside the dipole,
    2454 $h_{\mathrm{ref}} = 1/\rho_{ref}$;
    2455 $h_{\mathrm{bend}}$ is due to the bending curvature of the dipole which is determined by the dipole
    2456 field, $h_{\mathrm{bend}} = 1/ \rho_{bend}$. $h_{\mathrm{ref}} \neq 0$ only inside dipoles.
    2457 
    2458 In the dipole, $A_z \neq 0$, and $h_{\mathrm{ref}} \neq $ 0, so
    2459 from eqn.~\ref{eqn:H:exact:multipole}, we can get the kick map due to the dipole
    2460 in the \textbf{small ring} which use the exact Hamiltonian:
    2461 \begin{align}
    2462 \label{eqn:kickmap:exact}
    2463 x^{'} = \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)}} \\
    2464 y^{'} = \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)}} \\
    2465 p_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}\\
    2466 p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
    2467 (-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)}} \\
    2468 or \\
    2469 (ct)^{'} = h_{\mathrm{ref}} x_0 \frac{1+\delta_0}{\sqrt{(1+\delta_0)^2 -(p_{x0}^2+p_{y0}^2)}} \\
    2470 \delta = \delta_0 \\
    2471 B \rho = \frac{p_0}{e}
    2472 \end{align}
    2473 where
    2474 \begin{align}
    2475 \frac{\partial A_z}{\partial x} = - B_y \\
    2476 \frac{\partial A_z}{\partial y} = B_x
    2477 \end{align}
    2478 since
    2479 \begin{align}
    2480 A_x = 0 \\
    2481 A_y =0
    2482 \end{align}
    2483 inside the body of the multipoles, and
    2484 \begin{align*}
    2485 \vec{B} = \Delta \times \vec{A}  \\
    2486 \hat{x} & \hat{y} & \hat{z} \\
    2487 \frac{\partial}{x} &  \frac{\partial}{y} &  \frac{\partial}{z} \\
    2488 A_x  & A_y & A_z \\
    2489 \end{align*}
    2490 
    2491 
    2492 In the dipole, $A_z \neq 0$, and $h_{\mathrm{ref}} \neq $ 0, so
    2493 from eqn.~\ref{eqn:H:approxi:multipole}, we can get the kick map due to the dipole
    2494 in the \textbf{big ring} which use the exact Hamiltonian:
    2495 \begin{align}
    2496 \label{eqn:kickmap:approxi}
    2497 x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = h_{\mathrm{ref}} x_0 \frac{p_{x0}}{1+\delta_0} \\
    2498 y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}=  h_{\mathrm{ref}} x_0 \frac{p_{y0}}{1+\delta_0} \\
    2499 p_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}\\
    2500 p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
    2501 (-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)} \\
    2502 or \\
    2503 (ct)^{'} =-\frac{h_{\mathrm{ref}} x_0}{1+\delta_0} \frac{(p_{x0}^2+p_{y0}^2)}{2(1+\delta_0)} \\
    2504 \delta^{'} = 0
    2505 \end{align}
    2506 
    2507 For other multipoles (quadrupoles, sextupole, decapole, octupole, etc), the curvilinear coordinate is
    2508 the cartesian coordinates, that is $h_{ref}$ = 0, so from eqn.~\ref{eqn:kickmap:exact}, the kick map for
    2509 these multipoles in the small ring is: 
    2510 \begin{align}
    2511 \label{eqn:kickmap:exact:multipole}
    2512 x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = 0 \\
    2513 y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}=  0 \\
    2514 p_x^{'}  = -\frac{\partial H}{\partial y_0} = - (h_{\mathrm{bend}} + \frac{B_y}{B \rho})\\
    2515 p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
    2516 (-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} = 0\\
    2517 or \\
    2518 (ct)^{'} = 0 \\
    2519 \delta^{'} = 0
    2520 \end{align}
    2521 
    2522 With $h_{ref} = 0$, from eqn:~\ref{eqn:kickmap:approxi}, the kick map for these
    2523 multipoles (quadrupoles, sextupole, decapole, octupole, etc) in the big ring is:
    2524 \begin{align}
    2525 \label{eqn:kickmap:approxi:multipole}
    2526 x^{'} = \frac{dx}{ds} = \frac{\partial H}{\partial p_{x0}} = 0 \\
    2527 y^{'} = \frac{dy}{ds} = \frac{\partial H}{\partial p_{y0}}=  0 \\
    2528 p_x^{'}  = -\frac{\partial H}{\partial y_0} = - (h_{\mathrm{bend}} + \frac{B_y}{B \rho})\\
    2529 p_y^{'}  = -\frac{\partial H}{\partial y_0} = \frac{1}{B \rho} \frac{\partial A_z}{\partial y_0} = \frac{B_x}{B \rho}\\
    2530 (-ct)^{'} = \frac{d(-ct)}{ds} = \frac{\partial H}{\partial \delta_0} = 0\\
    2531 or \\
    2532 (ct)^{'} = 0 \\
    2533 \delta^{'} = 0
    2534 \end{align}
    2535 
    2536 From the eqn~\ref{eqn:kickmap:exact} to eqn.~\ref{eqn:kickmap:approxi:multipole}, it's clear
    2537 that the kick map from the main body of dipoles are different in the small ring and big ring;
    2538 while the kick map from the main body of other type of multipoles are the same in small
    2539 rings and big rings.
    2540 
    2541 
    2542 
    2543 
    2544 
    2545 
    2546 
    2547 
    2548 \section{Magnetic field}
    2549 
    2550 A. Dragt ....(Lie methods for acceleator........)
    2551 
    2552 \section{FF of dipole}
    2553 \subsection{kick map}
    2554 E. Forest ...........
    2555 
    2556 \section{FF of quadrupole}
    2557 \subsection{kick map}
    2558 
    2559 
    2560 \section{ Lattice file}
    2561 In the lattice, RF cavity must be defined!!! Otherwise Tracy will give the error message:
    2562 \textcolor{red}{Elem\_GetPos: there are no kids in family 0 ()}. This obigatory is for the
    2563 correct calculation of positive/negtive momentum compaction factor.
    2564 
    2565 
    2566 
    2567 The followings are the rules to define a lattice file used in Tracy 3. The curvelinear coordinates are
    2568 used. \textbf{The ideal particle or design particle sees the perfect magnetic field in all magnets, and its}
    2569 \textbf{orbit is used as the reference orbit and base of the curvilinear coordinate}. Since the reference orbit
    2570 is a curve inside the dipoles and a straight line in other lattice elements (drifts and the magnets except
    2571 dipoles), so the length of the dipole is the the path length of the reference particle inside the dipole
    2572 which is equal to $\rho*\theta$ where $\rho$ is the bending radius of the dipole and $theta$ is the bending angle
    2573 with unit [rad], and all the other magnet lengths are the straight length of the magnets.
    2574 
    2575 Due to the same reason, the curvature of the curvilinear cooridnates h = 1/$\rho$ is not zero only inside dipole;
    2576 in other magnets and drift h = 0, and the curvilinear coordinates goes to cartesian cooridnates.
    2577 As a result, the independent variable $s$ inside the dipole harmitonian is the arc length, while the staight
    2578 length in other lattice elements.
    2579 
    2580 \subsection{Lattice}
    2581 The $n^{th}$ field component of the lattice element is defined as in Tracy (n = 1, 2, 3, 4 ...):
    2582 \begin{eqnarray*}
    2583 b_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_y }{\partial x ^{n-1}}|_{x=0,y=0} \\
    2584 a_n & = & \frac{1}{B \rho} \frac{1}{(n-1)!} \frac{\partial^{n-1} B_x }{\partial x ^{n-1}}|_{x=0,y=0} \\
    2585 B \rho & = & \frac{p_0}{e}
    2586 \end{eqnarray*}
    2587 $B \rho$ is the magnetic rigidity, $p_0$ is the design beam momentum, $e$ is the electric charge.
    2588 For example, for sextupole,  n = 3, so $b_3$ and $a_3$ are defined as
    2589 \begin{eqnarray*}
    2590 b_3 & = & \frac{1}{B \rho} \frac{1}{2} \frac{\partial^{2} B_y }{\partial x ^{2}}|_{x=0,y=0} \\
    2591 a_3 & = & \frac{1}{B \rho} \frac{1}{2} \frac{\partial^{2} B_x }{\partial x ^{2}}|_{x=0,y=0}
    2592 \end{eqnarray*}.
    2593 
    2594  \textbf{Notes:}
    2595 In \textbf{AT} (Accelerator Toolbox) and \textbf{BETA} code, the definition of are the same as in \textbf{Tracy}.
    2596 While In \textbf{MAD8}, \textbf{MADX} and \textbf{ELEGANT}, the order of the field compoent start from 0, that is
    2597 n = 0, 1, 2, 3, ..., and the $n^{th}$ field strength components of the lattice element $b_n$ and $a_n$ are defined as
    2598 \begin{eqnarray*}
    2599 b_n & = & \frac{1}{B \rho} \frac{\partial^{n} B_y }{\partial x ^{n}}|_{x=0,y=0} \\
    2600 a_n & = & \frac{1}{B \rho} \frac{\partial^{n} B_x }{\partial x ^{n}}|_{x=0,y=0} \\
    2601 B \rho & = & \frac{p_0}{e}
    2602 \end{eqnarray*}
    2603 For example, for sextupole,  n = 3, its field component $b_2$ and $a_2$ are defined as
    2604 \begin{eqnarray*}
    2605 b_2 & = & \frac{1}{B \rho} \frac{\partial^{2} B_y }{\partial x ^{2}}|_{x=0,y=0} \\
    2606 a_2 & = & \frac{1}{B \rho} \frac{\partial^{2} B_x }{\partial x ^{2}}|_{x=0,y=0}
    2607 \end{eqnarray*}.
    2608 
    2609 
    2610                                
    2611 \subsection{Syntax}
    2612 Every line embraced by “{}” is comment line. For example:
    2613 
    2614           {*****drift space *****}
    2615 
    2616 Each sentence is ended by ‘;’ or no punctuation.
    2617 Tracy is not sensitive to capital/small letters in the lattice.
    2618 User can define any lattice element with any valid name (but must start with a character) they want, but the element type is fixed.
    2619 For 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.
    2620 
    2621 \subsection{Variables}
    2622   User can define the variables in the lattice file. For example:
    2623                     Intmeth = 4;
    2624 so when the code is running,  each  “intmeth” in the lattice file will be replaced by “4”.
    2625 
    2626 \subsection{Start line}
    2627   The lattice file must begin with the sentence:
    2628                         define    lattice;
    2629 This definition is mandatory.
    2630 
    2631 \subsection{Global variables}
    2632   After define the ring, user needs to define the system parameters of the lattice:
    2633 Energy, the beam energy with unit [GeV].
    2634  dP, the relative momentum offset of the particle.
    2635 CODeps, the convergence for the algorism to find the closed orbit.
    2636  For example:
    2637                 Energy = 2.739;
    2638 dP    = 1.0d-10;
    2639                                                            CODeps= 1.0d-15;
    2640 These definitions are mandatory.
     2944
     2945
    26412946
    26422947\section{Multipole field error file}
    26432948\label{sec:mult:field:error}
    2644   The multipole field errors of the lattice elements can be defined in a file, and then the file is read into the lattice. User can define the systematic or random multipole field error of the lattice elements.
    2645   There are two ways to define the multipole field errors, one way is to define the errors for all the families with the same type, for example, the error for all the quadrupoles; another way is to define the error for each family, for example, the “Q1” family of the quadrupoles.
     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.
    26462959 
    26472960\subsection{Systematic errors}
    2648      To define the systematic multipole field error of the element, the user just need to follow the rules as below.       
    2649    This command is commonly used to add the mangets design errors in the lattice.
     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
    26502967Input format of multipole error:
    2651        keywords/name   sys   $r0$(radius where the multipole field error is measured. If $r0$ = 0, then the An and Bn are the integrated
    2652 multipole field strength at the position $x$ = $z$ = 0).
    2653                                             $n$(order of multipole field error, in US. notation. Dip errors is 1, quadrupole error is 2, sextupole field error is 3, decaper field error is 4, octoper field error is 5, etc.),   
    2654 $Bn$($n^{\mathrm{th}}$ integrated upright component of the 
    2655                                             multipole field)  An($n^{\mathrm{th}}$ integrated skew component of the multipole field)
    2656                                              m, Bm, Am,......   
    2657 The "keywords" means one type of lattice elements or the family name; the keywords of the type of lattice elements are:
    2658                                 dip        dipole \\
    2659                               quad       quadrupole \\
    2660                                sext       sextupole \\
    2661                               hcorr      horizontal corrector \\
    2662                               vcorr      vorizontal corrector \\
    2663                               qt           skew quadrupole \\
    2664 
    2665 â€œsys” is a keyword to denote that user are setting the systematic multipole error.
    2666 Bn defines the upright component of the magnetic field, then for the component of a skew quadrupole or a vertical corrector, Bn = 0
    2667 An defines the skew component of the magnetic field, then for the component of a dipole or upright quadrupole, An = 0.
    2668 The line start with ‘\#’ is a comment line.
    2669 The blank lines in the multipole definition file are neglected by the code.
    2670 
    2671 There are two ways to define the multipole field errors strength, one is to define the measured field errors at the pole tip location $r_0$,
    2672 then $b_n$ and $a_n$ are respectively the scale coefficient of the main magnetic field coeffeicient. For example, to define the decupole field
    2673 errors inside a horizontal bending dipole with coefficient $b_1$, we define the normal scale coefficience as $c_5$ and skew scale coefficience
    2674 as $d_5$, then the $b_5$ component of this decupole is $c_5$ * $b_1$ and the skew coefficience $a_5$ is $d_5$ * $b_1$; that is
     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
    26753020\begin{eqnarray*}
    26763021 b_5 &=& \frac{1}{B \rho} \frac{c_5 * B_0}{r_0^5}  \\
     
    26813026 b_1 = \frac{1}{B \rho} B_0.
    26823027\end{equation}
    2683 This method is the simplest way to define the multipole errors inside a lattice element. The default scaling factors $c_n$ and $d_n$ are 1.
    2684 
    2685 Another way is to direct define the multipole field coefficiences $b_n$ and $a_n$, that is, set $r_0 = 0$.
    2686 If the multipole field $\vec{B^{tip}}$ are measured at the tips with radius $r_0$, then $b_n$ and $a_n$ can
     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
    26873036be calculated using
    26883037\begin{eqnarray*}   
     
    26923041\end{eqnarray*}
    26933042
    2694 The assigned multipoles errors will be added to the corresponding $n^{th}$ order multipole errors of the lattice element.
    2695 
    2696 
    2697    For the soleil lattice, the use can define the multipole errors for the type or each family. But to define the multipole error for all the quadrupoles, user can NOT define the multipole errors by the type. There are two choice: one is to define the multipole errors for each quadrupole family; second is to define the field errors by quadrupole type, and then define the multipole errors on Q2 and Q7 families (the lattice with full quadrupoles) or  QP2a, QP2b, QP7a and QP7b families (lattice with quadrupoles which are cut into two halves). This is due to that Q2/QP2a/QP2b and Q7/QP7a/QP7b are the quadrupoles which have lengths larger than other quadrupoles in the lattice, and the multipole errors on them are different from the ones on the other short quadrupoles.
     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}
    26983073   
    2699 The following is an example file to define systematic multipole errors on Soleil lattice:
    2700    
     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
    27013173\#dipole
    2702 
    2703   dip sys 20e-3 2 2.2e-40 0.0 3 -3.0e-4 0.0  4 2.0e-5 0.0  5  -1.0e-4 0.0  6 -6.0e-5 0.0  7 -1.0e-4 0.0
     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}
    27043179
    27053180\#quadrupole
    2706 
    2707 
    2708 \#for all short quadrupoles
    2709 
    2710 
    2711   quad sys 30e-3 6 2.4e-4  0.0  10 0.7e-4 0.0    14   0.9e-4  0.0
    2712 
    2713 \#for all long quadrupoles qp2 and qp7
    2714 
    2715   qp2a sys 30e-3 6 0.7e-4  0.0  10  1.9e-4   0.0   14 1.0e-4  0.0
    2716   qp2b sys  30e-3 6 0.7e-4  0.0  10  1.9e-4   0.0   14 1.0e-4  0.0
    2717   qp7a sys  30e-3 6 0.7e-4  0.0  10  1.9e-4   0.0   14 1.0e-4  0.0
    2718   qp7b sys  30e-3 6 0.7e-4  0.0  10  1.9e-4   0.0   14 1.0e-4  0.0
    2719 
    2720 \#for all short quadrupoles,sextupole mesure quadrupoles longs
    2721 
    2722    quad sys 30e-3 3 -1.6e-4  0.0   4  -3.4e-4   0.0
    2723 
    2724 \#for long quadrupoles qp2 and qp7
    2725 
    2726   qp2a sys 30e-3 3  2.9e-4  0.0   4  -8.6e-4   0.0
    2727 
    2728   qp2b sys 30e-3 3  2.9e-4  0.0   4  -8.6e-4   0.0
    2729 
    2730   qp7a sys 30e-3 3  2.9e-4  0.0   4  -8.6e-4   0.0
    2731 
    2732   qp7b sys 30e-3 3  2.9e-4  0.0   4  -8.6e-4   0.0
    2733 
    2734 
    2735 \# for sextupoles
    2736 
    2737   sext 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  21 -20.9e-4 0.0  27  0.8e-4 0.0
    2738 
    2739 
    2740 \# for horizontal correctors, all An=0
    2741   hcorr sys 35e-3 5 0.430 0.0   7 0.063 0.0  11 -0.037 0.0
    2742 
    2743 \# for vertical correctors, all Bn=0
    2744 
    2745   vcorr sys 35e-3 5 0.0 -0.430  7  0.0  0.063  11 0.0  0.037
    2746 
    2747 
    2748 \# for sextupole associated skew quadrupole, all Bn=0
    2749 
    2750 \#  qt sys 35e-3  4  0.0  -0.0
    2751 
    2752   qt sys 35e-3    4  0.0  -0.680
    2753 
    2754 \subsection{Ramdom error}
    2755 To define random multipole field errors on the lattice elements, user needs to define the seed of the random errors, and then follow the same rule as the ones to define systematic multipole error except replacing “sys” by “rms”. For example:
    2756                                  seed             seed\_number
    2757                                   quad                   rms                30e-3 6 2.4e-4  0.0  10 0.7e-4 0.0    14   0.9e-4  0.0
    2758 
    2759 The random multipole error is multiplied by the random scale factor; the new value is added to the corresponding components of the magnetic field. The random scale factor is generated by a random function which follows the normal distribution (mean value is 0 and standard deviation is 1). The cut off value for the normal distribution function is 2 times of the RMS value. If user does not define seed for the random function before the setting of errors, then the code will stop and give an error message.
    2760 
    2761   Here is example file to define random multipole error in the lattice:
    2762 
    2763  \#define seed for the ramdom multipole error
    2764 seed       1000000
    2765 
    2766 \#dipole
    2767 \#  dip 20e-3 2 2.2e-4 0.0 3 -3.0e-4 0.0  4 2.0e-5 0.0  5  -1.0e-4 0.0  6 -6.0e-5 0.0  7 -1.0e-4 0.0
    2768   dip rms  20e-3 2 2.2e-40 0.0 3 -3.0e-4 0.0  4 2.0e-5 0.0  5  -1.0e-4 0.0  6 -6.0e-5 0.0  7 -1.0e-4 0.0
    2769 
    2770 \#quadrupole
    2771 quad rms  30e-3 3 -1.6e-4  0.0   4  -3.4e-4   0.0  6 2.4e-4  0.0  10 0.7e-4 0.0    14   0.9e-4  0.0
    2772 
    2773 Q2  rms 30e-3 3  2.9e-4  0.0   4  -8.6e-4   0.0   6 0.7e-4  0.0  10  1.9e-4   0.0   14 1.0e-4  0.0
    2774 Q7  rms 30e-3 3  2.9e-4  0.0   4  -8.6e-4   0.0   6 0.7e-4  0.0  10  1.9e-4   0.0   14 1.0e-4  0.0
     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
    27753192
    27763193\section{ Misalignment error file}
    2777         The misalignment error of the lattice elements can be defined in a file, and then the file is read into the lattice. User can define the systematic or random misalignment error of the lattice elements.
    2778        There are two ways to define the misalignment error, one way is to define the error for all the families in one type, for example, the error for all the quadrupoles; another way is to define the error for each family, for example, the “Q1” family of the quadrupoles.
    2779   The systermatic misalignment error file works for the lattices with full or half quadrupoles; the random misalignment error file only works for lattice with full quadrupoles.
     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.
    27803206
    27813207\subsection{Systematic errors}
    2782      To define the systematic misalignment error of the element, user just needs to follow the rules as below.       
     3208To define the systematic misalignment error of the element, user
     3209just needs to follow the rules as below.       
     3210
    27833211input format of misalignment error:
    2784        type/family         name               sys              dx                 dy                       dr
    2785 
    2786 The "keywords" means one type of lattice elements or the name of the family, and keywords of the type of lattice elements are:
    2787                               All                  all the elements in the lattice
    2788                               girder            girder
    2789                               dipole             dipole
    2790                               quad                quadrupole
    2791                               sext                 sextupole
    2792                               bpm                  beam position monitor
    2793                               family name     family name of the elements
    2794 â€œsys” is a keyword to denote that user are setting the systematic displacement error.
    2795 dx defines the displacement in x direction with unit [m].
    2796 dy defines the displacement in y direction with unit [m].
    2797 dr defines the rotation angle with unit [rad]).
     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
    27983247The line start with ‘\#’ is comment line.
     3248\item
    27993249The blank line in the misalignment error file is neglected by the code.
    2800 
    2801    The following is an example file to define systematic multipole error on Soleil lattice:
    2802 
    2803 \#----------------------------------------------------------------------- 
    2804 \#  systematic  alignment error for SOLEIL
    2805 \#  name       x(m)      y(m)      r (rad)
    2806 \#-----------------------------------------------------------------------
    2807 \begin{table}[h]
    2808 \centering
    2809 \caption{}
    2810 \label{}
    2811 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    2812 \hline
    2813 \hline
    2814 \end{tabular*}
    2815 \end{table}
    2816 
    2817 girder  sys   100.0e-6  100.0e-6            0.5e-03
    2818 quad    sys    30.0e-6   30.0e-6       80.0e-06
    2819 sext    sys    30.0e-6   30.0e-6      100.0e-06
    2820 dipole  sys   500.0e-6  500.0e-6            0.2e-03
     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}
    28213264
    28223265\subsection{Random errors}
    2823 To define random misalignment errors on the lattice elements, user need to follow the same rule as the ones to define systematic misalignment error except replacing “sys” by “rms”. That is:
     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:
    28243269input format of misalignment error:
    2825 seed            seed\_number
    2826       type/family      name               rms              dx                 dy                       dr
    2827 The random misalignment error is multiplied by the random scale factor; the new value is added to the corresponding components of the misalignment components. The random scale factor is generated by a random function which follows the normal distribution (mean value is 0 and standard deviation is 1), the cut off value for the normal distribution function is 2 times of the RMS value.       
    2828   If user does not define seed for the random function before the setting of errors, then the code will stop and give an error message.
    2829   Here is example file to define random misalignment error in the lattice:
    2830 \#----------------------------------------------------------------------- 
    2831 \#  random  alignment error for SOLEIL
    2832 \#  name       x(m)      y(m)      r (rad)
    2833 \#-----------------------------------------------------------------------
    2834 \begin{table}[h]
    2835 \centering
    2836 \caption{}
    2837 \label{}
    2838 \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|p{0.2\linewidth} |p{0.5\linewidth} | p{0.15\linewidth} |}
    2839 \hline
    2840 \hline
    2841 \end{tabular*}
    2842 \end{table}
    2843 
    2844 girder  rms   100.0e-6  100.0e-6            0.5e-03
    2845 quad    rms    30.0e-6   30.0e-6       80.0e-06
    2846 sext    rms    30.0e-6   30.0e-6      100.0e-06
    2847 dipole  rms   500.0e-6  500.0e-6            0.2e-03
    2848 5.4 Vacuum chamber file
    2849 User can define the script to set the vacuum chamber limitation around the ring. The characteristic for the vacuum chamber script are:
     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
    28503313Lines start with “\#” are comment.
    2851 The format of the vacuum chamber definition is
    2852              MK1, MK2, minimum x, maximum x, minimum y, maximum y. 
    2853 To set the vacuum chamber, it is needed to add two markers in the lattice, such as MK1 and MK2, MK1 is before the first element and MK2 is after the end element of the vacuum chamber region.
    2854 The numbers of MK1 and MK2 are the same in the lattice.
    2855 The units are [meter] for minimum x, maximum x, minimum y, maximum y. 
    2856 The first line is to define the global vacuum chamber limit around the ring, and the key words should be "Start","All".
     3314\end{itemize}
     3315
    28573316
    28583317
    28593318The following is one example of the user vacuum chamber script:
    2860 
    2861          \#*********************************************
    2862          \# Script to set the vacuum chamber
    2863          \#
    2864          \#**********************************************
    2865          \# MK1 MK2  dxmin  dxmax  dymin   dymax  (Apertures in  meter)
    2866          Start  All    -35e-3  35e-3  -12.5e-3   12.5e-3
    2867         \#sdm1 esdm  -21e-3  21e-3   -5e-3     5e-3
    2868           debut ehu600  -35e-3  35e-3  -7e-3    7e-3
    2869           ssep  esep   -20e-3  35e-3  -7e-3    7e-3
    2870           ssdm  esdm   -21e-3  21e-3  -5e-3    5e-3
    2871            ssdac esdac  -35e-3  25e-3  -2.5e-3   2.5e-3
    2872 
     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}
    28733334\end{document}
    28743335
  • trunk/tracy/tracy/inc/field.h

    r3 r32  
    233233
    234234
    235 typedef ss_vect<double>  Vector;
    236 typedef Vector           Matrix[ss_dim];
     235typedef ss_vect<double>  Vector;                 /*6*1 vector*/
     236typedef Vector           Matrix[ss_dim];         /*6*6 matrix*/
    237237
    238238
  • trunk/tracy/tracy/inc/tracy_global.h

    r11 r32  
    33
    44typedef struct globvalrec {
    5   double        dPcommon,       // dp for numerical differentiation 
     5  double        dPcommon,       // dp for numerical differentiation; defined in lattice
    66                dPparticle;     // energy deviation
    77  double        delta_RF;       // RF acceptance
     
    99  double        Omega,
    1010                U0,             // energy lost per turn in keV
    11                 Alphac;         // alphap
     11                Alphac;         // momentum compaction factor
    1212  Vector2       Chrom;          // chromaticities
    13   double        Energy;         // ring energy
    14   long          Cell_nLoc,      // number of elements in a cell
     13  double        Energy;         // ring energy; defined in lattice
     14  long          Cell_nLoc,      // number of elements in a cell (For example, a lattice can have several same cells)
    1515                Elem_nFam,      // number of families
    1616                CODimax;        /* maximum number of cod search before
    1717                                   failing */
    18   double        CODeps;         // precision for closed orbit finder
     18  double        CODeps;         // precision for closed orbit finder; defined in the lattice
    1919  Vector        CODvect;        // closed orbit; beam position at the first element of lattice
    2020 
     
    3535                Vi;             // imaginal par of the eigenvectors
    3636
    37   bool          MatMeth,        // matrix method
     37  bool          MatMeth,        // matrix method or symplectic tracking?
    3838                Cavity_on,      // if true, cavity turned on
    3939                radiation,      // if true, radiation turned on
    40                 emittance,
    41                 quad_fringe,    /* dipole- and quadrupole hard-edge
     40                emittance,       // calculate emittance?
     41                quad_fringe,    /* dipole- and quadrupole hard-edge?
    4242                                   fringe fields. */
    43                 H_exact,        // "small ring" Hamiltonian.
     43                H_exact,        // "small ring" or approximation Hamiltonian?
    4444                pathlength,     // absolute path length
    4545                stable,
     
    105105  mpolArray   PBrnd;     // random scale factor of rms error PBrms gradient, bn and an
    106106  mpolArray   PB;        // total field strength(design,sys,rms) gradient, bn and an
     107  //basic parameters
    107108  int         Porder;    // The highest order in PB
    108109  int         n_design;  // multipole order (design, All = 0, Dip = 1, Quad = 2, Sext = 3, Oct = 4, Dec = 5, Dodec = 6)
    109110  pthicktype  Pthick;    // thick element
    110   // Bending Angles
     111  // dipole type
    111112  double PTx1;           // horizontal entrance angle [deg]
    112113  double PTx2;           // horizontal exit angle [deg]
    113114  double PH1;            // bending curvature of the entrance pole face of dipole, see P116 SAC-75.
    114115  double PH2;            // bending curvature of the exit pole face of dipole, see P116 SAC-75.
    115   double Pgap;           // total magnet gap [m]
    116   double Pirho;          // angle([radian], but in lattice definition, angle is with unit degree)/length of the dipole, 1/rho [1/m]
     116  double Pgap;           // total dipole gap [m]
     117  double Pirho;          // curvature of the dipoles. 1/rho [1/m]
    117118  double Pc0, Pc1, Ps1;  // corrections for roll error of bend
    118119  Matrix AU55,           // Upstream 5x5 matrix
     
    285286                                         maxampl[X_][0] < x < maxampl[X_][1]
    286287                                         maxampl[Y_][0] < y < maxampl[Y_][1] */
    287 };
     288
     289   Vector        CODvect;        //orbit at the end of the lattice element  Added by Jianfeng Zhang @ LAL, 01/04/2014.
     290};
  • trunk/tracy/tracy/src/mathlib.cc

    r3 r32  
    218218}
    219219
    220 
     220/***********************************************************
     221 * void CopyVec(const int n, const Vector &a, Vector &b)
     222 *
     223 *  Copy 6D vector a to b: b = a.
     224 *
     225 ***********************************************************/
    221226void CopyVec(const int n, const Vector &a, Vector &b)
    222227{
    223   int i;
     228  int i=0;
    224229
    225230  for (i = 0; i < n; i++)
     
    457462
    458463
     464/*********************************************************
     465 * void MulLMat(const int n, const Matrix &A, Matrix &B)
     466 *
     467 * Matrix multiplication.  B = A * B
     468 *
     469 *
     470 **********************************************************/
    459471void MulLMat(const int n, const Matrix &A, Matrix &B)
    460472{
    461   int i, j, k;
    462   double x;
     473  int i=0, j=0, k=0;
     474  double x=0.0;
    463475  Matrix C;
    464476
     
    474486}
    475487
    476 
     488/*********************************************************
     489 * void MulRMat(const int n, const Matrix &A, Matrix &B)
     490 *
     491 * Matrix multiplication.  A = A * B
     492 *
     493 *
     494 **********************************************************/
    477495void MulRMat(const int n, Matrix &A, const Matrix &B)
    478496{
    479   int i, j, k;
    480   double x;
     497  int i=0, j=0, k=0;
     498  double x=0.0;
    481499  Matrix C;
    482500
     
    492510}
    493511
    494 
     512/*********************************************************
     513 * double TrMat(const int n, const Matrix &A)
     514 *
     515 * Calculate the trance of the matrix A.
     516 *
     517 *  return:
     518 *          x.
     519 *
     520 **********************************************************/
    495521double TrMat(const int n, const Matrix &A)
    496522{
  • trunk/tracy/tracy/src/nsls-ii_lib.cc

    r11 r32  
    763763                      1.5  sextupole
    764764                      2.0  bpm
    765       Fnum        family index
     765      Fnum        family index of the BPM.
    766766      all         true, print the cod at all elements
    767                   false, print the cod at the family elements
     767                  false, print the cod at the BPM elements, the name of the BPM must be defined in the "*.prm" file.
    768768   Output:
    769769       none
     
    784784void prt_cod(const char *file_name, const int Fnum, const bool all)
    785785{
    786   long      i;
     786  long      i=0L;
    787787  double    code = 0.0;
    788788  FILE      *outf;
    789   long      FORLIM;
     789  long      FORLIM=0L;
    790790  struct    tm *newtime;
    791791
     
    828828      }
    829829      /* COD is in local coordinates */
    830       fprintf(outf, "%4ld %.*s %6.2f %4.1f %6.3f %6.3f %6.3f %6.3f"
    831               " %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
     830      fprintf(outf, "%4ld %.*s %6.2f %4.1f %6.4f %6.4f %6.4f %6.4f"
     831              " %6.4f %6.4f %6.4f %6.4f %6.4f %6.4f\n",
    832832              i, SymbolLength, Cell[i].Elem.PName, Cell[i].S, code,
    833833              Cell[i].Beta[X_], Cell[i].Nu[X_],
     
    842842}
    843843
     844/****************************************************************
     845 * void prt_beampos(const char *file_name)
     846 *
     847 *  print the orbits at all lattice elements.
     848 *
     849 * Comments:   
     850 *     To use this command, the BPM name should be defined in the
     851 *  "*.prm" file with the command
     852 *                bpm_name   BPM_names
     853 *
     854 *
     855 ****************************************************************/
    844856
    845857void prt_beampos(const char *file_name)
    846858{
    847   int       k;
     859  int       i=0;
    848860  ofstream  outf;
    849861
    850862  file_wr(outf, file_name);
    851863
    852   outf << "# k  s  name x   px    y   py   delta ct" << endl;
     864  outf << "#   i     name              s[m]     x[mm]   px    y[mm]   py   delta ct" << endl;
    853865  outf << "#" << endl;
    854866
    855   for (k = 0; k <= globval.Cell_nLoc; k++)
    856     outf << scientific << setprecision(5)
    857          << setw(5) << k << setw(11) << Cell[k].Elem.PName
    858          << setw(13) << Cell[k].BeamPos << endl;
    859 
     867 
     868  for (i = 0; i <= globval.Cell_nLoc; i++){
     869   if (Cell[i].Fnum == globval.bpm)
     870        outf << scientific << setprecision(4)
     871          << setw(5) << i << setw(20) << Cell[i].Elem.PName
     872          << setw(5) << Cell[i].S
     873          << setw(13) << Cell[i].BeamPos*1e3 << endl;
     874  }     
    860875  outf.close();
    861876}
     
    874889  // the dT and roll angle are all printed out
    875890{
    876   int i,j;
    877   int  n_girders;
    878   int  gs_Fnum, ge_Fnum;
    879   int  gs_nKid, ge_nKid;
    880   int  dip_Fnum,dip_nKid;
    881   int  loc, loc_gs, loc_ge;
     891  int i=0,j=0;
     892  int  n_girders=0;
     893  int  gs_Fnum=0, ge_Fnum=0;
     894  int  gs_nKid=0, ge_nKid=0;
     895  int  dip_Fnum=0,dip_nKid=0;
     896  int  loc=0, loc_gs=0, loc_ge=0;
    882897  char * name;
    883   double s;
     898  double s=0.0;
    884899  double PdSsys[2], PdSrms[2], PdSrnd[2], dS[2], dT[2];
    885900  fstream fout;
     
    52855300  Purpose:
    52865301           Calculate momentum compact factor up to third order.
    5287            Method:
    5288            track the orbit offset c*tau at the first element,
    5289            at 11 different energy offset(-10-3 to 10-3), then
    5290            use polynomal to fit the momentum compact faction factor
    5291            up to 3rd order.
    5292            The initial coorinates are (x_co,px_co,y_co,py_co,delta,0).
    5293            
     5302           Method:
     5303           track the orbit offset c*tau at the first element,
     5304           at 11 different energy offset(-10-3 to 10-3), then
     5305           use polynomal to fit the momentum compact faction factor
     5306           up to 3rd order.
     5307          The initial coorinates are (x_co,px_co,y_co,py_co,delta,0).
     5308          
    52945309 Input:
    52955310       none
     
    53075322       change the initial coorinates from (0 0 0 0 delta 0) to
    53085323              (x_co,px_co,y_co,py_co,delta,0).  i.e., track
    5309               around the off-momentum close orbit but not zero orbit.     
     5324       around the off-momentum close orbit but not zero orbit.     
    53105325
    53115326*******************************************************************/
     
    53205335 //const double  d_delta  = 1e-4;
    53215336
    5322   int       i, n;
    5323   long int  lastpos;  // last tracking position when the particle is stable
    5324   double    delta[2*n_points+1], alphac[2*n_points+1], sigma;
     5337  int       i=0, n=0;
     5338  long int  lastpos=0L;  // last tracking position when the particle is stable
     5339  double    delta[2*n_points+1], alphac[2*n_points+1], sigma=0.0;
    53255340  Vector    x, b;
    53265341  CellType  Cell;
    5327   bool      cod;
     5342  bool      cod=false;
    53285343 
    53295344  globval.pathlength = false;
    53305345  getelem(globval.Cell_nLoc, &Cell);
    5331   n = 0;
    53325346 
    53335347  for (i = -n_points; i <= n_points; i++) {
     
    53535367
    53545368
     5369/**********************************************************
     5370 * float f_bend(float b0L[])
     5371 *
     5372 *
     5373 *
     5374 **********************************************************/
    53555375float f_bend(float b0L[])
    53565376{
  • trunk/tracy/tracy/src/physlib.cc

    r11 r32  
    263263
    264264/****************************************************************************/
    265 /* void printglob2file(void)
    266 
    267  Purpose:
    268  Print global variables on screen
    269  Print tunes and chromaticities
    270  Print Oneturn matrix
     265/* void printglob2file(const char fic[])
     266
     267 Purpose:
     268 Print global variables,
     269       tunes and chromaticities, and
     270       Oneturn matrix,
     271       to an external file.
    271272
    272273 Input:
     
    615616void TraceABN(long i0, long i1, const Vector2 &alpha, const Vector2 &beta,
    616617        const Vector2 &eta, const Vector2 &etap, const double dP) {
    617     long i, j;
    618     double sb;
     618    long i=0, j=0;
     619    double sb=0.0;
    619620    ss_vect<tps> Ascr;
    620621
  • trunk/tracy/tracy/src/prtmfile.cc

    r11 r32  
    8686 Type codes:
    8787 marker         -1
    88  drift      0
     88 drift           0
    8989 multipole       1
    9090 cavity          2
     
    166166 ******************************************************************************/
    167167void prtmfile(const char mfile_dat[]) {
    168   int i, j;
     168  int i=0, j=0;
    169169  FILE *mfile;
    170170
     
    192192        fprintf(mfile, " %23.16e %23.16e %23.16e\n", Cell[i].dS[X_],
    193193            Cell[i].dS[Y_], Cell[i].Elem.M->PdTsys + Cell[i].Elem.M->PdTrms
    194                 * Cell[i].Elem.M->PdTrnd);
    195         prtHOM(mfile, Cell[i].Elem.M->n_design, Cell[i].Elem.M->PB,
     194                * Cell[i].Elem.M->PdTrnd);         
     195        prtHOM(mfile, Cell[i].Elem.M->n_design, Cell[i].Elem.M->PB,
    196196            Cell[i].Elem.M->Porder);
    197197      }
  • trunk/tracy/tracy/src/read_script.cc

    r11 r32  
    7878 
    7979 
    80   char    str[max_str]="voidstring", dummy[max_str]="voidstring",dummy2[max_str]="voidstring", nextpara[max_str]="voidpara";
    81   char    in[max_str];  //temporary line with preceding white space
     80  char    str[max_str]="", dummy[max_str]="",dummy2[max_str]="", nextpara[max_str]="";
     81  char    in[max_str]="";  //temporary line with preceding white space
    8282  char    *line = NULL; //line to store the command without preceding white space
    8383  size_t   len = 0;
    8484  ssize_t  read;
    85   char    name[max_str]="voidname";
     85  char    name[max_str]=""; //initialize with empty character array.
    8686 // char    lat_file[max_str]="voidlattice";
    87   char    EndName[]="void";
     87  char    EndName[5]="";
    8888
    8989  FILE    *inf;
     
    9292  long int    NameLen=0L;
    9393  int idummy=0;
    94   char full_param_file_name[max_str];
    95   char lat_FileName[max_str];
     94  char full_param_file_name[max_str]="";
     95  char lat_FileName[max_str]="";
    9696 //bool TuneTracFlag;
    9797  char *pch;
     
    115115     
    116116     LineNum++;
    117      if(prt){
     117     if(!prt){
    118118       printf("Line # %ld \n",LineNum);
    119119       printf("Retrieved line of length %zu : \n",read);
     
    126126    if (strstr(line, "#") == NULL && line[0] != '\n' &&
    127127        line[0] != '\r' && strcmp(line, "\r\n") != 0 ){
     128   
     129       
    128130      // get initial command token
    129131      sscanf(line, "%s", name);
     
    134136      //find the sequence of the bool flag in user input script
    135137      NameLen = strlen(name);
    136       EndName[0] = name[NameLen-4];
    137       EndName[1] = name[NameLen-3];
    138       EndName[2] = name[NameLen-2];
    139       EndName[3] = name[NameLen-1];         
    140      
     138      if(NameLen >= 4 ){
     139        EndName[0] = name[NameLen-4];
     140        EndName[1] = name[NameLen-3];
     141        EndName[2] = name[NameLen-2];
     142        EndName[3] = name[NameLen-1];         
     143      }
    141144      //find the bool flag whose last 4 character are 'Flag'
    142145      if(strcmp(EndName,"Flag")==0)
  • trunk/tracy/tracy/src/soleilcommon.cc

    r11 r32  
    153153    /*check whether the RF cavity hormonic number is defined or not*/
    154154    if(Cell[Elem_GetPos(globval.cav, 1)].Elem.C->Ph == 0){
    155       printf("soleilcommon():    Error!!! Please define RF harmonic number in the lattice! \n"
    156               "Because this parameter will be used to calculate stable phase for positive / negative momentum compaction factor\n");
     155      printf("soleilcommon():    Error!!! Please define the RF harmonic number in the lattice! \n"
     156              "Because this parameter will be used to calculate the stable phase for the lattice with the "
     157              "positive / negative momentum compaction factor\n");
    157158      exit_(1);
    158159    }
     
    169170    globval.emittance  = false; /* emittance  on/off */
    170171    globval.pathlength = false; /* Path lengthening computation */
    171     globval.CODimax    = 40L;   /* maximum number of iterations for COD algo */
     172    globval.CODimax    = 40L;   /* maximum number of iterations for COD algorithm */
    172173    globval.dPcommon   = 1e-10; /* Common energy step for energy differentiation */
    173174    globval.delta_RF  = RFacceptance;/* energy acceptance for SOLEIL */
    174175
    175    /* define x/y physical aperture, use the default values: +- 1 meter  */
     176   /* define x/y physical aperture (vacuum chamber), use the default values: +- 1 meter  */
    176177    globval.Aperture_on = false;
    177178   
     
    183184  else
    184185  { // for transfer lines 
    185     /* Initial settings : */
    186     beta[0]  = 8.1;
    187     alpha[0] = 0.0;
    188     beta[1]  = 8.1;
    189     alpha[1] = 0.0;
    190     eta[0]   = 0.0;
    191     etap[0]  = 0.0;
    192     eta[1]   = 0.0;
    193     etap[1]  = 0.0;
    194 
     186    /* Initial optical parameters of the transfer line: */
     187    beta[0]  = 34.46;   // beta_x
     188    beta[1]  = 33.94;   // beta_y
     189    alpha[0] = -4.24;   // alpha_x
     190    alpha[1] = -4.34;   // alpha_y
     191    eta[0]   = 0.0;   // eta_x
     192    etap[0]  = 0.0;   // etap_x
     193    eta[1]   = 0.0;   // eta_y
     194    etap[1]  = 0.0;   // etap_y
     195
     196    // set the initial orbit of the transfer line is zero
    195197     for (i = 0; i < ss_dim; i++) {
    196198    {
     
    200202    dP = codvect[4];
    201203
     204    codvect[0]=1e-4;
     205   
    202206    /* Defines global variables for Tracy code */
    203207    globval.MatMeth = false;  /* matrix method */
     
    214218    globval.Aperture_on = false;
    215219   
    216    
     220    // transfer the optical functions and the orbit
    217221    TransTwiss(alpha, beta, eta, etap, codvect);
     222 
     223    // print location, twiss parameters and close orbit/orbit at all elements position to a file
     224      prt_cod("cod.out", globval.bpm, true);
    218225    }
    219226  }//finish read the transfer line
  • trunk/tracy/tracy/src/t2cell.cc

    r3 r32  
    798798     fixed point for the lattice with negative momentum compact factor. 
    799799      28/06/11   Correct the one turn map for the lattice with negative momentum compact factor, now the one turn map is
    800       tracked around the COD.
     800      tracked around the COD. By Jianfeng Zhang @ SOLEIL
    801801****************************************************************************/
    802802bool Cell_getCOD(long imax, double eps, double dP, long &lastpos)
    803803{
    804   long             j = 0, n = 0, n_iter = 0, h_RF = 0;
     804  long             j = 0L, n = 0L, n_iter = 0L, h_RF = 0L;
    805805  double           dxabs = 0.0;
    806806  iVector          jj;
     
    845845    }
    846846   
    847   n_iter = 0;
     847   
    848848  I.identity();
    849849 
  • trunk/tracy/tracy/src/t2elem.cc

    r24 r32  
    885885
    886886 Comments:
    887  06/11/2012     Jianfeng Nadolski @ LAL
     887 06/11/2012     Jianfeng Zhang @ LAL
    888888                Fix the bug in the kick map of the exact Hamiltonian.
    889889                Add the second order of the approximate Hamiltonian.
     
    893893void thin_kick(int Order, double MB[], double L, double h_bend, double h_ref,
    894894        ss_vect<T> &x) {
    895     int j;
     895    int j=0;
    896896    T BxoBrho, ByoBrho, ByoBrho1, B[3];
    897897    T sqrtpx, dpx, ps2new, psnew;
     
    24482448
    24492449 Input:
    2450  xref vector
    2451  x    matrix
     2450 xref: 6*1 orbit
     2451 x:    6*6 (optics) transfer matrix?
    24522452
    24532453 Output:
    2454  xref
    2455  x
     2454 xref:  6*1 orbit
     2455 x:   6*6 (optics) transfer matrix
    24562456
    24572457 Return:
     
    26222622     */
    26232623
    2624     double L;
     2624    double L=0.0;
    26252625    CellType *cellp;
    26262626    elemtype *elemp;
     
    26742674     (  0    0     0    0       1  )                     */
    26752675
    2676     double t, sk, sk0, s, c;
     2676    double t=0.0, sk=0.0, sk0=0.0, s=0.0, c=0.0;
    26772677    Matrix a, ah, av;
    26782678
     
    27712771     cos phi                                              */
    27722772
    2773     double r, s, c, sk, p, fk, afk;
     2773    double r=0.0, s=0.0, c=0.0, sk=0.0, p=0.0, fk=0.0, afk=0.0;
    27742774    Matrix edge, ah, av;
    2775     double coef, scoef;
     2775    double coef=0.0, scoef=0.0;
    27762776
    27772777    if (irho == 0.0) {
     
    41264126 ****************************************************************************/
    41274127void Drift_Init(int Fnum1) {
    4128     int i;
     4128    int i=1;
    41294129    ElemFamType *elemfamp;
    41304130    CellType *cellp;
     
    41714171
    41724172void Mpole_Init(int Fnum1) {
    4173     double x;
    4174     int i;
     4173    double x=0.0;
     4174    int i=1;
    41754175    ElemFamType *elemfamp;
    41764176    CellType *cellp;
  • trunk/tracy/tracy/src/t2lat.cc

    r11 r32  
    258258static long CheckUDItable(const char *name, struct LOC_Lattice_Read *LINK)
    259259{
    260   long  i, j, FORLIM;
     260  long  i=0, j=0, FORLIM=0;
    261261
    262262  j = 0;
     
    26522652    QL = 0.0;   /* L */
    26532653    QKick = 0.0; /* kick angle of the corrector [rad]*/
    2654     Kplane = 0;   /* 1 is horizontal corrector, -1 is vertical corrector */
    2655     k1 = 1;     /* N */
    2656     k2 = Meth_Linear;   /* method */
    2657     dt = 0.0;
     2654    Kplane = 1;   /* 1 is horizontal corrector, -1 is vertical corrector */
     2655    k1 = 1;     /* N, cut piece of corrector */
     2656    k2 = Meth_Linear;   /* integartion method */
     2657    dt = 0.0;    /* roll angle of the corrector */
    26582658    ClearHOMandDBN(&V);
    26592659    getest__(P_expset(SET, 1 << ((long)comma)), "<, > expected", &V);
     
    26682668      P_addset(mysys, (long)rollsym);
    26692669      P_addset(mysys, (long)dbnsym);
    2670       do {   /*5: read L, K, N, T, T1, T2 */
     2670      do {   /*5: read L, kick angle, cut piece, integartion method, roll angle, T2 */
    26712671        test__(mysys, "illegal parameter", &V); sym1 = *V.sym;
    26722672        if (*V.sym == (long)dbnsym || *V.sym == (long)rollsym ||
     
    27142714            else if (sym1 == versym)
    27152715              Kplane = -1;
     2716            else{
     2717              cout << "t2lat: Error! Must specify the type of the corrector, Horizontal or vertical!" << endl;
     2718              exit_(1);
     2719            }
    27162720            GetSym__(&V);
    27172721          }
     
    27432747      WITH2->PN = k1;
    27442748      WITH2->PdTpar = dt;
    2745 
    2746         if(Kplane == 0){
    2747                 cout << "t2lat: Error! Must specify the type of the corrector, Horizontal or vertical!" << endl;
    2748                 exit_(1);
    2749             }
    27502749      WITH2->PBpar[Kplane*Dip + HOMmax] = -1*QKick;  //assign the kick angle [rad]
    27512750 
     
    37553754  Reg("inv            ", invsym, &V);
    37563755  Reg("kick           ", corkicksym, &V); /* with "corrector", define the kick angle of the corrector ,  Jianfeng Zhang*/
    3757   Reg("kicker         ", kicksym, &V);
     3756 //Reg("kicker         ", kicksym, &V); /*overlap with the lattice element type: corrector*/
    37583757  Reg("ks             ", kssym, &V);
    37593758  Reg("lambda         ", lmdsym, &V);
     
    41214120void GetEnergy(struct LOC_Lattice_Read *LINK)
    41224121{
    4123   long k;
     4122  long k=0;
    41244123
    41254124  k = CheckUDItable("energy         ", LINK);
     
    41374136void GetRingType(struct LOC_Lattice_Read *LINK)
    41384137{
    4139   long k;
     4138  long k=0;
    41404139
    41414140  k = CheckUDItable("ringtype       ", LINK);
  • trunk/tracy/tracy/src/t2ring.cc

    r11 r32  
    196196
    197197   Purpose:
    198      Computes Twiss parameters alpha and beta from the matrix Ascr
     198     Assign the Twiss parameters alpha and beta from the matrix Ascr
     199       to alpha & beta.
    199200       
    200201       M oneturn matrix    (A and M are symplectic)
     
    218219
    219220   Return:
    220        none
     221       alpha, beta.
    221222
    222223   Global variables:
     
    233234void getprm(Matrix &Ascr, Vector2 &alpha, Vector2 &beta)
    234235{
    235   int  i, j;
     236  int  i=0, j=0;
    236237
    237238  for (i = 1; i <= 2; i++) {
     
    253254       i0     first element
    254255       i1     last element
    255        ring   true if a ring
     256       ring   true if a ring, false is a transfer line
    256257       chroma true if compute chromaticities
    257258       dP     energy offset
     
    278279                  bool ring, double dP)
    279280{
    280   long int  i;
    281   int       j, k;
     281  long int  i=0L;
     282  int       j=0, k=0;
    282283  Vector2   nu1, dnu;
    283   Vector    xref;
    284   Matrix    Ascr0, Ascr1;
     284  Vector    xref;                   /*6*1 vector*/
     285  Matrix    Ascr0, Ascr1;           /*6*6 matrix*/
    285286  CellType  *cellp;
    286287
    287288  if (dP != globval.dPparticle) Cell_SetdP(dP);
    288289
    289   /* Init */ 
     290  /* Initize the phase */ 
    290291  for (j = 0; j <= 1; j++)
    291     nu1[j] = 0.0;
    292 
    293   /* get alpha beta for i0 */ 
     292    nu1[j] = 0.0;  /*phase advance*/
     293
     294  /* get alpha & beta for i0 */ 
    294295  cellp = &Cell[i0];
    295   getprm(Ascr, cellp->Alpha, cellp->Beta);
    296   memcpy(cellp->Nu, nu1, sizeof(Vector2));
     296  getprm(Ascr, cellp->Alpha, cellp->Beta);  /*initialize the alpha & beta functions */
     297  memcpy(cellp->Nu, nu1, sizeof(Vector2));  /*initialize the phase advance*/
    297298  CopyMat(n+1, Ascr, Ascr0); CopyVec(n+2L, globval.CODvect, xref);
    298299
     
    301302    /* Ascr1=Elem_M*Ascr0 */
    302303    /* xref =Elem(xref)   */
    303     Elem_Pass_M(i, xref, Ascr1);
     304    Elem_Pass_M(i, xref, Ascr1);   /* transport orbit & optic matrix */
    304305
    305306    cellp = &Cell[i];
    306307    /* get alpha and beta for element i */
    307308    getprm(Ascr1, cellp->Alpha, cellp->Beta);
     309    /*save the orbit at the end of the lattice elment*/
     310    CopyVec(ss_dim, xref,cellp->CODvect);
    308311
    309312    for (j = 0; j <= 1; j++) {
     
    861864                Vector2 &etap, Vector &codvect)
    862865{
    863   long i, j, lastpos;
    864   double sb;
    865   Matrix Ascr;
     866  long i=0L, j=0L, lastpos=0L;
     867  double sb=0.0;
     868  Matrix Ascr; /* 6*6 transfer matrix*/
    866869
    867870  UnitMat(6L, Ascr);
Note: See TracChangeset for help on using the changeset viewer.