openfermion.ops.InteractionOperator

Class for storing 'interaction operators' which are defined to be

Inherits From: PolynomialTensor

fermionic operators consisting of one-body and two-body terms which conserve particle number and spin. The most common examples of data that will use this structure are molecular Hamiltonians. In principle, everything stored in this class could also be represented using the more general FermionOperator class. However, this class is able to exploit specific properties of how fermions interact to enable more numerically efficient manipulation of the data. Note that the operators stored in this class take the form:

.. math::

constant + \sum_{p, q} h_{p, q} a^\dagger_p a_q +
\sum_{p, q, r, s} h_{p, q, r, s} a^\dagger_p a^\dagger_q a_r a_s.


constant A constant term in the operator given as a float. For instance, the nuclear repulsion energy.
one_body_tensor The coefficients of the one-body terms (:math:h_{p,q}). This is an n_qubits x n_qubits numpy array of floats.
two_body_tensor The coefficients of the two-body terms (:math:h_{p, q, r, s}). This is an n_qubits x n_qubits x n_qubits x n_qubits numpy array of floats.

one_body_tensor The coefficients of the one-body terms (:math:h_{p, q}). This is an n_qubits x n_qubits numpy array of floats.
two_body_tensor The coefficients of the two-body terms (:math:h_{p, q, r, s}). This is an n_qubits x n_qubits x n_qubits x n_qubits numpy array of floats.
constant The value of the constant term.

Methods

View source

projected_n_body_tensors

View source

Keep only selected elements.

Args
selection (Union[int, Iterable[int]): If int, keeps terms with at most (exactly, if exact is True) that many unique indices. If iterable, keeps only terms containing (all of, if exact is True) the specified indices. exact (bool): Whether or not the selection is strict.

rotate_basis

View source

Rotate the orbital basis of the PolynomialTensor.

Args
rotation_matrix A square numpy array or matrix having dimensions of n_qubits by n_qubits. Assumed to be real and invertible.

unique_iter

View source

Iterate all terms that are not in the same symmetry group.

Four point symmetry:

1. pq = qp.
2. pqrs = srqp = qpsr = rspq.

Eight point symmetry:

1. pq = qp.
2. pqrs = rqps = psrq = srqp = qpsr = rspq = spqr = qrsp.

Args
complex_valued (bool): Whether the operator has complex coefficients.

Yields
tuple[int]

View source

View source

View source

__eq__

View source

Return self==value.

__getitem__

View source

Look up matrix element.

Args
args Tuples indicating which coefficient to get. For instance, my_tensor[(6, 1), (8, 1), (2, 0)] returns my_tensor.n_body_tensors[1, 1, 0][6, 8, 2]

__iter__

View source

Iterate over non-zero elements of PolynomialTensor.

View source

View source

__ne__

View source

Return self!=value.

View source

View source

View source

View source

View source

View source