EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH MAD-X Logo

PTC_TWISS Module
(Ripken Optics Parameters)

The PTC_TWISS module of MAD-X [a] is based on the PTC code. It is a supplementary to the TWISS module. The Twiss parameters are calculated in Ripken's style (invented by G. Ripken in 1970 [31] and most accessible in Ref. [b]). These parameters were available in MAD8 using the TWISS3 command. This module is a typical example of the advantages of using PTC and its Normal Form technique (and of course the object-oriented Fortran90 coding): once the rather modest programming has been performed the Twiss calculation will always be automatically correct for all machine conditions like closed orbit, coupling or after a new element has been introduced into the code. In a traditional coding like in MAD8 this depends on reprogramming and modifying the code at various places, which is inherently error-prone.

The PTC_TWISS tracks a special representation of the beam in three degrees of freedom. It works on the coupled lattice functions defined in Ref.[b], which are essentially the projections of the lattice functions for the eigen-modes on the three planes. The PTC_TWISS lists the projections of the ellipses of motion onto the three planes (x, px), (y, py), (t, pt) expressed them via the Ripken's parameters bk,j, ak,j, gk,j along with the phase advances   mj in selected positions, where index k=1...3 refers to the plane (x, y,...), and the index j=1...3 denotes the eigen-mode. The PTC_TWISS also calculates the dispersion values D1,...,D4. In the MAD-X commands and tables, these parameters are denoted as beta11,...,beta33, alfa11,...,alfa33, gama11,...,gama33, mu1,...,mu3, disp1,...,disp4, respectively. The ring parameters like gamma transition, compaction factor and phase slip factor are calculated when closed solution is requested, or otherwise if RING_PARAMETERS is set to true. They are available in the summary table and in the header of twiss table.

The Ripken parameterization can be transformed into the Edwards-Teng parameterization (used in twiss proper) using the formulae of Ref. [d]. The parameters are noted as betx, bety, alfx, alfy and the coupling matrix: R11, R12, R21 and R22. In absence of coupling it holds: betx=beta11, bety=beta22, alfx=alfa11 and alfy=alfa22.

PTC_TWISS can also compute the deltap/p-dependency of the Twiss parameters. The column names beta11p,...,beta33p, alfa11p...,alfa33p, gama11p,...,gama33p denote the derivatives of the optics parameters w.r.t. deltap/p. If one is interested in evaluating deltap/p-dependency of the Twiss parameters, one must ensure that the order (no) of the map is set to 2 at least. The derivatives of the dispersion w.r.t. deltap/p have column names: disp1p,...,disp4p. Second and third order derivatives have respective column names: disp1p2,...,disp4p2 for the second order, and disp1p3,...,disp4p3 for the third order.

Any component of the transfer map at any location can be accessed (e.g. in matching) using PTC_SELECT command. If MAPTABLE parameter is set than the complete transfer map at the end of the sequence is saved in table called map_table.

For clarification: in the 4-D case, there is the following correspondence between MAD-X and Ripken's notations: beta11®bxI, beta12®bxII, beta21®byI, beta22®byII, while in the uncoupled 4-D case beta11 is the same as the classical bx (betx) and beta22 is by (bety), while beta12 and beta21 are zero. When there is coupling all betaNN are non-zero and beta11, beta22 are distinctively different from bx , by, respectively.

PTC_TWISS also tracks the eigenvectors and prints them to Twiss table according to the SELECT command (flag=ptc_twiss). Either all 36 components or  particular components of the eigenvectors can be selected with eign or eignij, respectively  (j = number of eigenvector, i = number of coordinate {x, px, y, py, t,pt}).

For ring lattices, PTC_TWISS computes momentum compaction, transition energy, as well as other one-turn characteristics such as the tunes (Q1,Q2 and if icase=6 with cavity Qs) and chromaticities (for no>=2).


Synopsis
PTC_CREATE_UNIVERSE;
PTC_CREATE_LAYOUT, model=integer,method=integer, nst=integer, [exact];
...
SELECT, flag=ptc_twiss, clear;
SELECT, flag=ptc_twiss, column=name, s,
beta11,...,beta33,alfa11,..., alfa33,gama11,...,gama33,
beta11p,...,beta33p,alfa11p,...,alfa33p,gama11p,...,gama33p,
mu1,...,mu3,
disp1,...,disp4,
disp1p,...,disp4p,
disp1p2,...,disp4p2,
disp1p3,...,disp4p3,
[eign], eign11, ...,eign16,...,eign61,...,eign66;
...
PTC_TWISS;
...
PTC_END;
Commands
PTC_TWISS,
    icase=
integer,
deltap=double, closed_orbit, slice_magnets,
    range=
string, file[=string], table[=string],
    initial_matrix_table, initial_matrix_manual, initial_map_manual, ignore_map_orbit,
    beta0=
string, map_table[=logical],
    ring_parameters,
    betx=
double, alfx=double, mux=double,
    bety=
