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

216 lines
8.2 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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 (v0.31)
description: API reference for qiskit.chemistry.FermionicOperator in qiskit v0.31
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.chemistry.FermionicOperator
---
# FermionicOperator
<Class id="qiskit.chemistry.FermionicOperator" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/chemistry/fermionic_operator.py" signature="FermionicOperator(h1, h2=None, ph_trans_shift=None)" modifiers="class">
Bases: `object`
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
## Methods
<span id="qiskit-chemistry-fermionicoperator-fermion-mode-elimination" />
### fermion\_mode\_elimination
<Function id="qiskit.chemistry.FermionicOperator.fermion_mode_elimination" signature="FermionicOperator.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>
<span id="qiskit-chemistry-fermionicoperator-fermion-mode-freezing" />
### fermion\_mode\_freezing
<Function id="qiskit.chemistry.FermionicOperator.fermion_mode_freezing" signature="FermionicOperator.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>
<span id="qiskit-chemistry-fermionicoperator-mapping" />
### mapping
<Function id="qiskit.chemistry.FermionicOperator.mapping" signature="FermionicOperator.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>
<span id="qiskit-chemistry-fermionicoperator-particle-hole-transformation" />
### particle\_hole\_transformation
<Function id="qiskit.chemistry.FermionicOperator.particle_hole_transformation" signature="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. 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>
<span id="qiskit-chemistry-fermionicoperator-total-angular-momentum" />
### total\_angular\_momentum
<Function id="qiskit.chemistry.FermionicOperator.total_angular_momentum" signature="FermionicOperator.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>
<span id="qiskit-chemistry-fermionicoperator-total-magnetization" />
### total\_magnetization
<Function id="qiskit.chemistry.FermionicOperator.total_magnetization" signature="FermionicOperator.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>
<span id="qiskit-chemistry-fermionicoperator-total-particle-number" />
### total\_particle\_number
<Function id="qiskit.chemistry.FermionicOperator.total_particle_number" signature="FermionicOperator.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>
<span id="qiskit-chemistry-fermionicoperator-transform" />
### transform
<Function id="qiskit.chemistry.FermionicOperator.transform" signature="FermionicOperator.transform(unitary_matrix)">
Transform the one and two body term based on unitary\_matrix.
</Function>
## Attributes
### 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>
### modes
<Attribute id="qiskit.chemistry.FermionicOperator.modes">
Getter of modes.
</Attribute>
</Class>