示例#1
0
    def _test_cu_metallic_frozen_vir(self, kmf, cell, nk=[1, 1, 1]):
        assert cell.mesh == [7, 7, 7]
        ecc3_bench = -0.94610600274627665
        max_cycle = 2

        # The following calculation at full convergence gives -0.58688462599474
        # for a cell.mesh = [25, 25, 25].  It is equivalent to a supercell [1, 1, 2]
        # calculation with frozen = [0, 3, 35].
        mycc = pbcc.KGCCSD(kmf, frozen=[[2, 3, 34, 35], [0, 1]])
        mycc.max_cycle = max_cycle
        mycc.iterative_damping = 0.05
        eris = mycc.ao2mo()
        eris.mo_energy = [f.diagonal() for f in eris.fock]
        ecc3, t1, t2 = mycc.kernel(eris=eris)

        self.assertAlmostEqual(ecc3, ecc3_bench, 6)

        check_gamma = False  # Turn me on to run the supercell calculation!

        if check_gamma:
            from pyscf.pbc.tools.pbc import super_cell
            supcell = super_cell(cell, nk)
            kmf = pbcscf.RHF(supcell, exxdiv=None)
            ehf = kmf.scf()

            mycc = pbcc.RCCSD(kmf, frozen=[0, 3, 35])
            mycc.max_cycle = max_cycle
            mycc.iterative_damping = 0.05
            ecc, t1, t2 = mycc.kernel()

            print('Gamma energy =', ecc / np.prod(nk))
            print('K-point energy =', ecc3)
示例#2
0
    def _test_cu_metallic_frozen_vir(self, kmf, cell):
        assert cell.mesh == [7, 7, 7]
        ecc3_bench = -0.76794053711557086
        max_cycle = 5

        # The following calculation at full convergence gives -0.58688462599474
        # for a cell.mesh = [25, 25, 25].  It is equivalent to a supercell [1, 1, 2]
        # calculation with frozen = [0, 3, 35].
        mycc = pbcc.kccsd_rhf.RCCSD(kmf, frozen=[[1, 17], [0]])
        mycc.diis_start_cycle = 1
        mycc.max_cycle = max_cycle
        mycc.iterative_damping = 0.05
        eris = mycc.ao2mo()
        eris.mo_energy = [f.diagonal() for f in eris.fock]
        ecc3, t1, t2 = mycc.kernel(eris=eris)

        self.assertAlmostEqual(ecc3, ecc3_bench, 6)

        ew, ev = mycc.ipccsd(nroots=3, koopmans=True, kptlist=[1])
        self.assertAlmostEqual(ew[0][0], -3.028339571372944, 3)
        self.assertAlmostEqual(ew[0][1], -2.850636489429295, 3)
        self.assertAlmostEqual(ew[0][2], -2.801491561537961, 3)

        ew, ev = mycc.eaccsd(nroots=3, koopmans=True, kptlist=[1])
        self.assertAlmostEqual(ew[0][0], 3.266064683223669, 2)
        self.assertAlmostEqual(ew[0][1], 3.281390137070985, 2)
        self.assertAlmostEqual(ew[0][2], 3.426297911456726, 2)

        check_gamma = False  # Turn me on to run the supercell calculation!

        nk = [1, 1, 2]
        if check_gamma:
            from pyscf.pbc.tools.pbc import super_cell
            supcell = super_cell(cell, nk)
            kmf = pbcscf.RHF(supcell, exxdiv=None)
            ehf = kmf.scf()

            mycc = pbcc.RCCSD(kmf, frozen=[0, 3, 35])
            mycc.max_cycle = max_cycle
            mycc.iterative_damping = 0.04
            ecc, t1, t2 = mycc.kernel()

            print('Gamma energy =', ecc / np.prod(nk))
            print('K-point energy =', ecc3_bench)

            ew, ev = mycc.ipccsd(nroots=5)
            # For cell mesh of [25, 25, 25], we get:
            #
            # EOM-CCSD root 0 E = -3.052456841625895
            # EOM-CCSD root 1 E = -2.989798972232893
            # EOM-CCSD root 2 E = -2.839646545189692
            # EOM-CCSD root 3 E = -2.836645046801352
            # EOM-CCSD root 4 E = -2.831020659800223

            ew, ev = mycc.eaccsd(nroots=5)
