Injector2-sc.in 15.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
// Injector 2 template file
// started 21-01-16: Nate Pogue based on work of A. Kolano and A. Adelmann
//
//---------------------------------------------------------------------------------------------//
//                                      Global Options                                         //
//---------------------------------------------------------------------------------------------//
OPTION, VERSION         =10900;         // Version number, acknowledging recent changes
OPTION, ECHO            =false;         // If true, command prints an echo of the input files on
                                        // the standard error file.
OPTION, PSDUMPFREQ      =1000000;    // Defines after how many steps the phase is dumped into
                                        // the H5hut file, Default is 10. A higher number dumps
                                        // less. if 1 then every step, every turn. If too low it
                                        // will be time prohibitive, and large file sizes.
OPTION, STATDUMPFREQ    =8;  // Defines after how many steps the bunch statistics is
                                        // dumped into *.stat file. The behaviour is like
                                        // PSDUMPFREQ.
OPTION, SPTDUMPFREQ     =10;   // Defines after how many steps we dump the phase space
                                        // for Single Particle simulations. It is always useful
                                        // record the trajectory of the reference particle or
                                        // some specified particle for a primary study.
                                        // Default value is 1. same as above but single particle
OPTION, REPARTFREQ      =10;    // Defines after how many time steps the particles are
                                        // repartitioned to balance the computational load on
                                        // the computer nodes, Default value is 10.
OPTION, PSDUMPFRAME     =bunch_mean; // Determines whether the phase space data is dumped in
                                        // global frame or in the local frame. If true, run can
                                        // not be restarted as it is in local frame. Default is
                                        // false
OPTION, PSDUMPEACHTURN  =true;    // Phase space dumped each turn
OPTION, ENABLEHDF5      =false;  // Enable HDF5 (.h5) output
OPTION, ASCIIDUMP       =false;   // Dump in ascii instead of HDF5
OPTION, CLOTUNEONLY     =false; // Compute tunes using the matched distribution
IF (false) {
  OPTION, AMR             =false;         // Enable AMR simulation
  OPTION, AMR_YT_DUMP_FREQ=1000000000000;  // Defines after how many steps we dump a Yt file
  OPTION, AMR_REGRID_FREQ =10;  // Defines after how many steps a AMR regrid is performed
}
OPTION, SCSOLVEFREQ     =1; // Defines after how many steps we compute space-charge
OPTION, SEED            =123456789;        // RNG seed for particle generation
//---------------------------------------------------------------------------------------------//
//                                      Physical Parameters                                    //
//---------------------------------------------------------------------------------------------//
REAL Ebeam                   =.0008685;                     // injection energy of the beam
REAL gamma                   =(Ebeam+PMASS)/PMASS;           // relativistic gamma
REAL beta                    =sqrt(1-(1/gamma^2));           // relativistic beta
REAL gammabeta               =gamma*beta;                    // self explanatory
REAL P0                      =PMASS*gammabeta;               // Initial momentum of the particle
REAL Brho                    =(PMASS*1.0e9*gammabeta)/CLIGHT;// Magnetic rigidity

VALUE,{gamma,beta,gammabeta,Ebeam,Brho,CLIGHT};         // Prints values in output to check
                                                        // initial conditions

//---------------------------------------------------------------------------------------------//
//                                      Cyclotron Configuration                                //
//---------------------------------------------------------------------------------------------//
// Below are the series of value and commands required to set up the cyclotron's configuration

INJECTOR2: CYCLOTRON, TYPE="INJECTOR2", CYHARMON=10, PHIINIT=30.0, PRINIT=-.00550008,
           RINIT=392.0,SYMMETRY=1.0, RFFREQ=50.6370, BSCALE=1, FMAPFN="ZYKL9Z.NAR";

// Note: CYHARMON - Cyclotron's harmonics, SYMMETRY - symmetry of cyclotron, in this case the
//       field map imported is for the whole cyclotron, hence symmetry 1, FMAPFN - insert
//       field maps - in this case the sector dipole field map.
// Note: In general there should be gap widths, otherwise no transit is taken into account. In
//       this model none are specified by one needs to add this for accurate models.

RFM11: RFCAVITY, VOLT=.303619, FMAPFN="Cav1.dat", TYPE="SINGLEGAP", FREQ=50.6370,
       RMIN=350.0, RMAX=3150.0, ANGLE=35.0, PDIS=0.0,
       GAPWIDTH=0.0, PHI0=50.0;
