sk_builder.stride_helpers

Helper functions for computation of (memory) strides.

This module implements helper functions to construct the Hamiltonian matrix or operator. These functions "hard-code" the mapping of 3D unit cell indices and repetitions into a linear (1D) index, taking into account periodic boundary conditions, i.e., the wrapping of unit cells across the boundaries of the system.

@private

Copyright © 2023-2024 HQS Quantum Simulations GmbH. All Rights Reserved.

def get_ids_strides( translation: tuple[int, ...], size: tuple[int, ...], region: str) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]:

Get tuple of id_from, id_to and stride corresponding to translation.

Arguments:
  • translation (tuple[int, ...]): Translation along each lattice vector.
  • size (tuple[int, ...]): Number of unit cells along each lattice vector.
  • region (str): Can be 'boundary', 'bulk' or 'all'
Returns:

tuple[np.ndarray, np.ndarray, np.ndarray]: Tuple of arrays (abstract COO representation of bond).

def get_stride_to_shift_map( translation: tuple[int, ...], size: tuple[int, ...]) -> dict[int, tuple[int, ...]]:

Return map from strides to lattice vector shifts for a given translation.

This is a helper routine to identify boundary terms for a given translation vector between unit cells. The strides are defined as the difference of indices for the flattened tensor describing the super cell.

Arguments:
  • translation (tuple[int, ...]): Translation in terms of unit cells for each direction.
  • size (tuple[int, ...]): Unit cell repetitions along each direction.
Returns:

dict[int, tuple[int, ...]]: Map from strides to lattice vector shifts.

def get_stride_to_boundary_phase_map( translation: tuple[int, ...], size: tuple[int, ...], boundary_phase: tuple[complex, ...], bulk: complex) -> dict[int, complex]:

Return map from stride to phase for a given translation.

This is a helper routine to identify boundary terms for a given translation vector between unit cells. The strides are defined as the difference of indices for the flattened tensor describing the super cell.

Arguments:
  • translation (tuple[int, ...]): Translation in terms of unit cells for each direction.
  • size (tuple[int, ...]): Unit cell repetitions along each direction.
  • boundary_phase (tuple[complex, ...]): (Bloch) boundary phase jump along each direction.
  • bulk (complex): Complex phase associated to all bulk strides
Returns:

dict[int, complex]: Map from strides to phase jump.