def generate_nonlocaljump_gamma_and_Lterms(num_qubits, Gamma, mu): #gammas_to_append = 1 gammas = [] L_terms = [] if num_qubits == 1: raise ( RuntimeError('Cannot generate non-local jump terms with 1 qubit')) else: gammas.append(1) cof = np.sqrt(Gamma * (1 - mu)) L_terms.append( hcp.generate_arbitary_hamiltonian( num_qubits, [0.25 * cof, 0.25j * cof, -0.25j * cof, 0.25 * cof], [ '1' + '0' * (num_qubits - 2) + '1', '2' + '0' * (num_qubits - 2) + '1', '1' + '0' * (num_qubits - 2) + '2', '2' + '0' * (num_qubits - 2) + '2' ])) gammas.append(1) cof = np.sqrt(Gamma * (1 + mu)) L_terms.append( hcp.generate_arbitary_hamiltonian( num_qubits, [0.25 * cof, -0.25j * cof, 0.25j * cof, 0.25 * cof], [ '1' + '0' * (num_qubits - 2) + '1', '2' + '0' * (num_qubits - 2) + '1', '1' + '0' * (num_qubits - 2) + '2', '2' + '0' * (num_qubits - 2) + '2' ])) return (gammas, L_terms)
def generate_fuji_boy_gamma_and_Lterms(num_qubits): gammas_to_append = 1 gammas = [] L_terms = [] if num_qubits == 1: gammas.append(gammas_to_append) L_terms.append(hcp.generate_arbitary_hamiltonian(1, [0.5,0.5j],["1","2"])) else: for i in range(num_qubits): gammas.append(gammas_to_append) L_terms.append(hcp.generate_arbitary_hamiltonian(num_qubits,[1],['0'*i+'3'+'0'*(num_qubits-1-i)])) gammas.append(gammas_to_append) L_terms.append(hcp.generate_arbitary_hamiltonian(num_qubits,[0.5,-0.5j],['0'*i+'1'+'0'*(num_qubits-1-i),'0'*i+'2'+'0'*(num_qubits-1-i)])) return (gammas, L_terms)
def generate_fuji_boy_hamiltonian(num_qubits, g): epsilon = 0.5 if num_qubits == 1: hamiltonian = hcp.generate_arbitary_hamiltonian(num_qubits,[epsilon,g],['3','1']) else: hamiltonian = hcp.transverse_ising_model_1d(num_qubits, -0.5, g) return hamiltonian
def generate_total_magnetisation_matform(num_qubits): def make_sigma_z_string(i): pauli_string_deconstructed = ["0"]*num_qubits pauli_string_deconstructed[i] = "3" pauli_string_str = "".join(pauli_string_deconstructed) return pauli_string_str p_strings = [make_sigma_z_string(i) for i in range(num_qubits)] betas = [1 for i in range(num_qubits)] M = hcp.generate_arbitary_hamiltonian(num_qubits, betas, p_strings) return M.to_matrixform()
def generate_bulk_dephasing(num_qubits): gammas = [] L_terms = [] if num_qubits == 1: raise(RuntimeError("One qubit case not considered")) else: for i in range(num_qubits): pauli_string_deconstructed = ["0"]*num_qubits pauli_string_deconstructed[i] = "3" pauli_string_str = "".join(pauli_string_deconstructed) L_i = hcp.generate_arbitary_hamiltonian(num_qubits, [1], [pauli_string_str]) # print(L_i.to_matrixform()) gammas.append(1) L_terms.append(L_i) return (gammas, L_terms)
delta = 0.1 #gammas = [0.1] gammas = [] epsilon = 0.5 #hamiltonian = hcp.generate_arbitary_hamiltonian(num_qubits,[delta,epsilon],['3','1']) #L_terms = [hcp.generate_arbitary_hamiltonian(num_qubits,[1,-1j],['1','2'])] hcoeffs = [] hstrings = [] for i in range(num_qubits - 1): hcoeffs.append(0.5) hstrings.append('0' * i + '33' + '0' * (num_qubits - 2 - i)) for i in range(num_qubits): hcoeffs.append(0.5) hstrings.append('0' * i + '1' + '0' * (num_qubits - 1 - i)) hamiltonian = hcp.generate_arbitary_hamiltonian(num_qubits, hcoeffs, hstrings) L_terms = [] for i in range(num_qubits): gammas.append(0.1) L_terms.append( hcp.generate_arbitary_hamiltonian( num_qubits, [1], ['0' * i + '3' + '0' * (num_qubits - 1 - i)])) gammas.append(0.1) L_terms.append( hcp.generate_arbitary_hamiltonian(num_qubits, [0.5, -0.5j], [ '0' * i + '1' + '0' * (num_qubits - 1 - i), '0' * i + '2' + '0' * (num_qubits - 1 - i) ])) #L_terms = [hcp.generate_arbitary_hamiltonian(num_qubits,[1],['30'])] #L_terms.append(hcp.generate_arbitary_hamiltonian(num_qubits,[0.5,-0.5j],['10','20']))
uptowhatK = 1 num_qubits = 2 optimizer = 'eig'#'eigh' , 'eig' eigh_inv_cond = 10**(-6) eig_inv_cond = 10**(-6) degeneracy_tol = 5 #Generate initial state initial_state = acp.Initialstate(num_qubits, "efficient_SU2", 267, 2) L = np.array([[-0.1,-0.25j,0.25j,0],[-0.25j,-0.05-0.1j,0,0.25j],[0.25j,0,-0.05+0.1j,-0.25j],[0.1,0.25j,-0.25j,0]]) #Converting L^dag L into Hamiltonian LdagL = np.array([[0.145,0.025+0.0375j,0.025-0.0375j,-0.125],[0.025-0.0375j,0.1375,-0.125,-0.025-0.0125j],[0.025+0.0375j,-0.125,0.1375,-0.025+0.0125j],[-0.125,-0.025+0.0125j,-0.025-0.0125j,0.125]]) pauli_decomp = pcp.paulinomial_decomposition(L) hamiltonian = hcp.generate_arbitary_hamiltonian(num_qubits, list(pauli_decomp.values()), list(pauli_decomp.keys())) #print('Beta values are ' + str(hamiltonian.return_betas())) ansatz = acp.initial_ansatz(num_qubits) #Run IQAE for k in range(1, uptowhatK + 1): print(k) #Generate Ansatz for this round ansatz = acp.gen_next_ansatz(ansatz, hamiltonian, num_qubits) E_mat_uneval = mcp.unevaluatedmatrix(num_qubits, ansatz, hamiltonian, "E") D_mat_uneval = mcp.unevaluatedmatrix(num_qubits, ansatz, hamiltonian, "D") #Here is where we should be able to specify how to evaluate the matrices. However only the exact method (classical matrix multiplication) has been implemented so far
LdagL = np.array([[0.145, 0.025 + 0.0375j, 0.025 - 0.0375j, -0.125], [0.025 - 0.0375j, 0.1375, -0.125, -0.025 - 0.0125j], [0.025 + 0.0375j, -0.125, 0.1375, -0.025 + 0.0125j], [-0.125, -0.025 + 0.0125j, -0.025 - 0.0125j, 0.125]]) pauli_decomp = pcp.paulinomial_decomposition(LdagL) #print(list(pauli_decomp.values())) if optimizer == 'feasibility_sdp': delta = 0.1 #gammas = [0.1] gammas = [0.1, 0.1, 0.1, 0.1] epsilon = 0.5 #hamiltonian = hcp.generate_arbitary_hamiltonian(num_qubits,[delta,epsilon],['3','1']) #L_terms = [hcp.generate_arbitary_hamiltonian(num_qubits,[1,-1j],['1','2'])] hamiltonian = hcp.generate_arbitary_hamiltonian(num_qubits, [0.5, 0.5, 0.5], ['33', '01', '10']) L_terms = [hcp.generate_arbitary_hamiltonian(num_qubits, [1], ['30'])] L_terms.append( hcp.generate_arbitary_hamiltonian(num_qubits, [0.5, -0.5j], ['10', '20'])) L_terms.append(hcp.generate_arbitary_hamiltonian(num_qubits, [1], ['03'])) L_terms.append( hcp.generate_arbitary_hamiltonian(num_qubits, [0.5, -0.5j], ['01', '02'])) else: hamiltonian = hcp.generate_arbitary_hamiltonian( num_qubits, list(pauli_decomp.values()), list(pauli_decomp.keys())) #print('Beta values are ' + str(hamiltonian.return_betas()))