Spin Contamination in UHF

In unrestricted Hartree-Fock (UHF), the single determinant wavefunction is not an eigenfunction of the operator. This leads to spin contamination — the wavefunction mixes in higher-spin states.

The Expectation Value

For a UHF determinant with alpha and beta electrons, the expectation value of the total spin operator is:

where:

  • is the expected spin quantum number
  • and are the occupied alpha and beta molecular orbitals
  • The overlap integral is

Ideal vs. Actual Values

SystemMultiplicityIdeal
Doublet (1 unpaired e⁻)2½0.75
Triplet (2 unpaired e⁻)312.00
Quartet (3 unpaired e⁻)43/23.75

The actual from a UHF calculation equals the ideal value only when the alpha and beta occupied orbitals are perfectly orthogonal ( for all ). Any non-zero overlap between occupied alpha and beta orbitals increases above the ideal value.

Quantifying Spin Contamination

The degree of spin contamination is measured by the difference:

  • : Pure spin state, minimal contamination
  • : Moderate contamination, usually acceptable
  • : Significant contamination; results may be unreliable

In OpenQuantum, a warning is printed when :

Spin Information:
  N(alpha): 5
  N(beta):  4
  <S²>:     0.850000 (ideal: 0.750000)
  WARNING: Significant spin contamination detected (0.1000)

Physical Interpretation

Spin contamination arises because the UHF determinant allows alpha and beta electrons to occupy different spatial orbitals. This flexibility lowers the energy but mixes in higher-spin configurations:

  • For a doublet (), the contaminated wavefunction contains quartet () and higher-spin character
  • For a triplet (), it contains quintet () character
  • The energy lowering is artificial — it comes from spin-symmetry breaking, not physical correlation

Consequences

  1. Energies: UHF energies are variationally lower than RHF, but part of this lowering is due to spin contamination rather than physical correlation
  2. Properties: Properties like dipole moments and gradients may be affected
  3. Post-HF methods: MP2 and CCSD(T) built on a contaminated UHF reference inherit spin contamination
  4. Geometry optimization: Contaminated forces can lead to incorrect geometries

Mitigation Strategies

StrategyDescription
ROHFRestricted open-shell HF — forces alpha/beta orbitals to be identical in the open shell; spin-pure but often higher energy
Spin projectionApproximate projection of (e.g., Yamaguchi formula)
Spin-flip methodsUse spin-flip TDDFT or spin-flip CC to target spin-pure states
Use RHF for closed-shellAvoid UHF entirely when not needed

Implementation in OpenQuantum

The computation is in crates/scf/src/fock.rs::compute_s_squared():

#![allow(unused)]
fn main() {
pub fn compute_s_squared(
    coefficients_alpha: &DMatrix<f64>,
    coefficients_beta: &DMatrix<f64>,
    overlap: &DMatrix<f64>,
    n_alpha: usize,
    n_beta: usize,
) -> (f64, f64) {
    // Ideal S²: S(S+1) where S = (N_α - N_β)/2
    let s = (n_alpha as f64 - n_beta as f64) / 2.0;
    let s_squared_ideal = s * (s + 1.0);

    // Overlap of occupied orbitals: S_αβ = C_occ^α^T · S · C_occ^β
    let c_alpha_occ = coefficients_alpha.columns(0, n_alpha);
    let c_beta_occ = coefficients_beta.columns(0, n_beta);
    let s_alpha_beta = c_alpha_occ.transpose() * overlap * c_beta_occ;

    // Sum of squared overlaps
    let overlap_sum: f64 = s_alpha_beta.iter().map(|x| x * x).sum();

    // ⟨S²⟩ = S_ideal + N_β - Σ|S_αβ|²
    let s_squared = s_squared_ideal + n_beta as f64 - overlap_sum;

    (s_squared, s_squared_ideal)
}
}

The result is returned in UhfResult and formatted in format_uhf_energy_output() with a warning for significant contamination.

Further Reading

  • Szabo & Ostlund, Modern Quantum Chemistry, Ch. 3 (UHF theory)
  • Krylov, "Spin-flip methods in quantum chemistry" (2006)
  • Yamaguchi et al., "Spin-projected UHF energies" (1986)