EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH

Beam Line Sequences

MAD-X accepts two forms of an accelerator definition: sequences and lines. However, the sequence definition is the only one used internally; lines are converted into sequences when they are USEd. Consequently, only sequences can be saved (written onto a file) by MAD-X.

The corresponding sequence of statements defining a sequence is

name: SEQUENCE, L=real, REFER=keyword, REFPOS=name, 
      ADD_PASS=integer, NEXT_SEQU='seq_name';
  ...
  label: class, AT=real, FROM=name {,attributes};
  class, AT=real, FROM=name;  
  sequ_name, AT=real, FROM=name;
  ...
ENDSEQUENCE;
where "real" means a real number, variable, or expression.

The first line declares a sequence with the given name and provides key parameters:


Inside the SEQUENCE ... ENDSEQUENCE bracketing keywords, three types of commands may appear:

The additional arguments that can be given in the declaration of sequence elements or sub-sequences are:



When the sequence is expanded in a
USE command, MAD-X generates the missing drift spaces according to the following rules:

Note that a bug in the expansion of sub-sequences within a sequence was reported in July 2013 and fixed from version 5.01.03 onwards. Details are explained here.

For efficiency reasons MAD-X imposes an important restriction on element lengths and positions: once a sequence is expanded, the element positions and lengths are considered as fixed; in order to vary a position or element length, a re-expansion of the sequence becomes necessary. The MATCH command contains a special flag "vlength" to match element lengths.

Example:

! define a default beam (otherwise fatal error)
beam;
! Define element classes for a simple cell:
b:     sbend,l=35.09, angle = 0.011306116;
qf:    quadrupole,l=1.6,k1=-0.02268553;
qd:    quadrupole,l=1.6,k1=0.022683642;
sf:    sextupole,l=0.4,k2=-0.13129;
sd:    sextupole,l=0.76,k2=0.26328;
! define the cell as a sequence:
sequ:  sequence,l=79;
   b1:    b,      at=19.115;
   sf1:   sf,     at=37.42;
   qf1:   qf,     at=38.70;
   b2:    b,      at=58.255,angle=b1->angle;
   sd1:   sd,     at=76.74;
   qd1:   qd,     at=78.20;
   endm:  marker, at=79.0;
endsequence;


Example of very small drift space being ignored during sequence expansion:
QTEST: QUADRUPOLE, L=1.000001;
 
TEST: SEQUENCE, REFER=centre, L=2.;
  QTEST, AT=1.5;	 
ENDSEQUENCE;	 

USE, SEQUENCE=TEST;
SURVEY, FILE='test';
The above sequence will expand to a total length of 2.0000005 m, half a micron longer than the claimed length of 2 m, but will not fail.

hansg, June 17, 2002

Last updated: Ghislain Roy, 18 March 2014