RFM12: RFCAVITY, VOLT=.303619, FMAPFN="Cav1.dat", TYPE="SINGLEGAP", FREQ=50.6370,
       RMIN=350.0, RMAX=3150.0, ANGLE=55.0, PDIS=0.0,
       GAPWIDTH=0.0, PHI0=((50.0)+200);
RFM21: RFCAVITY, VOLT=.288119, FMAPFN="Cav1.dat", TYPE="SINGLEGAP", FREQ=50.6370,
       RMIN=350.0, RMAX=3150.0, ANGLE=((35.0)+180), PDIS=0.0,
       GAPWIDTH=0.0, PHI0=(50.0);
RFM22: RFCAVITY, VOLT=.288119, FMAPFN="Cav1.dat", TYPE="SINGLEGAP", FREQ=50.6370,
       RMIN=350.0, RMAX=3150.0, ANGLE=((55.0)+180), PDIS=0.0,
       GAPWIDTH=0.0, PHI0=((50.0)+200);

// Flat Top Cavities

REAL ftfreq                  =(50.6370)*3;                  // 3rd harmonic frequency for FT Cavity

FT1:   RFCAVITY, VOLT=.031, FMAPFN="Cav3.dat", TYPE="SINGLEGAP", FREQ=ftfreq,
       RMIN=830.0, RMAX=3150.0, ANGLE=135.0, PDIS=0.0,
       GAPWIDTH=0.0, PHI0=(((50.0)+100)*3);          // 3 comes from 3rd harmonic
FT2:   RFCAVITY, VOLT=.031, FMAPFN="Cav3.dat", TYPE="SINGLEGAP", FREQ=ftfreq,
       RMIN=830.0, RMAX=3150.0, ANGLE=((135.0)+180), PDIS=0.0,
       GAPWIDTH=0.0, PHI0=(((50.0)+100)*3);          // 3 comes from 3rd harmonic

//---------------------------------------------------------------------------------------------//
//                                      Probes                                                 //
//---------------------------------------------------------------------------------------------//
// RIE1 - extraction probe, contains the last 7 turns, is a wire with stopping block
// RIE2 - vertical extraction probe, contains the last 5 turns, consists of two plates approx
//        15 mm apart with beam going between them. This measures how much the beam deviates
//        from the center.
// RIL1 - Long Probe. This has a full machine scan but only to approximately 2 microamps. At
//        higher energies larger currents are hard to distinguish.
// MXP01- extraction probe, good up to 1 mA, last 4 turns, located after septum, shows the
//        extraction radius.
// RIZ1 - last 13 turns, for time structure measurement

// Probe positioning according to the report of Rudolf Doelling:
// identifier - HIPA-BEAMDY-DR84-023.02-030712
// title      - Wire probe properties in Injector 2 and Ring cyclotron
// date       - 03.07.12
RIZ1: PROBE, XSTART= -2769.80797259, XEND= -2982.0814283, YSTART= 1044.46742649, YEND= 1256.7408822, STEP=1.0;
RIE1: PROBE, XSTART= -2981.184446, XEND= -3249.523561, YSTART= 911.4395523, YEND= 993.4790526, STEP=1.0;
RIE2: PROBE, XSTART= 914.240473234, XEND = 1017.45353244, YSTART=-2990.3458458, YEND=-3327.94055075, STEP=1.0;
RIL1: PROBE, XSTART= 145.785076437, XEND= 1029.55562455, YSTART= 492.162169908, YEND= 3475.7215389, STEP=1.0;
MXP01: PROBE, XSTART= 1227.82021485, XEND= 1296.97525805, YSTART= -2946.08969314, YEND= -3015.24473634, STEP=1.0;

//---------------------------------------------------------------------------------------------//
//                                      Collimators                                            //
//---------------------------------------------------------------------------------------------//
// These values are used to essentially open and close the collimators. Note that they all do
// not scale the same as each collimator has its own angle. To understand get more information
// read the separate collimator file.

