diff --git a/.coveragerc b/.coveragerc index 5fbeb7242b..840dfe2bfd 100644 --- a/.coveragerc +++ b/.coveragerc @@ -19,6 +19,7 @@ omit = */dmrgscf/* */pbc/mpicc/* */pbc/mpitools/* */gen_*_param.py + *slow* disable_warnings = include-ignored [report] diff --git a/pyscf/df/test/test_df_grad.py b/pyscf/df/test/test_df_grad.py index 6630def483..affdbfc14b 100644 --- a/pyscf/df/test/test_df_grad.py +++ b/pyscf/df/test/test_df_grad.py @@ -47,6 +47,26 @@ def test_rhf_grad(self): g1 = scf.RHF(mol).density_fit().run().nuc_grad_method().kernel() self.assertAlmostEqual(abs(gref - g1).max(), 0, 5) + def test_rks_lda_grad(self): + gref = mol.RKS(xc='lda,').run().nuc_grad_method().kernel() + g1 = mol.RKS(xc='lda,').density_fit().run().nuc_grad_method().kernel() + self.assertAlmostEqual(abs(gref - g1).max(), 0, 4) + + def test_rks_grad(self): + gref = mol.RKS(xc='b3lyp').run().nuc_grad_method().kernel() + g1 = mol.RKS(xc='b3lyp').density_fit().run().nuc_grad_method().kernel() + self.assertAlmostEqual(abs(gref - g1).max(), 0, 4) + + def test_uhf_grad(self): + gref = mol.UHF.run().nuc_grad_method().kernel() + g1 = mol.UHF.density_fit().run().nuc_grad_method().kernel() + self.assertAlmostEqual(abs(gref - g1).max(), 0, 5) + + def test_uks_lda_grad(self): + gref = mol.UKS.run(xc='lda,').nuc_grad_method().kernel() + g1 = mol.UKS.density_fit().run(xc='lda,').nuc_grad_method().kernel() + self.assertAlmostEqual(abs(gref - g1).max(), 0, 4) + def test_uks_grad(self): gref = mol.UKS.run(xc='b3lyp').nuc_grad_method().kernel() g1 = mol.UKS.density_fit().run(xc='b3lyp').nuc_grad_method().kernel() diff --git a/pyscf/df/test/test_df_hessian.py b/pyscf/df/test/test_df_hessian.py index fb58b35365..835d37868c 100644 --- a/pyscf/df/test/test_df_hessian.py +++ b/pyscf/df/test/test_df_hessian.py @@ -44,16 +44,25 @@ def tearDownModule(): class KnownValues(unittest.TestCase): def test_rhf_hess(self): - gref = scf.RHF(mol).run().Hessian().kernel() - g1 = scf.RHF(mol).density_fit().run().Hessian().kernel() - self.assertAlmostEqual(abs(gref - g1).max(), 0, 3) + href = scf.RHF(mol).run().Hessian().kernel() + h1 = scf.RHF(mol).density_fit().run().Hessian().kernel() + self.assertAlmostEqual(abs(href - h1).max(), 0, 3) + + def test_rks_hess(self): + href = mol.RKS.run(xc='b3lyp').Hessian().kernel() + h1 = mol.RKS.density_fit().run(xc='b3lyp').Hessian().kernel() + self.assertAlmostEqual(abs(href - h1).max(), 0, 3) + + def test_uhf_hess(self): + href = scf.UHF(mol).run().Hessian().kernel() + h1 = scf.UHF(mol).density_fit().run().Hessian().kernel() + self.assertAlmostEqual(abs(href - h1).max(), 0, 3) def test_uks_hess(self): - gref = mol.UKS.run(xc='b3lyp').Hessian().kernel() - g1 = mol.UKS.density_fit().run(xc='b3lyp').Hessian().kernel() - self.assertAlmostEqual(abs(gref - g1).max(), 0, 3) -# + href = mol.UKS.run(xc='b3lyp').Hessian().kernel() + h1 = mol.UKS.density_fit().run(xc='b3lyp').Hessian().kernel() + self.assertAlmostEqual(abs(href - h1).max(), 0, 3) + if __name__ == "__main__": print("Full Tests for df.hessian") unittest.main() - diff --git a/pyscf/dft/numint2c.py b/pyscf/dft/numint2c.py index 88d79d017f..4f31676e31 100644 --- a/pyscf/dft/numint2c.py +++ b/pyscf/dft/numint2c.py @@ -535,7 +535,7 @@ class NumInt2C(numint._NumIntMixin): collinear_thrd = getattr(__config__, 'dft_numint_RnumInt_collinear_thrd', 0.99) collinear_samples = getattr(__config__, 'dft_numint_RnumInt_collinear_samples', 200) - eval_rho = eval_rho + eval_rho = staticmethod(eval_rho) def eval_rho2(self, mol, ao, mo_coeff, mo_occ, non0tab=None, xctype='LDA', with_lapl=True, verbose=None):