atcollab / at

Accelerator Toolbox
Apache License 2.0
48 stars 31 forks source link

python get_1d_acceptance: return 0.0 instead of error if no particle survives #702

Closed simoneliuzzo closed 7 months ago

simoneliuzzo commented 7 months ago

presently if at one of the refpts of get_1d_acceptance all particles are lost, an error is returned.

a warning and ZERO acceptance could be a beeter choice. expecially for lattices that have strongly varying grids along s, that may not be given as input.

simoneliuzzo commented 7 months ago

Here an example of lengthy computation being junked by this error:

Running grid boundary search:
Element DR_015, obspt=40
The grid mode is GridMode.CARTESIAN
The planes are ['xp']
Number of steps are [100]
The maximum amplitudes are [0.001]
The maximum boundaries are ((-1, 1),)
The initial offset is [ 1.35857499e-03 -5.09479172e-05 -5.15650716e-03 -1.03736928e-04
  0.00000000e+00  0.00000000e+00] with dp=None
Calculation took 6.80971097946167

Running grid boundary search:
Element DR_015, obspt=50
The grid mode is GridMode.CARTESIAN
The planes are ['xp']
Number of steps are [100]
The maximum amplitudes are [0.001]
The maximum boundaries are ((-1, 1),)
The initial offset is [nan nan nan nan  0.  0.] with dp=None
**No particle survived, please check your grid or lattice.**
evaluation of AngularAcceptance failed

I may change the ranges, but they will become too small for other locations. So, ZERO acceptance would be a rather good approximation of the correct result.

It is not clear to me why the initial offset at obspt=50 is nan nan nan... In any case I would prefer a zero to stopping the computation.

swhite2401 commented 7 months ago

Fixed in #716