def make_intermediates(mycc, t1, t2, eris): saved = ccsd_lambda.make_intermediates(mycc, t1, t2, eris) nocc, nvir = t1.shape eris_ovvv = _cp(eris.ovvv) eris_ovvv = _ccsd.unpack_tril(eris_ovvv.reshape(nocc * nvir, -1)) eris_ovvv = eris_ovvv.reshape(nocc, nvir, nvir, nvir) mo_e = mycc._scf.mo_energy eia = lib.direct_sum('i-a->ia', mo_e[:nocc], mo_e[nocc:]) d3 = lib.direct_sum('ia,jb,kc->ijkabc', eia, eia, eia) eris_ovoo = eris.ovoo w = (numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) / d3 v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) / d3 * .5 w = ccsd_t.p6_(w) v = ccsd_t.p6_(v) rwv = ccsd_t.r6_(w * 2 + v) jov = numpy.einsum('jbkc,ijkabc->ia', eris.ovov, ccsd_t.r6_(w)) joovv = numpy.einsum('iabf,ijkabc->kjcf', eris_ovvv, rwv) joovv -= numpy.einsum('iajm,ijkabc->mkbc', eris.ovoo, rwv) joovv = joovv + joovv.transpose(1, 0, 3, 2) saved.jov = jov saved.joovv = joovv return saved
def gamma2_intermediates(mycc, t1, t2, l1, l2, eris=None, max_memory=2000): dovov, dvvvv, doooo, doovv, dovvo, dvvov, dovvv, dooov = \ ccsd_rdm.gamma2_intermediates(mycc, t1, t2, l1, l2) if eris is None: eris = ccsd._ERIS(mycc) nocc, nvir = t1.shape eris_ovvv = _cp(eris.ovvv) eris_ovvv = _ccsd.unpack_tril(eris_ovvv.reshape(nocc*nvir,-1)) eris_ovvv = eris_ovvv.reshape(nocc,nvir,nvir,nvir) mo_e = mycc._scf.mo_energy eia = lib.direct_sum('i-a->ia',mo_e[:nocc], mo_e[nocc:]) d3 = lib.direct_sum('ia,jb,kc->ijkabc', eia, eia, eia) eris_ovoo = eris.ovoo w =(numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) / d3 v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) / d3 * .5 w = ccsd_t.p6_(w) v = ccsd_t.p6_(v) rw = ccsd_t.r6_(w) rwv = ccsd_t.r6_(w*2+v) dovov += numpy.einsum('kc,ijkabc->iajb', t1, rw) * .5 dooov -= numpy.einsum('mkbc,ijkabc->jmia', t2, rwv) # Note "dovvv +=" also changes the value of dvvov dovvv += numpy.einsum('kjcf,ijkabc->iabf', t2, rwv) dvvov = dovvv.transpose(2,3,0,1) return dovov, dvvvv, doooo, doovv, dovvo, dvvov, dovvv, dooov
def make_intermediates(mycc, t1, t2, eris): saved = ccsd_lambda.make_intermediates(mycc, t1, t2, eris) nocc, nvir = t1.shape eris_ovvv = _cp(eris.ovvv) eris_ovvv = _ccsd.unpack_tril(eris_ovvv.reshape(nocc*nvir,-1)) eris_ovvv = eris_ovvv.reshape(nocc,nvir,nvir,nvir) mo_e = mycc._scf.mo_energy eia = lib.direct_sum('i-a->ia',mo_e[:nocc], mo_e[nocc:]) d3 = lib.direct_sum('ia,jb,kc->ijkabc', eia, eia, eia) eris_ovoo = eris.ovoo w =(numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) / d3 v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) / d3 * .5 w = ccsd_t.p6_(w) v = ccsd_t.p6_(v) rwv = ccsd_t.r6_(w*2+v) jov = numpy.einsum('jbkc,ijkabc->ia', eris.ovov, ccsd_t.r6_(w)) joovv = numpy.einsum('iabf,ijkabc->kjcf', eris_ovvv, rwv) joovv-= numpy.einsum('iajm,ijkabc->mkbc', eris.ovoo, rwv) joovv = joovv + joovv.transpose(1,0,3,2) saved.jov = jov saved.joovv = joovv return saved
def gamma1_intermediates(mycc, t1, t2, l1, l2, eris=None, max_memory=2000): doo, dov, dvo, dvv = ccsd_rdm.gamma1_intermediates(mycc, t1, t2, l1, l2) if eris is None: eris = ccsd._ERIS(mycc) nocc, nvir = t1.shape eris_ovvv = _cp(eris.ovvv) eris_ovvv = _ccsd.unpack_tril(eris_ovvv.reshape(nocc*nvir,-1)) eris_ovvv = eris_ovvv.reshape(nocc,nvir,nvir,nvir) mo_e = mycc._scf.mo_energy eia = lib.direct_sum('i-a->ia',mo_e[:nocc], mo_e[nocc:]) d3 = lib.direct_sum('ia,jb,kc->ijkabc', eia, eia, eia) eris_ovoo = eris.ovoo w =(numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) / d3 v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) / d3 * .5 w = ccsd_t.p6_(w) v = ccsd_t.p6_(v) wv = w+v rw = ccsd_t.r6_(w) goo =-numpy.einsum('iklabc,jklabc->ij', wv, rw) * .5 gvv = numpy.einsum('ijkacd,ijkbcd->ab', wv, rw) * .5 doo += goo dvv += gvv return doo, dov, dvo, dvv
#print e3ref, e3-(mf.e_tot+ecc) nocc, nvir = t1.shape eris_ovvv = _cp(eris.ovvv) eris_ovvv = lib.unpack_tril(eris_ovvv.reshape(nocc * nvir, -1)) eris_ovvv = eris_ovvv.reshape(nocc, nvir, nvir, nvir) mo_e = mcc._scf.mo_energy eia = lib.direct_sum('i-a->ia', mo_e[:nocc], mo_e[nocc:]) d3 = lib.direct_sum('ia,jb,kc->ijkabc', eia, eia, eia) eris_ovoo = eris.ovoo w = (numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) / d3 v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) / d3 * .5 w = ccsd_t.p6_(w) v = ccsd_t.p6_(v) rw = ccsd_t.r6_(w) rwv = ccsd_t.r6_(w * 2 + v * 0) dovov = numpy.einsum('kc,ijkabc->iajb', t1, rw) dooov = -numpy.einsum('mkbc,ijkabc->jmia', t2, rwv) dovvv = numpy.einsum('kjcf,ijkabc->iabf', t2, rwv) e3a = numpy.einsum('iajb,iajb', eris.ovov, dovov) e3a += numpy.einsum('iajm,jmia', eris.ovoo, dooov) e3a += numpy.einsum('iabf,iabf', eris_ovvv, dovvv) print(e3a) w = (numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) wvd = ccsd_t.p6_(w + .5 * v) / d3 print(numpy.einsum('ijkabc,ijkabc', wvd, ccsd_t.r6_(w)) * 2)
#print e3ref, e3-(mf.e_tot+ecc) nocc, nvir = t1.shape eris_ovvv = _cp(eris.ovvv) eris_ovvv = _ccsd.unpack_tril(eris_ovvv.reshape(nocc*nvir,-1)) eris_ovvv = eris_ovvv.reshape(nocc,nvir,nvir,nvir) mo_e = mcc._scf.mo_energy eia = lib.direct_sum('i-a->ia',mo_e[:nocc], mo_e[nocc:]) d3 = lib.direct_sum('ia,jb,kc->ijkabc', eia, eia, eia) eris_ovoo = eris.ovoo w =(numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) / d3 v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) / d3 * .5 w = ccsd_t.p6_(w) v = ccsd_t.p6_(v) rw = ccsd_t.r6_(w) rwv = ccsd_t.r6_(w*2+v*0) dovov = numpy.einsum('kc,ijkabc->iajb', t1, rw) dooov =-numpy.einsum('mkbc,ijkabc->jmia', t2, rwv) dovvv = numpy.einsum('kjcf,ijkabc->iabf', t2, rwv) e3a = numpy.einsum('iajb,iajb', eris.ovov, dovov) e3a+= numpy.einsum('iajm,jmia', eris.ovoo, dooov) e3a+= numpy.einsum('iabf,iabf', eris_ovvv, dovvv) print(e3a) w =(numpy.einsum('iabf,kjcf->ijkabc', eris_ovvv, t2) - numpy.einsum('iajm,mkbc->ijkabc', eris_ovoo, t2)) v = numpy.einsum('iajb,kc->ijkabc', eris.ovov, t1) wvd = ccsd_t.p6_(w + .5 * v) / d3 print(numpy.einsum('ijkabc,ijkabc', wvd, ccsd_t.r6_(w)) * 2)