Skip to content

Commit 20475e4

Browse files
authored
Merge pull request #1200 from jgray-19/testing_ptc
PTC Improvements and BugFixes
2 parents 34b9146 + 80b4101 commit 20475e4

File tree

81 files changed

+2641
-2152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2641
-2152
lines changed

doc/latexuguide/biblio-mad.bib

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ @InProceedings{burkhardt2013
415415
series = {International Particle Accelerator Conference},
416416
year = 2013,
417417
number = {MOPWO027},
418-
note = {http://accelconf.web.cern.ch/AccelConf/IPAC2013/papers/mopwo027.pdf}}
418+
note = {\url{http://accelconf.web.cern.ch/AccelConf/IPAC2013/papers/mopwo027.pdf}}}
419419

420420
@TechReport{bjorken-mtingwa1982,
421421
author = {J. D. Bjorken and S. K. Mtingwa},
@@ -455,7 +455,7 @@ @InProceedings{schmidt2005
455455
pages = 1772,
456456
number = {MPPE012},
457457
address = {Knoxville, USA},
458-
note = {http://cern.ch/madx/doc/MPPE012.pdf}}
458+
note = {\url{http://cern.ch/madx/doc/MPPE012.pdf}}}
459459

460460
@TechReport{forest2002,
461461
author = {Etienne Forest and Frank Schmidt and Eric McIntosh},
@@ -464,7 +464,15 @@ @TechReport{forest2002
464464
year = 2002,
465465
number = {KEK Report 2002-3, CERN-SL-2002-044-AP},
466466
month = {July},
467-
note = {http://ccdb4fs.kek.jp/cgi-bin/img/allpdf?200302020, http://cern.ch/madx/doc/sl-2002-044.pdf}}
467+
note = {\url{http://ccdb4fs.kek.jp/cgi-bin/img/allpdf?200302020}, \url{http://cern.ch/madx/doc/sl-2002-044.pdf}}}
468+
469+
@misc{sad_quad_2022,
470+
title={Elements/{QUAD}, {SADWiki}},
471+
Author={KEK},
472+
year={2022},
473+
month={Nov},
474+
note={\url{https://www-kekb.kek.jp/Documentation/SAD/?Elements%2FQUAD}},
475+
}
468476
469477
@Article{danilov2010,
470478
author = {V. Danilov and S. Nagaitsev},
@@ -520,7 +528,7 @@ @TechReport{schoch1958
520528
institution = {CERN},
521529
year = 1958,
522530
number = {CERN-27-21},
523-
note = {http://cern.ch/madx/doc/yellow-report-1957.pdf}}
531+
note = {\url{http://cern.ch/madx/doc/yellow-report-1957.pdf}}}
524532

525533
@TechReport{zhang2005,
526534
author = {K. Zhang},

doc/latexuguide/ptc-general.tex

Lines changed: 251 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ \section{PTC\_CREATE\_UNIVERSE}
104104
\texttt{SECTOR\_NMUL\_MAX} is passed than it is also identified automatically.
105105
However, if multipolar parameters of the bends are to be modified inside the PTC universe,
106106
for example with \texttt{PTC\_READ\_ERRORS},
107-
than this parameter needs to be set to a corresponding value.
107+
then this parameter needs to be set to a corresponding value.
108108
Please note that using large values (above 10) slows down the computations,
109-
so the smallest required value should be used.
110-
\\
109+
so the smallest required value should be used. We recommended a minimum of
110+
MAX(\texttt{ORDER}+1,N+2) (where \texttt{ORDER} is the order of the map),
111+
however \texttt{order}+1+N would give the most accurate results. \\
111112
(Default:-1)
112113

113114
\ttitem{NTPSA} invokes the Differential Algebra (DA) package
@@ -151,10 +152,16 @@ \section{PTC\_CREATE\_LAYOUT}
151152
\ttitem{MODEL} an integer to switch between models:\\
152153
1 for "Drift-Kick-Drift"; (Default value)\\
153154
2 for "Matrix-Kick-Matrix" and \\
154-
3 for "Delta-Matrix-Kick-Matrix" (SixTrack-code model).
155+
3 for "Delta-Matrix-Kick-Matrix" (SixTrack-code model). \\
156+
Note: Model 1 usually will require more integration and slicing than model 2.
155157

156-
\ttitem{METHOD} the integration order: 2, 4, or 6 (See
157-
\cite{forest2002}~Chapter~K) \\ (Default: 2)
158+
\ttitem{METHOD} the integration order: 2, 4, 6 or 8. This will either use
159+
Forest-Yoshida integration or Boole's rule (See \cite{forest2002}~Chapter~K for
160+
more details). The optimum \texttt{METHOD} value corresponds to
161+
the value beyond which the studied properties no longer change
162+
(in conjunction with increasing slicing). \texttt{METHOD} has a greater effect
163+
on this convergence, while not increasing the amount of computations as much
164+
as slicing would to achieve the same convergence \\ (Default: 2)
158165

159166
\ttitem{NST} the number of integration steps. (Default:~1)\\
160167
The body of each element is divided into \texttt{NST} equal slices and
@@ -231,24 +238,28 @@ \section{PTC\_SETSWITCH}
231238
The \texttt{PTC\_SETSWITCH} command allows to set some global \ptc states and to configure the interface between {\madx} and {\ptc}, adapting the behavior of the program to the needs.
232239

233240
\madbox{
234-
PTC\_SETSWITCH, \=DEBUGLEVEL=integer, \\
235-
\>EXACT\_MIS=logical,\\
236-
\>TOTALPATH=logical,\\
237-
\>RADIATION=logical,\\
238-
\>ENVELOPE=logical,\\
239-
\>STOCHASTIC=logical,\\
240-
\>MODULATION=logical,\\
241-
\>FRINGE=logical,\\
242-
\>TIME=logical,\\
243-
\>SEED=integer,\\
244-
\>MAXACCELERATION=logical;
241+
PTC\_SETSWITCH, \=DEBUGLEVEL=integer, MAPDUMP=integer, MADPRINT=logical, \\
242+
\>EXACT\_MIS=logical, TOTALPATH=logical, RADIATION=logical, \\
243+
\>ENVELOPE=logical, STOCHASTIC=logical, MODULATION=logical,\\
244+
\>FRINGE=logical, TIME=logical, SEED=integer, \\
245+
\>MAXACCELERATION=logical, NOCAVITY=logical, NOCHARGE=logical;
245246
}
246247

247248
The command parameters and switches are:
248249
\begin{madlist}
249250
\ttitem{DEBUGLEVEL} (Default: 1)\\
250251
Sets the level of debugging printout: 0 prints none, 4 prints everything
251252

253+
\ttitem{MAPDUMP} (Default: 0)\\
254+
Sets the level of map dump printout in all tracking codes. \\
255+
0: None,\\
256+
1: Order 0,\\
257+
2: Order 1,\\
258+
3: The full map.
259+
260+
\ttitem{MADPRINT} (Default: false)\\
261+
Sets map dump printout format so that it can be read by MAD-NG
262+
252263
\ttitem{EXACT\_MIS} (Default: false)\\
253264
Switch ensures exact misalignment treatment.
254265

@@ -344,6 +355,14 @@ \section{PTC\_SETSWITCH}
344355
Switch to set cavities phases so the reference orbit is always on
345356
the crest, i.e. gains max energy.
346357

358+
\ttitem{NOCAVITY} (Default: false)\\
359+
Switch to turn off the RF cavities, with \texttt{NOCAVITY=true},
360+
RF cavities are ignored.
361+
362+
\ttitem{NOCHARGE} (Default: true)\\
363+
Switch to ignore the charge of your beam. If set to false,
364+
the charge of the beam is taken into account.
365+
347366

348367
\end{madlist}
349368

@@ -460,7 +479,7 @@ \section{Additional Options for Physical Elements}
460479
\madbox{
461480
SBEND | \=RBEND | QUADRUPOLE | SEXTUPOLE | OCTUPOLE | SOLENOID ,\\
462481
\>L=real, ... , TILT=real, ... , NST=integer, ... ,\\
463-
\>KNL=\{0, real, real,...\}, KSL=\{0, real, real,...\};
482+
\>KNL=\{real, real, real,...\}, KSL=\{real, real, real,...\};
464483
}
465484

466485
These attributes are:
@@ -501,15 +520,225 @@ \section{Additional Options for Physical Elements}
501520
\ttitem{KSL} is an array representing the skew multipole
502521
coefficients. \\ (Default:~0~m$^{-1}$)
503522
\end{madlist}
504-
To preserve the reference orbit of straight elements, the dipole
505-
components for those elements are ignored and must be specified as
506-
zero: \texttt{KNL(0)=0, KSL(0)=0}.
507523

508524
A full range of additional multipole \hyperref[sec:efcomp]{field
509525
errors} can be additionally specified with the
510526
\hyperref[sec:efcomp]{\texttt{EFCOMP}} command. Errors are added to
511-
the above multipole fields on the bench.
527+
the above multipole fields on the bench.\\
528+
If you specify the corresponding multipole coefficient in a magnet that can accept
529+
a non integrated value, these are added together, i.e.
530+
$\texttt{k}_1 = \texttt{k}_1 + \texttt{knl}[2]/\texttt{l}$,
531+
where \texttt{knl[2]} is the value of the second element of the array knl and .
532+
533+
\end{madlist}
534+
535+
\subsection{Additional Fringe Field Parameters}
536+
537+
The following parameters are available for the following elements
538+
(Additional details can be found in \ref{sec:bend}):
539+
540+
\madbox{
541+
SBEND | \=RBEND | QUADRUPOLE | SEXTUPOLE | OCTUPOLE | SOLENOID ,\\
542+
\>FINT=real, FINTX=real, HGAP=real, FRNGMAX=integer, \\
543+
\>F1=real, F2=real, FRINGE=integer, ...;
544+
}
545+
546+
\begin{madlist}
547+
548+
\ttitem{FINT} (Default: 0) \\
549+
The fringe field integral at entrance and exit of the
550+
bend.\\ This has been activated for all elements listed above,
551+
not just for \texttt{(S|R)BEND}, as in \madx.
552+
553+
\ttitem{FINTX} (Default: =\texttt{FINT}) \\
554+
If defined and positive, the fringe field integral at
555+
the exit of the element, overriding \texttt{FINT} for the
556+
exit. \\
557+
This allows to set different fringe field integrals at entrance
558+
(\texttt{FINT}) and exit (\texttt{FINTX}) of the element.\\
559+
This has been activated for all elements listed above,
560+
not just for \texttt{(S|R)BEND}, as in \madx.
561+
562+
\ttitem{HGAP} (default: 0 m) \\
563+
The half gap of the magnet.\\
564+
This has been activated for all elements listed above,
565+
not just for \texttt{(S|R)BEND}, as in \madx.
566+
567+
\ttitem{FRNGMAX} (default: 2) \\
568+
The maximum multipole component to be included in the multipolar fringe field.
569+
570+
\ttitem{F1} (default: 0) \\
571+
The entry linear fringe field coefficient for quadrupoles, from SAD \cite{sad_quad_2022}. \\
572+
573+
\ttitem{F2} (default: 0) \\
574+
The exit linear fringe field coefficient for quadrupoles, from SAD \cite{sad_quad_2022}. \\
575+
576+
\ttitem{FRINGE} (default: 0) \\
577+
This is a bit mask that specifies the fringe field model to be used.
578+
The bits are defined as follows:\\
579+
580+
1: The dipole fringe field is performed using the \texttt{FINT},
581+
\texttt{FINTX} and \texttt{HGAP} parameters.
582+
Note: It is not possible to remove this fringe from a bend element, as \ptc
583+
will always use the dipole fringe field for bending magnets.\\
584+
585+
2: The multipole fringe field is performed, integrating up to the minimum of
586+
\texttt{FRNGMAX} and the highest multipole component specified.\\
587+
588+
4: Use the linear fringe field map for the quadrupole from the SAD code,
589+
using parameters \texttt{F1}, \texttt{F2} \cite{sad_quad_2022}. \\ \\
590+
591+
592+
An example use of the \texttt{FRINGE}, would be to specify a dipole fringe and
593+
the multipolar fringe field, has \texttt{FRINGE=3}, but to specify the multipolar
594+
fringe field and the SAD fringe field map, use \texttt{FRINGE=6}.
595+
596+
\end{madlist}
597+
598+
\subsection{Additional Pole Face Parameters}
599+
600+
The following parameters are available for the following elements,
601+
not just for \texttt{(S|R)BEND}, as in \madx
602+
(Additional details can be found in \ref{sec:bend}):
603+
604+
\madbox{
605+
SBEND | \=RBEND | QUADRUPOLE | SEXTUPOLE | OCTUPOLE ,\\
606+
\>..., E1 = real, E2 = real, ..., H1 = real, H2 = real;
607+
}
608+
609+
\begin{madlist}
610+
\ttitem{E1} (default: 0 rad) \\
611+
The entry pole face rotation angle.\\
612+
613+
\ttitem{E2} (default: 0 rad) \\
614+
The exit pole face rotation angle.\\
615+
616+
\ttitem{H1} (default: 0 m$^{-1}$) \\
617+
The entry pole face curvature.\\
618+
619+
\ttitem{H2} (default: 0 m$^{-1}$) \\
620+
The exit pole face curvature.\\
621+
622+
\end{madlist}
623+
624+
\subsection{Additional Parameters for the \texttt{SBEND} and \texttt{RBEND} elements}
512625

626+
The following parameters are available for the \texttt{SBEND} and \texttt{RBEND} elements:
627+
628+
\madbox {
629+
SBEND | \=RBEND, \\
630+
\>..., K0=real, K0S=real, K1=real, K1S=real, \\
631+
\>K2=real, K2S=real, K3=real, K3S=real, ...;
632+
}
633+
634+
The philosophy of the implementation of these components is the same as described
635+
in \ref{sec:add-option-PTC}, i.e. the multipole components (divided by the element length)
636+
are added to the strengths listed above.
637+
638+
639+
\subsection{Parameters for the \texttt{CAVITY} elements}
640+
641+
The following parameter is available for the following elements:
642+
\madbox{
643+
RFCAVITY | \=RFMULTIPOLE | CRABCAVITY, \\
644+
\> ..., no\_cavity\_totalpath=logical, ... ;
645+
}
646+
647+
\begin{madlist}
648+
\ttitem{no\_cavity\_totalpath} (default=\texttt{false}) \\
649+
If \texttt{true}, the total path length of the cavity is not taken into account.
650+
See \texttt{TOTALPATH} in \ref{sec:ptc-setswitch} for more details. This parameter
651+
has a higher priority than \texttt{TOTALPATH} in \ref{sec:ptc-setswitch} and therefore
652+
can override this value per element.
653+
\end{madlist}
654+
655+
Note that the \texttt{PNL} and \texttt{PSL} parameters, used in \madx, are not
656+
considered in \ptc.
657+
658+
Furthermore, the implementation of the \texttt{CRABCAVITY} element means that
659+
the following are equivalent:
660+
\madbox{
661+
CRABCAVITY \=, L=LENGTH, VOLT=V, LAG=lag, \\
662+
\> FREQ=freq, ...,; \\
663+
RFMULTIPOLE\>, L=LENGTH, VOLT=0, LAG=(lag-0.25), \\
664+
\> FREQ=freq, ..., KNL=\{V/1000 * LENGTH\};
665+
}
666+
667+
Essentially, the voltage is set to zero and converted to a dipole compenet, and
668+
the lag is reduced.
669+
670+
\subsection{Additional Parameter for \texttt{DRIFT} Element}
671+
\madbox{
672+
DRIFT, L=real, ... , TILT=real;
673+
}
674+
\begin{madlist}
675+
\ttitem{TILT} The DRIFT can also be tilted.
676+
\end{madlist}
677+
678+
\subsection{Additional Parameter for \texttt{MULTIPOLE} Element}
679+
\madbox{
680+
MULTIPOLE, LRAD=real, KSI=real, ... ;
681+
}
682+
683+
\begin{madlist}
684+
\ttitem{LRAD} A fictitious length (default: 0 m), originally only used to
685+
compute synchrotron radiation effect.
686+
\ttitem{KSI} The \texttt{KSI} (default: 0 rad)parameter is used to specify the
687+
integrated solenoid component. If \texttt{KSI} is specified, but \texttt{LRAD}
688+
is not, or 0, then this attribute is ignored and a warning is emmited.
689+
\end{madlist}
690+
691+
\section{The \texttt{RBEND} element in \ptc}
692+
693+
For the \texttt{RBEND} element, the \ptc environment provides
694+
three types of this element:
695+
\madbox{
696+
RBEND, L=real, ... , TRUE\_RBEND=logical, E1=real, E2=real, ...;
697+
}
698+
699+
The attributes \texttt{TRUE\_RBEND}, \texttt{E1} and \texttt{E2} are used to
700+
decide which \texttt{RBEND} is used in \ptc.
701+
The default is \texttt{TRUE\_RBEND=FALSE}.
702+
703+
\begin{madlist}
704+
\ttitem{CURVED RBEND} (\texttt{TRUE\_RBEND=FALSE}) \\
705+
This is the normal rbend that is used in \madx, which is equivalent
706+
to an \texttt{SBEND} with an \texttt{E1} and \texttt{E2} set to \texttt{ANGLE}/2. \\
707+
Note: This means that additional multipole components are integrated in curved space,
708+
therefore also requires more computation and \texttt{SECTOR\_NMUL\_MAX} must be considered.
709+
710+
\ttitem{STRAIGHT RBEND} (\texttt{TRUE\_RBEND=TRUE}) \\
711+
This is equivalent to the \texttt{LIKEMAD=TRUE} case
712+
in \cite{forest2002}~Subsection~K.4.12 Figure~19. \\
713+
Note: This means that additional multipole components are integrated in straight space.
714+
715+
\ttitem{TRUE PARALLEL RBEND} (\texttt{TRUE\_RBEND=TRUE \& (E1 > 2*PI | E2 > 2*PI)}) \\
716+
This is equivalent to the \texttt{LIKEMAD=FALSE} case in \cite{forest2002}~Subsection~K.4.12 Figure~19. \\
717+
This \texttt{RBEND} element performs a translation, to ensure the orbit is restored,
718+
at the entry (if \texttt{E1 > 2*PI}) or exit (if \texttt{E2 > 2*PI}) of the element.
719+
If both \texttt{E1} and \texttt{E2} are greater than \texttt{2*PI}, then an
720+
error is thrown. \\
721+
The sum of \texttt{E1} and \texttt{E2} will be the total bend angle
722+
and therefore if \texttt{E(1|2)} is greater than \texttt{2*PI},
723+
then, \texttt{E(2|1)} dictates the rotation on entry and exit of the element.
724+
This magnet is equivalent to the \texttt{RBEND\_STRAIGHT} if \texttt{E(1|2) > 2*PI}
725+
and \texttt{E(2|1) = ANGLE/2}.
726+
727+
728+
\end{madlist}
729+
730+
It is important to note that each of these different rbends will have different
731+
lengths, since the \texttt{L} parameter is the path length (\texttt{LD}).
732+
Therefore, the weighting of your multipole components will be different
733+
for each of these elements, which uses the true element length. We calculate
734+
the true element length as follows, where the input length of the user is
735+
\texttt{L$_D$}, the input \texttt{ANGLE} is $\theta$ and the $\alpha$ is the value
736+
of \texttt{E(1|2)} when \texttt{E(2|1) > 2*PI}.
737+
738+
\begin{madlist}
739+
\ttitem{CURVED RBEND} $L = L_D$
740+
\ttitem{STRAIGHT RBEND} $L =\frac{L_D\sin \theta/2}{\theta/2}$
741+
\ttitem{TRUE PARALLEL RBEND} $L = \frac{L_D\sin \theta/2}{\theta/2} \cos{(\theta/2-\alpha)} $
513742
\end{madlist}
514743

515744
%\href{mailto:[email protected]}{ V.Kapin}(ITEP) and

libs/ptc/src/Sa_extend_poly.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ SUBROUTINE PRTP(S, X)
108108
T = X(6) ; call daprint(T)
109109
call kill(T)
110110
endif
111+
call flush(6)
111112
END SUBROUTINE PRTP
112113

113114
SUBROUTINE ANALYSE_APERTURE_FLAG(I,R)

0 commit comments

Comments
 (0)