Beispiel #1
0
    def test_SCF_dipderiv(self):
        from pyxdh.Utilities.test_molecules import Mol_H2O2
        from pyxdh.DerivOnce import DipoleSCF, GradSCF

        # HF
        H2O2 = Mol_H2O2()
        dip_deriv = DipoleSCF({"scf_eng": H2O2.hf_eng, "cphf_tol": 1e-10})
        grad_deriv = GradSCF({"scf_eng": H2O2.hf_eng, "cphf_tol": 1e-10})
        self.valid_assert(dip_deriv, grad_deriv,
                          "Validation/gaussian/H2O2-HF-freq.fchk")

        # B3LYP
        H2O2 = Mol_H2O2()
        grids_cphf = H2O2.gen_grids(50, 194)
        dip_deriv = DipoleSCF({
            "scf_eng": H2O2.gga_eng,
            "cphf_grids": grids_cphf,
            "cphf_tol": 1e-10
        })
        grad_deriv = GradSCF({
            "scf_eng": H2O2.gga_eng,
            "cphf_grids": grids_cphf,
            "cphf_tol": 1e-10
        })
        self.valid_assert(dip_deriv, grad_deriv,
                          "Validation/gaussian/H2O2-B3LYP-freq.fchk")
Beispiel #2
0
 def test_r_rhf_dipole(self):
     scf_eng = scf.RHF(self.mol).run()
     diph = DipoleSCF({"scf_eng": scf_eng})
     formchk = FormchkInterface(
         resource_filename("pyxdh", "Validation/gaussian/NH3-HF-freq.fchk"))
     # ASSERT: dipole - Gaussian
     assert np.allclose(diph.E_1, formchk.dipole(), atol=1e-6, rtol=1e-4)
Beispiel #3
0
 def test_r_b3lyp_dipole(self):
     scf_eng = dft.RKS(self.mol, xc="B3LYPg")
     scf_eng.grids = self.grids
     scf_eng.run()
     diph = DipoleSCF({"scf_eng": scf_eng})
     formchk = FormchkInterface(
         resource_filename("pyxdh",
                           "Validation/gaussian/NH3-B3LYP-freq.fchk"))
     # ASSERT: dipole - Gaussian
     assert np.allclose(diph.E_1, formchk.dipole(), atol=1e-6, rtol=1e-4)
Beispiel #4
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)
Beispiel #5
0
 def test_r_rhf_dipderiv(self):
     scf_eng = scf.RHF(self.mol).run()
     gradh = GradSCF({"scf_eng": scf_eng})
     diph = DipoleSCF({"scf_eng": scf_eng})
     ddh = DipDerivSCF({"deriv_A": diph, "deriv_B": gradh})
     formchk = FormchkInterface(
         resource_filename("pyxdh", "Validation/gaussian/NH3-HF-freq.fchk"))
     # ASSERT: hessian - Gaussian
     assert np.allclose(ddh.E_2.T,
                        formchk.dipolederiv(),
                        atol=5e-6,
                        rtol=2e-4)
Beispiel #6
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))
Beispiel #7
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)
Beispiel #8
0
 def test_r_b3lyp_dipderiv(self):
     scf_eng = dft.RKS(self.mol, xc="B3LYPg")
     scf_eng.grids = self.grids
     scf_eng.run()
     gradh = GradSCF({"scf_eng": scf_eng, "cphf_grids": self.grids_cphf})
     diph = DipoleSCF({"scf_eng": scf_eng, "cphf_grids": self.grids_cphf})
     ddh = DipDerivSCF({"deriv_A": diph, "deriv_B": gradh})
     formchk = FormchkInterface(
         resource_filename("pyxdh",
                           "Validation/gaussian/NH3-B3LYP-freq.fchk"))
     # ASSERT: hessian - Gaussian
     assert np.allclose(ddh.E_2.T,
                        formchk.dipolederiv(),
                        atol=5e-6,
                        rtol=2e-4)