MAD input file

From New IAC Wiki
(Redirected from MAD-X input file)
Jump to navigation Jump to search

Beamline design (G. Stancari)


! HRRL positron beamline, version 3
TITLE,"HRRL POSITRON BEAMLINE (HPBv3 2009.05.27)";

! Positron beam
PC = 1.7e-3;
EMITX = 10E-6; EMITY = 10E-6; ! maximum, geometrical
DPP = 0.02; ! maximum
BRHO = (1E9/CLIGHT) * PC;
BEAM,PARTICLE=POSITRON,PC=PC,
  EX=EMITX,EY=EMITY,SIGE=DPP;

! Yellow quadrupoles
! Max gradient = 19 T/m
! Aperture = +- 1 in
YQF: QUADRUPOLE, L=0.10;
YQD: QUADRUPOLE, L=0.10;
KQ1:=+0.181;
KQ2:=-0.170;
KQ3:=+0.011;

KQ4:=+0.173;
KQ5:=-0.246;
KQ6:=+0.249;

KQ7:=-0.078;
KQ8:=-0.044;
KQ9:=+0.118;

VALUE,KQ1,KQ2,KQ3,KQ4,KQ5,KQ6,KQ7,KQ8,KQ9;

! Kiwi dipoles
RHO = 0.290185;
TH = 45.*PI/180;
L = RHO*TH;
VALUE,L;
KD: SBEND, L=L, ANGLE=TH;

! POSITRON BEAMLINE
!
! Positron target - first bend = L1 = 0.887 m
! First bend =                 = L  = 0.228
! Between bends =              = L2 = 1.295
! Second bend =                = L  = 0.228
! Second bend - wall =         = L3 = 2.034
! Wall thickness =             = L4 = 0.914
!                                    ---------
! Total beamline length =      = LT = 5.586 m
L1 = 0.887; L2 = 1.295; L3 = 2.034; L4 = 0.914;
LT = L1+L+L2+L+L3+L4;
VALUE, LT;
! Initial conditions
AX0=0; BX0=1.6; AY0=0; BY0=1.6;
PBL: SEQUENCE,REFER=ENTRY,L=LT;
! Positron production target
PTRGT: MONITOR,L=0., AT=0.;
! First triplet
Q1: YQF,K1:=KQ1/BRHO,AT=0.2;
Q2: YQD,K1:=KQ2/BRHO,AT=0.4;
Q3: YQF,K1:=KQ3/BRHO,AT=0.6;
! First bend
D1: KD,AT=L1+L/2;
! Second triplet
Q4: YQF,K1:=KQ4/BRHO,AT=0.3+L+L1;
Q5: YQD,K1:=KQ5/BRHO,AT=0.5+L+L1;
Q6: YQF,K1:=KQ6/BRHO,AT=0.7+L+L1;
! Steerer 2
! S2: MONITOR,L=0.05,AT=0.250+0.798+L+L1;
! Second bend
D2: KD,AT=L1+L+L2+L/2;
! BPM 2
! BPM2: MONITOR,L=0.10,AT=0.362+L+L2+L+L1;
! Third triplet
Q7: YQF,K1:=KQ7/BRHO,AT=0.623+L+L2+L+L1;
Q8: YQD,K1:=KQ8/BRHO,AT=0.823+L+L2+L+L1;
Q9: YQF,K1:=KQ9/BRHO,AT=1.023+L+L2+L+L1;
! Steerer 3
! S3: MONITOR,L=0.05,AT=0.227+1.023+L+L2+L+L1;
! Secondary target
STRGT: MONITOR,L=0., AT=0.871+1.023+L+L2+L+L1;
! Wall1
WALL1: MONITOR,L=0.,AT=L3+L+L2+L+L1;
! Wall2
WALL2: MONITOR,L=0.,AT=L4+L3+L+L2+L+L1;
ENDSEQUENCE;