示例#3
0
    def test_ccsd_t_non_hf_frozen(self):
        '''Tests ccsd and ccsd_t for non-Hartree-Fock references with frozen orbitals
        using supercell vs k-point calculation.'''
        n = 14
        cell = make_test_cell.test_cell_n3([n] * 3)
        #import sys
        #cell.stdout = sys.stdout
        #cell.verbose = 7

        nk = [2, 1, 1]
        kpts = cell.make_kpts(nk)
        kpts -= kpts[0]
        kks = pbcdft.KRKS(cell, kpts=kpts)
        ekks = kks.kernel()

        khf = pbcscf.KRHF(cell)
        khf.__dict__.update(kks.__dict__)

        mycc = pbcc.KRCCSD(khf, frozen=1)
        eris = mycc.ao2mo()
        ekcc, t1, t2 = mycc.kernel(eris=eris)

        ekcc_t = mycc.ccsd_t(eris=eris)

        # Run supercell
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nk)
        rks = pbcdft.RKS(supcell)
        erks = rks.kernel()

        rhf = pbcscf.RHF(supcell)
        rhf.__dict__.update(rks.__dict__)

        mycc = pbcc.RCCSD(rhf, frozen=2)
        eris = mycc.ao2mo()
        ercc, t1, t2 = mycc.kernel(eris=eris)
        self.assertAlmostEqual(ercc / np.prod(nk), -0.11467718013872311, 6)
        self.assertAlmostEqual(ercc / np.prod(nk), ekcc, 6)

        ercc_t = mycc.ccsd_t(eris=eris)
        self.assertAlmostEqual(ercc_t / np.prod(nk), -0.00066503872045200996,
                               6)
        self.assertAlmostEqual(ercc_t / np.prod(nk), ekcc_t, 6)
示例#4
0
    def test_ccsd_t_non_hf(self):
        '''Tests ccsd and ccsd_t for non-Hartree-Fock references
        using supercell vs k-point calculation.'''
        n = 14
        cell = make_test_cell.test_cell_n3([n] * 3)

        nk = [2, 1, 1]
        kpts = cell.make_kpts(nk)
        kpts -= kpts[0]
        kks = pbcdft.KRKS(cell, kpts=kpts)
        ekks = kks.kernel()

        khf = pbcscf.KRHF(cell)
        khf.__dict__.update(kks.__dict__)

        mycc = pbcc.KRCCSD(khf)
        eris = mycc.ao2mo()
        ekcc, t1, t2 = mycc.kernel(eris=eris)

        ekcc_t = mycc.ccsd_t(eris=eris)

        # Run supercell
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nk)
        rks = pbcdft.RKS(supcell)
        erks = rks.kernel()

        rhf = pbcscf.RHF(supcell)
        rhf.__dict__.update(rks.__dict__)

        mycc = pbcc.RCCSD(rhf)
        eris = mycc.ao2mo()
        ercc, t1, t2 = mycc.kernel(eris=eris)
        self.assertAlmostEqual(ercc / np.prod(nk), -0.15632445245405927, 6)
        self.assertAlmostEqual(ercc / np.prod(nk), ekcc, 6)

        ercc_t = mycc.ccsd_t(eris=eris)
        self.assertAlmostEqual(ercc_t / np.prod(nk), -0.00114619248449, 6)
        self.assertAlmostEqual(ercc_t / np.prod(nk), ekcc_t, 6)
