odho.setup_system(potential=HOPotential(omega), add_spin=True) one_body = odho.h one_body[np.absolute(one_body) < 1e-8] = 0 two_body = odho.u two_body[np.absolute(two_body) < 1e-8] = 0 # Coupled Cluster print('Reference energy:', odho.compute_reference_energy()) ccsd = CCSD(odho, verbose=False) ccsd.compute_ground_state() print('ECCSD =', ccsd.compute_energy()) # Prepare circuit list H2 = SecondQuantizedHamiltonian(n, l) H2.set_integrals(one_body, two_body, anti_symmetric=True) H2.get_circuit() circuit_list = H2.to_circuit_list(ptype='vqe') ansatz = UnitaryCoupledCluster(n, l, 'S', 1) og_params = ansatz.new_parameters(H2.h, H2.v) print(ansatz.num_S) print(ansatz.num_D) print(len(og_params)) grid_points = 500 x = np.linspace(0, 2 * np.pi, grid_points) params = [[i] for i in x] Es = np.zeros(grid_points) theta = og_params
# Matrix elements h_pq = np.identity(l) for p in range(l): h_pq[p, p] *= delta * (p - (p % 2)) / 2 h_pqrs = np.zeros((l, l, l, l)) for p in range(0, l - 1, 2): for r in range(0, l - 1, 2): h_pqrs[p, p + 1, r, r + 1] = -0.5 * g UCCD = UnitaryCoupledCluster(n, l, 'D', 1) theta = UCCD.new_parameters() theta[0] = 5.829889373194686 # Hardcode good parameter Pairing = SecondQuantizedHamiltonian(n, l) Pairing.set_integrals(h_pq, h_pqrs) Pairing.get_circuit() circuit_list = Pairing.to_circuit_list(ptype='vqe') all_shots = np.linspace(1000, 100000, 100) Es = np.zeros(100) legal = np.zeros(100) illegal = np.zeros(100) i = 0 for shot in tqdm(all_shots): model = VQE( n_qubits=l, ansatz=UCCD, circuit_list=circuit_list, shots=500, #int(shot),