Example #1
0
def energy_basis(state, H):
    #find sym blocks state has non zero overlap in
    state_ref = bin_to_int_base_m(state, H.system.base)
    state_index = find_index_bisection(state_ref, H.system.basis_refs)
    sym_ref = H.syms.sym_data[state_index, 0]
    k_refs = H.syms.find_k_ref(sym_ref)

    #dict to store state in sym sector basis
    z_sym = dict()
    eigenvalues = dict()
    for n in range(0, np.size(k_refs, axis=0)):
        psi = ref_state(state_ref, H.system)
        z_sym[n] = psi.sym_basis(k_refs[n], H.syms)
        eigenvalues[n] = H.sector.eigvalues(k_refs[n])

    #dict to store state from sym sector in energy eigenbasis
    z_energy = dict()
    for n in range(0, np.size(k_refs, axis=0)):
        z_energy[n] = np.zeros(np.size(H.sector.eigvalues(k_refs[n])),
                               dtype=complex)
        #find coefficients by taking overlaps
        for m in range(0, np.size(z_energy[n], axis=0)):
            z_energy[n][m] = np.vdot(
                H.sector.eigvectors(k_refs[n])[:, m], z_sym[n])

    #combine all sym sectors
    z_init = z_energy[0]
    eig_f = eigenvalues[0]
    for n in range(1, len(z_energy)):
        z_init = np.append(z_init, z_energy[n])
        eig_f = np.append(eig_f, eigenvalues[n])
    return z_init, eig_f
def subcube_basis(root_refs, LR, cube_dim):
    distinct_subcube_basis = dict()
    for n in range(0, np.size(root_refs, axis=0)):
        distinct_subcube_basis[n] = ref_state(root_refs[n], pxp).prod_basis()
        current_state = distinct_subcube_basis[n]
        Hm, Hp = fsa_ops_from_root(root_refs[n], LR)
        for m in range(0, cube_dim):
            next_state = np.dot(Hp, current_state)
            if (np.abs(next_state) < 1e-5).all() == False:
                next_state = next_state / np.power(
                    np.vdot(next_state, next_state), 0.5)
                distinct_subcube_basis[n] = np.vstack(
                    (distinct_subcube_basis[n], next_state))
            current_state = next_state
        distinct_subcube_basis[n] = np.transpose(distinct_subcube_basis[n])

    #now combine subcube basis
    subcube_basis = distinct_subcube_basis[0]
    for n in range(1, len(distinct_subcube_basis)):
        subcube_basis = subcube_basis + distinct_subcube_basis[n]

    #delete any zeros
    to_del = []
    for n in range(0, np.size(subcube_basis, axis=1)):
        if (np.abs(subcube_basis[:, n]) < 1e-5).all():
            to_del = np.append(to_del, n)
    for n in range(np.size(to_del, axis=0) - 1, -1, -1):
        subcube_basis = np.delete(subcube_basis, to_del[n], axis=1)

    for n in range(0, np.size(subcube_basis, axis=1)):
        subcube_basis[:, n] = subcube_basis[:, n] / np.power(
            np.vdot(subcube_basis[:, n], subcube_basis[:, n]), 0.5)

    return subcube_basis
Example #3
0
def column_rate(column_index):
    N_column = np.size(hamming_sectors[column_index])
    rate_sum = 0
    for ref1 in hamming_sectors[column_index]:
        for ref2 in hamming_sectors[column_index]:
            temp = np.dot(V.sector.matrix(), ref_state(ref1, pxp).prod_basis())
            int_term1 = np.abs(np.sum(temp))
            if ref1 == ref2:
                rate_sum = rate_sum + (N_column - 1) * int_term1**2
            else:
                # print("HOHo")
                temp = np.dot(V.sector.matrix(),
                              ref_state(ref2, pxp).prod_basis())
                int_term2 = np.abs(np.sum(temp))
                rate_sum = rate_sum - int_term1 * int_term2
    rate_sum = -2 * rate_sum / N_column**2
    return rate_sum
Example #4
0
    def bulk_eval(state, H, k_vec=None):
        if k_vec is None:  #no symmetry, use full basis
            z_ref = bin_to_int_base_m(state, H.system.base)
            z_index = find_index_bisection(z_ref, H.system.basis_refs)
            z_energy = H.sector.eigvectors()[z_index, :]
            eigenvalues = H.sector.eigvalues()
        else:  #symmetry used, just plot the given sym_block
            z_ref = bin_to_int_base_m(state, H.system.base)
            psi = ref_state(z_ref, H.system)
            z_mom = psi.sym_basis(k_vec, H.syms)
            # z_mom = z_mom * np.power(np.vdot(z_mom,z_mom),-0.5)
            z_energy = np.zeros(np.size(H.sector.eigvalues(k_vec)),
                                dtype=complex)
            for n in range(0, np.size(z_energy, axis=0)):
                z_energy[n] = np.vdot(z_mom, H.sector.eigvectors(k_vec)[:, n])
            eigenvalues = H.sector.eigvalues(k_vec)

        overlap = np.log10(np.abs(z_energy)**2)
        return overlap
