# openfermion.ops.DOCIHamiltonian

Class for storing DOCI hamiltonians which are defined to be restrictions of fermionic operators to doubly occupied configurations.

Inherits From: PolynomialTensor

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.$$


constant A constant term in the operator given as a float. For instance, the nuclear repulsion energy.
hc the coefficients of ($$h^{(c)}_{p}$$)
hr1 The coefficients of ($$h^{(r1)}_{p, q}$$). This is an n_qubits x nqubits numpy array of floats.
hr2 The coefficients of ($$h^{(r2)}{p, q}$$). This is an n_qubits x n_qubits array of floats.

constant The constant offset.
hr1 The coefficients of ($$h^{r1}_{p, q}$$). This is an n_qubits x nqubits numpy array of floats.
hr2 The coefficients of ($$h^{r2}{p, q}$$). This is an n_qubits x n_qubits numpy array of floats.
hc

identity_part Returns identity term of this operator (i.e. trace-ful term) in QubitOperator form.
n_body_tensors

n_qubits

qubit_operator Return the QubitOperator representation of this DOCI Hamiltonian
xx_part Returns the XX part of the QubitOperator representation of this DOCIHamiltonian
xy_part Returns the XX+YY part of the QubitOperator representation of this DOCIHamiltonian
yy_part Returns the YY part of the QubitOperator representation of this DOCIHamiltonian
z_part Return the Z and ZZ part of the QubitOperator representation of this DOCI Hamiltonian
zz_part Returns the ZZ part of the QubitOperator representation of this DOCIHamiltonian

## Methods

View source

### get_projected_integrals

View source

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

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.

View source

### xx_term

View source

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

View source

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

View source

Returns the Z term on a single qubit as a QubitOperator Arguments: p [int] -- qubit index Returns: [QubitOperator] -- Z term on the chosen qubit.

View source

### zz_term

View source

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.

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

### __truediv__`

View source

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]
{"lastModified": "Last updated 2024-04-26 UTC."}