Density Mixing — Pulay, DIIS, and Kerker
The Kohn-Sham equations are nonlinear: the effective potential depends on the density, which depends on the orbitals, which depend on the potential. Solving this fixed point naively almost never converges. Density mixing is the numerical machinery that turns a divergent fixed-point iteration into a robust SCF loop, and the choice of mixer is often the difference between convergence in 15 steps and convergence never.
The fixed-point problem
A single self-consistent-field iteration maps an input density to an output density:
The converged density is the fixed point . The naive iteration almost always oscillates or diverges because of charge sloshing: small changes in the density at long wavelengths (small ) produce large changes in the Hartree potential (), which feed back into a large output-density swing the other way.
Mixing combines with (and possibly earlier iterates) to damp this feedback loop into something that converges.
Linear mixing
The simplest mixer is a weighted average:
A small (typically –) damps oscillation but yields slow convergence — often hundreds of SCF iterations for metals. Linear mixing is robust but not competitive; it serves as a fallback and as a baseline against which fancier mixers are measured.
Residual minimization
Define the SCF residual:
At the fixed point . Pulay's insight (1980) was that, given a history of input densities and their residuals, we can construct a linear combination
whose predicted residual
has minimum norm. The optimal coefficients extrapolate toward using only iterates we have already computed — no extra Hamiltonian builds, just linear algebra on a small matrix.
Pulay's DIIS equations
Minimizing subject to with a Lagrange multiplier yields the linear system
with the overlap matrix (the inner product taken in real space or, in KRONOS, in G-space for numerical robustness). Once are obtained, the mixed input density for the next SCF iteration is
The factor here is a small linear-mixing step applied inside the DIIS extrapolation — it stabilizes the procedure when the residual history is short and the matrix is ill-conditioned.
History depth and stability
KRONOS uses a default history depth of . Larger in principle improves the rate of convergence, but tends to become ill-conditioned because successive residuals get nearly parallel as the SCF converges. KRONOS detects this and falls back to using only the most recent entry when the smallest pivot in the LU factorization drops below :
if (min_pivot < 1e-15) {
// matrix singular — drop oldest, retry with shorter history
}
Without this safeguard, a near-converged SCF can suddenly diverge as numerical noise in produces extrapolation coefficients of order .
Kerker preconditioning for metals
Charge sloshing in metals is dominated by long wavelengths — the divergent in the Hartree response means small- residuals are over-weighted in . Kerker's fix (1981) is to precondition the residual in G-space before mixing:
The screening wavevector is typically chosen near the Thomas-Fermi screening length. KRONOS uses , which is appropriate for most metals. The preconditioner suppresses the small- components of the residual, so DIIS no longer "sees" the charge-sloshing modes and converges in 15–30 steps even for transition metals.
For insulators, the Kerker preconditioner is unnecessary (no Fermi surface, no sloshing) and may slow convergence. KRONOS activates Kerker only when smearing is non-None, i.e., when the calculation is treating a metal.
Convergence criteria
KRONOS declares convergence when both of these are satisfied for a single SCF step:
- Energy:
- Density:
The density norm is computed in G-space to avoid aliasing artifacts from the real-space grid. Defaults are and , controllable via convergence.energy_threshold and convergence.density_threshold in the YAML input.
A non-converged run after max_scf_steps (default 200) writes a partial output marked "converged": false and emits a diagnostic suggesting tighter ecutwfc, denser k-grid, or smaller mixing .
Initial density and convergence speed
The closer the initial guess to the fixed point, the fewer SCF iterations are required. KRONOS initializes the density as a superposition of atomic densities, , using the rho_atomic data field from the UPF file. When a pseudopotential lacks rho_atomic (some older HGH files), the initial density falls back to uniform over the cell — typically adding 5–10 SCF iterations.
How KRONOS implements this
The mixer lives in src/solver/mixing.cpp as the PulayMixer class. Its responsibilities, in order:
- Push each iteration's pair into a ring buffer of depth .
- Apply the Kerker preconditioner to each residual when metallic smearing is active.
- Build the matrix in G-space (Parseval): .
- Solve the augmented linear system, falling back to shorter history if the pivot threshold is crossed.
- Construct the mixed input density, clamp , and renormalize to conserve total electron count.
After the mix, the loop returns to step (a) of the SCF flow at SCF Flowchart. The data structures and call sites are documented in the architecture page on Algorithms.
References
- Pulay, P. "Convergence acceleration of iterative sequences. The case of SCF iteration", Chem. Phys. Lett. 73, 393 (1980).
- Kerker, G. P. "Efficient iteration scheme for self-consistent pseudopotential calculations", Phys. Rev. B 23, 3082 (1981).
- Kresse, G. & Furthmüller, J. "Efficiency of ab-initio total energy calculations for metals and semiconductors", Comput. Mater. Sci. 6, 15 (1996).
- Johnson, D. D. "Modified Broyden's method for accelerating convergence in self-consistent calculations", Phys. Rev. B 38, 12807 (1988).
- Martin, R. M. Electronic Structure: Basic Theory and Practical Methods, Cambridge University Press, 2004 — Ch. 9.