qiskit-documentation/docs/api/qiskit/0.24/qiskit.chemistry.FermionicO...

242 lines
14 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: FermionicOperator
description: API reference for qiskit.chemistry.FermionicOperator
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.chemistry.FermionicOperator
---
<span id="qiskit-chemistry-fermionicoperator" />
# qiskit.chemistry.FermionicOperator
<Class id="qiskit.chemistry.FermionicOperator" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.8/qiskit/chemistry/fermionic_operator.py" signature="FermionicOperator(h1, h2=None, ph_trans_shift=None)" modifiers="class">
A set of functions to map fermionic Hamiltonians to qubit Hamiltonians.
References:
* *E. Wigner and P. Jordan., Über das Paulische Äquivalenzverbot, Z. Phys., 47:631 (1928).*
* *S. Bravyi and A. Kitaev. Fermionic quantum computation, Ann. of Phys., 298(1):210226 (2002).*
* *A. Tranter, S. Sofia, J. Seeley, M. Kaicher, J. McClean, R. Babbush, P. Coveney, F. Mintert, F. Wilhelm, and P. Love. The BravyiKitaev transformation: Properties and applications. Int. Journal of Quantum Chemistry, 115(19):14311441 (2015).*
* *S. Bravyi, J. M. Gambetta, A. Mezzacapo, and K. Temme, arXiv e-print arXiv:1701.08213 (2017).*
* *K. Setia, J. D. Whitfield, arXiv:1712.00446 (2017)*
This class requires the integrals stored in the *chemist* notation
> h2(i,j,k,l) > adag\_i adag\_k a\_l a\_j
and the integral values are used for the coefficients of the second-quantized Hamiltonian that is built. The integrals input here should be in block spin format and also have indexes reordered as follows ijkl->ljik
There is another popular notation, the *physicist* notation
> h2(i,j,k,l) > adag\_i adag\_j a\_k a\_l
If you are using the *physicist* notation, you need to convert it to the *chemist* notation. E.g. h2=numpy.einsum(ikmj->ijkm, h2)
The [`QMolecule`](qiskit.chemistry.QMolecule "qiskit.chemistry.QMolecule") class has [`one_body_integrals`](qiskit.chemistry.QMolecule#one_body_integrals "qiskit.chemistry.QMolecule.one_body_integrals") and [`two_body_integrals`](qiskit.chemistry.QMolecule#two_body_integrals "qiskit.chemistry.QMolecule.two_body_integrals") properties that can be directly supplied to the h1 and h2 parameters here respectively.
**Parameters**
* **h1** (*numpy.ndarray*) second-quantized fermionic one-body operator, a 2-D (NxN) tensor
* **h2** (*numpy.ndarray*) second-quantized fermionic two-body operator, a 4-D (NxNxNxN) tensor
* **ph\_trans\_shift** (*float*) energy shift caused by particle hole transformation
### \_\_init\_\_
<Function id="qiskit.chemistry.FermionicOperator.__init__" signature="__init__(h1, h2=None, ph_trans_shift=None)">
This class requires the integrals stored in the *chemist* notation
> h2(i,j,k,l) > adag\_i adag\_k a\_l a\_j
and the integral values are used for the coefficients of the second-quantized Hamiltonian that is built. The integrals input here should be in block spin format and also have indexes reordered as follows ijkl->ljik
There is another popular notation, the *physicist* notation
> h2(i,j,k,l) > adag\_i adag\_j a\_k a\_l
If you are using the *physicist* notation, you need to convert it to the *chemist* notation. E.g. h2=numpy.einsum(ikmj->ijkm, h2)
The [`QMolecule`](qiskit.chemistry.QMolecule "qiskit.chemistry.QMolecule") class has [`one_body_integrals`](qiskit.chemistry.QMolecule#one_body_integrals "qiskit.chemistry.QMolecule.one_body_integrals") and [`two_body_integrals`](qiskit.chemistry.QMolecule#two_body_integrals "qiskit.chemistry.QMolecule.two_body_integrals") properties that can be directly supplied to the h1 and h2 parameters here respectively.
**Parameters**
* **h1** (*numpy.ndarray*) second-quantized fermionic one-body operator, a 2-D (NxN) tensor
* **h2** (*numpy.ndarray*) second-quantized fermionic two-body operator, a 4-D (NxNxNxN) tensor
* **ph\_trans\_shift** (*float*) energy shift caused by particle hole transformation
</Function>
## Methods
| | |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`__init__`](#qiskit.chemistry.FermionicOperator.__init__ "qiskit.chemistry.FermionicOperator.__init__")(h1\[, h2, ph\_trans\_shift]) | This class requires the integrals stored in the *chemist* notation |
| [`fermion_mode_elimination`](#qiskit.chemistry.FermionicOperator.fermion_mode_elimination "qiskit.chemistry.FermionicOperator.fermion_mode_elimination")(fermion\_mode\_array) | Eliminate modes. |
| [`fermion_mode_freezing`](#qiskit.chemistry.FermionicOperator.fermion_mode_freezing "qiskit.chemistry.FermionicOperator.fermion_mode_freezing")(fermion\_mode\_array) | Freezing modes and extracting its energy. |
| [`mapping`](#qiskit.chemistry.FermionicOperator.mapping "qiskit.chemistry.FermionicOperator.mapping")(map\_type\[, threshold]) | Map fermionic operator to qubit operator. |
| [`particle_hole_transformation`](#qiskit.chemistry.FermionicOperator.particle_hole_transformation "qiskit.chemistry.FermionicOperator.particle_hole_transformation")(num\_particles) | The standard second quantized Hamiltonian can be transformed in the particle-hole (p/h) picture, which makes the expansion of the trail wavefunction from the HF reference state more natural. |
| [`total_angular_momentum`](#qiskit.chemistry.FermionicOperator.total_angular_momentum "qiskit.chemistry.FermionicOperator.total_angular_momentum")() | Total angular momentum. |
| [`total_magnetization`](#qiskit.chemistry.FermionicOperator.total_magnetization "qiskit.chemistry.FermionicOperator.total_magnetization")() | A data\_preprocess\_helper fermionic operator which can be used to evaluate the magnetization of the given eigenstate. |
| [`total_particle_number`](#qiskit.chemistry.FermionicOperator.total_particle_number "qiskit.chemistry.FermionicOperator.total_particle_number")() | A data\_preprocess\_helper fermionic operator which can be used to evaluate the number of particle of the given eigenstate. |
| [`transform`](#qiskit.chemistry.FermionicOperator.transform "qiskit.chemistry.FermionicOperator.transform")(unitary\_matrix) | Transform the one and two body term based on unitary\_matrix. |
## Attributes
| | |
| ----------------------------------------------------------------------------------------------- | ----------------------------------- |
| [`h1`](#qiskit.chemistry.FermionicOperator.h1 "qiskit.chemistry.FermionicOperator.h1") | Getter of one body integral tensor. |
| [`h2`](#qiskit.chemistry.FermionicOperator.h2 "qiskit.chemistry.FermionicOperator.h2") | Getter of two body integral tensor. |
| [`modes`](#qiskit.chemistry.FermionicOperator.modes "qiskit.chemistry.FermionicOperator.modes") | Getter of modes. |
### fermion\_mode\_elimination
<Function id="qiskit.chemistry.FermionicOperator.fermion_mode_elimination" signature="fermion_mode_elimination(fermion_mode_array)">
Eliminate modes.
Generate a new fermionic operator with the modes in fermion\_mode\_array deleted
**Parameters**
**fermion\_mode\_array** (*list*) orbital index for elimination
**Returns**
Fermionic Hamiltonian
**Return type**
[FermionicOperator](#qiskit.chemistry.FermionicOperator "qiskit.chemistry.FermionicOperator")
</Function>
### fermion\_mode\_freezing
<Function id="qiskit.chemistry.FermionicOperator.fermion_mode_freezing" signature="fermion_mode_freezing(fermion_mode_array)">
Freezing modes and extracting its energy.
Generate a fermionic operator with the modes in fermion\_mode\_array deleted and provide the shifted energy after freezing.
**Parameters**
**fermion\_mode\_array** (*list*) orbital index for freezing
**Returns**
Fermionic Hamiltonian and energy of frozen modes
**Return type**
tuple([FermionicOperator](#qiskit.chemistry.FermionicOperator "qiskit.chemistry.FermionicOperator"), float)
</Function>
### h1
<Attribute id="qiskit.chemistry.FermionicOperator.h1">
Getter of one body integral tensor.
</Attribute>
### h2
<Attribute id="qiskit.chemistry.FermionicOperator.h2">
Getter of two body integral tensor.
</Attribute>
### mapping
<Function id="qiskit.chemistry.FermionicOperator.mapping" signature="mapping(map_type, threshold=1e-08)">
Map fermionic operator to qubit operator.
Using multiprocess to speedup the mapping, the improvement can be observed when h2 is a non-sparse matrix.
**Parameters**
* **map\_type** (*str*) case-insensitive mapping type. “jordan\_wigner”, “parity”, “bravyi\_kitaev”, “bksf”
* **threshold** (*float*) threshold for Pauli simplification
**Returns**
create an Operator object in Paulis form.
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
**Raises**
[**QiskitChemistryError**](qiskit.chemistry.QiskitChemistryError "qiskit.chemistry.QiskitChemistryError") if the map\_type can not be recognized.
</Function>
### modes
<Attribute id="qiskit.chemistry.FermionicOperator.modes">
Getter of modes.
</Attribute>
### particle\_hole\_transformation
<Function id="qiskit.chemistry.FermionicOperator.particle_hole_transformation" signature="particle_hole_transformation(num_particles)">
The standard second quantized Hamiltonian can be transformed in the particle-hole (p/h) picture, which makes the expansion of the trail wavefunction from the HF reference state more natural. In fact, for both trail wavefunctions implemented in q-lib (heuristic hardware efficient and UCCSD) the p/h Hamiltonian improves the speed of convergence of the VQE algorithm for the calculation of the electronic ground state properties. For more information on the p/h formalism see: P. Barkoutsos, arXiv:1805.04340([https://arxiv.org/abs/1805.04340](https://arxiv.org/abs/1805.04340)).
**Parameters**
**num\_particles** (*list, int*) number of particles, if it is a list, the first number is alpha and the second number is beta.
**Returns**
new\_fer\_op, energy\_shift
**Return type**
tuple
</Function>
### total\_angular\_momentum
<Function id="qiskit.chemistry.FermionicOperator.total_angular_momentum" signature="total_angular_momentum()">
Total angular momentum.
A data\_preprocess\_helper fermionic operator which can be used to evaluate the total angular momentum of the given eigenstate.
**Returns**
Fermionic Hamiltonian
**Return type**
[FermionicOperator](#qiskit.chemistry.FermionicOperator "qiskit.chemistry.FermionicOperator")
</Function>
### total\_magnetization
<Function id="qiskit.chemistry.FermionicOperator.total_magnetization" signature="total_magnetization()">
A data\_preprocess\_helper fermionic operator which can be used to evaluate the magnetization of the given eigenstate.
**Returns**
Fermionic Hamiltonian
**Return type**
[FermionicOperator](#qiskit.chemistry.FermionicOperator "qiskit.chemistry.FermionicOperator")
</Function>
### total\_particle\_number
<Function id="qiskit.chemistry.FermionicOperator.total_particle_number" signature="total_particle_number()">
A data\_preprocess\_helper fermionic operator which can be used to evaluate the number of particle of the given eigenstate.
**Returns**
Fermionic Hamiltonian
**Return type**
[FermionicOperator](#qiskit.chemistry.FermionicOperator "qiskit.chemistry.FermionicOperator")
</Function>
### transform
<Function id="qiskit.chemistry.FermionicOperator.transform" signature="transform(unitary_matrix)">
Transform the one and two body term based on unitary\_matrix.
</Function>
</Class>