# Are there efficient open source implementations of electrostatic potential integrals?

We've had several questions regarding calculation and plotting of electron density.

The electrostatic potential represents the interaction between a point charge at a given point $$\mathbf{r}$$ in a system of atoms, given by: $$V(\mathbf{r})=\sum_{A=1}^{N_{\text {atoms }}} \frac{Z_{A}}{\left|\mathbf{R}_{A}-\mathbf{r}\right|}-\int \frac{\rho\left(\mathbf{r}^{\prime}\right)}{\left|\mathbf{r}-\mathbf{r}^{\prime}\right|} d \mathbf{r}^{\prime}$$

The first part of this is easy - it's the classical Coulomb formula between the atomic nuclear charges $$Z_A$$ at positions $$R_A$$ and the point $$\mathbf{r}$$.

The second piece involves an integral over the electron density $$\rho$$

I'd like to evaluate the electrostatic potential at a set of points, either over a grid or vertices of a surface mesh. Ideally, I'd like to see the algorithm as well as an open source implementation.

• My not-so-hidden motive is to add an implementation to Avogadro after reading in an output file (e.g., Molden, fchk, etc.) Jul 6, 2021 at 18:34

The electron density is expanded in the basis set as $$n({\bf r}) = \sum_{\mu \nu} P_{\mu \nu} \chi_\mu({\bf r}) \chi_\nu({\bf r}).$$ When you substitute this into your equation, you get $$V({\bf r}) = \sum_{A=1}^{N_{\rm atoms}} \frac {Z_A} {|{\bf r}-{\bf R}_A|} - \sum_{\mu \nu} P_{\mu \nu} \int \frac {\chi_\mu({\bf r}') \chi_\nu({\bf r}')} {{|{\bf r}-{\bf r}'|}} {\rm d}^3r'.$$
The nuclear attraction integral for atom $$A$$ is $$V^A_{\mu \nu} = \int \frac {\chi_\mu({\bf r}) \chi_\nu({\bf r})} {|{\bf r}-{\bf R}_A|} {\rm d}^3r$$ so you can see that you just need to compute these integrals for every point on your grid; one-electron integrals are pretty cheap even though the nuclear-attraction integrals are the most expensive to compute.