grimme-lab / xtb

Semiempirical Extended Tight-Binding Program Package
https://xtb-docs.readthedocs.io/
GNU Lesser General Public License v3.0
567 stars 142 forks source link

GFN1 fails for PBC optimisation #536

Open benedictsaunders opened 2 years ago

benedictsaunders commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behaviour:

  1. happens with input (include input files) POSCAR file
    Generated by cif2cell 2.0.0. Na Cl :  Abrahams, S C and Bernstein, J L, Acta Crystallographica (1,1948-23,1967) 18, 926-932 (1965). Species order: Na Cl
    5.620000
    0.000000000000000   0.500000000000000   0.500000000000000
    0.500000000000000   0.000000000000000   0.500000000000000
    0.500000000000000   0.500000000000000   0.000000000000000
    Na  Cl
    1   1
    Direct
    0.000000000000000   0.000000000000000   0.000000000000000
    0.500000000000000   0.500000000000000   0.500000000000000
  2. start xtb with POSCAR --gfn 1 --opt

    
          |                Calculation Setup                |
           -------------------------------------------------
    
          program call               : xtb POSCAR --gfn 1 --opt
          hostname                   : zx81.csc.warwick.ac.uk
          coordinate file            : POSCAR
          omp threads                :                     1
          number of atoms            :                     2
          number of electrons        :                     8
          charge                     :                     0
          spin                       :                   0.0
          first test random number   :      0.00554113810463
    
    ID    Z sym.   atoms
    1   11 Na     1
    2   17 Cl     2

molecular fragmentation (1/2 indicates fragments): 12

atoms in fragment 1/2: 1 1

fragment masses (1/2) : 22.99 35.45 CMA distance (Bohr) : 9.197 constraining FC (au) : 0.0500

       -------------------------------------------------
      |                 G F N 1 - x T B                 |
       -------------------------------------------------

    Reference                      10.1021/acs.jctc.7b00118
  * Hamiltonian:
    H0-scaling (s, p, d)           1.850000    2.250000    2.000000
    zeta-weighting                 0.000000
  * Dispersion:
    s8                             2.400000
    a1                             0.630000
    a2                             5.000000
    s9                             0.000000
  * Repulsion:
    kExp                           1.500000
    rExp                           1.000000
  * Coulomb:
    alpha                          2.000000
    third order                    atomic
    anisotropic                    false
  * Halogen bond correction:
    rad-scale                      1.300000
    damping                        0.440000

      ...................................................
      :                      SETUP                      :
      :.................................................:
      :  # basis functions                  14          :
      :  # atomic orbitals                  13          :
      :  # shells                            5          :
      :  # electrons                         8          :
      :  # halogen bonds                     0          :
      :  max. iterations                   250          :
      :  Hamiltonian                  GFN1-xTB          :
      :  restarted?                      false          :
      :  GBSA solvation                  false          :
      :  PC potential                    false          :
      :  electronic temp.          300.0000000     K    :
      :  accuracy                    1.0000000          :
      :  -> integral cutoff          0.2500000E+02      :
      :  -> integral neglect         0.1000000E-07      :
      :  -> SCF convergence          0.1000000E-05 Eh   :
      :  -> wf. convergence          0.2000000E-04 e    :
      :  Broyden damping             0.4000000          :
      ...................................................

iter E dE RMSdq gap omega full diag ######################################################################## [ERROR] Program stopped due to fatal error -6- Single point calculation terminated -5- xtb_calculator_singlepoint: Electronic structure method terminated -4- scf: Self consistent charge iterator terminated -3- scc_core: Diagonalization of Hamiltonian failed -2- mctc_lapack_sygvd: Failed to solve eigenvalue problem -1- mctc_lapack_potrf: Factorisation of matrix failed ######################################################################## abnormal termination of xtb

3. run `xtb` with your options and the `--verbose` flag
      |                Calculation Setup                |
       -------------------------------------------------

      program call               : xtb POSCAR --gfn 1 --opt --verbose
      hostname                   : zx81.csc.warwick.ac.uk
      coordinate file            : POSCAR
      xtbhome directory          : /home/chem/msrzvr
      path for xtb               : /home/chem/msrzvr
      xcontrol input file        : POSCAR
      omp threads                :                     1
      number of atoms            :                     2
      number of electrons        :                     8
      charge                     :                     0
      spin                       :                   0.0
      first test random number   :      0.89988904096678
      a pointer address          :            0x3F665F21
      random memory content      :      3FECCBE41A1F6569

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ CONSTRAINTS & SCANS: DEBUG SECTION $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ID Z sym. atoms 1 11 Na 1 2 17 Cl 2 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

