def test_uccsd_hf_qUCCD0full(self): """singlet full uccd test""" optimizer = SLSQP(maxiter=100) initial_state = HartreeFock(self.num_spin_orbitals, self.num_particles, self.qubit_converter) # TODO: add `full` option ansatz = SUCCD( self.qubit_converter, self.num_particles, self.num_spin_orbitals, initial_state=initial_state, ) solver = VQE( ansatz=ansatz, optimizer=optimizer, quantum_instance=QuantumInstance( backend=BasicAer.get_backend("statevector_simulator")), ) gsc = GroundStateEigensolver(self.qubit_converter, solver) result = gsc.solve(self.electronic_structure_problem) self.assertAlmostEqual(result.total_energies[0], self.reference_energy_UCCD0full, places=6)
def test_uccsd_hf_qUCCD0(self): """singlet uccd test""" self.skipTest( "Temporarily skip test until the changes done by " "https://github.com/Qiskit/qiskit-terra/pull/7551 are handled properly." ) optimizer = SLSQP(maxiter=100) initial_state = HartreeFock(self.num_spin_orbitals, self.num_particles, self.qubit_converter) ansatz = SUCCD( self.qubit_converter, self.num_particles, self.num_spin_orbitals, initial_state=initial_state, ) solver = VQE( ansatz=ansatz, optimizer=optimizer, quantum_instance=QuantumInstance( backend=BasicAer.get_backend("statevector_simulator")), ) gsc = GroundStateEigensolver(self.qubit_converter, solver) result = gsc.solve(self.electronic_structure_problem) self.assertAlmostEqual(result.total_energies[0], self.reference_energy_UCCD0, places=6)
def test_succd_ansatz(self, num_spin_orbitals, num_particles, expect): """Tests the SUCCD Ansatz.""" converter = QubitConverter(JordanWignerMapper()) ansatz = SUCCD(qubit_converter=converter, num_particles=num_particles, num_spin_orbitals=num_spin_orbitals) assert_ucc_like_ansatz(self, ansatz, num_spin_orbitals, expect)
def test_succd_ansatz_with_singles(self, num_spin_orbitals, num_particles, include_singles, expect): """Tests the SUCCD Ansatz with included single excitations.""" converter = QubitConverter(JordanWignerMapper()) ansatz = SUCCD(qubit_converter=converter, num_particles=num_particles, num_spin_orbitals=num_spin_orbitals, include_singles=include_singles) assert_ucc_like_ansatz(self, ansatz, num_spin_orbitals, expect)
def test_raise_non_singlet(self): """Test an error is raised when the number of alpha and beta electrons differ.""" with self.assertRaises(QiskitNatureError): SUCCD(num_particles=(2, 1))