Beispiel #1
0
    def test_sgx_jk(self):
        mol = gto.Mole()
        mol.build(
            verbose=0,
            atom=[["O", (0., 0., 0.)], [1, (0., -0.757, 0.587)],
                  [1, (0., 0.757, 0.587)]],
            basis='ccpvdz',
        )
        nao = mol.nao
        #numpy.random.seed(1)
        #dm = numpy.random.random((nao,nao))
        #dm = dm + dm.T
        mf = scf.UHF(mol)
        dm = mf.get_init_guess()

        sgxobj = sgx.SGX(mol)
        sgxobj.grids = sgx_jk.get_gridss(mol, 0, 1e-10)

        with lib.temporary_env(sgxobj, debug=False):
            vj, vk = sgx_jk.get_jk_favork(sgxobj, dm)
        #self.assertAlmostEqual(lib.finger(vj), -19.25235595827077,  9)
        #self.assertAlmostEqual(lib.finger(vk), -16.711443399467267, 9)
        with lib.temporary_env(sgxobj, debug=True):
            vj1, vk1 = sgx_jk.get_jk_favork(sgxobj, dm)
        self.assertAlmostEqual(abs(vj1 - vj).max(), 0, 9)
        self.assertAlmostEqual(abs(vk1 - vk).max(), 0, 9)

        with lib.temporary_env(sgxobj, debug=False):
            vj, vk = sgx_jk.get_jk_favorj(sgxobj, dm)
        #self.assertAlmostEqual(lib.finger(vj), -19.176378579757973, 9)
        #self.assertAlmostEqual(lib.finger(vk), -16.750915356787406, 9)
        with lib.temporary_env(sgxobj, debug=True):
            vj1, vk1 = sgx_jk.get_jk_favorj(sgxobj, dm)
        self.assertAlmostEqual(abs(vj1 - vj).max(), 0, 9)
        self.assertAlmostEqual(abs(vk1 - vk).max(), 0, 9)
Beispiel #2
0
    def build(self, level=None):
        if level is None:
            level = self.grids_level_f
        self.grids = sgx_jk.get_gridss(self.mol, level, self.grids_thrd)
        self._opt = _make_opt(self.mol)

        # In the RSH-integral temporary treatment, recursively rebuild SGX
        # objects in _rsh_df.
        if self._rsh_df:
            for k, v in self._rsh_df.items():
                v.build(level)
        return self
Beispiel #3
0
    def test_rsh_get_jk(self):
        mol = gto.M(verbose = 0,
            atom = 'H 0 0 0; H 0 0 1',
            basis = 'ccpvdz',
        )
        nao = mol.nao_nr()
        numpy.random.seed(1)
        dm = numpy.random.random((2,nao,nao))
        sgxobj = sgx.SGX(mol)
        sgxobj.grids = sgx_jk.get_gridss(mol, 0, 1e-7)
        vj, vk = sgxobj.get_jk(dm, hermi=0, omega=1.1)
        self.assertAlmostEqual(lib.finger(vj), 4.78603728911563 , 9)
        self.assertAlmostEqual(lib.finger(vk), 8.614628576953983, 9)

        vj1, vk1 = scf.hf.get_jk(mol, dm, hermi=0, omega=1.1)
        self.assertAlmostEqual(abs(vj-vj1).max(), 0, 2)
        self.assertAlmostEqual(abs(vk-vk1).max(), 0, 2)