dftd3 / simple-dftd3

reimplementation of the DFT-D3 program
https://dftd3.readthedocs.io
GNU Lesser General Public License v3.0
51 stars 24 forks source link

Periodic systems calculated as non-periodic in PySCF #73

Closed aizvorski closed 1 month ago

aizvorski commented 1 month ago

It seems that, when using simple-dftd3's PySCF interface, periodic systems are calculated as though they were non-periodic.

Minimal example:

import dftd3.pyscf as disp

xc = 'PBE'
basis =  'def2-TZVP'
atom = '''
O  -1.6256  -0.0413   0.3705
H  -0.7061  -0.0938   0.0934
H  -2.0618  -0.7328  -0.1359
'''

from pyscf import gto
from pyscf.pbc import gto as pbc_gto

mol = gto.M(atom=atom, basis = basis)
e_disp = float(disp.DFTD3Dispersion(mol, xc=xc, version="d3bj").kernel()[0])
print('non-periodic result', e_disp)

cell = pbc_gto.M(atom=atom, basis = basis, a=[[3,0,0], [0,3,0], [0,0,3]])
e_disp_periodic = float(disp.DFTD3Dispersion(cell, xc=xc, version="d3bj").kernel()[0])
print('periodic result', e_disp_periodic)
print('difference', abs(e_disp_periodic - e_disp))

Output:

non-periodic result -0.0003594806949831674 periodic result -0.0003594806949831674 difference 0.0

Expected: the two results should be different ;)

dftd3.interface.Dispersionmodel seems to support lattice=... and periodic=... arguments. However the PySCF interface code doesn't copy these parameters from the PySCF cell to the DispersionModel. It looks like if that did happen, it should happen when the other parameters (atom nuclear charges and coordinates) are copied, at pyscf.py line 223.

Could you please let me know if this is a missing feature or deliberate? If missing, how hard would it be to add it?

awvwgk commented 1 month ago

Thanks for pointing this out. Of course this is something that should be addressed in the PySCF interface of dftd3. If the lattice information can be easily retrieved from the mol object than implementation should be straight forward.