SCESS-LISP icon

Archived2023 – 2024

SCESS-LISP

Where SCESS started, a restricted Hartree–Fock solver written from scratch in Common Lisp.

  • Common Lisp
  • SBCL
  • Quantum chemistry
  • LLA (LAPACK)
  • Lisp-Stat
  • ASDF
The SCF loop from HartreeFock.lisp. Build the Fock matrix, diagonalise it, rebuild the density, and repeat until it settles.
0.7k Lines of Common Lisp
4 Integral types
8 Fold integral symmetry
2 Prebuilt platforms (Linux, Windows)

Gaussian basis sets, the one- and two-electron integrals and the self-consistent field procedure, implemented from the textbook formulas in Common Lisp. It computes the ground-state energy of water in the STO-3G basis, and later became the C++ SCESS.

SCESS-LISP is the first version of SCESS: a restricted Hartree–Fock (RHF) program written in Common Lisp while I was learning both the language and the method. It has everything an SCF calculation needs, built from scratch: Gaussian basis functions, every integral, and the self-consistent field loop.

What it computes

The program builds a water molecule (0.957 Å bonds, a 104.5° angle), loads the STO-3G basis set from JSON and runs RHF to convergence:

  1. Integrals. Overlap \(S\), kinetic \(T\) and nuclear attraction \(V\) matrices, plus the two-electron integrals \((ij|kl)\).
  2. Orthogonalisation. \(X = S^{-1/2}\), from the eigendecomposition of \(S\) (through LLA and LAPACK).
  3. SCF loop. Build the Fock matrix \(F = H^{\text{core}} + G(P)\), transform it, diagonalise it, rebuild the density matrix \(P\), and repeat until \(P\) changes by less than \(10^{-5}\).
\[ E = \tfrac{1}{2}\sum_{\mu\nu} P_{\nu\mu}\left(H^{\text{core}}_{\mu\nu} + F_{\mu\nu}\right) + V_{nn} \]

The integrals

The integrals use the Taketa–Huzinaga–O-ohata expansion over Cartesian Gaussians: binomial polynomial coefficients, A-factors for the nuclear attraction and B-coefficients for electron repulsion. The Boys function comes from the incomplete gamma function. Two-electron integrals are stored once each in a hash table, under a Yoshimine index that folds in their eightfold permutational symmetry:

(defun YoshimineIndex (i j k l)

  (if (< i j)
      (let ((swapVar i))
        (setf i j)
        (setf j swapVar)))

  (if (< k l)
      (let ((swapVar k))
        (setf k l)
        (setf l swapVar)))

  (let ((ij (+ (* i (/ (+ i 1) 2)) j))
        (kl (+ (* k (/ (+ k 1) 2)) l)))

    (if (< ij kl)
        (let ((swapVar kl))
          (setf kl ij)
          (setf ij swapVar)))

    (return-from YoshimineIndex (+ (* ij (/ (+ ij 1) 2)) kl))))

What came next

The same THO expansion lives on. SCESS reimplemented the method in C++ and grew to coupled cluster, explicitly correlated F12 methods and quantum Monte Carlo. dhERI now generates GPU kernels for exactly these electron-repulsion integrals. SCESS-LISP is built with ASDF's program-op into standalone SBCL executables.