In #17, one of the points raised was about the correctness of the non-XC terms in the total energy.
Mostly, I was concerned with the inclusion of two body terms because these do not exist in DFT (outside the scope of the XC functional atleast). However, it appears that removal of these terms makes the energy completely wrong so I think my concern was related to a monomer in the language used in PySCF rather than any actual numerics being incorrect.
To make entirely sure that we are doing things correctly here, I am recommending implementing tests for the Non-XC total energy by checking the dissociation curves of 3 diatomic molecules match the result from PySCF. Runs with no XC functional can be run in PySCF using the dummy function:
mol = gto.M(
atom = '''
Li 0. -0.37 0.
F 0. 0.98 0.
''',
basis = 'ccpvdz')
def zero_xc(xc_code, rho, spin=0, relativity=0, deriv=1, omega=None, verbose=None):
# A fictitious XC functional to demonstrate the usage
rho0, dx, dy, dz = rho[:4]
vlapl = None
vtau = None
fxc = None
kxc = None
vgamma = np.zeros(shape=rho0.shape)
vrho = np.zeros(shape=rho0.shape)
exc = np.zeros(shape=rho0.shape)
vxc = (vrho, vgamma, vlapl, vtau)
return exc, vxc, fxc, kxc
mf = dft.RKS(mol)
mf = mf.define_xc_(zero_xc, 'GGA')
truth = mf.kernel(max_cycle=500)
We can check for error (in the total energy) with our code by running:
HF_molecule = molecule_from_pyscf(mf, scf_iteration=500)
print(HF_molecule.nonXC() - truth)
A good benchmark for judging this error is chemical accuracy (1 mHa) but in reality I hope to see us with around 100x less error.