“Know how to solve every problem that has been solved.” “What I cannot create, I do not understand.” — Richard Feynman

Geometry optimization in PySCF, by the diff

Quantum Chemistry

A single-point energy tells you what one fixed shape costs. Geometry optimization answers the question a chemist actually cares about: what shape does the molecule adopt? The route there is short — compute the forces on the nuclei, then walk downhill until they vanish — and in PySCF it's a handful of one-line additions on top of the basics. As before, every program runs and every number below is what PySCF actually printed.

The chain: a single point at a deliberately-bad guess → the gradient (forces) → optimize() → confirm the minimum → the effect of the level of theory. Step with the arrows; hover a marked line for its rationale.

1 / 5
Single point — one fixed shape
starting point
from pyscf import gto, scf
 
mol = gto.M(
atom="O 0 0 0; H 0 -0.90 0.70; H 0 0.90 0.70",
basis="sto-3g",
)
 
mf = scf.RHF(mol)
e = mf.kernel()
print(f"E = {e:.6f} Ha")
the starting point
One energy at one fixed geometry — a guess, with the O–H bonds stretched to 1.14 Å (real water is about 0.96). This is the same single-point Hartree-Fock from the basics tutorial. The energy is just a number for this one shape. Geometry optimization answers the next question: which shape does the molecule actually want?
hover a marked line (left bar) for its rationale
what it prints
E = -74.925328 Ha

Everything follows from the gradient

Three things to take from the diffs, all visible in the output panels:

As a citeable, falsifiable claim: at a converged geometry optimum the maximum nuclear gradient is zero (to the convergence threshold), because the optimum is where the forces vanish. The experiment is steps 2 and 4; it would be falsified by a structure the optimizer reports as converged while a fresh gradient comes back large — which would mean a broken convergence test, not a real minimum.

Read next