Skip to content

Commit

Permalink
Merge pull request #51 from mcocdawc/fix_bug_in_get_emb_eri_fast_gdf
Browse files Browse the repository at this point in the history
Enable an automatic installation of the libdmet dependency + account for fixed bug in get_emb_eri_fast_gdf
  • Loading branch information
mcocdawc authored Nov 4, 2024
2 parents b5cf74a + 90fb04c commit b6bce7d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ processors.
- PySCF library
- Numpy
- Scipy
- libDMET<sup>##</sup> (required for periodic BE)
- libDMET (required for periodic BE)
- [Wannier90](https://github.com/wannier-developers/wannier90)<sup>&&</sup> (to use Wannier functions)

<sub><sup>##</sup>The modified version of [libDMET](https://github.com/gkclab/libdmet_preview) available
at [here](https://github.com/oimeitei/libdmet_preview) is
recommended to run periodic BE using QuEmb.
<sup>&&</sup>Wannier90 code is interfaced via [libDMET](https://github.com/gkclab/libdmet_preview) in QuEmb</sub>

### Steps
Expand Down
4 changes: 2 additions & 2 deletions kbe/pbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def initialize(self, eri_,compute_hf, restart=False):
eri = get_emb_eri_fast_gdf(self.mf.cell, self.mf.with_df,
t_reversal_symm=True,
symmetry=4,
C_ao_emb=fobjs_.TA)[0]
C_ao_eo=fobjs_.TA)[0]

file_eri.create_dataset(fobjs_.dname, data=eri)
eri = ao2mo.restore(8, eri, fobjs_.nao)
Expand Down Expand Up @@ -638,7 +638,7 @@ def eritransform_parallel(a, atom, basis, kpts, C_ao_emb, cderi):
mydf._cderi = cderi
eri = get_emb_eri_fast_gdf(cell, mydf,
t_reversal_symm=True, symmetry=4,
C_ao_emb = C_ao_emb)
C_ao_eo=C_ao_emb)

return eri

Expand Down
7 changes: 6 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
pyscf==2.6.2
pytest==8.3.2

# TODO this temporarily points to mcocdawc/libdmet_preview.
# as soon as this PR: https://github.com/gkclab/libdmet_preview/pull/21
# is merged, let it point to the original libdmet
# https://github.com/gkclab/libdmet_preview
libdmet @ git+https://github.com/mcocdawc/libdmet_preview.git@add_fixes_for_BE
matplotlib
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@
'numpy>=1.22.0',
'scipy>=1.7.0',
'pyscf>=2.0.0',
'matplotlib',
# TODO this temporarily points to mcocdawc/libdmet_preview.
# as soon as this PR: https://github.com/gkclab/libdmet_preview/pull/21
# is merged, let it point to the original libdmet
# https://github.com/gkclab/libdmet_preview
'libdmet @ git+https://github.com/mcocdawc/libdmet_preview.git@add_fixes_for_BE'
],
)
21 changes: 10 additions & 11 deletions tests/chem_dm_kBE_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This script tests the period BE1 and BE2 workflows using chemical potential and density matching, respectively.
This script tests the period BE1 and BE2 workflows using chemical potential and density matching, respectively.
Also tests the gaussian density fitting interface, which is typically used by default.
Author(s): Shaun Weatherly
Expand All @@ -14,7 +14,7 @@ class Test_kBE_Full(unittest.TestCase):
import libdmet
except ImportError:
libdmet = None

@unittest.skipIf(libdmet is None, "Module `libdmet` not imported correctly.")
def test_kc2_sto3g_be1_chempot(self):
kpt = [1, 1, 1]
Expand All @@ -37,9 +37,8 @@ def test_kc2_sto3g_be1_chempot(self):
cell.verbose=0
cell.build()

self.periodic_test(cell, kpt, 'be1', 'C2 (kBE1)', 'autogen', -74.62798837, only_chem = True)
self.periodic_test(cell, kpt, 'be1', 'C2 (kBE1)', 'autogen', -74.64695833012868, only_chem = True)

@unittest.skipIf(os.getenv("GITHUB_ACTIONS") == "true", "Skip expensive tests on Github Actions")
def test_kc4_sto3g_be2_density(self):
kpt = [1, 1, 1]
cell = gto.Cell()
Expand All @@ -61,28 +60,28 @@ def test_kc4_sto3g_be2_density(self):
cell.verbose=0
cell.build()

self.periodic_test(cell, kpt, 'be2', 'C4 (kBE2)', 'autogen', -149.37047888, only_chem = False)
self.periodic_test(cell, kpt, 'be2', 'C4 (kBE2)', 'autogen', -149.4085332249809, only_chem = False)

def periodic_test(self, cell, kpt, be_type, test_name, frag_type, target, delta = 1e-4, only_chem = True):

kpts = cell.make_kpts(kpt, wrap_around=True)
mydf = df.GDF(cell, kpts)
mydf.build()

kmf = scf.KRHF(cell, kpts)
kmf.with_df = mydf
kmf.exxdiv = None
kmf.conv_tol = 1e-12
kmf.kernel()
kfrag = fragpart(be_type=be_type,

kfrag = fragpart(be_type=be_type,
mol=cell,
frag_type=frag_type,
kpt=kpt,
kpt=kpt,
frozen_core=True)
mykbe = BE(kmf, kfrag, kpts=kpts)
mykbe.optimize(solver='CCSD', only_chem=only_chem)

self.assertAlmostEqual(mykbe.ebe_tot, target,
msg = "kBE Correlation Energy for " + test_name
+ " does not match the expected correlation energy!", delta = delta)
Expand Down

0 comments on commit b6bce7d

Please sign in to comment.