The requirement that the linear density fitting error in the integral exactly vanishes introduces unphysical long range contributions to the approximate density when the auxiliary basis is incomplete. A quasi-robust density fitting formulation is presented where spatial locality is recovered at the expense of permitting a linear error that is made small by the fitting procedure, which involves optimising the Coulomb potential of the approximate charge density. The method is shown to be stable and almost as accurate as standard robust density fitting without local approximations in practical calculations using standard density fitting basis sets.

## I. INTRODUCTION

The mean-field or correlated treatment of the electronic Schrödinger equation using the LCAO (linear combination of atomic orbital) approach necessitates the evaluation of four-centre two-electron repulsion integrals

where *χ*_{μ} are atomic orbitals, *ϕ*_{p} = *C*_{μp}*χ*_{μ} are molecular orbital, and *C*_{μp} are the molecular orbital coefficients. The density fitting approximation was introduced to reduce the computational effort required to build the integrals (*rs*$|$*pq*) through a reduced rank formulation.^{1,2} The central idea is to fit each charge density *χ*_{μ}(**r**_{1})*χ*_{ν}(**r**_{1}) with an auxiliary basis set of atom-centred density fitting functions *ϕ*_{P}(**r**_{1}) so that

The coefficients of the approximate charge density $|\mu \nu \u0303$) are determined by minimising the error in the Coulomb energy

This enforces that the error in the integral is bilinear in the fitting error *ϵ*_{J} = (*ϵ*_{κλ}$|$*ϵ*_{μν}) and the approximation is termed robust.^{3} The optimal coefficients are computed by solving

This formulation has the unsatisfactory feature that although the AOs $|$*μν*) belong to at most two atoms, the auxiliary functions $|$*P*) used to fit that charge density are drawn from all of the atoms of the system and the coefficients decay in the worst case only as the reciprocal of the distance between the charge centre of $|$*μν*) and the fitting function $|$*P*).^{4}

Local density fitting formulations circumvent this extraneous long-range behaviour either (a) by replacing Eq. (5), which is a least squares fit to the density using the Coulomb metric, by a least squares fit with a short-ranged metric such as the overlap,^{5–7} Yukawa-Coulomb^{4} or attenuated^{8} or Gaussian damped^{9} Coulomb metrics, or (b) by using a domain-based fit that excludes contributions from distant fitting functions *a priori*.^{10–14} In both cases, the error *ϵ*_{J} in the integral Eq. (4) is then linearly dependent on the fitting error and, when using standard libraries of atom-centred density fitting functions, the magnitude of linear error makes Eq. (4) impractical for general application.^{5,15–18} Local density fitting therefore either follows a pair-domain scheme, with standard fitting in the unified domain of (*κλ*$|$ and $|$*μν*), or uses Dunlap’s robust formula for the integral^{3} that removes the linear error by adding the linear terms

In all cases, the dependence on integrals (*Q*$|$*μν*) with (*Q*$|$ distant from $|$*μν*) remains, appearing either in the fitting formula or in the integral expression.

Consider again Eq. (6), which determines the fitting coefficients. The functions $|$*P*) fit the charge density $|$*μν*) and the functions (*Q*$|$ act as test functions where the Coulomb potential from $|\mu \nu \u0303$) should be accurate or, more precisely, yield accurate Coulomb energies $(Q|\mu \nu \u0303)$. If we insert an approximate resolution of the identity (RI) $1\u2248\u2211PR|PSPR\u22121R|$, where *S*_{PR} is the overlap metric between auxiliary basis functions, we obtain

