Skip to content

Fixes some errors obtained by valgrind+verrou

Nicolas Tancogne-Dejean requested to merge fix_verrou into hotfix-14.1

Description

Fixes some errors obtained by valgrind+verrou

  • Avoid computing the Legendre polynomial for values outside of [-1:1]. This is fixed by imposing the bounds on the routine argument.
  • Fix a rounding error in which 2/3+2/3+2/3 -> 2.0000000000000004 occupations in C leads to loosing 2 electrons because int((4.0-2.0000000000000004)/2) = 0 whereas the expected result is 1. This is fixed using nint instead of int.

Both of the errors were obtained for the test finite_system_3d/01-carbon_atom.01-psf_l0.inp.

  • Further problems have been found by running the test lda_u/01-nio.01-U5-gs.inp. These are mostly comparisons that are unstable upon adding or not 1e-16 digits, and could lead to GSL errors, NaN, or unpredictable recomputation of a submesh or not depending on equal floating-point comparison.

  • The number of boundary points, given by the stencil star general was not robust against rounding errors. This is fixed by introducing a small tolerance

  • The magnetic moments and the number of points in the submesh was found to be unstable. This is solved by adding some tolerances.

  • Fix some bugs with the splines. The debug routine were accessing points outside of the spline range, and the splines_div routine was wrong, as it was not changing the number of points in the spline. This was causing the pseudopotential filtering to be wrong and quite unstable numerically.

With the last set of changes, verrou reports identical stout for the test lda_u/01-nio.01-U5-gs.inp, showing an increased robustness again round-off errors.

News snippet

Fix some floating-point instabilities and minor bugs in the code.

Checklist

  • I have checked that my code follows the Octopus coding standards
  • I have added tests for all the new features added in this request.
Edited by Nicolas Tancogne-Dejean

Merge request reports