AWAGun-TrackBack-1.in 6.22 KB
Newer Older
kraus's avatar
kraus committed
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
OPTION, PSDUMPFREQ = 300000;   // 6d data written every 300000 time steps (h5).
OPTION, STATDUMPFREQ = 10;  // Beam Stats written every 10 time steps (stat).
OPTION, BOUNDPDESTROYFQ=10; // Delete lost particles, if any
OPTION, AUTOPHASE=4;        // Autophase is on, and phase of max energy
                            // gain will be found automatically for cavities
Option, VERSION=10900;

Title, string="AWA Photoinjector";

//----------------------------------------------------------------------------
//Global Parameters

REAL rf_freq             = 1.3e3;     //RF frequency. (Hz)
REAL n_particles         = 1E4;      //Number of particles in simulation.
REAL beam_bunch_charge   = 1e-9;      //Charge of bunch. (C)

//Initial Momentum Calculation
REAL Edes    = 1.4e-9; //initial energy in GeV
REAL gamma   = (Edes+EMASS)/EMASS;
REAL beta    = sqrt(1-(1/gamma^2));
REAL P0      = gamma*beta*EMASS;    //inital z momentum

//Printing initial energy and momentum to terminal output.
value , {Edes, P0, OPALVERSION};

//----------------------------------------------------------------------------
// RF photoinjector (Gun)
//
// Cavity/RF field.
//
// L:        physical element length (real in m). Length (of field map) (m).
// VOLT:     field scaling factor (real). RF field magnitude (MV/m).
// FMAPFN:   file name, or full path name to file (string)
// ELEMEDGE: physical start of the element on the floor (m)
// TYPE:     specifies "STANDING", "TRAVELLING" or "SINGLE GAP" structure
// FREQ:     RF frequency of cavity (real in MHz). Resonance frequency.
// LAG:      cavity phase (radians)
//

REAL gun_inj_phase = 0.0;  // Rf injection phase (in degrees) with restpect
                      // to max phase. i.e. 0.0 inj phase corresponds
                      // to running on crest (max energy).
GUNSOURCE: SOURCE, ELEMEDGE = 0.0;

GUN:    RFCavity, L = 0.2927, VOLT = 60.0, ELEMEDGE = 0.0, TYPE = "STANDING",
        FMAPFN = "DriveGun.T7", FREQ = rf_freq, LAG = (gun_inj_phase*Pi)/180.0;
        //LAG (phase) is converted to radians

//----------------------------------------------------------------------------
// Solenoids
//
// L:           Physcial element length (m)
// ELEMEDGE:    Physcial start of element (m)
// KS:          Solenoid strength (Rad/m)
// FMAPFM:      Field file (string)

// Note: OPAL scales the field file based on the max magnetic
// field value in the file, not Bz on axis. The max field
// value is normalized to 1 [T], and scaled with KS.
// i.e. The max value in the BF_559 file = 0.162544398 [T].
// Therefore, setting KS = 0.162544398 runs the magnet at max current.

REAL KSBF = 0.162544398;
if (OPALVERSION>10500)
 KSBF = KSBF/1.3528;

// Buck and Focusing Solenoid
BF: Solenoid, L = 0.5, ELEMEDGE=0.0, KS = KSBF,
    FMAPFN = "BF_550.T7";

// Matching Solenoid
// Max value in the M_440 file = 1.973966
// Conversion from Current (I) to Scaling factor:
// Scaling Factor (KS) = (I / Imax) * 1.973966
// Where Imax for this Matching solenoid = 440 [A]

REAL I  = 273; //[A]
REAL SF = (I/440)*1.973966;
if (OPALVERSION>10500)
 SF = SF/3.2306;

M:  Solenoid, L = 0.5, ELEMEDGE=0.0, KS = SF,
    FMAPFN = "M_440.T7";

value,{KSBF,SF};

//----------------------------------------------------------------------------
//Drift after gun.

DR1: DRIFT, L = 10.0, ELEMEDGE = 0.5;

//----------------------------------------------------------------------------
// DEFINE BEAM LINE

GS:  Line = (GUNSOURCE, GUN, BF, M);

// Complete accelerator
DRIVE: Line = (GS, DR1);

//----------------------------------------------------------------------------
// INITIAL DISTRIBUTION
//
// Flattop distribution.
// SIGMAX/Y:      RMS radius of transverse beam size (Laser radius in m).
// TRISE/FALL:    Rise time/fall time in longitudinal direction (s).
// TPULSEFWHM:    FWHM in longitudinal direction (s).
// CUTOFFLONG:    Longitudinal cuttoff in units of sigma.
// NBIN:          Number of energy bins to use during emission.
// EMISSIONSTEPS: Number of steps during emssion.
//                Emission time step is adjusted to fit this number.
// EKIN:          Kinetic energy of electrons at emission (eV).
// ELASER:        Energy of laser (eV).
// W:             Photocathode work functioin (eV).
// FE:            Fermi energy of photocathode (eV).
// CATHTEMP:      Operating temperature of photocathode (K).

// Note, ELASER, W, FE, and CATHTEMP are used for the NONEQUIL emission model.
// These values are not necessary when using other models.

// Note, If you want a Gaussian, in the longitudinal direction:
//      TRISE/FALL = 1.6869*simgar
//      Sigmar     = FWHM / 2.35 (this equation is only valid for 1.3 GHz)

Dist: DISTRIBUTION, TYPE = FROMFILE,
      FNAME = "DistAt2m.dat";

// Note on emission time step: FWHM pulse width divided by emission
// steps gives the time step for the emissions process.
// i.e 20.0e-12 / 100 gives a time step of 2e-13 (s) during emission.
// This is the not the same as the time step used in rest of the file.

//----------------------------------------------------------------------------
// Define Field solvers
// The mesh sizes should be a factor of 2
// for most efficient space charge calculation.

FS_SC: Fieldsolver, FSTYPE = FFT,
            MX = 16, MY = 16, MT = 16, // SC grid size is 32^3
            PARFFTX = false,
            PARFFTY = false,
            PARFFTT = true,  // parallel in the z direction only
            BCFFTX = open,
            BCFFTY = open,
            BCFFTT = open,
            BBOXINCR = 1,
            GREENSF = INTEGRATED;

//----------------------------------------------------------------------------
// Electron Beam Definition

BEAM1:  BEAM, PARTICLE = ELECTRON, pc = P0, NPART = n_particles,
        BFREQ = rf_freq, BCURRENT = beam_bunch_charge * rf_freq * 1e6, CHARGE = -1;

//----------------------------------------------------------------------------
// Simulate the beamline using TRACK and RUN.
// Note, different time steps are set based on the z location in the beam line.
// In the case below, 1.0e-13 is used for 0.0 to 0.4 m,
// and 3.0e-12 is used from 0.4 to 5 m.

TRACK, LINE = DRIVE, BEAM = BEAM1, MAXSTEPS = {17200, 1800},
    DT = {1.0e-13, 3.0e-12}, ZSTART = 2.0, ZSTOP = {0.0, 0.4};

RUN, METHOD = "PARALLEL-T", BEAM = BEAM1,
    FIELDSOLVER = FS_SC, DISTRIBUTION = Dist, TRACKBACK = TRUE;
ENDTRACK;

Stop;
Quit;