Skip to content

Collimation SixTrack: Proton Collimation with Online Aperture Check

Björn Lindström

Based on, and partially copied 1:1 from, the offline aperture check step-by-step guide on this website.

Overview

With the implementation of the online aperture check in SixTrack, it is no longer necessary to save the tracks2.dat file, containing the tracks of all the particles. Particle loss locations can be correctly identified directly by SixTrack, whereafter they are removed, significantly speeding up the simulation. The BeamLossPattern post-processing script is thus not necessary.

Input parameters for collimation SixTrack are divided in four files:

  • fort.2 (generated by MAD-X), defining the lattice of the machine without magnetic field errors.
  • Collimator database file, containing the details of collimators geometry, material, settings (opening)
  • fort.3 (modified from the one used for SixTrack without collimation), including tracking parameters (number of particles and turns), type of beam, type of halo.
  • fort3.limi (generated by MAD-X), defines the aperture model to be used for the online aperture check

Required input for scenarios that were already studied are available on CERN gitlab and can be downloaded via

git clone ssh://git@gitlab.cern.ch:7999/collteam/sixtrack_simulation_material.git

Preparation

Here it is assumed that you have prepared SixTrack and MAD-X as explained in the guide for the offline aperture check.

Running the Simulation

Step 1: Optics preparation

MAD-X is used to generate the LHC lattice, the optics and eventual orbit and focusing errors. Optics input files are available on afs:

/afs/cern.ch/eng/lhc/optics

For the SixTrack simulations, thin optics must be used, and all the necessary aperture markers must be loaded within the MAD-X script. A functional template, for HLLHCV1.5 optics, with 20 cm beta star, follows:

system,"ln -fns /afs/cern.ch/eng/lhc/optics/runIII lhc";
system,"ln -fns /afs/cern.ch/eng/lhc/optics/HLLHCV1.5  slhc";
system, "mkdir out";


call,file="slhc/toolkit/macro.madx";
call,file="slhc/aperture/const_for_aperture.madx";
call,file="lhc/LHC_LS2_2021-07-02.seq";  

mylhcbeam = 1;
exec,mk_beam(7000);
call,file="slhc/hllhc_sequence.madx";  ! installs HLLHC on top of LHC sequence
call,file="lhc/aperture/aperture.b1.madx"; ! aperture definitions
call,file="lhc/aperture/aperture.b2.madx";
call,file="lhc/aperture/aper_tol.b1.madx";
call,file="lhc/aperture/aper_tol.b2.madx";
call,file="slhc/aperture/exp_pipe_model_after_LS3.madx";
call,file="slhc/aperture/exp_pipe_install_after_LS3.madx";
call,file="slhc/aperture/aperture_upgrade_IT.madx";
call,file="slhc/aperture/aperture_upgrade_MS.madx";  

mbh_shift=0; ! must set this to zero when not using MBH otherwise aperture will be wrong, this shift is due to MBH being RBEND
make_end_markers=1; ! adds start and end markers to each thick element during slicing, such that aperture is correctly defined  
exec,myslice; ! makes sequence thin 

call,file="slhc/round/opt_round_200_1500_tcdq4_thin.madx";  ! the optics file

on_x1:=250; on_x2:=200; on_x5:=250; on_x8:=170; ! xing angles [murad]
phi_IR1:=0; phi_IR2:=90; phi_IR5:=90; phi_IR8:=90; ! xing plane: 0,180 H, 90,270 V
on_sep1:=0; on_sep2:=0; on_sep5:=0; on_sep8:=0; ! beam separations at xing point [mm]
on_sol_atlas:=0; on_sol_alice:=0; on_sol_cms:=0; ! solenoid switches [0/1]
on_alice:=7000/nrj; on_lhcb:=7000/nrj;           ! spectrometer dipoles in ALICE and LHCb [0,1; 1 is for 7 TeV beam]
on_a1=0; on_a2=0; on_a5=0; on_a8=0;              ! add crossing angle in the non-nominal plane as well, keep at 0 [murad]
on_o1=0; on_o2=0; on_o5=0; on_o8=0;             ! add offset - plane depends on phi_IRx
on_crab1:=0; on_crab5:=0; ! crab cavity switches [0/1]
on_disp=1;       ! switch for arc orbit correctors (dispersion), leave at 1 [0/1]

! Rematch post-knobs

call, file="/afs/cern.ch/eng/lhc/optics/HLLHCV1.5/toolkit/rematch_chroma.madx";
call, file="/afs/cern.ch/eng/lhc/optics/HLLHCV1.5/toolkit/rematch_tune.madx";   

select, flag=twiss, CLEAR; 
select, flag=twiss,column=name,keyword,s,l,mux,betx,alfx,muy,bety,alfy,dx,dpx,dy,dpy,x,y,px,py,apertype,mech_sep;   
use,sequence=lhcb2;twiss, centre=true, table=twiss;write,table=twiss,file="out/LHC_b2_7000GeV_thinXing.twiss";        
use,sequence=lhcb1;twiss, centre=true, table=twiss;write,table=twiss,file="out/LHC_b1_7000GeV_thinXing.twiss";    

sixtrack, aperture=true, long_names=true;
system, "rm -r lhc slhc d2_aperture fc.3";   

After running this script, the following files will be created: fc.2, fc.3.aux, fc.3.aper, fc.8, fc.34.

