lG11 = G(H1, w) rG11 = inv(inv(g1) - tmm(tau12, g2, tau21)) lG22 = inv(inv(g2) - tmm(tau21, g1, tau12)) rG22 = G(H2, w) fG11 = inv(inv(g1) - tmm(tau12, rG22, tau21)) fG22 = inv(inv(g2) - tmm(tau21, lG11, tau12)) fG12 = tmm(lG11, tau12, fG22) fG21 = tmm(rG22, tau21, fG11) fGF = np.block([[fG11, fG12], [fG21, fG22]]) A.append((-1 / np.pi) * np.imag(np.trace(fGF))) pb.progressbar(w, w_list[0], w_list[-1]) plt.plot(w_list, A) plt.title('Formula inversion, U = ' + str(U) + ', l_n = ' + str(l_n)) # plt.savefig('ordmatplots/formula_inversion_U4.pdf') plt.show() f = open(filename, 'w') for i in range(len(w_list)): f.write(str(w_list[i]) + '\t' + str(A[i]) + '\n') f.close()
# print(c, i.getstate()) # c += 1 # print(H_n_n) print("Generating DOS for block", n) omega_list = np.linspace(startpoint, stoppoint, 2000) # omega_list = [0] wc = 0 A_list = [] for omega in omega_list: z = omega + complex(0, 1 * eta) Gi_n = z * np.eye(len(H_n_n)) - H_n_n Gi_p = z * np.eye(len(H_p_p)) - H_p_p Gi_m = z * np.eye(len(H_m_m)) - H_m_m G = np.linalg.inv(Gi_n - np.dot(tau_n_m, np.dot(np.linalg.inv(Gi_m), tau_m_n)) - np.dot(tau_n_p, np.dot(np.linalg.inv(Gi_p), tau_p_n))) A = (-1 / np.pi) * np.imag(np.trace(G)) / len(G) A_list.append(A) wc += 1 pb.progressbar(wc, 0, len(omega_list)) print('') plt.plot(omega_list, A_list) plt.show()
if (state1.getleftnum() == state2.getleftnum()): H[bi][bj] = t * mel(state1, state2) H[bj][bi] = H[bi][bj] if (state1.getleftnum() != state2.getleftnum()): H[bi][bj] = tprime * mel(state1, state2) H[bj][bi] = H[bi][bj] if (bi == bj): a = basis[bi] particles = np.array(a.upconfig) + np.array(a.downconfig) for nump in particles: if (nump == 2): H[bi][bj] += U Hprog = len(basis1) * (bi + 1) + bj + 1 pb.progressbar(Hprog, 0, len(basis1) * len(basis2)) for i in range(len(H)): H[i, i] += Unn * unnlist[i] t_H_stop = time.perf_counter() print("\nHamiltonian matrix generated in", round(t_H_stop - t_H_start, 5), 's.') print('The Hamiltonian matrix is:') for i in range(len(H)): for j in range(len(H)): if (H[i, j] >= 0): print(' ', H[i, j], end=' ', sep='') else:
# for e in ev: # print( round(e, 2), sep = '\t', end = ' ' ) # print('') w_list = np.linspace(startpoint, stoppoint, 2000) t_lsw_start = time.perf_counter() print("Generating local spectral weight function for state:\n", \ basis[p].getstate() ) A_list = [] i = 0 for w in w_list: A_list.append(-(1 / np.pi) * np.imag(G(w)[p][p])) pb.progressbar(i, 0, len(w_list) - 1) i += 1 t_lsw_stop = time.perf_counter() print("\nLocal spectral weight calculated in", \ round(t_lsw_stop - t_lsw_start, 5), 's.') plt.xlim(startpoint, stoppoint) plt.plot(w_list, A_list, color='green', label='With interface hopping') plt.title( "Local spectral weight function for the state " +\ str(p) ) #plt.show() ######################################################################### #Hamiltonian construction without interface hopping
if (state1.getleftnum() == state2.getleftnum()): H[bi][bj] = t * mel(state1, state2) #H[bj][bi] = H[bi][bj] if (state1.getleftnum() != state2.getleftnum()): H[bi][bj] = tprime * mel(state1, state2) #H[bj][bi] = H[bi][bj] if (l_n1 == l_n2 and bi == bj): a = basis1[bi] particles = np.array(a.upconfig) + np.array(a.downconfig) for nump in particles: if (nump == 2): H[bi][bj] += U H_counter += 1 pb.progressbar(H_counter, 0, len(basis1) * len(basis2)) # print('\nThe Hamiltonian matrix is:') # for i in range(len(basis1)): # for j in range(len(basis2)): # if (H[i, j] >= 0): # print(' ', H[i, j], end=' ', sep='') # else: # print(H[i, j], end=' ', sep='') # print('') filename = 'tau_' + str(N) + '_' + str(n) + '_' + \ str(l_n1) + '_' + str(l_n2) + '.txt' np.savetxt(filename, H, fmt='%4.1f', delimiter='\t')
for bj in range(len(basis)): state1 = basis[bi] state2 = basis[bj] if (bi <= bj): if (state1.getleftnum() == state2.getleftnum()): H[bi][bj] = t * mel(state1, state2) H[bj][bi] = H[bi][bj] if (state1.getleftnum() != state2.getleftnum()): H[bi][bj] = tprime * mel(state1, state2) H[bj][bi] = H[bi][bj] if (bi == bj): a = basis[bi] particles = np.array(a.upconfig) + np.array(a.downconfig) for nump in particles: if (nump == 2): H[bi][bj] += U Hprog = len(basis) * (bi + 1) + bj + 1 pb.progressbar(Hprog, 0, len(basis) * len(basis)) print('\nThe Hamiltonian matrix is:') for i in range(len(H)): for j in range(len(H)): if (H[i, j] >= 0): print(' ', H[i, j], end=' ', sep='') else: print(H[i, j], end=' ', sep='') print('')