def fidelity_error(coef, pxp_config, pxxxp_config):
    Hp = gen_Hp(pxp_config, pxxxp_config, coef)
    Hm = np.conj(np.transpose(Hp))

    H = Hp + Hm
    e, u = np.linalg.eigh(H)
    z = zm_state(2, 1, pxp, 1)
    psi_energy = np.dot(np.conj(np.transpose(u)), z.prod_basis())

    t = np.arange(0, 10, 0.01)
    f = np.zeros(np.size(t))
    for n in range(0, np.size(t, axis=0)):
        f[n] = -fidelity_eval(psi_energy, e, t[n])
    # plt.plot(t,f)
    # plt.show()
    for n in range(0, np.size(f, axis=0)):
        if f[n] < 0.1:
            cut = n
            break
    f_max = np.max(f[cut:])

    res = minimize_scalar(lambda t: fidelity_eval(psi_energy, e, t),
                          method="golden",
                          bracket=(4.5, 5.5))
    f = -fidelity_eval(psi_energy, e, res.x)
    print(coef, f)
    # print(f)
    if res.x < 1e-5:
        return 1000
    else:
        return -f_max
def fidelity_error(coef, plot=False):
    coef = coef[0]
    H = H_operations.add(H0, V, np.array([1, coef]))
    H = H.sector.matrix()
    e, u = np.linalg.eigh(H)
    z = zm_state(4, 1, pxp)
    psi_energy = np.dot(np.conj(np.transpose(u)), z.prod_basis())

    if plot is True:
        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, e, t[n])
        plt.plot(t, f)
        plt.show()

    res = minimize_scalar(lambda t: fidelity_eval(psi_energy, e, t),
                          method="golden",
                          bracket=(4.5, 5.5))
    f = -fidelity_eval(psi_energy, e, res.x)
    print(coef, f)
    if res.x < 1e-5:
        return 1000
    else:
        return -f
Esempio n. 3
0
def fidelity_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(2, 1, pxp, 1)
    psi_energy = np.dot(np.conj(np.transpose(u)), z.prod_basis())

    t = np.arange(0, 10, 0.01)
    f = np.zeros(np.size(t))
    for n in range(0, np.size(t, axis=0)):
        f[n] = -fidelity_eval(psi_energy, e, t[n])
    # plt.plot(t,f)
    # plt.show()
    for n in range(0, np.size(f, axis=0)):
        if f[n] < 0.1:
            cut = n
            break
    f_max = np.max(f[cut:])

    res = minimize_scalar(lambda t: fidelity_eval(psi_energy, e, t),
                          method="golden",
                          bracket=(4.5, 5.5))
    f = -fidelity_eval(psi_energy, e, res.x)
    print(coef, f)
    # print(f)
    if res.x < 1e-5:
        return 1000
    else:
        return -f_max
Esempio n. 4
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
Esempio n. 5
0
def fidelity_erorr(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()

    z=zm_state(3,1,pxp)
    psi_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors())),z.prod_basis())

    t=np.arange(0,6,0.001)
    f=np.zeros(np.size(t))
    for n in range(0,np.size(t,axis=0)):
        evolved_state = time_evolve_state(psi_energy,H.sector.eigvalues(),t[n])
        f[n] = np.abs(np.vdot(evolved_state,psi_energy))**2
    for n in range(0,np.size(f,axis=0)):
        if f[n] < 0.1:
            cut = n
            break
    f0 = np.max(f[cut:])
    # 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.5))
    # f0 = fidelity_eval(psi_energy,H.sector.eigvalues(),res.x)
    return 1-f0
Esempio n. 6
0
def subspace_variance(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()

    z=zm_state(3,1,pxp)
    from Calculations import gen_fsa_basis
    fsa_dim = int(2*pxp.N/3)
    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)):
        # for m in range(0,np.size(fsa_basis,axis=1)):
            # temp = np.abs(np.vdot(fsa_basis[:,n],fsa_basis[:,m]))
            # if temp > 1e-5:
                # print(temp,n,m)
    fsa_basis,temp = np.linalg.qr(fsa_basis)

    H2 = np.dot(H.sector.matrix(),H.sector.matrix())
    H2_fsa = np.dot(np.conj(np.transpose(fsa_basis)),np.dot(H2,fsa_basis))
    H_fsa = np.dot(np.conj(np.transpose(fsa_basis)),np.dot(H.sector.matrix(),fsa_basis))
    subspace_variance = np.real(np.trace(H2_fsa-np.dot(H_fsa,H_fsa)))
    return subspace_variance
