xtb icon indicating copy to clipboard operation
xtb copied to clipboard

Numerical stability of gradients

Open foxtran opened this issue 3 months ago • 5 comments

Describe the bug I'm playing with the system from Issue #1338 and I see after optimizations different results:

OUT.1:          | TOTAL ENERGY             -527.462303250991 Eh   |
OUT.2:          | TOTAL ENERGY             -527.462298371078 Eh   |
OUT.3:          | TOTAL ENERGY             -527.462286086233 Eh   |
OUT.mod.1:          | TOTAL ENERGY             -527.462288154660 Eh   |
OUT.mod.2:          | TOTAL ENERGY             -527.462298371078 Eh   |

To Reproduce Steps to reproduce the behaviour:

  1. Take input from #1338.
  2. cmake -Bbuild -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=gfortran -DWITH_CPCMX=OFF -DWITH_TBLITE=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_Fortran_FLAGS="-g"
  3. OMP_NUM_THREADS=4 OMP_PLACES=24-27 ../xtb -P 4 --gfn 2 test.xyz --opt --alpb water
  4. See description

Please provide all input and output file such that we confirm your report.

Expected behaviour Results should be more consistent between runs.

Additional context OUT.mod.* related to some changes for decreasing OMP stack usage. 40 kb is enough for this build. OUT.*2 runned with 1 OMP thread.

GCC 14.1 + MKL 2024.2.1

foxtran avatar Nov 07 '25 18:11 foxtran

Does the same happen if one uses tblite for the energy/gradient evaluation?

thfroitzheim avatar Nov 08 '25 20:11 thfroitzheim

How can I test?

toxtran avatar Nov 08 '25 20:11 toxtran

Just runn the same calculations with the --tblite flag to use the xtb implementation in tblite (I think currently you have to leave out the --alpb water since we haven't updated the interface. With low OMP stacksize and different numbers of OMP threads tblite should yield consistently the same result.

thfroitzheim avatar Nov 08 '25 20:11 thfroitzheim

Looks like the problem comes from alpb :(

Without alpb, the results are consistent between runs.

foxtran avatar Nov 08 '25 21:11 foxtran

That is strange. Are the results also consistent in xtb without ALPB (so without using tblite)? Since it is the result of the geometry optimization, we cannot directly check with the ALPB in tblite (maybe via CREST), but this is should be checked once we have the interface to tblite with solvation

thfroitzheim avatar Nov 08 '25 21:11 thfroitzheim