Skip to content

Commit

Permalink
Fix post-hf Gradients with cartesian GTOs (issue pyscf#1985)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Dec 16, 2023
1 parent efe8f52 commit 4a0dbc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pyscf/grad/mp2.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,16 @@ def converged(self):


def _shell_prange(mol, start, stop, blksize):
l = mol._bas[start:stop,gto.ANG_OF]
if mol.cart:
dims = (l+1)*(l+2)//2 * mol._bas[start:stop,gto.NCTR_OF]
else:
dims = (l*2+1) * mol._bas[start:stop,gto.NCTR_OF]
nao = 0
ib0 = start
for ib in range(start, stop):
now = (mol.bas_angular(ib)*2+1) * mol.bas_nctr(ib)
for ib, now in zip(range(start, stop), dims):
nao += now
if nao > blksize and nao > now:
if nao > blksize:
yield (ib0, ib, nao-now)
ib0 = ib
nao = now
Expand Down
8 changes: 8 additions & 0 deletions pyscf/grad/test/test_mp2.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ def test_symmetrize(self):
g = mol.RHF.run().MP2().run().Gradients().kernel()
self.assertAlmostEqual(lib.fp(g), 0.049987975650731625, 6)

# issue 1985
def test_cart_gto(self):
mol1 = mol.copy()
mol1.cart = True
mol1.basis = '6-31g*'
g = mol.RHF.run().MP2().run().Gradients().kernel()
self.assertAlmostEqual(lib.fp(g), -0.03568120792884476, 6)


if __name__ == "__main__":
print("Tests for MP2 gradients")
Expand Down

0 comments on commit 4a0dbc6

Please sign in to comment.