def __init__(s, h, V, m, rho=None, Delta=None, tol=10**-7): s.h = h s.V = V s.m = m s.n = h.shape[0] s.tol = tol s.app_pot = 0. s.mu = 0. #each time we re-calc applied potentials, we'll keep track of the total with mu if rho is None: #generate HF density matrix instead hart = hf.HF(h, V, m, scf='diis') s.rho = hart.get_rho() s.E_hf = hart.e / s.n print "HF energy: ", s.E_hf else: s.rho = rho if Delta is None: #just set to 0's, as it would be for HF solution s.Delta = np.zeros((s.n, s.n)) else: s.Delta = Delta s.F = hf.HF.genFock(s.rho, s.h, s.V) s.H = np.zeros((2 * s.n, 2 * s.n)) s.H[:s.n, :s.n] = s.F s.H[s.n:, s.n:] = -s.F s.H[:s.n, s.n:] = s.Delta s.H[s.n:, :s.n] = -s.Delta s.G = s.genG(s.H)
def __init__(s, h, V, m, rho=None, Delta=None): s.h = h s.V = V s.m = m s.n = h.shape[0] if rho is None: #generate HF density matrix instead hart = hf.HF(h, V, m) s.rho = hart.get_rho() print hart.e / s.n else: s.rho = rho if Delta is None: #just set to 0's, as it would be for HF solution s.Delta = np.zeros((s.n, s.n)) else: s.Delta = Delta s.F = hf.HF.genFock(s.rho, s.h, s.V) s.H = s.genH(s.F, s.Delta) s.G = s.genG(s.H)
def C2(): return C2 if __name__ == "__main__": n = 12 m = 4 U = 2. nf = 2 # h,V = randHV(n,U=U,scale=0.0) h,V = coulV(n,U=U,cutoff=2) print "Beginning HF" hart = hf.HF(h,V,m) psi = hart.get_Cocc() rho = hart.get_rho() F = hart.F print np.trace(np.dot(rho,h+F))/n print "HF energy:" print hart.get_energy()/n #make a list of range(nf) that tile n fraglist = [] for i in range(n//nf): #assumes n divisible by nf fraglist.append(range(nf*i,nf*(1+i))) e_list1 = []; e_list2 = []; e_list3 = [] for frag_sites in fraglist:
V[i, i, i, i] = U return V n = 12 m = 6 U = 0. nf = 2 V = V_hubbard(n, U) h = np.diag(np.ones(n - 1), 1) h[0, -1] = -1 h += h.T h *= -1 hart = hf.HF(h, V, m) psi = hart.get_Cocc() rho = hart.get_rho() print hart.get_energy() / n 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:]