Grid-Based K in cuEST#

The basic idea of grid-based exchange methods is to evaluate the electron repulsion integrals (ERIs) by introducing a Becke-style integration grid [1] in physical space for one of the electrons and integrating over the coordinates of the other electron analytically:

\[(pq|g_\omega|rs)^{\mathrm{grid}} \equiv \sum_{A} w_A\, X_{p}^{A}\, X_{q}^{A}\, V_{rs}^{A}\]

Here, indices \(p, q, r, s\) label atomic-orbital basis functions and \(A\) labels the grid points \(\vec R_A\) of the molecular quadrature grid with Becke weights \(w_A\). The collocation matrices carry the two basis functions of the electron integrated by quadrature,

\[X_{p}^{A} = \phi_p(\vec R_A)\]

and the potential integrals those of the electron integrated analytically:

\[V_{rs}^{A} = \int g_\omega(|\vec R_A - \vec r_2|)\,\phi_r(\vec r_2)\,\phi_s(\vec r_2)\,d\vec r_2\]

Here \(g_\omega(r) = s_{\rm FR}/r + s_{\rm LR}\operatorname{erf}(\omega r)/r\) is the range-separated exchange operator, a property of the plan with the same parameterization as the integral-direct and density-fitting plans: CUEST_GRIDKINTPLAN_PARAMETERS_EXCHANGE_FRACTION, CUEST_GRIDKINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION and CUEST_GRIDKINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA (defaults 1, 0 and 0: full-range exact exchange). The one-sided quadrature breaks the 8-fold permutational symmetry of the exact integrals: \((pq|g_\omega|rs)^{\mathrm{grid}}\) is symmetric under \(p \leftrightarrow q\) and \(r \leftrightarrow s\), but not under exchange of the bra and ket pairs. The symmetry is restored by approximating the ERIs with the explicitly symmetrized combination:

\[(pq|g_\omega|rs) \approx \frac{1}{2} \left( (pq|g_\omega|rs)^{\mathrm{grid}} + (rs|g_\omega|pq)^{\mathrm{grid}} \right)\]

A principal advantage of this approach is that the introduction of the integration grid unpins the bra indices in the ERI and allows exchange matrix evaluation to factorize in a manner that reduces the formal complexity from \(O(N^4)\) to \(O(N^3)\) (before sparsity has been considered). In cuEST, we refer to any grid-based exchange technique as a variant of “Grid-K”.

All Grid-K routines share one cuestGridKIntPlan_t plan handle (see the Grid-K plan reference), created from a molecular integration grid and a one-electron integral plan that supplies the primary basis, atomic coordinates and AO pair structure. The plan holds only geometry- and grid-dependent data, no density-dependent quantities, so a single plan serves every SCF iteration at a fixed molecular geometry.

Grid-K Exchange Matrices#

Contracting a density matrix \(D\) into the one-sided grid ERIs defines the Grid-K exchange matrix

\[K^{\mathrm{grid}}_{pq}[D] \equiv \sum_{rs} (pr|g_\omega|qs)^{\mathrm{grid}}\, D_{rs}\]

Because the one-sided grid ERIs lack bra–ket symmetry, \(K^{\mathrm{grid}}[D]\) is not a symmetric matrix. The exchange matrix of the symmetrized ERIs averages the two orderings,

\[K_{pq} = \frac{1}{2} \sum_{rs} \left[ (pr|g_\omega|qs)^{\mathrm{grid}} + (qs|g_\omega|pr)^{\mathrm{grid}} \right] D_{rs}\]

For a symmetric density matrix, the second ordering is the transpose of the first, and a single Grid-K build suffices:

\[K = \frac{1}{2} \left( K^{\mathrm{grid}}[D] + \left( K^{\mathrm{grid}}[D] \right)^{T} \right)\]

This is the matrix returned by cuestGridKSymmetricExchangeCompute. For a general density matrix, the second ordering is instead the transpose of a Grid-K build over the transposed density,

