qrunch.quantum.operators.second_quantization.fermion.sums

A chemistry-specific representation of a fermionic operator consisting only of single and double excitations.

Classes

ChemistryFermionHermitianSum

Backward-compatible alias for deserializing legacy fermionic operator data.

FermionHermitianSum

Compact chemistry-specific representation of the full second quantization fermionic hermitian sum.

class ChemistryFermionHermitianSum

Bases: FermionHermitianSum

Backward-compatible alias for deserializing legacy fermionic operator data.

This operator used to live in a chemistry-specific module and class. Legacy serialized data references this class name, so this shim reconstructs the current FermionHermitianSum.

__init__(single_excitations: SingleExcitationsArray, two_body_integrals: RestrictedTwoBodyElectronRepulsionIntegralsProtocol | UnrestrictedTwoBodyElectronRepulsionIntegralsProtocol, *, tolerance: float = 1e-10) → None

Initialize the full operator.

Parameters:
  • single_excitations (SingleExcitationsArray) – Single excitation part of the operator.

  • two_body_integrals (RestrictedTwoBodyElectronRepulsionIntegralsProtocol | UnrestrictedTwoBodyElectronRepulsionIntegralsProtocol) – Double excitation part of the operator.

  • tolerance (float) – Remove terms with a value lower than this.

Return type:

None

classmethod decode(data: dict[str, Any]) → FermionHermitianSum

Decode legacy-encoded data into a FermionHermitianSum.

Parameters:

data (dict[str, Any])

Return type:

FermionHermitianSum

property double_excitations: DoubleExcitationsArray

Double excitation part of the operator (physics ordering).

encode() → dict[str, Any]

Encode the instance into a dictionary.

Return type:

dict[str, Any]

static integrals_are_real() → bool

Return True, if the integrals are real.

Return type:

bool

static is_hardcore_bosonic() → Literal[False]

Return True, if it is harcore bosonic.

Return type:

Literal[False]

property is_restricted: bool

Whether the Hamiltonian is created from a restricted molecular ground state problem.

one_body_index_coefficient_pairs() → Iterator[tuple[tuple[int, int], float]]

Iterate over the one-body terms as ((p, q), coefficient) pairs.

Each pair represents the operator \(\text{coefficient} \cdot a_p^\dagger a_q\). Both orderings of a Hermitian off-diagonal pair are yielded; only structurally non-zero entries appear.

Return type:

Iterator[tuple[tuple[int, int], float]]

physics_einsum(component: Literal['aa', 'bb', 'mixed'], einsum_str: str, *operands: ndarray[tuple[Any, ...], dtype[float64]], **kwargs: Any) → ndarray[tuple[Any, ...], dtype[float64]]

Wrap np.einsum where the first operand is always double_excitations integrals.

Note that the einsum_str expect double_excitations to have a physics ordering.

Parameters:
  • component (Literal['aa', 'bb', 'mixed']) – Which integral component to use “aa”, “bb”, or “mixed”

  • einsum_str (str) – The einsum string, e.g. “pqii->pq” or “pqrs,rs->pq”. The first operand-label (before the first comma) must have exactly 4 characters.

  • *operands (ndarray[tuple[Any, ...], dtype[float64]]) – Any additional ndarrays, in the order their labels appear in einsum_str.

  • **kwargs (Any) – Any keywords arguments.

Raises:

ValueError – If the first label isn’t length 4 or the number of extra operands doesn’t match.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

rotate(rotation_matrices: tuple[ndarray[tuple[Any, ...], dtype[float64]], ...]) → Self

Rotate the excitations.

Parameters:

rotation_matrices (tuple[ndarray[tuple[Any, ...], dtype[float64]], ...]) – The matrix to rotate with.

Return type:

Self

rotation_matrix_structure() → list[RotationBlockDefinition]

Get information on which blocks should be non-zero in the rotation matrix.

Return type:

list[RotationBlockDefinition]

property single_excitations: SingleExcitationsArray

Single excitation part of the operator.

two_body_index_coefficient_pairs() → Iterator[tuple[tuple[int, int, int, int], float]]

Iterate over the two-body terms as ((p, q, r, s), coefficient) pairs.

Each pair represents \(\text{coefficient} \cdot a_p^\dagger a_q^\dagger a_r a_s\) (physics ordering). Only structurally non-zero entries are yielded.