Esempio n. 7
0
def var_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
    Hz = 1 / 2 * com(Hp_total.sector.matrix(), Hm)
    z = zm_state(2, 1, pxp, 1)
    fsa_basis = z.prod_basis()
    current_state = fsa_basis
    for n in range(0, pxp.N):
        next_state = np.dot(Hp_total.sector.matrix(), 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)
    Hz_var = np.zeros(np.size(fsa_basis, axis=1))
    for n in range(0, np.size(Hz_var, axis=0)):
        Hz_var[n] = var(Hz, fsa_basis[:, n])
    error = np.max(Hz_var)
    print(coef, error)
    return error
Esempio n. 8
0
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 = Hp_total.herm_conj()
    Hz = 1 / 2 * com(Hp_total.sector.matrix(), Hm.sector.matrix())

    z = zm_state(2, 1, pxp, 1)
    from Calculations import gen_fsa_basis
    fsa_basis = gen_fsa_basis(Hp_total.sector.matrix(), z.prod_basis(), pxp.N)

    exp_vals = np.zeros(np.size(fsa_basis, axis=1))
    for n in range(0, np.size(exp_vals, axis=0)):
        exp_vals[n] = np.real(exp(Hz, fsa_basis[:, n]))
    exp_diff = np.zeros(np.size(exp_vals) - 1)
    for n in range(0, np.size(exp_diff, axis=0)):
        exp_diff[n] = exp_vals[n + 1] - exp_vals[n]

    M = np.zeros((np.size(exp_diff), np.size(exp_diff)))
    for n in range(0, np.size(M, axis=0)):
        for m in range(0, np.size(M, axis=1)):
            M[n, m] = np.abs(exp_diff[n] - exp_diff[m])
    error = np.power(np.trace(np.dot(M, np.conj(np.transpose(M)))), 0.5)
    return error
Esempio n. 9
0
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()))

    Hp0 = Hp_total.sector.matrix()
    Hm0 = np.conj(np.transpose(Hp0))

    Hz = 1 / 2 * com(Hp0, Hm0)

    #find lowest weight state
    e, u = np.linalg.eigh(Hz)
    lowest_weight = u[:, 0]

    z = zm_state(2, 1, pxp, 1)
    fsa_basis = z.prod_basis()
    current_state = fsa_basis
    fsa_dim = pxp.N
    for n in range(0, fsa_dim):
        next_state = np.dot(Hp0, current_state)
        if np.abs(np.vdot(next_state, next_state)) > 1e-5:
            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
        else:
            break
    fsa_basis = np.transpose(fsa_basis)

    if np.size(np.shape(fsa_basis)) == 2:
        Hz_exp = np.zeros(np.size(fsa_basis, axis=1))
        for n in range(0, np.size(Hz_exp, axis=0)):
            Hz_exp[n] = exp(Hz, fsa_basis[:, n])

        Hz_diff = np.zeros(np.size(Hz_exp) - 1)
        for n in range(0, np.size(Hz_diff, axis=0)):
            Hz_diff[n] = np.abs(Hz_exp[n + 1] - Hz_exp[n])

        #spacing error
        error_matrix = np.zeros((np.size(Hz_diff), np.size(Hz_diff)))
        for n in range(0, np.size(Hz_diff, axis=0)):
            for m in range(0, np.size(Hz_diff, axis=0)):
                error_matrix[n, m] = np.abs(Hz_diff[n] - Hz_diff[m])
        error = np.power(
            np.trace(np.dot(error_matrix,
                            np.conj(np.transpose(error_matrix)))), 0.5)
        print(coef, error)
        return error
    else:
        return 1000
Esempio n. 10
0
def fidelity_erorr(coef):
    coef = coef[0]
    Hp_total = deepcopy(Hp[0])
    Hp_total = H_operations.add(Hp_total,Hp[1],np.array([1,coef]))
    Hm = Hp_total.herm_conj()

    H = H_operations.add(Hp_total,Hm,np.array([1,1]))
    H.sector.find_eig()
    z=zm_state(2,2,pxp,1)

    psi_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors())),z.prod_basis())


    res = minimize_scalar(lambda t: -fidelity_eval(psi_energy,H.sector.eigvalues(),t),method="golden",bracket=(4.5,5.5))
    f0 = fidelity_eval(psi_energy,H.sector.eigvalues(),res.x)
    print(coef,f0)
    return 1-f0
