Ejemplo n.º 1
0
def pert_opt_fidelity(coef, plot=False):
    # H = H_operations.add(H0,V1,np.array([1,coef[0]]))
    H = H_operations.add(H0, V1, np.array([1, coef]))
    # H = H_operations.add(H,V2,np.array([1,coef[1]]))
    # H = H_operations.add(H,V3,np.array([1,coef[2]]))
    z = zm_state(3, 1, pxp)
    psi = z.prod_basis()
    # psi = np.load("./z3,entangled_MPS_coef,15.npy")
    H.sector.find_eig()
    psi_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors())), psi)
    if plot is True:
        eig_overlap(z, H).plot()
        plt.show()
        t = np.arange(0, 20, 0.01)
        f = np.zeros(np.size(t))
        for n in range(0, np.size(t, axis=0)):
            f[n] = -fidelity_eval(psi_energy, H.sector.eigvalues(), t[n])
        plt.plot(t, f)
        plt.show()
    res = minimize_scalar(
        lambda t: fidelity_eval(psi_energy, H.sector.eigvalues(), t),
        method="golden",
        bracket=(2.5, 5))
    # f_max = -fidelity_eval(z_energy,H.sector.eigvalues(),res.x)
    f_max = -fidelity_eval(psi_energy, H.sector.eigvalues(), res.x)
    print(coef, f_max, res.x)
    if np.abs(res.x) < 1e-5:
        return 1000
    else:
        return -f_max
Ejemplo n.º 2
0
def exp(Q, psi):
    return np.vdot(psi, np.dot(Q, psi))


def var(Q, psi):
    Q2 = np.dot(Q, Q)
    return exp(Q2, psi) - exp(Q, psi)**2


N = 12
pxp = unlocking_System([0], "periodic", 2, N)
pxp.gen_basis()
pxp_syms = model_sym_data(pxp, [translational_general(pxp, order=4), PT(pxp)])

H = Hamiltonian(pxp, pxp_syms)
H.site_ops[1] = np.array([[0, 1], [1, 0]])
H.model = np.array([[0, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0]])
H.model_coef = np.array([1, -1, -1])
H.uc_size = np.array([1, 4, 4])
H.uc_pos = np.array([0, 3, 1])
H.gen()
H.sector.find_eig()
z = zm_state(4, 1, pxp)

eig_overlap(z, H).plot()
plt.show()

fidelity(z, H).plot(np.arange(0, 20, 0.01), z)
plt.show()
Ejemplo n.º 3
0
Ip_total = H_operations.add(Ip, Ip_pert, np.array([1, coef]))
Im_total = H_operations.add(Im, Im_pert, np.array([1, coef]))
Kp_total = H_operations.add(Kp, Kp_pert, np.array([1, coef]))
Km_total = H_operations.add(Km, Km_pert, np.array([1, coef]))
Lp_total = H_operations.add(Lp, Lp_pert, np.array([1, coef]))
Lm_total = H_operations.add(Lm, Lm_pert, np.array([1, coef]))

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]))

H.sector.find_eig(k)
exact_energy = H.sector.eigvalues(k)
exact_overlap = eig_overlap(z, H, k).eval()

plt.scatter(exact_energy, exact_overlap)
plt.show()
t = np.arange(0, 20, 0.01)
f = fidelity(z, H, "use sym").eval(t, z)
plt.plot(t, f)
plt.show()

#su3 rep
#0th order rep (no perts)
root3 = np.power(3, 0.5)
I3 = 1 / 2 * com(Ip.sector.matrix(k), Im.sector.matrix(k))
g8 = 1 / (2 * root3) * (com(Kp.sector.matrix(k), Km.sector.matrix(k)) +
                        com(Lp.sector.matrix(k), Lm.sector.matrix(k)))
Ejemplo n.º 4
0
Hp[2] = Hamiltonian(pxp, pxp_syms)
Hp[2].site_ops[1] = np.array([[0, 0], [1, 0]])
Hp[2].site_ops[2] = np.array([[0, 1], [0, 0]])
Hp[2].site_ops[4] = np.array([[0, 0], [0, 1]])
Hp[2].model = np.array([[0, 4, 0, 1, 2, 0], [0, 1, 2, 0, 4, 0]])
Hp[2].model_coef = np.array([1, 1])

