Skip to content
Snippets Groups Projects
Commit 33b912a2 authored by Vadim Gubaidulin's avatar Vadim Gubaidulin
Browse files

-added a check on number of particles in a slice to prevent mean of empty slice warnings

parent f5d28a3a
No related branches found
No related tags found
1 merge request!280.8.0
...@@ -86,15 +86,16 @@ class TransverseSpaceCharge(Element): ...@@ -86,15 +86,16 @@ class TransverseSpaceCharge(Element):
x = bunch['x'][particle_ids] x = bunch['x'][particle_ids]
y = bunch['y'][particle_ids] y = bunch['y'][particle_ids]
mean_x, std_x = x.mean(), x.std() if len(x) != 0 and len(y) != 0:
mean_y, std_y = y.mean(), y.std() mean_x, std_x = x.mean(), x.std()
mean_y, std_y = y.mean(), y.std()
en_x, en_y = get_displaced_efield(self.efieldn,
bunch['x'][particle_ids], en_x, en_y = get_displaced_efield(self.efieldn,
bunch['y'][particle_ids], std_x, bunch['x'][particle_ids],
std_y, mean_x, mean_y) bunch['y'][particle_ids],
std_x, std_y, mean_x, mean_y)
kicks_x = prefactor * en_x * charge_density[bin_index]
kicks_y = prefactor * en_y * charge_density[bin_index] kicks_x = prefactor * en_x * charge_density[bin_index]
bunch['xp'][particle_ids] += kicks_x kicks_y = prefactor * en_y * charge_density[bin_index]
bunch['yp'][particle_ids] += kicks_y bunch['xp'][particle_ids] += kicks_x
bunch['yp'][particle_ids] += kicks_y
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment