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_UB3LYP_grad(self):

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

        CH3 = Mol_CH3()
        helper = GradUSCF({"scf_eng": CH3.gga_eng})
        formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/CH3-B3LYP-freq.fchk"))
        assert(np.allclose(helper.E_1, formchk.grad(), atol=1e-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_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 #5
0
    def test_UMP2_grad(self):

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

        CH3 = Mol_CH3()
        helper = GradUMP2({"scf_eng": CH3.hf_eng.run(), "cphf_tol": 1e-10})
        formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/CH3-MP2-freq.fchk"))
        assert(np.allclose(helper.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #6
0
    def test_UB2PLYP_grad(self):

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

        CH3 = Mol_CH3(xc="0.53*HF + 0.47*B88, 0.73*LYP")
        grids_cphf = CH3.gen_grids(atom_grid=(50, 194))
        helper = GradUMP2({"scf_eng": CH3.gga_eng.run(), "cphf_tol": 1e-10, "cc": 0.27, "cphf_grids": grids_cphf})
        formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/CH3-B2PLYP-freq.fchk"))
        assert(np.allclose(helper.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #7
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 #8
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 #9
0
    def test_UXYGJOS_grad(self):

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

        CH3_sc = Mol_CH3(xc="B3LYPg")
        CH3_nc = Mol_CH3(xc="0.7731*HF + 0.2269*LDA, 0.2309*VWN3 + 0.2754*LYP")
        grids_cphf = CH3_sc.gen_grids(atom_grid=(50, 194))
        helper = GradUXDH({"scf_eng": CH3_sc.gga_eng, "nc_eng": CH3_nc.gga_eng,
                           "cc": 0.4364, "ss": 0.,
                           "cphf_tol": 1e-10, "cphf_grids": grids_cphf})
        formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/CH3-XYGJOS-force.fchk"))
        assert(np.allclose(helper.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #10
0
    def test_UXYG3_grad(self):

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

        CH3_sc = Mol_CH3(xc="B3LYPg")
        CH3_nc = Mol_CH3(xc="0.8033*HF - 0.0140*LDA + 0.2107*B88, 0.6789*LYP")
        grids_cphf = CH3_sc.gen_grids(atom_grid=(50, 194))
        helper = GradUXDH({
            "scf_eng": CH3_sc.gga_eng, "nc_eng": CH3_nc.gga_eng,
            "cc": 0.3211,
            "cphf_tol": 1e-10, "cphf_grids": grids_cphf})
        formchk = FormchkInterface(resource_filename("pyxdh", "Validation/gaussian/CH3-XYG3-force.fchk"))
        assert(np.allclose(helper.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #11
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 #12
0
    def test_HF_grad(self):

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

        H2O2 = Mol_H2O2()
        config = {"scf_eng": H2O2.hf_eng}
        helper = GradSCF(config)
        hf_grad = helper.scf_grad

        assert (np.allclose(helper.E_1, hf_grad.grad(), atol=1e-6, rtol=1e-4))

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

        assert (np.allclose(helper.E_1, formchk.grad(), atol=1e-6, rtol=1e-4))
Beispiel #13
0
    def test_B3LYP_grad(self):

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

        H2O2 = Mol_H2O2()
        config = {"scf_eng": H2O2.gga_eng}
        helper = GradSCF(config)
        gga_grad = helper.scf_grad

        assert (np.allclose(helper.E_1, gga_grad.grad(), atol=1e-6, rtol=1e-4))

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

        # TODO: This is a weaker compare! Try to modulize that someday.
        assert (np.allclose(helper.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #14
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 #15
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 #16
0
    def test_MP2_grad(self):

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

        from pyscf import mp, grad

        H2O2 = Mol_H2O2()
        config = {"scf_eng": H2O2.hf_eng}
        gmh = GradMP2(config)

        mp2_eng = mp.MP2(gmh.scf_eng)
        mp2_eng.kernel()
        mp2_grad = grad.mp2.Gradients(mp2_eng)
        mp2_grad.kernel()

        assert (np.allclose(gmh.E_1, mp2_grad.de, atol=1e-6, rtol=1e-4))

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

        assert (np.allclose(gmh.E_1, formchk.grad(), atol=1e-6, rtol=1e-4))
Beispiel #17
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 #18
0
 def valid_assert(config, resource_path):
     from pkg_resources import resource_filename
     from pyxdh.Utilities import FormchkInterface
     helper = GradSCF(config)
     formchk = FormchkInterface(resource_filename("pyxdh", resource_path))
     assert (np.allclose(helper.E_1, formchk.grad(), atol=1e-5, rtol=1e-4))
Beispiel #19
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))