// KIP3 - Description needed
REAL KIP3_1L_vary= 23.0;
REAL KIP3_1R_vary= -7.5;
REAL KIP3_2L_vary= 19.4;
REAL KIP3_2R_vary= -13.0;
// KIR1L- Description needed
REAL KIR1L_vary=   -2.8;
REAL KIR1R_vary=   -2.0;
// KIP4 - Description needed
REAL KIP4L_vary=   -27.0;
REAL KIP4R_vary=   38.552;
// KIR3 - Description needed
REAL KIR3L_vary=   -18.93;
REAL KIR3R_vary=   13.47;
// KIV-OU-Description needed
REAL KIVo_vary_Z=  -5.8;
REAL KIVu_vary_Z=  0.0;
// KIP2 - Description needed
REAL KIP2_vary_x=  15.9;
// KIG1 - Description needed
REAL KIG1u_vary_Z= -5.0;
REAL KIG1o_vary_Z= -1.7;
// KIG3 - Description needed
REAL KIG3u_vary_Z= 3.5;
REAL KIG3o_vary_Z= 2.0;

VALUE, {KIP3_1L_vary, KIVU_vary_Z, KIG3U_vary_Z, KIG3O_vary_Z};

//---------------------------------------------------------------------------------------------//
//                                      Distributions                                          //
//---------------------------------------------------------------------------------------------//

153
// Note: Distributions in eV/c need to be specified as EVOVERC in the parameter INPUTMOUNITS (see Opal
154 155 156
//       Manual). Some from other sources are in BETA*GAMMA, thus have no units.

//For Single Particle
157
DistSP: DISTRIBUTION, TYPE = fromfile, FNAME = "spdist.opal",
158
        INPUTMOUNITS = EVOVERC;
159
//For Multiple Particles
160
DistSC: DISTRIBUTION, TYPE = fromfile, FNAME = "scdist.opal",
161 162
        INPUTMOUNITS = NONE;
//For Tune 
163
DistT:  DISTRIBUTION, TYPE = fromfile, FNAME = "tdist.opal";
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299

//General Distribution
DistG: DISTRIBUTION, TYPE = gauss,
       SIGMAX = 1.26e-03, SIGMAPX = 0, CORRX = 0,
       SIGMAY = 6.70e-03, SIGMAPY = 3.68e-3, CORRY = 0,
       SIGMAZ = 1.26e-03, SIGMAPZ = 0, CORRZ = 0,
       R61 = 0, R62 = 0, R51 = 0, R52 = 0,
       SCALABLE=false;

//---------------------------------------------------------------------------------------------//
//                                      Choice of Simulation                                   //
//---------------------------------------------------------------------------------------------//
REAL RF_MODE                 =0;      // Selects Single Particle mode
REAL SC_MODE                 =1;      // Selects Space Charge mode
REAL TUNE_MODE               =0;    // Selects Tune Calculation
//---------------------------------------------------------------------------------------------//
//                                      Tune Mode - Easiest to Start with.                     //
//---------------------------------------------------------------------------------------------//
// Calculation of the betatron oscillation frequency for a cyclotron. Calls tuning.bash and
// works with FIXPOEORBIT output data.
// Requires a distribution file with two particles: first particle is the reference orbit, the
// second is displaced off center with a dx and dz as follows:  (note dx radial, dz vertical)
// 2
// 0.0  0.0     0.0     0.0     0.0     0.0
// 0.01 0.0     0.0     0.0     0.01    0.0
// When the total number of particles is equal to 2, SEO mode is triggered automatically,
// regardless of the existence of a cavity or other components.

IF (TUNE_MODE>0){

TITLE, STRING           ="Tune Calculation of Cyclotron";

Line1: LINE = (INJECTOR2);
// the number of particles must match the number of particles stated in the distribution. Thus
// for tune calculations the number is just hard coded here.

REAL numparticles = 2;

Dist: DistT;
FS1:  FIELDSOLVER, FSTYPE = NONE, MX = 16, MY = 16, MT = 16,
      PARFFTX = true, PARFFTY = true, PARFFTT = true,
      BCFFTX  = open,      BCFFTY  = open,      BCFFTT  = open,
      BBOXINCR = 5;
}
//---------------------------------------------------------------------------------------------//
//                                      Single Particle Mode                                   //
//---------------------------------------------------------------------------------------------//
// Sends a single particle through the machine. Allows for quick assessment of the system and
// whether it is work properly or as expected.

