MAD-X Primer (2): TWISSパラメータ計算, Whileによるビームラインの記載

目的

  • MAD-X Primer Appendix 1.2 (Example 2)

  • TWISSパラメータ の計算

  • While文 を利用した繰り返しの記載


命令

  • survey : ビームラインコンポーネントの基本情報の出力

  • twiss : TWISSパラメータの計算

  • while : 繰り返し処理


コード (sps.madx): TWISS命令を利用したパラメータの計算

TITLE, s="MAD-X test";
option,-echo;

// Read input file with machine description
call, file="sps.seq";

// Define the beam for the machine
Beam, particle = proton, sequence=cassps, energy = 450.0;

// Use the sequence with the name: cassps
use, period=cassps;

// beam line components 
survey,file=out/survey.tfs;

// Define the type and amount of output for the action TWISS
select,flag=twiss,column=name,s,x,y,mux,betx,muy,bety,dx,dy;

// Execute the Twiss command to calculate the Twiss parameters
// Compute at the centres of the elements and write to: twiss.out
twiss,centre,file=out/twiss.tfs;

// Plot the horizontal and vertical beta function between the
// 10th and 16th occurence of a defocussing quadrupole
plot, haxis=s, vaxis=x, betx, bety,colour=100, range=qd[10]/qd[16];
plot, haxis=s, vaxis=dx, colour=100, range=qd[10]/qd[36];
stop;

コード (sps.seq):while文を利用した繰り返しの記載

// define the total length
circum = 6912.0;

// define number of cells and therefore cell length
ncell  = 108;
lcell  = circum/ncell;

// define lengths of elements and half lengths
lquad  = 3.085;
lquad2 = lquad/2.;
lsex   = 1.0;

// forces and other constants;
// element definitions;

// define bending magnet as multipole
mbsps : multipole, lrad=dummy, knl={2.0*pi/(8*ncell)};

// define quadrupole and their strengths
qsps  : quadrupole, l=lquad;
qf    : qsps, k1:=kqf;
qd    : qsps, k1:=kqd;
kqf =  1.4631475E-02;
kqd = -1.4643443E-02;

// define sextupoles for chromaticity correction
lsf   : sextupole, l=lsex, k2:=ksf;
lsd   : sextupole, l=lsex, k2:=ksd;
ksf = 2.0284442E-02;
ksd = -3.8394267E-02;

// define orbit correctors and beam position monitors
bpm : monitor, l=0.1;
ch  : hkicker, l=0.1;
cv  : vkicker, l=0.1;

// sequence declaration;
cassps: sequence, refer=centre, l:=circum;
  start_machine: marker, at = 0;
  
  // This defines ONE cell, repeat NCELL times
  // to get the full machine
  // SPS has 8 bending magnets per cell
  n = 1;
  while (n < ncell+1) {
        qf    : qf    , at=(n-1)*lcell+lquad2;
        lsf   : lsf   , at=(n-1)*lcell+lquad2+2.5;
        ch    :  ch   , at=(n-1)*lcell+lquad2+3.1;
        bpm   : bpm   , at=(n-1)*lcell+lquad2+3.2;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+3.50;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+9.90;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+22.10;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+28.50;
        qd    : qd    , at=(n-1)*lcell+lquad2+32.00;
        lsd   : lsd   , at=(n-1)*lcell+lquad2+34.50;
        cv    :  cv   , at=(n-1)*lcell+lquad2+35.10;
        bpm   : bpm   , at=(n-1)*lcell+lquad2+35.20;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+35.50;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+41.90;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+54.10;
        mbsps : mbsps , at=(n-1)*lcell+lquad2+60.50;
        n = n + 1;
    }
  end_machine: marker at=circum;
endsequence;