Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several PTC improvements #548

Merged
merged 6 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/latexuguide/elements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,14 @@ \section{Thin Radio-Frequency Multipole}
Contrary to the regular multipole, where the dipole
component has an effect on the reference orbit, an RF-Multipole that
includes a dipole component does not bend the reference orbit.


In PTC there must be at least one cavity with non-zero voltage,
otherwise all RF elements, including RF multipoles, are disabled.
Concerning RF behaviour of cavities in PTC
please refer to \hyperref[sec:ptc-setswitch]{\texttt{PTC\_SETSWITCH}} command,
in particular to \texttt{TIME} and \texttt{TOTALPATH} switches.


\begin{madlist}
\ttitem{VOLT} The peak voltage of the RF accelerating mode (DEFAULT: 0 MV).
\ttitem{LAG} The phase lag [$2\pi$] (DEFAULT: 0)
Expand Down
6 changes: 4 additions & 2 deletions doc/latexuguide/ptc-general.tex
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ \section{PTC\_SETSWITCH}
It enables stochastic emission of photons in ray tracking,
it only affects \texttt{PTC\_TRACK} and \texttt{PTC\_TRACKLINE}.
The emission is calculated during map tracking therefore
\texttt{PTC\_TWISS} or \texttt{PTC\_NORMAL} needs to be invoked before
launching the tracking. Every tracked ray will receive the same stochastic kicks.
\texttt{PTC\_TWISS} or \texttt{PTC\_NORMAL}
needs to be invoked before launching the tracking
(also with \ttitem{RADIATION}, \ttitem{ENVELOPE} and \ttitem{STOCHASTIC} set to true).
Every tracked ray will receive the same stochastic kicks.

\ttitem{MODULATION} (Default: false)\\
Sets the modulation switch/internal state of PTC.
Expand Down
8 changes: 8 additions & 0 deletions libs/ptc/src/Sra_fitting.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3554,6 +3554,9 @@ SUBROUTINE FIND_ORBIT_LAYOUT_noda_object(FIX0,STATE,eps,TURNS,fibre1,node1) ! Fi


if((stat%totalpath==1).and.(.not.stat%nocavity)) then

if(global_verbose) print*,"Totpath and cavity: Looking for Frequency"

C=>RING%START
freq=0.0_dp
i=1
Expand All @@ -3572,8 +3575,10 @@ SUBROUTINE FIND_ORBIT_LAYOUT_noda_object(FIX0,STATE,eps,TURNS,fibre1,node1) ! Fi

if(freq_redefine) then
tot=RING%HARMONIC_NUMBER*twopi/FREQ
if(global_verbose) print*,"Totpath and cavity: f_redefine TOT=",TOT
else
tot=RING%HARMONIC_NUMBER*CLIGHT/FREQ
if(global_verbose) print*,"Totpath and cavity: TOT=",TOT
endif
endif

Expand All @@ -3593,6 +3598,9 @@ SUBROUTINE FIND_ORBIT_LAYOUT_noda_object(FIX0,STATE,eps,TURNS,fibre1,node1) ! Fi
! CALL TRACK(RING,X,LOC,STAT)
! trackflag=TRACK_flag(RING,X,LOC,STAT)
!! xs%x=x

if(global_verbose) print*,"ITEM=",ITEM," x=",x

call TRACK_probe_X(x,stat,fibre1=fibre1,node1=node1)

if(.not.check_stable) then
Expand Down
18 changes: 18 additions & 0 deletions src/mad_cmdpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,23 @@ command_par_string_user2(const char* parameter, const struct command* cmd, char*
return inf;
}

int
command_par_value_user2(const char* parameter, const struct command* cmd, double* val)
/* returns a command parameter value val
if found returns 1, else 0 */
{
struct command_parameter* cp;
int inf=command_par(parameter, cmd, &cp);
if (inf && cp && cp->type < 3) {
*val = cp->expr ? expression_value(cp->expr, 2) : cp->double_value;
}
else
{
*val = 0;
}
return inf;
}

