This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/gto

Gaussian-basis quantum chemistry, held against PySCF

Molecular electronic structure from the Gaussians up: contracted s-type basis functions, the four integrals a Hartree-Fock calculation needs, and the self-consistent field that turns them into an energy. Every number is checked against PySCF's own, which tools/pyscf_reference.py writes into lib/qcref with enough digits to round-trip. What separates PySCF's answer from this one is the arithmetic in between.

The four integrals, for primitives exp(-a|r-A|^2):

  • Overlap. Two Gaussians multiply to a third, at P = (aA + bB)/(a + b), scaled by K = exp(-ab/(a+b) |A-B|^2). Integrating that gives K (pi/p)^(3/2) and nothing harder.
  • Kinetic. The Laplacian of a Gaussian is a Gaussian, so this is the overlap times ab/p (3 - 2ab/p |A-B|^2).
  • Nuclear attraction. 1/|r-C| is not Gaussian, and this is where the Boys function F0(x) = sqrt(pi/4x) erf(sqrt(x)) arrives. It is the one special function this module calls, and it is built from erf.
  • Two-electron. Two Gaussian products, one Boys function between them. For n basis functions there are n^4 of these, which is why everything past a small molecule is about not computing them.

Then the self-consistent field: the Fock matrix depends on the density, which comes from the Fock matrix. Start with a zero density, solve F C = S C e in an orthonormal basis found by Cholesky, rebuild the density, repeat.

Only s functions, which means hydrogen. Oxygen has p, and the recursion that handles angular momentum is the next rung.

Used with import gto.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 36–471