psi = bin_state(np.array([0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0]), pxp)
k = pxp_syms.find_k_ref(psi.ref)

for n in range(0, len(Hp)):
    for m in range(0, np.size(k, axis=0)):
        Hp[n].gen(k[m])

coef = np.load("./data/xy,pert_coef,10.npy")
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]]))

Hp = Hp_total
Hm = Hp_total.herm_conj()

H = H_operations.add(Hp, Hm, np.array([1, 1]))
for m in range(0, np.size(k, axis=0)):
    H.sector.find_eig(k[m])
    eig_overlap(psi, H, k[m]).plot()
plt.show()
fidelity(psi, H, "use sym").plot(np.arange(0, 20, 0.01), psi)
plt.show()
Ejemplo n.º 5
0
    for m in range(0,np.size(k,axis=0)):
        Hp[n].gen(k[m])

# for m in range(0,np.size(k,axis=0)):
    # Hp[0].gen(k[m])

coef = np.load("./pxxxp,1stOrder,coef,12.npy")
# coef = np.zeros(len(Hp)-1)
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 = Hp_total.herm_conj()

H = H_operations.add(Hp_total,Hm,np.array([1,1]))
H.sector.find_eig(k[0])
eig_overlap(z,H,k[0]).plot(tol=-15)
plt.show()
fidelity(z,H,"use sym").plot(np.arange(0,20,0.01),z)
plt.show()

from Calculations import gen_fsa_basis
fsa_basis = gen_fsa_basis(Hp_total.sector.matrix(k[0]),z.sym_basis(k[0],pxp_syms),int(2*pxp.N/4))
H_fsa = np.dot(np.conj(np.transpose(fsa_basis)),np.dot(H.sector.matrix(k[0]),fsa_basis))
e,u = np.linalg.eigh(H_fsa)
overlap_fsa = np.log10(np.abs(u[0,:])**2)

exact_overlap = eig_overlap(z,H,k[0]).eval()
plt.scatter(H.sector.eigvalues(k[0]),exact_overlap)
plt.scatter(e,overlap_fsa,marker="x",color="red",s=100)
plt.show()
t=np.arange(0,20,0.01)
Ejemplo n.º 6
0
H = Hamiltonian(pxp,pxp_syms)
H.site_ops[1] = np.array([[0,1],[1,0]])
# H.model = np.array([[0,1,0],[0,1,1,1,0]])
H.model = np.array([[0,1,0],[0,0,1,0],[0,1,0,0]])
# H.model_coef = np.array([1,0.122959959])
a=0.108
H.model_coef = np.array([1,a,a])

z=zm_state(2,1,pxp)

k=pxp_syms.find_k_ref(z.ref)
for n in range(0,np.size(k,axis=0)):
    H.gen(k[n])
    H.sector.find_eig(k[n])
    eig_overlap(z,H,k[n]).plot()
plt.title(r"$H=PXP + \lambda PXXXP$, N="+str(pxp.N))
plt.show()

t=np.arange(0,20,0.001)
f0 = fidelity(z,H,"use sym").eval(t,z)
for n in range(0,np.size(f0,axis=0)):
    if f0[n] < 0.1:
        cut = n
        break
max_index = np.argmax(f0[cut:])
print(t[cut:][max_index])

# plt.plot(t,f0)
# plt.xlabel(r"$t$")
# plt.ylabel(r"$\vert \langle \psi(0) \vert \psi(t) \rangle \vert^2$")
plt.title(r"$PXP$ Projected time evolution, N=" + str(pxp.N))
plt.show()

# svd_basis = np.load("./svd_basis_for_gif/svd_basis,16,150.npy")
# t_info = np.load("./svd_basis_for_gif/t_info,16,150.npy")
# print(t_info[1])

# z_svd = np.dot(np.conj(np.transpose(svd_basis)),z.prod_basis())
# H_svd = np.dot(np.conj(np.transpose(svd_basis)),np.dot(H0.sector.matrix(),svd_basis))
# e_svd,u_svd = np.linalg.eigh(H_svd)

