# Usual way of computing exchange-correlation potential on a simple case H2 (RKS, LDA)

The python code is here.

I tried to do a DFT calculation for H2 Restricted Hartree-Fock with Local Density Approximation. The optimization is a scf-loop with Lagrange-multiplier only. I use the same atomic orbitals as the STO3G ab initio computation counterpart. I get the following Energy plot : My guess is that the exchange(-correlation) energy/operator computation is not good since I am using Riemann integrals (uniform cubes formed with a uniform point grid) to compute it.

How are computed exchange-correlation integrals usually? Via Gauss quadrature? Analytic integration if possible?

If you have any questions, dont hesitate.

• Follow-up questions can be asked in a new post! May 6 at 19:51

Firstly, consider an atomic calculation. It is very natural to perform the integration in polar coordinates, using the position of the atomic nucleus as the origin. In many (maybe most) quantum chemistry programs, the radial integration is done with Gaussian quadrature, after a nonlinear coordinate transformation that makes the radial grid very dense near $$r=0$$ ($$r$$ is the distance of the grid point to the nucleus) and sparse when $$r$$ is large. The angular (i.e. $$\theta$$ and $$\phi$$) integration is usually done with Lebedev quadrature, which is an efficient quadrature that exactly integrates spherical harmonics up to a high degree, just as the Gaussian quadrature exactly integrates polynomials up to a high degree. Integrating under polar coordinates not only utilizes and keeps all relevant spherical symmetries, but also allows us to separate out the radial degree of freedom, and therefore apply well-known techniques to put more grid points near the nuclei while still being able to assign suitable weights to the grid points.
There are a few more techniques for reducing the number of grid points for a given integration accuracy, such as using small Lebedev grids for very small and very large $$r$$, and large Lebedev grids for intermediate $$r$$ (where an accurate angular integration is more important). These kind of grid optimizations can go up to quite elaborate levels, as exemplified by the newest ORCA grids. Some earlier protocols for optimizing the molecular grids can be found in the reference list of this paper as well.