Ejemplo n.º 1
0
def update_amps(cc, t1, t2, eris):
    assert (isinstance(eris, _PhysicistsERIs))
    nocc, nvir = t1.shape
    fock = eris.fock

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

    tau = imd.make_tau(t2, t1, t1)

    Fvv = imd.cc_Fvv(t1, t2, eris)
    Foo = imd.cc_Foo(t1, t2, eris)
    Fov = imd.cc_Fov(t1, t2, eris)
    Woooo = imd.cc_Woooo(t1, t2, eris)
    Wvvvv = imd.cc_Wvvvv(t1, t2, eris)
    Wovvo = imd.cc_Wovvo(t1, t2, eris)

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

    # T1 equation
    t1new = einsum('ie,ae->ia', t1, Fvv)
    t1new += -einsum('ma,mi->ia', t1, Foo)
    t1new += einsum('imae,me->ia', t2, Fov)
    t1new += -einsum('nf,naif->ia', t1, eris.ovov)
    t1new += -0.5 * einsum('imef,maef->ia', t2, eris.ovvv)
    t1new += -0.5 * einsum('mnae,mnie->ia', t2, eris.ooov)
    t1new += fov.conj()

    # T2 equation
    Ftmp = Fvv - 0.5 * einsum('mb,me->be', t1, Fov)
    tmp = einsum('ijae,be->ijab', t2, Ftmp)
    t2new = tmp - tmp.transpose(0, 1, 3, 2)
    Ftmp = Foo + 0.5 * einsum('je,me->mj', t1, Fov)
    tmp = einsum('imab,mj->ijab', t2, Ftmp)
    t2new -= tmp - tmp.transpose(1, 0, 2, 3)
    t2new += np.asarray(eris.oovv).conj()
    t2new += 0.5 * einsum('mnab,mnij->ijab', tau, Woooo)
    t2new += 0.5 * einsum('ijef,abef->ijab', tau, Wvvvv)
    tmp = einsum('imae,mbej->ijab', t2, Wovvo)
    tmp -= -einsum('ie,ma,mbje->ijab', t1, t1, eris.ovov)
    tmp = tmp - tmp.transpose(1, 0, 2, 3)
    tmp = tmp - tmp.transpose(0, 1, 3, 2)
    t2new += tmp
    tmp = einsum('ie,jeba->ijab', t1, np.array(eris.ovvv).conj())
    t2new += (tmp - tmp.transpose(1, 0, 2, 3))
    tmp = einsum('ma,ijmb->ijab', t1, np.asarray(eris.ooov).conj())
    t2new -= (tmp - tmp.transpose(0, 1, 3, 2))

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

    return t1new, t2new
Ejemplo n.º 2
0
Archivo: gccsd.py Proyecto: sunqm/pyscf
def update_amps(cc, t1, t2, eris):
    assert(isinstance(eris, _PhysicistsERIs))
    nocc, nvir = t1.shape
    fock = eris.fock

    fov = fock[:nocc,nocc:]
    mo_e_o = eris.mo_energy[:nocc]
    mo_e_v = eris.mo_energy[nocc:] + cc.level_shift

    tau = imd.make_tau(t2, t1, t1)

    Fvv = imd.cc_Fvv(t1, t2, eris)
    Foo = imd.cc_Foo(t1, t2, eris)
    Fov = imd.cc_Fov(t1, t2, eris)
    Woooo = imd.cc_Woooo(t1, t2, eris)
    Wvvvv = imd.cc_Wvvvv(t1, t2, eris)
    Wovvo = imd.cc_Wovvo(t1, t2, eris)

    # Move energy terms to the other side
    Fvv[np.diag_indices(nvir)] -= mo_e_v
    Foo[np.diag_indices(nocc)] -= mo_e_o

    # T1 equation
    t1new  =  einsum('ie,ae->ia', t1, Fvv)
    t1new += -einsum('ma,mi->ia', t1, Foo)
    t1new +=  einsum('imae,me->ia', t2, Fov)
    t1new += -einsum('nf,naif->ia', t1, eris.ovov)
    t1new += -0.5*einsum('imef,maef->ia', t2, eris.ovvv)
    t1new += -0.5*einsum('mnae,mnie->ia', t2, eris.ooov)
    t1new += fov.conj()

    # T2 equation
    Ftmp = Fvv - 0.5*einsum('mb,me->be', t1, Fov)
    tmp = einsum('ijae,be->ijab', t2, Ftmp)
    t2new = tmp - tmp.transpose(0,1,3,2)
    Ftmp = Foo + 0.5*einsum('je,me->mj', t1, Fov)
    tmp = einsum('imab,mj->ijab', t2, Ftmp)
    t2new -= tmp - tmp.transpose(1,0,2,3)
    t2new += np.asarray(eris.oovv).conj()
    t2new += 0.5*einsum('mnab,mnij->ijab', tau, Woooo)
    t2new += 0.5*einsum('ijef,abef->ijab', tau, Wvvvv)
    tmp = einsum('imae,mbej->ijab', t2, Wovvo)
    tmp -= -einsum('ie,ma,mbje->ijab', t1, t1, eris.ovov)
    tmp = tmp - tmp.transpose(1,0,2,3)
    tmp = tmp - tmp.transpose(0,1,3,2)
    t2new += tmp
    tmp = einsum('ie,jeba->ijab', t1, np.array(eris.ovvv).conj())
    t2new += (tmp - tmp.transpose(1,0,2,3))
    tmp = einsum('ma,ijmb->ijab', t1, np.asarray(eris.ooov).conj())
    t2new -= (tmp - tmp.transpose(0,1,3,2))

    eia = mo_e_o[:,None] - mo_e_v
    eijab = lib.direct_sum('ia,jb->ijab', eia, eia)
    t1new /= eia
    t2new /= eijab

    return t1new, t2new
Ejemplo n.º 3
0
# 1st step Ecc
ecc_0_ref = mycc_ref.energy(t1_mp2_ref, t2_mp2_ref, eris_ref)

# converged Ecc
ecc_ref, t1_cc_ref, t2_cc_ref = mycc_ref.kernel()

# converged lambda
mycc_ref.max_cycle = 50
l1_cc_ref, l2_cc_ref = mycc_ref.solve_lambda()

# tau_ref
tau_ref = imd.make_tau(t2_cc_ref, t1_cc_ref, t1_cc_ref)

# imd ref
Foo_ref = imd.cc_Foo(t1_cc_ref, t2_cc_ref, eris_ref)
Fvv_ref = imd.cc_Fvv(t1_cc_ref, t2_cc_ref, eris_ref)
Fov_ref = imd.cc_Fov(t1_cc_ref, t2_cc_ref, eris_ref)
Woooo_ref = imd.cc_Woooo(t1_cc_ref, t2_cc_ref, eris_ref)
Wvvvv_ref = imd.cc_Wvvvv(t1_cc_ref, t2_cc_ref, eris_ref)
Wovvo_ref = imd.cc_Wovvo(t1_cc_ref, t2_cc_ref, eris_ref)

# test class
mf = mf.newton()
mycc = mpicc.GCCSD(mf)
mycc.conv_tol = 1e-8
mycc.conv_tol_normt = 1e-6
mycc.max_cycle = 50
mycc.kernel()

mycc.distribute_amplitudes_(t1_cc_ref, t2_cc_ref)