BoothGroup / Vayesta

A Python package for wave function-based quantum embedding
Apache License 2.0
33 stars 8 forks source link

`MP2_BNO_Bath` for density-fitted molecules #6

Closed obackhouse closed 2 years ago

obackhouse commented 2 years ago

MP2_BNO_Bath does not support density-fitted molecules. Example:

from pyscf import gto, scf
from vayesta.ewf import EWF
from vayesta.core.bath import MP2_BNO_Bath

mol = gto.M(atom='O 0 0 0; O 0 0 1', basis='sto3g', verbose=0)

mf = scf.RHF(mol)
mf = mf.density_fit()
mf.kernel()

qemb = EWF(mf)
qemb.iao_fragmentation()
frag = qemb.add_atomic_fragment([0])

bath = MP2_BNO_Bath(frag)
bath.kernel()

Which raises:

Traceback (most recent call last):
  File "bugs/bno_bath.py", line 16, in <module>
    bath.kernel()
  File "/home/olli/git/vayesta/vayesta/core/bath/bno.py", line 35, in kernel
    self.c_bno_occ, self.n_bno_occ = self.make_bno_bath('occ')
  File "/home/olli/git/vayesta/vayesta/core/bath/bno.py", line 55, in make_bno_bath
    c_bno, n_bno = self.make_bno_coeff(kind)
  File "/home/olli/git/vayesta/vayesta/core/bath/bno.py", line 221, in make_bno_coeff
    assert (eris.ovov is not None)
AssertionError
cjcscott commented 2 years ago

I've just run into this issue in some work I'm doing, and tracked it back to some behaviour in the pyscf MP2 implementation, specifically relating to the store_eris keyword. For some system mol and density-fitted restricted meanfield rdfmf you can run the following

from pyscf import mp my_mp2 = mp.MP2(rdfmf) print(my_mp2.ao2mo(rdfmf.mo_coeff, store_eris=False).ovov is None) print(my_mp2.ao2mo(rdfmf.mo_coeff, store_eris=True).ovov is None)

and get

True False

so it looks like we might need to ensure this keyword defaults to True instead of False when using this functionality. The pbc.mp implementation doesn't have an equivalent keyword to worry about, so this isn't an issue there.

maxnus commented 2 years ago

I actually don't use PySCF's MP2 anymore at all in my dev branch - the MP2 equations are too simple to be worth the massive pain PySCF inflicts on you. I will try to have a merge asap

cjcscott commented 2 years ago

Aha that'd definitely fix it! Sounds brilliant- thanks very much!

maxnus commented 2 years ago

Should be fixed in 047d49fd5027