source: PSPA/madxPSPA/tests/test-dynap/test-dynap.madx @ 430

Last change on this file since 430 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 9.8 KB
Line 
1Option, -echo,-info,-warn;
2
3!call, file = "../share/LHC/LHCRing/V6.503/V6.5.thin.seq";
4call, file = "../share/LHC/LHCRing/V6.503/V6.5.seq";
5call, file = "../share/LHC/LHCRing/V6.503/toolkit/slice.madx";
6
7Option, info,warn;
8
9!+++++++++++++++++++++++++ Step 1 +++++++++++++++++++++++
10!       define beam constants
11!++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
13b_t_dist = 25.e-9;                  !--- bunch distance in [sec]
14b_h_dist = clight * b_t_dist / 2 ;  !--- bunch half-distance in [m]
15ip1_range = 58.;                     ! range for parasitic collisions
16ip5_range = ip1_range;
17ip2_range = 60.;
18ip8_range = ip2_range;
19
20npara_1 = ip1_range / b_h_dist;     ! # parasitic either side
21npara_2 = ip2_range / b_h_dist;
22npara_5 = ip5_range / b_h_dist;
23npara_8 = ip8_range / b_h_dist;
24
25value,npara_1,npara_2,npara_5,npara_8;
26
27eg   = 7000;
28bg   = eg/pmass;
29en   = 3.75e-06;
30epsx = en/bg;
31epsy = en/bg;
32
33Beam, particle = proton, sequence=lhcb1, energy = eg,
34          sigt=      0.077     ,
35          bv = +1, NPART=1.1E11, sige=      1.1e-4,
36          ex=epsx,   ey=epsy;
37
38Beam, particle = proton, sequence=lhcb2, energy = eg,
39          sigt=      0.077     ,
40          bv = -1, NPART=1.1E11, sige=      1.1e-4,
41          ex=epsx,   ey=epsy;
42
43beamx = beam%lhcb1->ex;   beamy%lhcb1 = beam->ey;
44sigz  = beam%lhcb1->sigt; sige = beam%lhcb1->sige;
45
46!--- split5, 4d
47long_a = 0.53 * sigz/2;
48long_b = 1.40 * sigz/2;
49value,long_a,long_b;
50
51ho_charge = 0.2;
52
53!+++++++++++++++++++++++++ Step 2 +++++++++++++++++++++++
54!       slice, flatten sequence, and cycle start to ip3
55!++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56
57use,sequence=lhcb1;
58makethin,sequence=lhcb1;
59use,sequence=lhcb2;
60makethin,sequence=lhcb2;
61
62option,-warn,-echo,-info;
63call, file = "../share/LHC/LHCRing/V6.503/V6.5.thin.coll.str";
64option,warn;
65
66abas := 2.0*clight/(7e12)*on_atlas ;
67abcs := 4.0*clight/(7e12)*on_cms ;
68
69!on_x1:=1; on_sep1:=0; on_atlas  :=  1 ;
70!on_x2:=1; on_sep2:=0; on_alice  :=  1 ;
71!on_x5:=1; on_sep5:=0; on_cms    :=  1 ;
72!on_x8:=1; on_sep8:=0; on_lhcb   :=  1 ;
73
74! keep sextupoles
75ksf0=ksf; ksd0=ksd;
76use,period=lhcb1;
77select,flag=twiss,column=name,x,y,betx,bety;
78twiss,file="twiss-table-1";
79!plot,haxis=s,vaxis=x,y,colour=100,noline;
80
81use,period=lhcb2;
82select,flag=twiss,column=name,x,y,betx,bety;
83twiss,file="twiss-table-2";
84!plot,haxis=s,vaxis=x,y,colour=100,noline;
85
86seqedit,sequence=lhcb1;
87flatten;
88endedit;
89
90seqedit,sequence=lhcb1;
91cycle,start=ip3;
92endedit;
93
94seqedit,sequence=lhcb2;
95flatten;
96endedit;
97
98seqedit,sequence=lhcb2;
99cycle,start=ip3;
100endedit;
101
102bbmarker: marker;  /* for subsequent remove */
103
104
105!+++++++++++++++++++++++++ Step 3 +++++++++++++++++++++++
106!       define the beam-beam elements
107!++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108!
109!===========================================================
110! read macro definitions
111call,file="bb.macros";
112
113!
114!===========================================================
115!   this sets CHARGE in the head-on beam-beam elements.
116!   set +1 * ho_charge   for parasitic on, 0 for off
117
118 on_ho1  = +1 * ho_charge; ! ho_charge depends on split
119 on_ho2  = +0 * ho_charge; ! because of the "by hand" splitting
120 on_ho5  = +1 * ho_charge;
121 on_ho8  = +0 * ho_charge;
122
123!
124!===========================================================
125!   set CHARGE in the parasitic beam-beam elements.
126!   set +1 for parasitic on, 0 for off
127
128 on_lr1l = +1;
129 on_lr1r = +1;
130 on_lr2l = +0;
131 on_lr2r = +0;
132 on_lr5l = +1;
133 on_lr5r = +1;
134 on_lr8l = +0;
135 on_lr8r = +0;
136
137!
138!===========================================================
139!   define markers and savebetas
140
141option,echo;
142assign,echo="temp.bb.install",truncate;
143
144!--- ip1
145if (on_ho1 <> 0)
146{
147  exec, mkho(1);
148  exec, sbhomk(1);
149}
150if (on_lr1l <> 0 || on_lr1r <> 0)
151{
152  n=1; ! counter
153  while (n < npara_1)
154  {
155   exec, mkl(1,$n);
156   exec, sbl(1,$n);
157   n=n+1;
158  };
159}
160if (on_lr1r <> 0 || on_lr1l <> 0)
161{
162  n=1; ! counter
163  while (n < npara_1)
164  {
165   exec, mkr(1,$n);
166   exec, sbr(1,$n);
167   n=n+1;
168  };
169}
170!--- ip5
171if (on_ho5 <> 0)
172{
173  exec, mkho(5);
174  exec, sbhomk(5);
175}
176if (on_lr5l <> 0 || on_lr5r <> 0)
177{
178  n=1; ! counter
179  while (n < npara_5)
180  {
181   exec, mkl(5,$n);
182   exec, sbl(5,$n);
183   n=n+1;
184  };
185}
186if (on_lr5r <> 0 || on_lr5l <> 0)
187{
188  n=1; ! counter
189  while (n < npara_5)
190  {
191   exec, mkr(5,$n);
192   exec, sbr(5,$n);
193   n=n+1;
194  };
195}
196!--- ip2
197if (on_ho2 <> 0)
198{
199  exec, mkho(2);
200  exec, sbhomk(2);
201}
202if (on_lr2l <> 0 || on_lr2r <> 0)
203{
204  n=1; ! counter
205  while (n < npara_2)
206  {
207   exec, mkl(2,$n);
208   exec, sbl(2,$n);
209   n=n+1;
210  };
211}
212if (on_lr2r <> 0 || on_lr2l <> 0)
213{
214  n=1; ! counter
215  while (n < npara_2)
216  {
217   exec, mkr(2,$n);
218   exec, sbr(2,$n);
219   n=n+1;
220  };
221}
222!--- ip8
223if (on_ho8 <> 0)
224{
225  exec, mkho(8);
226  exec, sbhomk(8);
227}
228if (on_lr8l <> 0 || on_lr8r <> 0)
229{
230  n=1; ! counter
231  while (n < npara_8)
232  {
233   exec, mkl(8,$n);
234   exec, sbl(8,$n);
235   n=n+1;
236  };
237}
238if (on_lr8r <> 0 || on_lr8l <> 0)
239{
240  n=1; ! counter
241  while (n < npara_8)
242  {
243   exec, mkr(8,$n);
244   exec, sbr(8,$n);
245   n=n+1;
246  };
247}
248
249assign,echo=terminal;
250call,file="temp.bb.install";
251
252!
253!===========================================================
254!   install bb markers
255
256assign,echo="temp.bb.install",truncate;
257
258!--- ip1
259if (on_ho1 <> 0)
260{
261exec, inho(mk,1);
262}
263if (on_lr1l <> 0 || on_lr1r <> 0)
264{
265  n=1; ! counter
266  while (n < npara_1)
267  {
268   exec, inl(mk,1,$n);
269   n=n+1;
270  };
271}
272if (on_lr1r <> 0 || on_lr1l <> 0)
273{
274  n=1; ! counter
275  while (n < npara_1)
276  {
277   exec, inr(mk,1,$n);
278   n=n+1;
279  };
280}
281!--- ip5
282if (on_ho5 <> 0)
283{
284exec, inho(mk,5);
285}
286if (on_lr5l <> 0 || on_lr5r <> 0)
287{
288  n=1; ! counter
289  while (n < npara_5)
290  {
291   exec, inl(mk,5,$n);
292   n=n+1;
293  };
294}
295if (on_lr5r <> 0 || on_lr5l <> 0)
296{
297  n=1; ! counter
298  while (n < npara_5)
299  {
300   exec, inr(mk,5,$n);
301   n=n+1;
302  };
303}
304!--- ip2
305if (on_ho2 <> 0)
306{
307exec, inho(mk,2);
308}
309if (on_lr2l <> 0 || on_lr2r <> 0)
310{
311  n=1; ! counter
312  while (n < npara_2)
313  {
314   exec, inl(mk,2,$n);
315   n=n+1;
316  };
317}
318if (on_lr2r <> 0 || on_lr2l <> 0)
319{
320  n=1; ! counter
321  while (n < npara_2)
322  {
323   exec, inr(mk,2,$n);
324   n=n+1;
325  };
326}
327!--- ip8
328if (on_ho8 <> 0)
329{
330exec, inho(mk,8);
331}
332if (on_lr8l <> 0 || on_lr8r <> 0)
333{
334  n=1; ! counter
335  while (n < npara_8)
336  {
337   exec, inl(mk,8,$n);
338   n=n+1;
339  };
340}
341if (on_lr8r <> 0 || on_lr8l <> 0)
342{
343  n=1; ! counter
344  while (n < npara_8)
345  {
346   exec, inr(mk,8,$n);
347   n=n+1;
348  };
349}
350
351assign,echo=terminal;
352seqedit,sequence=lhcb2;
353call,file="temp.bb.install";
354endedit;
355
356!
357!===========================================================
358!--- get beta functions at bb in all four IPs
359use,period=lhcb2;
360select,flag=twiss,class=bbmarker,column=name,s,x,y;
361twiss, sequence=lhcb2; !,file;
362!--- separation for halo collisions at IP2
363on_sep2 = 2.118 * sqrt(epsx * r2ip2->betx) / 0.0007999979093;
364value,on_sep2;
365!===========================================================
366!   define bb elements
367
368assign,echo="temp.bb.install",truncate;
369
370!--- ip1
371if (on_ho1 <> 0)
372{
373exec, bbho(1);
374}
375if (on_lr1l <> 0)
376{
377  n=1; ! counter
378  while (n < npara_1)
379  {
380   exec, bbl(1,$n);
381   n=n+1;
382  };
383}
384if (on_lr1r <> 0)
385{
386  n=1; ! counter
387  while (n < npara_1)
388  {
389   exec, bbr(1,$n);
390   n=n+1;
391  };
392}
393!--- ip5
394if (on_ho5 <> 0)
395{
396exec, bbho(5);
397}
398if (on_lr5l <> 0)
399{
400  n=1; ! counter
401  while (n < npara_5)
402  {
403   exec, bbl(5,$n);
404   n=n+1;
405  };
406}
407if (on_lr5r <> 0)
408{
409  n=1; ! counter
410  while (n < npara_5)
411  {
412   exec, bbr(5,$n);
413   n=n+1;
414  };
415}
416!--- ip2
417if (on_ho2 <> 0)
418{
419exec, bbho(2);
420}
421if (on_lr2l <> 0)
422{
423  n=1; ! counter
424  while (n < npara_2)
425  {
426   exec, bbl(2,$n);
427   n=n+1;
428  };
429}
430if (on_lr2r <> 0)
431{
432  n=1; ! counter
433  while (n < npara_2)
434  {
435   exec, bbr(2,$n);
436   n=n+1;
437  };
438}
439!--- ip8
440if (on_ho8 <> 0)
441{
442exec, bbho(8);
443}
444if (on_lr8l <> 0)
445{
446  n=1; ! counter
447  while (n < npara_8)
448  {
449   exec, bbl(8,$n);
450   n=n+1;
451  };
452}
453if (on_lr8r <> 0)
454{
455  n=1; ! counter
456  while (n < npara_8)
457  {
458   exec, bbr(8,$n);
459   n=n+1;
460  };
461}
462
463assign,echo=terminal;
464call,file="temp.bb.install";
465
466!
467!===========================================================
468!   install bb elements
469
470assign,echo="temp.bb.install",truncate;
471
472!--- ip1
473if (on_ho1 <> 0)
474{
475exec, inho(bb,1);
476}
477if (on_lr1l <> 0)
478{
479  n=1; ! counter
480  while (n < npara_1)
481  {
482   exec, inl(bb,1,$n);
483   n=n+1;
484  };
485}
486if (on_lr1r <> 0)
487{
488  n=1; ! counter
489  while (n < npara_1)
490  {
491   exec, inr(bb,1,$n);
492   n=n+1;
493  };
494}
495!--- ip5
496if (on_ho5 <> 0)
497{
498exec, inho(bb,5);
499}
500if (on_lr5l <> 0)
501{
502  n=1; ! counter
503  while (n < npara_5)
504  {
505   exec, inl(bb,5,$n);
506   n=n+1;
507  };
508}
509if (on_lr5r <> 0)
510{
511  n=1; ! counter
512  while (n < npara_5)
513  {
514   exec, inr(bb,5,$n);
515   n=n+1;
516  };
517}
518!--- ip2
519if (on_ho2 <> 0)
520{
521exec, inho(bb,2);
522}
523if (on_lr2l <> 0)
524{
525  n=1; ! counter
526  while (n < npara_2)
527  {
528   exec, inl(bb,2,$n);
529   n=n+1;
530  };
531}
532if (on_lr2r <> 0)
533{
534  n=1; ! counter
535  while (n < npara_2)
536  {
537   exec, inr(bb,2,$n);
538   n=n+1;
539  };
540}
541!--- ip8
542if (on_ho8 <> 0)
543{
544exec, inho(bb,8);
545}
546if (on_lr8l <> 0)
547{
548  n=1; ! counter
549  while (n < npara_8)
550  {
551   exec, inl(bb,8,$n);
552   n=n+1;
553  };
554}
555if (on_lr8r <> 0)
556{
557  n=1; ! counter
558  while (n < npara_8)
559  {
560   exec, inr(bb,8,$n);
561   n=n+1;
562  };
563}
564
565assign,echo=terminal;
566select,flag=seqedit,class=bbmarker;
567seqedit,sequence=lhcb2;
568remove,element=selected;
569endedit;
570select,flag=seqedit,clear;
571
572seqedit,sequence=lhcb1;
573call,file="temp.bb.install";
574endedit;
575removefile, file="temp.bb.install";
576
577!--- Now the beam-beam element installation is complete
578
579seqedit,sequence=lhcb1;
580cycle,start=ip1;
581endedit;
582
583use,period=lhcb1;
584!twiss, sequence=lhcb1;
585
586!
587!  make footprint
588!
589
590option,trace;
591small=0.05;
592big=sqrt(1.-small^2);
593track;
594xs=small; ys=small;
595value,xs,ys;
596start,fx=xs,fy=ys;  // zero amplitude
597nsigmax=6;
598n=1; // sigma multiplier
599m=0; // angle multiplier
600while (n <= nsigmax)
601{
602  angle = 15*m*pi/180;
603  if (m == 0) {xs=n*big; ys=n*small;}
604  elseif (m == 6) {xs=n*small; ys=n*big;}
605  else
606  {
607    xs=n*cos(angle);
608    ys=n*sin(angle);
609  }
610  value,xs,ys;
611  start,fx=xs,fy=ys;
612  m=m+1;
613  if (m == 7) { m=0; n=n+1;}
614};
615dynap,fastune,turns=1024;
616endtrack;
617write,table=dynap,file;
618write,table=dynaptune,file;
619!system,"foot < dynaptune > footprint";
620!stop;
Note: See TracBrowser for help on using the repository browser.