device_builder.utils.chebyshev
Helper functions for computing chebyshev moments.
Copyright © 2023-2025 HQS Quantum Simulations GmbH. All Rights Reserved.
Compute Chebyshev moments for the given batch size.
NOTE: The spectral bounds of the operator must be in the interval (-1, 1).
The spectral bounds of the original linear operator are passed via the
spectral_bounds argument.
Arguments:
- operator (Callable[[xp.ndarray, xp.ndarray], xp.ndarray]): Linear operator for Chebyshev iteration.
- spectral_bounds (tuple[float, float]): Spectral bounds of the original linear operator.
- state (xp.ndarray): State for which to compute Chebyshev moments.
- number_of_chebyshev_moments (int): Number of Chebyshev moments to calculate.
- batch_size (int): Number of random states to generate.
Returns:
ChebyshevMoments: Model holding reference to Chebyshev moments and supporting information.
Get density of states from given Chebyshev moments.
The computation of the DOS is batched to reduce the memory footprint of
the get_dos function.
NOTE: Memory consumption scales: chebyshev_moments.size x n_grid_points_batch
Arguments:
- chebyshev_moments (ChebyshevMoments): Pre-computed Chebyshev moments.
- energy_window (tuple[float, float]): Energy window to compute DOS.
- n_grid_points (int): Target for number of grid points.
- n_grid_points_batch (int): Number of grid points for each batch.
- max_n_chebyshev_moments (Optional[int]): Maximum number of Chebyshev moments to be used for computing the DOS. Default is None, which means all Chebyshev moments are used.
- eta (float): Broadening parameter via shifting energies into complex plane. Defaults to 0.0, meaning no additional broadening.
Returns:
tuple[float, np.ndarray, np.ndarray]: Tuple of float: Integration weight, np.ndarray: Energy grid points, np.ndarray: Density of states on grid points.
Average Chebyshev moments from a list of ChebyshevMoments.
Arguments:
- chebyshev_moments (list[ChebyshevMoments]): List of ChebyshevMoments to be averaged.
Returns:
ChebyshevMoments: Average Chebyshev moments.
Returns the density of states (DOS) in given energy window.
NOTE: The input requires precomputed Chebyshev moments of the Hamiltonian for which the DOS is computed.
NOTE: At present, both, the energy window and the energy window scaled into the Chebyshev window are required input.
NOTE: If 'bare' Chebyshev moments are used the DOS is normalized to 1. You can use 'pre-scaled' Chebyshev moments to enforce a different normalization condition.
Arguments:
- chebyshev_moments (np.ndarray): Precomputed Chebyshev moments.
- window (tuple[float, float]): Energy window for which to compute the DOS.
- chebyshev_window (tuple[float, float]): Energy window scaled into Chebyshev interval.
- n_grid_points (int): Number of discretization points for energy window.
- eta (float): Broadening parameter via shifting energies into complex plane.
Returns:
tuple[float, np.ndarray, np.ndarray]: Tuple of float: energy spacing between grid points, np.ndarray: discretized energy window (equidistant grid), np.ndarray: DOS on grid points.