Open jminuse opened 1 year ago
Update: with a clean install of the latest xtb-python, this script gives the output "Failed, Energy is NaN" only for GFN1-xTB and GFN0-xTB. GFN2-xTB now raises the appropriate exception, "scf: Self consistent charge iterator did not converge", and none of the methods give an incorrect net charge. However, it would still be nice to have appropriate handling of a NaN energy (possibly related to https://github.com/grimme-lab/xtb-python/issues/80).
Another example: with the latest xtb-python, the following system returns non-finite values for the gradient in GFN0-xTB & GFN2-xTB. With GFN0-xTB, the gradient is an array of mixed np.inf and -np.inf, while with GFN2-xTB, the gradient is all NaN.
atomic_numbers = np.array([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])
xyz = np.array([[ 0.305, 1.818, 2.417],
[-1.227, 0.658, -2.75 ],
[ 0.021, 2.861, 0.379],
[-1.928, 1.384, 0.584],
[-1.211, 2.915, -1.727],
[ 0.72 , 1.346, -1.534],
[-1.089, -0.193, 2.436],
[ 1.151, -0.511, -2.935],
[-0.115, -0.055, 0.266],
[-1.341, -2.106, 1.163],
[-2.026, -0.473, -0.915],
[-0.122, -2.054, -1.216],
[ 1.956, 1.279, 0.876],
[ 3.207, 1.115, -1.338],
[ 1.125, -0.637, 2.324],
[ 3.241, -0.997, 1.191],
[ 1.39 , -2.447, 0.827],
[ 1.987, -0.837, -0.745],
[-3.279, -0.566, 1.313],
[-2.764, -2.499, -0.615]])
charge = 0
uhf = 0
Energy, charge, and dipole all appear perfectly normal. With GFN1-xTB, or the DFT functional wB97X-D3BJ/def2-TZVPD in Psi4, this system is fine, so I don't think there's any physical reason for it to give invalid gradients. In any case, I would think it should throw an exception rather than silently return non-finite values.
Describe the bug
For some inputs, xtb-python produces impossible outputs which are not handled as errors.
To Reproduce
This is a script to demonstrate unhandled xTB errors for simple cubes. The command line arguments are atomic number and grid spacing (in Angstroms) for a cube of the given element. Metals tend to be more unstable.
Example input:
python xtb_huge_error.py 3 2.7
Output:Expected behaviour
These error conditions should be handled within xtb or xtb-python, rather than requiring user checks. Probably the most alarming error here is
Bad net charge: 1 vs 0.412483
, where a significant fraction of an electron has appeared from nowhere.Additional context
GFN1-xTB and GFN0-xTB don't have the same problems with bad net charges or implausible partial charges, but they can still give NaN for energy.