ElectronicEnergy#

class ElectronicEnergy(electronic_integrals, *, constants=None)[source]#

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:

  1. 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})
  1. 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 also QubitMapper).

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#

The qiskit_nature.second_q.operators.ElectronicIntegrals.

constants#

A mapping of constant energy offsets, not mapped to the qubit operator.

প্যারামিটার:
  • 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)[source]#

Computes the Coulomb term for the given reduced density matrix.

\[J_{qr} = \sum g_{pqrs} D_{ps}\]
প্যারামিটার:

density (ElectronicIntegrals) -- the reduced density matrix.

রিটার্নস:

The Coulomb operator coefficients.

রেইজেস:

NotImplementedError -- when encountering SymmetricTwoBodyIntegrals inside of ElectronicEnergy.electronic_integrals.

রিটার্ন টাইপ:

ElectronicIntegrals

exchange(density)[source]#

Computes the Exchange term for the given reduced density matrix.

\[K_{pr} = \sum g_{pqrs} D_{qs}\]
প্যারামিটার:

density (ElectronicIntegrals) -- the reduced density matrix.

রিটার্নস:

The Exchange operator coefficients.

রেইজেস:

NotImplementedError -- when encountering SymmetricTwoBodyIntegrals inside of ElectronicEnergy.electronic_integrals.

রিটার্ন টাইপ:

ElectronicIntegrals

fock(density)[source]#

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() and exchange() terms, respectively.

প্যারামিটার:

density (ElectronicIntegrals) -- the reduced density matrix.

রিটার্নস:

The Fock operator coefficients.

রিটার্ন টাইপ:

ElectronicIntegrals

classmethod from_raw_integrals(h1_a, h2_aa, h1_b=None, h2_bb=None, h2_ba=None, *, validate=True, auto_index_order=True)[source]#

Constructs a hamiltonian instance from raw integrals.

This function simply calls from_raw_integrals(). See its documentation for more details.

প্যারামিটার:
  • 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.

রিটার্নস:

The resulting ElectronicEnergy instance.

রিটার্ন টাইপ:

ElectronicEnergy

interpret(result)[source]#

Interprets an EigenstateResult.

In particular, this adds the constant energy shifts stored in this hamiltonian to the result object.

প্যারামিটার:

result (EigenstateResult) -- the result to add meaning to.

second_q_op()[source]#

Returns the second quantized operator constructed from the contained electronic integrals.

রিটার্নস:

A FermionicOp instance.

রিটার্ন টাইপ:

FermionicOp