qrunch.chemistry.subspace_diagonalization.eigenpair_solvers

Eigenpair solving and caching shared by the Slater-Condon subspace diagonalizers.

Module Attributes

DIRECT_SOLVE_MAXIMUM_SUBSPACE_SIZE

Largest subspace still handed to the direct solver rather than the iterative one.

Functions

lowest_eigenpair(ci_matrix, starting_vector, ...)

Solve for the lowest eigenpair of a dense or sparse CI matrix.

lowest_eigenpairs(ci_matrix, ...)

Solve for the lowest eigenpairs of a dense or sparse CI matrix.

Classes

EigenpairCache

The most recent subspace solution, reused directly or as a seed for the next one.

DIRECT_SOLVE_MAXIMUM_SUBSPACE_SIZE: int = 100

Largest subspace still handed to the direct solver rather than the iterative one.

class EigenpairCache

Bases: object

The most recent subspace solution, reused directly or as a seed for the next one.

Only the most recent subspace is held: subspaces grow monotonically over a run, so an older one is never asked for again and keeping it would only tie up memory.

__init__() → None

Initialize an empty cache.

Return type:

None

lookup(subspace: tuple[int, ...], *, number_of_eigenpairs: int) → tuple[NDArray[float64], NDArray[float64]] | None

Return the cached solution of a subspace, if the cache holds at least that many roots for it.

Parameters:
  • subspace (tuple[int, ...]) – Determinants spanning the subspace, as bitstring integers.

  • number_of_eigenpairs (int) – Requested number of lowest eigenpairs.

Return type:

tuple[NDArray[float64], NDArray[float64]] | None

starting_vector(bitstrings_as_integers: list[int]) → NDArray[float64] | None

Project the cached ground-state eigenvector onto the given determinants, to seed an iterative solve.

Determinants absent from the cached subspace get a zero coefficient. A projection that retains nothing is discarded. The iterative solver supplements this direction with an independent probe rather than restricting its search to the cached eigenvector’s invariant sector.

Parameters:

bitstrings_as_integers (list[int]) – Determinants spanning the subspace to seed, as bitstring integers.

Return type:

NDArray[float64] | None

store(subspace: tuple[int, ...], eigenpairs: tuple[NDArray[float64], NDArray[float64]]) → None

Replace the cached solution.

Parameters:
  • subspace (tuple[int, ...]) – Determinants spanning the subspace, as bitstring integers.

  • eigenpairs (tuple[NDArray[float64], NDArray[float64]]) – The lowest eigenvalues and their eigenvectors for that subspace.

Return type:

None

lowest_eigenpair(ci_matrix: NDArray[float64] | csr_matrix, starting_vector: NDArray[float64] | None, *, rng: Generator) → tuple[float, NDArray[float64]]

Solve for the lowest eigenpair of a dense or sparse CI matrix.

A direct solve reduces the whole matrix at a cost cubic in the subspace size, so it only wins while the matrix is small – which is also where an iterative solver has too little room to build a Krylov space.

Parameters:
  • ci_matrix (NDArray[float64] | csr_matrix) – The CI matrix to diagonalize; the direct solve consumes a dense matrix.

  • starting_vector (NDArray[float64] | None) – Optional vector seeding the iterative solver.

  • rng (Generator) – Random generator supplying iterative starting probes; unused for direct solves.

Return type:

tuple[float, NDArray[float64]]

lowest_eigenpairs(ci_matrix: NDArray[float64] | csr_matrix, starting_vector: NDArray[float64] | None, *, rng: Generator, number_of_eigenpairs: int) → tuple[NDArray[float64], NDArray[float64]]

Solve for the lowest eigenpairs of a dense or sparse CI matrix.

A direct solve reduces the whole matrix at a cost cubic in the subspace size, so it only wins while the matrix is small – which is also where an iterative solver has too little room to build a Krylov space. Sparse matrices falling into the direct-solve regime are densified first.

Parameters:
  • ci_matrix (NDArray[float64] | csr_matrix) – The CI matrix to diagonalize; the direct solve consumes a dense matrix.

  • starting_vector (NDArray[float64] | None) – Optional vector seeding the iterative solver.

  • rng (Generator) – Random generator supplying iterative starting probes; unused for direct solves.

  • number_of_eigenpairs (int) – Positive number of lowest eigenpairs to compute.

Return type:

tuple[NDArray[float64], NDArray[float64]]