Beispiel #1
0
 def test_r_b2plyp_grad(self):
     scf_eng = dft.RKS(self.mol, xc="0.53*HF + 0.47*B88, 0.73*LYP"); scf_eng.grids = self.grids; scf_eng.run()
     gradh = GradMP2({"scf_eng": scf_eng, "cc": 0.27, "cphf_grids": self.grids_cphf})
     formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/NH3-B2PLYP-freq.fchk"))
     # ASSERT: energy - Gaussian
     assert np.allclose(gradh.eng, formchk.total_energy())
     # ASSERT: grad - Gaussian
     assert np.allclose(gradh.E_1, formchk.grad(), atol=1e-6, rtol=1e-4)
Beispiel #2
0
 def test_r_xygjos_grad(self):
     scf_eng = dft.RKS(self.mol, xc="B3LYPg"); scf_eng.grids = self.grids; scf_eng.run()
     nc_eng = dft.RKS(self.mol, xc="0.7731*HF + 0.2269*LDA, 0.2309*VWN3 + 0.2754*LYP"); nc_eng.grids = self.grids
     config = {"scf_eng": scf_eng, "nc_eng": nc_eng, "cc": 0.4364, "ss": 0., "cphf_grids": self.grids_cphf}
     gradh = GradXDH(config)
     formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/NH3-XYGJOS-freq.fchk"))
     # ASSERT: energy - Gaussian
     assert np.allclose(gradh.eng, formchk.total_energy())
     # ASSERT: grad - Gaussian
     assert np.allclose(gradh.E_1, formchk.grad(), atol=5e-6, rtol=1e-4)
Beispiel #3
0
 def test_r_xyg3_grad(self):
     scf_eng = dft.RKS(self.mol, xc="B3LYPg"); scf_eng.grids = self.grids; scf_eng.run()
     nc_eng = dft.RKS(self.mol, xc="0.8033*HF - 0.0140*LDA + 0.2107*B88, 0.6789*LYP"); nc_eng.grids = self.grids
     config = {"scf_eng": scf_eng, "nc_eng": nc_eng, "cc": 0.3211, "cphf_grids": self.grids_cphf}
     gradh = GradXDH(config)
     formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/NH3-XYG3-freq.fchk"))
     # ASSERT: energy - Gaussian
     assert np.allclose(gradh.eng, formchk.total_energy())
     # ASSERT: grad - Gaussian
     assert np.allclose(gradh.E_1, formchk.grad(), atol=5e-6, rtol=1e-4)
Beispiel #4
0
 def test_r_b3lyp_grad(self):
     scf_eng = dft.RKS(self.mol, xc="B3LYPg"); scf_eng.grids = self.grids; scf_eng.run()
     scf_grad = scf_eng.Gradients().run()
     gradh = GradSCF({"scf_eng": scf_eng})
     formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/NH3-B3LYP-freq.fchk"))
     # ASSERT: energy - Gaussian
     assert np.allclose(gradh.eng, formchk.total_energy())
     # ASSERT: energy - PySCF
     assert np.allclose(gradh.eng, scf_eng.e_tot)
     # ASSERT: grad - Gaussian
     assert np.allclose(gradh.E_1, formchk.grad(), atol=5e-6, rtol=1e-4)
     # ASSERT: grad - PySCF
     assert np.allclose(gradh.E_1, scf_grad.de, atol=1e-6, rtol=1e-4)
Beispiel #5
0
 def test_r_rhf_grad(self):
     scf_eng = scf.RHF(self.mol).run()
     scf_grad = scf_eng.Gradients().run()
     gradh = GradSCF({"scf_eng": scf_eng})
     formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/NH3-HF-freq.fchk"))
     # ASSERT: energy - Gaussian
     assert np.allclose(gradh.eng, formchk.total_energy())
     # ASSERT: energy - PySCF
     assert np.allclose(gradh.eng, scf_eng.e_tot)
     # ASSERT: grad - Gaussian
     assert np.allclose(gradh.E_1, formchk.grad(), atol=1e-6, rtol=1e-4)
     # ASSERT: grad - PySCF
     assert np.allclose(gradh.E_1, scf_grad.de, atol=1e-6, rtol=1e-4)
