qc2.algorithms.qiskit.pebase

Module defining the QPE algorithm for qiskit

Classes

PEBase

Module Contents

class qc2.algorithms.qiskit.pebase.PEBase(qc2data=None, active_space=None, mapper=None, sampler=None, reference_state=None, verbose=0)[source]

Bases: qc2.algorithms.base.base_algorithm.BaseAlgorithm

qc2data = None[source]
format = 'qiskit'[source]
verbose = 0[source]
solver = None[source]
active_space[source]
mapper[source]
qubits[source]
electrons[source]
reference_state[source]
sampler[source]
static _get_default_reference(active_space: qc2.algorithms.utils.active_space.ActiveSpace, mapper: qiskit_nature.second_q.mappers.QubitMapper) qiskit.QuantumCircuit[source]

Set up the default reference state circuit based on Hartree Fock.

Parameters:
  • active_space (ActiveSpace) – description of the active space.

  • mapper (mapper) – mapper class instance.

Returns:

Hartree-Fock circuit as the reference state.

Return type:

QuantumCircuit

_init_qubit_hamiltonian()[source]
static _phase_to_energy(phase: float) float[source]

Convert a phase from 0 to 1 to an energy from -pi to pi.

Parameters:

phase (float) – The phase to convert.

Returns:

The energy corresponding to the given phase.

Return type:

float

run() qc2.algorithms.algorithms_results.QPEResults[source]

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.

Return type:

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()