Exemple #1
0
    def test_dmd_high_cost(self):
        cell = gto.Cell()
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.685068664391   1.685068664391   1.685068664391
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        nmp = [1, 1, 2]

        # treating 1*1*2 supercell at gamma point
        supcell = super_cell(cell, nmp)
        gmf = scf.GHF(supcell, exxdiv=None)
        ehf = gmf.kernel()
        gcc = cc.GCCSD(gmf)
        gcc.conv_tol = 1e-12
        gcc.conv_tol_normt = 1e-10
        gcc.max_cycle = 250
        ecc, t1, t2 = gcc.kernel()
        print('GHF energy (supercell) %.7f \n' % (float(ehf) / 2.))
        print('GCCSD correlation energy (supercell) %.7f \n' %
              (float(ecc) / 2.))

        eom = eom_gccsd.EOMIP(gcc)
        e1, v = eom.ipccsd(nroots=2)
        eom = eom_gccsd.EOMEA(gcc)
        e2, v = eom.eaccsd(nroots=2, koopmans=True)

        # Running HF and CCSD with 1x1x2 Monkhorst-Pack k-point mesh
        kmf = scf.KGHF(cell, kpts=cell.make_kpts(nmp), exxdiv=None)
        ehf2 = kmf.kernel()

        mycc = cc.KGCCSD(kmf)
        mycc.conv_tol = 1e-12
        mycc.conv_tol_normt = 1e-10
        mycc.max_cycle = 250
        ecc2, t1, t2 = mycc.kernel()
        print('GHF energy %.7f \n' % (float(ehf2)))
        print('GCCSD correlation energy  %.7f \n' % (float(ecc2)))

        kptlist = cell.make_kpts(nmp)
        eom = EOMIP(mycc)
        e1_obt, v = eom.ipccsd(nroots=2, kptlist=[0])
        eom = EOMEA(mycc)
        e2_obt, v = eom.eaccsd(nroots=2, koopmans=True, kptlist=[0])

        assert (ehf / 2 - ehf2 < 1e-10)
        assert (ecc / 2 - ecc2 < 1e-10)
        assert (e1[0] - (e1_obt[0][0]) < 1e-7)
        assert (e2[0] - (e2_obt[0][0]) < 1e-7)
Exemple #2
0
nmo = dm1a.shape[0]
eri_aa = mf.with_df.ao2mo(mf.mo_coeff[0], kpts=kpt).reshape([nmo]*4)
eri_bb = mf.with_df.ao2mo(mf.mo_coeff[1], kpts=kpt).reshape([nmo]*4)
eri_ab = mf.with_df.ao2mo((mf.mo_coeff[0],mf.mo_coeff[0],mf.mo_coeff[1],mf.mo_coeff[1]), kpts=kpt).reshape([nmo]*4)
hcore = mf.get_hcore()
h1a = reduce(numpy.dot, (mf.mo_coeff[0].conj().T, hcore, mf.mo_coeff[0]))
h1b = reduce(numpy.dot, (mf.mo_coeff[1].conj().T, hcore, mf.mo_coeff[1]))
e_tot = (numpy.einsum('ij,ji', h1a, dm1a) +
         numpy.einsum('ij,ji', h1b, dm1b) +
         numpy.einsum('ijkl,jilk', eri_aa, dm2aa)*.5 +
         numpy.einsum('ijkl,jilk', eri_ab, dm2ab)    +
         numpy.einsum('ijkl,jilk', eri_bb, dm2bb)*.5 + mf.energy_nuc())
print("UCCSD energy based on CCSD density matrices =", e_tot.real)


mf = scf.addons.convert_to_ghf(mf)
mycc = cc.GCCSD(mf).run()
print("GCCSD energy (per unit cell) at k-point =", mycc.e_tot)
dm1 = mycc.make_rdm1()
dm2 = mycc.make_rdm2()
nao = cell.nao_nr()
nmo = mf.mo_coeff.shape[1]
mo = mf.mo_coeff[:nao] + mf.mo_coeff[nao:]
eri_mo = mf.with_df.ao2mo(mo, kpts=kpt).reshape([nmo]*4)
orbspin = mf.mo_coeff.orbspin
eri_mo[orbspin[:,None]!=orbspin] = 0
eri_mo[:,:,orbspin[:,None]!=orbspin] = 0
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("GCCSD energy based on CCSD density matrices =", e_tot.real)