double, alfy=double, muy=double,
    dx=
double, dpx=double, dy=double, dpy=double,
   
x=double, px=double, y=double, py=double, t=double, pt=double,
    re11=double, re12=double, ... ,re16=double,
    ...
    re61=double, re62=double, ... ,re66=double;                      
 
Description
The PTC_TWISS command causes computation of the Twiss parameters in Ripken's style. It operates on the working beam line defined in the latest USE command. Several options can be specified, the most important being icase, deltap, closed_orbit, slice_magnets, no, and file, table. (see the table below). Other options should be specified for particular tasks. Applications for the PTC_TWISS command are similar to the TWISS-command. The PTC_TWISS can be applied to two basic tasks. It can calculate either a periodic solution or a solution with initial conditions.
Options
Option Meaning Default Value Value Type
ICASE the user-defined dimensionality of the phase-space (4, 5 or 6). Note that the value is internally set to 56 when attempting to set icase=6 with no cavity. 4 integer
NO the order of the map, which is often supplied as 1 but must be at least set to 2 to retrieve chromaticities for instance. For evaluating the Twiss parameters derivatives w.r.t. deltap/p, one must pass order 2 at least. 1 integer
DELTAP

relative momentum offset for reference closed orbit.

0.0 double
CLOSED_ORBIT the switch to turn on the closed orbit calculation (periodic solution ONLY). .FALSE. logical
DELTAP_DEPENDENCY the switch to turn on computation of the Twiss and dispersion derivatives w.r.t. deltap/p. Derivation formula assume that icase=5, so that deltap/p is supplied as a parameter. .FALSE. logical
SLICE_MAGNETS Turns on the evaluation of Twiss parameters at each integration step inside magnets, in addition to the end face. The number of slices is determined by the number of steps (nst) that can be separately defined for each element, or otherwise set by nst parameter when creating the PTC layout.
Note that the orbit rms calculated in this mode counts as valid data points both the end of the previous element and the entrance of the current element. Since the first integration node is always at the entrance of the magnet (after position offset and fringe effects are calculated), which corresponds to the same s position (and usually optical functions) as the end of the previous element, the points at the interface between magnets are included twice in the rms calculation.
.FALSE. logical
CENTER_MAGNETS the switch to turn on the evaluation of Twiss parameters at the middle of each magnet. This relies on internal slicing and 'integration nodes' as determined by the number of steps (nst) selected when creating the PTC layout. This number is assumed to be even otherwise the program issues a warning. .FALSE. logical
FILE omitted no output written to a file    
present the name of the file for printing the PTC_TWISS output. ptc_twiss string
TABLE omitted no output written to a internal table    
present the name of the internal PTC_TWISS table ptc_twiss string
SUMMARY_FILE omitted no output written to a file    
present the name of the file for printing the PTC_TWISS_SUMMARY table output. ptc_twiss_summary string
SUMMARY_TABLE omitted no output written to a internal table    
present the name of the internal PTC_TWISS_SUMMARY table ptc_twiss_summary string
RANGE specifies a segment of beam-line for
the PTC_TWISS calculation
#s/#e string
INITIAL_MATRIX_TABLE Reading the transfer map from table called map_table created by preceding PTC_TWISS or PTC_NORMAL command. The table can be also read before hand from files using READTABLE command. .FALSE. logical
INITIAL_MATRIX_MANUAL Using the input variables RE11,...,RE66 (see next entry) as the transfer matrix. .FALSE. logical
INITIAL_MAP_MANUAL Using the input map stored beforehand in file fort.18 (e.g. by some initial run of PTC_NORMAL). .FALSE. logical
IGNORE_MAP_ORBIT Ignore the orbit in the map and use instead closed orbit, if requested, or otherwise specified with x,px,y,p,t,dt parameters. .FALSE. logical
RE11,..., RE66 Values of the 6x6 transfer matrix. unit matrix double
BETA0 The name of the BETA0-block, which contains the Twiss parameters for the input. When icase=6, this information must be complemented by supplying a value for 'betz' on the ptc_twiss command line. beta0 string
MAP_TABLE If true, save the one-turn-map to table "map_table". This one-turn-map can then be used as starting condition for a subsequent ptc_twiss, see INITIAL_MATRIX_TABLE parameter of this command. .FALSE. logical
betx, alfx, mux, bety, alfy, muy, dx, dpx, dy, dpy   Twiss and dispersion parameters bx,y, ax,y, gx,y, Dx, Dpx, Dy, Dpy (Edwards and Teng). 0 double
RING_PARAMETERS Forces computation of ring parameters (gamma_tr, alpha_c, etc.). .FALSE. logical
x, px, y, py, t, pt The canonical coordinates of the initial orbit. 0 double
Remarks
ICASE:   It can be internally corrected by the code. For example, if RF cavity has the voltage set to zero and for icase=6, the code sets icase=4.
Periodic (closed) solution
PTC_TWISS,
    icase=