\[K = \frac{1}{2} \left( K^{\mathrm{grid}}[D] + \left( K^{\mathrm{grid}}[D^{T}] \right)^{T} \right)\]

This is the matrix returned by cuestGridKNonsymmetricExchangeCompute. Both routines accept a batch of density matrices, like their integral-direct counterparts. For symmetric density matrices, cuestGridKSymmetricExchangeDerivativeCompute returns the nuclear gradient of the exchange energy \(E_K[D] = \sum_{pq} D_{pq} K_{pq}\) at fixed density-matrix coefficients; the Grid-K energy depends on the atomic positions through the quadrature weights, the collocation matrix and the potential integrals, and all three contributions are differentiated analytically.

Symmetric Orthogonalized Overlap Fitting#

For a given grid, the quadrature error can be reduced substantially by fitting: dressing the collocation matrix so that the quadrature exactly reproduces an analytically known target, most naturally the overlap matrix. Pseudospectral and seminumerical codes have traditionally fit asymmetrically, replacing only one of the two collocation matrices, and in the raw AO basis, which can be ill conditioned. cuEST instead fits symmetrically, in the canonically orthogonalized AO basis: the dressed collocation

\[\bar X_{p}^{A} = \sum_{q} M_{pq}\, X_{q}^{A} \qquad \text{satisfies} \qquad \sum_{A} w_A\, \bar X_{p}^{A} \bar X_{q}^{A} = S_{pq}\]

on the retained orthogonal subspace, where \(S_{pq}\) is the usual AO overlap matrix. With the eigendecomposition \(S = U s\, U^T\) (eigenvalues below the canonical orthogonalization cutoff discarded), the transfer matrix is

\[M = U\, s^{+1/2}\, \Omega^{-1/2}\, s^{-1/2}\, U^{T}, \qquad \Omega = s^{-1/2}\, U^{T} S^{\mathrm{grid}}\, U\, s^{-1/2}\]

where \(S^{\mathrm{grid}}_{pq} = \sum_A w_A X_p^A X_q^A\) is the quadrature approximation of the overlap matrix. The fitting metric \(\Omega\) — the quadrature overlap in the orthonormalized basis — equals the identity for an exact grid, so the fit is a well-conditioned correction for any reasonable grid.

The fit is selected at plan creation by setting CUEST_GRIDKINTPLAN_PARAMETERS_FITTING_ALGORITHM to CUEST_GRIDKINTPLAN_PARAMETERS_FITTING_ALGORITHM_OVERLAP_SYMMETRIC and is controlled by two cutoffs: CUEST_GRIDKINTPLAN_PARAMETERS_FITTING_ORTHOGONALIZATION_CUTOFF on the eigenvalues of \(S\) and CUEST_GRIDKINTPLAN_PARAMETERS_FITTING_CUTOFF on the eigenvalues of \(\Omega\). With the fit enabled, the exchange matrices and nuclear gradients returned by the Grid-K compute routines are those of the dressed collocation, \(X \rightarrow \bar X\), and exactly account for the response of the transfer matrix.

At present, we do not include the inter-subspace response of the canonical orthogonalization in cases where linear dependencies are removed; we expect the errors due to the neglect of these terms to be on the order of the noise introduced into the SCF potential surface by discarding basis functions. Inclusion of these terms is straightforward, but it can become extremely ill-conditioned if many orthogonal functions lie near the numerical cutoff between included/excluded functions, which is likely why most SCF gradient implementations also neglect these contributions.

Compensated Grid-K#

The accuracy of Grid-K can be improved by applying the grid approximation to a smaller quantity than the full exchange energy. In the difference-density (dSCF) picture [2], the density matrix is partitioned as

\[D_{pq} = D^{\varnothing}_{pq} + D^{\Delta}_{pq}\]

where \(D^{\varnothing}\) is a density matrix constructed from a superposition of atomic densities (SAD). This matrix is atom-block diagonal and independent of the molecular geometry — the same construction behind the usual SAD initial guess. The exchange energy is re-partitioned before any approximation is made, and only the term quadratic in the much smaller difference density is evaluated on the grid:

