Skip to content

Commit

Permalink
avoid divide by 0 if no parts in bunch
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Carver committed May 23, 2024
1 parent 59493cc commit 941ba72
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion atintegrators/atimplib.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ static void slice_bunch(double *r_in,int num_particles,int nslice,int nturns,
zpos[i] += bunch_spos[ib]-bunch_spos[nbunch-1];
xpos[i] = (weight[i]>0.0) ? xpos[i]/weight[i] : 0.0;
ypos[i] = (weight[i]>0.0) ? ypos[i]/weight[i] : 0.0;
weight[i] *= bunch_currents[ib]/np_bunch[ib];
if (np_bunch[ib] == 0.0) {
weight[i] = 0.0;
}
else {
weight[i] *= bunch_currents[ib]/np_bunch[ib];
}
}
atFree(np_bunch);
atFree(smin);
Expand Down

0 comments on commit 941ba72

Please sign in to comment.