def subcube_basis_from_sector(sector):
    root_basis = dict()
    refs = sector_refs[perm_key(sector, pxp)]
    for n in range(0, np.size(refs, axis=0)):
        root_basis[n] = np.zeros(pxp.dim)
        Hm = Hm_from_ref(refs[n])
        Hm = np.conj(np.transpose(Hm))
        current_state = ref_state(refs[n], pxp).prod_basis()
        while (np.abs(current_state) < 1e-5).all() == False:
            root_basis[n] = np.vstack((root_basis[n], current_state))
            current_state = np.dot(Hm, current_state)
        root_basis[n] = np.transpose(np.delete(root_basis[n], 0, axis=0))

    #form superposition from all roots
    basis = root_basis[0]
    for n in range(1, len(root_basis)):
        basis = basis + root_basis[n]

    #normalize
    for n in range(0, np.size(basis, axis=1)):
        basis[:, n] = basis[:, n] / np.power(np.vdot(basis[:, n], basis[:, n]),
                                             0.5)
    return basis
rc('text', usetex=True)
# matplotlib.rcParams['figure.dpi'] = 400

N = 10
J = 1
hx = 1
hz = 1
#init system
system = unlocking_System([0, 1], "periodic", 2, N)
system.gen_basis()
system_syms = model_sym_data(system, [translational(system)])

#create Hamiltonian
H = Hamiltonian(system, system_syms)
H.site_ops[1] = np.array([[0, 1], [1, 0]])
H.site_ops[2] = np.array([[-1, 0], [0, 1]])
H.model = np.array([[1, 1], [2], [1]])
H.model_coef = np.array([J, hz, hx])

#dynamics following quench from |00000>
psi = ref_state(0, system)
k = system_syms.find_k_ref(psi.ref)
for n in range(0, np.size(k, axis=0)):
    H.gen(k[n])
    H.sector.find_eig(k[n])
    print(H.sector.eigvalues(k[n]))
    eig_overlap(psi, H, k[n]).plot()
plt.show()
fidelity(psi, H, "use sym").plot(np.arange(0, 20, 0.01), psi)
plt.show()
Example #7
0
    ref_list = perm_sector_refs[perm_key(edge_vertex_sectors[n])]
    for m in range(0, np.size(ref_list)):
        index = pxp.keys[ref_list[m]]
        edge_vertex_projectors[n][index, index] = 1

H = spin_Hamiltonian(pxp, "x")
H.gen()
#find root states by those which reside in root sector and are not killed by PH, P a projector into edge_vertex_sectors
# root_refs = []
root_refs = dict()
for n in range(0, np.size(root_sectors, axis=0)):
    root_refs[perm_key(root_sectors[n])] = []
    for m in range(
            0, np.size(perm_sector_refs[perm_key(root_sectors[n])], axis=0)):
        ref = perm_sector_refs[perm_key(root_sectors[n])][m]
        state = np.dot(H.sector.matrix(), ref_state(ref, pxp).prod_basis())
        for j in range(0, len(edge_vertex_projectors)):
            temp = np.dot(edge_vertex_projectors[j], state)
            if np.abs(np.sum(temp)) > 1e-5:
                root_refs[perm_key(root_sectors[n])] = np.append(
                    root_refs[perm_key(root_sectors[n])], ref)
                break

for n in range(0, np.size(root_sectors, axis=0)):
    print("\n")
    for m in range(0, np.size(root_refs[perm_key(root_sectors[n])], axis=0)):
        ref = root_refs[perm_key(root_sectors[n])][m]
        print(pxp.basis[pxp.keys[ref]], basis_perm_labels[pxp.keys[ref]])