integer,
deltap=double, closed_orbit,
    range=
string, file[=string], table[=string];
Description
This is the simplest form of the PTC_TWISS command, which computes the periodic solution for a specified beam line. It may accept  all basic options described in the above table.
Evaluation of Twiss parameters inside magnets
PTC_TWISS,
    icase=
integer,
deltap=double, closed_orbit, slice_magnets
    range=
string, file[=string], table[=string];
Description
This computes the periodic solution for a specified beam line and evaluates the Twiss parameters at each thin-slice (a.k.a "integration-node") inside magnets. The number of such integration-nodes is given by the number of steps (nst) selected when creating the PTC layout. All other basic options described in the above table may be selected.
Example
An example is found in the PTC_TWISS Examples' repository.
Solution with Initial Conditions
Description
Initial conditions can be supplied in different ways. Naturally only one of the methods below can be used at a time, and they can not be mixed. In this mode it is assumed that the lattice is a line and no ring parameters are evaluated (their values are set to -1000000), unless parameter RING_PARAMETERS is set to true, which forces computation of closed solution for the resulting map; then if such solution does not exist, the routine shall report an error and exit.
Initial Values from the Given Twiss Parameters:
    PTC_TWISS,
        icase=
integer,
deltap=double,
        range=string, file[=
string],table[=string],
       
betx=double, alfx=double,mux=double,
        bety=
double, alfy=double,muy=double,
        dx=
double, dpx=double, dy=double, dpy=double,
   
    x=double, px=double, y=double,py=double,
        t
=double, pt=double;
Description
PTC_TWISS calculates a solution with initial conditions given by the Twiss parameters, which are explicitly typed  on the command line. Note, that this case is also limited to uncoupled motion of the preceding ring or beam-line.
Example
An example is found in the PTC_TWISS Examples in the folder "Example2".
Initial Values from a Map-Table
(obtainable by a preceding
PTC_NORMAL command):
    PTC_TWISS,
icase=
integer,
deltap=double,  
range=string, file[=
string], table[=string],
initial_matrix_table
;
 
Description
PTC_TWISS calculates a solution with initial conditions given as a map-table of preceding ring or beam-line. It requires the input option initial_matrix_table and an existence of the map-table in memory, which was generated by a preceding PTC_NORMAL command.
Example
An example is found in the PTC_TWISS Examples in the folder "Example3".
Initial Values from a Map-File
(obtainable by a preceding
PTC_NORMAL command):
    PTC_TWISS,
        icase=
integer,
deltap=double,  
        range=string, file[=
string], table[=string],
        initial_map_manual
;
 
Description
PTC_TWISS calculates a solution with initial conditions given as a map-file fort.18 obtained from a preceding ring or beam-line. It requires the input option initial_map_manual and an existence of the map-file named a fort.18 file, which was generated by a  preceding PTC_NORMAL command.
Example
An example is found in the PTC_TWISS Examples in the folder "Example3".
Initial Values from a Given Matrix:
    PTC_TWISS,
        icase=
integer,
deltap=double,
        range=string, file=
string, table=string,
        initial_matrix_manual,
        re11
=double, re12=double, ... ,re16=double,
        ................................................................
        re61=double, re62=double, ... ,re66=double;
Description
PTC_TWISS calculates a solution with initial conditions given by the matrix, which is "manually" entered on the command-line. It requires the option initial_matrix_manual. MAD-X expects a symplectic 6x6 transfer matrix as input. 
Example
An example is found in the PTC_TWISS Examples in the folder "Example4".
Initial Values from Twiss Parameters via BETA0-block:
    PTC_TWISS,
        icase=
integer,
deltap=double,
        range=string, file[=
string], table[=string],
        beta0=
string;
Description
PTC_TWISS calculates a solution with initial conditions given by Twiss parameters, which are transferred from  the BETA0-block.  The data in the the BETA0-block have to be filled by a combination of the SAVEBETA and TWISS commands of a preceding ring or beam-line. Note, that this case is limited to uncoupled motion of the preceding machine.
Example
An example is found in the PTC_TWISS Examples in the folder "Example1".
References for PTC_TWISS
  1. F. Schmidt, "`MAD-X PTC Integration'', Proc. of the 2005 PAC Conference in Knoxville, USA, pp.1272.
  2. G. Ripken and F. Willeke, "Methods of Beam Optics", DESY 88–114, 1988.
  3. K. Zhang, "PTC twiss with initial TWISS parameters", MAD-X Meeting 13 (04.07.2005)slides in ppt.
  4. V.A. Lebedev and S.A. Bogacsz, " Betatron motion with coupling of horizontal and vertical degrees of motion", Thomas Jefferson National Accelerator Facility 2010.
See Also
TWISS, PTC_TWISS Examples.

V. Kapin (ITEP) and F. Schmidt, March 2006
P. Skowronski and G. Roy, January 2014, November 2014