ansatze = ['UCCD'] depth = 1 #for g in gs: for ansatz in ansatze: if ansatz == 'RYRZ': depth = 2 else: depth = 1 print('For ', ansatz, 'with depth', depth) i = 0 fci = np.zeros_like(gs) hf = np.zeros_like(gs) data = np.zeros_like(gs) coeff = np.zeros((len(gs), 70)) for g in tqdm(gs): h_pq, h_pqrs, Efci, Ehf = get_pairing_matrix(n, l, delta, g, w_E=True) fci[i] = Efci hf[i] = Ehf #print('FCI:',fci[i]) #print('HF:',Ehf) pairing = PairingHamiltonian(n, l, h_pq, h_pqrs) #pairing = SecondQuantizedHamiltonian(n,l,h_pq,h_pqrs) pairing.group_paulis() #print('Num measures:',len(pairing.circuit_list('vqe'))) options = { 'shots': shots, #'optimization_level':1, #'seed':1, 'print': False } model = VQE(pairing,
# IBM PREP import qiskit as qk qk.IBMQ.load_account() provider = qk.IBMQ.get_provider('ibm-q') qcomp = provider.get_backend('ibmq_essex') #qcomp = provider.get_backend('ibmq_london') l = 4 # number of spin orbitals / number of qubits n = 2 # Number of occupied spin orbitals delta = 1 # Level spacing g = 1 # Interaction strength h,v = get_pairing_matrix(n,l,delta,g) Efci = FCI(n,l,h,v) print('FCI energy :',Efci) import time t1 = time.time() pairing = PairingHamiltonian(n,l,h,v) t2 = time.time() print('Time:',t2-t1) pairing.group_paulis(qwc=True,gc=True) #theta = [5.829889373194686] # Hardcode good parameter
device = '' if len(sys.argv) > 1: device = sys.argv[1] else: device = 'london' ansatz = 'RYPAIRING' gs = np.arange(-2, 2, 0.05) data = np.zeros((len(gs), 3)) fci = np.zeros_like(gs) shots = 1000 i = 0 for g in tqdm(gs): h_pq, h_pqrs = get_pairing_matrix(n, l, delta, g) pairing = PairingHamiltonian(n, l, h_pq, h_pqrs) pairing.group_paulis() option1 = { 'shots': shots, 'optimization_level': 1, #'seed':1, 'print': False } option2 = { 'shots': shots, 'optimization_level': 1, 'device': 'ibmq_{}'.format(device), 'layout': [1, 0, 2, 3], 'noise_model': True, 'basis_gates': True,