Skip to content

Commit 73bd664

Browse files
author
alexander
committed
generation of electron beams
1 parent dc6917a commit 73bd664

File tree

2 files changed

+5
-150
lines changed

2 files changed

+5
-150
lines changed

setsim/.ipynb_checkpoints/setsim-checkpoint.py

-144
This file was deleted.

setsim/setsim.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,22 @@ def make_plasma(lcode, n_plasma, plasma_length, plasma_radius, n_profile):
8080
#------------------------------
8181
# Beamfile construction module
8282
#------------------------------
83-
def Q2I(Q, sigma_z): # SI (return Amps)
83+
def Q2I(Q, sigma_z): # SI (returns Amps)
8484
return c/100. * Q / np.sqrt(2*np.pi) / sigma_z
85-
def make_beam(lcode, sigma_z, pos_xi, sigma_r, gamma, enspread, emittance, N_particles):
85+
def make_beam(lcode, sigma_z, pos_xi, sigma_r, p0, enspread, emittance, N_particles, q_m=m_MeV/M_MeV, q_e=1):
8686
print("# BEAM")
87-
q_m = m_MeV/M_MeV
8887
# xi
8988
xi_shape = Gauss(pos_xi, sigma_z)
9089
# r
9190
r_shape = rGauss(sigma_r)
9291
# pz
93-
pz_shape = Gauss(gamma, enspread)
92+
pz_shape = Gauss(p0, enspread)
9493
# angle
95-
angspread = emittance / (gamma / (M_MeV/m_MeV) * sigma_r)
94+
angspread = emittance / (p0 * q_m * sigma_r)
9695
#print('%e' % angspread)
9796
ang_shape = Gauss(0, angspread)
9897
# current
99-
Ipeak_A = Q2I(N_particles*e/3e9, sigma_z*lcode.cwp/100)
98+
Ipeak_A = Q2I(N_particles*e*q_e/3e9, sigma_z*lcode.cwp/100)
10099
Ipeak_kA = Ipeak_A/1000
101100
print('Peak current {:.2f} A'.format(Ipeak_A))
102101
lcode.beam = lcode.make_beam(xi_shape, r_shape, pz_shape, ang_shape, Ipeak_kA, q_m, saveto=lcode.path)

0 commit comments

Comments
 (0)