def mps_wf_distance(psi, mps_params, print=False): psi_tt = mps_wf(mps_params[0], mps_params[1], mps_params[2], mps_params[3], mps_params[4], mps_params[5]) diff = psi - psi_tt if print is True: print_wf(psi_tt, pxp, 1e-2) return np.real(np.vdot(diff, diff))
z = zm_state(4, 1, pxp) k = pxp_syms.find_k_ref(z.ref) print(k) # for n in range(0,np.size(k,axis=0)): # Hp.gen(k[n]) Hp.gen() Hm = Hp.herm_conj() # Hz = 1/2 * com(Hp.sector.matrix(k[0]),Hm.sector.matrix(k[0])) Hz = 1 / 2 * com(Hp.sector.matrix(), Hm.sector.matrix()) plt.matshow(np.abs(Hz)) plt.show() e, u = np.linalg.eigh(Hz) print(e) from Diagnostics import print_wf print_wf(u[:, 0], pxp, 1e-2) print("\n") print_wf(u[:, 1], pxp, 1e-2) print("\n") print_wf(u[:, 2], pxp, 1e-2) print("\n") print_wf(u[:, 3], pxp, 1e-2) print("\n") print_wf(u[:, 4], pxp, 1e-2) print("\n") print_wf(u[:, 5], pxp, 1e-2) print("\n") print_wf(u[:, 6], pxp, 1e-2) print("\n") print_wf(u[:, 7], pxp, 1e-2)
0.5) fsa_basis = np.vstack((fsa_basis, next_state)) fsa_basis2 = np.vstack((fsa_basis2, next_state2)) krylov_basis = np.vstack((krylov_basis, next_stateK)) current_state = next_state current_state2 = next_state2 current_stateK = next_stateK fsa_basis = np.transpose(fsa_basis) psi = fsa_basis[:, np.size(fsa_basis, axis=1) - 1] from Diagnostics import print_wf for n in range(0, np.size(fsa_basis, axis=0)): print("\n") print_wf(fsa_basis[:, n], pxp, 1e-5) # krylov_basis = np.transpose(krylov_basis) # gs = gram_schmidt(krylov_basis) # gs.ortho() # krylov_basis = gs.ortho_basis # # krylov_basis,temp = np.linalg.qr(krylov_basis) # # fsa_basis2 = np.transpose(fsa_basis2) # # fsa_basis = fsa_basis2 # # fsa_basis = np.hstack((fsa_basis,fsa_basis2)) # # from Calculations import gram_schmidt # # gs = gram_schmidt(fsa_basis) # # gs.ortho() # # fsa_basis = gs.ortho_basis # for n in range(0,np.size(k,axis=0)): # H.gen(k[n])
# exact_overlap = np.zeros(np.size(e)) # for n in range(0,np.size(e,axis=0)): # max_overlap = 0 # for m in range(0,pxp.dim): # temp = np.abs(np.vdot(H.sector.eigvectors()[:,m],u_comp[:,n]))**2 # if temp > max_overlap: # max_overlap = temp # exact_overlap[n] = max_overlap # print(exact_overlap) # plt.scatter(e,exact_overlap) # plt.show() from Diagnostics import print_wf for m in range(0, np.size(basis, axis=1)): print("\n") print_wf(basis[:, m], pxp, 1e-2) H_rot = np.dot(np.conj(np.transpose(basis)), np.dot(H.sector.matrix(), basis)) e, u = np.linalg.eigh(H_rot) eigenvalues = e overlap = np.log10(np.abs(u[0, :])**2) to_del = [] for n in range(0, np.size(overlap, axis=0)): if overlap[n] < -5: to_del = np.append(to_del, n) for n in range(np.size(to_del, axis=0) - 1, -1, -1): overlap = np.delete(overlap, to_del[n]) eigenvalues = np.delete(eigenvalues, to_del[n]) H.sector.find_eig() z = zm_state(2, 1, pxp)
# H=H0 H.sector.find_eig() temp = Hp + Hm def com(a, b): return np.dot(a, b) - np.dot(b, a) Hz = 1 / 2 * com(Hp, Hm) e, u = np.linalg.eigh(Hz) from Diagnostics import print_wf print(e[0]) print_wf(u[:, 0], pxp, 1e-2) print("\n") print_wf(u[:, np.size(u, axis=1) - 1], pxp, 1e-2) print(e) z = zm_state(3, 1, pxp) fsa_basis = z.prod_basis() current_state = fsa_basis fsa_dim = int(2 * pxp.N / 3) for n in range(0, fsa_dim): next_state = np.dot(Hp, current_state) next_state = next_state / np.power(np.vdot(next_state, next_state), 0.5) fsa_basis = np.vstack((fsa_basis, next_state)) current_state = next_state fsa_basis = np.transpose(fsa_basis)
tempL = tempL + ref_state(half_cube_refsL[n][m], pxp).prod_basis() tempR = tempR + ref_state(half_cube_refsR[n][m], pxp).prod_basis() tempL = tempL / np.power(np.vdot(tempL, tempL), 0.5) tempR = tempR / np.power(np.vdot(tempR, tempR), 0.5) half_cube_basisL[:, n] = tempL half_cube_basisR[:, n] = tempR #form total sub basis basis = np.hstack((half_cube_basisL, subcube_combined_basisL)) basis = np.hstack((basis, subcube_combined_basisR)) basis = np.hstack((basis, half_cube_basisR)) from Diagnostics import print_wf for n in range(0, np.size(basis, axis=1)): print("\n,State " + str(n)) print_wf(basis[:, n], pxp, 1e-5) basis = np.unique(basis, axis=1) basis, temp = np.linalg.qr(basis) #FSA basis z = zm_state(2, 1, pxp) hamming_sectors = find_hamming_sectors(z.bits, pxp) fsa_basis = np.zeros((pxp.dim, len(hamming_sectors))) for n in range(0, len(hamming_sectors)): for m in range(0, np.size(hamming_sectors[n], axis=0)): fsa_basis[:, n] = fsa_basis[:, n] + ref_state(hamming_sectors[n][m], pxp).prod_basis() fsa_basis[:, n] = fsa_basis[:, n] / np.power( np.vdot(fsa_basis[:, n], fsa_basis[:, n]), 0.5)
else: B_occ += pxp.basis[n][m] coef = np.power(c1_down,N/2-A_occ)*np.power(c1_up,A_occ)*np.power(c2_down,N/2-B_occ)*np.power(c2_up,B_occ) wf[n] = coef wf = wf / np.power(np.vdot(wf,wf),0.5) return wf def TT_wf_distance(psi,tt_params): psi_tt = TT_wf(tt_params[0],tt_params[1],tt_params[2],tt_params[3]) diff = psi - psi_tt return np.real(np.vdot(diff,diff)) wf = TT_wf(0,0,math.pi/2,0) from Diagnostics import print_wf print_wf(wf,pxp,1e-2) from scipy.optimize import minimize TT_distance = np.zeros(np.size(t)) pbar=ProgressBar() for n in pbar(range(0,np.size(evolved_states,axis=1))): if n == 0: res = minimize(lambda tt_params: TT_wf_distance(evolved_states[:,n],tt_params),method="powell",x0=[0,0,math.pi/2,0]) print(res.x) last_coef = res.x else: res = minimize(lambda tt_params: TT_wf_distance(evolved_states[:,n],tt_params),method="powell",x0=last_coef) last_coef = res.x TT_distance[n] = TT_wf_distance(evolved_states[:,n],res.x) np.save("tt_full,t,10",t) np.save("tt_full,distance,10",TT_distance) print(TT_distance[0])
# Hz_temp.model_coef = np.array([1/2,-1/2,1/2,-1/2,1/2,-1/2,-1/2,1/2]) # Hz_temp.uc_size = np.array([2,2,2,2,2,2,2,2]) # Hz_temp.uc_pos = np.array([1,1,0,0,1,0,0,1]) # Hz_temp.gen() # plt.matshow(np.abs(Hz_temp.sector.matrix())) # plt.matshow(np.abs(Hz0)) # plt.show() # print((np.abs(Hz_temp.sector.matrix()-Hz0)<1e-5).all()) ez, uz = np.linalg.eigh(Hz0) print(ez) from Diagnostics import print_wf count = 0 psi = uz[:, count] from Diagnostics import print_wf print_wf(psi, pxp, 1e-2) ent = entropy(pxp) # print("\nLw") # print_wf(psi,pxp,1e-10) # print("\n") # coef = np.load("./data/1_pert_PQP+-P/xy,pert_coef,16.npy") # # coef = np.zeros(1) # # from scipy.optimize import minimize # res = minimize(lambda coef: fidelity_error(coef,psi),method="Nelder-Mead",x0=coef) # # # res = minimize(lambda coef: spacing_error(coef,psi),method="Nelder-Mead",x0=coef) # coef = res.x # np.save("xy,pert_coef,"+str(pxp.N),coef) # # coef = 0
print("Z eff") print(np.diag(Z_eff)) print("\n") print("X eff") print(e0) Ux_eig = u0 P = scar_basis U_eig = H.sector.eigvectors() U_fsa = np.dot(P, np.conj(np.transpose(Ux_eig))) U_fsa = np.dot(U_eig, U_fsa) print(np.shape(U_fsa)) from Diagnostics import print_wf print_wf(U_fsa[:, 0], pxp, 1e-2) z = zm_state(2, 1, pxp) z_energy = H.sector.eigvectors()[pxp.keys[z.ref], :] z0 = U_fsa[:, 2] z0_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors())), z0) overlap = np.log10(np.abs(z0_energy)**2) overlap_neel = np.log10(np.abs(z_energy)**2) plt.scatter(H.sector.eigvalues(), overlap) plt.xlabel(r"$E$") plt.ylabel(r"$\log(\vert \langle \psi \vert E \rangle \vert^2)$") plt.title( r"$\sum_{n} P_{n-1}X_nP_{n+1} (\sum_{d=2}^5 Z_{i+d} + Z_{i-d} ), N=$" +
print(e) #form two perm sectors permBasis1 = np.zeros(pxp.dim) permBasis2 = np.zeros(pxp.dim) for n in range(0, np.size(e, axis=0)): if np.abs(e[n] + 1) < 1e-5: permBasis1 = np.vstack((permBasis1, u[:, n])) else: permBasis2 = np.vstack((permBasis2, u[:, n])) permBasis1 = np.transpose(np.delete(permBasis1, 0, axis=0)) permBasis2 = np.transpose(np.delete(permBasis2, 0, axis=0)) from Diagnostics import print_wf for n in range(0, np.size(permBasis2, axis=1)): print("\n") print_wf(permBasis2[:, n], pxp, 1e-2) # new_basis = np.hstack((permBasis2,permBasis1)) # H_new = np.dot(np.conj(np.transpose(new_basis)),np.dot(H.sector.matrix(),new_basis)) # plt.matshow(np.abs(H_new)) # plt.show() # z=zm_state(2,1,pxp) # H.sector.find_eig() # eig_overlap(z,H).plot() # H_perm = np.dot(np.conj(np.transpose(permBasis2)),np.dot(H.sector.matrix(),permBasis2)) # psi_perm = np.dot(np.conj(np.transpose(permBasis2)),z.prod_basis()) # e,u = np.linalg.eigh(H_perm) # overlap_perm = np.log10(np.abs(np.dot(np.conj(np.transpose(u)),psi_perm))**2) # plt.scatter(e,overlap_perm,marker="x",color="red",s=100)
# a = 0.51 a_vals = np.arange(0.5, 1.1, 0.1) for count in range(0, np.size(a_vals, axis=0)): a = a_vals[count] Hp_new = a * Hp + (1 - a) * Hm Hm_new = np.conj(np.transpose(Hp_new)) print((np.abs(Hp_new - Hm_new) < 1e-5).all()) #Raising op def com(a, b): return np.dot(a, b) - np.dot(b, a) Hz = 1 / 2 * com(Hp_new, Hm_new) e, u = np.linalg.eigh(Hz) from Diagnostics import print_wf print_wf(u[:, 0], pxp, 1e-2) fsa_basis = z.prod_basis() current_state = fsa_basis for n in range(0, krylov_dim): next_state = np.dot(Hp_new, current_state) next_state = next_state / np.power(np.vdot(next_state, next_state), 0.5) fsa_basis = np.vstack((fsa_basis, next_state)) current_state = next_state fsa_basis = np.transpose(fsa_basis) # fsa_basis,temp = np.linalg.qr(fsa_basis) gs = gram_schmidt(fsa_basis) gs.ortho() fsa_basis = gs.ortho_basis