Esempio n. 11
0
def max_variance(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()
    Hz = 1 / 2 * com(Hp_total.sector.matrix(), Hm.sector.matrix())

    z = zm_state(2, 1, pxp, 1)
    from Calculations import gen_fsa_basis
    fsa_basis = gen_fsa_basis(Hp_total.sector.matrix(), z.prod_basis(), pxp.N)

    var_vals = np.zeros(np.size(fsa_basis, axis=1))
    for n in range(0, np.size(var_vals, axis=0)):
        var_vals[n] = np.real(var(Hz, fsa_basis[:, n]))
    error = np.max(var_vals)
    return error
Esempio n. 12
0
def fidelity_erorr(coef):
    coef = coef[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)

    z = zm_state(2, 1, pxp, 1)
    block_refs = pxp_syms.find_block_refs(k)
    psi = np.zeros(np.size(block_refs))
    loc = find_index_bisection(z.ref, block_refs)
    psi[loc] = 1
    psi_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors(k))), psi)

    t = np.arange(0, 20, 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, H.sector.eigvalues(k),
                                          t[n])
        f[n] = np.abs(np.vdot(evolved_state, psi_energy))**2
    for n in range(0, np.size(f, axis=0)):
        if f[n] < 0.1:
            cut = n
            break
    f0 = np.max(f[cut:])
    plt.scatter(H.sector.eigvalues(k), np.log10(np.abs(psi_energy)**2))
    plt.title(r"$PCP+\lambda(PPCP+PCPP), N=$" + str(pxp.N))
    plt.xlabel(r"$E$")
    plt.ylabel(r"$\log(\vert \langle \psi \vert E \rangle \vert^2)$")
    plt.show()
    plt.plot(t, f)
    plt.title(r"$PCP+\lambda(PPCP+PCPP), N=$" + str(pxp.N))
    plt.xlabel(r"$t$")
    plt.ylabel(r"$\vert \langle \psi(0) \vert \psi(t) \rangle \vert^2$")
    plt.show()
    return 1 - f0
def var_error(coef, pxp_config, pxxxp_config):
    Hp = gen_Hp(pxp_config, pxxxp_config, coef)
    Hm = np.conj(np.transpose(Hp))

    H = Hp + Hm
    Hz = 1 / 2 * com(Hp, Hm)
    z = zm_state(2, 1, pxp, 1)
    fsa_basis = gen_fsa_basis(Hp, z.prod_basis(), pxp.N)
    gs = gram_schmidt(fsa_basis)
    gs.ortho()
    fsa_basis = gs.ortho_basis
    Hz_var = np.zeros(np.size(fsa_basis, axis=1))
    for n in range(0, np.size(Hz_var, axis=0)):
        Hz_var[n] = var(Hz, fsa_basis[:, n])
    # error = np.max(Hz_var)
    error = np.sum(Hz_var)
    print(coef, error)
    return error
Esempio n. 14
0
def subspace_variance(coef):
    coef = coef[0]
    Hp_total = deepcopy(Hp[0])
    Hp_total = H_operations.add(Hp_total,Hp[1],np.array([1,coef]))
    Hm = Hp_total.herm_conj()

    H = H_operations.add(Hp_total,Hm,np.array([1,1]))
    H.sector.find_eig()

    z=zm_state(2,2,pxp,1)
    from Calculations import gen_fsa_basis
    fsa_dim = 2*pxp.N
    fsa_basis = gen_fsa_basis(Hp_total.sector.matrix(),z.prod_basis(),fsa_dim)

    H2 = np.dot(H.sector.matrix(),H.sector.matrix())
    H2_fsa = np.dot(np.conj(np.transpose(fsa_basis)),np.dot(H2,fsa_basis))
    H_fsa = np.dot(np.conj(np.transpose(fsa_basis)),np.dot(H.sector.matrix(),fsa_basis))
    subspace_variance = np.real(np.trace(H2_fsa-np.dot(H_fsa,H_fsa)))
    return subspace_variance
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
Esempio n. 16
0
def opt_fidelity(coef, plot=False):
    H = H0.sector.matrix() + coef[0] * V1 + coef[1] * V2 + coef[2] * V3
    # H = H0.sector.matrix()+coef[0]*V3
    e, u = np.linalg.eigh(H)
    psi = zm_state(3, 1, pxp)
    psi_energy = np.conj(u[pxp.keys[psi.ref], :])
    res = minimize_scalar(lambda t: fidelity_eval(psi_energy, e, t),
                          method="golden",
                          bracket=(2.5, 3.5))
    f_max = fidelity_eval(psi_energy, e, res.x)
    print(coef, -f_max, res.x)
    if plot is True:
        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, e, t[n])
        # plt.plot(t,f,label="$H_0+\lambda_i V_i$")
        # plt.show()
    # if np.abs(res.x) < 1e-5:
    # f_max = 0
    return f