# overlap_svd = np.zeros(np.size(e_svd))
# for n in range(0,np.size(overlap_svd,axis=0)):
# overlap_svd[n] = np.log10(np.abs(np.vdot(z_svd,u_svd[:,n]))**2)

exact_overlap = eig_overlap(z, H0).eval()
eigenvalues = H0.sector.eigvalues()
to_del = []
for n in range(0, np.size(exact_overlap, axis=0)):
    if exact_overlap[n] < -5:
        to_del = np.append(to_del, n)
for n in range(np.size(to_del, axis=0) - 1, -1, -1):
    exact_overlap = np.delete(exact_overlap, to_del[n])
    eigenvalues = np.delete(eigenvalues, to_del[n])

overlap_fsa = np.log10(np.abs(u_fsa[0, :])**2)

# plt.scatter(eigenvalues,exact_overlap,label="Exact")
# plt.scatter(e_fsa,overlap_fsa,marker="x",s=100,label="FSA")
# plt.scatter(e_svd,overlap_svd,marker="s",color="red",s=100,alpha=0.6,label="SVD")
# plt.legend()
Ejemplo n.º 8
0
Hp.uc_pos = np.array([2, 3, 0, 1])
Hp.gen()

from Calculations import gen_fsa_basis
z = zm_state(4, 1, pxp)
fsa_basis = gen_fsa_basis(Hp.sector.matrix(), z.prod_basis(),
                          int(2 * pxp.N / 4))
print(np.shape(fsa_basis))
H_fsa = np.dot(np.conj(np.transpose(fsa_basis)),
               np.dot(H.sector.matrix(), fsa_basis))
e, u = np.linalg.eigh(H_fsa)
fsa_energy = e
fsa_overlap = np.log10(np.abs(u[0, :])**2)
plt.scatter(fsa_energy, fsa_overlap, marker="x", color="red", s=100)
H.sector.find_eig()
eig_overlap(z, H).plot(tol=-10)
plt.show()

H.sector.find_eig()
ent = entropy(pxp)
ent_vals = np.zeros(pxp.dim)
for n in range(0, np.size(pxp.basis, axis=0)):
    ent_vals[n] = ent.eval(H.sector.eigvectors()[:, n])
plt.scatter(H.sector.eigvalues(), ent_vals)
plt.show()

# k=pxp_syms.find_k_ref(z.ref)
# exact_energy = []
# exact_overlap = []
# for n in range(0,np.size(k,axis=0)):
# H.gen(k[n])
Ejemplo n.º 9
0
# coef = np.loadtxt("../../../../pxp,2nd_order_perts/z3/data/pxp,z3,2nd_order_pert,coef,18")
print(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 = Hp_total.herm_conj()

H = H_operations.add(Hp_total,Hm,np.array([1,1]))
# H.sector.find_eig()
exact_energy = []
exact_overlap = []
for n in range(0,np.size(k,axis=0)):
    H.sector.find_eig(k[n])
    exact_energy = np.append(exact_energy,H.sector.eigvalues(k[n]))
    exact_overlap= np.append(exact_overlap,eig_overlap(z,H,k[n]).eval())
t=np.arange(0,20,0.01)
# eig_overlap(z,H).plot()
# plt.show()
# fidelity(z,H).plot(t,z)
# plt.show()
plt.scatter(exact_energy,exact_overlap)
plt.show()
f=fidelity(z,H,"use sym").eval(t,z)
plt.plot(t,f)
plt.show()
    
# fsa_dim = int(2*pxp.N/4)
# from Calculations import gen_fsa_basis
# fsa_basis = gen_fsa_basis(Hp_total.sector.matrix(),z.prod_basis(),fsa_dim)
# for n in range(0,np.size(fsa_basis,axis=1)):
Ejemplo n.º 10
0
coupling_basis[:, 0] = z1.prod_basis()
coupling_basis[:, 1] = z2.prod_basis()
coupling_basis[:, 2] = z3.prod_basis()
coupling_basis[:, 3] = z0.prod_basis()

basis = np.hstack((c1_basis, coupling_basis))
basis = np.hstack((basis, np.flip(c2_basis, axis=1)))

pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)])
H = spin_Hamiltonian(pxp, "x", pxp_syms)
z = zm_state(2, 1, pxp)
k = pxp_syms.find_k_ref(z.ref)
for n in range(0, np.size(k, axis=0)):
    H.gen(k[n])
    H.sector.find_eig(k[n])
    overlap = eig_overlap(z, H, k[n]).eval()
    plt.scatter(H.sector.eigvalues(k[n]), overlap, color="blue")
