Esempio n. 1
0
def hRedHalf(nf,h,T):
    h_r = copy.copy(h)
    h_r[nf:,:] = 0.
    return xform.one(T,h_r)
Esempio n. 2
0
def hRedSym(nf,h,T):
    h_r = copy.copy(h)
    h_r[nf:,:nf] *= 0.5
    h_r[:nf,nf:] *= 0.5
    h_r[nf:,nf:] *= 0.0
    return xform.one(T,h_r)
Esempio n. 3
0
#        M = psi[:nf,:] #select the first nf orbitals out of the HF wavefunction
        M = psi[frag_sites,:] #select the first nf orbitals out of the HF wavefunction
        u,s,v = np.linalg.svd(M) #perform an SVD of the fragment AOs wrt the MOs
        C = psi.dot(v.T) #wavefunction dot SVD
        T = np.zeros((n,2*nf)) #pull components; split entangled bath and fragment into block diagonal matrix
        T[frag_sites,:nf] = C[frag_sites,:nf]
        T[:,nf:] = C[:,:nf] - T[:,:nf]
        Tc = C[:,nf:]
        C1 = copy.copy(T)

        #Normalize np.dot(C1.T,C1)
        for i in range(nf):
            C1[:,nf+i] /= np.sqrt(C1[:,nf+i].dot(C1[:,nf+i]))
            C1[:,i] /= np.sqrt(C1[:,i].dot(C1[:,i]))

        h_f1 = xform.one(C1,h)
        V_f1 = xform.two(C1,V)
        core = xform.core(Tc,V)
        hc = xform.one(C1,core)
        rho_f1 = xform.one(C1,rho)
        rho_f2 = genP2f(rho_f1)
        F_f1 = xform.one(C1,h+F)
#        rho_f2 = genP2(rho_f1)

#        e_list1.append(embed_energy(nf,h_f1,hc,V_f1,rho_f1,rho_f2)) #Not returning correct E atm.

#        e_list2.append(np.trace(np.dot(rho_f1,h_f1+F_f1)))
        e_list2.append(fragTrace(nf,rho_f1,F_f1))

#        #Method 2 for producing C2, which is a unitary rotation of C1
#        rho_f = rho[:nf,:nf]
Esempio n. 4
0
print hf_energy(h, V, rho) / n

M = psi[:nf, :]
S_M = np.dot(M.T, M)

u, s, v = np.linalg.svd(M)

C = psi.dot(v.T)
T = np.zeros((n, 2 * nf))
T[:nf, :nf] = C[:nf, :nf]
T[nf:, nf:] = C[nf:, :nf]
Tc = C[:, nf:]
print Tc

hc = xform.core(Tc, V)
h_f = xform.one(T, h + hc)
V_f = xform.two(T, V)

rho_f = T.T.dot(np.dot(rho, T))
print embed_energy(nf, h_f, V_f, rho_f) / nf

Tfull = schmidt.schmidt(psi, range(nf), allv=True)
T = Tfull[:, :2 * nf]
Tc = Tfull[:, 2 * nf:]
rho_f = xform.one(T, rho)
hc = xform.core(Tc, V)
h_f = xform.one(T, h + hc)
V_f = xform.two(T, V)
print embed_energy(nf, h_f, V_f, rho_f) / nf

