81 lines
12 KiB
Plaintext
81 lines
12 KiB
Plaintext
---
|
||
title: chemistry (v0.26)
|
||
description: API reference for qiskit.chemistry in qiskit v0.26
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: qiskit.chemistry
|
||
---
|
||
|
||
<span id="module-qiskit.chemistry" />
|
||
|
||
<span id="qiskit-chemistry" />
|
||
|
||
<span id="qiskit-s-chemistry-module-qiskit-chemistry" />
|
||
|
||
# Qiskit’s chemistry module
|
||
|
||
`qiskit.chemistry`
|
||
|
||
This is Qiskit’s chemistry module that provides for experimentation with chemistry domain problems such as ground state energy and excited state energies of molecules.
|
||
|
||
## Overview
|
||
|
||
This is an overview of the workings of the chemistry module and how it may be used. There are different levels of exposure to its functionality, allowing for experimentation at different abstractions. The outline below starts with the flow that provides the most control of the process.
|
||
|
||
A classical chemistry driver is first instantiated, from the available [`drivers`](qiskit.chemistry.drivers#module-qiskit.chemistry.drivers "qiskit.chemistry.drivers"), by means of a molecule specification, along with other configuration such as basis set and method (RHF, ROHF, UHF). This configuration may include custom settings for the specific driver for more custom control over the driver’s behavior. When the driver is run the output is a mostly driver independent [`QMolecule`](qiskit.chemistry.QMolecule "qiskit.chemistry.QMolecule"). This contains various quantities that were computed including one and two-body electron integrals that are used as input [`FermionicOperator`](qiskit.chemistry.FermionicOperator "qiskit.chemistry.FermionicOperator"). Mostly driver independent means that these integrals, for example, will be there from every driver but the values may differ due to how each underlying chemistry library/program computes them. Also some fields in the QMolecule may not be populated by all drivers, for instance dipole integrals are not output from the PyQuante driver, and hence the dipole moment cannot be computed by qiskit.chemistry when using this driver. The FermionicOperator once created can then be converted/mapped to a qubit operator for use as input to an Aqua algorithms. The operator must be in qubit form at this stage since the execution target of the algorithm will be a quantum device, or simulator ,comprised of qubits and the mapping is needed as qubits behave differently than fermions. Once the algorithm is run it will compute the electronic part of the quantity, such as the electronic ground state energy. To get the total ground state energy this can be combined with the nuclear repulsion energy in the QMolecule.
|
||
|
||
Instead of using the FermionicOperator the [`core.Hamiltonian`](qiskit.chemistry.core.Hamiltonian "qiskit.chemistry.core.Hamiltonian") may be used. This itself uses the FermionicOperator but provides a higher level of function to simplify use. For instance the FermionicOperator supports particle-hole transformation and different mappings. And to compute dipole moments each of the X, Y and Z dipole integrals must be prepared, as individual FermionicOperators, in a like manner to the main electronic energy one, i.e. same transformations, and eventually same qubit mapping. The core.Hamiltonian class does all this and more, such as orbital reductions, frozen core and automatic symmetry reduction. When run with a QMolecule output from a driver it produces qubit operators that can be given directly to Aqua algorithms for the computation. Also available are several properties, such as number of particles and number of orbitals, that are needed to correctly instantiate chemistry specific components such as [`UCCSD`](qiskit.chemistry.components.variational_forms.UCCSD "qiskit.chemistry.components.variational_forms.UCCSD") and [`HartreeFock`](qiskit.chemistry.components.initial_states.HartreeFock "qiskit.chemistry.components.initial_states.HartreeFock"). Using the FermionicOperator directly requires taking the initial values for the QMolecule and then keeping track of any changes based on any orbital elimination and/or freezing, and/or Z2Symmetry reductions that are done. Once the output qubit operators have been used with an Aqua algorithm, to compute the electronic result, this result can be fed back to the core.Hamiltonian, to [`process_algorithm_result()`](qiskit.chemistry.core.Hamiltonian#process_algorithm_result "qiskit.chemistry.core.Hamiltonian.process_algorithm_result") which will then compute a final total result including a user friendly formatted text result that may be printed.
|
||
|
||
Lastly the chemistry [`applications`](qiskit.chemistry.applications#module-qiskit.chemistry.applications "qiskit.chemistry.applications") may be used. These are given a chemistry driver and, in the case of [`MolecularGroundStateEnergy`](qiskit.chemistry.applications.MolecularGroundStateEnergy "qiskit.chemistry.applications.MolecularGroundStateEnergy") an optional instance of an Aqua [`MinimumEigensolver`](qiskit.aqua.algorithms.MinimumEigensolver "qiskit.aqua.algorithms.MinimumEigensolver"), such as [`VQE`](qiskit.aqua.algorithms.VQE "qiskit.aqua.algorithms.VQE"). Optional since components such as [`UCCSD`](qiskit.chemistry.components.variational_forms.UCCSD "qiskit.chemistry.components.variational_forms.UCCSD") need certain information that may be unknown at this point. So alternatively, when its method [`compute_energy()`](qiskit.chemistry.applications.MolecularGroundStateEnergy#compute_energy "qiskit.chemistry.applications.MolecularGroundStateEnergy.compute_energy") is run a callback can be provided which will later be passed information, such as number of particles and orbitals, and allow a complete MinimumEigensolver to be built using say UCCSD with HartreeFock, and subsequently returned to the application and run. MinimumEigensolver itself uses the core.Hamiltonian class wrapping it to form this high level application.
|
||
|
||
### Mappings
|
||
|
||
To map the FermionicOperator to a qubit operator the chemistry module supports the following mappings:
|
||
|
||
**Jordan Wigner**
|
||
|
||
The [Jordan-Wigner transformation](https://rd.springer.com/article/10.1007%2FBF01331938), maps spin operators onto fermionic creation and annihilation operators. It was proposed by Ernst Pascual Jordan and Eugene Paul Wigner for one-dimensional lattice models, but now two-dimensional analogues of the transformation have also been created. The Jordan–Wigner transformation is often used to exactly solve 1D spin-chains by transforming the spin operators to fermionic operators and then diagonalizing in the fermionic basis.
|
||
|
||
**Parity**
|
||
|
||
The [parity-mapping transformation](https://arxiv.org/abs/1701.08213). optimizes encodings of fermionic many-body systems by qubits in the presence of symmetries. Such encodings eliminate redundant degrees of freedom in a way that preserves a simple structure of the system Hamiltonian enabling quantum simulations with fewer qubits.
|
||
|
||
**Bravyi-Kitaev**
|
||
|
||
Also known as *binary-tree-based qubit mapping*, the [Bravyi-Kitaev transformation](https://www.sciencedirect.com/science/article/pii/S0003491602962548) is a method of mapping the occupation state of a fermionic system onto qubits. This transformation maps the Hamiltonian of $n$ interacting fermions to an $\mathcal{O}(\log n)$ local Hamiltonian of $n$ qubits. This is an improvement in locality over the Jordan–Wigner transformation, which results in an $\mathcal{O}(n)$ local qubit Hamiltonian. The Bravyi–Kitaev transformation was proposed by Sergey B. Bravyi and Alexei Yu. Kitaev.
|
||
|
||
**Bravyi-Kitaev Superfast**
|
||
|
||
[Bravyi-Kitaev Superfast (BKSF)](https://aip.scitation.org/doi/10.1063/1.5019371) algorithm is a mapping from fermionic operators to qubit operators. BKSF algorithm defines an abstract model where the fermionic modes are mapped to vertices of an interaction graph. The edges of the graph correspond to the interaction between the modes. The graph can be constructed from the Hamiltonian. The simulation is done by putting qubits on the edges of the graph. Each fermionic operator costs $\mathcal{O}(d)$ qubit operations, where $d$ is the degree of the interaction graph. The BKSF was proposed by Kanav Setia and James D. Whitfield.
|
||
|
||
The classes and submodules of qiskit.chemistry are now listed for reference:
|
||
|
||
## Chemistry Error
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
||
| [`QiskitChemistryError`](qiskit.chemistry.QiskitChemistryError "qiskit.chemistry.QiskitChemistryError") | Class for errors returned by Qiskit’s Chemistry module. |
|
||
|
||
## Chemistry Classes
|
||
|
||
| | |
|
||
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
||
| [`BosonicOperator`](qiskit.chemistry.BosonicOperator "qiskit.chemistry.BosonicOperator") | A set of functions to map bosonic Hamiltonians to qubit Hamiltonians. |
|
||
| [`FermionicOperator`](qiskit.chemistry.FermionicOperator "qiskit.chemistry.FermionicOperator") | A set of functions to map fermionic Hamiltonians to qubit Hamiltonians. |
|
||
| [`QMolecule`](qiskit.chemistry.QMolecule "qiskit.chemistry.QMolecule") | Molecule data class containing driver result. |
|
||
| [`WatsonHamiltonian`](qiskit.chemistry.WatsonHamiltonian "qiskit.chemistry.WatsonHamiltonian") | Watson Hamiltonian class containing the results of a driver’s anharmonic calculation |
|
||
| [`MP2Info`](qiskit.chemistry.MP2Info "qiskit.chemistry.MP2Info") | A utility class for Moller-Plesset 2nd order (MP2) information |
|
||
|
||
## Submodules
|
||
|
||
| | |
|
||
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||
| [`algorithms`](qiskit.chemistry.algorithms#module-qiskit.chemistry.algorithms "qiskit.chemistry.algorithms") | Chemistry specific Aqua algorithms ([`qiskit.chemistry.algorithms`](qiskit.chemistry.algorithms#module-qiskit.chemistry.algorithms "qiskit.chemistry.algorithms")) |
|
||
| [`applications`](qiskit.chemistry.applications#module-qiskit.chemistry.applications "qiskit.chemistry.applications") | Chemistry Applications ([`qiskit.chemistry.applications`](qiskit.chemistry.applications#module-qiskit.chemistry.applications "qiskit.chemistry.applications")) |
|
||
| [`components`](qiskit.chemistry.components#module-qiskit.chemistry.components "qiskit.chemistry.components") | Chemistry Components ([`qiskit.chemistry.components`](qiskit.chemistry.components#module-qiskit.chemistry.components "qiskit.chemistry.components")) |
|
||
| [`core`](qiskit.chemistry.core#module-qiskit.chemistry.core "qiskit.chemistry.core") | Chemistry Core ([`qiskit.chemistry.core`](qiskit.chemistry.core#module-qiskit.chemistry.core "qiskit.chemistry.core")) |
|
||
| [`drivers`](qiskit.chemistry.drivers#module-qiskit.chemistry.drivers "qiskit.chemistry.drivers") | Chemistry Drivers ([`qiskit.chemistry.drivers`](qiskit.chemistry.drivers#module-qiskit.chemistry.drivers "qiskit.chemistry.drivers")) |
|
||
| [`results`](qiskit.chemistry.results#module-qiskit.chemistry.results "qiskit.chemistry.results") | Chemistry Results ([`qiskit.chemistry.results`](qiskit.chemistry.results#module-qiskit.chemistry.results "qiskit.chemistry.results")) |
|
||
| [`transformations`](qiskit.chemistry.transformations#module-qiskit.chemistry.transformations "qiskit.chemistry.transformations") | Qubit Transformations ([`qiskit.chemistry.transformations`](qiskit.chemistry.transformations#module-qiskit.chemistry.transformations "qiskit.chemistry.transformations")) |
|
||
|