molecular fragmentation (1/2 indicates fragments): 12

atoms in fragment 1/2: 1 1

fragment masses (1/2) : 22.99 35.45 CMA distance (Bohr) : 9.197 constraining FC (au) : 0.0500

       -------------------------------------------------
      |                 G F N 1 - x T B                 |
       -------------------------------------------------

    Reference                      10.1021/acs.jctc.7b00118
  * Hamiltonian:
    H0-scaling (s, p, d)           1.850000    2.250000    2.000000
    zeta-weighting                 0.000000
  * Dispersion:
    s8                             2.400000
    a1                             0.630000
    a2                             5.000000
    s9                             0.000000
  * Repulsion:
    kExp                           1.500000
    rExp                           1.000000
  * Coulomb:
    alpha                          2.000000
    third order                    atomic
    anisotropic                    false
  * Halogen bond correction:
    rad-scale                      1.300000
    damping                        0.440000

      ...................................................
      :                      SETUP                      :
      :.................................................:
      :  # basis functions                  14          :
      :  # atomic orbitals                  13          :
      :  # shells                            5          :
      :  # electrons                         8          :
      :  # halogen bonds                     0          :
      :  max. iterations                   250          :
      :  Hamiltonian                  GFN1-xTB          :
      :  restarted?                      false          :
      :  GBSA solvation                  false          :
      :  PC potential                    false          :
      :  electronic temp.          300.0000000     K    :
      :  accuracy                    1.0000000          :
      :  -> integral cutoff          0.2500000E+02      :
      :  -> integral neglect         0.1000000E-07      :
      :  -> SCF convergence          0.1000000E-05 Eh   :
      :  -> wf. convergence          0.2000000E-04 e    :
      :  Broyden damping             0.4000000          :
      ...................................................

iter E dE RMSdq gap omega full diag ######################################################################## [ERROR] Program stopped due to fatal error -6- Single point calculation terminated -5- xtb_calculator_singlepoint: Electronic structure method terminated -4- scf: Self consistent charge iterator terminated -3- scc_core: Diagonalization of Hamiltonian failed -2- mctc_lapack_sygvd: Failed to solve eigenvalue problem -1- mctc_lapack_potrf: Factorisation of matrix failed ######################################################################## abnormal termination of xtb

4. output showing the error

######################################################################## [ERROR] Program stopped due to fatal error -6- Single point calculation terminated -5- xtb_calculator_singlepoint: Electronic structure method terminated -4- scf: Self consistent charge iterator terminated -3- scc_core: Diagonalization of Hamiltonian failed -2- mctc_lapack_sygvd: Failed to solve eigenvalue problem -1- mctc_lapack_potrf: Factorisation of matrix failed ########################################################################


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

**Expected behaviour**
Geometry to optimise and xtb to terminate normally.

