Abstract
An efficient integral library, Libcint, was designed to automatically implement general integrals for Gaussian-type scalar and spinor basis functions. The library can handle arbitrary integral expressions on top of $\mathbf{p}$, $\mathbf{r}$, and $\sigma$ operators with one-electron overlap and nuclear attraction, as well as two-electron Coulomb and Gaunt operators. Using a symbolic algebra tool, new integrals are derived and translated to C code programmatically. The generated integrals can be used in various types of molecular properties. In this work, analytical gradients and NMR shielding constants were computed at both non-relativistic and four-component relativistic Hartree-Fock levels to demonstrate the library's capabilities. Due to the use of kinetically balanced basis sets and gauge-including atomic orbitals, relativistic analytical gradients and shielding constants require the library to handle fifth-order electron repulsion integral derivatives. The generality of the integral library is achieved without losing efficiency. On modern multi-CPU platforms, Libcint can reach an overall throughput many times the I/O bandwidth, achieving an average output of 7.9 GB/s for a $C_{60}$ molecule with a cc-pVTZ basis on a 20-core node.
Introduction
In the field of computational chemistry, the calculation of molecular integrals—mathematical descriptions of electron-electron and electron-nucleus interactions—represents the primary computational bottleneck. As research progresses toward more complex simulations, such as those involving heavy elements where relativistic effects are significant or the determination of magnetic properties like NMR shielding, the variety and complexity of required integrals increase exponentially. Traditionally, implementing these integrals required manual, error-prone coding. Libcint addresses this by providing an open-source, high-performance library that automates the generation of complex molecular integrals for both non-relativistic and relativistic quantum chemistry.
Methodology
The core innovation of Libcint is its use of a symbolic algebra system. Instead of manually coding specific interactions, researchers provide expressions involving fundamental operators. The library then parses these expressions, decomposes them into basic Cartesian integrals, and programmatically translates them into optimized C code.
Libcint supports a wide array of operators, categorized into scalar, vector, and compound classes. This flexibility allows for the implementation of diverse physical models within a unified framework.
For the underlying numerical integration, Libcint utilizes the Dupuis-Rys-King (DRK) algorithm. While other algorithms might offer lower theoretical operation counts (FLOPs), the DRK algorithm was selected for its high data locality. By ensuring that data structures fit within the CPU's L1 and L2 caches, the library minimizes memory latency, which is often a more significant bottleneck than raw arithmetic on modern hardware. Furthermore, the library leverages SIMD (Single Instruction, Multiple Data) instructions, specifically SSE3, to parallelize inner loops.
Key Insights
A critical finding during development was the importance of the order in which recursive relations are applied. To produce correct mathematical factors when building derived integrals, the authors implemented a "left-to-right" propagation strategy. This approach, while seemingly counter-intuitive compared to standard mathematical operations, is essential for the symbolic derivation of momentum indices and their associated factors.
Additionally, Libcint demonstrates the ability to handle extremely high-order derivatives. Relativistic NMR shielding calculations, for instance, require fifth-order electron repulsion integral derivatives. Libcint manages these complex requirements while maintaining high efficiency.
Results and Performance
The library's performance was benchmarked against established packages like Molpro (SEWARD) and Psi4 (Libint) using various molecular systems, including $C_2H_6$, $Cr(CO)_6$, $UF_6$, and $C_{60}$.
Libcint achieved massive computational throughput. On a 20-core node, it reached an average output of 7.9 GB/s for $C_{60}$, effectively moving the bottleneck away from integral calculation and toward I/O bandwidth. In direct comparisons using loosely contracted basis sets (e.g., cc-pVTZ), Libcint consistently outperformed its peers. For an ethane test case, Libcint completed the task in 2.05 seconds, whereas Psi4 and Molpro required 4.98 and 4.82 seconds, respectively.
Beyond speed, the library proved its accuracy in relativistic contexts. It correctly captured the relativistic bond shortening in $Cr(CO)_6$ (from 2.0106 Å to 1.998 Å) and the significant sign change in NMR shielding constants for Uranium when relativistic corrections were applied.
Conclusion
Libcint represents a significant step forward in automating the most demanding parts of quantum chemistry simulations. By prioritizing data locality and symbolic automation, it provides a general-purpose tool that is both flexible and highly efficient. Future work will focus on extending the library to support density fitting, explicitly correlated methods, and porting the code to GPU architectures to further enhance performance.
Summary updated