hart_f = hf.HF(h_f, V, nf)
Esempio n. 5
0
        T_Uv = T_norm[2 * n:, :]

        ###Can I normalize it this way instead? --> this is ludicrously wrong
        #T_Vv = T_Vv.dot(np.diag(np.diag(T_Vv.T.dot(T_Vv))**-0.5))
        #T_Uv = T_Uv.dot(np.diag(np.diag(T_Uv.T.dot(T_Uv))**-0.5))

        #print(T_norm)
        #print()
        #print(T_Vv)
        #print(T_Uv)

        #        ##What if I don't normalize it? --> it is very wrong
        #        T_Vv = T[:2*n,:] #cut T into the original V and U parts
        #        T_Uv = T[2*n:,:]

        F_f = xform.one(T_Vv, h_dirsum + bogil.H[:2 * n, :2 * n])
        h_f = xform.one(T_Vv, 2 * h_dirsum)
        P1_f = xform.one(T_Vv, bogil.G[:2 * n, :2 * n])

        D_f = xform.one(T_Uv, bogil.H[:2 * n, 2 * n:])
        Ki_f = xform.one(T_Uv, bogil.G[:2 * n, 2 * n:])

        #        H_f = xform.one(T_norm,bogil.H)
        #        G_f = xform.one(T_norm,bogil.G)
        #        H_f2 = xform.one(T_norm,c1c2.reduceBath(bogil.H,fb=1.))
        #        G_f2 = xform.one(T_norm,c1c2.reduceBath(bogil.G,fb=1.))

        ##This works for hubb and coulV, but not lrHop or randHV
        e_list1.append(
            2 * fragTrace(F_f, P1_f)
        )  #off by precisely a factor of 2. I'll add this factor here for now
Esempio n. 6
0
    #T_2 = np.zeros((n,2*nf))
    #T_2[:nf,:nf] = C2[:nf,:]
    #T_2[nf:,nf:] = C2[nf:,:]

    T_2 = np.column_stack((C2, C2_hole))
    #    print(C2)
    #    print(C2_hole)
    #    print(T_2)

    TdT = np.dot(T_2.T, T_2)
    T_2 *= np.diag(TdT)**-0.5
    #    print(TdT)
    #    print(T_2)
    #    print(np.linalg.det(TdT))

    P1_f = xform.one(T_2, rho_swp)
    h_f = xform.one(T_2, h_swp)
    F_f = xform.one(T_2, h_swp + F_swp)

    F_r = c1c2.reduceBath(h_swp + F_swp, nf=2)
    F_rf = xform.one(T_2, F_r)

    #F_f = c1c2.hRedHalf(nf,F_swp+h_swp,T_2) #0's the rows below nf
    #P2_f = c1c2.genP2f(rho_f)
    #V_f = xform.two(T_2,V)
    #    V_f = c1c2.genP2f(P1_f)

    efrag = np.trace(np.dot(F_f[:, :nf].T, P1_f[:, :nf]))
    e_list.append(efrag)
    efrag = np.trace(np.dot(F_rf.T, P1_f))
    e_list3.append(efrag)
Esempio n. 7
0
hart = hf.HF(h, V, m)
psi = hart.get_Cocc()
rho = hart.get_rho()
F = hart.F
print("HF Energy:", hart.get_energy())

e_list = []
e_list2 = []
e_list3 = []
e_list4 = []

for frag_sites in fraglist:

    #Test for generating C1 (via wavefunction rather than density matrix)
    C1, Tc, hc, h_f, V_f = c1c2.C1Proj(nf, psi, frag_sites, h, V)
    P1_f = xform.one(C1, rho)
    P2_f = c1c2.genP2f(P1_f)
    hc_f = xform.one(C1, hc)

    F_f = xform.one(C1, h + F)
    efrag = np.trace(np.dot(F_f[:, :nf].T, P1_f[:, :nf])) / nf
    e1_1 = np.trace(np.dot(2. * h_f[:, :nf].T, P1_f[:, :nf])) / nf
    e1_2 = efrag - e1_1
    e_list4.append(efrag)
    print("Efrag %s: %f, e1: %f, e2: %f" %
          (" ".join([str(item) for item in frag_sites]), efrag, e1_1, e1_2))

    #    efrag2 = c1c2.embed_e1(nf,F_f,P1_f)/nf
    #    e_list2.append(efrag2)
    #    print("Efrag2 %s: %s" % (" ".join([str(item) for item in frag_sites]),str(efrag2)))
    #