\[E_K \approx E_K[D^{\varnothing}] + 2\, E_K[D^{\varnothing}, D^{\Delta}] + E^{\mathrm{grid}}_K[D^{\Delta}]\]

The first two terms, the SAD exchange energy and the SAD/difference bilinear cross term, are evaluated analytically, and the exchange matrix that enters the Fock matrix is the sum of the analytic exchange of the SAD density and the grid exchange of the difference density, \(K = K[D^{\varnothing}] + K^{\mathrm{grid}}[D^{\Delta}]\). Everything required for the analytic pieces — the exchange matrix of the SAD density, its energy gradient, and the gradients of the bilinear forms — is provided by the integral-direct exchange routines, which accept difference densities as ordinary inputs.

Because \(D^{\Delta}\) is smaller than \(D\), the quadrature error shrinks accordingly, while the re-partitioned energy remains variational and analytically differentiable (\(D^{\varnothing}\) carries no geometric response). Note that the familiar dot product \(E_K = \sum_{pq} D_{pq} K_{pq}\) does not hold for the re-partitioned energy: the energy must be assembled from the three terms above.

We refer to the combination of this SAD compensation with the symmetric orthogonalized overlap fitting — two independent corrections — as Compensated Grid-K. A sample implementation of the Compensated Grid-K procedure can be found in the NVIDIA/CUDALibrarySamples GitHub repository.

Numerical Thresholds#

Four thresholds control the accuracy of a Grid-K build; all four are evaluated as absolute cutoffs.

  • Pair screening: the thresholdPQ argument of cuestAOPairListCreate, inherited through the one-electron integral plan. A primitive pair is retained when its overlap magnitude \(|(p|q)|\) (contraction coefficients included, primitives treated as \(s\) functions) exceeds the threshold; a shell pair is retained when any of its primitive pairs is retained.

  • Collocation threshold: CUEST_GRIDKINTPLAN_PARAMETERS_THRESHOLD_COLLOCATION (default \(10^{-18}\)). A primitive Gaussian is significant at a grid point when its magnitude \(|c|\, e^{-\alpha r^2}\) exceeds the threshold; grid points and basis functions with no significant collocation are dropped.

  • Orthogonalization cutoff: CUEST_GRIDKINTPLAN_PARAMETERS_FITTING_ORTHOGONALIZATION_CUTOFF (default \(10^{-6}\)). Eigenvalues of the overlap matrix \(S\) below the cutoff are discarded in the canonical orthogonalization underlying the fit. The details of the orthogonalization may be obtained from the plan via cuestQuery: CUEST_GRIDKINTPLAN_FITTING_NUM_MO returns the number of retained orthogonal functions and CUEST_GRIDKINTPLAN_CANONICAL_ORTHOGONALIZATION_MATRIX_GPU the canonical orthogonalization matrix itself.

  • Fitting cutoff: CUEST_GRIDKINTPLAN_PARAMETERS_FITTING_CUTOFF (default \(10^{-2}\)). Eigenvalues of the fitting metric \(\Omega\) below the cutoff are excluded from the fit. The eigenvalues of \(\Omega\) are dimensionless and near unity for a good grid, so this absolute cutoff acts as a fraction of the ideal value. The extreme eigenvalues of \(\Omega\) may be queried from the plan (CUEST_GRIDKINTPLAN_FITTING_MIN_EIGENVALUE and CUEST_GRIDKINTPLAN_FITTING_MAX_EIGENVALUE) as a diagnostic of grid quality.

Recommendations#

We recommend Compensated Grid-K — the symmetric orthogonalized overlap fit together with the dSCF procedure — for basis sets of triple-zeta quality or better and for basis sets containing diffuse functions. Note that both the accuracy of the method and its performance advantage over integral-direct exchange improve with increasing basis set size. The SG-0 grid [3] is a good general-purpose grid for Compensated Grid-K.

References#