示例#5
0
    def test_ccsd_t_hf_frozen(self):
        '''Tests ccsd and ccsd_t for Hartree-Fock references with frozen orbitals
        using supercell vs k-point calculation.'''
        n = 14
        cell = make_test_cell.test_cell_n3([n] * 3)

        nk = [2, 1, 1]
        kpts = cell.make_kpts(nk)
        kpts -= kpts[0]
        kks = pbcscf.KRHF(cell, kpts=kpts)
        ekks = kks.kernel()

        khf = pbcscf.KRHF(cell)
        khf.__dict__.update(kks.__dict__)

        mycc = pbcc.KRCCSD(khf, frozen=1)
        eris = mycc.ao2mo()
        ekcc, t1, t2 = mycc.kernel(eris=eris)
        ekcc_t = mycc.ccsd_t(eris=eris)

        # Run supercell
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nk)
        rks = pbcscf.RHF(supcell)
        erks = rks.kernel()

        rhf = pbcscf.RHF(supcell)
        rhf.__dict__.update(rks.__dict__)

        mycc = pbcc.RCCSD(rhf, frozen=2)
        eris = mycc.ao2mo()
        ercc, t1, t2 = mycc.kernel(eris=eris)
        self.assertAlmostEqual(ercc / np.prod(nk), -0.1137362020855094, 6)
        self.assertAlmostEqual(ercc / np.prod(nk), ekcc, 6)

        ercc_t = mycc.ccsd_t(eris=eris)
        self.assertAlmostEqual(ercc_t / np.prod(nk), -0.0006758642528821, 6)
        self.assertAlmostEqual(ercc_t / np.prod(nk), ekcc_t, 6)
示例#6
0
    def test_single_kpt(self):
        cell = pbcgto.Cell()
        cell.atom = '''
        H 0 0 0
        H 1 0 0
        H 0 1 0
        H 0 1 1
        '''
        cell.a = np.eye(3) * 2
        cell.basis = [[0, [1.2, 1]], [1, [1.0, 1]]]
        cell.verbose = 0
        cell.build()

        kpts = cell.get_abs_kpts([.5, .5, .5]).reshape(1, 3)
        mf = pbcscf.KRHF(cell, kpts=kpts).run(conv_tol=1e-9)
        kcc = pbcc.kccsd_rhf.RCCSD(mf)
        kcc.level_shift = .05
        e0 = kcc.kernel()[0]

        mf = pbcscf.RHF(cell, kpt=kpts[0]).run(conv_tol=1e-9)
        mycc = pbcc.RCCSD(mf)
        e1 = mycc.kernel()[0]
        self.assertAlmostEqual(e0, e1, 5)
示例#7
0
    def test_ccsd_t_hf(self):
        '''Tests ccsd and ccsd_t for Hartree-Fock references.'''
        n = 14
        cell = make_test_cell.test_cell_n3([n] * 3)

        nk = [2, 1, 1]
        kpts = cell.make_kpts(nk)
        kpts -= kpts[0]
        kks = pbcscf.KRHF(cell, kpts=kpts)
        ekks = kks.kernel()

        khf = pbcscf.KRHF(cell)
        khf.__dict__.update(kks.__dict__)

        mycc = pbcc.KRCCSD(khf)
        eris = mycc.ao2mo()
        ekcc, t1, t2 = mycc.kernel(eris=eris)
        ekcc_t = mycc.ccsd_t(eris=eris)

        # Run supercell
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nk)
        rks = pbcscf.RHF(supcell)
        erks = rks.kernel()

        rhf = pbcscf.RHF(supcell)
        rhf.__dict__.update(rks.__dict__)

        mycc = pbcc.RCCSD(rhf)
        eris = mycc.ao2mo()
        ercc, t1, t2 = mycc.kernel(eris=eris)
        self.assertAlmostEqual(ercc / np.prod(nk), -0.15530756381467772, 6)
        self.assertAlmostEqual(ercc / np.prod(nk), ekcc, 6)

        ercc_t = mycc.ccsd_t(eris=eris)
        self.assertAlmostEqual(ercc_t / np.prod(nk), -0.0011112735513837887, 6)
        self.assertAlmostEqual(ercc_t / np.prod(nk), ekcc_t, 6)
示例#8
0
文件: test.py 项目: snsunx/kccgf
cell.rcut *= 2.0
cell.build()

omegas = [-10.99479191]