IF (RF_MODE>0){

TITLE, STRING           ="Single Particle through the Cyclotron";

Line1: LINE = (INJECTOR2, RFM11, RFM12, RFM21, RFM22, FT1, FT2, RIE1, RIE2, RIZ1, RIL1, MXP01);

//KIP2, KIG3o, KIG3u, KIVo, KIVu, KIP3_1L, KIP3_1R, KIP3_2L, KIP3_2R, KIR1R, KIR1L, KIG1o, KIG1u, KIR3L,
//KIR3R, KIP4L, KIP4R

// the number of particles must match the number of particles stated in the distribution. Thus
// for single particle calculation the number is just hard coded here.

REAL numparticles = 1;

Dist: DistSP;
FS1:  FIELDSOLVER, FSTYPE = NONE, MX = 16, MY = 16, MT = 16,
      PARFFTX = true, PARFFTY = true, PARFFTT = true,
      BCFFTX  = open,      BCFFTY  = open,      BCFFTT  = open,
      BBOXINCR = 5;

}
//---------------------------------------------------------------------------------------------//
//                                      Space Charge Mode                                      //
//---------------------------------------------------------------------------------------------//
// Large Multiparticle Runs where Space Charge must be use dot get correct dynamics.

IF (SC_MODE>0){

TITLE, STRING           ="Space Charge Simulation in the Cyclotron";

REAL Sigmacutter = 0;

IF (Sigmacutter > 0){
OPTION, REMOTEPARTDEL   = _Sigmacutter_;// Scrapes off the beam larger than the sigma specified
}

Line1: LINE = (INJECTOR2, RFM11, RFM12, RFM21, RFM22, FT1, FT2, RIE1, RIE2, RIZ1, KIP2, KIG3o, KIG3u,
               KIVo, KIVu, KIP3_1L, KIP3_1R, KIP3_2L, KIP3_2R, KIR1R, KIR1L, KIG1o, KIG1u, KIR3L,
               KIR3R, KIP4L, KIP4R, RIL1, MXP01);

// remember the number of particles has to match was is inserted into the distribution.

REAL numparticles = 1e5;

Dist: DistSC;  // Or switch to DistG for general distribution.

IF (false) {
FS1:  FIELDSOLVER, FSTYPE = FFT, MX = 16, MY = 16, MT = 16,
      PARFFTX = true, PARFFTY = true, PARFFTT = true,
      BCFFTX  = open,	   BCFFTY  = open,	BCFFTT  = open,
      BBOXINCR = 2,
      AMR_MAXLEVEL=0, AMR_MAXGRIDX=16, AMR_MAXGRIDY=16, AMR_MAXGRIDZ=16,
      AMR_BFX=8, AMR_BFY=8, AMR_BFZ=8, AMR_REFX=2, AMR_REFY=2, AMR_REFZ=2,
      AMR_TAGGING=CHARGE_DENSITY, AMR_SCALING=0.5, AMR_DENSITY=1.0e-14, AMR_MAX_NUM_PART=2,
      AMR_MIN_NUM_PART=5, AMR_DOMAIN_RATIO={1.0, 0.75, 0.75},
      AMR_MG_SMOOTHER=gs, AMR_MG_NSWEEPS=12, AMR_MG_PREC=none, AMR_MG_INTERP=pc,
      AMR_MG_NORM=linf, AMR_MG_REBALANCE=true, AMR_MG_REUSE=rap, ITSOLVER=sa,
      AMR_MG_VERBOSE=false;
} ELSE {
FS1:  FIELDSOLVER, FSTYPE = FFT, MX = 16, MY = 16, MT = 16,
      PARFFTX = true, PARFFTY = true, PARFFTT = true,
      BCFFTX  = open,      BCFFTY  = open,      BCFFTT  = open,
      BBOXINCR = 2;
}
}
//---------------------------------------------------------------------------------------------//
//                                      Tracking and Computation                               //
//---------------------------------------------------------------------------------------------//

Beam1: BEAM, PARTICLE = PROTON, PC = P0, NPART = numparticles, BCURRENT = .0095, CHARGE = 1.0,
      BFREQ = 50.6370;

SELECT, LINE = Line1;

REAL nstep1 =3600; //dummy for duplicate variable

TRACK, LINE = Line1, BEAM = Beam1, MAXSTEPS = ((nstep1)*(83)), STEPSPERTURN = nstep1,
       TIMEINTEGRATOR = "RK-4";

RUN, METHOD = "CYCLOTRON-T", BEAM = Beam1, FIELDSOLVER = FS1, DISTRIBUTION = Dist,
     MBMODE=force, PARAMB=5.0, TURNS=1, MB_BINNING=GAMMA, MB_ETA=0.01;

ENDTRACK;

STOP;