Beispiel #1
0
    def test_ccsd_t_high_cost(self):
        n = 14
        cell = make_test_cell.test_cell_n3([n] * 3)

        kpts = cell.make_kpts([1, 1, 2])
        kpts -= kpts[0]
        kmf = pbcscf.KRHF(cell, kpts=kpts)
        ehf = kmf.kernel()

        mycc = pbcc.KRCCSD(kmf)
        eris = mycc.ao2mo()
        ecc, t1, t2 = mycc.kernel(eris=eris)

        eris.mo_energy = [eris.fock[i].diagonal() for i in range(len(kpts))]
        energy_t = kccsd_t_rhf.kernel(mycc, eris=eris)
        energy_t_bench = -0.00191443154358
        self.assertAlmostEqual(energy_t, energy_t_bench, 6)
Beispiel #2
0
    def test_ccsd_t_high_cost(self):
        n = 14
        cell = make_test_cell.test_cell_n3([n]*3)

        kpts = cell.make_kpts([1, 1, 2])
        kpts -= kpts[0]
        kmf = pbcscf.KRHF(cell, kpts=kpts)
        ehf = kmf.kernel()

        mycc = pbcc.KRCCSD(kmf)
        eris = mycc.ao2mo()
        ecc, t1, t2 = mycc.kernel(eris=eris)

        eris.mo_energy = [eris.fock[i].diagonal() for i in range(len(kpts))]
        energy_t = kccsd_t_rhf.kernel(mycc, eris=eris)
        energy_t_bench = -0.00191443154358
        self.assertAlmostEqual(energy_t, energy_t_bench, 6)
Beispiel #3
0
    def test_rccsd_t_vs_gccsd_t(self):
        '''Test rccsd(t) vs gccsd(t) with k-points.'''
        from pyscf.pbc.scf.addons import convert_to_ghf
        kmf = copy.copy(rand_kmf)
        mat_veff = kmf.get_veff().round(4)
        mat_hcore = kmf.get_hcore().round(4)
        kmf.get_veff = lambda *x: mat_veff
        kmf.get_hcore = lambda *x: mat_hcore

        rand_cc = pbcc.KRCCSD(kmf)
        eris = rand_cc.ao2mo(kmf.mo_coeff)
        eris.mo_energy = [
            eris.fock[k].diagonal() for k in range(rand_cc.nkpts)
        ]
        t1, t2 = rand_t1_t2(kmf, rand_cc)
        rand_cc.t1, rand_cc.t2, rand_cc.eris = t1, t2, eris
        energy_t = kccsd_t_rhf.kernel(rand_cc, eris=eris)

        gkmf = convert_to_ghf(rand_kmf)
        # Round to make this insensitive to small changes between PySCF versions
        mat_veff = gkmf.get_veff().round(4)
        mat_hcore = gkmf.get_hcore().round(4)
        gkmf.get_veff = lambda *x: mat_veff
        gkmf.get_hcore = lambda *x: mat_hcore

        from pyscf.pbc.cc import kccsd_t
        rand_gcc = pbcc.KGCCSD(gkmf)
        eris = rand_gcc.ao2mo(rand_gcc.mo_coeff)
        eris.mo_energy = [
            eris.fock[k].diagonal() for k in range(rand_cc.nkpts)
        ]
        gt1 = rand_gcc.spatial2spin(t1)
        gt2 = rand_gcc.spatial2spin(t2)
        rand_gcc.t1, rand_gcc.t2, rand_gcc.eris = gt1, gt2, eris
        genergy_t = kccsd_t.kernel(rand_gcc, eris=eris)

        self.assertAlmostEqual(energy_t, -65.5365125645066, 6)
        self.assertAlmostEqual(energy_t, genergy_t, 8)
Beispiel #4
0
 def ccsd_t(self, t1=None, t2=None, eris=None):
     from pyscf.pbc.cc import kccsd_t_rhf
     if t1 is None: t1 = self.t1
     if t2 is None: t2 = self.t2
     if eris is None: eris = self.ao2mo(self.mo_coeff)
     return kccsd_t_rhf.kernel(self, eris, t1, t2, self.verbose)