qc2.algorithms.qiskit.pebase ============================ .. py:module:: qc2.algorithms.qiskit.pebase .. autoapi-nested-parse:: Module defining the QPE algorithm for qiskit Classes ------- .. autoapisummary:: qc2.algorithms.qiskit.pebase.PEBase Module Contents --------------- .. py:class:: PEBase(qc2data=None, active_space=None, mapper=None, sampler=None, reference_state=None, verbose=0) Bases: :py:obj:`qc2.algorithms.base.base_algorithm.BaseAlgorithm` .. py:attribute:: qc2data :value: None .. py:attribute:: format :value: 'qiskit' .. py:attribute:: verbose :value: 0 .. py:attribute:: solver :value: None .. py:attribute:: active_space .. py:attribute:: mapper .. py:attribute:: qubits .. py:attribute:: electrons .. py:attribute:: reference_state .. py:attribute:: sampler .. py:method:: _get_default_reference(active_space: qc2.algorithms.utils.active_space.ActiveSpace, mapper: qiskit_nature.second_q.mappers.QubitMapper) -> qiskit.QuantumCircuit :staticmethod: Set up the default reference state circuit based on Hartree Fock. :param active_space: description of the active space. :type active_space: ActiveSpace :param mapper: mapper class instance. :type mapper: mapper :returns: Hartree-Fock circuit as the reference state. :rtype: QuantumCircuit .. py:method:: _init_qubit_hamiltonian() .. py:method:: _phase_to_energy(phase: float) -> float :staticmethod: Convert a phase from 0 to 1 to an energy from -pi to pi. :param phase: The phase to convert. :type phase: float :returns: The energy corresponding to the given phase. :rtype: float .. py:method:: run() -> qc2.algorithms.algorithms_results.QPEResults Executes the Quantum Phase Estimation (QPE) algorithm to estimate the energy of the electronic ground state of a molecule. Initializes the qubit Hamiltonian, constructs the unitary matrix, runs the QPE algorithm, and calculates the phase and energy. The results are encapsulated in a `QPEResults` object. :returns: An instance of the `QPEResults` class containing the optimal energy, eigenvalue, and phase obtained from the QPE algorithm. :rtype: QPEResults **Example** >>> from ase.build import molecule >>> from qc2.ase import PySCF >>> from qc2.data import qc2Data >>> from qc2.algorithms.qiskit import QPE >>> from qc2.algorithms.utils import ActiveSpace >>> >>> mol = molecule('H2O') >>> >>> hdf5_file = 'h2o.hdf5' >>> qc2data = qc2Data(hdf5_file, mol, schema='qcschema') >>> qc2data.molecule.calc = PySCF() >>> qc2data.run() >>> qc2data.algorithm = QPE( ... active_space=ActiveSpace( ... num_active_electrons=(2, 2), ... num_active_spatial_orbitals=4 ... ), ... mapper='parity', ... num_evaluation_qubits=9 ... ) >>> results = qc2data.algorithm.run()