H.gen()
H.sector.find_eig()

# eig_overlap(z,H).plot()
# plt.show()

H_rot = np.dot(np.conj(np.transpose(basis)), np.dot(H.sector.matrix(), basis))
# plt.matshow(np.abs(H_rot))
# plt.show()

print(H.sector.eigvalues())
e, u = np.linalg.eigh(H_rot)
print(e)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
overlap_fsa = np.log10(np.abs(psi_energy_fsa)**2)
plt.scatter(e_fsa, overlap_fsa, marker="x", color="blue", s=200, label="FSA")

#krylov neel overlap
e_krylov, u_krylov = np.linalg.eigh(H_krylov)
psi_energy_krylov = u_krylov[0, :]
overlap_krylov = np.log10(np.abs(psi_energy_krylov)**2)
plt.scatter(e_krylov,
            overlap_krylov,
            marker="x",
            color="green",
            s=200,
            label="Krylov")

z = zm_state(2, 1, pxp)
overlap = eig_overlap(z, H).eval()
plt.scatter(H.sector.eigvalues(), overlap, label="Exact")

plt.legend()
plt.show()

u_comp_basis = np.dot(basis, u)
exact_overlap = np.zeros(np.size(e), dtype=complex)
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(u_comp_basis[:, n],
                              H.sector.eigvectors()[:, m]))**2
        if temp > max_overlap:
            max_overlap = temp
    exact_overlap[n] = max_overlap
Ejemplo n.º 13
0
U[0] = pxp_syms.basis_transformation(k[0])
U[1] = pxp_syms.basis_transformation(k[1])

# ent_vals = dict()
# ent = entropy(pxp)
# for n in range(0,np.size(k,axis=0)):
# ent_vals[n] = np.zeros(np.size(H.sector.eigvalues(k[n])))
# eigs_rotated = np.dot(U[n], H.sector.eigvectors(k[n]))
# for m in range(0,np.size(ent_vals[n],axis=0)):
# ent_vals[n][m] = ent.eval(eigs_rotated[:,m])

# # ent_vals = np.zeros(np.size(pxp.basis_refs))
# # pbar=ProgressBar()
# # for n in pbar(range(0,np.size(ent_vals,axis=0))):
# # ent_vals[n] = ent.eval(H.sector.eigvectors()[:,n])
# plt.scatter(H.sector.eigvalues(k[0]),ent_vals[0],color="blue")
# plt.scatter(H.sector.eigvalues(k[1]),ent_vals[1],color="blue")
# plt.title(r"$H=X+\lambda n n$, $\textrm{Eigenstate Entropy}, \lambda = 0.1, N=16$")
# plt.xlabel(r"$E$")
# plt.ylabel(r"$S$")
# plt.show()

eig_overlap(z, H, k[0]).plot()
eig_overlap(z, H, k[1]).plot()
plt.title(
    r"$H=X+\lambda n n$, $\textrm{Eigenstate Overlap with Neel}, \lambda = 0.1, N=16$"
)
plt.xlabel(r"$E$")
plt.ylabel(r"$\log(\vert \langle \psi \vert E \rangle \vert^2)$")
plt.show()
V = Hamiltonian(pxp)
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))
V2 = Hamiltonian(pxp, pxp_syms)
V2.site_ops[1] = np.array([[0, 1], [1, 0]])
V2.model = np.array([[0, 1, 1, 1, 0]])
V2.model_coef = np.array([1])

H0.gen()
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)
    pxp.basis_refs[n] = bin_to_int_base_m(pxp.basis[n], pxp.base)
    pxp.keys[pxp.basis_refs[n]] = n
pxp.dim = np.size(pxp.basis, axis=0)
print("new dim = " + str(pxp.dim))

pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)])

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)$")