Rename them into the following: * fort.2 - the lattice file for SixTrack (required) * fort.3.aux - (not required) * fort3.limi - the aperture definitions (required) * fort.8 - tilts and misalignments of elements (not required) * fort.34 - linear lattice functions, phase advances and multipole strengths needed for resonance calculations for the program SODD(not required)

Aside from these files, you will need a fort.3 file. You can use the same as for the offline aperture check, but with some changes.

Add this block:

LIMI 
PREC 0.1
LOAD fort3.limi
PRIN ape_dump.dat
NEXT
PREC sets the precision of the interpolation to 0.1 m. LOAD loads the specified aperture model file. PRIN prints the interpolated aperture to a file, e.g. for plotting or cross-checking with the twiss output from MAD-X.

It is also recommended to set the WRITE_TRACKS option to .FALSE. in the collimation block in the fort.3 file (DOWRITETRACKS option, first value of the last line if you are using the old fort.3 format). Otherwise the tracks2.dat file will be outputted, which can quickly become very cumbersome.

Finally, you need a CollDB file, usually named CollDB_HL.data, with the collimator specifications.

Since the same files can be reused for different simulations, with different parameters, it is recommended to put them in a specific clean_input folder.

mkdir <path>/<to>/<your>/<templates>/clean_input_HLLHCV15_20cm_250murad
cp CollDB_HL.data fort.2 fort.3 fort3.limi <path>/<to>/<your>/<templates>/clean_input_HLLHCV15_20cm_250murad/

Step 2 (optional): Running a single SixTrack job locally

To confirm that everything is running as expected and to do some sanity checks, it is good to do a local run before submitting the jobs to condor.

Create a folder to run in and link the input files to it:

mkdir singleRun
cd singleRun
ln -s cp <path>/<to>/<your>/<templates>/clean_input_HLLHCV15_20cm_250murad/* ./
If you want to do any further changes to fort.3, such as number of turns, particles, type of beam distribution, or changes to the CollDB file, it might be better to copy these two files instead of just linking to them.

Now, simply run sixtrack. When it is finished, you will see the following files:

singleRun $ ls
align_error.dat      CollDB_HL.data coll_summary.dat  FirstImpacts.dat   fort.2    fort.3      impact.dat       orbitchecking.dat     singletrackfile.dat
all_absorptions.dat  collgaps.dat   colltrack.out     FLUKA_impacts_all.dat  fort.20   fort.31     jaw_profiles.dat     pencilbeam_distr.dat  survival.dat
all_impacts.dat      CollPositions.dat  dist0.dat     FLUKA_impacts.dat  fort.208  fort3.limi  linopt_coupled.dat   sigmasettings.out
amplitude.dat        Coll_Scatter.dat   distn.dat     fort.18        fort.21   fort.4      linopt_dump.dat      sim_meta.dat
aperture_losses.dat  collsettings.dat   file_units.log    fort.19        fort.26   fort.9      MaterialInformation.txt  sim_time.dat

Some sanity checks: * Check coll_summary.dat that you are losing particles where you expect, in particular that most of the losses are on the correct TCP * Check the impact parameter. This is contained in FirstImpacts.dat. Note that the impact is in the horizontal plane even if you have a vertical collimator, since the K2 routine rotates the coordinate system for vertical collimators. If you have a converging beam (in LHC, horizontal case), meaning that you hit the front face of the collimator, the impact parameter is simply the average of the x_in parameter. For a diverging beam (in LHC, vertical case), the impact parameter is instead the average of the x_out, that particles would have if they were not scattered. Adding the following two aliases to your ~/.bashrc lets you conveniently calculate the impact parameters:

alias ximpactParamIn="awk '\$1>0 {sum+=\$7} END { print \"Average x_in = \",sum/(NR-1)}' FirstImpacts.dat"
alias ximpactParamOutCor="awk '\$1>0 {sum+=sin(sqrt(\$8*\$8))*(0.6-\$5)/cos(sqrt(\$8*\$8))} END { print \"Average y_out =\",sum/(NR-1)}' FirstImpacts.dat"

Then simply run in the terminal:

singleRun $ ximpactParamIn
Average x_in =  1.31793e-05

  • Check the aperture_losses.dat file. This file contains all the losses into the aperture, as determined by the online aperture check. If you do not run a few thousand particles, this file can often be empty, simply because there were no losses into the aperture in that particular run.

Running SixTrack

For running on the cluster, the procedure is identical to the offline aperture check. One need only edit the submit script to remove the post-processing parts, that is, the following lines:

# post-processing

$beamLossPatt lowb tracks2.dat BLP_out \${apeFile}
# remove binary characters in LPI file:
perl -pi -e 's/\0/ /g' LPI_BLP_out.s 

# clean lists of events in collimators from protons being lost in machine aperture beforehand
$cleanInel FLUKA_impacts.dat LPI_BLP_out.s \${collPosFile} coll_summary.dat
$cleanCollScatter Coll_Scatter.dat LPI_BLP_out.s \${collPosFile} coll_summary.dat

# create clean coll_summary with awk script
$cleanCollSum

From the fileList=... in the submit script, one should also remove LPI_BLP_out.s, Coll_Scatter_real.dat, impacts_real.dat, and instead add aperture_losses.dat, coll_summary.dat, Coll_Scatter.dat, FLUKA_impacts_all.dat.

Bibliography

http://lhc-collimation-project.web.cern.ch/code-tracking-2012.php

http://sixtrack.web.cern.ch/SixTrack/source.php