eigs_lanczos
Performs an iterative eigenvalue calculation building eigenvectors using the Lanczos algorithm. Returns the tridiagonal matrix, eigenvalues, number of iterations and the stopping criterion. The Lanczos interations are performed twice, where at the second run the eigenvectors are built.
The algorithm can be run either on-the-fly (matrix-free) or using a sparse matrix in the compressed-sparse-row format (see CSRMatrix).
Sources
eigs_lanczos.hpp
eigs_lanczos.cpp
eigs_lanczos.jl
Definition
On-the-fly
The Lanczos algorithm can be run in two distinct ways:
-
A random intial state \(|\psi_0\rangle = |r\rangle\) with normal distributed entries is used.
-
The initial state \(|\psi_0\rangle\) is explicitly specified
Sparse matrix
-
A random intial state \(|\psi_0\rangle = |r\rangle\) with normal distributed entries is used.
-
The initial state \(|\psi_0\rangle\) is explicitly specified
Parameters
| Name | Description | Default |
|---|---|---|
| ops | OpSum or CSRMatrix defining the bonds of the operator | |
| block | block on which the operator is defined | |
| psi0 | Initial State from which the Lanczos algorithm is started | |
| neigvals | number of eigenvalues to converge | 1 |
| precision | accuracy of the computed ground state | 1e-12 |
| max_iterations | maximum number of iterations | 1000 |
| deflation_tol | tolerance for deflation, i.e. breakdown of Lanczos due to Krylow space exhaustion | 1e-7 |
| random_seed | random seed for setting up the initial vector | 42 |
Returns
A struct with the following entries
| Entry | Description |
|---|---|
| alphas | diagonal elements of the tridiagonal matrix |
| betas | off-diagonal elements of the tridiagonal matrix |
| eigenvalues | the computed Ritz eigenvalues of the tridiagonal matrix |
| eigenvectors | State of shape $D \times $neigvals holding all low-lying eigenvalues up to neigvals |
| niterations | number of iterations performed |
| criterion | string denoting the reason why the algorithm stopped |
Convergence criterion
The algorithm terminates if the \(k\)-th (\(k\) is the argument neigvals) approximate eigenvalue changes only by a fraction smaller than \(\epsilon\) (\(k\) is the argument precision), i.e.
Here, \(\tilde{e}_k^{(n)}\) denotes the Lanczos approximation to the \(k\)-th eigenvalue after \(n\) iterations.
Usage Example
int N = 8;
int nup = N / 2;
auto block = Spinhalf(N, nup);
// Define the nearest-neighbor Heisenberg model
auto ops = OpSum();
for (int i=0; i<N; ++i) {
ops += "J" * Op("SdotS", {i, (i+1) % N});
}
ops["J"] = 1.0;
// With random intial state
auto res = eigs_lanczos(ops, block);
XDIAG_SHOW(res.alphas);
XDIAG_SHOW(res.betas);
XDIAG_SHOW(res.eigenvalues);
XDIAG_SHOW(res.eigenvectors);
// sparse matrix
auto spmat = csr_matrix(ops, block);
auto ress = eigs_lanczos(spmat, block);
let
N = 8
nup = N รท 2
block = Spinhalf(N, nup)
# Define the nearest-neighbor Heisenberg model
ops = OpSum()
for i in 1:N
ops += "J" * Op("SdotS", [i, mod1(i+1, N)])
end
ops["J"] = 1.0
# With random intial state
res = eigs_lanczos(ops, block)
@show res.alphas
@show res.betas
@show res.eigenvalues
@show res.eigenvectors
# sparse matrix
spmat = csr_matrix(ops, block)
res = eigs_lanczos(spmat, block)
end