# smaller hypercubes + hamming, for subcube identification
sub_cube_systems = dict()
def cube_fsa(root_sector,sublattice_parity,sector_refs,system):
    refs = sector_refs[perm_key(root_sector,system)]
    # #find root refs, those with two neighbouring 1->0 from Neel
    root_refs = []
    for n in range(0,np.size(refs,axis=0)):
        bits = system.basis[system.keys[refs[n]]]
        for m in range(0,np.size(bits,axis=0)):
            if m == np.size(bits)-1:
                mp1 = 0
                mp2 = 1
                mp3 = 2
            elif m == np.size(bits)-2:
                mp1 = m + 1
                mp2 = 0
                mp3 = 1
            elif m == np.size(bits)-3:
                mp1 = m + 1
                mp2 = m + 2
                mp3 = 0
            else:
                mp1 = m + 1
                mp2 = m + 2
                mp3 = m + 3

            if bits[m] == 0 and bits[mp1] == 0 and bits[mp2] == 0 and bits[mp3] == 0:
                root_refs = np.append(root_refs,refs[n])
                break

    root_bits = np.zeros((np.size(root_refs),system.N))
    for n in range(0,np.size(root_refs,axis=0)):
        root_bits[n] = system.basis[system.keys[root_refs[n]]]

    fsa_min_bit_loc = np.zeros((np.size(root_bits,axis=0),int(system.N/2)-2))
    fsa_plus_bit_loc = np.zeros(np.size(root_bits,axis=0))

    for n in range(0,np.size(root_bits,axis=0)):
        c=0
        for m in range(0,np.size(root_bits[n],axis=0)):
            if root_bits[n,m] == 1:
                fsa_min_bit_loc[n,c] = m
                c = c+1


            if sublattice_parity == "L":
                if m % 2 != 0:
                    if m == system.N-1:
                        mp1 = 0
                    else:
                        mp1 = m + 1
                    if m == 0:
                        mm1 = system.N-1
                    else:
                        mm1 = m - 1
                    if root_bits[n,mm1] == 0 and root_bits[n,m] == 0 and root_bits[n,mp1] == 0:
                        fsa_plus_bit_loc[n] = m

            elif sublattice_parity == "R":
                if m % 2 == 0:
                    if m == system.N-1:
                        mp1 = 0
                    else:
                        mp1 = m + 1
                    if m == 0:
                        mm1 = system.N-1
                    else:
                        mm1 = m - 1
                    if root_bits[n,mm1] == 0 and root_bits[n,m] == 0 and root_bits[n,mp1] == 0:
                        fsa_plus_bit_loc[n] = m

    fsa_plus = dict()
    fsa_min = dict()
    for n in range(0,np.size(fsa_plus_bit_loc,axis=0)):
        fsa_plus[n] = np.zeros((system.dim,system.dim))
        #scan basis + sites
        for m in range(0,np.size(system.basis_refs,axis=0)):
            for k in range(0,system.N):
                #sp
                if np.abs(k - fsa_plus_bit_loc[n])<1e-5:
                    bits = np.copy(system.basis[m])
                    if k == system.N-1:
                        kp1 = 0
                    else:
                        kp1 = k +1
                    if k == 0:
                        km1 = system.N-1
                    else:
                        km1 = k - 1

                    if bits[kp1] == 0 and bits[km1] == 0 and bits[k] == 0:
                        bits[k] = 1
                        new_ref = bin_to_int_base_m(bits,system.base)
                        fsa_plus[n][m,system.keys[new_ref]] = 1
                #sm
                if k in fsa_min_bit_loc[n]:
                    bits = np.copy(system.basis[m])
                    if k == system.N-1:
                        kp1 = 0
                    else:
                        kp1 = k +1
                    if k == 0:
                        km1 = system.N-1
                    else:
                        km1 = k - 1

                    if bits[kp1] == 0 and bits[km1] == 0 and bits[k] == 1:
                        bits[k] = 0
                        new_ref = bin_to_int_base_m(bits,system.base)
                        fsa_plus[n][m,system.keys[new_ref]] = 1

    for n in range(0,len(fsa_plus)):
        fsa_min[n] = np.conj(np.transpose(fsa_plus[n]))

    fsa_basis = dict()
    fsa_dim = int(system.N/2-2)
    for n in range(0,np.size(root_refs,axis=0)):
        fsa_basis[n] = ref_state(root_refs[n],system).prod_basis()
        current_state = fsa_basis[n]
        for m in range(0,fsa_dim):
            new_state = np.dot(fsa_min[n],current_state)
            new_state = new_state / np.power(np.vdot(new_state,new_state),0.5)
            fsa_basis[n] = np.vstack((fsa_basis[n],new_state))
            current_state = new_state
        fsa_basis[n] = np.transpose(fsa_basis[n])

    basis = fsa_basis[0]
    for n in range(1,len(fsa_basis)):
        basis = basis + fsa_basis[n]
    for n in range(0,np.size(basis,axis=1)):
        basis[:,n] = basis[:,n] / np.power(np.vdot(basis[:,n],basis[:,n]),0.5)
    return basis
Example #9
0
V=30e-1
H.model_coef = np.array([V,1,1])
# H.model = np.array([[0,1]])
# H.model_coef = np.array([1])

k=[0]
H.gen(k)
H.sector.find_eig(k)

block_refs = pxp_syms.find_block_refs(k)
block_keys = dict()
for n in range(0,np.size(block_refs,axis=0)):
    block_keys[block_refs[n]] = n

neel=zm_state(2,1,pxp,1)
pol = ref_state(0,pxp)
all_ones = bin_state(np.append([0],np.ones(pxp.N-1)),pxp)

neel_trans = np.zeros(np.size(block_refs))
pol_trans = np.zeros(np.size(block_refs))
all_ones_trans = np.zeros(np.size(block_refs))

neel_trans[block_keys[neel.ref]] = 1
pol_trans[block_keys[pol.ref]] = 1
all_ones_trans[block_keys[all_ones.ref]] = 1

neel_trans_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors(k))),neel_trans)
pol_trans_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors(k))),pol_trans)
all_ones_trans_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors(k))),all_ones_trans)

t=np.arange(0,80,0.01)
Example #10
0
            if system.basis[n][m] != state_bits[m]:
                h = h + 1
        hamming_sectors[int(h)] = np.append(hamming_sectors[int(h)],
                                            system.basis_refs[n])
    return hamming_sectors


