PartBunch::get_bounds can produce NaNs
While trying to update the PSI-Ring simulations to the master branch, I encountered the following running error:
OPAL> PartBunch.cpp: 1574 nan 2.000000e-02
Error>
Error> *** User error detected by function "PartBunch::boundp() "
Error> *** in line 311 of file "Ring.in":
Error> RUN,METHOD="CYCLOTRON-T",BEAM=BEAM1,FIELDSOLVER=FS1,DISTRIBUTION=DIST;
Error> h<0, can not build a mesh
The nan
gets introduced in line 1521: get_bounds(rmin_m, rmax_m);
Printing out rmax and rmin before and after this line gives (ymmv):
before:
(i,rmax, rmin) 0 0.0000000000000000e+00 0.0000000000000000e+00
(i,rmax, rmin) 1 0.0000000000000000e+00 0.0000000000000000e+00
(i,rmax, rmin) 2 0.0000000000000000e+00 0.0000000000000000e+00
after
(i,rmax, rmin) 0 7.1153710538428058e-03 -6.9640951722910538e-03
(i,rmax, rmin) 1 4.0421699390708048e-02 -4.0512781208033796e-02
(i,rmax, rmin) 2 -nan -nan
I likely do something wrong with my input, but I believe the code should not get this far and produce a better error message.
This can be reproduced with OPAL master (0469d1ac), and the latest version of PSI-Ring and executing runOpal --nobatch
Edit 20 July:
#110 (comment 1914): Simplified input file Ring.in
#110 (comment 1916): Regression test RingCyclotron
has the same bug when one changes the distribution from gauss to either single particle or binomial.