grimme-lab / xtb-python

Python API for the extended tight binding program package
https://xtb-python.readthedocs.io
GNU Lesser General Public License v3.0
99 stars 30 forks source link

calculation that worked on 20.1 is failing on later versions #105

Open stenczelt opened 1 year ago

stenczelt commented 1 year ago

Describe the bug

A single point calculation that completed on version v20.1 cannot be evaluated with v20.2 and v22.1. This is a specific example, a pair of OH separated by 4Å, seen as part of re-evaluating an earlier MD run which then worked nicely but re-evaluating it has failed. See a simplified input below with a specific example.

To Reproduce

Run the following script with version v20.1 and v20.2/v22.1

import ase.io
from xtb.ase.calculator import XTB

at = ase.Atoms(
    numbers=[8, 1, 8, 1],
    positions=[
        [0.0, 0.0, 0.0],
        [0.0, -1.0, -0.1],
        [4.0, 0.0, 0.0],
        [4.5, 0.0, 0.0],
    ],
)

at.calc = XTB()

print("calculator parameters:", at.calc.parameters)
print(at.get_potential_energy())
print(at.get_forces())

On v20.1: (xtb 6.3.3)

calculator parameters: {'method': 'GFN2-xTB', 'accuracy': 1.0, 'max_iterations': 250, 'electronic_temperature': 300.0, 'solvent': 'None', 'cache_api': True}
-214.44720907410627
[[-3.96791193e-02 -1.37415655e+00  4.02421008e-07]
 [ 4.04500519e-02  1.39420829e+00 -6.16613596e-06]
 [-1.98186104e+02 -4.99697091e-02 -5.89461047e-05]
 [ 1.98185333e+02  2.99179612e-02  6.47098196e-05]]

On v20.2 & v22.1: (xtb 6.5.0 & 6.5.1)

calculator parameters: {'method': 'GFN2-xTB', 'accuracy': 1.0, 'max_iterations': 250, 'electronic_temperature': 300.0, 'solvent': 'None', 'cache_api': True}
Traceback (most recent call last):
  File "/home/tks32/.conda/envs/xtb-20.2/lib/python3.8/site-packages/xtb/ase/calculator.py", line 231, in calculate
    self._res = self._xtb.singlepoint(self._res)
  File "/home/tks32/.conda/envs/xtb-20.2/lib/python3.8/site-packages/xtb/interface.py", line 814, in singlepoint
    raise XTBException(self.get_error("Single point calculation failed"))
xtb.interface.XTBException: Single point calculation failed:
-2- xtb_calculator_singlepoint: Electronic structure method terminated
-1- scf: Self consistent charge iterator did not converge

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "xtb-debug-1.py", line 20, in <module>
    print(at.get_potential_energy())
  File "/home/tks32/.conda/envs/xtb-20.2/lib/python3.8/site-packages/ase/atoms.py", line 731, in get_potential_energy
    energy = self._calc.get_potential_energy(self)
  File "/home/tks32/.conda/envs/xtb-20.2/lib/python3.8/site-packages/ase/calculators/calculator.py", line 709, in get_potential_energy
    energy = self.get_property('energy', atoms)
  File "/home/tks32/.conda/envs/xtb-20.2/lib/python3.8/site-packages/ase/calculators/calculator.py", line 737, in get_property
    self.calculate(atoms, [name], system_changes)
  File "/home/tks32/.conda/envs/xtb-20.2/lib/python3.8/site-packages/xtb/ase/calculator.py", line 233, in calculate
    raise ase_calc.CalculationFailed("xtb could not evaluate input")
ase.calculators.calculator.CalculationFailed: xtb could not evaluate input

Both tested with the same ubuntu machine using Conda, see env files below, and re-tried on MacOS (Intel & M2 as well) for the latest version.

Expected behaviour

Would expect the calculation to be successful on the later versions as well.

Additional context

conda info:


     active environment : xtb-22.1
    active env location : /home/tks32/.conda/envs/xtb-22.1
            shell level : 10
       user config file : /home/tks32/.condarc
 populated config files : /opt/womble/miniconda3/.condarc
          conda version : 23.1.0
    conda-build version : not installed
         python version : 3.8.5.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.27=0
                          __linux=5.4.0=0
                          __unix=0=0
       base environment : /opt/womble/miniconda3  (writable)
      conda av data dir : /opt/womble/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /opt/womble/miniconda3/pkgs
                          /home/tks32/.conda/pkgs
       envs directories : /home/tks32/.conda/envs
                          /opt/womble/miniconda3/envs
               platform : linux-64
             user-agent : conda/23.1.0 requests/2.28.1 CPython/3.8.5 Linux/5.4.0-42-generic ubuntu/18.04.6 glibc/2.27
                UID:GID : 220009:13000
             netrc file : None
           offline mode : False

xtb-20.1.yaml.txt xtb-20.2.yaml.txt xtb-22.1.yaml.txt

awvwgk commented 1 year ago

Does the SCF converge with 20.1 or is the error just not reported back to Python and the unconverted energy is returned?

stenczelt commented 1 year ago

How can I determine that when running the above snippet? Forces are returned, not sure if that's any indication.

awvwgk commented 1 year ago

You can increase the verbosity of the calculator or use the API provided in xtb.interface.