#init small hypercube
N = 6
pxp = unlocking_System([0], "periodic", 2, N)
pxp.gen_basis()
pxp_syms = model_sym_data(pxp, [translational(pxp)])

pxp_sub = unlocking_System([0, 1], "open", 2, int(N / 2))
pxp_sub.gen_basis()
z = ref_state(np.max(pxp_sub.basis_refs), pxp_sub)
hamming_sub = find_hamming_sectors(z.bits, pxp_sub)

c1_bits = dict()
c2_bits = dict()

for n in range(0, len(hamming_sub) - 1):
    c1_bits[n] = np.zeros((np.size(hamming_sub[n]), pxp.N))
    c2_bits[n] = np.zeros((np.size(hamming_sub[n]), pxp.N))
    print("\n")
    for m in range(0, np.size(hamming_sub[n], axis=0)):
        bits = pxp_sub.basis[pxp_sub.keys[hamming_sub[n][m]]]
        for i in range(0, np.size(bits, axis=0)):
            c1_bits[n][m, 2 * i] = bits[i]
            c2_bits[n][m, 2 * i + 1] = bits[i]
    print(c1_bits[n])
# print(1,8)
# root_refs = find_root_refs(np.array([1,0]),np.array([1,8]),H,sector_refs,from_sector,pxp,refs_found)
# if np.size(root_refs)>0:
# temp = subcube_basis(root_refs,"Left",9)
# refs_found = np.sort(np.unique(np.append(refs_found,non_zero_ref_in_basis(temp))))
# basis = np.hstack((basis,temp))
# print(np.size(root_refs))

#neel cubes
L_cube_sectors = np.zeros((int(pxp.N / 2) + 1, 2))
R_cube_sectors = np.zeros((int(pxp.N / 2) + 1, 2))
for n in range(0, int(pxp.N / 2) + 1):
    L_cube_sectors[n, 0] = int(pxp.N / 2) - n
    R_cube_sectors[n, 1] = int(pxp.N / 2) - n

L_cube_basis = ref_state(sector_refs[perm_key(L_cube_sectors[0], pxp)][0],
                         pxp).prod_basis()
R_cube_basis = ref_state(sector_refs[perm_key(R_cube_sectors[0], pxp)][0],
                         pxp).prod_basis()
for n in range(1, np.size(L_cube_sectors, axis=0)):
    refsL = sector_refs[perm_key(L_cube_sectors[n], pxp)]
    refsR = sector_refs[perm_key(R_cube_sectors[n], pxp)]

    tempL = np.zeros(pxp.dim)
    tempR = np.zeros(pxp.dim)
    for m in range(0, np.size(refsL, axis=0)):
        tempL[pxp.keys[refsL[m]]] = 1
        tempR[pxp.keys[refsR[m]]] = 1
    # tempL = tempL / np.power(np.vdot(tempL,tempL),0.5)
    # tempR = tempR / np.power(np.vdot(tempR,tempR),0.5)
    L_cube_basis = np.vstack((L_cube_basis, tempL))
    R_cube_basis = np.vstack((R_cube_basis, tempR))
Example #12
0
rc('text', usetex=True)
# matplotlib.rcParams['figure.dpi'] = 400

#init system
N = 10
pxp = unlocking_System(
    [0, 1],
    "periodic",
    2,
    N,
)
pxp.gen_basis()
pxp_syms = model_sym_data(pxp, [translational(pxp)])

#create Hamiltonian
J = 0.7
h = 1.4
g = 1
H = Hamiltonian(pxp, pxp_syms)
H.site_ops[1] = np.array([[0, 1], [1, 0]])
H.site_ops[2] = np.array([[1, 0], [0, -1]])
H.model = np.array([[1, 1], [1], [2]])
H.model_coef = np.array([J, h, g])
H.gen()
H.sector.find_eig()
z = ref_state(0, pxp)
eig_overlap(z, H).plot()
plt.show()
fidelity(z, H).plot(np.arange(0, 20, 0.01), z)
plt.show()
Example #13
0
H.gen()

Hp = np.zeros((pxp.dim, pxp.dim))
for n in range(0, np.size(pxp.basis, axis=0)):
    bits = np.copy(pxp.basis[n])
    for m in range(0, pxp.N):
        if bits[m] == 2:
            new_bits = np.copy(bits)
            new_bits[m] = 0
            new_ref = bin_to_int_base_m(new_bits, pxp.base)
            Hp[pxp.keys[new_ref], n] += 2 * (-1)**m
Hm = np.conj(np.transpose(Hp))
Hx = 1 / 2 * (Hp + Hm)

#scarred eigenstates
psi = ref_state(0, pxp).prod_basis()
from Calculations import gen_fsa_basis
fsa_basis = gen_fsa_basis(Hm, psi, pxp.N)

H0 = Hamiltonian(pxp)
H0.site_ops[1] = x
H0.site_ops[2] = y
H0.site_ops[3] = z
H0.site_ops[4] = z2
H0.model = np.array([[1, 1], [2, 2]])
H0.model_coef = np.array([J, J])
H0.gen()

