nikolasibalic / ARC-Alkali-Rydberg-Calculator

Object-oriented Python library for computation of properties of highly-excited Rydbeg states of alkali and divalent atoms.
https://atomcalc.org
BSD 3-Clause "New" or "Revised" License
86 stars 72 forks source link

getRadialMatrixElement() may return wrong results for float input parameters #140

Closed rsruster closed 1 year ago

rsruster commented 1 year ago

In getRadialMatrixElement(), the input parameters are converted to integer via a typecast:

https://github.com/nikolasibalic/ARC-Alkali-Rydberg-Calculator/blob/265fa0a9c06f95fa9225445aa87502c0a5f812f1/arc/alkali_atom_functions.py#L800-L805

This can lead to rounding errors when passing floating point numbers. For example, the value 39.99999999999 will be converted to 39 instead of 40. I suggest to use round() instead (which already converts to integer, so no subsequent typecast needed).

This behavior also occurs in other functions such as getQuadrupoleMatrixElement()