int
command_par_string_or_calldef(const char* parameter, const struct command* cmd, char** str)
/* returns command parameter string if explicitly set, otherwise call_def. */
Expand Down Expand Up @@ -447,6 +464,7 @@ command_par_value2(const char* parameter, const struct command* cmd, double* val
return 0;
}


struct double_array*
command_par_array(const char* parameter, struct command* cmd)
/* returns an updated command parameter array if found, else NULL */
Expand Down
1 change: 1 addition & 0 deletions src/mad_cmdpar.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ double command_par_special(const char* parameter, const struct element*);
char* command_par_string(const char* parameter, const struct command*);
char* command_par_string_user(const char* parameter, const struct command*);
int command_par_string_user2(const char* parameter, const struct command*, char**);
int command_par_value_user2(const char* parameter, const struct command*, double* val);
int command_par_string_or_calldef(const char* par, const struct command*, char**);
double command_par_value(const char* parameter, const struct command*);
int command_par_value2(const char* parameter, const struct command*, double* val);
Expand Down
2 changes: 2 additions & 0 deletions src/mad_dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ const char *const_command_def =
"rmatrix = [l, false, true], "
"ring_parameters = [l, false, true], " /* forces ring parametersd (skowron on 140120)*/
"normal = [l, false, true], " /* runs normal form analysis (skowron on 150903)*/
"trackrdts = [l, false, true], " /* track RDTs (GnFu) (skowron on 180124)*/
"initial_matrix_table = [l, false, true], " /* reads table map_table cooked by ptc_normal */
"initial_matrix_manual = [l, false, true], "
"initial_map_manual = [l, false, true], "
Expand Down Expand Up @@ -710,6 +711,7 @@ const char *const_command_def =
" "
"ptc_setswitch: ptc_setswitch none 0 0 "
"debuglevel = [i,1], "/*sets the level of debugging printout 0 none, 4 everything */
"seed = [i, 123456789], "
"maxacceleration = [l, true, true], " /*switch saying to set cavities phases so the reference orbit is always on the crest, i.e. gains max energy*/
"exact_mis = [l, false, true], " /* switch to ensure exact misaligment treatment */
"totalpath = [l, false, true], " /* switch to use totalpath, modifies PTC states by adding totalpath0 flag */
Expand Down
2 changes: 2 additions & 0 deletions src/mad_extrn_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
#define double_to_table_row double_to_table_row_
#define string_to_table_row string_to_table_row_
#define double_to_table_curr double_to_table_curr_ // **
#define double_to_table_curr2 double_to_table_curr2_ // **
#define vector_to_table_curr vector_to_table_curr_
#define string_to_table_curr string_to_table_curr_
#define comment_to_table_curr comment_to_table_curr_
Expand Down Expand Up @@ -306,6 +307,7 @@ void w_ptc_refreshtables_(void);
void w_ptc_script_(F_INTEGER scriptname);
void w_ptc_setaccel_method_(F_INTEGER method);
void w_ptc_setdebuglevel_(F_INTEGER level);
void w_ptc_setseed_(F_INTEGER level);
void w_ptc_setstochastic_(F_INTEGER method);
void w_ptc_setfieldcomp_(F_INTEGER fibreidx);
void w_ptc_setexactmis_(F_INTEGER method);
Expand Down
2 changes: 1 addition & 1 deletion src/mad_gcst.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ const char* const ptc_twiss_summary_table_cols[] = {
"disp4min","disp4max",
"deltap",
"orbit_x","orbit_px","orbit_y",
"orbit_py","orbit_pt","orbit_-cT",
"orbit_py","orbit_pt","orbit_t",
"xcorms","ycorms","pxcorms","pycorms","tcorms","ptcorms",
"xcomax","ycomax","pxcomax","pycomax","tcomax","ptcomax",
"xcomin","ycomin","pxcomin","pycomin","tcomin","ptcomin",
Expand Down