#
#Run old code
#
supcell = super_cell(cell, nmp)
mf = scf.RHF(supcell, exxdiv=None)
mf.diis = None
mf.conv_tol_grad = 1e-8
mf.conv_tol = 1e-8
ehf = mf.kernel()
mf.analyze()
mycc = cc.RCCSD(mf)
mycc.frozen = [0, 1, 3, 4, 5, 6, 9, 10, 11, 12, 14, 15]
mycc.ip_partition = None
mycc.ea_partition = None
mycc.conv_tol_normt = 1e-10
mycc.conv_tol = 1e-10
mycc.kernel()
#p=[8,9,10,11,12,13,14,15]
#q=[8,9,10,11,12,13,14,15]
p = [2, 3]
q = [2, 3]
gfunccc = gf.OneParticleGF(mycc)
gf_ea = gfunccc.kernel(p, q, omegas)
print("KRCCSD energy (per unit cell) =", mycc.e_tot)

print "gf"
示例#9
0
    kpts -= kpts[0]
    kmf = scf.KRHF(cell, kpts=kpts, exxdiv=None)
    kmf.conv_tol = 1e-12
    kmf.conv_tol_grad = 1e-12
    kmf.direct_scf_tol = 1e-16
    ehf = kmf.kernel()

    mycc = cc.KRCCSD(kmf)
    eris = mycc.ao2mo()
    ecc, t1, t2 = mycc.kernel(eris=eris)
    energy_t = kernel(mycc, eris=eris, verbose=9)

    # Start of supercell calculations
    from pyscf.pbc.tools.pbc import super_cell
    supcell = super_cell(cell, nmp)
    supcell.build()
    kmf = scf.RHF(supcell, exxdiv=None)
    kmf.conv_tol = 1e-12
    kmf.conv_tol_grad = 1e-12
    kmf.direct_scf_tol = 1e-16
    sup_ehf = kmf.kernel()

    myscc = cc.RCCSD(kmf)
    eris = myscc.ao2mo()
    sup_ecc, t1, t2 = myscc.kernel(eris=eris)
    sup_energy_t = myscc.ccsd_t(eris=eris)
    print("Kpoint    CCSD: %20.16f" % ecc)
    print("Supercell CCSD: %20.16f" % (sup_ecc / np.prod(nmp)))
    print("Kpoint    CCSD(T): %20.16f" % energy_t)
    print("Supercell CCSD(T): %20.16f" % (sup_energy_t / np.prod(nmp)))
示例#10
0
mycc.kernel()
print("KRCCSD energy (per unit cell) =", mycc.e_tot)


#
# The PBC module provides an separated implementation specified for the single
# k-point calculations.  They are more efficient than the general implementation
# with k-point sampling.  For gamma point, integrals and orbitals are all real
# in this implementation.  They can be mixed with other post-HF methods that
# were provided in the molecular program.
#
kpt = cell.get_abs_kpts([0.25, 0.25, 0.25])
mf = scf.RHF(cell, kpt=kpt, exxdiv=None)
ehf = mf.kernel()

mycc = cc.RCCSD(mf).run()
print("RCCSD energy (per unit cell) at k-point =", mycc.e_tot)
dm1 = mycc.make_rdm1()
dm2 = mycc.make_rdm2()
nmo = mf.mo_coeff.shape[1]
eri_mo = mf.with_df.ao2mo(mf.mo_coeff, kpts=kpt).reshape([nmo]*4)
h1 = reduce(numpy.dot, (mf.mo_coeff.conj().T, mf.get_hcore(), mf.mo_coeff))
e_tot = numpy.einsum('ij,ji', h1, dm1) + numpy.einsum('ijkl,jilk', eri_mo, dm2)*.5 + mf.energy_nuc()
print("RCCSD energy based on CCSD density matrices =", e_tot.real)


mf = scf.addons.convert_to_uhf(mf)
mycc = cc.UCCSD(mf).run()
print("UCCSD energy (per unit cell) at k-point =", mycc.e_tot)
dm1a, dm1b = mycc.make_rdm1()
dm2aa, dm2ab, dm2bb = mycc.make_rdm2()