Esempio n. 17
0
def fidelity_erorr(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()
    Hz = 1 / 2 * com(Hp_total.sector.matrix(), Hm.sector.matrix())
    e, u = np.linalg.eigh(Hz)
    psi = u[:, 0]
    psi = zm_state(4, 1, pxp).prod_basis()

    H = H_operations.add(Hp_total, Hm, np.array([1, 1]))
    H.sector.find_eig()

    psi_energy = np.dot(np.conj(np.transpose(H.sector.eigvectors())), psi)

    t = np.arange(0, 6, 0.001)
    # t=np.arange(0,20,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, H.sector.eigvalues(),
                                          t[n])
        f[n] = np.abs(np.vdot(evolved_state, psi_energy))**2
    for n in range(0, np.size(f, axis=0)):
        if f[n] < 0.1:
            cut = n
            break
    f0 = np.max(f[cut:])
    print(coef, f0)
    np.save("pxxxp,1stOrder,coef," + str(pxp.N), coef)
    # 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.5))
    # f0 = fidelity_eval(psi_energy,H.sector.eigvalues(),res.x)
    if (np.abs(coef) > 0.5).any():
        return 1000
    else:
        return 1 - f0
def krylov_su2_coupling_error(coef):
    coef = coef[0]
    H = H_operations.add(H0,V,np.array([1,coef]))

    z=zm_state(2,1,pxp)
    krylov_basis = gen_krylov_basis(H.sector.matrix(),pxp.N,z.prod_basis(),pxp,orth="qr")
    H_krylov = np.dot(np.conj(np.transpose(krylov_basis)),np.dot(H.sector.matrix(),krylov_basis))
    couplings = np.diag(H_krylov,1)

    s = pxp.N/4
    m = np.arange(-s,s)
    su2_couplings_half = np.power(s*(s+1)-m*(m+1),0.5)

    s = pxp.N/2
    m = np.arange(-s,s)
    su2_couplings_full = np.power(s*(s+1)-m*(m+1),0.5)

    coupling_diff_full = couplings - su2_couplings_full
    error = np.power(np.abs(np.vdot(coupling_diff_full,coupling_diff_full)),0.5)
    # error = np.abs(couplings[3] - su2_couplings_half[3])
    print(coef,error)
    return error
Esempio n. 19
0
def cost(alpha):
    H=Hamiltonian(pxp_half,"x")
    H.site_ops[1] = np.array([[0,alpha[0]],[alpha[0],0]])
    H.model = np.array([[1]])
    H.model_coef=np.array((1))
    H.gen()
    H.sector.find_eig()
    z_rydberg = zm_state(2,1,pxp_half)
    f_neel_ham = fidelity(z_rydberg,H).eval(t,z_rydberg)
    # plt.plot(t,f_neel_ham)
    # plt.show()

    cut_index = 5
    for n in range(0,np.size(f_neel_ham,axis=0)):
        if f_neel_ham[n]<0.1:
            cut_index = n
            break
    max_index = np.argmax(f_neel_ham[cut_index:])
    t0_ham = t[max_index]

    print(cost,t0_ham)
    return np.abs(t0_ham-t0_floquet)
def fidelity_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())

    res = minimize_scalar(lambda t: fidelity_eval(psi_energy, e, t),
                          method="golden",
                          bracket=(2.5, 3.5))
    f = -fidelity_eval(psi_energy, e, res.x)
    print(coef, f)
    # print(f)
    if res.x < 1e-5:
        return 1000
    if (np.abs(coef) > 0.5).any():
        return 1000
    return -f
