def overlap_error(coef): # coef = coef[0] H = H_operations.add(H0, V, np.array([1, coef])) H.sector.find_eig() overlap_no_log = np.abs(H.sector.eigvectors()[pxp.keys[z.ref], :])**2 overlap = np.log10(overlap_no_log) scar_indices_perturbed = np.flip( get_top_band_indices(H.sector.eigvalues(), overlap, pxp.N, 200, 150, 0.8)) # check got right scars # plt.scatter(H.sector.eigvalues(),overlap) # for n in range(0,np.size(scar_indices_perturbed,axis=0)): # plt.scatter(H.sector.eigvalues()[scar_indices_perturbed[n]],overlap[scar_indices_perturbed[n]],marker="x",color="red",s=100) # plt.show() for n in range(0, np.size(scar_indices_perturbed, axis=0)): overlap_no_log = np.delete(overlap_no_log, scar_indices_perturbed[n], axis=0) cost = np.sum(overlap_no_log) # cost = np.sum(scar_overlap_perturbed-scar_overlap) print(coef, cost) return cost
def spacing_error(coef): Hp_total = deepcopy(Hp[0]) for n in range(1, len(Hp)): Hp_total = H_operations.add(Hp_total, Hp[n], np.array([1, coef[n - 1]])) Hm = np.conj(np.transpose(Hp_total.sector.matrix())) H = Hp_total.sector.matrix() + Hm e, u = np.linalg.eigh(H) z = zm_state(3, 1, pxp) psi_energy = np.dot(np.conj(np.transpose(u)), z.prod_basis()) overlap = np.log10(np.abs(psi_energy)**2) scar_indices = get_top_band_indices(e, overlap, int(2 * N / 3), 150, 200, e_diff=0.5) # plt.scatter(e,overlap) # for n in range(0,np.size(scar_indices,axis=0)): # plt.scatter(e[scar_indices[n]],overlap[scar_indices[n]],marker="x",s=100,color="red") # plt.show() scar_e = np.zeros(np.size(scar_indices)) for n in range(0, np.size(scar_indices, axis=0)): scar_e[n] = e[scar_indices[n]] diffs = np.zeros(np.size(scar_e) - 1) for n in range(0, np.size(diffs, axis=0)): diffs[n] = scar_e[n + 1] - scar_e[n] diff_matrix = np.zeros((np.size(diffs), np.size(diffs))) for n in range(0, np.size(diff_matrix, axis=0)): for m in range(0, np.size(diff_matrix, axis=0)): diff_matrix[n, m] = diffs[n] - diffs[m] error = np.power( np.trace(np.dot(diff_matrix, np.conj(np.transpose(diff_matrix)))), 0.5) print(coef, error) print(scar_e) # print(coef) # if (np.abs(coef).any())>0.5: # return 1000 # else: return error
e,u = np.linalg.eigh(H_fsa) fsa_overlap = np.log10(np.abs(u[0,:])**2) fsa_energy = e plt.scatter(exact_energy,exact_overlap) plt.scatter(fsa_energy,fsa_overlap,marker="x",color="red",s=100) plt.show() t=np.arange(0,20,0.01) f=fidelity(z,H,"use sym").eval(t,z) plt.plot(t,f) plt.show() #identify scar states for entropy highlight scar_indices = get_top_band_indices(exact_energy,exact_overlap,pxp.N,100,100,e_diff = 0.5) #check identified right states plt.scatter(exact_energy,exact_overlap) for n in range(0,np.size(scar_indices,axis=0)): plt.scatter(exact_energy[scar_indices[n]],exact_overlap[scar_indices[n]],marker="D",color="green",alpha=0.5,s=100) plt.show() U = pxp_syms.basis_transformation(k[0]) eigvectors_comp = np.dot(U,H.sector.eigvectors(k[0])) fsa_eigs_comp = np.dot(U,np.dot(fsa_basis,u)) #entropy ent_vals = np.zeros(np.size(eigvectors_comp,axis=1)) ent = entropy(pxp) pbar=ProgressBar() for n in pbar(range(0,np.size(ent_vals,axis=0))):
def subspace_varianceSu2(coef): c = 0 Ip_total = deepcopy(Ip[0]) for n in range(1, len(Ip)): Ip_total = H_operations.add(Ip_total, Ip[n], np.array([1, coef[c + n - 1]])) Im_total = deepcopy(Im[0]) for n in range(1, len(Im)): Im_total = H_operations.add(Im_total, Im[n], np.array([1, coef[c + n - 1]])) c += len(Ip) - 1 Kp_total = deepcopy(Kp[0]) for n in range(1, len(Kp)): Kp_total = H_operations.add(Kp_total, Kp[n], np.array([1, coef[c + n - 1]])) Km_total = deepcopy(Km[0]) for n in range(1, len(Km)): Km_total = H_operations.add(Km_total, Km[n], np.array([1, coef[c + n - 1]])) c += len(Kp) - 1 Lp_total = deepcopy(Lp[0]) for n in range(1, len(Lp)): Lp_total = H_operations.add(Lp_total, Lp[n], np.array([1, coef[c + n - 1]])) Lm_total = deepcopy(Lm[0]) for n in range(1, len(Lm)): Lm_total = H_operations.add(Lm_total, Lm[n], np.array([1, coef[c + n - 1]])) H = H_operations.add(Ip_total, Im_total, np.array([1j, -1j])) H = H_operations.add(H, Kp_total, np.array([1, -1j])) H = H_operations.add(H, Km_total, np.array([1, 1j])) H = H_operations.add(H, Lp_total, np.array([1, 1j])) H = H_operations.add(H, Lm_total, np.array([1, -1j])) su3_basis = gen_su3Basis(coef) # restrict to 2N+1 basis with largest overlap with scar states # identify 2N+1 scars from H H.sector.find_eig(k) overlap = eig_overlap(z, H, k).eval() from Calculations import get_top_band_indices scar_indices = get_top_band_indices(H.sector.eigvalues(k), overlap, 2 * pxp.N, 100, 200, e_diff=0.5) plt.scatter(H.sector.eigvalues(k), overlap) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(H.sector.eigvalues(k)[scar_indices[n]], overlap[scar_indices[n]], marker="x", color="red", s=100) plt.show() #redifine su3_basis as the ritz vectors (new linear combs) H_fsa = np.dot(np.conj(np.transpose(su3_basis)), np.dot(H.sector.matrix(k), su3_basis)) e, u = np.linalg.eigh(H_fsa) su3_basis = np.dot(su3_basis, u) #find 2N+1 basis states with largest overlap with scars states max_scar_overlap = np.zeros(np.size(su3_basis, axis=1)) for n in range(0, np.size(max_scar_overlap, axis=0)): scarOverlap = np.zeros(np.size(scar_indices)) for m in range(0, np.size(scarOverlap, axis=0)): scarOverlap[m] = np.vdot( su3_basis[:, n], H.sector.eigvectors(k)[:, scar_indices[m]]) max_scar_overlap[n] = np.max(scarOverlap) su3_indices = np.arange(0, np.size(su3_basis, axis=1)) max_scar_overlap, su3_indices = (list(t) for t in zip( *sorted(zip(max_scar_overlap, su3_indices)))) max_scar_overlap = np.flip(max_scar_overlap) su3_indices = np.flip(su3_indices) su3_sub_indices = su3_indices[:np.size(scar_indices)] su3_sub_basis = np.zeros(np.size(su3_basis, axis=0)) for n in range(0, np.size(su3_sub_indices, axis=0)): su3_sub_basis = np.vstack( (su3_sub_basis, su3_basis[:, su3_sub_indices[n]])) su3_sub_basis = np.transpose(np.delete(su3_sub_basis, 0, axis=0)) H2 = np.dot(H.sector.matrix(k), H.sector.matrix(k)) H2_fsa = np.dot(np.conj(np.transpose(su3_basis)), np.dot(H2, su3_basis)) H_fsa = np.dot(np.conj(np.transpose(su3_basis)), np.dot(H.sector.matrix(k), su3_basis)) subspace_variance = np.real(np.trace(H2_fsa - np.dot(H_fsa, H_fsa))) print(coef, subspace_variance) e, u = np.linalg.eigh(H_fsa) H2 = np.dot(H.sector.matrix(k), H.sector.matrix(k)) H2_fsa = np.dot(np.conj(np.transpose(su3_sub_basis)), np.dot(H2, su3_sub_basis)) H_fsa = np.dot(np.conj(np.transpose(su3_sub_basis)), np.dot(H.sector.matrix(k), su3_sub_basis)) subspace_variance = np.real(np.trace(H2_fsa - np.dot(H_fsa, H_fsa))) print(coef, subspace_variance) e, u = np.linalg.eigh(H_fsa) return subspace_variance / np.size(su3_sub_basis, axis=1)
H_fsa = np.dot(np.conj(np.transpose(fsa_basis)), np.dot(H.sector.matrix(), fsa_basis)) Hz_fsa = np.dot(np.conj(np.transpose(fsa_basis)), np.dot(Hz, fsa_basis)) print(np.diag(Hz_fsa)) print(Hz_fsa[1, 1] - Hz_fsa[0, 0]) plt.matshow(np.abs(H_fsa)) plt.show() plt.matshow(np.abs(Hz_fsa)) plt.show() overlap = eig_overlap(z, H).eval() scar_indices = np.unique( np.sort(get_top_band_indices(H.sector.eigvalues(), overlap, pxp.N))) plt.scatter(H.sector.eigvalues(), overlap) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(H.sector.eigvalues()[scar_indices[n]], overlap[scar_indices[n]], marker="x", color="red", s=100) plt.show() Z_eff = np.zeros((np.size(scar_indices), np.size(scar_indices))) for n in range(0, np.size(scar_indices, axis=0)): Z_eff[n, n] = H.sector.eigvalues()[scar_indices[n]] # print(np.sort(np.diag(Z_eff))) # print(Z_eff[1,1]-Z_eff[0,0])
V.site_ops[1] = np.array([[0, 1], [1, 0]]) V.model = np.array([[0, 1, 1, 1, 0]]) V.model_coef = np.array([1]) # V.model = np.array([[0,1,0,0],[0,0,1,0]]) # V.model_coef = np.array([1,1]) H0.gen() V.gen() z = zm_state(2, 1, pxp) #get scar z2 overlap (no pert) H0.sector.find_eig() overlap = eig_overlap(z, H0).eval() from Calculations import get_top_band_indices scar_indices = get_top_band_indices(H0.sector.eigvalues(), overlap, pxp.N, 200, 150, 0.8) #check got right scars plt.scatter(H0.sector.eigvalues(), overlap) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(H0.sector.eigvalues()[scar_indices[n]], overlap[scar_indices[n]], marker="x", color="red", s=100) plt.show() scar_overlap = np.zeros(np.size(scar_indices)) for n in range(0, np.size(scar_indices, axis=0)): scar_overlap[n] = overlap[scar_indices[n]]
N = 18 pxp = unlocking_System([0],"periodic",2,N) pxp.gen_basis() e_nopert = np.load("./pxp,no_pert,e,18.npy") u_nopert = np.load("./pxp,no_pert,u,18.npy") e_pert = np.load("./pxp,pert,e,18.npy") u_pert = np.load("./pxp,pert,u,18.npy") z=zm_state(3,1,pxp) overlap_pert = np.log10(np.abs(u_pert[pxp.keys[z.ref],:])**2) overlap_nopert = np.log10(np.abs(u_nopert[pxp.keys[z.ref],:])**2) from Calculations import get_top_band_indices scar_indices_pert = get_top_band_indices(e_pert,overlap_pert,int(2*N/3),150,400,e_diff = 0.5) scar_indices_nopert = get_top_band_indices(e_nopert,overlap_nopert,int(2*N/3),150,400,e_diff = 0.5) plt.scatter(e_pert,overlap_pert) for n in range(0,np.size(scar_indices_pert,axis=0)): plt.scatter(e_pert[scar_indices_pert[n]],overlap_pert[scar_indices_pert[n]],marker="x",s=100,color="red") plt.show() plt.scatter(e_nopert,overlap_nopert) for n in range(0,np.size(scar_indices_nopert,axis=0)): plt.scatter(e_nopert[scar_indices_nopert[n]],overlap_nopert[scar_indices_nopert[n]],marker="x",s=100,color="red") plt.show() M = np.zeros((np.size(scar_indices_nopert,axis=0),np.size(scar_indices_pert,axis=0)),dtype=complex) for n in range(0,np.size(scar_indices_pert,axis=0)): for m in range(0,np.size(scar_indices_nopert,axis=0)):
z = zm_state(2, 1, pxp) k = pxp_syms.find_k_ref(z.ref) H = spin_Hamiltonian(pxp, "x", pxp_syms) overlapSectors = dict() for n in range(0, np.size(k, axis=0)): H.gen(k[n]) H.sector.find_eig(k[n]) overlapSectors[n] = eig_overlap(z, H, k[n]).eval() overlap = np.append(overlapSectors[0], overlapSectors[1]) energy = np.append(H.sector.eigvalues(k[0]), H.sector.eigvalues(k[1])) plt.scatter(energy, overlap) from Calculations import get_top_band_indices scar_indices = get_top_band_indices(energy, overlap, N, 100, 200, e_diff=0.5) scar_e = np.zeros(np.size(scar_indices)) scar_overlap = np.zeros(np.size(scar_indices)) for n in range(0, np.size(scar_indices, axis=0)): scar_e[n] = energy[scar_indices[n]] scar_overlap[n] = overlap[scar_indices[n]] plt.scatter(scar_e, scar_overlap, marker="x", color="red", s=300) plt.xlabel(r"$E$") plt.ylabel(r"$\log(\vert \langle Z_2 \vert E \rangle \vert^2)$") plt.show() t = np.arange(0, 20, 0.01) f = fidelity(z, H, "use sym").eval(t, z) plt.plot(t, f) plt.xlabel(r"$t$") plt.ylabel(r"$\vert \langle \psi(0) \vert \psi(t) \rangle \vert^2$")
fsa_overlap = np.log10(np.abs(u[0, :])**2) fsa_energy = e plt.scatter(exact_energy, exact_overlap) plt.scatter(fsa_energy, fsa_overlap, marker="x", color="red", s=100) plt.show() t = np.arange(0, 20, 0.01) f = fidelity(z, H).eval(t, z) plt.plot(t, f) plt.show() #identify scar states for entropy highlight scar_indices = get_top_band_indices(H.sector.eigvalues(), exact_overlap, int(pxp.N / 2), 200, 200, e_diff=0.5) #check identified right states plt.scatter(exact_energy, exact_overlap) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(exact_energy[scar_indices[n]], exact_overlap[scar_indices[n]], marker="D", color="green", alpha=0.5, s=100) plt.show() #entropy ent_vals = np.zeros(pxp.dim)
exact_overlap = eig_overlap(z, H).eval() exact_energy = H.sector.eigvalues() e, u = np.linalg.eigh(H_fsa) fsa_overlap = np.log10(np.abs(u[0, :])**2) fsa_energy = e #overlap plt.scatter(exact_energy, exact_overlap) plt.scatter(fsa_energy, fsa_overlap, marker="x", color="red", s=100) plt.show() #identify scar states for entropy highlight scar_indices = get_top_band_indices(H.sector.eigvalues(), exact_overlap, pxp.N, 100, 100, e_diff=0.5) #check identified right states plt.scatter(exact_energy, exact_overlap) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(exact_energy[scar_indices[n]], exact_overlap[scar_indices[n]], marker="D", color="green", alpha=0.5, s=100) plt.show() #fidelity t = np.arange(0, 20, 0.01)
Hp.model = np.array([[0, 2, 0], [0, 1, 0], [0, 1, 0]]) Hp.model_coef = np.array([1, 1, 1]) Hp.uc_size = np.array([3, 3, 3]) Hp.uc_pos = np.array([2, 0, 1]) Hp.gen() Hm = Hp.herm_conj() H = H_operations.add(Hp, Hm, np.array([1, 1])) z = zm_state(3, 1, pxp) H.sector.find_eig() overlap = eig_overlap(z, H).eval() from Calculations import get_top_band_indices scar_indices = get_top_band_indices(H.sector.eigvalues(), overlap, int(2 * pxp.N / 3), 100, 200, e_diff=0.5) plt.scatter(H.sector.eigvalues(), overlap) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(H.sector.eigvalues()[scar_indices[n]], overlap[scar_indices[n]], marker="x", color="red", s=100) plt.show() ent_vals = np.zeros(pxp.dim) ent = entropy(pxp) pbar = ProgressBar()
V1.gen() V2.gen() H1 = H_operations.add(H0, V1, np.array([1, 0.108])) H2 = H_operations.add(H0, V2, np.array([1, 0.122])) H1.sector.find_eig() H2.sector.find_eig() z = zm_state(2, 1, pxp) overlap1 = eig_overlap(z, H1).eval() overlap2 = eig_overlap(z, H1).eval() from Calculations import get_top_band_indices scar_indices_ppxp = get_top_band_indices(H1.sector.eigvalues(), overlap1, pxp.N, 150, 300, e_diff=0.5) scar_indices_pxxxp = get_top_band_indices(H2.sector.eigvalues(), overlap2, pxp.N, 150, 300, e_diff=0.5) plt.scatter(H1.sector.eigvalues(), overlap1) for n in range(0, np.size(scar_indices_ppxp, axis=0)): plt.scatter(H1.sector.eigvalues()[scar_indices_ppxp[n]], overlap1[scar_indices_ppxp[n]], marker="x", color="red")
pxp_syms = model_sym_data(pxp, [translational(pxp)]) z = zm_state(2, 1, pxp) k = pxp_syms.find_k_ref(z.ref) H = spin_Hamiltonian(pxp, "x") H.gen() H.sector.find_eig() overlap = eig_overlap(z, H).eval() plt.scatter(H.sector.eigvalues(), overlap) from Calculations import get_top_band_indices scar_indices = get_top_band_indices(H.sector.eigvalues(), overlap, N, 100, 200, e_diff=0.5) scar_e = np.zeros(np.size(scar_indices)) scar_overlap = np.zeros(np.size(scar_indices)) for n in range(0, np.size(scar_indices, axis=0)): scar_e[n] = H.sector.eigvalues()[scar_indices[n]] scar_overlap[n] = overlap[scar_indices[n]] plt.scatter(scar_e, scar_overlap, marker="x", color="red", s=300) plt.ylim(bottom=-10) plt.show() # z=bin_state([1,1,0,1,1,0,1,1,0,1,1,0],pxp) fidelity(z, H).plot(np.arange(0, 20, 0.01), z) plt.show()
# if overlap_total[n] <-10: # to_del = np.append(to_del,n) # for n in range(np.size(to_del,axis=0)-1,-1,-1): # overlap_total=np.delete(overlap_total,to_del[n]) # e=np.delete(e,to_del[n]) # np.save("e_temp",e) # np.save("overlap_temp",overlap_total) e = np.load("./e_temp.npy") overlap_total = np.load("./overlap_temp.npy") e, overlap_total = (list(t) for t in zip(*sorted(zip(e, overlap_total)))) plt.scatter(e, overlap_total) from Calculations import get_top_band_indices scar_indices = np.sort( get_top_band_indices(e, overlap_total, pxp.N + 2, 350, 400, e_diff=1)) scar_indices = np.append(scar_indices, 1) scar_indices = np.append(scar_indices, np.size(e) - 2) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(e[scar_indices[n]], overlap_total[scar_indices[n]], marker="x", color="red", s=100) plt.show() scar_e = np.zeros(np.size(scar_indices)) for n in range(0, np.size(scar_indices, axis=0)): scar_e[n] = e[scar_indices[n]] scar_e = np.sort(scar_e)
-c * pert_coef[1], -c * pert_coef[2], -c * pert_coef[2], -c * pert_coef[3], -c * pert_coef[3] ]) # H.model = np.array([[0,1,0],[0,1,0,2],[2,0,1,0]]) # H.model_coef = np.array([c,-c*pert_coef[0],-c*pert_coef[0]]) H.gen() H.sector.find_eig() z = zm_state(2, 1, pxp) fidelity(z, H).plot(np.arange(0, 20, 0.01), z) plt.show() overlap = eig_overlap(z, H).eval() from Calculations import get_top_band_indices scar_indices = np.sort( np.unique(get_top_band_indices(H.sector.eigvalues(), overlap, N))) scar_basis = np.zeros((pxp.dim, np.size(scar_indices))) for n in range(0, np.size(scar_indices, axis=0)): scar_basis[scar_indices[n], n] = 1 plt.scatter(H.sector.eigvalues(), overlap) for n in range(0, np.size(scar_indices, axis=0)): plt.scatter(H.sector.eigvalues()[scar_indices[n]], overlap[scar_indices[n]], s=100, marker="x", color="red") plt.show() # H=H_operations.add(H0,V,np.array([c,-c*pert_coef]))
rc('text', usetex=True) # matplotlib.rcParams['figure.dpi'] = 400 N = 18 pxp = unlocking_System([0], "periodic", 2, N) pxp.gen_basis() e = np.load("./pxp,e," + str(pxp.N) + ".npy") u = np.load("./pxp,u," + str(pxp.N) + ".npy") z3_overlap = np.load("./pxp,z3_overlap," + str(pxp.N) + ".npy") mps_overlap = np.load("./pxp,mps_overlap," + str(pxp.N) + ".npy") from Calculations import get_top_band_indices z3_scar_indices = get_top_band_indices(e, z3_overlap, int(2 * pxp.N / 3), 150, 300, e_diff=0.5) mps_scar_indices = get_top_band_indices(e, mps_overlap, int(2 * pxp.N / 3), 150, 300, e_diff=0.5) plt.scatter(e, z3_overlap) for n in range(0, np.size(z3_scar_indices, axis=0)): plt.scatter(e[z3_scar_indices[n]], z3_overlap[z3_scar_indices[n]], marker="x", s=100,
# t=np.arange(0,60,0.01) # f=np.zeros(np.size(t)) # for n in range(0,np.size(t,axis=0)): # evolved_state = time_evolve_state(psi_energy,e,t[n]) # f[n] = np.abs(np.vdot(evolved_state,psi_energy))**2 # plt.plot(t,f) # plt.xlabel(r"$t$") # plt.ylabel(r"$\vert \langle \psi(0) \vert \psi(t) \rangle \vert^2$") # plt.title(r"$SU_q(2), q=e^{i * 0.01}, N=$"+str(N)) # plt.show() psi_energy = np.conj(u[0, :]) overlap = np.log10(np.abs(psi_energy)**2) plt.scatter(e, overlap) from Calculations import get_top_band_indices scars_indices = get_top_band_indices(e, overlap, N, 250, 450, e_diff=0.8) print(scars_indices) for n in range(0, np.size(scars_indices, axis=0)): plt.scatter(e[scars_indices[n]], overlap[scars_indices[n]], marker="x", color="red") plt.show() eigenvalues = e 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])