H1 = Hamiltonian(pxp)
H1.site_ops[1] = x
H1.site_ops[2] = y
Example #14
0
def join_states(psi1, psi2, M_basis_map, system, double_system):
    M_coef = np.zeros((system.dim, system.dim), dtype=complex)
    for n in range(0, system.dim):
        for m in range(0, system.dim):
            M_coef[n, m] = psi1[n] * psi2[m]
    new_state = half_rep_to_full(M_coef, M_basis_map, system, double_system)
    return new_state


# H_half = spin_Hamiltonian(pxp_half,"x",pxp_half_syms)
H_half = clock_Hamiltonian(pxp_half, pxp_half_syms)
H_half.gen()
# z_even = ref_state(np.max(pxp_half.basis_refs),pxp_half).prod_basis()
# z_odd = ref_state(0,pxp_half).prod_basis()

z_even = ref_state(np.max(pxp_half.basis_refs), pxp_half)
z_odd = ref_state(0, pxp_half)
z_even_prod = z_even.prod_basis()
z_odd_prod = z_odd.prod_basis()
print(z_even.bits)
print(z_odd.bits)

state_half_rep = np.zeros((pxp_half.dim, pxp_half.dim))
for n in range(0, np.size(state_half_rep, axis=0)):
    for m in range(0, np.size(state_half_rep, axis=0)):
        state_half_rep[n, m] = z_even_prod[n] * z_odd_prod[m]

#find Hp sublattice operators in sublattice H space from upper tridiagonal of krylov in sublattice H
even_krylov_basis = gen_krylov_basis(H_half.sector.matrix(),
                                     krylov_half_dim,
                                     z_even,
Example #15
0
V = 0.05

U0 = np.dot(
    H0.sector.eigvectors(),
    np.dot(np.diag(np.exp(-1j * tau * H0.sector.eigvalues())),
           np.conj(np.transpose(H0.sector.eigvectors()))))
U_kick = np.dot(
    H_kick.sector.eigvectors(),
    np.dot(np.diag(np.exp(-1j * V * H_kick.sector.eigvalues())),
           np.conj(np.transpose(H_kick.sector.eigvectors()))))

F = np.dot(U_kick, U0)
e, u = np.linalg.eig(F)

z = zm_state(2, 1, pxp)
z1 = ref_state(0, pxp)
z2 = ref_state(1, pxp)
no_steps = 500
f = np.zeros(no_steps)
f1 = np.zeros(no_steps)
f2 = np.zeros(no_steps)
current_state = z.prod_basis()
current_state1 = z1.prod_basis()
current_state2 = z2.prod_basis()
for n in range(0, no_steps):
    f[n] = np.abs(np.vdot(current_state, z.prod_basis()))**2
    f1[n] = np.abs(np.vdot(current_state1, z1.prod_basis()))**2
    f2[n] = np.abs(np.vdot(current_state2, z2.prod_basis()))**2
    current_state = np.dot(F, current_state)
    current_state1 = np.dot(F, current_state1)
    current_state2 = np.dot(F, current_state2)
for n in range(0, np.size(overlap, axis=0)):
    if overlap[n] < -10:
        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])
plt.scatter(eigenvalues, overlap)
plt.xlabel(r"$E$")
plt.ylabel(r"$\log(\vert \langle \psi \vert E \rangle \vert^2)$")
# plt.title(r"Ising + SU(2) perts, SU(2) Lowest weight overlap, $N=$"+str(pxp.N))
plt.title(r"Ising, SU(2) Lowest weight overlap, $N=$" + str(pxp.N))
plt.show()

t = np.arange(0, 20, 0.01)
f = np.zeros(np.size(t))
pol = ref_state(0, pxp)
pol_energy = np.conj(u[0, :])
f_pol = np.zeros(np.size(t))
f_hw = np.zeros(np.size(t))
psi_HW_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors())),
                       fsa_basis[:, np.size(fsa_basis, axis=1) - 1])
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(psi_energy, evolved_state))**2
    f_pol[n] = np.abs(np.vdot(pol_energy, evolved_state))**2
    f_hw[n] = np.abs(np.vdot(psi_HW_energy, evolved_state))**2
plt.plot(t, f, label=r"$\vert H_z, LW \rangle$")
plt.plot(t, f_pol, label=r"$\vert 000...\rangle$")
plt.plot(t, f_hw, label=r"$\vert H_z, HW \rangle$")
plt.legend()
plt.xlabel(r"$t$")
Example #17
0
            subcube_root_hamming_refsL[n][m][j] = temp_refL
            subcube_root_hamming_refsR[n][m][j] = temp_refR

