Ejemplo n.º 1
0
def ea_e_vec(cc, q):
    nocc, nvir = cc.t1.shape
    lamb1 = cc.L1
    lamb2 = cc.L2
    nocc, nvir = cc.t1.shape
    vector1 = np.zeros((nvir), dtype=complex)
    vector2 = np.zeros((nocc, nvir, nvir), dtype=complex)
    if q >= nocc:
        vector1[q - nocc] += 1.0
        vector1 += np.einsum('ia,i->a', lamb1, cc.t1[:, q - nocc])
        vector1 += (1. / 4.) * np.einsum('ilcd,ild->c', lamb2,
                                         cc.t2[:, :, q - nocc, :])
        vector1 -= (1. / 4.) * np.einsum('ildc,ild->c', lamb2,
                                         cc.t2[:, :, q - nocc, :])
        #
        #
        #  Notice the change in signs between this and the green's function
        #  equations in the Nooijen paper.  The sign comes from working with
        #  s(i,j,a) versus s(j,i,a)
        #
        #
        vector2[:, q - nocc, :] += 1.0 * lamb1
        vector2[:, :, q - nocc] -= 1.0 * lamb1
        vector2 += (1. / 2.) * np.einsum('i,ijcb->jcb', cc.t1[:, q - nocc],
                                         lamb2)
        vector2 -= (1. / 2.) * np.einsum('i,jicb->jcb', cc.t1[:, q - nocc],
                                         lamb2)
    else:
        vector1 += lamb1[q, :]
        vector2 += -0.5 * (lamb2[:, q, :, :] - lamb2[q, :, :, :])

    return cc.amplitudes_to_vector_ea(vector1, vector2)
Ejemplo n.º 2
0
def ea_b_vec(cc, p):
    nocc, nvir = cc.t1.shape
    vector1 = np.zeros((nvir), dtype=complex)
    vector2 = np.zeros((nocc, nvir, nvir), dtype=complex)
    if p >= nocc:
        vector1[p - nocc] += 1.0
    else:
        vector1 = cc.t1[p, :]
        vector2 = 1.0 * cc.t2[p, :, :, :]
    return cc.amplitudes_to_vector_ea(vector1, vector2)
Ejemplo n.º 3
0
def _run_ea_matvec(cc, r1, r2, kshift):
    try:  # Different naming & calling conventions between master/dev
        vector = cc.ea_amplitudes_to_vector(r1, r2)
    except:
        vector = cc.amplitudes_to_vector_ea(r1, r2)
    try:
        vector = cc.eaccsd_matvec(vector, kshift)
    except:
        cc.kshift = kshift
        vector = cc.eaccsd_matvec(vector)
    try:
        Hr1, Hr2 = cc.ea_vector_to_amplitudes(vector)
    except:
        Hr1, Hr2 = cc.vector_to_amplitudes_ea(vector)
    return Hr1, Hr2
Ejemplo n.º 4
0
def _run_ea_matvec(cc, r1, r2, kshift):
    try:  # Different naming & calling conventions between master/dev
        vector = cc.ea_amplitudes_to_vector(r1, r2)
    except:
        vector = cc.amplitudes_to_vector_ea(r1, r2)
    try:
        vector = cc.eaccsd_matvec(vector, kshift)
    except:
        cc.kshift = kshift
        vector = cc.eaccsd_matvec(vector)
    try:
        Hr1, Hr2 = cc.ea_vector_to_amplitudes(vector)
    except:
        Hr1, Hr2 = cc.vector_to_amplitudes_ea(vector)
    return Hr1, Hr2
Ejemplo n.º 5
0
def eom_ccsd_ea_greenfunction(cc):
    eta = 0.04777412092810763
    omega = [0.0]
    state = 0

    nocc, nvir = cc.t1.shape
    vector1 = np.zeros((nvir), dtype=complex)
    vector2 = np.zeros((nocc, nvir, nvir), dtype=complex)

    #
    #
    #  Making initial guess
    #
    #
    vector1 += np.ones(nvir)
    #vector1 += 1j*np.ones(nvir)
    vector2 += np.ones((nocc, nvir, nvir))
    #vector2 += 1j*np.ones((nocc,nvir,nvir))
    v0 = cc.amplitudes_to_vector_ea(vector1, vector2)
    v0 = v0.reshape(v0.shape[0], 1)

    #
    #
    #  Making pre conditioner
    #
    #
    vector1 -= vector1
    vector2 -= vector2
    vector1 += np.ones(nvir)
    vector2 += np.ones((nocc, nvir, nvir))
    P = cc.amplitudes_to_vector_ea(vector1, vector2)
    P = P.reshape(P.shape[0], 1)
    #print "precon : ", P

    #
    #
    #  Making 'b' vector
    #
    #
    b = ea_b_vec(cc, state)
    b = b.reshape(b.shape[0], 1)
    #for i in xrange(b.shape[0]):
    #    dval = b[i]
    #    if abs(dval) > 1e-15:
    #        print "b : ", i, dval

    #
    #
    #  Making 'e' vector
    #
    #
    e = ea_e_vec(cc, state)
    e = e.reshape(e.shape[0], 1)
    #print "evector..."
    #for i in xrange(e.shape[0]):
    #    dval = e[i]
    #    if abs(dval) > 1e-15:
    #        print "e : ", i, dval
    #for i in xrange(e.shape[0]):
    #    print e[i]

    gg = gminres.gMinRes(cc.ea_eom_ccsd_matvec, b, v0, P)
    #gg = arnoldi_solver.arnoldi(cc,v0,P)
    solution = gg.getSolution()
    print "green's function = "
    print np.vdot(e, solution)