def test_H4_spqe_exact(self): print('\n') # The FCI energy for H4 at 0.75 Angstrom in a sto-6g basis Efci = -2.1628978832666865 # The Nuclear repulsion energy Enuc = 3.057468328315556 mol = system_factory(stytem_type = 'molecule', build_type = 'external', basis='sto-6g', filename=data_path) Hnonzero = qforte.QuantumOperator() for term in mol._hamiltonian.terms(): if abs(term[0]) > 1.0e-14: Hnonzero.add_term(term[0], term[1]) mol._hamiltonian = Hnonzero qforte.smart_print(Hnonzero) alg = SPQE(mol, print_summary_file=False) alg.run(spqe_maxiter=20, spqe_thresh=1.0e-4, res_vec_thresh=1.0e-5, dt = 0.0001) Egs_elec = alg.get_gs_energy() # Egs = Egs_elec + Enuc Egs = Egs_elec self.assertLess(abs(Egs-Efci), 5.0e-11)
def test_trotterization(self): circ_vec = [qforte.QuantumCircuit(), qforte.build_circuit('Z_0')] coef_vec = [-1.0j * 0.5, -1.0j * -0.04544288414432624] # the operator to be exponentiated minus_iH = qforte.QuantumOperator() for i in range(len(circ_vec)): minus_iH.add_term(coef_vec[i], circ_vec[i]) # exponentiate the operator Utrot, phase = qforte.trotterization.trotterize(minus_iH) inital_state = np.zeros(2**4, dtype=complex) inital_state[3] = np.sqrt(2 / 3) inital_state[12] = -np.sqrt(1 / 3) # initalize a quantum computer with above coeficients # i.e. ca|1100> + cb|0011> qc = qforte.QuantumComputer(4) qc.set_coeff_vec(inital_state) # apply the troterized minus_iH qc.apply_circuit(Utrot) qc.apply_constant(phase) qforte.smart_print(qc) coeffs = qc.get_coeff_vec() self.assertAlmostEqual(np.real(coeffs[3]), 0.6980209737879599) self.assertAlmostEqual(np.imag(coeffs[3]), -0.423595782342996) self.assertAlmostEqual(np.real(coeffs[12]), -0.5187235657531178) self.assertAlmostEqual(np.imag(coeffs[12]), 0.25349397560041553)
def test_H2(self): print('\n'), # The FCI energy for H2 at 1.5 Angstrom in a sto-3g basis E_fci = -0.9981493534 coef_vec = [-0.4917857774144603, 0.09345649662931771, 0.09345649662931771, -0.0356448161226769, -0.0356448161226769, 0.1381758457453024, 0.05738398402634884, -0.0573839840263488, -0.0573839840263488, 0.05738398402634884, 0.08253705485911705, 0.13992103888546592, 0.13992103888546592, 0.08253705485911705, 0.1458551902800438] circ_vec = [ qforte.QuantumCircuit( ), qforte.build_circuit( 'Z_0' ), qforte.build_circuit( 'Z_1' ), qforte.build_circuit( 'Z_2' ), qforte.build_circuit( 'Z_3' ), qforte.build_circuit( 'Z_0 Z_1' ), qforte.build_circuit( 'Y_0 X_1 X_2 Y_3' ), qforte.build_circuit( 'X_0 X_1 Y_2 Y_3' ), qforte.build_circuit( 'Y_0 Y_1 X_2 X_3' ), qforte.build_circuit( 'X_0 Y_1 Y_2 X_3' ), qforte.build_circuit( 'Z_0 Z_2' ), qforte.build_circuit( 'Z_0 Z_3' ), qforte.build_circuit( 'Z_1 Z_2' ), qforte.build_circuit( 'Z_1 Z_3' ), qforte.build_circuit( 'Z_2 Z_3' )] H2_qubit_hamiltonian = qforte.QuantumOperator() for i in range(len(circ_vec)): H2_qubit_hamiltonian.add_term(coef_vec[i], circ_vec[i]) ref = [1,1,0,0] print('\nBegin QPE test for H2') print('----------------------') # make test with algorithm class mol = Molecule() mol.set_hamiltonian(H2_qubit_hamiltonian) alg = QPE(mol, reference=ref, trotter_number=2) alg.run(t = 0.4, nruns = 100, success_prob = 0.5, num_precise_bits = 8) Egs = alg.get_gs_energy() self.assertLess(abs(Egs-E_fci), 1.1e-3)
def test_trotterization_with_controlled_U(self): circ_vec = [ qforte.build_circuit('Y_0 X_1'), qforte.build_circuit('X_0 Y_1') ] coef_vec = [-1.0719145972781818j, 1.0719145972781818j] # the operator to be exponentiated minus_iH = qforte.QuantumOperator() for i in range(len(circ_vec)): minus_iH.add_term(coef_vec[i], circ_vec[i]) ancilla_idx = 2 # exponentiate the operator Utrot, phase = qforte.trotterization.trotterize_w_cRz( minus_iH, ancilla_idx) # Case 1: positive control # initalize a quantum computer qc = qforte.QuantumComputer(3) # build HF state qc.apply_gate(qforte.gate('X', 0, 0)) # put ancilla in |1> state qc.apply_gate(qforte.gate('X', 2, 2)) # apply the troterized minus_iH qc.apply_circuit(Utrot) qforte.smart_print(qc) coeffs = qc.get_coeff_vec() self.assertAlmostEqual(coeffs[5], -0.5421829373 + 0.0j) self.assertAlmostEqual(coeffs[6], -0.840260473 + 0.0j) # Case 2: negitive control # initalize a quantum computer qc = qforte.QuantumComputer(3) # build HF state qc.apply_gate(qforte.gate('X', 0, 0)) # apply the troterized minus_iH qc.apply_circuit(Utrot) qforte.smart_print(qc) coeffs = qc.get_coeff_vec() self.assertAlmostEqual(coeffs[1], 1.0 + 0.0j)
def test_H2_experiment_perfect(self): print('\n') #the RHF H2 energy at equilibrium bond length E_hf = -1.1166843870661929 #the H2 qubit hamiltonian circ_vec = [ qforte.QuantumCircuit(), qforte.build_circuit('Z_0'), qforte.build_circuit('Z_1'), qforte.build_circuit('Z_2'), qforte.build_circuit('Z_3'), qforte.build_circuit('Z_0 Z_1'), qforte.build_circuit('Y_0 X_1 X_2 Y_3'), qforte.build_circuit('Y_0 Y_1 X_2 X_3'), qforte.build_circuit('X_0 X_1 Y_2 Y_3'), qforte.build_circuit('X_0 Y_1 Y_2 X_3'), qforte.build_circuit('Z_0 Z_2'), qforte.build_circuit('Z_0 Z_3'), qforte.build_circuit('Z_1 Z_2'), qforte.build_circuit('Z_1 Z_3'), qforte.build_circuit('Z_2 Z_3') ] coef_vec = [ -0.098863969784274, 0.1711977489805748, 0.1711977489805748, -0.222785930242875, -0.222785930242875, 0.1686221915724993, 0.0453222020577776, -0.045322202057777, -0.045322202057777, 0.0453222020577776, 0.1205448220329002, 0.1658670240906778, 0.1658670240906778, 0.1205448220329002, 0.1743484418396386 ] H2_qubit_hamiltonian = qforte.QuantumOperator() for i in range(len(circ_vec)): H2_qubit_hamiltonian.add_term(coef_vec[i], circ_vec[i]) # circuit for making HF state circ = qforte.QuantumCircuit() circ.add_gate(qforte.gate('X', 0, 0)) circ.add_gate(qforte.gate('X', 1, 1)) TestExperiment = qforte.Experiment(4, circ, H2_qubit_hamiltonian, 1000000) params2 = [] avg_energy = TestExperiment.perfect_experimental_avg(params2) print('Perfectly Measured H2 Experimental Avg. Energy') print(avg_energy) print('H2 RHF Energy') print(E_hf) experimental_error = abs(avg_energy - E_hf) self.assertAlmostEqual(experimental_error, 0.0)
def test_op_exp_val_1(self): # test direct expectation value measurement trial_state = qforte.QuantumComputer(4) trial_prep = [None] * 5 trial_prep[0] = qforte.gate('H', 0, 0) trial_prep[1] = qforte.gate('H', 1, 1) trial_prep[2] = qforte.gate('H', 2, 2) trial_prep[3] = qforte.gate('H', 3, 3) trial_prep[4] = qforte.gate('cX', 0, 1) trial_circ = qforte.QuantumCircuit() #prepare the circuit for gate in trial_prep: trial_circ.add_gate(gate) # use circuit to prepare trial state trial_state.apply_circuit(trial_circ) # gates needed for [a1^ a2] operator X1 = qforte.gate('X', 1, 1) X2 = qforte.gate('X', 2, 2) Y1 = qforte.gate('Y', 1, 1) Y2 = qforte.gate('Y', 2, 2) # initialize circuits to make operator circ1 = qforte.QuantumCircuit() circ1.add_gate(X2) circ1.add_gate(Y1) circ2 = qforte.QuantumCircuit() circ2.add_gate(Y2) circ2.add_gate(Y1) circ3 = qforte.QuantumCircuit() circ3.add_gate(X2) circ3.add_gate(X1) circ4 = qforte.QuantumCircuit() circ4.add_gate(Y2) circ4.add_gate(X1) #build the quantum operator for [a1^ a2] a1_dag_a2 = qforte.QuantumOperator() a1_dag_a2.add_term(0.0 - 0.25j, circ1) a1_dag_a2.add_term(0.25, circ2) a1_dag_a2.add_term(0.25, circ3) a1_dag_a2.add_term(0.0 + 0.25j, circ4) #get direct expectatoin value exp = trial_state.direct_op_exp_val(a1_dag_a2) self.assertAlmostEqual(exp, 0.2499999999999999 + 0.0j)
def test_jw1(self): """ test JW transform of 1.0(2^ 3^ 4 6) + 1.5(1^ 2^ 3 4) """ coeff_vec = [ -0.093750, +0.093750j, -0.093750, -0.093750j, -0.093750, -0.093750j, +0.062500j, -0.093750, -0.093750, +0.093750j, +0.093750, -0.062500, -0.093750j, -0.062500j, +0.062500j, -0.062500, +0.062500, +0.062500, -0.062500j, -0.093750, +0.062500j, -0.062500, -0.062500j, -0.062500, +0.093750j, +0.093750j, +0.062500j, +0.093750, -0.062500, -0.062500, -0.093750j, -0.062500j ] circ_vec = [ qforte.build_circuit('X_1 Y_2 X_3 Y_4'), qforte.build_circuit('X_1 Y_2 X_3 X_4'), qforte.build_circuit('X_1 Y_2 Y_3 X_4'), qforte.build_circuit('X_1 X_2 X_3 Y_4'), qforte.build_circuit('X_1 X_2 X_3 X_4'), qforte.build_circuit('X_1 X_2 Y_3 X_4'), qforte.build_circuit('Y_2 X_3 X_4 Z_5 X_6'), qforte.build_circuit('Y_1 Y_2 Y_3 Y_4'), qforte.build_circuit('Y_1 X_2 X_3 Y_4'), qforte.build_circuit('Y_1 X_2 X_3 X_4'), qforte.build_circuit('Y_1 Y_2 X_3 X_4'), qforte.build_circuit('X_2 X_3 X_4 Z_5 X_6'), qforte.build_circuit('Y_1 X_2 Y_3 Y_4'), qforte.build_circuit('X_2 Y_3 Y_4 Z_5 Y_6'), qforte.build_circuit('X_2 Y_3 X_4 Z_5 X_6'), qforte.build_circuit('X_2 Y_3 Y_4 Z_5 X_6'), qforte.build_circuit('X_2 X_3 Y_4 Z_5 Y_6'), qforte.build_circuit('Y_2 Y_3 X_4 Z_5 X_6'), qforte.build_circuit('X_2 X_3 Y_4 Z_5 X_6'), qforte.build_circuit('Y_1 X_2 Y_3 X_4'), qforte.build_circuit('Y_2 Y_3 X_4 Z_5 Y_6'), qforte.build_circuit('Y_2 X_3 X_4 Z_5 Y_6'), qforte.build_circuit('X_2 X_3 X_4 Z_5 Y_6'), qforte.build_circuit('X_2 Y_3 X_4 Z_5 Y_6'), qforte.build_circuit('Y_1 Y_2 Y_3 X_4'), qforte.build_circuit('Y_1 Y_2 X_3 Y_4'), qforte.build_circuit('Y_2 Y_3 Y_4 Z_5 X_6'), qforte.build_circuit('X_1 X_2 Y_3 Y_4'), qforte.build_circuit('Y_2 Y_3 Y_4 Z_5 Y_6'), qforte.build_circuit('Y_2 X_3 Y_4 Z_5 X_6'), qforte.build_circuit('X_1 Y_2 Y_3 Y_4'), qforte.build_circuit('Y_2 X_3 Y_4 Z_5 Y_6') ] correct_op = qforte.QuantumOperator() for i in range(len(circ_vec)): correct_op.add_term(coeff_vec[i], circ_vec[i]) # Test qforte construction a1 = qforte.SQOperator() a1.add_term(1.00, [ 2, 3, 4, 6] ) a1.add_term(+1.50, [ 1, 2, 3, 4]) print(a1.str(), '\n') aop = a1.jw_transform() print(aop.str(), '\n') self.assertTrue(aop.check_op_equivalence(correct_op, True))
def test_H4_physical_qkd(self): print('\n') # The FCI energy for H4 at 1.5 Angstrom in a sto-6g basis E_fci = -2.0126741263939656 # The He hamilitonian circ_vec = [ qforte.QuantumCircuit(), qforte.build_circuit('Z_0'), qforte.build_circuit('Y_0 Z_1 Z_2 Z_3 Y_4'), qforte.build_circuit('X_0 Z_1 Z_2 Z_3 X_4'), qforte.build_circuit('Z_1'), qforte.build_circuit('Y_1 Z_2 Z_3 Z_4 Y_5'), qforte.build_circuit('X_1 Z_2 Z_3 Z_4 X_5'), qforte.build_circuit('Z_2'), qforte.build_circuit('Y_2 Z_3 Z_4 Z_5 Y_6'), qforte.build_circuit('X_2 Z_3 Z_4 Z_5 X_6'), qforte.build_circuit('Z_3'), qforte.build_circuit('Y_3 Z_4 Z_5 Z_6 Y_7'), qforte.build_circuit('X_3 Z_4 Z_5 Z_6 X_7'), qforte.build_circuit('Z_4'), qforte.build_circuit('Z_5'), qforte.build_circuit('Z_6'), qforte.build_circuit('Z_7'), qforte.build_circuit('Z_0 Z_1'), qforte.build_circuit('Y_0 Z_2 Z_3 Y_4'), qforte.build_circuit('X_0 Z_2 Z_3 X_4'), qforte.build_circuit('Y_0 X_1 X_2 Y_3'), qforte.build_circuit('X_0 X_1 Y_2 Y_3'), qforte.build_circuit('Y_0 Y_1 X_2 X_3'), qforte.build_circuit('X_0 Y_1 Y_2 X_3'), qforte.build_circuit('Y_0 X_1 X_3 Z_4 Z_5 Y_6'), qforte.build_circuit('X_0 X_1 X_3 Z_4 Z_5 X_6'), qforte.build_circuit('Y_0 Y_1 Y_3 Z_4 Z_5 Y_6'), qforte.build_circuit('X_0 Y_1 Y_3 Z_4 Z_5 X_6'), qforte.build_circuit('Z_0 Y_1 Z_2 Z_3 Z_4 Y_5'), qforte.build_circuit('Z_0 X_1 Z_2 Z_3 Z_4 X_5'), qforte.build_circuit('Y_0 X_1 X_4 Y_5'), qforte.build_circuit('X_0 X_1 Y_4 Y_5'), qforte.build_circuit('Y_0 Y_1 X_4 X_5'), qforte.build_circuit('X_0 Y_1 Y_4 X_5'), qforte.build_circuit('Y_0 X_1 X_2 Z_3 Z_4 Z_5 Z_6 Y_7'), qforte.build_circuit('X_0 X_1 Y_2 Z_3 Z_4 Z_5 Z_6 Y_7'), qforte.build_circuit('Y_0 Y_1 X_2 Z_3 Z_4 Z_5 Z_6 X_7'), qforte.build_circuit('X_0 Y_1 Y_2 Z_3 Z_4 Z_5 Z_6 X_7'), qforte.build_circuit('Y_0 X_1 X_6 Y_7'), qforte.build_circuit('X_0 X_1 Y_6 Y_7'), qforte.build_circuit('Y_0 Y_1 X_6 X_7'), qforte.build_circuit('X_0 Y_1 Y_6 X_7'), qforte.build_circuit('Z_0 Z_2'), qforte.build_circuit('Z_0 Y_2 Z_3 Z_4 Z_5 Y_6'), qforte.build_circuit('Z_0 X_2 Z_3 Z_4 Z_5 X_6'), qforte.build_circuit('Y_0 Z_1 Z_3 Y_4'), qforte.build_circuit('X_0 Z_1 Z_3 X_4'), qforte.build_circuit('Y_0 Z_1 X_2 X_4 Z_5 Y_6'), qforte.build_circuit('X_0 Z_1 X_2 X_4 Z_5 X_6'), qforte.build_circuit('X_0 Z_1 X_2 Y_4 Z_5 Y_6'), qforte.build_circuit('Y_0 Z_1 Y_2 X_4 Z_5 X_6'), qforte.build_circuit('Y_0 Z_1 Y_2 Y_4 Z_5 Y_6'), qforte.build_circuit('X_0 Z_1 Y_2 Y_4 Z_5 X_6'), qforte.build_circuit('Z_0 Z_3'), qforte.build_circuit('Y_0 Z_1 Z_2 Y_4'), qforte.build_circuit('X_0 Z_1 Z_2 X_4'), qforte.build_circuit('Y_0 Z_1 Y_2 Y_3 Z_4 Y_5'), qforte.build_circuit('X_0 Z_1 X_2 Y_3 Z_4 Y_5'), qforte.build_circuit('Y_0 Z_1 Y_2 X_3 Z_4 X_5'), qforte.build_circuit('X_0 Z_1 X_2 X_3 Z_4 X_5'), qforte.build_circuit('Y_0 Z_1 Z_2 X_3 X_5 Y_6'), qforte.build_circuit('X_0 Z_1 Z_2 X_3 X_5 X_6'), qforte.build_circuit('Y_0 Z_1 Z_2 Y_3 Y_5 Y_6'), qforte.build_circuit('X_0 Z_1 Z_2 Y_3 Y_5 X_6'), qforte.build_circuit('Z_0 Y_3 Z_4 Z_5 Z_6 Y_7'), qforte.build_circuit('Z_0 X_3 Z_4 Z_5 Z_6 X_7'), qforte.build_circuit('Y_0 Z_1 Z_2 X_3 X_4 Z_5 Z_6 Y_7'), qforte.build_circuit('X_0 Z_1 Z_2 X_3 Y_4 Z_5 Z_6 Y_7'), qforte.build_circuit('Y_0 Z_1 Z_2 Y_3 X_4 Z_5 Z_6 X_7'), qforte.build_circuit('X_0 Z_1 Z_2 Y_3 Y_4 Z_5 Z_6 X_7'), qforte.build_circuit('Z_0 Z_4'), qforte.build_circuit('Z_0 Z_5'), qforte.build_circuit('Y_0 Z_1 Z_2 Z_3 Y_4 Z_5'), qforte.build_circuit('X_0 Z_1 Z_2 Z_3 X_4 Z_5'), qforte.build_circuit('Y_0 Z_1 Y_2 Y_5 Z_6 Y_7'), qforte.build_circuit('X_0 Z_1 X_2 Y_5 Z_6 Y_7'), qforte.build_circuit('Y_0 Z_1 Y_2 X_5 Z_6 X_7'), qforte.build_circuit('X_0 Z_1 X_2 X_5 Z_6 X_7'), qforte.build_circuit('Y_0 Z_1 Z_2 Z_3 Z_4 X_5 X_6 Y_7'), qforte.build_circuit('X_0 Z_1 Z_2 Z_3 Z_4 X_5 Y_6 Y_7'), qforte.build_circuit('Y_0 Z_1 Z_2 Z_3 Z_4 Y_5 X_6 X_7'), qforte.build_circuit('X_0 Z_1 Z_2 Z_3 Z_4 Y_5 Y_6 X_7'), qforte.build_circuit('Z_0 Z_6'), qforte.build_circuit('Y_0 Z_1 Z_2 Z_3 Y_4 Z_6'), qforte.build_circuit('X_0 Z_1 Z_2 Z_3 X_4 Z_6'), qforte.build_circuit('Z_0 Z_7'), qforte.build_circuit('Y_0 Z_1 Z_2 Z_3 Y_4 Z_7'), qforte.build_circuit('X_0 Z_1 Z_2 Z_3 X_4 Z_7'), qforte.build_circuit('Z_1 Z_2'), qforte.build_circuit('Y_1 Z_3 Z_4 Y_5'), qforte.build_circuit('X_1 Z_3 Z_4 X_5'), qforte.build_circuit('Y_1 X_2 X_3 Y_4'), qforte.build_circuit('X_1 X_2 Y_3 Y_4'), qforte.build_circuit('Y_1 Y_2 X_3 X_4'), qforte.build_circuit('X_1 Y_2 Y_3 X_4'), qforte.build_circuit('Y_1 X_2 X_4 Z_5 Z_6 Y_7'), qforte.build_circuit('X_1 X_2 X_4 Z_5 Z_6 X_7'), qforte.build_circuit('Y_1 Y_2 Y_4 Z_5 Z_6 Y_7'), qforte.build_circuit('X_1 Y_2 Y_4 Z_5 Z_6 X_7'), qforte.build_circuit('Z_1 Y_2 Z_3 Z_4 Z_5 Y_6'), qforte.build_circuit('Z_1 X_2 Z_3 Z_4 Z_5 X_6'), qforte.build_circuit('Y_1 X_2 X_5 Y_6'), qforte.build_circuit('X_1 X_2 Y_5 Y_6'), qforte.build_circuit('Y_1 Y_2 X_5 X_6'), qforte.build_circuit('X_1 Y_2 Y_5 X_6'), qforte.build_circuit('Z_1 Z_3'), qforte.build_circuit('Z_1 Y_3 Z_4 Z_5 Z_6 Y_7'), qforte.build_circuit('Z_1 X_3 Z_4 Z_5 Z_6 X_7'), qforte.build_circuit('Y_1 Z_2 Z_4 Y_5'), qforte.build_circuit('X_1 Z_2 Z_4 X_5'), qforte.build_circuit('Y_1 Z_2 X_3 X_5 Z_6 Y_7'), qforte.build_circuit('X_1 Z_2 X_3 X_5 Z_6 X_7'), qforte.build_circuit('X_1 Z_2 X_3 Y_5 Z_6 Y_7'), qforte.build_circuit('Y_1 Z_2 Y_3 X_5 Z_6 X_7'), qforte.build_circuit('Y_1 Z_2 Y_3 Y_5 Z_6 Y_7'), qforte.build_circuit('X_1 Z_2 Y_3 Y_5 Z_6 X_7'), qforte.build_circuit('Z_1 Z_4'), qforte.build_circuit('Y_1 Z_2 Z_3 Y_5'), qforte.build_circuit('X_1 Z_2 Z_3 X_5'), qforte.build_circuit('Y_1 Z_2 Y_3 Y_4 Z_5 Y_6'), qforte.build_circuit('X_1 Z_2 X_3 Y_4 Z_5 Y_6'), qforte.build_circuit('Y_1 Z_2 Y_3 X_4 Z_5 X_6'), qforte.build_circuit('X_1 Z_2 X_3 X_4 Z_5 X_6'), qforte.build_circuit('Y_1 Z_2 Z_3 X_4 X_6 Y_7'), qforte.build_circuit('X_1 Z_2 Z_3 X_4 X_6 X_7'), qforte.build_circuit('Y_1 Z_2 Z_3 Y_4 Y_6 Y_7'), qforte.build_circuit('X_1 Z_2 Z_3 Y_4 Y_6 X_7'), qforte.build_circuit('Z_1 Z_5'), qforte.build_circuit('Z_1 Z_6'), qforte.build_circuit('Y_1 Z_2 Z_3 Z_4 Y_5 Z_6'), qforte.build_circuit('X_1 Z_2 Z_3 Z_4 X_5 Z_6'), qforte.build_circuit('Z_1 Z_7'), qforte.build_circuit('Y_1 Z_2 Z_3 Z_4 Y_5 Z_7'), qforte.build_circuit('X_1 Z_2 Z_3 Z_4 X_5 Z_7'), qforte.build_circuit('Z_2 Z_3'), qforte.build_circuit('Y_2 Z_4 Z_5 Y_6'), qforte.build_circuit('X_2 Z_4 Z_5 X_6'), qforte.build_circuit('Y_2 X_3 X_4 Y_5'), qforte.build_circuit('X_2 X_3 Y_4 Y_5'), qforte.build_circuit('Y_2 Y_3 X_4 X_5'), qforte.build_circuit('X_2 Y_3 Y_4 X_5'), qforte.build_circuit('Z_2 Y_3 Z_4 Z_5 Z_6 Y_7'), qforte.build_circuit('Z_2 X_3 Z_4 Z_5 Z_6 X_7'), qforte.build_circuit('Y_2 X_3 X_6 Y_7'), qforte.build_circuit('X_2 X_3 Y_6 Y_7'), qforte.build_circuit('Y_2 Y_3 X_6 X_7'), qforte.build_circuit('X_2 Y_3 Y_6 X_7'), qforte.build_circuit('Z_2 Z_4'), qforte.build_circuit('Y_2 Z_3 Z_5 Y_6'), qforte.build_circuit('X_2 Z_3 Z_5 X_6'), qforte.build_circuit('Z_2 Z_5'), qforte.build_circuit('Y_2 Z_3 Z_4 Y_6'), qforte.build_circuit('X_2 Z_3 Z_4 X_6'), qforte.build_circuit('Y_2 Z_3 Y_4 Y_5 Z_6 Y_7'), qforte.build_circuit('X_2 Z_3 X_4 Y_5 Z_6 Y_7'), qforte.build_circuit('Y_2 Z_3 Y_4 X_5 Z_6 X_7'), qforte.build_circuit('X_2 Z_3 X_4 X_5 Z_6 X_7'), qforte.build_circuit('Z_2 Z_6'), qforte.build_circuit('Z_2 Z_7'), qforte.build_circuit('Y_2 Z_3 Z_4 Z_5 Y_6 Z_7'), qforte.build_circuit('X_2 Z_3 Z_4 Z_5 X_6 Z_7'), qforte.build_circuit('Z_3 Z_4'), qforte.build_circuit('Y_3 Z_5 Z_6 Y_7'), qforte.build_circuit('X_3 Z_5 Z_6 X_7'), qforte.build_circuit('Y_3 X_4 X_5 Y_6'), qforte.build_circuit('X_3 X_4 Y_5 Y_6'), qforte.build_circuit('Y_3 Y_4 X_5 X_6'), qforte.build_circuit('X_3 Y_4 Y_5 X_6'), qforte.build_circuit('Z_3 Z_5'), qforte.build_circuit('Y_3 Z_4 Z_6 Y_7'), qforte.build_circuit('X_3 Z_4 Z_6 X_7'), qforte.build_circuit('Z_3 Z_6'), qforte.build_circuit('Y_3 Z_4 Z_5 Y_7'), qforte.build_circuit('X_3 Z_4 Z_5 X_7'), qforte.build_circuit('Z_3 Z_7'), qforte.build_circuit('Z_4 Z_5'), qforte.build_circuit('Y_4 X_5 X_6 Y_7'), qforte.build_circuit('X_4 X_5 Y_6 Y_7'), qforte.build_circuit('Y_4 Y_5 X_6 X_7'), qforte.build_circuit('X_4 Y_5 Y_6 X_7'), qforte.build_circuit('Z_4 Z_6'), qforte.build_circuit('Z_4 Z_7'), qforte.build_circuit('Z_5 Z_6'), qforte.build_circuit('Z_5 Z_7'), qforte.build_circuit('Z_6 Z_7')] coef_vec = [ -0.9398866173443505, 0.12129073807829349, 0.00641125283150221, 0.00641125283150221, 0.12129073807829353, 0.0064112528315022135, 0.0064112528315022135, 0.07308734612725618, -0.010595295586558178, -0.010595295586558178, 0.0730873461272563, -0.010595295586558171, -0.010595295586558171, -0.004903180263267734, -0.0049031802632676785, -0.0972417632017775, -0.09724176320177753, 0.10115751743776852, 0.016853161923367253, 0.016853161923367253, 0.03977035285263866, -0.03977035285263866, -0.03977035285263866, 0.03977035285263866, 0.00905981792020611, 0.00905981792020611, 0.00905981792020611, 0.00905981792020611, 0.016853161923367253, 0.016853161923367253, 0.028827330860814942, -0.028827330860814942, -0.028827330860814942, 0.028827330860814942, -0.00905981792020611, 0.00905981792020611, 0.00905981792020611, -0.00905981792020611, 0.027456714140683562, -0.027456714140683562, -0.027456714140683562, 0.027456714140683562, 0.05019794254014193, 0.008400644724214635, 0.008400644724214635, 0.01678679876377047, 0.01678679876377047, 0.008370670304957601, 0.019986723846961468, 0.011616053542003863, 0.011616053542003863, 0.019986723846961468, 0.008370670304957601, 0.08996829539278059, -0.00401664635059683, -0.00401664635059683, 0.020803445114367297, 0.020803445114367297, 0.020803445114367297, 0.020803445114367297, -0.020045295426307817, -0.020045295426307817, -0.020045295426307817, -0.020045295426307817, 0.01746046264442075, 0.01746046264442075, 0.028415965731265418, -0.028415965731265418, -0.028415965731265418, 0.028415965731265418, 0.062364797002734416, 0.09119212786354935, -0.0029292718691351837, -0.0029292718691351837, 0.040032019273269284, 0.040032019273269284, 0.040032019273269284, 0.040032019273269284, -0.008895760438436422, 0.008895760438436422, 0.008895760438436422, -0.008895760438436422, 0.077813400984472, 0.008622786573744252, 0.008622786573744252, 0.10527011512515555, 0.017518547012180676, 0.017518547012180676, 0.08996829539278059, -0.00401664635059683, -0.00401664635059683, 0.020803445114367297, -0.020803445114367297, -0.020803445114367297, 0.020803445114367297, -0.020045295426307817, -0.020045295426307817, -0.020045295426307817, -0.020045295426307817, 0.01746046264442075, 0.01746046264442075, 0.028415965731265418, -0.028415965731265418, -0.028415965731265418, 0.028415965731265418, 0.05019794254014193, 0.008400644724214635, 0.008400644724214635, 0.01678679876377047, 0.01678679876377047, 0.008370670304957601, 0.019986723846961468, 0.011616053542003863, 0.011616053542003863, 0.019986723846961468, 0.008370670304957601, 0.09119212786354935, -0.0029292718691351837, -0.0029292718691351837, 0.040032019273269284, 0.040032019273269284, 0.040032019273269284, 0.040032019273269284, 0.008895760438436422, 0.008895760438436422, 0.008895760438436422, 0.008895760438436422, 0.062364797002734416, 0.10527011512515555, 0.017518547012180676, 0.017518547012180676, 0.077813400984472, 0.008622786573744252, 0.008622786573744252, 0.09416046345893181, -0.0025909758017290006, -0.0025909758017290006, 0.035233425879700006, -0.035233425879700006, -0.035233425879700006, 0.035233425879700006, -0.0025909758017290006, -0.0025909758017290006, 0.029476085351951252, -0.029476085351951252, -0.029476085351951252, 0.029476085351951252, 0.05898073895378817, 0.018463477774636035, 0.018463477774636035, 0.09421416483348818, -0.003276374161489622, -0.003276374161489622, 0.02173985193612566, 0.02173985193612566, 0.02173985193612566, 0.02173985193612566, 0.06484557443787466, 0.0943216597898259, 0.01867832322072119, 0.01867832322072119, 0.09421416483348818, -0.003276374161489622, -0.003276374161489622, 0.02173985193612566, -0.02173985193612566, -0.02173985193612566, 0.02173985193612566, 0.05898073895378817, 0.018463477774636035, 0.018463477774636035, 0.0943216597898259, 0.01867832322072119, 0.01867832322072119, 0.06484557443787466, 0.0970891982291751, 0.042405629926062886, -0.042405629926062886, -0.042405629926062886, 0.042405629926062886, 0.05395287215237218, 0.09635850207843506, 0.09635850207843506, 0.05395287215237218, 0.11278693858600855] H4_qubit_hamiltonian = qforte.QuantumOperator() for i in range(len(circ_vec)): H4_qubit_hamiltonian.add_term(coef_vec[i], circ_vec[i]) ref = [1,1,1,1,0,0,0,0] # make test with algorithm class mol = Molecule() mol.set_hamiltonian(H4_qubit_hamiltonian) # SRQK alg1 = SRQK(mol, reference=ref, trotter_number=1, fast=False) alg1.run(s=3) Egs1 = alg1.get_gs_energy() Egs1_fast = -1.9982299799 self.assertLess(abs(Egs1-Egs1_fast), 1.0e-9)