subcube_root_hamming_basisL = dict()
subcube_root_hamming_basisR = dict()
for n in range(0, len(subcube_root_hamming_refsL)):
    subcube_root_hamming_basisL[n] = np.zeros(
        (pxp.dim, len(subcube_root_hamming_refsL[n])))
    subcube_root_hamming_basisR[n] = np.zeros(
        (pxp.dim, len(subcube_root_hamming_refsR[n])))
    for m in range(0, len(subcube_root_hamming_refsL[n])):
        tempL = np.zeros(pxp.dim)
        tempR = np.zeros(pxp.dim)
        for k in range(0, np.size(subcube_root_hamming_refsL[n][m], axis=0)):
            tempL = tempL + ref_state(subcube_root_hamming_refsL[n][m][k],
                                      pxp).prod_basis()
            tempR = tempR + ref_state(subcube_root_hamming_refsR[n][m][k],
                                      pxp).prod_basis()
        tempL = tempL / np.power(np.vdot(tempL, tempL), 0.5)
        tempR = tempR / np.power(np.vdot(tempR, tempR), 0.5)
        subcube_root_hamming_basisL[n][:, m] = tempL
        subcube_root_hamming_basisR[n][:, m] = tempR

subcube_combined_basisL = subcube_root_hamming_basisL[0]
subcube_combined_basisR = subcube_root_hamming_basisR[0]
for n in range(1, len(subcube_root_hamming_refsL)):
    subcube_combined_basisL = subcube_combined_basisL + subcube_root_hamming_basisL[
        n]
    subcube_combined_basisR = subcube_combined_basisR + subcube_root_hamming_basisR[
        n]
    d = np.size(temp)-1
    if d > int(N/2):
        d = N - d
    model_coef = np.append(model_coef,J/np.power(d,alpha))
    model.append(temp)
Hz = Hamiltonian(pxp,pxp_syms)
Hz.site_ops[1] = np.array([[-1,0],[0,1]])
Hz.model = model
Hz.model_coef = model_coef

Hx = Hamiltonian(pxp,pxp_syms)
Hx.site_ops[1] = np.array([[0,1],[1,0]])
Hx.model = np.array([[1]])
Hx.model_coef = np.array([-B])

k=[0]
z=ref_state(np.max(pxp.basis_refs),pxp)
Hz.gen(k)
Hx.gen(k)
H = H_operations.add(Hz,Hx,np.array([1,1]))
H.sector.find_eig(k)

overlap = eig_overlap(z,H,k).eval()
plt.scatter(H.sector.eigvalues(k),overlap)
plt.title(r"$H = -\sum_{i<j}^L \frac{J}{r_{ij}^\alpha} \sigma_i^z \sigma_{i+1}^z - B \sum_i \sigma_i^x$"+"\n"+r"$J=1$, $B=0.27$, $\alpha=2.3$, $k=0$, $N=$"+str(pxp.N))
plt.ylabel(r"$\log(\vert \langle 1111... \vert E \rangle \vert^2)$")
plt.xlabel(r"$E$")

plt.show()

Example #19
0
H.model = np.array([[0,1,0]])
H.model_coef=np.array((1))
H.gen()
H.sector.find_eig()
z_rydberg = zm_state(2,1,pxp)
f_neel_ham = fidelity(z_rydberg,H).eval(t,z_rydberg)
# plt.plot(t,f_neel_ham)
# plt.show()

H_diag = np.diag(np.exp(-1j*tau*H.sector.eigvalues()))
exp_H = np.dot(H.sector.eigvectors(),np.dot(np.diag(np.exp(-1j*tau*H.sector.eigvalues())),np.conj(np.transpose(H.sector.eigvectors()))))

#evaluate direct overlap of all states
states=dict()
for n in range(0,np.size(pxp_half.basis_refs,axis=0)):
    states[n] = ref_state(pxp_half.basis_refs[n],pxp)


pbar=ProgressBar()
f_ham=dict()
f_floquet=dict()
evolution_overlap=dict()
for state_index in pbar(range(0,len(states))):
    evolution_overlap[state_index] = np.zeros(np.size(t))
    # print(states[state_index].bits)
    original_state = states[state_index].prod_basis()
    current_state_ham = original_state
    current_state_floquet = original_state
    f_ham[state_index] = np.zeros(np.size(t))
    f_floquet[state_index] = np.zeros(np.size(t))
Example #20
0
        if target_sectorR in mapped_sectorsR:
            root_refsR[perm_key(root_sectorsR[n])] = np.append(
                root_refsR[perm_key(root_sectorsR[n])], refsR[m])
        else:
            non_root_refsR[perm_key(root_sectorsR[n])] = np.append(
                non_root_refsR[perm_key(root_sectorsR[n])], refsR[m])

non_root_basisL = np.zeros(pxp.dim)
non_root_basisR = np.zeros(pxp.dim)
for n in range(0, np.size(root_sectorsL, axis=0)):
    refsL = non_root_refsL[perm_key(root_sectorsL[n])]
    refsR = non_root_refsR[perm_key(root_sectorsR[n])]
    tempL = np.zeros(pxp.dim)
    tempR = np.zeros(pxp.dim)
    for m in range(0, np.size(refsL, axis=0)):
        tempL = tempL + ref_state(refsL[m], pxp).prod_basis()
        tempR = tempR + ref_state(refsR[m], pxp).prod_basis()
    if np.sum(np.abs(tempL)) > 1e-5:
        tempL = tempL / np.power(np.vdot(tempL, tempL), 0.5)
        non_root_basisL = np.vstack((non_root_basisL, tempL))
    if np.sum(np.abs(tempR)) > 1e-5:
        tempR = tempR / np.power(np.vdot(tempR, tempL), 0.5)
        non_root_basisR = np.vstack((non_root_basisR, tempL))
