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/hf/uhf

Unrestricted Hartree-Fock, one set of orbitals per spin

When the numbers of alpha and beta electrons differ, the two spins feel different exchange fields, because exchange acts only between electrons of the same spin. UHF gives each spin its own orbitals and its own Fock matrix:

F_a = H + J(Da + Db) - K(Da)
F_b = H + J(Da + Db) - K(Db)

Both spins see the Coulomb field of every electron, and each sees exchange only with its own spin. The iteration is the RHF one with two densities instead of one: the same loop, lib/hf/scf_loop's scf_iterate, with options.method = SCF_UHF, and DIIS extrapolates both spins with one set of coefficients.

The freedom has a price: a UHF determinant is in general not an eigenfunction of S^2. Its expectation value,

<S^2> = ((Na - Nb)/2)^2 + (Na + Nb)/2 - Tr(Da S Db S),

exceeds the exact S(S+1) by the spin contamination; for OH it is 0.7538 against 0.75 [test "OH 6-31G: PySCF's energy and spin contamination"]. The result carries it as r.s2.

With Na = Nb and a guess that treats both spins alike, the two densities stay equal at every step, so closed-shell UHF reproduces RHF exactly. With Na < Nb (PySCF's negative spin) the roles of the spins swap and the energy is the same as for Na > Nb.

Result: an ScfResult (lib/hf/scf_loop) whose alpha and beta hold each spin's orbitals, density and Fock matrix; density is their total.

Used with import hf.uhf.

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 38–210