qat.fermion.hamiltonians.ElectronicStructureHamiltonian

class qat.fermion.hamiltonians.ElectronicStructureHamiltonian(hpq: ndarray, hpqrs: Optional[ndarray] = None, constant_coeff: float = 0.0)

A container for the electronic-structure Hamiltonian, defined as

\[H = \sum_{pq} h_{pq}a_p^\dagger a_q + \frac{1}{2} \sum_{pqrs} h_{pqrs}a_p^\dagger a_q^\dagger a_r a_s + c \mathbb{I}\]
Parameters
  • hpq (np.ndarray) – Array \(h_{pq}\). Must be 2D.

  • hpqrs (np.ndarray) – Array \(h_{pqrs}\). Must be 4D.

  • constant_coeff (float) – Constant coefficient \(c.\)

hpq

Array \(h_{pq}\).

Type

np.ndarray

hpqrs

Array \(h_{pqrs}\).

Type

np.ndarray

constant_coeff

Constant coefficient \(c\).

Type

float

Example

import numpy as np
from qat.fermion import ElectronicStructureHamiltonian

h_pq = 0.2 * np.array([[0, 1], [1, 0]])
h_pqrs = np.zeros((2, 2, 2, 2))
h_pqrs[0, 1, 1, 0] = 0.7
h_pqrs[1, 0, 0, 1] = 0.7
hamiltonian = ElectronicStructureHamiltonian(h_pq, h_pqrs, -6)

print(f"H = {hamiltonian}")
eigvals = np.linalg.eigvalsh(hamiltonian.get_matrix())

print(f"eigenvalues = {eigvals}")
H = -6 * I^2 +
0.2 * (Cc|[0, 1]) +
0.2 * (Cc|[1, 0]) +
-0.7 * (CCcc|[0, 1, 0, 1])
eigenvalues = [-6.2 -6.  -5.8 -5.3]
copy()

Deepcopy the current class.

Returns

Copy of the ElectronicStructureHamiltonian.

Return type

ElectronicStructureHamiltonian

dag() ElectronicStructureHamiltonian

Compute the conjugate transpose of the Hamiltonian.

Returns

Conjugate transpose of the Hamiltonian.

Return type

ElectronicStructureHamiltonian

get_matrix(sparse: bool = False) ndarray

This function returns the matrix corresponding to \(H\) in the computational basis.

Parameters
  • sparse (Optional[bool]) – Whether to return in sparse representation.

  • False. (Defaults to) –

Returns

The matrix of the FermionHamiltonian.

Return type

numpy.ndarray

Warning

This method should not be used if the Hamiltonian is too large.

to_fermion() FermionHamiltonian

Convert current ElectronicStructureHamiltonian to a FermionHamiltonian.

Returns

Fermionic Hamiltonian.

Return type

FermionHamiltonian

to_spin(method: Optional[str] = 'jordan-wigner')

Maps the fermionic Hamiltonian to a spin Hamiltonian.

Parameters

method (str, optional) –

Method to use for the transformation to a spin representation. Available methods are :

  • ”jordan-wigner” : Jordan-Wigner transform (default),

  • ”bravyi-kitaev” : Bravyi-Kitaev transform,

  • ”parity” : Parity transform.

Returns

Hamiltonian in spin representation.

Return type

SpinHamiltonian