hqs_quantum_solver.tools#

Tools that use Operators defined in hqs_quantum_solver.

This submodule adds extra features that can be computed whenever a matrix satisfies the OperatorProtocol.

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

Functions

calculate_chebyshev_moments(operator, ...[, ...])

Function to calculate the Chebyshev moments of the retarded Green's function.

calculate_extremal_algebraic_eigenvalues(...)

Calculates the largest and smallest algebraic eigenvalues of an operator.

calculate_retarded_greens_function(...[, ...])

Calculate frequency-resolved retarded Green's function via Chebyshev expansion.

calculate_chebyshev_moments(operator: OperatorProtocol, operator_bounds: Tuple[float, float], number_chebyshev_moments: int, right_vectors: ndarray, left_vectors: ndarray | None = None, spectral_buffer: float = 0.02) ndarray#

Function to calculate the Chebyshev moments of the retarded Green’s function.

The method for computing the moments is as described in the following paper:

A. Braun, and P. Schmitteckert, “Numerical evaluation of Green’s functions based on the Chebyshev expansion”, Physical Review B 90(16), 165112 (2014) doi:10.1103/PhysRevB.90.165112

To calculate the right vectors apply the corresponding operators to the groundstate and save the resulting vectors as columns of an array.

As pseudocode:

for site in sites:
    right_vectors[site, :] = creation_operator(site).dot(ground_state)

Where sites is a list containing the site indices and creation_operator(i) and annihilation_operator(i) creates or destroys a particle at site i respectively.

The left vectors can be created in a similar fashion. We would like to note that the so-called left vectors will be implicitly conjugate-transposed by the internal routines, this means for a full representation they would typically be equal to the right vectors.

For an explicit example check out the spinful_fermions_greensfunction.ipynb notebook.

Parameters:
  • operator (OperatorProtocol) – Hermitian operator whose Chebyshev moments will be calculated.

  • operator_bounds (Tuple[float, float]) – Tuple containing the most negative and most positive eigenvalues of the operator respectively.

  • number_chebyshev_moments (int) – Number of Chebyshev moments to calculate.

  • right_vectors (np.ndarray) – Right (column) vectors used for the Chebyshev moments.

  • left_vectors (Optional[np.ndarray]) – Left (column) vectors used for the Chebyshev moments. If None, the right vectors are also used as the left vectors. Defaults to None.

  • spectral_buffer (float) – Buffer to the interval boundaries when performing the scaling of the Operator spectrum into the interval (-1, 1), which is necessary for the Chebyshev expansion. Defaults to 0.02.

Returns:

Array with the Chebyshev moments.

Return type:

np.ndarray

Raises:
  • ValueError – If the right vectors are not one- or two-dimensional.

  • ValueError – If the left vectors are not one- or two-dimensional.

  • ValueError – If the spectrum of the operator is fully degenerate.

calculate_extremal_algebraic_eigenvalues(operator: OperatorProtocol) Tuple[float, float]#

Calculates the largest and smallest algebraic eigenvalues of an operator.

Parameters:

operator (OperatorProtocol) – Operator whose eigenvalues are to be determined.

Returns:

Tuple containing the most negative and most positive eigenvalues.

Return type:

Tuple[float, float]

calculate_retarded_greens_function(hamiltonian_plus: OperatorProtocol, hamiltonian_minus: OperatorProtocol, groundstate_energy: float, omegas: ndarray, eta: float, number_chebyshev_moments: int, vectors_plus: ndarray, vectors_minus: ndarray, spectral_buffer: float = 0.02) ndarray#

Calculate frequency-resolved retarded Green’s function via Chebyshev expansion.

The function is based on expressing the Green’s function in terms of Green’s functions for which the Chebyshev expansion is known. For detailed reference:

A. Braun, and P. Schmitteckert, “Numerical evaluation of Green’s functions based on the Chebyshev expansion”, Physical Review B 90(16), 165112 (2014) doi:10.1103/PhysRevB.90.165112

To calculate the plus and minus vectors apply the corresponding operators to the groundstate and save the resulting vectors as columns of a matrix.

As pseudocode:

for site in sites:
    vectors_plus[site, :] = creation_operator(site).dot(ground_state)
    vectors_minus[site, :] = annihilation_operator(site).dot(ground_state)

Where sites is a list with all the site indices and creation_operator(i) and annihilation_operator(i) creates or destroys a particle at site i respectively.

For an explicit example check out the spinful_fermions_greensfunction.ipynb notebook.

Parameters:
  • hamiltonian_plus (OperatorProtocol) – Hamiltonian used for the plus Green’s function.

  • hamiltonian_minus (OperatorProtocol) – Hamiltonian used for the minus Green’s function.

  • groundstate_energy (float) – Groundstate energy of the Hamiltonian in the particle sector of interest.

  • omegas (np.ndarray) – Frequencys at which to calculate the retarded Green’s function.

  • eta (float) – Broadening parameter used in the Chebyshev expansion. Typically corresponds to the single particle level spacing.

  • number_chebyshev_moments (int) – Number of Chebyshev moments to calculate.

  • vectors_plus (np.ndarray) – Ket vectors for the plus Green’s function with the approriate operators applied.

  • vectors_minus (np.ndarray) – Ket vectors for the minus Green’s function with the approriate operators applied.

  • spectral_buffer (float) – Buffer to the interval boundaries when performing the scaling of the Operator spectrum into the interval (-1, 1), which is necessary for the Chebyshev expansion. Defaults to 0.02.

Returns:

Array with frequency-resolved Green’s function.

Return type:

np.ndarray

Raises:
  • ValueError – If ket inputs for the plus and minus Green’s functions have different shapes.

  • ValueError – If ket inputs are not one- or two-dimenional.

  • ValueError – If Hamiltonian in plus sector is fully degenerate.

  • ValueError – If Hamiltonian in minus sector is fully degenerate.