# 4.5.3 Direct Inversion in the Iterative Subspace (DIIS)

The SCF implementation of the Direct Inversion in the Iterative Subspace (DIIS) method759, 760 uses the property of an SCF solution that requires the density matrix to commute with the Fock matrix:

 ${\rm{\bf SPF}}-{\rm{\bf FPS}}=\bm{0}\;.$ (4.30)

During the SCF cycles, prior to achieving self-consistency, it is therefore possible to define an error vector e${}_{i}$, which is non-zero except at convergence:

 ${\rm{\bf SP}}_{i}{\rm{\bf F}}_{i}-{\rm{\bf F}}_{i}{\rm{\bf P}}_{i}{\rm{\bf S}}% ={\rm{\bf e}}_{i}$ (4.31)

Here $\mathbf{P}_{i}$ is obtained by diagonalizing $\mathbf{F}_{i}$, and

 $\mathbf{F}_{k}=\sum\limits_{j=1}^{k-1}{c_{j}{\rm{\bf F}}_{j}}$ (4.32)

The DIIS coefficients $c_{k}$, are obtained by a least-squares constrained minimization of the error vectors, viz

 $Z=\left({\sum\limits_{k}{c_{k}{\rm{\bf e}}_{k}}}\right)\cdot\left({\sum\limits% _{k}{c_{k}{\rm{\bf e}}_{k}}}\right)$ (4.33)

where the constraint $\sum_{k}c_{k}=1$ is imposed to yield a set of linear equations, of dimension $N+1$:

 $\left({{\begin{array}[]{*{20}c}{{\rm{\bf e}}_{1}\cdot{\rm{\bf e}}_{1}}\hfill&% \cdots\hfill&{{\rm{\bf e}}_{1}\cdot{\rm{\bf e}}_{N}}\hfill&1\hfill\\ \vdots\hfill&\ddots\hfill&\vdots\hfill&\vdots\hfill\\ {{\rm{\bf e}}_{N}\cdot{\rm{\bf e}}_{1}}\hfill&\cdots\hfill&{{\rm{\bf e}}_{N}% \cdot{\rm{\bf e}}_{N}}\hfill&1\hfill\\ 1\hfill&\cdots\hfill&1\hfill&0\hfill\\ \end{array}}}\right)\left({{\begin{array}[]{*{20}c}{c_{1}}\hfill\\ \vdots\hfill\\ {c_{N}}\hfill\\ \lambda\hfill\\ \end{array}}}\right)=\left({{\begin{array}[]{*{20}c}0\hfill\\ \vdots\hfill\\ 0\hfill\\ 1\hfill\\ \end{array}}}\right)\;.$ (4.34)

Convergence criteria require the largest element of the $N$th error vector to be below a cutoff threshold, usually $10^{-5}$  a.u. for single point energies, but often increased to $10^{-8}$ a.u. for optimizations and frequency calculations.

The rate of convergence may be improved by restricting the number of previous Fock matrices used for determining the DIIS coefficients,

 $\mathbf{F}_{k}=\sum_{j=k-(L+1)}^{k-1}c_{j}\,\mathbf{F}_{j}\;.$ (4.35)

Here $L$ is the size of the DIIS subspace, which is set using the $rem variable DIIS_SUBSPACE_SIZE. As the Fock matrix nears self-consistency, the linear matrix equations in Eq. (4.34) tend to become severely ill-conditioned and it is often necessary to reset the DIIS subspace (this is automatically carried out by the program). Finally, on a practical note, we observe that DIIS has a tendency to converge to global minima rather than local minima when employed for SCF calculations. This seems to be because only at convergence is the density matrix in the DIIS iterations idempotent. On the way to convergence, one is not on the true energy surface, and this seems to permit DIIS to “tunnel” through barriers in wave function space. This is usually a desirable property, and is the motivation for the options that permit initial DIIS iterations before switching to direct minimization to converge to the minimum in difficult cases. The following$rem variables permit some customization of the DIIS iterations:

DIIS_SUBSPACE_SIZE
Controls the size of the DIIS and/or RCA subspace during the SCF.
TYPE:
INTEGER
DEFAULT:
15
OPTIONS:
User-defined
RECOMMENDATION:
None

DIIS_PRINT
Controls the output from DIIS SCF optimization.
TYPE:
INTEGER
DEFAULT:
0
OPTIONS:
0 Minimal print out. 1 Chosen method and DIIS coefficients and solutions. 2 Level 1 plus changes in multipole moments. 3 Level 2 plus Multipole moments. 4 Level 3 plus extrapolated Fock matrices.
RECOMMENDATION:
Use the default

Note:  In Q-Chem 3.0 the DIIS error is determined by the maximum error rather than the RMS error. For backward compatibility the RMS error can be forced by using the following \$rem:

DIIS_ERR_RMS
Changes the DIIS convergence metric from the maximum to the RMS error.
TYPE:
LOGICAL
DEFAULT:
FALSE
OPTIONS:
TRUE, FALSE
RECOMMENDATION:
Use the default, the maximum error provides a more reliable criterion.

DIIS_SEPARATE_ERRVEC
Control optimization of DIIS error vector in unrestricted calculations.
TYPE:
LOGICAL
DEFAULT:
FALSE Use a combined $\alpha$ and $\beta$ error vector.
OPTIONS:
FALSE Use a combined $\alpha$ and $\beta$ error vector. TRUE Use separate error vectors for the $\alpha$ and $\beta$ spaces.
RECOMMENDATION:
When using DIIS in Q-Chem a convenient optimization for unrestricted calculations is to sum the $\alpha$ and $\beta$ error vectors into a single vector which is used for extrapolation. This is often extremely effective, but in some pathological systems with symmetry breaking, can lead to false solutions being detected, where the $\alpha$ and $\beta$ components of the error vector cancel exactly giving a zero DIIS error. While an extremely uncommon occurrence, if it is suspected, set DIIS_SEPARATE_ERRVEC = TRUE to check.