Beispiel #6
0
    def test_B2PLYP_grad(self):

        from pkg_resources import resource_filename
        from pyxdh.Utilities.test_molecules import Mol_H2O2
        from pyxdh.Utilities import FormchkInterface

        H2O2 = Mol_H2O2(xc="0.53*HF + 0.47*B88, 0.73*LYP")
        config = {"scf_eng": H2O2.gga_eng, "cc": 0.27}
        gmh = GradMP2(config)

        formchk = FormchkInterface(
            resource_filename("pyxdh",
                              "Validation/gaussian/H2O2-B2PLYP-freq.fchk"))

        assert (np.allclose(gmh.eng, formchk.total_energy()))
        assert (np.allclose(gmh.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #7
0
 def test_u_mp2_grad(self):
     scf_eng = scf.UHF(self.mol)
     scf_eng.conv_tol_grad = 1e-8
     scf_eng.max_cycle = 128
     scf_eng.run()
     assert scf_eng.converged
     mp2_eng = mp.MP2(scf_eng).run()
     mp2_grad = mp2_eng.Gradients().run()
     gradh = GradUMP2({"scf_eng": scf_eng})
     formchk = FormchkInterface(
         resource_filename("pyxdh",
                           "Validation/gaussian/CH3-MP2-freq.fchk"))
     # ASSERT: energy - Gaussian
     assert np.allclose(gradh.eng, formchk.total_energy())
     # ASSERT: energy - PySCF
     assert np.allclose(gradh.eng, mp2_eng.e_tot)
     # ASSERT: grad - Gaussian
     assert np.allclose(gradh.E_1, formchk.grad(), atol=1e-6, rtol=1e-4)
     # ASSERT: grad - PySCF
     assert np.allclose(gradh.E_1, mp2_grad.de, atol=1e-6, rtol=1e-4)
Beispiel #8
0
    def test_XYG3_grad(self):

        from pkg_resources import resource_filename
        from pyxdh.Utilities.test_molecules import Mol_H2O2
        from pyxdh.Utilities import FormchkInterface

        H2O2_sc = Mol_H2O2(xc="B3LYPg")
        H2O2_nc = Mol_H2O2(
            xc="0.8033*HF - 0.0140*LDA + 0.2107*B88, 0.6789*LYP")
        config = {
            "scf_eng": H2O2_sc.gga_eng,
            "nc_eng": H2O2_nc.gga_eng,
            "cc": 0.3211
        }
        gmh = GradXDH(config)

        formchk = FormchkInterface(
            resource_filename("pyxdh",
                              "Validation/gaussian/H2O2-XYG3-force.fchk"))

        assert (np.allclose(gmh.eng, formchk.total_energy()))
        assert (np.allclose(gmh.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #9
0
 def test_u_xyg3_grad(self):
     scf_eng = dft.UKS(self.mol, xc="B3LYPg")
     scf_eng.grids = self.grids
     scf_eng.conv_tol_grad = 1e-10
     scf_eng.max_cycle = 128
     scf_eng.run()
     nc_eng = dft.UKS(self.mol,
                      xc="0.8033*HF - 0.0140*LDA + 0.2107*B88, 0.6789*LYP")
     nc_eng.grids = self.grids
     config = {
         "scf_eng": scf_eng,
         "nc_eng": nc_eng,
         "cc": 0.3211,
         "cphf_grids": self.grids_cphf,
         "cphf_tol": 1e-10
     }
     gradh = GradUXDH(config)
     formchk = FormchkInterface(
         resource_filename("pyxdh",
                           "Validation/gaussian/CH3-XYG3-force.fchk"))
     # ASSERT: energy - Gaussian
     assert np.allclose(gradh.eng, formchk.total_energy())
     # ASSERT: grad - Gaussian
     assert np.allclose(gradh.E_1, formchk.grad(), atol=5e-6, rtol=1e-4)
Beispiel #10
0
 def valid_resource(helper, resource_path):
     from pkg_resources import resource_filename
     from pyxdh.Utilities import FormchkInterface
     formchk = FormchkInterface(resource_filename("pyxdh", resource_path))
     assert (np.allclose(helper.eng, formchk.total_energy()))
     assert (np.allclose(helper.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))