non_root_basisL = np.transpose(np.delete(non_root_basisL, 0, axis=0))
non_root_basisR = np.transpose(np.delete(non_root_basisR, 0, axis=0))

# form subcube basis stemming from root nodes
hamming_layer_refsL = dict()
hamming_layer_refsR = dict()
for n in range(0, np.size(root_sectorsL, axis=0)):
    print(root_sectorsR[n])
# H.gen(k[n])
# H.sector.find_eig(k[n])

# fidelity(z,H,"use sym").plot(np.arange(0,20,0.01),z)
fidelity(z, H).plot(np.arange(0, 20, 0.01), z)
plt.show()

states = dict()
states_energy = dict()
f = dict()
ent = entropy(pxp)
ent_vals = np.zeros(np.size(pxp.basis_refs))
pbar = ProgressBar()
print("Plotting fidelity/entropy")
for n in pbar(range(0, np.size(pxp.basis_refs, axis=0))):
    states[n] = ref_state(pxp.basis_refs[n], pxp)
    states_energy[n] = np.conj(u[pxp.keys[states[n].ref], :])
    f[n] = np.zeros(np.size(t))

    ent_vals[n] = ent.eval(u[:, n])
    for m in range(0, np.size(t, axis=0)):
        evolved_state = time_evolve_state(states_energy[n], e, t[m])
        f[n][m] = np.abs(np.vdot(states_energy[n], evolved_state))**2

    plt.plot(t, f[n], alpha=0.6)
plt.xlabel(r"$t$")
plt.ylabel(r"$\vert \langle n(0) \vert n(t) \rangle \vert^2$")
plt.title(
    r"Hypercube $H=\sum_i X_i$, with $P=$" + str(p) +
    " chance of removing state from $L/2-1, L/2, L/2+1$ hamming sector. Computational basis fidelities, $N=$"
    + str(pxp.N))
Example #22
0
    # linblads[j] = temp


def linblad(rho, H, P, coef):
    temp = -1j * com(H, rho)
    for n in range(0, len(linblads)):
        temp = temp + coef * (np.dot(linblads[n], np.dot(rho, linblads[n])) -
                              0.5 * np.dot(linblads[n], rho) -
                              0.5 * np.dot(rho, linblads[n]))
    return temp
    # return -1j * com(H,rho)+coef*(np.dot(P,np.dot(rho,P))-0.5*np.dot(P,rho)-0.5*np.dot(rho,P))


pbar = ProgressBar()
for index in pbar(range(0, np.size(pxp.basis_refs), 2)):
    z = ref_state(pxp.basis_refs[index], pxp)
    index = pxp.keys[z.ref]
    rho = np.zeros((pxp.dim, pxp.dim))
    rho[index, index] = 1

    #integrate linblad with runge kutta
    rho
    delta_t = 0.1
    t_max = 10
    t = np.arange(0, t_max + delta_t, delta_t)
    rho_t = dict()
    rho_t[0] = rho
    coef = 0.1
    f = np.zeros(np.size(t))
    f[0] = 1
    z_anti = zm_state(2, 1, pxp, 1)
    temp_basis = temp_basis + find_subcube_basis(roots[m],1,"Left")
for m in range(0,np.size(temp_basis,axis=1)):
    temp_basis[:,m] = temp_basis[:,m] / np.power(np.vdot(basis[:,m],basis[:,m]),0.5)
basis = np.hstack((basis,temp_basis))

roots = find_root_refs(np.array([2,0]),np.array([2,2]))
temp_basis = find_subcube_basis(roots[0],2,"Right")
for m in range(1,np.size(roots,axis=0)):
    temp_basis = temp_basis + find_subcube_basis(roots[m],2,"Right")
for m in range(0,np.size(temp_basis,axis=1)):
    temp_basis[:,m] = temp_basis[:,m] / np.power(np.vdot(basis[:,m],basis[:,m]),0.5)
basis = np.hstack((basis,temp_basis))

neel_subcube_system = unlocking_System([0,1],"open",2,int(pxp.N/2))
neel_subcube_system.gen_basis()
z=ref_state(np.max(neel_subcube_system.basis_refs),neel_subcube_system)
neel_hamming = find_hamming_sectors(z.bits,neel_subcube_system)

#hypercube from Neel/AntiNeel
z0=zm_state(2,1,pxp)
z1=zm_state(2,1,pxp,1)
cube_dim = int(pxp.N/2)
cube_basisL = np.zeros(pxp.dim)
cube_basisR = np.zeros(pxp.dim)
for n in range(0,len(neel_hamming)):
# for n in range(0,2):
    refs = neel_hamming[n]
    temp_stateL = np.zeros(pxp.dim)
    temp_stateR = np.zeros(pxp.dim)
    one_locL = np.arange(0,pxp.N-1,2)
    one_locR = np.arange(1,pxp.N,2)
