Table of Contents
Fetching ...

SHarmonic: A fast and accurate implementation of spherical harmonics for electronic-structure calculations

Xavier Andrade, Jacopo Simoni, Yuan Ping, Tadashi Ogitsu, Alfredo A. Correa

TL;DR

Spherical harmonics are essential in electronic-structure calculations but many implementations lag in speed or GPU support. SHarmonic offers an explicit polynomial implementation up to $\ell \le 9$ in normalized Cartesian coordinates, covering real and spinorial variants and providing CPU and GPU execution via a header-only C/C++ interface. It achieves accuracy on par with stdc++, Boost, and GSL and delivers substantial speedups, especially on GPUs (up to ~$500\times$ faster than CPU references), facilitating integration into existing codes. The open-source release and GPU-friendly design promote reproducibility, performance, and broad adoption in electronic-structure workflows.

Abstract

The authors present SHarmonic, a new implementation of the spherical harmonics targeted for electronic-structure calculations. Their approach is to use explicit formulas for the harmonics written in terms of normalized Cartesian coordinates. This approach results in a code that is as precise as other implementations while being at least one order of magnitude more computationally efficient. The library can run on graphics processing units (GPUs) as well, achieving an additional order of magnitude in execution speed. This new implementation is simple to use and is provided under an open source license, it can be readily used by other codes to avoid the error-prone and cumbersome implementation of the spherical harmonics.

SHarmonic: A fast and accurate implementation of spherical harmonics for electronic-structure calculations

TL;DR

Spherical harmonics are essential in electronic-structure calculations but many implementations lag in speed or GPU support. SHarmonic offers an explicit polynomial implementation up to in normalized Cartesian coordinates, covering real and spinorial variants and providing CPU and GPU execution via a header-only C/C++ interface. It achieves accuracy on par with stdc++, Boost, and GSL and delivers substantial speedups, especially on GPUs (up to ~ faster than CPU references), facilitating integration into existing codes. The open-source release and GPU-friendly design promote reproducibility, performance, and broad adoption in electronic-structure workflows.

Abstract

The authors present SHarmonic, a new implementation of the spherical harmonics targeted for electronic-structure calculations. Their approach is to use explicit formulas for the harmonics written in terms of normalized Cartesian coordinates. This approach results in a code that is as precise as other implementations while being at least one order of magnitude more computationally efficient. The library can run on graphics processing units (GPUs) as well, achieving an additional order of magnitude in execution speed. This new implementation is simple to use and is provided under an open source license, it can be readily used by other codes to avoid the error-prone and cumbersome implementation of the spherical harmonics.

Paper Structure

This paper contains 11 sections, 30 equations, 2 figures, 3 tables.

Figures (2)

  • Figure 1: Comparison of the accuracy between SHarmonic and reference implementation of the real spherical harmonics. The comparison is done over a set of 5180 random values uniformly distributed over a sphere. Top panel: Difference between implementation for each $\ell$ averaged over points and $m$. Bottom panel: Maximum difference between implementations for each $\ell$. This results show that SHarmonic is as accurate as the reference implementations.
  • Figure 2: Comparson of the computational throughput in millions of harmonics per second for different implementations of the spherical harmonics: SHarmonic on CPU and GPU, . Calculation of real harmonics in angular coordinates averaged over $\ell$, between 1 and 9, and $m$. Execution on a single core of a AMD Ryzen 5950x CPU and an Nvidia V100 GPU.