Formally a beam line is defined by a LINE command:
label(arg{,arg}): LINE=(member{,member});Label gives a name to the beam line for later reference.
The formal argument list (arg{,arg}) is optional (see below). Each "member" may be one of the following:
label: LINE=(member{,member});Example:
l: line=(a,b,c,d,a,d); use,period=l;The USE command tells MAD to perform all subsequent calculations on the sequence
a,b,c,d,a,d
Example:
l: line=(a,b,s,b,a,s,a,b); s: line=(c,d,e); use,period=l;this example produces the following expansion steps:
1. replace sub-line s:
(a,b,(c,d,e),b,a,(c,d,e),a,b)
2. omit parentheses:
a,b,c,d,e,b,a,c,d,e,a,b
Example:
r: line=(g,h); s: line=(c,r,d); t: line=(2*s,2*(e,f),-s,-(a,b)); use,period=t; Attention: the repetition "2*s" will only work if "s" is itself a line. In case "s" is an element replace by "2*(s)".Proceeding step by step, this example produces
1. Replace sub-line S:
((c,r,d),(c,r,d),(e,f),(e,f),(d,-r,c),(b,a))
2. replace sub-line r:
((c,(g,h),d),(c,(g,h),d),(e,f),(e,f),(d,(h,g),c),(b,a))
3. omit parentheses:
c,g,h,d,c,g,h,d,e,f,e,f,d,h,g,c,b,aNote that the inner sub-line R is reflected together with the outer sub-line S.
Example:
s: line=(a,b,c); l(x,y): line=(d,x,e,3*y); l4f: line=(4*f); lm2s: line=(-2*s); res: line=l(l4f,lm2s);Proceeding step by step, this example generates the expansion
d,f,f,f,f,e,c,b,a,c,b,a,c,b,a,c,b,a,c,b,a,c,b,aSecond example:
cel(sf,sd): line=(qf,d,sf,d,b,d,qd,d,sd,d,b,d); arc: line=(cel(sf1,sd1),cel(sf2,sd2),cel(sf1,sd1)); use,period=arc;This example generates the expansion
1. Replace the line CEL and its formal arguments:
((qf,d,(sf1),d,b,d,qd,d,(sd1),d,b,d) (qf,d,(sf2),d,b,d,qd,d,(sd2),d,b,d) (qf,d,(sf1),d,b,d,qd,d,(sd1),d,b,d))
2. Omit parentheses:
qf,d,sf1,d,b,d,qd,d,sd1,d,b,d qf,d,sf2,d,b,d,qd,d,sd2,d,b,d qf,d,sf1,d,b,d,qd,d,sd1,d,b,d
!---------------------------------------------------------------------- beam, PARTICLE=electron, energy=1; qf: QUADRUPOLE, L:=1,K1:=1; qd: QUADRUPOLE, L:=1,K1:=-1; d: DRIFT, l=1; m: MARKER; rpl(a,b): LINE=(a,b); sl: LINE=(qf,d,qd); test0: LINE=(rpl(sl,sl)); !OK test1: LINE=(rpl((sl),(sl))); !OK test2: LINE=(rpl((sl),(-sl))); !OK test3: LINE=(sl,-sl); !OK test4: LINE=(rpl((3*sl),(3*sl))); ! WRONG test5: LINE=(3*sl,3*sl); !OK test6: LINE=(rpl((3*sl),(-3*sl))); ! WRONG test7: LINE=(3*sl,-3*sl); !OK use, period=test0; twiss,BETX=1,bety=1; use, period=test1; twiss,BETX=1,bety=1; use, period=test2; twiss,BETX=1,bety=1; use, period=test3; twiss,BETX=1,bety=1; use, period=test4; twiss,BETX=1,bety=1; use, period=test5; twiss,BETX=1,bety=1; use, period=test6; twiss,BETX=1,bety=1; use, period=test7; twiss,BETX=1,bety=1; !----------------------------------------------------------------------hansg, June 17, 2002