def xx_2site(self): pxp = unlocking_System(np.arange(0, self.base), "open", self.base, 2) pxp.gen_basis() H = Hamiltonian(pxp) H.site_ops[1] = np.array([[0, 1], [1, 0]]) H.model = np.array([[1, 1]]) H.model_coef = np.array([[1]]) H.gen() H.sector.find_eig() return H
def pxp_3site(self, Nc): pxp = unlocking_System(np.arange(0, self.base), "open", self.base, 3) pxp.gen_basis() X = spin_Hamiltonian(pxp, "x").site_ops[1] H = Hamiltonian(pxp) H.site_ops[1] = X H.model = np.array([[0, 1, 0]]) H.model_coef = np.array([[1]]) H.gen() H.sector.find_eig() return H
def HpFromKey(key): Hp = Hamiltonian(pxp) Hp.site_ops[1] = np.array([[0, 0], [1, 0]]) Hp.site_ops[2] = np.array([[0, 1], [0, 0]]) model = [] for m in range(0, np.size(key, axis=0)): if key[m] == 1: model.append([0, 1, 0]) else: model.append([0, 2, 0]) Hp.model = model Hp.model_coef = np.ones(pxp.N) Hp.uc_size = pxp.N * np.ones(pxp.N) Hp.uc_pos = np.arange(0, pxp.N) Hp.gen() return Hp
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 var(Q, psi): Q2 = np.dot(Q, Q) return exp(Q2, psi) - exp(Q, psi)**2 N = 10 pxp = unlocking_System([0], "periodic", 3, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational_general(pxp, order=2), PT(pxp)]) #orig H Ip = Hamiltonian(pxp, pxp_syms) Ip.site_ops[1] = np.array([[0, 1, 0], [0, 0, 0], [0, 0, 0]]) Ip.site_ops[2] = np.array([[0, 0, 0], [1, 0, 0], [0, 0, 0]]) Ip.model = np.array([[0, 1, 0], [0, 2, 0]]) Ip.model_coef = np.array([1, -1]) Ip.uc_size = np.array([2, 2]) Ip.uc_pos = np.array([1, 0]) Im = Hamiltonian(pxp, pxp_syms) Im.site_ops[1] = np.array([[0, 1, 0], [0, 0, 0], [0, 0, 0]]) Im.site_ops[2] = np.array([[0, 0, 0], [1, 0, 0], [0, 0, 0]]) Im.model = np.array([[0, 2, 0], [0, 1, 0]]) Im.model_coef = np.array([1, -1]) Im.uc_size = np.array([2, 2]) Im.uc_pos = np.array([1, 0]) Kp = Hamiltonian(pxp, pxp_syms) Kp.site_ops[1] = np.array([[0, 0, 1], [0, 0, 0], [0, 0, 0]]) Kp.site_ops[2] = np.array([[0, 0, 0], [0, 0, 0], [1, 0, 0]])
}) ## for Palatino and other serif fonts use: #rc('font',**{'family':'serif','serif':['Palatino']}) rc('text', usetex=True) # matplotlib.rcParams['figure.dpi'] = 400 N = 16 pxp = unlocking_System([0], "periodic", 2, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)]) Hp = dict() Hp[0] = Hamiltonian(pxp) Hp[0].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[0].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[0].model = np.array([[0, 1, 0], [0, 2, 0]]) Hp[0].model_coef = np.array([1, 1]) Hp[0].uc_size = np.array([2, 2]) Hp[0].uc_pos = np.array([1, 0]) #1st order pert Hp[1] = Hamiltonian(pxp) Hp[1].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[1].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[1].model = np.array([[0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 2, 0], [0, 2, 0, 0]]) Hp[1].model_coef = np.array([1, 1, 1, 1]) Hp[1].uc_size = np.array([2, 2, 2, 2]) Hp[1].uc_pos = np.array([0, 1, 1, 0]) #2nd order perts
def var(Q, psi): Q2 = np.dot(Q, Q) return exp(Q2, psi) - exp(Q, psi)**2 N = 14 pxp = unlocking_System([0, 1], "periodic", 2, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational(pxp)]) Hp = dict() Hp[0] = Hamiltonian(pxp, pxp_syms) Hp[0].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[0].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[0].model = np.array([[0, 1, 2, 0]]) Hp[0].model_coef = np.array([1]) Hp[1] = Hamiltonian(pxp, pxp_syms) Hp[1].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[1].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[1].model = np.array([[0, 1, 2, 0, 0], [0, 0, 1, 2, 0]]) Hp[1].model_coef = np.array([1, 1]) 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])
z = zm_state(2, 1, pxp) Neel_state_spin_basis = np.zeros(np.size(pxp.basis_refs)) Neel_state_spin_basis[pxp.keys[z.ref]] = 1 Neel_state_clock_basis = np.dot(spin2clock_u, Neel_state_spin_basis) z = zm_state(2, 1, pxp) Neel_state_clock_basis = np.zeros(np.size(pxp.basis_refs)) Neel_state_clock_basis[pxp.keys[z.ref]] = 1 Neel_state_spin_basis = np.dot(clock2spin_u, Neel_state_clock_basis) print(Neel_state_spin_basis) H = Hamiltonian(pxp, pxp_syms) H.site_ops[2] = P_spin_clock_basis H.site_ops[1] = H1.site_ops[1] H.model = np.array(([[2, 1, 2]])) H.model_coef = np.array((1)) H.gen() H.sector.find_eig() print(H.sector.eigvalues()) # eig_overlap.plot(z.bits,H) # plt.show() # fidelity.plot(z.bits,np.arange(0,20,0.01),H) # plt.show() H_clock = Hamiltonian(pxp, pxp_syms) H_clock.site_ops[2] = P H_clock.site_ops[1] = H2.site_ops[1] H_clock.model = np.array([[2, 1, 2]]) H_clock.model_coef = np.array((1))
def var(Q,psi): Q2 = np.dot(Q,Q) return exp(Q2,psi)-exp(Q,psi)**2 #init system N=20 pxp = unlocking_System([0],"periodic",2,N) pxp.gen_basis() pxp_syms = model_sym_data(pxp,[translational_general(pxp,order=4),PT(pxp)]) Hp = dict() Hp[0] = Hamiltonian(pxp,pxp_syms) Hp[0].site_ops[1] = np.array([[0,0],[1,0]]) Hp[0].site_ops[2] = np.array([[0,1],[0,0]]) Hp[0].model = np.array([[0,1,2,1,0],[0,1,2,1,0],[0,2,1,2,0],[0,1,2,1,0]]) Hp[0].model_coef = np.array([1,1,1,1]) Hp[0].uc_size = np.array([4,4,4,4]) Hp[0].uc_pos = np.array([2,3,0,1]) # Hp[1] = Hamiltonian(pxp,pxp_syms) # Hp[1].site_ops[1] = np.array([[0,0],[1,0]]) # Hp[1].site_ops[2] = np.array([[0,1],[0,0]]) # Hp[1].site_ops[4] = np.array([[0,0],[0,1]]) # Hp[1].model = np.array([[0,1,2,1,0,4,0],[0,1,2,1,0,4,0],[0,4,0,1,2,1,0],[0,4,0,1,2,1,0]]) # Hp[1].model_coef = np.array([1,1,1,1]) # Hp[1].uc_size = np.array([4,4,4,4]) # Hp[1].uc_pos = np.array([1,3,3,1]) # Hp[2] = Hamiltonian(pxp,pxp_syms) # Hp[2].site_ops[1] = np.array([[0,0],[1,0]])
Jm = np.diag(couplings, -1) x = 1 / 2 * (Jp + Jm) y = 1 / 2j * (Jp - Jm) z = 1 / 2 * com(Jp, Jm) z2 = np.dot(z, z) #create Hamiltonian J = 1 h = 0.1 D = 0.1 H = Hamiltonian(pxp) H.site_ops[1] = x H.site_ops[2] = y H.site_ops[3] = z H.site_ops[4] = z2 H.model = np.array([[1, 1], [2, 2], [3], [4]]) H.model_coef = np.array([J, J, h, D]) 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)
z = zm_state(2, 1, pxp) # z=zm_state(3,1,pxp) # z=ref_state(1,pxp) hamming_sectors = find_hamming_sectors(z.bits) hamming_length = 0 for n in range(0, len(hamming_sectors)): if np.size(hamming_sectors[n]) != 0: hamming_length = hamming_length + 1 # H=spin_Hamiltonian(pxp,"x") # H.gen() V = Hamiltonian(pxp) V.site_ops[1] = np.array([[0, 0], [0, 1]]) V.model = np.array([[1, 1]]) V.model_coef = np.array([1]) V.gen() removed_count = np.zeros(len(hamming_sectors)) for n in range(0, len(hamming_sectors)): c = 0 for m in range(0, np.size(hamming_sectors[n], axis=0)): ref = hamming_sectors[n][m] index = pxp.keys[ref] if V.sector.matrix()[index, index] != 0: c = c + 1 # c=c+V.sector.matrix()[index,index] removed_count[n] = c plt.plot(removed_count) plt.show()
}) ## for Palatino and other serif fonts use: #rc('font',**{'family':'serif','serif':['Palatino']}) rc('text', usetex=True) # matplotlib.rcParams['figure.dpi'] = 400 N = 14 pxp = unlocking_System([0], "periodic", 2, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)]) Hp = dict() Hp[0] = Hamiltonian(pxp) Hp[0].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[0].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[0].model = np.array([[0, 1], [0, 2]]) Hp[0].model_coef = np.array([1, 1]) Hp[0].uc_size = np.array([2, 2]) Hp[0].uc_pos = np.array([1, 0]) #1st order pert Hp[1] = Hamiltonian(pxp) Hp[1].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[1].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[1].site_ops[3] = np.array([[-1, 0], [0, 1]]) Hp[1].model = np.array([[0, 2, 3], [0, 1, 3]]) Hp[1].model_coef = np.array([1, 1]) Hp[1].uc_size = np.array([2, 2]) Hp[1].uc_pos = np.array([0, 1]) for n in range(0, len(Hp)):
# for n in range(0,np.size(indices,axis=0)): # psi = basis[:,indices[n]] psi = basis[:,n] for m in range(0,np.size(psi,axis=0)): if np.abs(psi[m])>1e-5: refs_non_zeros = np.append(refs_non_zeros,pxp.basis_refs[m]) refs_non_zeros = np.unique(np.sort(refs_non_zeros)) return refs_non_zeros #PXP+PPXP from Hamiltonian_Classes import H_operations H0 = spin_Hamiltonian(pxp,"x") V = Hamiltonian(pxp) V.site_ops[1] = np.array([[0,1/2],[1/2,0]]) V.site_ops[2] = np.array([[-1/2,0],[0,1/2]]) V.model = np.array([[2,0,1,0],[0,1,0,2]]) V.model_coef = np.array([1,1]) H0.gen() V.gen() H = H_operations.add(H0,V,np.array([1,-0.02])) H.sector.find_eig() H = spin_Hamiltonian(pxp,"x") H.gen() H.sector.find_eig() # N=10 # root_refs = find_root_refs(np.array([3,0]),np.array([3,1]),H,sector_refs,from_sector,pxp,[]) # basis = subcube_basis(root_refs,"Left",4) # refs_found = non_zero_ref_in_basis(basis)
from matplotlib import rc rc('font',**{'family':'sans-serif','sans-serif':['Computer Modern'],'size':26}) ## for Palatino and other serif fonts use: #rc('font',**{'family':'serif','serif':['Palatino']}) rc('text', usetex=True) # matplotlib.rcParams['figure.dpi'] = 400 N=16 pxp = unlocking_System([0],"periodic",2,N) pxp.gen_basis() pxp_syms = model_sym_data(pxp,[translational(pxp)]) #create Hamiltonian a=0.1229 H = Hamiltonian(pxp,pxp_syms) H.site_ops[1] = np.array([[0,1],[1,0]]) H.model = np.array([[1],[0,1,1,1,0]]) H.model_coef = np.array([0,1]) 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.show() fidelity(z,H,"use sym").plot(np.arange(0,20,0.01),z) plt.show()
print(pxp.dim) pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)]) # J = -1 # hx = 0.05 # hz = -0.5 J = 1 hx = 1 hz = 1 Hp = dict() Hp[0] = Hamiltonian(pxp, pxp_syms) Hp[0].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[0].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[0].site_ops[3] = np.array([[-1 / 2, 0], [0, 1 / 2]]) Hp[0].model = np.array([[1, 1], [2, 2], [1, 2], [2, 1], [1], [2], [3]]) Hp[0].model_coef = np.array( [J / 4, J / 4, J / 4, J / 4, hx / 2, hx / 2, hz / 2]) Hp[0].uc_size = np.array([2, 2, 2, 2, 2, 2, 1]) Hp[0].uc_pos = np.array([0, 1, 0, 1, 0, 1, 0]) Hp[1] = Hamiltonian(pxp, pxp_syms) Hp[1].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[1].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[1].site_ops[3] = np.array([[-1 / 2, 0], [0, 1 / 2]]) Hp[1].site_ops[4] = np.array([[0, 0], [0, 1]]) Hp[1].model = np.array([[2, 2, 4], [2, 2, 0], [1, 1, 0], [1, 1, 4]]) Hp[1].model_coef = np.array([1, 1, 1, 1]) Hp[1].uc_size = np.array([2, 2, 2, 2]) Hp[1].uc_pos = np.array([1, 1, 0, 0])
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) V1_ops[0].site_ops[1] = np.array([[0, 1], [1, 0]]) V1_ops[0].model = np.array([[0, 1, 0, 0]]) V1_ops[0].model_coef = np.array([1]) for n in range(0, np.size(k)): V1_ops[0].gen(k_vec=k[n], uc_size=3, uc_pos=1) V1_ops[1] = Hamiltonian(pxp, pxp_syms) V1_ops[1].site_ops[1] = np.array([[0, 1], [1, 0]]) V1_ops[1].model = np.array([[0, 0, 1, 0]]) V1_ops[1].model_coef = np.array([1]) for n in range(0, np.size(k)): V1_ops[1].gen(k_vec=k[n], uc_size=3, uc_pos=2) V1_ops[2] = Hamiltonian(pxp, pxp_syms) V1_ops[2].site_ops[1] = np.array([[0, 1], [1, 0]]) V1_ops[2].model = np.array([[0, 1, 0, 0]]) V1_ops[2].model_coef = np.array([1])
decompBasis.gen_basis() to_keep = np.zeros(pxp.dim) decomp_ref = [] pbar = ProgressBar() for n in pbar(range(0, np.size(decompBasis.basis, axis=0))): Hp = Hamiltonian(pxp) Hp.site_ops[1] = np.array([[0, 0], [1, 0]]) Hp.site_ops[2] = np.array([[0, 1], [0, 0]]) model = [] for m in range(0, np.size(decompBasis.basis[n], axis=0)): if decompBasis.basis[n][m] == 1: model.append([0, 1, 0]) else: model.append([0, 2, 0]) Hp.model = model Hp.model_coef = np.ones(pxp.N) Hp.uc_size = pxp.N * np.ones(pxp.N) Hp.uc_pos = np.arange(0, pxp.N) Hp.gen() Hm = Hp.herm_conj() Hz = 1 / 2 * com(Hp.sector.matrix(), Hm.sector.matrix()) Hx = 1 / 2 * (Hp.sector.matrix() + Hm.sector.matrix()) Hy = 1 / 2j * (Hp.sector.matrix() - Hm.sector.matrix()) C = np.dot(Hx, Hx) + np.dot(Hy, Hy) + np.dot(Hz, Hz) ec, uc = np.linalg.eigh(C) for m in range(0, np.size(ec, axis=0)): if np.abs(var(Hz, uc[:, 0])) < 1e-5:
## for Palatino and other serif fonts use: #rc('font',**{'family':'serif','serif':['Palatino']}) rc('text', usetex=True) # matplotlib.rcParams['figure.dpi'] = 400 N = 12 pxp = unlocking_System([0,1],"periodic",2,N) pxp.gen_basis() pxp_syms=model_sym_data(pxp,[translational(pxp)]) H = spin_Hamiltonian(pxp,"x",pxp_syms) H = Hamiltonian(pxp,pxp_syms) H.site_ops[1] = np.array([[0,1/2],[1/2,0]]) H.site_ops[2] = np.array([[1,0],[0,0]]) H.site_ops[3] = np.array([[0,0],[0,1]]) 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)
Q2 = np.dot(Q, Q) return exp(Q2, psi) - exp(Q, psi)**2 def com(a, b): return np.dot(a, b) - np.dot(b, a) N = 12 pxp = unlocking_System([0], "periodic", 2, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)]) H0 = Hamiltonian(pxp) H0.site_ops[1] = np.array([[0, 1], [1, 0]]) H0.model = np.array([[0, 1, 1, 1, 0]]) H0.model_coef = np.array([1]) V = Hamiltonian(pxp) V.site_ops[1] = np.array([[0, 1], [1, 0]]) V.site_ops[4] = np.array([[0, 0], [0, 1]]) V.model = np.array([[0, 1, 1, 1, 0, 4, 0], [0, 4, 0, 1, 1, 1, 0], [0, 1, 1, 1, 0, 4, 0], [0, 4, 0, 1, 1, 1, 0]]) V.model_coef = np.array([1, 1, 1, 1]) V.uc_size = np.array([4, 4, 4, 4]) V.uc_pos = np.array([2, 0, 0, 2]) def fidelity_eval(psi_energy, e, t): evolved_state = time_evolve_state(psi_energy, e, t) f = np.abs(np.vdot(evolved_state, psi_energy))**2
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()
def com(a, b): return np.dot(a, b) - np.dot(b, a) N = 12 pxp = unlocking_System([0], "periodic", 2, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)]) Hp = dict() Hp[0] = Hamiltonian(pxp) Hp[0].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[0].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[0].model = np.array([[0, 1, 0], [0, 2, 0]]) Hp[0].model_coef = np.array([1, 1]) Hp[0].uc_size = np.array([2, 2]) Hp[0].uc_pos = np.array([1, 0]) Hp[1] = Hamiltonian(pxp) Hp[1].site_ops[1] = np.array([[0, 0], [1, 0]]) Hp[1].site_ops[2] = np.array([[0, 1], [0, 0]]) Hp[1].model = np.array([[0, 2, 1, 2, 0], [0, 1, 2, 1, 0]]) Hp[1].model_coef = np.array([1, 1]) Hp[1].uc_size = np.array([2, 2]) Hp[1].uc_pos = np.array([0, 1]) # Hp[0] = Hamiltonian(pxp) # Hp[0].site_ops[1] = np.array([[0,0],[1,0]]) # Hp[0].site_ops[2] = np.array([[0,1],[0,0]])
#form Rydberg subspace in full basis rydberg_subspace = np.zeros((pxp.dim, pxp_half.dim)) for n in range(0, pxp_half.dim): rydberg_subspace[pxp.keys[pxp_half.basis_refs[n]], n] = 1 #pauli ops X = Hamiltonian(pxp, pxp_syms) Y = Hamiltonian(pxp, pxp_syms) Z = Hamiltonian(pxp, pxp_syms) X.site_ops[1] = np.array([[0, 1], [1, 0]]) Y.site_ops[1] = np.array([[0, -1j], [1j, 0]]) Z.site_ops[1] = np.array([[-1, 0], [0, 1]]) X.model, X.model_coef = np.array([[1]]), np.array((1)) Y.model, Y.model_coef = np.array([[1]]), np.array((1)) Z.model, Z.model_coef = np.array([[1]]), np.array((1)) X.gen() Y.gen() Z.gen() #n_i n_i+1 H0 = Hamiltonian(pxp, pxp_syms) H0.site_ops[1] = np.array([[0, 0], [0, 1]]) H0.model = np.array([[1, 1]]) H0.model_coef = np.array((1)) #X_n H_kick = Hamiltonian(pxp, pxp_syms)
def ncr(n, r): r = min(r, n-r) numer = reduce(op.mul, range(n, n-r, -1), 1) denom = reduce(op.mul, range(1, r+1), 1) return numer / denom def W(N): choose = ncr(int(N/2),2) return 1/np.power(choose,0.5)*1/np.power(int(N/2)-1,0.5)*N/2 N = 10 pxp = unlocking_System([0,1],"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,0]]) H.model_coef = np.array([1]) H.gen() from Calculations import connected_comps c_comp = connected_comps(H) c_comp.find_connected_components() largest = c_comp.largest_component() for n in range(0,np.size(largest,axis=0)): print(pxp.basis[pxp.keys[largest[n]]]) print(np.size(largest))
def var(Q,psi): Q2 = np.dot(Q,Q) return exp(Q2,psi)-exp(Q,psi)**2 #init system N=16 pxp = unlocking_System([0],"periodic",2,N) pxp.gen_basis() pxp_syms = model_sym_data(pxp,[translational_general(pxp,order=4)]) # pxp_syms = model_sym_data(pxp,[translational(pxp)]) Hp = dict() Hp[0] = Hamiltonian(pxp,pxp_syms) Hp[0].site_ops[1] = np.array([[0,0],[1,0]]) Hp[0].site_ops[2] = np.array([[0,1],[0,0]]) Hp[0].model = np.array([[0,2,0],[0,1,0],[0,1,0],[0,1,0]]) Hp[0].model_coef = np.array([1,1,1,1]) Hp[0].uc_size = np.array([4,4,4,4]) Hp[0].uc_pos = np.array([3,0,1,2]) # Hp[1] = Hamiltonian(pxp,pxp_syms) # Hp[1].site_ops[1] = np.array([[0,0],[1,0]]) # Hp[1].site_ops[2] = np.array([[0,1],[0,0]]) # Hp[1].model = np.array([[0,1,2,1,0]]) # Hp[1].model_coef = np.array([1]) # Hp[1].uc_size = np.array([4]) # Hp[1].uc_pos = np.array([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]])
# root_refs = find_root_refs(np.array([4,1]),np.array([4,2]),H,sector_refs,from_sector,pxp) # basis = np.hstack((basis,subcube_basis(root_refs,"Left",6))) # print("\n") # root_refs = find_root_refs(np.array([1,4]),np.array([2,4]),H,sector_refs,from_sector,pxp) # basis = np.hstack((basis,subcube_basis(root_refs,"Right",6))) # print("\n") # root_refs = find_root_refs(np.array([3,0]),np.array([3,3]),H,sector_refs,from_sector,pxp) # basis = np.hstack((basis,subcube_basis(root_refs,"Left",6))) # include Neel fsa (orig) #fsa Hamiltonian, H= H+ + H- Hp1 = Hamiltonian(pxp) Hp1.site_ops[1] = np.array([[0, 1], [0, 0]]) Hp1.model = np.array([[1]]) Hp1.model_coef = np.array([1]) Hp1.gen(parity=0) Hp2 = Hamiltonian(pxp) Hp2.site_ops[1] = np.array([[0, 0], [1, 0]]) Hp2.model = np.array([[1]]) Hp2.model_coef = np.array([1]) Hp2.gen(parity=1) Hm = Hp1.sector.matrix() + Hp2.sector.matrix() Hp = np.conj(np.transpose(Hm)) #fsa basis from Neel z = zm_state(2, 1, pxp) fsa_basis = z.prod_basis() current_state = fsa_basis fsa_dim = pxp.N
## for Palatino and other serif fonts use: #rc('font',**{'family':'serif','serif':['Palatino']}) rc('text', usetex=True) # matplotlib.rcParams['figure.dpi'] = 400 N = 16 pxp = unlocking_System([0], "periodic", 2, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational(pxp), parity(pxp)]) H0 = spin_Hamiltonian(pxp, "x", pxp_syms) H0.gen() Hpe = Hamiltonian(pxp, pxp_syms) Hpe.site_ops[1] = np.array([[0, 1], [0, 0]]) Hpe.model = np.array([[0, 1, 0]]) Hpe.model_coef = np.array([1]) Hpe.gen(parity=0) Hpo = Hamiltonian(pxp, pxp_syms) Hpo.site_ops[1] = np.array([[0, 1], [0, 0]]) Hpo.model = np.array([[0, 1, 0]]) Hpo.model_coef = np.array([1]) Hpo.gen(parity=1) Hme = Hamiltonian(pxp, pxp_syms) Hme.site_ops[1] = np.array([[0, 0], [1, 0]]) Hme.model = np.array([[0, 1, 0]]) Hme.model_coef = np.array([1]) Hme.gen(parity=0)
# matplotlib.rcParams['figure.dpi'] = 400 def com(a, b): return np.dot(a, b) - np.dot(b, a) #init system N = 21 pxp = unlocking_System([0], "periodic", 2, N) pxp.gen_basis() pxp_syms = model_sym_data(pxp, [translational_general(pxp, order=3)]) H0 = Hamiltonian(pxp, pxp_syms) H0.site_ops[1] = np.array([[0, 1], [1, 0]]) H0.model = np.array([[1]]) H0.model_coef = np.array([1]) H1 = Hamiltonian(pxp, pxp_syms) H1.site_ops[1] = np.array([[0, 1], [1, 0]]) H1.model = np.array([[0, 1, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0]]) H1.model_coef = np.array([1, 1, 1, 1]) H1.uc_size = np.array([3, 3, 3, 3]) H1.uc_pos = np.array([1, 2, 2, 1]) k = [0] H0.gen(k) H1.gen(k) # H0.gen() # H1.gen() H = H_operations.add(H0, H1, np.array([1, -1]))
count = 0 pxp_config = model_space.basis[indices[0][index_row_loc[count]]] pxxxp_config = model_space.basis[indices[1][index_row_loc[count]]] print(pxp_config, pxxxp_config) # print(index_spacing_error[count]) # print(index_var_error[count]) Hp = gen_Hp(pxp_config, pxxxp_config) Hm = np.conj(np.transpose(Hp)) Hp_test0 = Hamiltonian(pxp) Hp_test0.site_ops[1] = np.array([[0, 0], [1, 0]]) Hp_test0.site_ops[2] = np.array([[0, 1], [0, 0]]) Hp_test0.model = np.array([[0, 1, 0], [0, 2, 0]]) Hp_test0.model_coef = np.array([1, 1]) Hp_test0.uc_size = np.array([2, 2]) Hp_test0.uc_pos = np.array([1, 0]) Hp_test = Hamiltonian(pxp) Hp_test.site_ops[1] = np.array([[0, 0], [1, 0]]) Hp_test.site_ops[2] = np.array([[0, 1], [0, 0]]) Hp_test.model = np.array([[0, 2, 1, 2, 0]]) Hp_test.model_coef = np.array([1]) Hp_test0.gen() Hp_test.gen() from Hamiltonian_Classes import H_operations Hp_test = H_operations.add(Hp_test0, Hp_test, np.array([1, coef_f0])) print((np.abs(Hp_test.sector.matrix() - Hp) < 1e-5).all())
# matplotlib.rcParams['figure.dpi'] = 400 import numpy as np import scipy as sp import math from Calculations import plot_adjacency_graph N = 12 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, 0], [1, 0]]) H.site_ops[2] = np.array([[0, 1], [0, 0]]) H.model = np.array([[0, 1, 2, 0], [0, 2, 1, 0]]) H.model_coef = np.array([1, 1]) k = [0] H.gen(k) # H.gen() # H0=spin_Hamiltonian(pxp,"x",pxp_syms) # H0.gen(k) # # H = H_operations.add(H0,H,np.array([1,1/2])) # H = H_operations.add(H0,H,np.array([1,1])) # all states # basis_labels = dict() # for n in range(0,np.size(pxp.basis,axis=0)): # basis_labels[n] = pxp.basis[n] # plot_adjacency_graph(np.abs(H.sector.matrix()),labels=basis_labels)
z = zm_state(2, 1, pxp) #krylov basis krylov_dim = 2 * pxp.N krylov_basis = gen_krylov_basis(H.sector.matrix(), krylov_dim, z.prod_basis(), pxp, orth="qr") #FSA basis # P+P on even sites pe = Hamiltonian(pxp, pxp_syms) pe.site_ops[1] = np.array([[0, 1, 1j], [-1, 0, 0], [-1j, 0, 0]]) pe.model = np.array([[0, 1, 0]]) pe.model_coef = np.array([1]) pe.gen(parity=1) #P-P on odd sites mo = Hamiltonian(pxp, pxp_syms) mo.site_ops[1] = np.array([[0, -1, 1j], [1, 0, 0], [-1j, 0, 0]]) mo.model = np.array([[0, 1, 0]]) mo.model_coef = np.array([1]) mo.gen(parity=0) #Raising op Hp = H_operations.add(pe, mo, np.array([1, 1])) Hp = Hp.sector.matrix() Hm = np.conj(np.transpose(Hp)) def com(a, b):