Return type:

Iterator[tuple[tuple[int, int, int, int], float]]

class FermionHermitianSum

Bases: object

Compact chemistry-specific representation of the full second quantization fermionic hermitian sum.

This operator consists of single- and double-excitations of fermion second-quantization operators. The double-excitations are created from electron repulsion integrals from a molecular ground state problem.

__init__(single_excitations: SingleExcitationsArray, two_body_integrals: RestrictedTwoBodyElectronRepulsionIntegralsProtocol | UnrestrictedTwoBodyElectronRepulsionIntegralsProtocol, *, tolerance: float = 1e-10) → None

Initialize the full operator.

Parameters:
  • single_excitations (SingleExcitationsArray) – Single excitation part of the operator.

  • two_body_integrals (RestrictedTwoBodyElectronRepulsionIntegralsProtocol | UnrestrictedTwoBodyElectronRepulsionIntegralsProtocol) – Double excitation part of the operator.

  • tolerance (float) – Remove terms with a value lower than this.

Return type:

None

classmethod decode(data: dict[str, Any]) → FermionHermitianSum

Decode a dictionary to an instance of FermionHermitianSum.

Parameters:

data (dict[str, Any]) – The dictionary representation of a FermionHermitianSum instance.

Return type:

FermionHermitianSum

property double_excitations: DoubleExcitationsArray

Double excitation part of the operator (physics ordering).

encode() → dict[str, Any]

Encode the instance into a dictionary.

Return type:

dict[str, Any]

static integrals_are_real() → bool

Return True, if the integrals are real.

Return type:

bool

static is_hardcore_bosonic() → Literal[False]

Return True, if it is harcore bosonic.

Return type:

Literal[False]

property is_restricted: bool

Whether the Hamiltonian is created from a restricted molecular ground state problem.

one_body_index_coefficient_pairs() → Iterator[tuple[tuple[int, int], float]]

Iterate over the one-body terms as ((p, q), coefficient) pairs.

Each pair represents the operator \(\text{coefficient} \cdot a_p^\dagger a_q\). Both orderings of a Hermitian off-diagonal pair are yielded; only structurally non-zero entries appear.

Return type:

Iterator[tuple[tuple[int, int], float]]

physics_einsum(component: Literal['aa', 'bb', 'mixed'], einsum_str: str, *operands: ndarray[tuple[Any, ...], dtype[float64]], **kwargs: Any) → ndarray[tuple[Any, ...], dtype[float64]]

Wrap np.einsum where the first operand is always double_excitations integrals.

Note that the einsum_str expect double_excitations to have a physics ordering.

Parameters:
  • component (Literal['aa', 'bb', 'mixed']) – Which integral component to use “aa”, “bb”, or “mixed”

  • einsum_str (str) – The einsum string, e.g. “pqii->pq” or “pqrs,rs->pq”. The first operand-label (before the first comma) must have exactly 4 characters.

  • *operands (ndarray[tuple[Any, ...], dtype[float64]]) – Any additional ndarrays, in the order their labels appear in einsum_str.

  • **kwargs (Any) – Any keywords arguments.

Raises:

ValueError – If the first label isn’t length 4 or the number of extra operands doesn’t match.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

rotate(rotation_matrices: tuple[ndarray[tuple[Any, ...], dtype[float64]], ...]) → Self

Rotate the excitations.

Parameters:

rotation_matrices (tuple[ndarray[tuple[Any, ...], dtype[float64]], ...]) – The matrix to rotate with.

Return type:

Self

rotation_matrix_structure() → list[RotationBlockDefinition]

Get information on which blocks should be non-zero in the rotation matrix.

Return type:

list[RotationBlockDefinition]

property single_excitations: SingleExcitationsArray

Single excitation part of the operator.

two_body_index_coefficient_pairs() → Iterator[tuple[tuple[int, int, int, int], float]]

Iterate over the two-body terms as ((p, q, r, s), coefficient) pairs.

Each pair represents \(\text{coefficient} \cdot a_p^\dagger a_q^\dagger a_r a_s\) (physics ordering). Only structurally non-zero entries are yielded.

Return type:

Iterator[tuple[tuple[int, int, int, int], float]]