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/guess

Five initial densities for the SCF

The SCF is a fixed-point iteration, and like any fixed-point iteration it needs a starting point. When a molecule has more than one SCF solution, the start decides which one it lands on, so the guess is a strategy with its own registry, not a detail. Open shells make this concrete: from the core guess, UHF on OH converges to the excited 2Sigma+ state (0.155 Eh above the 2Pi ground state PySCF reports), and UHF on triplet water lands 0.082 Eh above PySCF's state. Both are genuine SCF solutions, with the unpaired electron in the wrong orbital.

Every member returns spin densities [2, n, n], Da and Db, each built from orbitals occupied once. A closed-shell driver adds them.

  • gs_avg (member 0, production): an SCF on the spin-averaged density first. All N = Na + Nb electrons go into one set of orbitals, two per orbital, and the electrons left at the top are shared equally by the orbitals of the highest level that is only partly filled (a pi pair holding 3 electrons gets 1.5 in each orbital). Averaging keeps degenerate orbitals equivalent, so the iteration does not commit to one of them early. It starts from the GWH matrix below; when it converges (or after GS_AVG_MAXIT steps), the lowest Na of its orbitals give Da and the lowest Nb give Db. Measured with CDIIS: from this guess UHF lands on PySCF's state for OH 6-31G, O2 STO-3G and triplet water 6-31G. Started from the core Hamiltonian instead, the averaged SCF sends OH and O2 to the same higher states the core guess reaches. It builds J and K with jk_packed, so it needs the packed integrals.
  • gs_core: drop the electron-electron repulsion and diagonalize the core Hamiltonian H = T + V, then occupy the lowest orbitals. PySCF calls this the 1e guess. It ignores the electrons' repulsion entirely, but it is cheap and needs only H and S.
  • gs_gwh: the generalized Wolfsberg-Helmholz guess, an extended-Huckel style matrix F_ij = K S_ij (H_ii + H_jj) / 2 off the diagonal (with K = 1.75) and F_ii = H_ii.
  • gs_zero: zero densities. The first Fock matrix is then H, so the first iteration reproduces gs_core one step later.
  • gs_import: the densities the caller passes in D0, unchanged. This is how a PySCF density enters an SCF run (import mode).

Member signature: (H, S, Gp, D0, opts) -> [2, n, n], five arrays like the J/K stage. D0 is [2, n, n] and only gs_import reads it; Gp is the packed ERI vector and only gs_avg reads it. Electron counts, the orthogonalizer (opts[OPT_ORTH]) and the eigensolver (opts[OPT_EIGEN]) come from opts. The guesses PySCF uses by default (minao, atom, huckel) need atomic data this library does not carry yet.

Used with import hf.guess.

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 53–255