Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

z injection #82

Merged
merged 3 commits into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion wake_t/particles/particle_bunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class ParticleBunch():

def __init__(self, q, x=None, y=None, xi=None, px=None, py=None, pz=None,
bunch_matrix=None, matrix_type='standard', gamma_ref=None,
tags=None, prop_distance=0, t_flight=0, name=None):
tags=None, prop_distance=0, t_flight=0, z_injection=None,
name=None):
"""
Initialize particle bunch.

Expand Down Expand Up @@ -73,6 +74,9 @@ def __init__(self, q, x=None, y=None, xi=None, px=None, py=None, pz=None,
t_flight : float
Time of flight of the bunch along the beamline.

z_injection: float (in meters)
Particles have a ballistic motion for z<z_injection.

name : str
Name of the particle bunch. Used for species identification
in openPMD diagnostics.
Expand All @@ -96,6 +100,7 @@ def __init__(self, q, x=None, y=None, xi=None, px=None, py=None, pz=None,
self.tags = tags
self.prop_distance = prop_distance
self.t_flight = t_flight
self.z_injection = z_injection
self.x_ref = 0
self.theta_ref = 0
self.set_name(name)
Expand Down Expand Up @@ -315,6 +320,11 @@ def evolve(self, fields, t, dt, pusher='rk4'):
The particle pusher to use. Either 'rk4' or 'boris'. By
default 'rk4'.
"""

if self.z_injection is not None:
if (np.amax(self.xi) + self.prop_distance) < self.z_injection:
fields = []

if pusher == 'rk4':
apply_rk4_pusher(self, fields, t, dt)
elif pusher == 'boris':
Expand Down