---
title: "Making the density and its field agree"
description: "Derive the restricted Hartree–Fock field, follow SCF residuals and see why orbital energies cannot simply be added into a total energy."
canonical_url: "https://sandboxphysics.com/stories/molecular-electronic/self-consistent-field/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/molecular-electronic/self-consistent-field/"
last_modified: "2026-10-28"
---

[Molecular electrons and the breaking of a bond](https://sandboxphysics.com/stories/molecular-electronic/)

L2 · Chapter 3

# Making the density and its field agree

Sandbox Physics · 2026-10-28

Hartree–Fock replaces the full two-electron problem with orbitals moving in a field built from those same orbitals. Self-consistency means that solving in the field returns the density used to construct it.

## Before you begin

The basis, overlap and integrals from chapter two. A Slater determinant is an antisymmetric combination of occupied spin orbitals; swapping two electrons changes its sign.

[Review the preceding chapter](https://sandboxphysics.com/stories/molecular-electronic/basis-and-integrals/)

- Build the restricted Fock matrix from a density matrix.
- Distinguish convergence from finding the lowest available energy.
- Recover total energy without double-counting electron repulsion.

## One determinant already includes exchange

A product that assigns electron one to one orbital and electron two to another treats the electrons as distinguishable. Antisymmetrizing that product produces a Slater determinant. Hartree–Fock chooses the best single determinant, with orthonormal occupied spin orbitals, for the fixed Hamiltonian.

The determinant generates a Coulomb contribution and an exchange contribution. Coulomb energy describes repulsion between orbital densities. Exchange comes from antisymmetry and acts between same-spin occupations. It is a contribution to the energy expression, not an additional classical force exerted by electron spin.

Restricted Hartree–Fock, or RHF, pairs opposite spins in the same spatial orbital. Hydrogen has one such occupied orbital. Exchange cancels the unphysical interaction of an occupied spin orbital with itself, but the remaining two electrons still repel one another.

Reading: Sandbox Physics · A. E. DePrince III · Psi4 manual

## A density produces the next orbital

For a closed-shell density matrix $P$, construct the Fock matrix $F$ by adding Coulomb and exchange terms to the one-electron matrix. Its coefficients define the effective one-electron problem. Because the atomic functions overlap, the orbital equation contains $S$ on the right.

Begin with a trial density. Build the Fock matrix, solve for orbitals, occupy the lowest orbital and rebuild the density. Repeat until input and output agree. Damping an update can reduce oscillation. This experiment blends old and new orbital coefficients, then renormalizes the orbital with the overlap matrix. Each displayed density therefore remains a single-determinant density; the damping changes the numerical path, not the stationary equations.

Symmetry makes this particular minimal-basis molecule unusually simple: the bonding combination can already be fixed by symmetry. A symmetric starting density may settle almost immediately. A deliberately displaced starting density makes the numerical relaxation easier to see without adding a physical time dependence.

$$
F_{\mu\nu}=h_{\mu\nu}+\sum_{\lambda\sigma}P_{\lambda\sigma}\left[(\mu\nu|\lambda\sigma)-\frac12(\mu\lambda|\nu\sigma)\right]
$$

This convention uses the total spatial density, with two electrons in each occupied restricted orbital.

$$
FC=SC\varepsilon,\qquad C^{\mathsf T}SC=I
$$

The diagonal matrix of orbital energies is written as epsilon. The second relation normalizes and orthogonalizes the orbitals using the overlap.

Reading: Sandbox Physics · A. E. DePrince III · Psi4 manual

## A small energy change is only one check

The residual $FPS-SPF$ vanishes when the occupied density and Fock operator are compatible. Its norm measures a failure of self-consistency. The experiment displays the root mean square of its four matrix entries, half the Frobenius norm in this two-by-two representation. Monitoring it together with density change and energy change is stronger than checking the last printed energy alone.

A tiny mixing step can make consecutive energies almost identical even when the density remains wrong. A converged stationary solution can also be an excited or unstable solution. Later we will find that a restricted stationary state can lose stability against spin-dependent orbital changes.

The iteration index counts numerical updates. Electrons do not literally spend time passing through these guessed densities. A cloud that changes during SCF is a view of an optimization procedure.

$$
r_{\mathrm{SCF}}=\frac12\|FPS-SPF\|_{\mathrm F}
$$

The Frobenius norm is the square root of the sum of squared matrix entries. This residual is in hartree; its numerical value depends on the representation. The experiment stops below one billionth of a hartree.

Reading: Sandbox Physics · Psi4 manual

## The orbital sum counts a repulsion twice

For hydrogen RHF, let $h_{gg}$ be the one-electron energy in the occupied bonding orbital and $J_{gg}=(gg|gg)$ its Coulomb integral. Each occupied spin orbital feels the other electron, so its orbital energy is $\varepsilon_g=h_{gg}+J_{gg}$. Adding two orbital energies counts the same pair interaction twice.

The correct electronic energy is $2h_{gg}+J_{gg}$. Add nuclear repulsion to obtain the molecular total. At $R=1.4$ bohr, the fixed STO-3G RHF total is approximately $-1.116714325$ hartree. FCI in the same basis is lower, approximately $-1.137275944$ hartree: self-consistency has optimized the determinant, but it has not included all two-electron correlation.

$$
E_{\mathrm{RHF}}=\frac12\sum_{\mu\nu}P_{\mu\nu}(h_{\mu\nu}+F_{\mu\nu})+\frac1R
$$

The factor of one half removes the duplicated interaction contribution while retaining the full one-electron energy.

$$
E_{\mathrm{RHF}}=2\varepsilon_g-J_{gg}+\frac1R
$$

For this one-pair molecule, subtract one copy of the Coulomb integral from the orbital-energy sum.

Reading: Sandbox Physics · A. E. DePrince III · Psi4 manual

## Try the prediction

### [Separate a numerical iteration from electronic motion](https://sandboxphysics.com/labs/h2-self-consistent-field/)

1. Press “Replay iterations” to follow the saved initial guess toward the converged default. Compare energy change with the SCF residual.
2. Use another initial guess or orbital-damping setting in the advanced controls. Compare the final state and the number of updates.
3. Change the nuclear separation and explain which part of the Hamiltonian changed. Reset to return to the original geometry.

## Exercises and explanations

1. For a hypothetical occupied orbital, $h_{gg}=-1.2$ and $J_{gg}=0.7$ hartree. Find the orbital energy and total electronic energy.

   Read the explanation

   The orbital energy is $-0.5$ hartree. The electronic total is $2(-1.2)+0.7=-1.7$ hartree, or $2(-0.5)-0.7$. Nuclear repulsion still has to be added at the chosen separation.

2. Two iterations print the same rounded energy but a substantial residual. Has the SCF calculation converged?

   Read the explanation

   The displayed energy has insufficient resolution to establish convergence. Inspect the unrounded energy change, density change and residual. Small updates caused by strong mixing can conceal a density that still fails the stationary equations.

3. Would changing the orbital-damping setting change the physical ground-state energy?

   Read the explanation

   It should change the convergence path and speed. If both calculations find the same stationary solution to the same tolerance, their final energies agree. Different final states indicate incomplete convergence or different stationary solutions, which must be inspected.

[Previous: Turning a molecule into a small matrix problem](https://sandboxphysics.com/stories/molecular-electronic/basis-and-integrals/) [Next: Why a shared orbital struggles when the bond stretches](https://sandboxphysics.com/stories/molecular-electronic/restricted-and-unrestricted/)

## Sources and calculation scope

1. [Sandbox Physics, FR13 reference inputs, raw numerical records and reproduction guide (2026)](https://github.com/yangzichao/sandboxphysics/blob/main/docs/frontier/fr13/reference-reproduction.md)

   Original generated data: H2/STO-3G method energies, forces and occupations; independent Psi4 checks; basis and DFT-grid checks; fixed-orbital fractional-spin data. The guide links scripts, raw outputs, runtime versions and data licenses.

2. [A. E. DePrince III, The Hartree–Fock Self-Consistent Field Procedure](https://www.chem.fsu.edu/~deprince/tutorials/jupyter_notebooks/hartree_fock/hartree_fock.html)

   Author tutorial: electronic Hamiltonian, variational principle, density matrices, SCF, basis convergence and spin-symmetry breaking. The browser calculation specializes these equations to two hydrogen STO-3G functions.

3. [Psi4 manual, HF: Hartree–Fock Theory](https://psicode.org/psi4manual/master/scf.html)

   Theory and numerical methods sections: restricted and unrestricted references, generalized eigenproblem, total energy and convergence. The reproducible reference manifest records the installed version and settings.

4. [Psi4 manual, CI: Configuration Interaction](https://psicode.org/psi4manual/master/detci.html)

   CI expansion and full configuration interaction within a chosen orbital space. Here FCI is exact only for the stated finite-basis Hamiltonian.
