dftd3 / simple-dftd3

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

Dispersion energy not the same between s-dftd3 binary and dftd3.interface API #14

Closed ajz34 closed 2 years ago

ajz34 commented 2 years ago

Hi :smile:

I'm experiencing result disaccordance between binary s-dftd3 and result from python API dftd3.interface, at least for D3-BJ with PBE0.

Results run on my computer are: Run Type Eng. Disp. (a.u.)
original dftd3 -0.02958913
simple s-dftd3 -2.9589129838629E-02
python (prebuild param) -0.02948923293249489
python (user param) -0.029589132634178346

Difference between python (prebuild param) and other results is somehow large. Difference between s-dftd3 and python (user param) may be a result of different Angstrom->Bohr conversion constant, which is not important.

I'm not acustomed to ffi workflow, thus I havn't hacked why this happens :smiling_face_with_tear:


Steps to reproduce python (prebuild param) and python (user param)

To reproduce python (prebuild param), I shamelessly borrow the code from test code of simple-dftd3 :joy: https://github.com/awvwgk/simple-dftd3/blob/4c6c7825ba25288d62047a1ecf8edaccecd7061a/python/dftd3/test_interface.py#L179-L204

To reproduce result of python (user param), substiuting RationalDampingParam(method="pbe0") by RationalDampingParam(s6=1, s8=1.2177, s9=0, a1=0.4145, a2=4.8593, alp=14) should work.

Steps to reproduce original dftd3 and simple s-dftd3

Coordinate file is defined as tm.xyz:

16
tm.xyz
H   1.47785865  2.02673935 -1.47792345
H  -0.75909124  0.22976202  2.93087098
C  -1.72653772 -1.3263511  -0.82885635
B   1.13534314 -0.46989888 -1.18849251
H  -2.27669551 -2.08300829 -0.2589304
P   0.03232026 -2.02393313 -1.17653739
O   0.21785459  0.30748145  2.94674769
Cl  2.33559684  2.07710454  1.36507466
Al  0.70755099  0.7418772   1.04528377
P   1.63167935  0.91293665 -2.34248821
B  -1.59995106  0.02348594 -0.14624446
H   0.59007699 -0.5165691   3.30980685
F   0.32776684  1.15309591 -3.28767134
P  -1.41550502  1.58846245  0.55584146
H  -2.18646012 -1.23947453 -1.82225432
P   1.50819301 -1.40171049  0.375773

Then run

$ s-dftd3 run --bj pbe0 tm.xyz
$ dftd3 tm.xyz -bj -func pbe0

I'm new to dftd3/4, so hope these scripts are the correct D3-BJ with PBE0 :smiling_face_with_tear:

ajz34 commented 2 years ago

Additional notes

simple-dftd3 (v0.5.1) and dftd4 (v3.3.0) are installed from conda channal. Original dftd3 is compiled from code at https://www.chemie.uni-bonn.de/pctc/mulliken-center/software/dft-d3/.

Seems that dftd4 does not suffer similar deviation between fortran binary and dftd4.interface python API.

awvwgk commented 2 years ago

Note that the Python API uses a slightly different default, always enabling the ATM, while the command line interface uses the two-body only version by default and requires an explicit option (--atm).

https://github.com/awvwgk/simple-dftd3/blob/4c6c7825ba25288d62047a1ecf8edaccecd7061a/python/dftd3/interface.py#L221

If you pass RationalDampingParam(method="pbe0", atm=False) the result should be consistent.

ajz34 commented 2 years ago

Thanks for clear reply! :smile: