# This is an input file for GPT. It describes a situation where a monochromatic beam is
# travelling through a current loop

# Set the GPT license
GPTLICENSE=1251405651;

# Define the beam parameters
gamma = 1.92;
radius = 1e-3;
length = 1e-6;
number_of_particles = 1000;
total_charge = -10E-15;
#total_charge = 0;
initial_emittance = 1e-10;

#Radius and Current of Current Loop
#R=.01;
I=50000;
#Divisor used to scale timestep and lattice
#DVR = 10;

# Start the beam
setparticles("beam", number_of_particles, me, qe, total_charge);
setrxydist("beam", "u", radius/2, radius);
setphidist("beam", "u", 0, 2*pi);
setGdist("beam", "u", gamma, 0);
setzdist( "beam", "g", 0, length, 3, 3) ;

# Set its initial emittance to 1nm
setGBxdist("beam", "g", 0.0, 1e-3, 3.0, 3.0);
setGBxemittance("beam", initial_emittance);
setGBydist("beam", "g", 0.0, 1e-3, 3.0, 3.0);
setGByemittance("beam", initial_emittance);

#Current loop halfway through the beamline with radius R and Current I
solenoid("wcs","z",1.5/DVR*.857, R, I);

# Compute the emittance components
emittance_component("4d space charge","false");
emittance_component("4d beamline element","false");
emittance_component("4d non-force","false");

# Set the solver tolerance
dtmax = 1e-13/DVR;
accuracy(6);

# Print touts
tout(0.0, 1.05e-8/DVR, 5e-9/DVR);