Example #24
0
def perm_key(n,m):
    return bin_to_int_base_m([n,m],int(pxp.N/2)+1)
permsectors = dict()
for n in range(0,np.size(pxp.basis,axis=0)):
    bits = pxp.basis[n]
    aOcc = 0
    bOcc = 0
    for m in range(0,pxp.N):
        if bits[m] == 1:
            if m % 2 == 0:
                aOcc += 1
            else:
                bOcc += 1
    key = perm_key(aOcc,bOcc)
    if key in list(permsectors.keys()):
        permsectors[key] += ref_state(pxp.basis_refs[n],pxp).prod_basis()
    else:
        permsectors[key] = ref_state(pxp.basis_refs[n],pxp).prod_basis()

keys = list(permsectors.keys())
perm_basis = np.zeros((pxp.dim,np.size(keys)))
for n in range(0,np.size(keys,axis=0)):
    perm_basis[:,n] = permsectors[keys[n]] / np.power(np.vdot(permsectors[keys[n]],permsectors[keys[n]]),0.5)

# create Hamiltonian
H = spin_Hamiltonian(pxp,"x")
H.gen()
z=zm_state(2,1,pxp,1)
H.sector.find_eig()

H_perm = np.dot(np.conj(np.transpose(perm_basis)),np.dot(H.sector.matrix(),perm_basis))
Example #25
0
    def plot(state, H, k_vec=None, label=None):
        print("Plotting eigenstate overlap with given state...")
        if k_vec is None:  #no symmetry, use full basis
            z_ref = bin_to_int_base_m(state, H.system.base)
            z_index = find_index_bisection(z_ref, H.system.basis_refs)
            z_energy = H.sector.eigvectors()[z_index, :]
            eigenvalues = H.sector.eigvalues()
        else:  #symmetry used, just plot the given sym_block
            z_ref = bin_to_int_base_m(state, H.system.base)
            psi = ref_state(z_ref, H.system)
            z_mom = psi.sym_basis(k_vec, H.syms)
            # z_mom = z_mom * np.power(np.vdot(z_mom,z_mom),-0.5)
            z_energy = np.zeros(np.size(H.sector.eigvalues(k_vec)),
                                dtype=complex)
            for n in range(0, np.size(z_energy, axis=0)):
                z_energy[n] = np.vdot(z_mom, H.sector.eigvectors(k_vec)[:, n])
            eigenvalues = H.sector.eigvalues(k_vec)

        overlap = np.log10(np.abs(z_energy)**2)
        to_del = []
        for n in range(0, np.size(overlap, axis=0)):
            if overlap[n] < -10:
                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])

        if label is not None:
            fig = plt.figure()
            ax = fig.add_subplot(111)

        if k_vec is None:
            # plt.scatter(eigenvalues,overlap,alpha=0.6)
            from scipy.stats import gaussian_kde
            x = eigenvalues
            y = overlap
            plt.scatter(x, y)

            # Calculate the point density
            # xy = np.vstack([x,y])
            # z = gaussian_kde(xy)(xy)

            # # Sort the points by density, so that the densest points are plotted last
            # idx = z.argsort()
            # x, y, z = x[idx], y[idx], z[idx]

            # fig, ax = plt.subplots()
            # ax.scatter(x, y, c=z, s=50, edgecolor='')
        else:
            # plt.scatter(eigenvalues,overlap,label=str(k_vec)+r" $\pi /$"+str(H.system.N)+" Symmetry sector")
            plt.scatter(eigenvalues, overlap, color='blue')

        if label is not None:
            A = eigenvalues
            B = overlap
            for i, j in zip(A, B):
                # ax.annotate('%s)' %j, xy=(i,j), xytext=(30,0), textcoords='offset points')
                ax.annotate('(%s,' % i, xy=(i, j))

        plt.legend()
        plt.xlabel("E")
        plt.ylabel(r"$\vert \langle \psi_E \vert \psi \rangle \vert^2$")
        plt.title(str(H.system.base) + " Colour, N=" + str(H.system.N))
        plt.legend()
Example #26
0
        h = 0
        for m in range(0, pxp.N, 1):
            if pxp.basis[n][m] != state_bits[m]:
                h = h + 1
        hamming_sectors[int(h)] = np.append(hamming_sectors[int(h)],
                                            pxp.basis_refs[n])
    return hamming_sectors


#init small hypercube
pxp = unlocking_System([0, 1], "periodic", 2, 10)
pxp.gen_basis()

#form hamming rep starting from Neel
# z=zm_state(2,1,pxp)
z = ref_state(2, pxp)
hamming_sectors = find_hamming_sectors(z.bits)

for n in range(0, np.size(hamming_sectors[2])):
    print(pxp.basis[pxp.keys[hamming_sectors[2][n]]])

V = Hamiltonian(pxp)
V.site_ops[1] = np.array([[0, 0], [0, 1]])
V.model = np.array([[1]])
V.model_coef = np.array([1])
V.gen()

# H0 = spin_Hamiltonian(pxp,"x")
# H0.gen()