Two-electron repulsion integrals (ERIs) constitute a fundamental computational bottleneck in quantum chemistry, scaling as
| Method | Grid Points | Relative Error | Significant Digits |
|---|---|---|---|
| NUFFT (Becke) | 7,760 | ~6 | |
| FFT (Uniform) | 884,736 | ~1 | |
| Direct | 3,300 | FAILED |
NUFFT achieves 23,038× better accuracy with 114× fewer grid points compared to FFT.
Two-electron repulsion integrals are the computational bottleneck of quantum chemistry, scaling as
The Coulomb operator $1/|\mathbf{r}_1 - \mathbf{r}2|$ has a singularity at $r{12}=0$ that destroys direct numerical integration. The key insight is the Fourier representation:
which converts the 6D real-space integral into a 3D Fourier-space integral with the well-behaved
| Package | Purpose |
|---|---|
| NumPy / SciPy | Array operations, FFT, erf |
grid-qchem |
Gauss-Legendre, Becke transforms, AtomGrid, MolGrid, BeckeWeights |
FINUFFT |
Type-3 NUFFT via finufft.nufft3d3() |
Implements Cartesian Gaussian-Type Orbitals for s-type (
A Cartesian GTO centered at
with normalization constant:
Primitive GTO evaluation — vectorized over all grid points simultaneously:
- Compute displacement vectors
$\mathbf{d} = \text{points} - \text{center}$ - Compute
$r^2 = d_x^2 + d_y^2 + d_z^2$ - Radial part:
exp(-α * r²) - Angular part:
$d_x^{i_x} \cdot d_y^{i_y} \cdot d_z^{i_z}$ - Return
$N \cdot \text{angular} \cdot \text{radial}$
Contracted GTO (STO-3G) — sums
Shell evaluation — allocates output array of shape (ncomp, npts) where
Double factorial — iterative: start at
Test 1.0 — Double Factorial Verification
| Computed |
Expected | |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 1 | 1 |
| 2 | 3 | 3 |
| 3 | 15 | 15 |
| 4 | 105 | 105 |
Test 1.1 — GTO Normalization (Grid:
| Orbital | Error | |||
|---|---|---|---|---|
| s | (0,0,0) | 0.712705 | 1.000000 | |
| s ( |
(0,0,0) | 0.423777 | 1.000000 | |
| (1,0,0) | 1.425411 | 1.000000 | ||
| (0,1,0) | 1.425411 | 1.000000 | ||
| (0,0,1) | 1.425411 | 1.000000 | ||
| (2,0,0) | 1.645923 | 1.000000 | ||
| (1,1,0) | 2.850822 | 1.000000 | ||
| (1,0,1) | 2.850822 | 1.000000 | ||
| (0,2,0) | 1.645923 | 1.000000 | ||
| (0,1,1) | 2.850822 | 1.000000 | ||
| (0,0,2) | 1.645923 | 1.000000 |
Test 1.2 — Gaussian Decay (
|
|
Region | |
|---|---|---|
| 0.0 | Maximum at nucleus | |
| 1.0 | Core | |
| 2.0 | Valence | |
| 3.1 | Outer valence | |
| 4.1 | Asymptotic tail |
Confirms
Test 1.3 — Angular Nodal Structure
| Test | Result | Status |
|---|---|---|
|
|
||
|
|
||
|
|
Test 1.4 — Contracted GTO (STO-3G Hydrogen)
| Primitive | ||
|---|---|---|
| 1 | 3.42525091 | 0.15432897 |
| 2 | 0.62391373 | 0.53532814 |
| 3 | 0.16885540 | 0.44463454 |
Test 1.5 — d-Shell Orthogonality
| 1.000 | 0.000 | 0.333 | 0.000 | 0.000 | 0.333 | |
| — | 1.000 | 0.000 | 0.000 | 0.000 | 0.000 | |
| — | — | 1.000 | 0.000 | 0.000 | 0.333 | |
| — | — | — | 1.000 | 0.000 | 0.000 | |
| — | — | — | — | 1.000 | 0.000 | |
| — | — | — | — | — | 1.000 |
The overlap of
Constructs two types of quadrature grids: uniform Cartesian grids (FFT-compatible) and adaptive atom-centered Becke grids (for NUFFT).
Uniform grid — fills a cubic box
- 1D coordinates via
linspace(-L/2, L/2, N, endpoint=False)(endpoint excluded for FFT periodicity) - 3D tensor product via
meshgrid→$N^3$ total points, all weights =$h^3$ - Constructor variants:
from_box,from_center,from_molecule(auto-sizes around atomic coordinates with padding)
Becke grid — atom-centered spherical grid:
-
Radial: Gauss-Legendre points
${x_i, w_i^{GL}}$ on$[-1,1]$ , mapped via Becke transform$r_i = R(1+x_i)/(1-x_i)$ with transformed weights$w_i^r = w_i^{GL} \cdot 2R/(1-x_i)^2$ -
Angular: Lebedev quadrature on the unit sphere (50–770 points, integrating spherical harmonics up to
$l=11$ –$29$) -
Combined:
$n_r \times n_\Omega$ points per atom: $\mathbf{r}_{ij} = r_i \hat{\Omega}_j + \mathbf{R}A$, $w{ij} = w_i^r \cdot w_j^\Omega \cdot r_i^2$ -
Molecular partitioning (Becke weights): For each atom pair, compute confocal elliptical coordinate
$\mu_{AB} = (|\mathbf{r}-\mathbf{R}_A| - |\mathbf{r}-\mathbf{R}_B|)/|\mathbf{R}_A - \mathbf{R}_B|$ , then smooth step function$s(\mu) = \tfrac{1}{2}[1-f(f(f(\mu)))]$ where$f(x) = (3x-x^3)/2$ . The triple application of$f$ ensures smooth partition of unity.
Test 2.1 — Uniform Grid Properties (
| Property | Value |
|---|---|
| Total points | 9,261 |
| Origin |
|
| Spacing |
0.5 Bohr |
| Weight per point |
|
Test 2.2 — Uniform Grid Integration (
| Integral | Numerical | Analytical | Relative Error |
|---|---|---|---|
| 5.568328 | 5.568328 | ||
| 1.000000 | 1.0 |
Machine precision.
Test 2.3 — Becke Grid Properties (
| Property | Value |
|---|---|
| Total points | 9,700 |
| Min weight | |
| Max weight | |
| Weight range | |
| Min |
0.0009 Bohr |
| Max |
2644.9 Bohr |
The 20-order-of-magnitude weight range reflects the
Test 2.4 — Becke Integration Accuracy (target:
| Grid Points | Result | Absolute Error | |
|---|---|---|---|
| 0.1 | 30,200 | 1.0000000000 | |
| 0.5 | 30,200 | 1.0000000000 | |
| 1.0 | 30,200 | 1.0000000000 | |
| 2.0 | 30,200 | 1.0000000000 | |
| 5.0 | 30,200 | 1.0000000000 |
Test 2.5 — H₂ Molecule Grid
| Test | Numerical | Expected | Error |
|---|---|---|---|
| 2.00000000 | 2.0 |
Test 2.6 — Grid Efficiency Comparison (target: error
Uniform grid:
| Spacing (Bohr) | Points | Error | Status |
|---|---|---|---|
| 1.00 | 4,913 | ||
| 0.50 | 35,937 | ||
| 0.40 | 68,921 | ||
| 0.30 | 166,375 | ||
| 0.25 | 274,625 | 0.00 |
Becke grid:
| Points | Error | Status | |
|---|---|---|---|
| 20 | 3,880 | ||
| 30 | 5,820 | ||
| 40 | 7,760 | ||
| 50 | 9,700 | ||
| 60 | 11,640 |
Becke ~3,880 pts vs Uniform ~35,937 pts → 9.3× fewer points. The anomalous 0.30 Bohr result (worse than 0.50) is an aliasing artifact — the spacing systematically misses the Gaussian's features.
Evaluates basis function products
Single product: Evaluate both GTOs on all grid points, return element-wise product.
Batch shell-pair products — vectorized via NumPy broadcasting:
- Evaluate shell
$i$ → shape$(n_i, N_\text{pts})$ - Evaluate shell
$j$ → shape$(n_j, N_\text{pts})$ -
products = χi[:, newaxis, :] × χj[newaxis, :, :]→ shape$(n_i, n_j, N_\text{pts})$
All
Overlap integral:
Test 3.1 — Self-Overlap
| Grid Points | Numerical | Expected | Error |
|---|---|---|---|
| 22,650 | 1.0000000000 | 1.0 |
Test 3.2 — H₂ Overlap Integral (
| Method | Value | Relative Error |
|---|---|---|
| Numerical (45,300 pts) | 0.3753110992 | — |
| Analytical | 0.3753110989 | — |
| Difference | — |
Test 3.3 — s-p Orthogonality
| Integral | Value | Status |
|---|---|---|
| 1.0000000000 |
Zero by symmetry —
Test 3.4 — p-Shell Overlap Matrix
| 1.000000 | |||
| — | 1.000000 | ||
| — | — | 1.000000 |
Max deviation from identity:
Test 3.5 — STO-3G Hydrogen Self-Overlap
| Property | Value |
|---|---|
| Grid points | 30,200 |
| 0.9999999909 |
Test 3.6 — Uniform vs Becke for Density Integration
Uniform:
| Spacing (Bohr) | Points | Error |
|---|---|---|
| 0.40 | 68,921 | |
| 0.30 | 166,375 | |
| 0.25 | 274,625 | |
| 0.20 | 531,441 |
Becke:
| Points | Error | |
|---|---|---|
| 30 | 5,820 | |
| 40 | 7,760 | |
| 50 | 9,700 | |
| 60 | 11,640 |
Implements three Fourier transform methods: standard FFT on uniform grids, NUFFT Type-3 via FINUFFT on Becke grids, and direct summation for validation.
FFT: Reshape density to fftfreq(N, h) × 2π.
NUFFT Type-3 — computes
- Weight coefficients:
$c_i = f(\mathbf{r}_i) \times w_i$ - Threshold filter: keep only
$|c_i| > 10^{-14} \times \max|c|$ - Cast to
complex128coefficients,float64coordinates (C-contiguous viaascontiguousarray) - Call
finufft.nufft3d3(x, y, z, c, kx, ky, kz, eps=ε, isign=1) - Fallback to direct summation (
$O(MN)$ loop) if FINUFFT fails
FINUFFT achieves
Spherical k-grid — Gauss-Legendre in each spherical coordinate, points: $\mathbf{k}{ijk} = k_i(\sin\phi_k\cos\theta_j, \sin\phi_k\sin\theta_j, \cos\phi_k)$, weights: $w{ijk} = w_i^r w_j^\theta w_k^\phi k_i^2$.
Analytical validation transforms:
Test 4.1 — Spherical k-Grid (
| Property | Value | Expected |
|---|---|---|
| Total points | 1,000 | 1,000 |
|
|
||
| 4188.79 | ||
| Relative error | 0 |
Test 4.2 — NUFFT vs Direct Summation
| Method | Grid Pts | k-Pts | Time (ms) |
|---|---|---|---|
| NUFFT | 3,300 | 125 | 25.3 |
| Direct | 3,300 | 125 | 1.06 |
Max difference:
Test 4.3 — NUFFT on Normalized Gaussian (
| Property | Value |
|---|---|
| Grid points | 59,000 |
| k-points | 1,000 |
| Max error | |
| Mean error |
Test 4.4 — NUFFT on s-type GTO
| Property | Value |
|---|---|
| 1.0000000000 | |
| Grid points | 59,000 |
| Max error vs analytical | |
| Mean error |
Test 4.5 — Off-Center GTO Phase (center at
| NUFFT | Analytical | |
|---|---|---|
|
|
1.818614 | 1.818614 |
| Max error | — |
Phase factor
Test 4.6 — Fourier Transform of Density (
| Property | Value |
|---|---|
| 1.0000000000 | |
| Max error vs analytical | |
| 0.998639 |
Test 4.7 — Convergence
| Grid Pts | Max Error | Time (ms) | ||
|---|---|---|---|---|
| 40 | 194 | 7,760 | 20.9 | |
| 60 | 302 | 18,120 | 15.8 | |
| 80 | 434 | 34,720 | 25.9 | |
| 100 | 590 | 59,000 | 13.3 | |
| 120 | 770 | 92,400 | 20.0 |
Computes ERIs by combining Fourier-transformed charge densities with the
ERI via NUFFT:
- Weight densities:
$c = \rho \odot w_\text{grid}$ - NUFFT Type-3 transform both bra and ket densities to spherical k-grid
- Coulomb kernel with regularization:
$k^2_\text{safe} = \max(k^2, 10^{-20})$ - Integrate: $\text{ERI} = \text{Re}!\left(\sum w_k \cdot \tilde{\rho}\text{bra} \cdot \tilde{\rho}\text{ket}^* / k^2_\text{safe}\right) / (2\pi^2)$
ERI via FFT:
- Reshape densities to
$(N,N,N)$ , compute 3D FFTs scaled by$h^3$ - k=0 singularity: set
$k^2[0,0,0]=1$ , compute$4\pi/k^2$ , then set$\text{Coulomb}[0,0,0]=0$ (charge neutrality) - Sum integrand and scale by
$\Delta k^3/(2\pi)^3$
ERI via Direct: Double loop over grid pairs with $r_{12}^\text{safe} = \max(|\mathbf{r}_1 - \mathbf{r}2|, 10^{-10})$ — fails catastrophically because $1/r\text{min} = 10^{10}$ corrupts the integral.
Test 5.1 — Same-Center (aa|aa)
| Property | Value |
|---|---|
| Real-space grid | 34,720 points |
| k-space grid | 3,375 points |
| Fourier ERI | 1.1283791672 Ha |
| Analytical | 1.1283791671 Ha |
| Absolute error |
|
| Relative error | |
| Time | 51.8 ms |
11 significant digits.
Test 5.2 — H₂ Molecule ERIs (
| Integral | Fourier (Ha) | Analytical (Ha) | Rel. Error |
|---|---|---|---|
| 1.12837917 | 1.12837917 | ||
| 0.68020366 | 0.68020366 | ||
| 0.15894171 | 0.15894171 |
Test 5.3 — Fourier vs Direct
| Method | ERI (Ha) | Error | Time (ms) |
|---|---|---|---|
| Fourier | 1.12837915 | 32.9 | |
| Direct | 5,539,177.89 | 546.8 | |
| Analytical | 1.12837917 | — | — |
Fourier: 16.6× faster, ~$10^{14}$× more accurate. Direct: FAILED.
Test 5.4 — Different Exponents
| Fourier (Ha) | Analytical (Ha) | Rel. Error | ||||
|---|---|---|---|---|---|---|
| 0.5 | 0.5 | 0.5 | 0.5 | 0.797885 | 0.797885 | |
| 1.0 | 1.0 | 1.0 | 1.0 | 1.128379 | 1.128379 | |
| 2.0 | 2.0 | 2.0 | 2.0 | 1.595769 | 1.595769 | |
| 0.5 | 1.0 | 0.5 | 1.0 | 0.818949 | 0.818949 | |
| 1.0 | 2.0 | 1.0 | 2.0 | 1.158169 | 1.158169 |
All ≥ 7 significant digits.
Test 5.5 — Convergence (real-space grid, fixed k-grid 3,375 pts)
| Points | Rel. Error | ||
|---|---|---|---|
| 40 | 194 | 7,760 | |
| 60 | 302 | 18,120 | |
| 80 | 434 | 34,720 | |
| 100 | 590 | 59,000 |
Convergence (k-space grid, fixed real-space 34,720 pts)
| k-Points | Rel. Error | ||
|---|---|---|---|
| 8 | 6 | 512 | |
| 10 | 8 | 1,000 | |
| 12 | 10 | 1,728 | |
| 15 | 12 | 3,375 | |
| 18 | 15 | 5,832 |
Systematic head-to-head benchmarking of all three methods (FFT, NUFFT, Direct) on identical test cases against the analytical Boys function reference.
Test 6.1 — Same-Center (ss|ss) (Analytical:
FFT (uniform grid):
|
|
Grid Points | ERI (Ha) | Rel. Error | Time (ms) | |
|---|---|---|---|---|---|
| 16 | 64 | 262,144 | 0.951815 | 20.3 | |
| 20 | 80 | 512,000 | 0.986907 | 40.8 | |
| 24 | 96 | 884,736 | 1.010386 | 61.4 | |
| 28 | 112 | 1,404,928 | 1.027190 | 105.1 |
NUFFT (Becke grid):
| Grid Points | ERI (Ha) | Rel. Error | Time (ms) | ||
|---|---|---|---|---|---|
| 20 | 50 | 1,000 | 1.1283992494 | 21.0 | |
| 25 | 86 | 2,150 | 1.1283838002 | 53.5 | |
| 30 | 110 | 3,300 | 1.1283842149 | 77.5 | |
| 40 | 194 | 7,760 | 1.1283842889 | 163.8 |
Direct:
| Grid Points | ERI (Ha) | Rel. Error | Time (ms) |
|---|---|---|---|
| 3,300 | 12,996,684.21 | 132.6 |
CATASTROPHIC FAILURE — Coulomb singularity produces error
Test 6.2 — H₂ Molecule (bond length 1.4 Bohr)
| FFT (884,736 pts) | NUFFT (15,520 pts) | |||
|---|---|---|---|---|
| Integral | Value (Ha) | Error | Value (Ha) | Error |
| 1.01038570 | 1.1283842318 | |||
| 0.56250863 | 0.6800256196 | |||
| 0.14232133 | 0.1589424515 |
Test 6.3 — Direct Comparison
| Method | Grid Points | ERI (Ha) | Rel. Error | Time (ms) | Status |
|---|---|---|---|---|---|
| FFT | 884,736 | 1.01038570 | 64.1 | ||
| NUFFT | 7,760 | 1.1283842889 | 159.6 | ||
| Direct | 3,300 | 12,996,684.21 | 114.8 |
Test 6.4 — Convergence
FFT with box size (
|
|
ERI (Ha) | Rel. Error |
|---|---|---|
| 12 | 0.89375576 | |
| 16 | 0.95181507 | |
| 20 | 0.98690699 | |
| 24 | 1.01038570 | |
| 28 | 1.02719023 | |
| 32 | 1.03980949 |
FFT error saturates at ~8% due to periodic boundary artifacts and cubic k-grid inefficiency for the spherical
NUFFT with grid refinement:
| Grid Points | Rel. Error | ||
|---|---|---|---|
| 20 | 50 | 1,000 | |
| 25 | 86 | 2,150 | |
| 30 | 110 | 3,300 | |
| 40 | 194 | 7,760 |
NUFFT succeeds — Fourier methods analytically handle the
FFT fails to converge — (1) periodic boundary artifacts, (2) finite box truncation, (3) cubic k-grid poorly samples the spherically symmetric
Direct integration fails catastrophically — when two grid points coincide,
- Szabo A, Ostlund NS. Modern Quantum Chemistry. Courier Corporation; 2012.
- Helgaker T, Jorgensen P, Olsen J. Molecular Electronic-Structure Theory. Wiley; 2013.
- Becke AD. A multicenter numerical integration scheme for polyatomic molecules. J. Chem. Phys. 1988;88(4):2547–53.
- Barnett AH, Magland J, af Klinteberg L. A parallel nonuniform fast Fourier transform library based on an "exponential of semicircle" kernel. SIAM J. Sci. Comput. 2019;41(5):C479–504.
Mehdi Hassanbeigi
Email: hasanbeigimahdi25@gmail.com
© 2026 Mehdi. All Rights Reserved.
Restrictions:
- ❌ No copying, modification, or distribution of this work is permitted