! Activate beamline
USE,SEQUENCE=PBL;

! Calculate Twiss parameters
SELECT,FLAG=TWISS,COLUMN=NAME,S,BETX,BETY,DX;
TWISS,ALFX=AX0,BETX=BX0,ALFY=AY0,BETY=BY0,FILE="twiss.out";

! Define beam profiles (maximum) in mm
! design momentum
MVAR1 := 1E3*SQRT(TABLE(TWISS,BETX)*EMITX);
MVAR2 := 1E3*SQRT(TABLE(TWISS,BETY)*EMITY);
! off-momentum
MVAR3 := 1E3*SQRT(TABLE(TWISS,BETX)*EMITX + (TABLE(TWISS,DX)*DPP)^2);
MVAR4 := 1E3*SQRT(TABLE(TWISS,BETY)*EMITY + (TABLE(TWISS,DY)*DPP)^2);

! Calculate Twiss parameters
SELECT,FLAG=TWISS,COLUMN=NAME,S,BETX,BETY,DX,MVAR1,MVAR2,MVAR3,MVAR4,MUX,MUY;
TWISS,ALFX=AX0,BETX=BX0,ALFY=AY0,BETY=BY0,FILE="twiss.out";

! Optimize
IF (0<1) {
MATCH,SEQUENCE=PBL,BETX=BX0,ALFX=AX0,BETY=BY0,ALFY=AX0,DX=0,DPX=0,DY=0,DPY=0;
CONSTRAINT,SEQUENCE=PBL,RANGE=#S/#E,MVAR3<10;
CONSTRAINT,SEQUENCE=PBL,RANGE=#S/#E,MVAR4<10;
CONSTRAINT,SEQUENCE=PBL,RANGE=STRGT,ALFX=0;
CONSTRAINT,SEQUENCE=PBL,RANGE=STRGT,ALFY=0;
CONSTRAINT,SEQUENCE=PBL,RANGE=STRGT,BETX=1.6;
CONSTRAINT,SEQUENCE=PBL,RANGE=STRGT,BETY=1.6;
CONSTRAINT,SEQUENCE=PBL,RANGE=Q9,DX=0;
CONSTRAINT,SEQUENCE=PBL,RANGE=Q9,DPX=0;
VARY, NAME=KQ1, STEP=1E-6;
VARY, NAME=KQ2, STEP=1E-6;
VARY, NAME=KQ3, STEP=1E-6;
VARY, NAME=KQ4, STEP=1E-6;
VARY, NAME=KQ5, STEP=1E-6;
VARY, NAME=KQ6, STEP=1E-6;
VARY, NAME=KQ7, STEP=1E-6;
VARY, NAME=KQ8, STEP=1E-6;
VARY, NAME=KQ9, STEP=1E-6;
LMDIF,CALLS=1E4,TOLERANCE=1E-8;
!MIGRAD,CALLS=1E4;
ENDMATCH;
}

VALUE, KQ1,KQ2,KQ3,KQ4,KQ5,KQ6,KQ7,KQ8,KQ9;

! Plot
RESPLOT;
SETPLOT,POST=2,YSIZE=16;
!  ASCALE=0.8,LSCALE=0.8,SSCALE=0.8,RSCALE=0.8;
SETPLOT,XSIZE=55;
PLOT, HAXIS=S, VAXIS1=BETX,BETY, VAXIS4=DX,
  STYLE=100, COLOUR=1, INTERPOLATE=TRUE, NOVERSION=TRUE;
SETPLOT,XSIZE=40;
PLOT, HAXIS=S, VAXIS1=MUX,MUY,
  STYLE=100, COLOUR=1, INTERPOLATE=TRUE, NOVERSION=TRUE;
PLOT, HAXIS=S, VAXIS1=MVAR1,MVAR2,MVAR3,
  STYLE=100, COLOUR=1, INTERPOLATE=TRUE, NOVERSION=TRUE;