Exemplo n.º 1
0
whatKs = [1]

ansatzgenmethod = "random_selection_new"  #'random_selection_new',"no_processing", 'pruning'
numberofnewstatestoadd = 10  #Only will be used if 'random_selection_new' is selected

degeneracy_tol = 5
loadmatlabmatrix = False
runSDPonpython = True

if optimizer == 'feasibility_sdp':
    num_qubits = 1

#Generate initial state

random_generator = np.random.default_rng(123)
initial_state = acp.Initialstate(num_qubits, "efficient_SU2", random_generator,
                                 5)

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(LdagL)
#print(list(pauli_decomp.values()))

if optimizer == 'feasibility_sdp':
    delta = 0.1
    #gammas = [0.1]
Exemplo n.º 2
0
import ansatz_class_package as acp 
import pauli_class_package as pcp 
import hamiltonian_class_package as hcp 
import matrix_class_package as mcp 
import post_processing as pp
import scipy as scp

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)