def test_h2_one_qubit(self): """Test H2 with tapering.""" two_qubit_reduction = False qubit_mapping = 'jordan_wigner' core = Hamiltonian(transformation=TransformationType.FULL, qubit_mapping=QubitMappingType.JORDAN_WIGNER, two_qubit_reduction=two_qubit_reduction, freeze_core=False, orbital_reduction=[]) qubit_op, _ = core.run(self.molecule) num_orbitals = core.molecule_info['num_orbitals'] num_particles = core.molecule_info['num_particles'] z2_symmetries = Z2Symmetries.find_Z2_symmetries(qubit_op) tapered_op = z2_symmetries.taper(qubit_op)[5] eom_ee = QEomEE(tapered_op, num_orbitals=num_orbitals, num_particles=num_particles, qubit_mapping=qubit_mapping, two_qubit_reduction=two_qubit_reduction, z2_symmetries=tapered_op.z2_symmetries, untapered_op=qubit_op) result = eom_ee.run() np.testing.assert_array_almost_equal(self.reference, result['energies'])
def test_h2_two_qubits(self): """Test H2 with parity mapping.""" two_qubit_reduction = True qubit_mapping = 'parity' warnings.filterwarnings('ignore', category=DeprecationWarning) core = Hamiltonian(transformation=TransformationType.FULL, qubit_mapping=QubitMappingType.PARITY, two_qubit_reduction=two_qubit_reduction, freeze_core=False, orbital_reduction=[]) warnings.filterwarnings('always', category=DeprecationWarning) qubit_op, _ = core.run(self.molecule) num_orbitals = core.molecule_info['num_orbitals'] num_particles = core.molecule_info['num_particles'] eom_ee = QEomEE(qubit_op, num_orbitals=num_orbitals, num_particles=num_particles, qubit_mapping=qubit_mapping, two_qubit_reduction=two_qubit_reduction) result = eom_ee.run() np.testing.assert_array_almost_equal(self.reference, result['energies'])
def test_h2_four_qubits(self): """Test H2 with jordan wigner.""" two_qubit_reduction = False qubit_mapping = 'jordan_wigner' core = Hamiltonian(transformation=TransformationType.FULL, qubit_mapping=QubitMappingType.JORDAN_WIGNER, two_qubit_reduction=two_qubit_reduction, freeze_core=False, orbital_reduction=[]) qubit_op, _ = core.run(self.molecule) num_orbitals = core.molecule_info['num_orbitals'] num_particles = core.molecule_info['num_particles'] eom_ee = QEomEE(qubit_op, num_orbitals=num_orbitals, num_particles=num_particles, qubit_mapping=qubit_mapping, two_qubit_reduction=two_qubit_reduction) result = eom_ee.run() np.testing.assert_array_almost_equal(self.reference, result['energies'])