EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH

Twiss Module

The TWISS command causes computation of the [Courant and Snyder] linear lattice functions, and optionally of the chromatic functions.
The coupled functions are calculated in the sense of [Edwards and Teng]. For the uncoupled cases they reduce to the C and S functions.
TWISS, SEQUENCE=seq_name, LINE=line_name, RANGE=range, 
       DELTAP=real{,real}||initial:final:step,
       CHROM=logical,
       CENTRE=logical, TOLERANCE=real,
       FILE=filename,
       TABLE=table_name, NOTABLE=logical,
       RMATRIX=logical, 
       SECTORMAP=logical, SECTORTABLE=tablename, SECTORFILE=filename,
       KEEPORBIT=name, USEORBIT=name,
       COUPLE=logical,
       RIPKEN=logical;
The attributes of the TWISS command are: Coupled Functions
TWISS in MAD-X is always calculated in coupled mode. MAD-X computes the coupled functions in the sense of [Edwards and Teng]. For the uncoupled cases they reduce to the C and S functions. The COUPLE option of MAD8 is therefore obsolete.
Please note that the chrom option is needed for a proper calculation of the chromaticities in the presence of coupling!

Twiss calculation is 4D only!
The Twiss command calculates an approximate 6D closed orbit when the accelerator structure includes an active cavity. However, the calculation of the Twiss parameters are 4D only. This may result in apparently non-closure of the beta values in the plane with non-zero dispersion. The full 6D Twiss parameters can be calculated with the ptc_twiss command.

Tables
The tables produced by TWISS are suitable for plot.
After a successful TWISS run MAD-X creates an implicit table of summary parameters named "summ" which includes tunes, chromaticities etc. versus the selected values of DELTAP.
The summary parameters can be accessed via the table access function using the aforementionned implicit table named "summ". There is no way to change the name of the summary table.

Momentum derivatives
MAD-X uses PT as longitudinal variable, instead of the common DELTAP used in the litterature. Dispersive and chromatic functions are hence derivatives with respect to PT( see table).

Twiss Parameters for a Period

The simplest form of the TWISS command is
TWISS;
which calculates the periodic solution for the last USE'd beamline or sequence, with DELTAP = 0. Chromatic functions are not calculated. Standard tables (TWISS and SUMM) are created in memory but no file is written to disk.

The slighltly more elaborate version

TWISS, DELTAP=real{,real}, CHROM, TABLE=table_name;
computes the periodic solution, including chromatic functions, for the last USE'd beam line or sequence, for all values of DELTAP entered (or for DELTAP = 0, if none is entered). The tables "table_name" and SUMM are created in memory and no file is written to disk.

Initial Values from a Periodic Line

It is possible to track the lattice functions starting with the periodic solution for another beam line. If this is desired the TWISS command takes the form
TWISS, DELTAP=real{,value}, LINE=beam-line,
       MUX=real, MUY=real,
       TABLE=table_name;
No other attributes should appear in the command. For each value of DELTAP MAD-X first searches for the periodic solution for the beam line mentioned in LINE=beam-line: The result is used as an initial condition for the lattice function tracking.

Example:

CELL:   LINE=(...);
INSERT: LINE=(...);
USE, period=INSERT;
TWISS, LINE=CELL, DELTAP=0.0:0.003:0.001, CHROM, FILE;
For four values of DELTAP the following happens: First MAD-X finds the periodic solution for the beam line CELL: Then it uses this solution as initial conditions for tracking the lattice functions of the beam line CELL: Output is also written on the file TWISS:

If any of the beam lines was defined with formal arguments, actual arguments must be provided:

CELL(SF,SD): LINE=(...);
INSERT(X):   LINE=(...);
USE, period=INSERT;
TWISS, LINE=CELL(SF1,SD1);

Given Initial Values

Initial values for linear lattice functions and chromatic functions may also be numerical. Initial values can be specified on the TWISS command:

TWISS,   BETX=real,ALFX=real,MUX=real,
         BETY=real,ALFY=real,MUY=real,
         DX=real,DPX=real,DY=real,DPY=real,
         X=real,PX=real,Y=real,PY=real,
         T=real,PT=real,
         WX=real,PHIX=real,DMUX=real,
         WY=real,PHIY=real,DMUY=real,
         DDX=real,DDY=real,DDPX=real,DDPY=real,
         R11=real,R12=real,R21=real,R22=real,  !coupling matrix
         TABLE=table_name,
         TOLERANCE=real,
         DELTAP=real:real:real;
All initial values for linear lattice functions and chromatic functions are permitted, but BETX and BETY are required. Moreover, a beta0 block can be added as filled by the savebeta command or see below. The lattice parameters are taken from this block, but will be overwritten by explicitly stated lattice parameters. As entered, the initial conditions cannot depend on DELTAP, and can thus be correct only for one such value.

SAVEBETA: Save Lattice Parameters

Initial lattice parameters can be transfered for later commands, in particular for twiss or the match module, by using the savebeta command sequence.

Parameters in tables can also be accessed using the table access function.

USE,period=...;
SAVEBETA, LABEL=name, PLACE=place, SEQUENCE=s_name;
TWISS,...;
When reaching the place in the sequence "s_name" during execution of TWISS, MAD-X will save a beta0 block with the label name: This block is filled with the values of all lattice parameters in place.

Example 1:

USE, period=CELL;
SAVEBETA, LABEL=END, PLACE=#E, SEQUENCE=CELL;
TWISS;
USE, period=INSERT;
TWISS, BETA0=END;
This first example calculates the periodic solution of the line CELL, and then tracks lattice parameters through INSERT, using all end conditions (including orbit) in CELL to start.

Example 2:

USE,period=CELL;
SAVEBETA, LABEL=END, PLACE=#E, SEQUENCE=CELL;
TWISS;
USE, period=INSERT;
TWISS, BETX=END->BETY, BETY=END->BETX;
This is similar to the first example, but the beta functions are interchanged (overwritten).

BETA0: Set Initial Lattice Parameters

Initial lattice parameters can be set 'manually' for later commands, in particular for twiss or the match module, by using the BETA0 command attached to a label.

Example 3:

INITIAL: BETA0, BETX=BX0, ALFX=0.0, MUX=0.0, BETY=BY0, ALFY=0.0, DX=DX0, DPX=0.0;
TWISS, BETA0=INITIAL;

Example 4:

INITIAL: BETA0, BETX=BX0, ALFX=0.0, MUX=0.0, BETY=BY0,A LFY=0.0, DX=DX0, DPX=0.0;
TWISS, BETX=INITIAL->BETY, BETY=INITIAL->BETX;

frs, 06-Apr-2003. Revised in February 2007.
Revised by Ghislain Roy, 1 July 2014.