Barely Functional Theories

Musings on science and game design by James Furness.



Hartree-Fock Slater Orbitals for Spherical Atoms



Get the code here! You are free to use it however you see fit under CC0 license CC0

Much of my recent work has been in developing new semi-local density functional approximations following a non-empirical philosophy of adherence to exact mathematical constraints. These constraints help form the body of the functional then we use simple systems, such as atoms, to set the remaining degrees of freedom. Having a computationally efficient set of high-accuracy orbitals has been a real asset for searching large parameter spaces.

This python module implements the evaluation routines for the sets of orbitals published by Clementi and Roetti in their 1974 paper. As described in the publication these are the Slater type orbitals that minimise the spherically symmetric Roothaan-Hartree-Fock Hamiltonian. The code uses vectorised numpy functions to provide a fast evaluation of the electron density, electron density gradient, orbital kinetic energy density, and electron density Laplacian from the published Slater orbitals.

The user should be aware that these orbitals impose spherical symmetry on the system, including the p and d orbitals. This imposed symmetry is not a limitation, the orbitals are optimal for the spherical Hamiltonian, but it does mean that the energy from these orbitals for atoms with partially filled valence shells (e.g. carbon) will be different to the energy obtained by breaking the spatial symmetry.

The module’s main interface is the Atom class that is initialised with the desired atomic element symbol:

import Densities
neon = Densities.Atom("Ne")

Calling the initialised atom’s get_densities(r) method with a distance from the nucleus (in atomic units) will return the spin resolved: electron density, density gradient, orbital kinetic energy, and density Laplacian, at the given distance from the nucleus. Due to the nature of the orbitals the nuclear distances must be positive and non-zero.

r = 1.5
d0, d1, g0, g1, t0, t1, l0, l1 = neon.get_densities(r) 

For many points in space it is best to use a numpy array to take advantage of the massive speed up offered by the vectorised routines:

r = np.linspace(0, 5, 500)
d0, d1, g0, g1, t0, t1, l0, l1 = neon.get_densities(r)

The spherical symmetry then allows a simple shortcut to evaluating integrals over all space:

# Create a simple integration grid and evaluate the orbitals
r, h = np.linspace(1e-6, 25, 5000, retstep=True)
d0, d1, g0, g1, t0, t1, l0, l1 = neon.get_densities(r)

# Then integrate to find the total number of electrons.
# For neon this should be 10
density = np.sum(4*h*np.pi*r**2*(d0 + d1))
print("Total Density: {:.6f}".format(density))

This is a viable and simple way of accessing the densities, but such evenly spaced integration grids need more points for accurate integrals than more refined methods. This module implements a simple Gauss-Legendre integration grid that can give better accuracy with a smaller number of points than a simple grid:

grid_level = 100  # Defines the accuracy of the grid. 100 is typically sufficient.
n, r, weights = Densities.GridGenerator.make_grid(grid_level)
d0, d1, g0, g1, t0, t1, l0, l1 = neon.get_densities(r)
density = np.sum(weights*(d0 + d1))
print("Total Density: {:.6f}".format(density)) 

The returned values are numpy arrays that can be combined as normal, to generate the β iso-orbital indicator:

from Densities import Atom
import numpy as np
import matplotlib.pyplot as plt

argon = Atom("Ar") # Initialise a new Neon atom

r = np.linspace(0.0001, 5, 500)

d0, d1, g0, g1, t0, t1, l0, l1 = argon.get_densities(r)

# Uniform electron gas kinetic energy density
tau_ueg_0 = 3.0/10.0*(3*np.pi**2)**(2.0/3.0)*d0**(5.0/3.0)
# von-Weizsacker (single-orbital) kinetic energy density
tau_vw_0 = g0**2/(8*d0)
# Calculate the beta iso-orbital indicator
alpha_0 = (t0 - tau_vw_0)/(t0 + tau_ueg_0)

plt.plot(r, alpha_0)
plt.xlabel("$r$")
plt.ylabel("$\\beta$ iso-orbital indicator")
plt.xlim([0,5])
plt.ylim([0,1])
plt.show()

Defining More Atoms

At the time of writing the module contains orbitals for:

{H, He, Li, Be, B, C, N, O, F, Ne, Na, Mg, Si, P, Cl, Ar, K, Sc (4s1,3d2: High spin), Cr (4s1,3d5: High spin), Cu (4s1,3d10: High spin), Cu+ (3d10: Low spin), As, Kr, Ag, and Xe}

The Clementi and Roetti paper contains orbital coefficients for all atoms with nuclear number ≤ 54 in many excited and ionic states. Unfortunately I haven’t found a way to reliably automate reading the orbital coefficients from the paper, so they have all been entered by hand so far. The inefficiency of this process means I have only implemented atoms as they become useful to my work.

Such manual entry can be error prone, so the module contains an internal test routine to ensure correctness of evaluation functions, and to check that orbital coefficients produce the expected integrated quantities.

If you would like to add new atoms this can be done by adding the relevant coefficients to the dictionaries in the AtomData class, see code comments and the paper for details. Alongside the coefficients the integrated kinetic energy (from the paper) should be added to ke_test and the integrated electron density should be added to N_test. The test routine will automatically check the orbitals integrate to these values when the test set is run:

import Densities
Densities.test_densities()

Alternatively running the module as main runs the test:

python Densities.py

The module also implements methods to get the Jmol coloring (roughly CPK colors) of the elements. This can be accessed by calling an Atom object’s get_color() method, or by passing a list of element label strings or Atom objects to the get_colors_for_elements() function.

And that’s it, happy calculating! If this tool has been useful to you I’d love to hear about it. I’m also happy to add the coefficients for any other atoms on request.