Index of /mad/madx.old/mad8tomadX

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[TXT]elettra.mad2005-04-29 17:58 12K 
[   ]incon892006-04-04 03:38 126K 
[   ]mad8.dict2005-04-29 17:58 50K 



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Checklist of MAD8 to MADX conversion !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


End of command/line and the "&" continuation symbol
***************************************************

MAD-X follows the C convention to use the symbol ";" for the end of a 
command. Several commands may be on one line. Except in case of a comment
(starting with the "!" symbol) a missing ";" means that the command is 
supposed to be continued on the following lines until a ";" symbol is 
found.

To convert MAD8 files one needs to add a ";" symbol after every command
and all continuation symbols "&" have to be taken out.

Command differences
*******************

Most MAD8 commands have the same syntax in MAD-X. Please check on the
MAD-X web page for small adjustments for a particular command. Essential
is that the "use" command has now the form:

use, period=Machine;

where "Maschine" is your sequence.

Preceding to this "use" command one is mandatory to execute the beam 
command.

Not all MAD8 commands have been transferred to MAD-X (MAD-X will 
complain during execution time). This was needed since some of the MAD8 
commands were thought to be unreliable or outdated. Most important cases 
are:

-Tracking: The MAD8 tracking with thick lattices was generally not
symplectic and has been dropped. Solution:

a) The sequence has to be made thin first with the "makethin" command 
and particles can then be tracked with the symplectic thin lens commands.

b) A symplectic thick lines tracking command is in preparation using 
PTC.

-Lie-Algebra Command: These commands are being replaced by PTC which 
uses differential algebra maps and NormalForm.

Sequences versus Lines
**********************

MAD-X is based on sequences. Lines are allowed but are transfered
internally into sequences. It has to be noted that Lines have created 
many problems. Although all known problems with Lines have been solved 
by now, it is highly recommended to operate with sequences only.

Element or command attributes
*****************************

In MAD8 an element attribute, say the k1 strength of a quadrupole QF 
could be addressed by using "QF[K1]". In MAD-X this is done via 
"QF->K1".

Assignments
***********

MAD8 users new to MAD-X have to get used to way assignments work in 
MAD-X.

Take the statement:

x = a;

"x" is set to the current value of "a" and not changed, even if "a" 
changes. This makes assignments such as

x = x + 1;

perfectly valid (this replaces the old SET instruction). The definition 
of the deferred expression is:

x := a;

and "x" changes whenever "a" does.

Note: It is good practice in the above example to define "a" first 
before "x" is used, in particular when dividing with "x" in expressions.
The code is complied such that those devisions will not crash during
execution. The execution might even work properly if "a" is defined 
eventually.

Constants
*********

Constants are defined differently in MAD8 and MAD-X.

Example:
l.bpm: constant = 0.3;   ! mad8
const l.bpm = 0.3;       ! madx


Negative Drift Lengths
**********************

Many MAD8 users work happily with overlapping elements. In MAD-X this 
is strictly forbidden and has to be fixed.

Conversion program incon89
**************************

The program "incon89" from Hans Grote does most of the conversion from
MAD8 to MAD-X (lxplus only), although a certain amount of fiddling will 
be required in some cases. A MAD8 input file "elettra.mad" and the MAD8
dictionary file "mad8.dict" are provided with this checklist. This 
conversion goes via (replace "elettra.mad" by your MAD8 file): 

incon89 -in elettra.mad -out el.madx -dict mad8.dict

Extra tricks
************

Using this conversion program one finds that some fiddling by hand will
be required. Here a few hints of what might be needed:

-The MAD8 continuation symbol "&" has to be removed.

-Beware of "loose" comments that are allowed in MAD8, MAD-X will interpret
these lines as real input and will crap as a result. Use "!" or the 
"/* ... */ construct in the MAD-X case.

-Replace "FILENAME" by "FILE".

-The MAD8 "INTER" option for interactive runs is not needed and therefore
not present in MAD-X.

-The element type "INST" is not available in MAD-X and has to be replaced 
by "MONITOR".

-The MAD8 half developed "SPLINE" plot attribute (not actually anything to do
with SPLINE!) has been replaced by a properly coded "INTERPOLATE" attribute
of the MAD-X plot module.

-The MAD8 "TILT" default was ambiguous. Therefore, in MAD-X one has to 
specify the proper tilt angle, E.g. "pi/2." for dipoles, "pi/4." degrees for
quadrupoles.

***********************************************************************
More issues concerning tilt
***************************

1) In MAD-X all multipoles come as normal knl or skew ksl.
                **********
What one has to do is:

1) T1=0; T2=0; T3=0 ==> knl and keep sign

2)
T1=-pi/4 ==> ksl(0,a)
T1=pi/4 ==> ksl(0,-a)
!!!!Notice that if you turn the magnet by twice the angle it
!!!!becomes a normal one but with opposite sign. Agreed a funny way to
!!!!change the sign but this is done often in this MAD8 file!!!!!
T1=pi/2 ==> knl(0,-a)  

3)
T2=-pi/6 ==> ksl(0,0,a)
T2=pi/6 ==> ksl(0,0,-a)
!!!!Notice that if you turn the magnet by twice the angle it
!!!!becomes a normal one but with opposite sign. Agreed a funny way to
!!!!change the sign but this is done often in some MAD8 file!!!!!
T2=pi/3 ==> knl(0,0,-a)  

4)
T3=-pi/8 ==> ksl(0,0,0,a)
T3=pi/8 ==> ksl(0,0,0,-a)
!!!!Notice that if you turn the magnet by twice the angle it
!!!!becomes a normal one but with opposite sign. Agreed a funny way to
!!!!change the sign but this is done often in some MAD8 file!!!!!
T3=pi/4 ==> knl(0,0,0,-a)  

5)
The trick is to start with initial conditions including including initial
coordinates:
MAD8:
TWISS, COUPLE, betx=1, bety=1, x=0.01,SAVE, TUNES, TAPE=twiss.txt
MAD-X:
TWISS, betx=1,bety=1,x=0.01,file=twiss_madx; !VK, file='twiss_madx.txt';

One can the look element by element where a nonlinear element goes wrong:
MAD8:
TWISS.TXT
MAD-X:
twiss_madx

6) None of this is automatically done by "incon89" but one has to do
it manually.

***********************************************************************

-People have been using "fake" attributes to pass for further use later,
E.g.:

  QBDS1  : QUAD, TYPE="QBDS1", L=L50CM/2, APER=L12MM/2
  QFACT1 := 1/(QBDS1[APER]*Brho)

this is not working in MAD-X. One has to replace it by something like:

  QBDS1:quadrupole, TYPE="QBDS1",L:=L50CM/2;
  QFACT1:=1/(L12MM/2*Brho);

-The MAD8 "SUBROUTINE" command has been replaced by the much more powerful
MAD-X "MACRO" command. Please consult the MAD-X manual for details.

-A very important difference to MAD8 is the fact that in lines the 
multiplication operator only works for lines but NOT for elements. 
Therefore, an element has to be surounded by brackets,  E.g. let 
SBD_FF & SBD_FF be elements, then:

replace:

 EFFd:LINE=(QF9,BPMQ079,QF9,D5B,2*SBD_FF,LX0,2*SBD_FF,LX0,
                    ...
by: 

 EFFd:LINE=(QF9,BPMQ079,QF9,D5B,2*(SBD_FF),LX0,2*(SBD_FF),LX0,