Notebooks · posts/h2-rhf-uhf-and-full-ci-along-the-bond
RHF, UHF and full CI for H₂ in STO-3G along the bond
Pull the two atoms of H₂ apart in the smallest basis there is, and compute its energy three ways. Restricted Hartree-Fock is off by Ha at the equilibrium bond length and heads for the wrong limit, 0.39 Ha too high. Unrestricted Hartree-Fock splits from it at bohr and reaches two hydrogen atoms. Full CI is exact in this basis. Every energy matches PySCF to Ha.
The program is self-contained: the STO-3G basis, the integrals over Gaussian
functions, the Hartree-Fock and full-CI energies, all in this file. The
reference is PySCF 2.5.0 (posts/refs/h2-rhf-uhf-and-full-ci-along-the-bond.py), which shares no
code with it: its own basis library, integrals, SCF solvers, stability
analysis and full-CI solver. The Coulson-Fischer point is checked against
PySCF two ways, by the onset of the RHF triplet instability in PySCF's
molecular-orbital integrals (2.179695 bohr) and by bisecting on where
PySCF's UHF first falls below its RHF (2.179731, with a 10−10 Ha threshold,
which puts it slightly past the true onset).
Units are atomic: energies in hartree (1 Ha = 27.211 eV), lengths in bohr (1 bohr = 0.5292 Å), both from CODATA 2022.
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.
The basis
A hydrogen molecule has two electrons and two protons. Its electrons' wave function has to be built out of something, and the smallest choice is one function per atom. STO-3G makes that function from three Gaussians, with fixed exponents and fixed weights, fitted once to look like a hydrogen 1s orbital. Gaussians are used because every integral the calculation needs has a closed form for them.
The two functions, on atom 1 and on atom 2, give two molecular orbitals, fixed by symmetry: the bonding orbital and the antibonding orbital .
The integrals
With the atoms at and , the program needs the overlap , the one-electron energy (kinetic energy plus attraction to both protons), and the electron-repulsion integrals , each a sum over three primitives per function. For two s Gaussians with exponents and , the product is one Gaussian of exponent centered between them, and the standard results (Szabo and Ostlund, Modern Quantum Chemistry, Appendix A) are
and for the repulsion between two such products, with exponents and and centers and , , each times the primitives' normalizations.
The overlap of the two atoms' functions at bohr is
(S_eq): they share most of their space. Ha is the
repulsion of two electrons both in , and it matters below.
Three approximations to the same energy
Restricted Hartree-Fock (RHF) puts both electrons, spin up and spin down, in the same orbital. For H₂ in this basis that orbital must be , so nothing needs iterating, and the energy is in molecular-orbital integrals.
Unrestricted Hartree-Fock (UHF) lets the spin-up electron have one orbital and the spin-down electron another. Here they can only be mixtures of and ; the lowest-energy pair has the form , which leans the spin-up electron toward one atom and the spin-down electron toward the other. The program minimizes the energy over . At it is RHF.
Full configuration interaction (FCI) is the exact answer within the basis: the lowest eigenvalue of the Hamiltonian over every two-electron state the two orbitals allow. With the right symmetry only two states mix, and , so it is a 2 by 2 matrix with .
At the equilibrium bond length the two Hartree-Fock methods agree, at
Ha, and full CI is lower by Ha (e_corr): the
correlation energy, the part of the electrons' repulsion a single
orbital per electron cannot describe. It is 1.8% of the total energy and
0.56 eV, the same size as the energy differences chemistry cares about.
Pulling the atoms apart
Before running: at large each atom should keep one electron, and the energy should be twice that of a hydrogen atom in this basis, Ha. Which of the three methods gets there?
Only RHF misses. At bohr it is Ha above two atoms
(rhf_excess). The reason is in its one orbital. written out
in the atoms' functions is
:
half the time the two electrons are on different atoms, and half the time
they are both on one, H⁻ next to a bare proton. Once the atoms' functions
stop overlapping, that ionic half costs the repulsion of two
electrons on one atom and gains the attraction between H⁻ and the
proton, each weighted by one half. Before looking at the next cell: what
should the excess be at bohr, and where does it go as grows?
At bohr the excess is Ha (excess_20), which is
to nine digits, and at it is
(excess_limit), on its way to Ha. RHF
describes the separated atoms as half atoms and half ions.
Where UHF breaks away
UHF avoids this by letting the spin-up electron sit on one atom and the spin-down electron on the other. Close to equilibrium that costs more than it gains, and UHF's lowest state is the RHF one. Past a bond length called the Coulson-Fischer point it pays, and the two curves split. The program finds it as the where the UHF energy stops curving upward in at : the second difference changes sign.
The price is the spin. The UHF state is no longer a pure singlet: its , zero for a singlet and 2 for a triplet, is , and it rises to 1 as the atoms separate, an even mixture of the two.
The split comes at bohr (r_cf), 1.56 times the 1.4 bohr bond
length used above. Past it the UHF curve bends over toward two atoms, and
climbs, to 0.44 at 2.5 bohr and 0.96 at 4 bohr. Full CI
stays a pure singlet and goes to the right limit smoothly: it mixes in
, which cancels the ionic half of , a little near
equilibrium and half and half at large .