ElectronicEnergy#
- class ElectronicEnergy(electronic_integrals, *, constants=None)[fuente]#
Bases:
Hamiltonian
The electronic energy Hamiltonian.
This class implements the following Hamiltonian:
\[\sum_{p, q} h_{pq} a^\dagger_p a_q + \sum_{p, q, r, s} g_{pqrs} a^\dagger_p a^\dagger_q a_r a_s ,\]where \(h_{pq}\) and \(g_{pqrs}\) are the one- and two-body electronic integrals, stored in an
ElectronicIntegrals
container. When dealing with separate coefficients for the \(\alpha\)- and \(\beta\)-spin electrons, the unrestricted-spin Hamiltonian can be obtained from the one above in a straight-forward manner, following any quantum chemistry textbook.You can construct an instance of this Hamiltonian in multiple ways:
With an existing instance of
ElectronicIntegrals
:
integrals: ElectronicIntegrals = ... from qiskit_nature.second_q.hamiltonians import ElectronicEnergy hamiltonian = ElectronicEnergy(integrals, constants={"nuclear_repulsion_energy": 1.0})
From a raw set of integral coefficient matrices:
# assuming, you have your one- and two-body integrals from somewhere h1_a, h2_aa, h1_b, h2_bb, h2_ba = ... hamiltonian = ElectronicEnergy.from_raw_integrals(h1_a, h2_aa, h1_b, h2_bb, h2_ba) hamiltonian.nuclear_repulsion_energy = 1.0
Note, how we specified the nuclear repulsion energy as a constant energy offset in the above examples. This term will not be included in the mapped qubit operator since it is a constant offset term and does not need to incur any errors from being measured on a quantum device. It is however possible to include constant energy terms inside of the
ElectronicIntegrals
container, if you want it to be included in the qubit operator, once mapping the second-quantized operator to the qubit space (see alsoQubitMapper
).from qiskit_nature.second_q.operators import PolynomialTensor e_nuc = hamiltonian.nuclear_repulsion_energy hamiltonian.electronic_integrals.alpha += PolynomialTensor({"": e_nuc}) hamiltonian.nuclear_repulsion_energy = None
It is also possible to add other constant energy offsets to the
constants
attribute of this Hamiltonian. All offsets registered in that dictionary will not be mapped to the qubit operator.hamiltonian.constants["my custom offset"] = 5.0 # be careful, the following overwrites the hamiltonian.nuclear_repulsion_energy value hamiltonian.constants["nuclear_repulsion_energy"] = 10.0
- electronic_integrals#
- constants#
A mapping of constant energy offsets, not mapped to the qubit operator.
- Parámetros:
electronic_integrals (ElectronicIntegrals) – The container with the one- and two-body coefficients.
constants (MutableMapping[str, float]) – A mapping of constant energy offsets.
Attributes
- nuclear_repulsion_energy#
The nuclear repulsion energy.
This constant energy offset does not get included in the generated operator. Add it as a constant term to the
electronic_integrals
and remove it here, if you want to include it in the generated operator:from qiskit_nature.second_q.operators import PolynomialTensor hamiltonian = ElectronicEnergy(...) hamiltonian.electronic_integrals.alpha += PolynomialTensor({ "": hamiltonian.nuclear_repulsion_energy }) hamiltonian.nuclear_repulsion_energy = None
- register_length#
Methods
- coulomb(density)[fuente]#
Computes the Coulomb term for the given reduced density matrix.
\[J_{qr} = \sum g_{pqrs} D_{ps}\]- Parámetros:
density (ElectronicIntegrals) – the reduced density matrix.
- Devuelve:
The Coulomb operator coefficients.
- Muestra:
NotImplementedError – when encountering
SymmetricTwoBodyIntegrals
inside ofElectronicEnergy.electronic_integrals
.- Tipo del valor devuelto:
- exchange(density)[fuente]#
Computes the Exchange term for the given reduced density matrix.
\[K_{pr} = \sum g_{pqrs} D_{qs}\]- Parámetros:
density (ElectronicIntegrals) – the reduced density matrix.
- Devuelve:
The Exchange operator coefficients.
- Muestra:
NotImplementedError – when encountering
SymmetricTwoBodyIntegrals
inside ofElectronicEnergy.electronic_integrals
.- Tipo del valor devuelto:
- fock(density)[fuente]#
Computes the Fock operator for the given reduced density matrix.
\[F_{pq} = h_{pq} + J_{pq} - K_{pq}\]where \(J\) and \(K\) are the
coulomb()
andexchange()
terms, respectively.- Parámetros:
density (ElectronicIntegrals) – the reduced density matrix.
- Devuelve:
The Fock operator coefficients.
- Tipo del valor devuelto:
- classmethod from_raw_integrals(h1_a, h2_aa, h1_b=None, h2_bb=None, h2_ba=None, *, validate=True, auto_index_order=True)[fuente]#
Constructs a hamiltonian instance from raw integrals.
This function simply calls
from_raw_integrals()
. See its documentation for more details.- Parámetros:
h1_a (ndarray) – the alpha-spin one-body coefficients.
h2_aa (ndarray) – the alpha-alpha-spin two-body coefficients.
h1_b (ndarray | None) – the beta-spin one-body coefficients.
h2_bb (ndarray | None) – the beta-beta-spin two-body coefficients.
h2_ba (ndarray | None) – the beta-alpha-spin two-body coefficients.
validate (bool) – whether or not to validate the coefficient matrices.
auto_index_order (bool) – whether or not to automatically convert the matrices to physicists” order.
- Devuelve:
The resulting
ElectronicEnergy
instance.- Tipo del valor devuelto:
- interpret(result)[fuente]#
Interprets an
EigenstateResult
.In particular, this adds the constant energy shifts stored in this hamiltonian to the result object.
- Parámetros:
result (EigenstateResult) – the result to add meaning to.