def spacing_error(coef, pxp_config, pxxxp_config):
    Hp = gen_Hp(pxp_config, pxp_config, coef)
    Hm = np.conj(np.transpose(Hp))

    Hz = 1 / 2 * com(Hp, Hm)

    #find lowest weight state
    e, u = np.linalg.eigh(Hz)
    lowest_weight = u[:, 0]

    z = zm_state(2, 1, pxp, 1)
    fsa_basis = gen_fsa_basis(Hp, z.prod_basis(), pxp.N)
    gs = gram_schmidt(fsa_basis)
    gs.ortho()
    fsa_basis = gs.ortho_basis

    if np.size(np.shape(fsa_basis)) == 2:
        Hz_exp = np.zeros(np.size(fsa_basis, axis=1))
        for n in range(0, np.size(Hz_exp, axis=0)):
            Hz_exp[n] = exp(Hz, fsa_basis[:, n])

        Hz_diff = np.zeros(np.size(Hz_exp) - 1)
        for n in range(0, np.size(Hz_diff, axis=0)):
            Hz_diff[n] = np.abs(Hz_exp[n + 1] - Hz_exp[n])

        #spacing error
        error_matrix = np.zeros((np.size(Hz_diff), np.size(Hz_diff)))
        for n in range(0, np.size(error_matrix, axis=0)):
            for m in range(0, np.size(error_matrix, axis=0)):
                error_matrix[n, m] = np.abs(Hz_diff[n] - Hz_diff[m])
        error = np.power(
            np.trace(np.dot(error_matrix,
                            np.conj(np.transpose(error_matrix)))), 0.5)
        print(coef, error)
        return error
    else:
        return 1000
Esempio n. 22
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()
Esempio n. 23
0
# plt.scatter(pxp.keys[z.ref],ref_non_zero_sectors[pxp.keys[z.ref]],marker="s",s=50,label="z2")
# z=zm_state(3,1,pxp)
# plt.scatter(pxp.keys[z.ref],ref_non_zero_sectors[pxp.keys[z.ref]],marker="s",s=50,label="z3")
# z=zm_state(3,1,pxp,1)
# plt.scatter(pxp.keys[z.ref],ref_non_zero_sectors[pxp.keys[z.ref]],marker="s",s=50,label="z3")
# z=zm_state(3,1,pxp,2)
# plt.scatter(pxp.keys[z.ref],ref_non_zero_sectors[pxp.keys[z.ref]],marker="s",s=50,label="z3")
# plt.legend()
# plt.plot(ref_non_zero_sectors)
# plt.xlabel("State label")
# plt.ylabel("No. of non zero Hamming sectors")
# plt.title("Non zero Hamming sectors from computational basis states, PXP, N="+str(pxp.N))
# plt.show()

# z=ref_state(0,pxp)
z = zm_state(2, 1, pxp)
hamming_sectors = find_hamming_sectors(z.bits)

# H = Hamiltonian(pxp,pxp_syms)
# H.site_ops[1] = np.array([[0,1],[1,0]])
# H.model = np.array([[0,1,0],[0,0,1,0],[0,1,0,0]])
# # H.model = np.array([[0,1,0],[0,1,1,1,0]])
# coef = 1/8
# H.model_coef = np.array((1,coef,coef))
# H.model_coef = np.array((1,coef))

H = spin_Hamiltonian(pxp, "x", pxp_syms)
H.gen()


def get_state_connections(state_ref, h_sector, H_matrix):
Esempio n. 24
0
Lm_pert.uc_pos = np.array([0, 1, 1, 0])

# Ip.gen()
# Im.gen()
# Kp.gen()
# Km.gen()
# Lp.gen()
# Lm.gen()
# Ip_pert.gen()
# Im_pert.gen()
# Kp_pert.gen()
# Km_pert.gen()
# Lp_pert.gen()
# Lm_pert.gen()

