def _gamma1_intermediates(mycc, t1, t2, l1, l2, eris=None): doo, dov, dvo, dvv = gccsd_rdm._gamma1_intermediates(mycc, t1, t2, l1, l2) if eris is None: eris = mycc.ao2mo() nocc, nvir = t1.shape bcei = numpy.asarray(eris.ovvv).conj().transpose(3,2,1,0) majk = numpy.asarray(eris.ooov).conj().transpose(2,3,0,1) bcjk = numpy.asarray(eris.oovv).conj().transpose(2,3,0,1) mo_e = eris.fock.diagonal().real eia = mo_e[:nocc,None] - mo_e[nocc:] d3 = lib.direct_sum('ia+jb+kc->ijkabc', eia, eia, eia) t3c =(numpy.einsum('jkae,bcei->ijkabc', t2, bcei) - numpy.einsum('imbc,majk->ijkabc', t2, majk)) t3c = t3c - t3c.transpose(0,1,2,4,3,5) - t3c.transpose(0,1,2,5,4,3) t3c = t3c - t3c.transpose(1,0,2,3,4,5) - t3c.transpose(2,1,0,3,4,5) t3c /= d3 t3d = numpy.einsum('ia,bcjk->ijkabc', t1, bcjk) t3d += numpy.einsum('ai,jkbc->ijkabc', eris.fock[nocc:,:nocc], t2) t3d = t3d - t3d.transpose(0,1,2,4,3,5) - t3d.transpose(0,1,2,5,4,3) t3d = t3d - t3d.transpose(1,0,2,3,4,5) - t3d.transpose(2,1,0,3,4,5) t3d /= d3 goo = numpy.einsum('iklabc,jklabc->ij', (t3c+t3d).conj(), t3c) * (1./12) gvv = numpy.einsum('ijkacd,ijkbcd->ab', t3c+t3d, t3c.conj()) * (1./12) doo[numpy.diag_indices(nocc)] -= goo.diagonal() dvv[numpy.diag_indices(nvir)] += gvv.diagonal() dvo += numpy.einsum('ijab,ijkabc->ck', t2.conj(), t3c) * (1./4) return doo, dov, dvo, dvv
def _gamma1_intermediates(mycc, t1, t2, l1, l2, eris=None): doo, dov, dvo, dvv = gccsd_rdm._gamma1_intermediates(mycc, t1, t2, l1, l2) if eris is None: eris = mycc.ao2mo() nocc, nvir = t1.shape bcei = numpy.asarray(eris.ovvv).conj().transpose(3,2,1,0) majk = numpy.asarray(eris.ooov).conj().transpose(2,3,0,1) bcjk = numpy.asarray(eris.oovv).conj().transpose(2,3,0,1) mo_e = eris.mo_energy eia = mo_e[:nocc,None] - mo_e[nocc:] d3 = lib.direct_sum('ia+jb+kc->ijkabc', eia, eia, eia) t3c =(numpy.einsum('jkae,bcei->ijkabc', t2, bcei) - numpy.einsum('imbc,majk->ijkabc', t2, majk)) t3c = t3c - t3c.transpose(0,1,2,4,3,5) - t3c.transpose(0,1,2,5,4,3) t3c = t3c - t3c.transpose(1,0,2,3,4,5) - t3c.transpose(2,1,0,3,4,5) t3c /= d3 t3d = numpy.einsum('ia,bcjk->ijkabc', t1, bcjk) t3d += numpy.einsum('ai,jkbc->ijkabc', eris.fock[nocc:,:nocc], t2) t3d = t3d - t3d.transpose(0,1,2,4,3,5) - t3d.transpose(0,1,2,5,4,3) t3d = t3d - t3d.transpose(1,0,2,3,4,5) - t3d.transpose(2,1,0,3,4,5) t3d /= d3 goo = numpy.einsum('iklabc,jklabc->ij', (t3c+t3d).conj(), t3c) * (1./12) gvv = numpy.einsum('ijkacd,ijkbcd->ab', t3c+t3d, t3c.conj()) * (1./12) doo[numpy.diag_indices(nocc)] -= goo.diagonal() dvv[numpy.diag_indices(nvir)] += gvv.diagonal() dvo += numpy.einsum('ijab,ijkabc->ck', t2.conj(), t3c) * (1./4) return doo, dov, dvo, dvv