Here (*Rμν*) is a three-centre one-electron overlap integral. The decay of the coefficients $C\mu \nu P$ follows $SPR\u22121(R\mu \nu )$ and is therefore exponential in the distance between the charge centre $|$*μν*) and the function $|$*P*). The test functions (*Q*$|$, however, span the whole molecule. Equation (8) suggests $C\mu \nu P=SPR\u22121(R\mu \nu )$, which is understood to be impractical as a direct means for determining $C\mu \nu P$ because the incompleteness errors in the approximate RI are substantial, leading to large linear errors in the Coulomb energy.^{6} For functions $|$*μ*) and $|$*ν*) located on different atoms, the charge centre $|$*μν*) lies in the vacuum between the atoms, whereas the fitting functions are all atom-centred and therefore often not well suited to fitting $|$*μν*). As a consequence, the approximate charge density $|\mu \nu \u0303$) resulting from Eq. (6) acquires unphysical contributions from $|$*P*) far away from $|$*μν*) that cancel the linear errors and yield the correct Coulomb energy $(Q|\mu \nu \u0303)=(Q|\mu \nu )$. The long-range behaviour of standard density fitting is thus seen to be a consequence of the requirement that the linear error in the integral vanishes entirely when the RI is incomplete. To summarise, the auxiliary functions in Eq. (5) have a dual role: they are used both to approximate a charge distribution $|$*μν*) and to test the accuracy of the approximation $|\mu \nu \u0303$). It is the second role that is responsible for the non-locality inherent to standard density fitting.

This paper communicates a new fully separable local density fitting formulation where a charge density $|$*μν*) is fit only using functions $|$*P*) near by and where it is not necessary to compute the Coulomb interaction between $|$*μν*) and distant functions (*Q*$|$. The method is derived by decoupling the two roles of the auxiliary basis functions and by permitting linear error that is made small by the fitting procedure. It will be shown to be stable and almost as accurate as standard robust density fitting without local approximations in practical calculations using standard density fitting basis sets.

## II. QUASI-ROBUST LOCAL DENSITY FITTING

The target integrals are computed as

For a given set of *μν*, a set of fitting functions *P*_{μν} ∈ {*P*} local to $|$*μν*) are selected according to the criteria

with *S*_{PP} = 1. A set of test functions *X*_{μν} ∈ {*P*} are selected according to the criteria

where $f(A,B)=\alpha \beta \alpha +\beta |A\u2212B|2$ for two functions with centres **A**, **B** and (smallest primitive) exponents *α*, *β*. The coefficients $C\mu \nu P$ are determined so that the Coulomb potential is accurate at the test points, by minimising the errors in the Coulomb energies between the charge density $|\mu \nu \u0303$) and the test densities $|$*X*),

The number of test functions *X*_{μν} is larger than the number of fitting functions *P*_{μν} and the appropriate solution to this system of equations is achieved through QR factorisation of the rectangular matrix (*P*_{μν}$|$*X*_{μν}).

The criteria for selecting the domain *P*_{μν} of fitting functions follows directly from the RI in Eq. (8). The criteria for selecting the test functions *X*_{μν} is based on Gauss’s theorem: If the Coulomb potential is correct at functions around $|\mu \nu \u0303$) that do not overlap with $|\mu \nu \u0303$), then it will also be correct at functions further away. In this work, the test functions have been drawn from the density fitting set, but any set could in principle be used. Using delta functions, for example, is equivalent to probing the Coulomb potential on a grid. The current choice of test set is preferable since it retains a direct link to robust density fitting. This can be seen by noticing that Eq. (12) reduces to Eq. (6) when {*X*_{μν}} = {*P*_{μν}} = {*P*}.

