This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/lobpcg

LOBPCG, the lowest eigenpairs of an operator you can only apply

lobpcg(apply_h, precondition, vectors, values, max_steps, nconv, tol) finds the lowest few eigenvalues and eigenvectors of a Hermitian operator H that is given as a function: apply_h(x) returns H applied to each row of x. The matrix is never formed, so H can be a stencil, an FFT sandwich, or anything else that is cheaper to apply than to store.

LOBPCG is short for locally optimal block preconditioned conjugate gradient. Each step searches a small subspace for the vectors with the lowest Rayleigh quotient , and the subspace is three blocks of rows: the current approximations, their preconditioned residuals (the direction in which the quotient falls fastest), and the step each approximation took last time. The lowest eigenvalues of H restricted to that subspace (Ritz values) and the vectors that achieve them (Ritz vectors) become the next approximations. The post lobpcg-finds-the-lowest-states explains why this works, on a particle in a box.

The arguments:

  • vectors is [nb, n] complex, one starting guess per row; it comes back holding the eigenvectors, orthonormal, lowest first. A real problem is a complex one whose imaginary parts are zero.
  • values is [nb]; it comes back holding the eigenvalues.
  • precondition(r, x) returns an approximation to for the residual r of the row x, or r itself when there is nothing better: no_preconditioner is that.
  • Only the lowest nconv rows are held to tol, a bound on the norm of for a unit x. The rows above them are a buffer: the top of a block converges slowest, because nothing above it in the block keeps it apart from the rest of the spectrum.
  • It returns the largest residual norm among those nconv rows.

Ask for a tol the arithmetic can reach. On the test problems below the residual stops falling near , and an iteration held at that floor with nothing left to find can come apart: on the 90 by 90 test matrix, asked for , the largest residual was back above by step 120 and above 1 by step 130. The DFT engine asks for .

lobpcg_start and lobpcg_step are the same iteration a step at a time, for a caller that wants to watch it.

Used with import lobpcg. The plane-wave DFT engine dft/pwdft_it uses it for its bands.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 49–472