% set various parameters for the run

% optional actions
    
    combine = 1;                % combine field maps?
    convert = 1;                % convert field maps to gdf?
    rungpt = 1;                 % run gpt?
    rungdftrans = 1;            % run gdftrans?
    calcemittance = 1;          % calculate emittance?
    setpauses = 0;              % pause after each figure?
    buildlosses = 1;            % build losses diagram?
    buildenergy = 1;            % build energy diagram?
    buildmov = 0;               % build movies?
    makemov = 1;                % save movie files?
    makelongitudinal = 1;       % build longitudinal profile movie?
    maketransverse = 1;         % build transvers profile movie?
    makephasex = 1;             % build x-phase movie?
    makephasey = 1;             % build y-phase movie?
    
% files

    rfqfiles = 'd:\mje\gpt\rfq\'; % location of gpt files, e.g. input.in
    fieldmapfile = 'fields.txt';    % name of field map file to be read/generated
    % inputfieldmaps is a cell array of filenames and starting points in z
    % these files are combined to form fieldmapfile if combine == 1 above
    inputfieldmaps = {'matching.txt', 0; 'rfq.txt', 21.8};
    %inputfieldmaps = {'matching.txt', 0; 'rfq-1.txt', 21.8; 'rfq-2.txt', 527.08; 'rfq-3.txt', 1032.36; 'rfq-4.txt', 2058.65; 'rfq-5.txt', 3063.37};
    
% tracking settings

    ffac = 1;                   % multiply field map by constant factor
    rfqfac = 1;                 % multiply z-coordinate by constant factor
    tsim = 5e-7;                % simulation time [s]
    tstep = 1e-9;               % simulation step time [s]
    zstep = 0.1;                % screen spacing [m]

% particle settings    
    
    disp('setting particle parameters') ;
    ma = 1.66053886e-27 ;       % atomic mass in kg
    m = 1.0083736 * ma ;        % mass of H-
    e = 1.602176487e-19 ;       % electron charge in C
    q = -1 * e ;                % H- ion
    nuc = 1;                	% single proton nucleon
    Eu = 65e3;                  % beam energy is 65 keV/u
    E0 = nuc * 65e3 ;           % total energy
    c = 299792458 ;             % speed of light

% beam settings

    disp('setting beam parameters') ;
    npart = 1000;               % number of particles
    current = 60e-3;            % beam current is 60 mA
    freq = 324e6;               % rf frequency is 324 MHz
    rfqend = 4.05968;           % z-position of end of rfq (m)
    slices = 500;               % number of time slices to include
    endslice = 482;             % slice at end of rfq
    screens = 41;               % number of screens / position slices
    rightscreen = 1;            % screen at end of rfq
   
% colour settings

    disp('setting colour parameters') ;
    ranges = 0:1:rfqend;        % length of colour range for losses diagram
    colloop = ('rgbcmy');       % colours to use
    asloop = ('x+o*sd^v><ph');
   
% plot settings

    energymax = 30;             % height of y axis in energy plots
    fps = 50;                   % frames per second for all movie files
    minenergy = 2.6e6;          % minimum energy to include for transmission [eV/u]
    mingraphenergy = 2.6e6;     % minimum energy to include for histogram [eV/u]