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

Fixed bug in beam.eliminate-lost-particles. #205

Merged
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
9 changes: 5 additions & 4 deletions blond/beam/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,13 @@ def eliminate_lost_particles(self):
"""

indexalive = np.where(self.id != 0)[0]
if len(indexalive) < self.n_macroparticles:
if len(indexalive) > 0:
self.dt = np.ascontiguousarray(
self.dt[indexalive], dtype=bm.precision.real_t, order='C')
self.dt[indexalive], dtype=bm.precision.real_t)
self.dE = np.ascontiguousarray(
self.dE[indexalive], dtype=bm.precision.real_t, order='C')
self.n_macroparticles = len(self.beam.dt)
self.dE[indexalive], dtype=bm.precision.real_t)
self.n_macroparticles = len(self.dt)
self.id = np.arange(1, self.n_macroparticles + 1, dtype=int)
else:
# AllParticlesLost
raise RuntimeError("ERROR in Beams: all particles lost and" +
Expand Down