D3 correction not applied
Closed this issue · 8 comments
I'm using the default aimnet2_b973c_0.jpt
model and it seems like the D3 corrections are not being applied. What makes me think this is that I can get consistent energies/forces with b973c DFT data, but only if I subtract the D3 correction manually from the DFT data first.
Is there a setting I need to apply to activate these corrections that I'm missing?
It must be applied. Note, it is only pairwise components, not 3-body. Please could you share the data that made you come to the conclusion?
Here's a minimal example for a calculation on ethanol. I can't use ORCA for licensing reasons, but Psi4 should give reasonably similar results for the same functional and basis set.
The relevant energies calculated below are:
AIMNet2ASE
calculator = -4216.9688- dft = -4217.2368
DFTD3
= -0.26485
so, by subtracting the D3 energy from the DFT (which has it built-in coming out of Psi4), AIMNet2 and DFT agree to within less than 3 meV, otherwise they are 100s of meV out. This is consistent for me across all the molecules in MD17 (not just ethanol)
ethanol_1.xyz.txt
from dftd3.ase import DFTD3
from ase.calculators.psi4 import Psi4
from aimnet2calc import AIMNet2ASE
ethanol = read('ethanol_1.xyz')
aimnet = AIMNet2ASE("/Users/joemorrow/models/aimnet2_b973c_0.jpt")
ethanol.calc = aimnet
aimnet_energy = ethanol.get_potential_energy()
dft_calc = Psi4(atoms = ethanol,
method = 'B973C',
basis = 'def2-TZVP',
num_threads=4,
label=f'dft_b973C-TZ'
)
dft_energy = ethanol.get_potential_energy()
d3 = DFTD3(method="b973c", damping="d3bj")
ethanol.calc = d3
d3_energy = ethanol.get_potential_energy()
print(
dft_energy - d3_energy, aimnet_energy[0]
)
Absolute DFT energy depends drastically on the integration grid. Therefore, absolute values of DFT energy cannot be compared between different software implementations, sometimes even between different versions of the same program, like ORCA-4 and ORCA-5.
ORCA gives -4216.9536 eV total energy for this ethanol geometry.
I agree that different DFT implementations will always be inconsistent to some extent, especially in absolute energies.
However, in this case, the forces also agree much better between AIMNet and DFT with the D3 corrections subtracted across a wide range of molecules, which made me think that it's not differences in DFT implementation behind this. Interesting that the differences between DFT flavours could be coincidentally very similar to the D3 correction, but perhaps that is the case
Hi @MorrowChem . I would re-iterate again that you can not compare total energies computed with different DFT codes. D3 contribution to forces is generally rather small, compared to intrinsic errors one expects from an NNP. At this point I am confident that that my code is correct and D3 correction is applied. I would need more evidence for your claim to keep the issue open.
Would you mind sharing your ORCA input parameters so I can try and reproduce on my end? Great work by the way, enjoying using AIMNet2, just want to make sure I know exactly what the calculations are doing.
B97-3c:
!b97-3c tightscf engrad
%elprop dipole true quadrupole true end
%output Print[P_DFTD_GRAD] 1 Print[P_Hirshfeld] 1 end
wB97M:
!def2-tzvpp def2/j rijcosx tightscf engrad
%method
method dft
functional hyb_mgga_xc_wb97m_v
end
%elprop dipole true quadrupole true end
%output Print[P_Hirshfeld] 1 end