z = zm_state(2, 1, pxp)
# k=pxp_syms.find_k_ref(z.ref)
k = [0, 0]
Ip.gen(k)
Im.gen(k)
Kp.gen(k)
Km.gen(k)
Lp.gen(k)
Lm.gen(k)
Ip_pert.gen(k)
Im_pert.gen(k)
Kp_pert.gen(k)
Km_pert.gen(k)
Lp_pert.gen(k)
Lm_pert.gen(k)
Esempio n. 25
0
    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)
    rho_anti = np.zeros((pxp.dim, pxp.dim))
    index = pxp.keys[z_anti.ref]
    rho_anti[index, index] = 1

    for n in range(1, np.size(t, axis=0)):
        k1 = delta_t * linblad(rho_t[n - 1], H.sector.matrix(), P, coef)
        k2 = delta_t * (linblad(rho_t[n - 1] + k1 / 2, H.sector.matrix(), P,
                                coef))
        k3 = delta_t * (linblad(rho_t[n - 1] + k2 / 2, H.sector.matrix(), P,
                                coef))
        k4 = delta_t * (linblad(rho_t[n - 1] + k3, H.sector.matrix(), P, coef))
        rho_t[n] = rho_t[n - 1] + 1 / 6 * (k1 + 2 * k2 + 2 * k3 + k4)
        f[n] = np.real(
            np.trace(np.dot(np.conj(np.transpose(rho_t[n])), rho_t[0])))
    plt.plot(t, f)
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)
    for m in range(0,np.size(refs,axis=0)):
        state_bits = neel_subcube_system.basis[neel_subcube_system.keys[refs[m]]]
        temp_bitsL = np.zeros(pxp.N)
        temp_bitsR = np.zeros(pxp.N)
Esempio n. 27
0
Hm = np.conj(np.transpose(Hp))


def com(a, b):
    return np.dot(a, b) - np.dot(b, a)


Hz = 1 / 2 * com(Hp, Hm)
# plt.matshow(np.abs(Hz))
# plt.show()
# print((np.abs(Hz-np.conj(np.transpose(Hz)))<1e-5).all())
H = spin_Hamiltonian(pxp, "x", pxp_syms)
H.gen()

z = zm_state(3, 1, pxp, 2)
k = pxp_syms.find_k_ref(z.ref)
U = dict()
for n in range(0, np.size(k, axis=0)):
    U[n] = pxp_syms.basis_transformation(k[n])

fsa_basis = z.prod_basis()
fsa_basis2 = z.prod_basis()
krylov_basis = z.prod_basis()
current_state = fsa_basis
current_state2 = fsa_basis
current_stateK = fsa_basis
fsa_dim = int(2 * N / 3)
for n in range(0, fsa_dim):
    next_state = np.dot(Hp, current_state)
    next_state2 = np.dot(Hp2, current_state2)
Esempio n. 28
0
H.model = np.array([[2,1,2],[2,1,3],[3,1,2]])
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)
Esempio n. 29
0
from Construction_functions import bin_to_int_base_m, int_to_bin_base_m, cycle_bits_state
from Search_functions import find_index_bisection
from State_Classes import zm_state, sym_state, prod_state, bin_state, ref_state
from rw_functions import save_obj, load_obj
from Calculations import level_stats, fidelity, eig_overlap, entropy, site_precession, site_projection, time_evolve_state
import math

N = 18
D = 2
d = 2

#convert MPS -> wf array
pxp = unlocking_System([0], "periodic", d, N)
pxp.gen_basis()
pxp_syms = model_sym_data(pxp, [translational_general(pxp, order=3)])
z = zm_state(3, 1, pxp)
k = pxp_syms.find_k_ref(z.ref)
U = dict()
for n in range(0, np.size(k, axis=0)):
    U[int(k[n])] = pxp_syms.basis_transformation(k[n])

wf = np.load("./z3,entangled_MPS_coef," + str(pxp.N) + ".npy")

#project wf to symmetry basis
wf_sym = dict()
for n in range(0, np.size(k, axis=0)):
    wf_sym[int(k[n])] = np.dot(np.conj(np.transpose(U[int(k[n])])), wf)

# dynamics + fidelity
V1_ops = dict()
V1_ops[0] = Hamiltonian(pxp, pxp_syms)
Esempio n. 30
0
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
# matplotlib.rcParams['figure.dpi'] = 400

N=20
pxp = unlocking_System([0],"periodic",2,N)
pxp.gen_basis()
pxp_syms = model_sym_data(pxp,[translational(pxp)])

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

z=zm_state(4,1,pxp)
z1=zm_state(4,1,pxp,1)
z2=zm_state(4,1,pxp,2)
z3=zm_state(4,1,pxp,3)

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.show()

t=np.arange(0,20,0.01)
f0 = fidelity(z,H,"use sym").eval(t,z)
f1 = fidelity(z,H,"use sym").eval(t,z1)
f2 = fidelity(z,H,"use sym").eval(t,z2)