View source on GitHub |
Class for storing DOCI hamiltonians which are defined to be restrictions of fermionic operators to doubly occupied configurations.
Inherits From: PolynomialTensor
openfermion.ops.DOCIHamiltonian(
constant, hc, hr1, hr2
)
As such they are by nature hard-core boson Hamiltonians, but the hard-core Boson algebra is identical to the Pauli algebra, which is why it is convenient to represent DOCI hamiltonians as QubitOperators
Note that the operators stored in this class take the form:
$$
constant + \sum_{p} h^{(r1)}_{p, p}/2 (1 - \sigma^Z_p) +
\sum_{p \neq q} h^{(r1)}_{p, q}/4
* (\sigma^X_p \sigma^X_q + \sigma^Y_p \sigma^Y_q) +
\sum_{p \neq q} h^{(r2)}_{p, q}/4 (1 - \sigma^Z_p -
\sigma^Z_q + \sigma^Z_p \sigma^Z_q)
=
constant + \sum_{p} h_{p, p} N_p +
\sum_{p \neq q} w_{p, p} N_p N_q +
\sum_{p \neq q} v_{p, p} P_p^\dagger P_q,
$$
where
$$
N_p = (1 - \sigma^Z_p)/2,
P_p = a_{i,\beta} a_{i,\alpha},
h_p = h^{(r1)}_{p, p} = \langle p|h|p \rangle =
2 I^{(1)}_{p, p} + I^{(2)}_{p, p, p, p},
w_{p, q} = h^{(r2)}_{p, q} = 2 \langle pq|v|pq \rangle -
\langle pq|v|qp \rangle =
2 I^{(2)}_{p, q, q, p} -
I^{(2)}_{p, q, p, q},
v_{p, q} = h^{(r1)}_{p, q} = \langle pp|v|qq \rangle =
I^{(2)}_{p, p, q, q},
$$
with (\(I^{(1)}_{p, q}\)) and (\(I^{(2)}_{p, q, r, s}\)) are the one and two body electron integrals and (\(h\)) and (\(v\)) are the coefficients of the corresponding InteractionOperator
$$
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
from_integrals
@classmethod
from_integrals( constant, one_body_integrals, two_body_integrals )
get_projected_integrals
get_projected_integrals()
Creates the one and two body integrals that would correspond to a hypothetic electronic structure Hamiltonian, which would satisfy the given set of hc, hr1 and hr2.
This is technically not well-defined, as hr2 is not generated in a one-to-one fashion. This implies that calling
get_doci_from_integrals( *get_projected_integrals_from_doci( hc, hr1, hr2 ) )
should return the same hc, hr1, and hr2, but there is no such guarantee for
get_projected_integrals_from_doci( *get_doci_from_integrals( one_body_integrals, two_body_integrals ) )
but this method attempts to create integrals that conform to the same symmetries as a physical electronic structure Hamiltonian would, with inevitable loss of information due to the ambiguity above.
Args | |
---|---|
hc [numpy array]: The single-particle DOCI terms in matrix form hr1 [numpy array]: The off-diagonal DOCI Hamiltonian terms in matrix form hr2 [numpy array]: The diagonal DOCI Hamiltonian terms in matrix form |
Returns | |
---|---|
projected_onebody_integrals [numpy array]: The corresponding one-body integrals for the electronic structure Hamiltonian projected_twobody_integrals [numpy array]: The corresponding two body integrals for the electronic structure Hamiltonian |
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. |
with_function_applied_elementwise
with_function_applied_elementwise(
func
)
xx_term
xx_term(
p, q
)
Returns the XX term on a single pair of qubits as a QubitOperator Arguments: p, q [int] -- qubit indices Returns: [QubitOperator] -- XX term on the chosen qubits.
yy_term
yy_term(
p, q
)
Returns the YY term on a single pair of qubits as a QubitOperator Arguments: p, q [int] -- qubit indices Returns: [QubitOperator] -- YY term on the chosen qubits.
z_term
z_term(
p
)
Returns the Z term on a single qubit as a QubitOperator Arguments: p [int] -- qubit index Returns: [QubitOperator] -- Z term on the chosen qubit.
zero
@classmethod
zero( n_qubits )
zz_term
zz_term(
p, q
)
Returns the ZZ term on a single pair of qubits as a QubitOperator Arguments: p, q [int] -- qubit indices Returns: [QubitOperator] -- ZZ term on the chosen 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
)