Skip to content

Commit fff48d2

Browse files
committed
Add more tests for df methods
1 parent 390d551 commit fff48d2

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

.coveragerc

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ omit = */dmrgscf/*
1919
*/pbc/mpicc/*
2020
*/pbc/mpitools/*
2121
*/gen_*_param.py
22+
*slow*
2223
disable_warnings = include-ignored
2324

2425
[report]

pyscf/df/test/test_df_grad.py

+20
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ def test_rhf_grad(self):
4747
g1 = scf.RHF(mol).density_fit().run().nuc_grad_method().kernel()
4848
self.assertAlmostEqual(abs(gref - g1).max(), 0, 5)
4949

50+
def test_rks_lda_grad(self):
51+
gref = mol.RKS(xc='lda,').run().nuc_grad_method().kernel()
52+
g1 = mol.RKS(xc='lda,').density_fit().run().nuc_grad_method().kernel()
53+
self.assertAlmostEqual(abs(gref - g1).max(), 0, 4)
54+
55+
def test_rks_grad(self):
56+
gref = mol.RKS(xc='b3lyp').run().nuc_grad_method().kernel()
57+
g1 = mol.RKS(xc='b3lyp').density_fit().run().nuc_grad_method().kernel()
58+
self.assertAlmostEqual(abs(gref - g1).max(), 0, 4)
59+
60+
def test_uhf_grad(self):
61+
gref = mol.UHF.run().nuc_grad_method().kernel()
62+
g1 = mol.UHF.density_fit().run().nuc_grad_method().kernel()
63+
self.assertAlmostEqual(abs(gref - g1).max(), 0, 5)
64+
65+
def test_uks_lda_grad(self):
66+
gref = mol.UKS.run(xc='lda,').nuc_grad_method().kernel()
67+
g1 = mol.UKS.density_fit().run(xc='lda,').nuc_grad_method().kernel()
68+
self.assertAlmostEqual(abs(gref - g1).max(), 0, 4)
69+
5070
def test_uks_grad(self):
5171
gref = mol.UKS.run(xc='b3lyp').nuc_grad_method().kernel()
5272
g1 = mol.UKS.density_fit().run(xc='b3lyp').nuc_grad_method().kernel()

pyscf/df/test/test_df_hessian.py

+17-8
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,25 @@ def tearDownModule():
4444

4545
class KnownValues(unittest.TestCase):
4646
def test_rhf_hess(self):
47-
gref = scf.RHF(mol).run().Hessian().kernel()
48-
g1 = scf.RHF(mol).density_fit().run().Hessian().kernel()
49-
self.assertAlmostEqual(abs(gref - g1).max(), 0, 3)
47+
href = scf.RHF(mol).run().Hessian().kernel()
48+
h1 = scf.RHF(mol).density_fit().run().Hessian().kernel()
49+
self.assertAlmostEqual(abs(href - h1).max(), 0, 3)
50+
51+
def test_rks_hess(self):
52+
href = mol.RKS.run(xc='b3lyp').Hessian().kernel()
53+
h1 = mol.RKS.density_fit().run(xc='b3lyp').Hessian().kernel()
54+
self.assertAlmostEqual(abs(href - h1).max(), 0, 3)
55+
56+
def test_uhf_hess(self):
57+
href = scf.UHF(mol).run().Hessian().kernel()
58+
h1 = scf.UHF(mol).density_fit().run().Hessian().kernel()
59+
self.assertAlmostEqual(abs(href - h1).max(), 0, 3)
5060

5161
def test_uks_hess(self):
52-
gref = mol.UKS.run(xc='b3lyp').Hessian().kernel()
53-
g1 = mol.UKS.density_fit().run(xc='b3lyp').Hessian().kernel()
54-
self.assertAlmostEqual(abs(gref - g1).max(), 0, 3)
55-
#
62+
href = mol.UKS.run(xc='b3lyp').Hessian().kernel()
63+
h1 = mol.UKS.density_fit().run(xc='b3lyp').Hessian().kernel()
64+
self.assertAlmostEqual(abs(href - h1).max(), 0, 3)
65+
5666
if __name__ == "__main__":
5767
print("Full Tests for df.hessian")
5868
unittest.main()
59-

pyscf/dft/numint2c.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class NumInt2C(numint._NumIntMixin):
535535
collinear_thrd = getattr(__config__, 'dft_numint_RnumInt_collinear_thrd', 0.99)
536536
collinear_samples = getattr(__config__, 'dft_numint_RnumInt_collinear_samples', 200)
537537

538-
eval_rho = eval_rho
538+
eval_rho = staticmethod(eval_rho)
539539

540540
def eval_rho2(self, mol, ao, mo_coeff, mo_occ, non0tab=None, xctype='LDA',
541541
with_lapl=True, verbose=None):

0 commit comments

Comments
 (0)