The above local density fitting scheme has several favourable features: In the limit of vanishing *T* and infinite *R*, standard robust density fitting is recovered; the coefficients $C\mu \nu P$ are in no way dependent on *κλ* and the formulation is in this sense fully separable and straightforward to parallelise; the coefficients $C\mu \nu P$ can be computed with costs that scale linearly with system size; the only components with quadratic scaling over the lengthscale determined by the slow 1/*r* decay are the integrals (*P*$|$*Q*), which only need to be computed once at the start of a calculation.

The numerical results reported in Sec. III will demonstrate that contrary to the predominant view in the literature, it is possible to use non-robust local formulas and obtain an accuracy comparable to that of standard robust density fitting for Coulomb and exchange contributions to the Fock matrix and for the integrals required for the MP2 energy and that the naturally local formulation of density fitting presented above achieves this. The implications for efficient algorithms for computing Coulomb, exchange, and MP2 integrals are discussed in Sec. IV.

## III. NUMERICAL TESTS

The accuracy of the quasi-robust local density fitting approximation for Coulomb, exchange, and MP2 integrals was first assessed by comparing the resulting Coulomb (J), exchange (K), and MP2 correlation energies to those computed exactly and to those computed using standard robust density fitting. First, a Hartree–Fock calculation was performed using the def2-TZVPP basis set^{19} and the RI-JK approximation as implemented in the Turbomole program package.^{20} This involves standard robust density fitting for both the Coulomb and exchange contributions to the energy and Fock matrix. Weigend’s RI-JK fitting basis sets^{21} and RI-MP2 sets^{22} were used. Using the converged orbitals and the same basis sets, the J, K, and MP2 correlation energies were computed using quasi-robust local density fitting (QR-J, QR-K, and QR-MP2). The energies were also computed using standard robust density fitting^{20,23} and analytically computed 4c-2e electron repulsion integrals. All calculations were performed with a locally modified version of the Turbomole program.^{24}

Figure 1 displays the density fitting error in the QR-J, QR-K, and QR-MP2 energies as a function of the overlap threshold *T* for the alkane chain C_{24}H_{50} in an idealised linear arrangement. Overlap screening was performed for sets of *μν* belonging to the same shell pair and a conservative threshold of $R=40\u2009a02$ was chosen to select the test functions. Figure 2 displays the corresponding distribution of distances between the fitting functions *P*_{μν} and the centre of the charge density $|$*μν*), summed over all shell pairs *μν*, and reveals the spatial locality of the fitting set as a function of *T*.

Each of the J, K, and MP2 energies converges to the standard RI values as the threshold *T* is reduced. The K and MP2 energies converge rapidly and with a threshold of 1 × 10^{−5} or 1 × 10^{−6}, and local density fitting is as accurate as robust density fitting. The QR-J energy converges more slowly, requiring a tighter threshold of 1 × 10^{−7} or 1 × 10^{−8}. Since QR-DF is non-robust, the QR-K energies are not an upper bound, which can result in a variational collapse if the errors are too large.^{25} The threshold of 1 × 10^{−6} was tight enough to avoid variational collapse in all cases. Linear alkanes represent a worst case scenario for local density fitting^{4} due to the large surface area, which corresponds to regions at the edge of the molecule where the atom-centred RI basis is poorly saturated. Examining the corresponding Fig. 2 reveals that not only are distant fitting functions not required for an accurate fit to the potential but also more than half of the functions nearby can also be safely discarded on the basis of poor overlap with the target charge density.

Table I lists the signed fitting for the J, K, and MP2 energies using the QR and standard RI methods for a sequence of alkanes each in an idealised linear geometry, for a cluster of 21 water molecules taken from the Cambridge Cluster Database,^{26} for Cu$(C3H6O)4+$, the largest Cu^{+} complex from the CuCNDe33 dataset,^{27} for the methotrexate molecule (C_{20}N_{8}O_{5}H_{22}) and the 4T-MeOH cluster model for the adsorption of methanol on the H-ZSM-5 zeolite, taken from Ref. 28. The def2-TZVPP basis set combinations was used in all cases and fitting errors are reported in micro-Hartree per occupied orbital for J and K and per valence orbital for MP2. Conservative thresholds *T* = 1 × 10^{−6} for exchange and MP2 correlation and *T* = 1 × 10^{−8} for the Coulomb energy were used. The MP2 values for C_{32}H_{66} and methotrexate are missing because the calculation without density fitting required more memory than was available on the computers used for these calculations. The accuracy of the local density fitting method matches that of standard density fitting for the progression of alkane chains with increasing length, and the density fitting error per occupied orbital is constant for both methods. For the more globular structures, the accuracy of the local fitting method is equally impressive.

Molecule . | QR-J . | RI-J . | QR-K . | RI-K . | QR-MP2 . | RI-MP2 . |
---|---|---|---|---|---|---|

C_{8}H_{18} | −6 | −6 | 9 | 9 | 9 | 10 |

C_{16}H_{34} | −6 | −6 | 9 | 9 | 9 | 10 |

C_{24}H_{50} | −6 | −6 | 9 | 9 | 9 | 10 |

C_{32}H_{66} | −6 | −6 | 10 | 9 | … | … |

$(H2O)21$ | −6 | −6 | 10 | 10 | 7 | 7 |

Cu$(C3H6O)4+$ | −6 | −6 | 10 | 10 | 5 | 6 |

C_{20}N_{8}O_{5}H_{22} | −4 | −4 | 12 | 12 | … | … |

4T-MeOH | −4 | −4 | 8 | 8 | 5 | 6 |

Molecule . | QR-J . | RI-J . | QR-K . | RI-K . | QR-MP2 . | RI-MP2 . |
---|---|---|---|---|---|---|

C_{8}H_{18} | −6 | −6 | 9 | 9 | 9 | 10 |

C_{16}H_{34} | −6 | −6 | 9 | 9 | 9 | 10 |

C_{24}H_{50} | −6 | −6 | 9 | 9 | 9 | 10 |

C_{32}H_{66} | −6 | −6 | 10 | 9 | … | … |

$(H2O)21$ | −6 | −6 | 10 | 10 | 7 | 7 |

Cu$(C3H6O)4+$ | −6 | −6 | 10 | 10 | 5 | 6 |

C_{20}N_{8}O_{5}H_{22} | −4 | −4 | 12 | 12 | … | … |

4T-MeOH | −4 | −4 | 8 | 8 | 5 | 6 |

Table II reports the differences between the local density fitted and robust density fitted isomerisation energies for a subset of the ISOL (large isomerisation) test set of molecules,^{29} which are between 24 and 42 atoms in size and large enough for the local approximations to take effect. The same TZVPP basis set combination and thresholds *T*, *R* were used for these calculations as those in Table I, but here the isomerisation energies were computed using the converged self-consistent Hartree–Fock energies, employing density fitting for both J and K. Correspondingly, the RI-MP2 energy was computed using orbitals converged using RI-JK and the QR-MP2 energy was computed using the orbitals converged using the QR-JK method. No variational collapse was observed in any of the HF calculations performed. The values in Table II show that the converged HF energies obtained by local density fitting are as accurate as the energies obtained by standard density fitting, with an RMS error compared to HF isomerisation energies computed using analytic 4c-2e integrals of 0.07 kJ/mol compared to 0.06 kJ/mol for standard fitting.

. | HF . | RI-JK . | QR-JK . | MP2 . | RI-MP2 . | QR-MP2 . |
---|---|---|---|---|---|---|

2 | −83.69 | −83.76 | −83.73 | −186.86 | −186.99 | −187.28 |

3 | −50.58 | −50.61 | −50.57 | −41.15 | −41.15 | −41.13 |

5 | −95.83 | −95.84 | −95.87 | −157.51 | −157.50 | −158.05 |

9 | −80.88 | −80.92 | −80.94 | −95.62 | −95.68 | −95.70 |

10 | −1.00 | −1.05 | −1.04 | −38.73 | −38.74 | −38.77 |

11 | −1169.51 | −1169.60 | −1169.67 | −538.24 | −538.06 | −538.77 |

13 | −124.01 | −124.01 | −123.98 | −153.29 | −153.27 | −151.31 |

14 | 2.00 | 2.00 | 2.03 | −22.24 | −22.16 | −22.40 |

15 | 14.75 | 14.70 | 14.65 | 2.79 | 3.01 | 2.12 |

20 | −21.23 | −21.22 | −21.20 | −24.22 | −24.22 | −22.34 |

21 | −23.36 | −23.50 | −23.50 | −49.97 | −50.05 | −51.57 |

23 | −73.22 | −73.26 | −73.21 | −123.56 | −123.56 | −123.83 |

RMSD | 0.06 | 0.07 | 0.10 | 0.97 |

. | HF . | RI-JK . | QR-JK . | MP2 . | RI-MP2 . | QR-MP2 . |
---|---|---|---|---|---|---|

2 | −83.69 | −83.76 | −83.73 | −186.86 | −186.99 | −187.28 |

3 | −50.58 | −50.61 | −50.57 | −41.15 | −41.15 | −41.13 |

5 | −95.83 | −95.84 | −95.87 | −157.51 | −157.50 | −158.05 |

9 | −80.88 | −80.92 | −80.94 | −95.62 | −95.68 | −95.70 |

10 | −1.00 | −1.05 | −1.04 | −38.73 | −38.74 | −38.77 |

11 | −1169.51 | −1169.60 | −1169.67 | −538.24 | −538.06 | −538.77 |

13 | −124.01 | −124.01 | −123.98 | −153.29 | −153.27 | −151.31 |

14 | 2.00 | 2.00 | 2.03 | −22.24 | −22.16 | −22.40 |

15 | 14.75 | 14.70 | 14.65 | 2.79 | 3.01 | 2.12 |

20 | −21.23 | −21.22 | −21.20 | −24.22 | −24.22 | −22.34 |

21 | −23.36 | −23.50 | −23.50 | −49.97 | −50.05 | −51.57 |

23 | −73.22 | −73.26 | −73.21 | −123.56 | −123.56 | −123.83 |

RMSD | 0.06 | 0.07 | 0.10 | 0.97 |

The QR-MP2 values are less accurate. Since Table I demonstrates that the QR-MP2 energy is accurate when the correct orbitals and eigenvalues are provided, the slightly poorer MP2 energies in Table II most likely result from the deterioration in the virtual orbitals and eigenvalues due to the local fitting at the SCF level. Indeed, the cases where a large MP2 deviation is observed are also the cases where the orbital relaxation from RI-HF to QR-HF is significant. Nonetheless, the maximum local density fitting error in the computed QR-MP2 isomerisation energies is only 2 kJ/mol.

## IV. PERSPECTIVES

The numerical results show that accurate HF and MP2 energies can be obtained using the quasi-robust local density fitting method. From a formal perspective, this approach is computationally attractive since the coefficients $C\mu \nu P$ are zero unless $|$*μ*), $|$*ν*), and $|$*P*) have non-negligible overlap and the number of $C\mu \nu P$ is therefore small and grows linearly with system size. Similarly the only (*Q*$|$*μν*) integrals that are required are those where (*Q*$|$ and $|$*μν*) are connected by overlap criteria, which also results in an early onset of linear scaling with system size for the 3c-2e integral evaluation. The cost of solving the fitting equations for each block of *μν* is independent of system size but carries an increased prefactor since QR factorisation (or divide and conquer single value decomposition) must be performed in the place of Cholesky decomposition.

In the context of efficient linear-scaling algorithms for computing HF exchange, quasi-robust density fitting is expected to be both more accurate and more efficient than ARI (atomic RI), which although restricts the fitting functions $|$*P*) to those near to $|$*μν*) uses the whole set of test functions (*Q*$|$ and requires the same 3c-2e evaluation as the full RI.^{11,12} Since QR-K is as accurate as RI-K, it is more accurate than the COSX pseudospectral method,^{30} but to properly compare the relative costs efficient QR-K implementations must be designed and tested, for example, one that combines quasi-robust local density fitting with the LinK density screened exchange algorithm^{31,32} and uses a low-scaling proxy for Eq. (10).

Replacing standard density fitting with quasi-robust density fitting for the evaluation of the HF Coulomb contribution does not change the scaling since the cubic cost of evaluating the fitting coefficients can be avoided through early contraction with the density matrix.^{33} The overall scaling for the Coulomb term is in both cases determined by the number of required (*κλ*$|$*μν*), which is quadratic over the lengthscale of non-negligible Coulomb interactions. Any computational saving of using the QR fitting in place of standard fitting would come from replacing the Cholesky decomposition of the full (*Q*$|$*P*) matrix, at $O(N3)$ cost with $O(N)$ QR factorisations of small matrices. The size regime where this becomes advantageous is also the regime where it is likely to be more efficient to use the existing efficient linear-scaling methods based on multipole moments for far-field contributions.^{34,35}

Quasi-robust local density fitting brings distinct advantages in the context of local correlation methods. Most implementations of PAO (projected atomic orbital) and PNO (pair natural orbital) local correlation methods^{14,36,37} use pair-domains for local density fitting, which requires integrals 3c-2e integrals (*Q*_{μi}$|$*μi*) and (*Q*_{νj}$|$*μi*) for all pairs of localised occupied orbitals *i*, *j* that have significant pair energies. In the quasi-robust formulation, the density fitting can be performed for *i* independently of *j* and the Coulomb integral formula does not require the cross terms (*Q*_{νj}$|$*μi*). Therefore, once the fitting coefficients have been computed, constructing the integrals is significantly simpler and cheaper. Moreover, the simplicity of the indexing required for the integral formula makes it significantly more straightforward to cast local correlation methods as a sequence of sparse tensor operations so that the state-of-the-art sparse tensor libraries suitable can be used to exploit modern massively parallel computer architectures.

## ACKNOWLEDGMENTS

D.P.T. thanks the Royal Society for financial support. This article is dedicated to the memory of Professor Reinhart Ahlrichs.