Example #1
0
    def test_MP2_polar(self):

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

        H2O2 = Mol_H2O2()
        config = {"scf_eng": H2O2.hf_eng}
        dip_helper = DipoleMP2(config)
        config = {
            "deriv_A": dip_helper,
            "deriv_B": dip_helper,
        }

        helper = PolarMP2(config)
        E_2 = helper.E_2

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

        assert (np.allclose(-E_2,
                            formchk.polarizability(),
                            atol=1e-6,
                            rtol=1e-4))
Example #2
0
    def test_B2PLYP_polar(self):

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

        H2O2 = Mol_H2O2(xc="0.53*HF + 0.47*B88, 0.73*LYP")
        grids_cphf = H2O2.gen_grids(50, 194)
        config = {
            "scf_eng": H2O2.gga_eng,
            "cc": 0.27,
            "cphf_grids": grids_cphf
        }
        dip_helper = DipoleMP2(config)
        config = {"deriv_A": dip_helper, "deriv_B": dip_helper}
        helper = PolarMP2(config)
        E_2 = helper.E_2

        formchk = FormchkInterface(
            resource_filename("pyxdh",
                              "Validation/gaussian/H2O2-B2PLYP-freq.fchk"))
        assert (np.allclose(-E_2,
                            formchk.polarizability(),
                            atol=1e-6,
                            rtol=1e-4))
Example #3
0
 def test_r_rhf_polar(self):
     scf_eng = scf.RHF(self.mol).run()
     diph = DipoleSCF({"scf_eng": scf_eng})
     polh = PolarSCF({"deriv_A": diph})
     formchk = FormchkInterface(
         resource_filename("pyxdh", "Validation/gaussian/NH3-HF-freq.fchk"))
     # ASSERT: polar - Gaussian
     assert np.allclose(-polh.E_2,
                        formchk.polarizability(),
                        atol=1e-6,
                        rtol=1e-4)
Example #4
0
 def valid_assert(dip_config, resource_path):
     from pkg_resources import resource_filename
     from pyxdh.Utilities import FormchkInterface
     from pyxdh.DerivOnce import DipoleSCF
     dip_helper = DipoleSCF(dip_config)
     polar_config = {"deriv_A": dip_helper, "deriv_B": dip_helper}
     helper = PolarSCF(polar_config)
     E_2 = helper.E_2
     formchk = FormchkInterface(resource_filename("pyxdh", resource_path))
     assert (np.allclose(-E_2,
                         formchk.polarizability(),
                         atol=1e-6,
                         rtol=1e-4))
Example #5
0
 def test_u_uhf_polar(self):
     scf_eng = scf.UHF(self.mol)
     scf_eng.conv_tol = 1e-12
     scf_eng.conv_tol_grad = 1e-10
     scf_eng.max_cycle = 256
     scf_eng.run()
     diph = DipoleUSCF({"scf_eng": scf_eng})
     polh = PolarUSCF({"deriv_A": diph})
     formchk = FormchkInterface(
         resource_filename("pyxdh", "Validation/gaussian/CH3-HF-freq.fchk"))
     assert np.allclose(-polh.E_2,
                        formchk.polarizability(),
                        atol=1e-6,
                        rtol=1e-4)
Example #6
0
 def test_r_b3lyp_polar(self):
     scf_eng = dft.RKS(self.mol, xc="B3LYPg")
     scf_eng.grids = self.grids
     scf_eng.run()
     diph = DipoleSCF({"scf_eng": scf_eng, "cphf_grids": self.grids_cphf})
     polh = PolarSCF({"deriv_A": diph})
     formchk = FormchkInterface(
         resource_filename("pyxdh",
                           "Validation/gaussian/NH3-B3LYP-freq.fchk"))
     # ASSERT: polar - Gaussian
     assert np.allclose(-polh.E_2,
                        formchk.polarizability(),
                        atol=1e-6,
                        rtol=1e-4)
Example #7
0
 def test_r_xyg3_polar(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
     }
     diph = DipoleXDH(config)
     polh = PolarXDH({"deriv_A": diph})
     formchk = FormchkInterface(
         resource_filename("pyxdh",
                           "Validation/gaussian/NH3-XYG3-freq.fchk"))
     # ASSERT: polar - Gaussian
     np.allclose(-polh.E_2, formchk.polarizability(), atol=1e-6, rtol=1e-4)
Example #8
0
 def test_r_xygjos_polar(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
     }
     diph = DipoleXDH(config)
     polh = PolarXDH({"deriv_A": diph})
     formchk = FormchkInterface(
         resource_filename("pyxdh",
                           "Validation/gaussian/NH3-XYGJOS-freq.fchk"))
     # ASSERT: polar - Gaussian
     np.allclose(-polh.E_2, formchk.polarizability(), atol=1e-6, rtol=1e-4)