示例#1
0
文件: rccsd_slow.py 项目: xlzan/pyscf
    def _make_shared_1e(self):
        cput0 = (time.clock(), time.time())
        log = logger.Logger(self.stdout, self.verbose)

        t1, t2, eris = self.t1, self.t2, self.eris
        self.Loo = imd.Loo(t1, t2, eris)
        self.Lvv = imd.Lvv(t1, t2, eris)
        self.Fov = imd.cc_Fov(t1, t2, eris)

        log.timer('EOM-CCSD shared one-electron intermediates', *cput0)
示例#2
0
文件: rccsd_slow.py 项目: xlzan/pyscf
def update_amps(cc, t1, t2, eris):
    # Ref: Hirata et al., J. Chem. Phys. 120, 2581 (2004) Eqs.(35)-(36)
    time0 = time.clock(), time.time()
    log = logger.Logger(cc.stdout, cc.verbose)
    nocc, nvir = t1.shape
    fock = eris.fock

    fov = fock[:nocc, nocc:]
    foo = fock[:nocc, :nocc]
    fvv = fock[nocc:, nocc:]

    mo_e = eris.fock.diagonal()
    eia = mo_e[:nocc, None] - mo_e[None, nocc:]
    eijab = lib.direct_sum('ia,jb->ijab', eia, eia)

    Foo = imd.cc_Foo(t1, t2, eris)
    Fvv = imd.cc_Fvv(t1, t2, eris)
    Fov = imd.cc_Fov(t1, t2, eris)

    # Move energy terms to the other side
    Foo -= np.diag(np.diag(foo))
    Fvv -= np.diag(np.diag(fvv))

    # T1 equation
    t1new = np.array(fov).conj()
    t1new += -2 * einsum('kc,ka,ic->ia', fov, t1, t1)
    t1new += einsum('ac,ic->ia', Fvv, t1)
    t1new += -einsum('ki,ka->ia', Foo, t1)
    t1new += 2 * einsum('kc,kica->ia', Fov, t2)
    t1new += -einsum('kc,ikca->ia', Fov, t2)
    t1new += einsum('kc,ic,ka->ia', Fov, t1, t1)
    t1new += 2 * einsum('akic,kc->ia', eris.voov, t1)
    t1new += -einsum('kaic,kc->ia', eris.ovov, t1)
    t1new += 2 * einsum('akcd,ikcd->ia', eris.vovv, t2)
    t1new += -einsum('akdc,ikcd->ia', eris.vovv, t2)
    t1new += 2 * einsum('akcd,ic,kd->ia', eris.vovv, t1, t1)
    t1new += -einsum('akdc,ic,kd->ia', eris.vovv, t1, t1)
    t1new += -2 * einsum('klic,klac->ia', eris.ooov, t2)
    t1new += einsum('lkic,klac->ia', eris.ooov, t2)
    t1new += -2 * einsum('klic,ka,lc->ia', eris.ooov, t1, t1)
    t1new += einsum('lkic,ka,lc->ia', eris.ooov, t1, t1)

    # T2 equation
    t2new = np.array(eris.oovv).conj()
    if cc.cc2:
        Woooo2 = np.array(eris.oooo)
        Woooo2 += einsum('klic,jc->klij', eris.ooov, t1)
        Woooo2 += einsum('lkjc,ic->klij', eris.ooov, t1)
        Woooo2 += einsum('klcd,ic,jd->klij', eris.oovv, t1, t1)
        t2new += einsum('klij,ka,lb->ijab', Woooo2, t1, t1)
        # avoid transpose inside loop
        ovvv = np.array(eris.vovv).transpose(1, 0, 3, 2)
        for a in range(nvir):
            Wvvvv2_a = eris.vvvv[a].copy()
            Wvvvv2_a += -einsum('kcd,kb->bcd', eris.vovv[a], t1)
            Wvvvv2_a += -np.einsum('k,kbcd->bcd', t1[:, a], ovvv)
            t2new[:, :, a, :] += einsum('bcd,ic,jd->ijb', Wvvvv2_a, t1, t1)
        Lvv2 = fvv - einsum('kc,ka->ac', fov, t1)
        Lvv2 -= np.diag(np.diag(fvv))
        tmp = einsum('ac,ijcb->ijab', Lvv2, t2)
        t2new += (tmp + tmp.transpose(1, 0, 3, 2))
        Loo2 = foo + einsum('kc,ic->ki', fov, t1)
        Loo2 -= np.diag(np.diag(foo))
        tmp = einsum('ki,kjab->ijab', Loo2, t2)
        t2new -= (tmp + tmp.transpose(1, 0, 3, 2))
    else:
        Loo = imd.Loo(t1, t2, eris)
        Lvv = imd.Lvv(t1, t2, eris)
        Loo -= np.diag(np.diag(foo))
        Lvv -= np.diag(np.diag(fvv))
        Woooo = imd.cc_Woooo(t1, t2, eris)
        Wvoov = imd.cc_Wvoov(t1, t2, eris)
        Wvovo = imd.cc_Wvovo(t1, t2, eris)
        Wvvvv = imd.cc_Wvvvv(t1, t2, eris)
        t2new += einsum('klij,klab->ijab', Woooo, t2)
        t2new += einsum('klij,ka,lb->ijab', Woooo, t1, t1)
        for a in range(nvir):
            Wvvvv_a = np.array(Wvvvv[a]).copy()
            t2new[:, :, a, :] += einsum('bcd,ijcd->ijb', Wvvvv_a, t2)
            t2new[:, :, a, :] += einsum('bcd,ic,jd->ijb', Wvvvv_a, t1, t1)
        tmp = einsum('ac,ijcb->ijab', Lvv, t2)
        t2new += (tmp + tmp.transpose(1, 0, 3, 2))
        tmp = einsum('ki,kjab->ijab', Loo, t2)
        t2new -= (tmp + tmp.transpose(1, 0, 3, 2))
        tmp = 2 * einsum('akic,kjcb->ijab', Wvoov, t2) - einsum(
            'akci,kjcb->ijab', Wvovo, t2)
        t2new += (tmp + tmp.transpose(1, 0, 3, 2))
        tmp = einsum('akic,kjbc->ijab', Wvoov, t2)
        t2new -= (tmp + tmp.transpose(1, 0, 3, 2))
        tmp = einsum('bkci,kjac->ijab', Wvovo, t2)
        t2new -= (tmp + tmp.transpose(1, 0, 3, 2))

    tmp2 = np.array(eris.vovv).transpose(3,2,1,0).conj() \
            - einsum('kbic,ka->abic',eris.ovov,t1)
    tmp = einsum('abic,jc->ijab', tmp2, t1)
    t2new += (tmp + tmp.transpose(1, 0, 3, 2))
    tmp2 = np.array(eris.ooov).transpose(3,2,1,0).conj() \
            + einsum('akic,jc->akij',eris.voov,t1)
    tmp = einsum('akij,kb->ijab', tmp2, t1)
    t2new -= (tmp + tmp.transpose(1, 0, 3, 2))

    t1new /= eia
    t2new /= eijab

    time0 = log.timer_debug1('update t1 t2', *time0)

    return t1new, t2new