# 2. SCF: all methods This page covers how the self-consistent field is solved: reference, initial guess, spin occupation, convergence acceleration, and how the Coulomb and exchange matrices are built. ## Reference determinant | `scf: reference` | Meaning | |---|---| | `uks` (default) | unrestricted Kohn–Sham (UHF without a `functional:` section) | | `roks` | restricted open-shell: one set of orbitals, $\langle S^2\rangle=S(S+1)$ exactly ([Roothaan 1960](#ref-roothaan60)) | OH radical, PBE/def2-TZVP, run with each reference (`oh_uks.yaml`, `oh_roks.yaml`): | Reference | Total energy (Ha) | $\langle S^2\rangle$ | |---|---|---| | UKS | −75.6823745 | 0.7520 | | ROKS | −75.6767474 | 0.7500 | After an open-shell SCF the program runs a **stability analysis** ([Seeger and Pople 1977](#ref-seeger77)) (`scf: stability: auto`) and follows unstable modes to a lower solution. ## Initial guess | `initial_guess` | | |---|---| | `atomic_potential_fit` (default) | superposition of atomic potentials ([Lehtola 2019](#ref-sap19)) | | `sad` | superposition of atomic densities | | `core_hamiltonian` | bare $T+V_{\rm ne}$; poor for large systems; the default with ECPs | The converged result does not depend on the guess; the iteration count does. ## Mixing and convergence ```yaml scf: max_iter: 100 conv_tol: 1.0e-8 # on the mixing error and on |dE| level_shift: 0.0 # virtual-orbital shift (Ha) for stubborn cases mixing: method: diis # diis (default, Pulay) | broyden ``` DIIS ([Pulay 1980](#ref-pulay80)) is the best-tested choice; `broyden` ([Johnson 1988](#ref-johnson88)) mixes the Fock matrix (`broyden_target: hamiltonian`) or the density. Use `level_shift` (for example 0.3 Ha) for near-degenerate or metal-containing systems. `scf: incremental_fock: true` builds $J$ and $K$ from the change of the density on the ERI path. ## Spin occupation: `moment_mode` | Mode | Behavior | |---|---| | `fixed` (default) | $N_\alpha$, $N_\beta$ from `unpaired_electrons` | | `variable` | lowest levels of both spins occupied each iteration; finds the ground-state moment | | `fixed_occupation` | occupy listed orbitals (`occ_alpha`, `occ_beta`, 1-based) | | `mom` | ΔSCF with the maximum overlap method ([Gilbert, Besley, Gill 2008](#ref-mom08)) | For charge-transfer states the perturbative ΔSCF (`pdscf:`) of [Baruah, Olguin and Zope](#ref-baruah12) is available; see {doc}`../tutorials/11_pdscf/index`. ## Coulomb and exchange | `coulomb: method` | Use | |---|---| | `eri` | exact four-index integrals; reference, required for gradients with some functionals | | `poisson` | numerical Poisson solve on the molecular grid ([Becke and Dickson](#ref-poisson)); default for DFT energies and SIC | | `density_fitting` | RI-J, and RI-K for exact exchange ([Weigend 2002](#ref-ri)); needs `aux_basis_file` | | `analytic` | closed-form Hartree potential on the grid | Use a J-fitting set (`def2-universal-JFIT`) for $J$ only and a JK-fitting set (`def2-universal-JKFIT`) when exchange or orbital densities are fitted. Exact exchange can also use chain-of-spheres: `coulomb: exchange: cosx` ([Neese et al.](#ref-cosx)). Water, PBE/def2-TZVP, with RI-J, SAD guess and Broyden mixing (`h2o_pbe_df.yaml`): ```{literalinclude} ../examples/h2o_pbe_df.yaml :language: yaml :start-at: "coulomb:" :end-before: "atoms:" ``` gives −76.3774249 Ha against −76.3773251 Ha with exact integrals (RI-J error 0.1 mHa for this auxiliary set), after 21 iterations against 9 for the default DIIS run (`h2o_pbe.yaml`). Both counts come from the real outputs in the example set; Broyden is not faster here. ## Restarting `scf: restart: write | read | readwrite` saves and reuses the converged orbitals; with `restart_project: true` they are projected onto a different geometry or basis. ## Hartree–Fock Omit the `functional:` section. `coulomb: density_fitting` then gives RI-HF without four-index integrals. Water/def2-TZVP gives −76.0594112 Ha (`h2o_hf.yaml`). Related: {doc}`dft`, {doc}`../tutorials/01_scf/index`, {doc}`../tutorials/21_output/index`.