**Additional context**
As suggested [here](https://github.com/grimme-lab/xtb/issues/326), tried using `--gfn 0` but received error `Parameter file param_gfn0-xtb.txt not found!` The error was first found with a more complex geometry input:

Generated by cif2cell 2.0.0. : Failed to get author information, No journal information. Species order: Nb O V S Li 5.943760 1.000000000000000 0.000000000000000 0.000000000000000 -0.492346036937469 0.877386200126650 0.000000000000000 0.491429882902069 0.242903566922128 0.843787021819361 Nb O V S Li 2 2 2 6 4 Direct 0.500010000000000 0.500010000000000 0.500000000000000 -0.000020000000000 0.499960000000000 0.500010000000000 0.506900000000000 0.242560000000000 0.252560000000000 0.466700000000000 0.724950000000000 0.288280000000000 0.499990000000000 -0.000010000000000 0.500000000000000 0.000000000000000 0.500010000000000 0.000000000000000 0.997000000000000 0.254570000000000 0.243660000000000 0.003000000000000 0.745420000000000 0.756330000000000 0.493080000000000 0.757450000000000 0.747450000000000 0.533320000000000 0.275060000000000 0.711710000000000 0.963890000000000 0.710660000000000 0.276340000000000 0.036120000000000 0.289350000000000 0.723660000000000 0.249030000000000 0.055450000000000 0.055550000000000 0.750980000000000 0.944570000000000 0.944450000000000 0.500010000000000 0.500010000000000 -0.000010000000000 -0.000010000000000 0.000000000000000 0.500010000000000


Used NaCl as a simple multielement input, to no avail (see above).

Thanks for any help
awvwgk commented 2 years ago

I'm currently working on solution in https://github.com/dftbplus/dftbplus/pull/862, this might be an option to try.

gavinwinter commented 2 years ago

Are there any updates on this issue regarding xTB calculations in the native xtb interface for periodic systems? The SCC calculation with GFN1-xTB does not work. (I receive the same error as the OP.) Currently, it seems that the dftb+ interface is the only way to use xtb. Unfortunately, dftb+ to drive a xTB Hamiltonian is very slow (about 1.5 SCC steps per minute), whereas the same size system as a non-periodic molecule in the native xtb interface is about a second per SCC step. Despite trying several parallelization options for dftb+ (with OMP and MPI), it is still very slow.

awvwgk commented 2 years ago

Indeed, using DFTB+ to drive calculations using the xTB Hamiltonian introduces an overhead, my checks did show at least a factor of two slowdown with DFTB+ compared to xtb or tblite for molecular system, which is unfortunate. I raised this issue with the DFTB+ team, but the issue is rooted somewhat deep in the design of the sparse representation of the Hamiltonian.

On the other hand, for periodic calculations the difference to finite calculation is mainly originating from the calculation of the integrals as well as the Ewald summation and dispersion interactions, however those do not impact the performance of the self-consistent iterations for Γ-point periodic calculations. A quick check with DFTB+ (Γ-only), tblite and xtb for a CO2 molecular crystals shows similar runtimes are all three programs (Intel 2022, Release mode with -axAVX2 -Ofast -march=core-avx2 -fma, MKL), but I will do some proper profiling to check for bottlenecks in tblite.

I'm planning to introduce Γ-point periodic xTB in xtb via the tblite library in the course of this year before finishing my thesis. The full periodic boundary condition support, namely k-point sampling and lattice optimizations, will rely on the infrastructure available in DFTB+, since implementing this from scratch is time-consuming and error-prone.

This are my goals for enabling xTB with PBCs, of course this is not the only solution. This project as well as DFTB+ are open-source projects and contributions are always welcome. I'm also happy to provide pointers to the implementation in either xtb, tblite or DFTB+ regarding xTB with PBCs.

WentongZhou commented 2 years ago

Hi,

Have you tried to use xTB-GFN 1 in CP2K package for periodic systems? It works for my systems.


发件人: gavinwinter @.> 发送时间: 2022年5月10日 16:35 收件人: grimme-lab/xtb @.> 抄送: Subscribed @.***> 主题: Re: [grimme-lab/xtb] GFN1 fails for PBC optimisation (Issue #536)

Are there any updates on this issue regarding xTB calculations in the native xtb interface for periodic systems? The SCC calculation with GFN1-xTB does not work. (I receive the same error as the OP.) Currently, it seems that the dftb+ interface is the only way to use xtb. Unfortunately, dftb+ to drive a xTB Hamiltonian is very slow (about 1.5 SCC steps per minute), whereas the same size system as a non-periodic molecule in the native xtb interface is about a second per SCC step. Despite trying several parallelization options for dftb+ (with OMP and MPI), it is still very slow.

― Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/grimme-lab/xtb/issues/536*issuecomment-1122835222__;Iw!!IrdRlI43zQ!d0fDMtLvg6ESbqIc4G1eS278HOMj_2v1bfb5AIl1JA0S0QYS0b2KoLab0Mx_I5tUzpO5IBUbQQhN6zzc-QOhLUBSQhwo1CNICUE$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/APN7ZMOUOEISC3PNVLSQZADVJLCAJANCNFSM5H5HK4EA__;!!IrdRlI43zQ!d0fDMtLvg6ESbqIc4G1eS278HOMj_2v1bfb5AIl1JA0S0QYS0b2KoLab0Mx_I5tUzpO5IBUbQQhN6zzc-QOhLUBSQhwoBfJwwuE$. You are receiving this because you are subscribed to this thread.Message ID: @.***>

gavinwinter commented 2 years ago

Hi, Have you tried to use xTB-GFN 1 in CP2K package for periodic systems? It works for my systems. ____ 发件人: gavinwinter @.> 发送时间: 2022年5月10日 16:35 收件人: grimme-lab/xtb @.> 抄送: Subscribed @.> 主题: Re: [grimme-lab/xtb] GFN1 fails for PBC optimisation (Issue #536) Are there any updates on this issue regarding xTB calculations in the native xtb interface for periodic systems? The SCC calculation with GFN1-xTB does not work. (I receive the same error as the OP.) Currently, it seems that the dftb+ interface is the only way to use xtb. Unfortunately, dftb+ to drive a xTB Hamiltonian is very slow (about 1.5 SCC steps per minute), whereas the same size system as a non-periodic molecule in the native xtb interface is about a second per SCC step. Despite trying several parallelization options for dftb+ (with OMP and MPI), it is still very slow. ― Reply to this email directly, view it on GitHub<[https://urldefense.com/v3/__https://github.com/grimme-lab/xtb/issues/536issuecomment-1122835222;Iw!!IrdRlI43zQ!d0fDMtLvg6ESbqIc4G1eS278HOMj_2v1bfb5AIl1JA0S0QYS0b2KoLab0Mx_I5tUzpO5IBUbQQhN6zzc-QOhLUBSQhwo1CNICUE$](https://urldefense.com/v3/https://github.com/grimme-lab/xtb/issues/536*issuecomment-1122835222__;Iw!!IrdRlI43zQ!d0fDMtLvg6ESbqIc4G1eS278HOMj_2v1bfb5AIl1JA0S0QYS0b2KoLab0Mx_I5tUzpO5IBUbQQhN6zzc-QOhLUBSQhwo1CNICUE%24)>, or unsubscribe<https://urldefense.com/v3/https://github.com/notifications/unsubscribe-auth/APN7ZMOUOEISC3PNVLSQZADVJLCAJANCNFSM5H5HK4EA;!!IrdRlI43zQ!d0fDMtLvg6ESbqIc4G1eS278HOMj_2v1bfb5AIl1JA0S0QYS0b2KoLab0Mx_I5tUzpO5IBUbQQhN6zzc-QOhLUBSQhwoBfJwwuE$>. You are receiving this because you are subscribed to this thread.Message ID: *@.>

Hi Wentong, thanks for your response. How large is your system and how long does it take to complete one SC step with xTB-GFN1 in CP2K?

gavinwinter commented 2 years ago

Got it. That makes sense. Thank you for your response.

Indeed, using DFTB+ to drive calculations using the xTB Hamiltonian introduces an overhead, my checks did show at least a factor of two slowdown with DFTB+ compared to xtb or tblite for molecular system, which is unfortunate. I raised this issue with the DFTB+ team, but the issue is rooted somewhat deep in the design of the sparse representation of the Hamiltonian.

On the other hand, for periodic calculations the difference to finite calculation is mainly originating from the calculation of the integrals as well as the Ewald summation and dispersion interactions, however those do not impact the performance of the self-consistent iterations for Γ-point periodic calculations. A quick check with DFTB+ (Γ-only), tblite and xtb for a CO2 molecular crystals shows similar runtimes are all three programs (Intel 2022, Release mode with -axAVX2 -Ofast -march=core-avx2 -fma, MKL), but I will do some proper profiling to check for bottlenecks in tblite.

I'm planning to introduce Γ-point periodic xTB in xtb via the tblite library in the course of this year before finishing my thesis. The full periodic boundary condition support, namely k-point sampling and lattice optimizations, will rely on the infrastructure available in DFTB+, since implementing this from scratch is time-consuming and error-prone.

This are my goals for enabling xTB with PBCs, of course this is not the only solution. This project as well as DFTB+ are open-source projects and contributions are always welcome. I'm also happy to provide pointers to the implementation in either xtb, tblite or DFTB+ regarding xTB with PBCs.