View source on GitHub |
Class for storing 'interaction operators' which are defined to be fermionic operators consisting of one-body and two-body terms which conserve particle number and spin.
Inherits From: PolynomialTensor
openfermion.ops.InteractionOperator(
constant, one_body_tensor, two_body_tensor
)
Used in the notebooks
Used in the tutorials |
---|
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:
$$
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.
$$
Methods
projected
projected(
indices, exact=False
)
projected_n_body_tensors
projected_n_body_tensors(
selection, exact=False
)
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
rotate_basis(
rotation_matrix
)
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
unique_iter(
complex_valued=False
)
Iterate all terms that are not in the same symmetry group.
Four point symmetry | |
---|---|
|
Eight point symmetry | |
---|---|
|
Args | |
---|---|
complex_valued
|
bool
Whether the operator has complex coefficients. |
Yields | |
---|---|
tuple[int] |
with_function_applied_elementwise
with_function_applied_elementwise(
func
)
zero
@classmethod
zero( n_qubits )
__add__
__add__(
addend
)
__eq__
__eq__(
other
)
Return self==value.
__getitem__
__getitem__(
args
)
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__
__iter__()
Iterate over non-zero elements of PolynomialTensor.
__mod__
__mod__(
other
)
__mul__
__mul__(
multiplier
)
__ne__
__ne__(
other
)
Return self!=value.
__neg__
__neg__()
__radd__
__radd__(
addend
)
__rmul__
__rmul__(
multiplier
)
__rsub__
__rsub__(
subtrahend
)
__sub__
__sub__(
subtrahend
)
__truediv__
__truediv__(
dividend
)