Open-shell Hartree–Fock (UHF/ROHF)
The uhf and rohf commands solve the Hartree–Fock equations for systems with unpaired electrons. Both report energies in Hartree and the HOMO–LUMO gap in eV.
UHF
Unrestricted HF gives the α and β electrons separate spatial orbitals:
flowchart LR
A[Geometry + charge + multiplicity] --> B[Guess density]
B --> C[Fock alpha and beta]
C --> D[Diagonalise each spin]
D --> E[New alpha/beta densities]
E --> F{Converged?}
F -- no --> C
F -- yes --> G[Energy, S², Mulliken]
The reported energy is the energy of the reported densities:
For a doublet, the exact expectation is S(S+1) = 0.75. Spin contamination is ⟨S²⟩ − 0.75; the CH₃ example gives 0.7586, so the contamination is 0.0086.
ROHF
Restricted open-shell HF forces α and β to share spatial orbitals. The implementation performs a canonical ROHF projection after the UHF loop, using the average Fock matrix; the projected density is then used to rebuild the Fock matrices and the energy. Consequently:
⟨S²⟩is exactly 0.75 for a doublet (spin_contamination ≈ 0).- the ROHF energy is variationally above the UHF energy for the same system.
The projected ROHF is not a full separate open-shell SCF loop; it is a canonical projection of the converged UHF solution.
CH₃ frontier
The methyl radical at the test geometry C=(0,0,0), H=(1.09,0,0), H=(-0.36,1.03,0), H=(-0.36,-0.52,0.89) gives:
| Quantity | UHF | ROHF |
|---|---|---|
| total energy (Ha) | −39.06969115534437 | −39.066274183948494 |
| ⟨S²⟩ | 0.7586289855325434 | 0.75 |
| spin contamination | 0.008628985532543432 | ≈0 |
| HOMO (Ha) | −0.396405444094244 | −0.05274290209831729 |
| LUMO (Ha) | 0.29807842046854216 | 0.7230371688184877 |
| gap (eV) | 18.89786868022439 | 21.110051151657142 |
| nα / nβ | 5 / 4 | 5 / 4 |
In ROHF both spins share the spatial orbitals, so the HOMO is the singly occupied SOMO and the LUMO is the next spatial orbital. It is not the β-spin "LUMO", which is the same SOMO; using that value previously collapsed the reported gap to zero.
Example
$ sci-form uhf "[6,1,1,1]" "$CH3" --multiplicity 2
{
"alpha_orbital_energies": [-11.0231, -0.9107, "..."],
"beta_orbital_energies": [-10.9909, -0.8187, "..."],
"electronic_energy": -48.6916,
"nuclear_repulsion": 9.6219,
"total_energy": -39.0697,
"homo_energy": -0.3964,
"lumo_energy": 0.2981,
"gap_ev": 18.8979,
"mulliken_charges": [-0.1485, 0.0494, 0.0496, 0.0495],
"scf_iterations": 33,
"converged": true,
"n_alpha": 5,
"n_beta": 4,
"s2_expectation": 0.7586,
"spin_contamination": 0.0086,
"unit": "Hartree"
}$ sci-form rohf "[6,1,1,1]" "$CH3" --multiplicity 2
# total_energy = -39.066274183948494
# s2_expectation = 0.75, spin_contamination = 0
# homo_energy = -0.05274290209831729, lumo_energy = 0.7230371688184877
# gap_ev = 21.110051151657142Input validation
multiplicity >= 1.multiplicitymust be compatible with the electron count (N ± (M−1)even andM−1 <= N).- the implied number of α and β electrons cannot exceed the number of spatial orbitals in the STO-3G basis. A high-spin multiplicity that passes the electron-count parity check but needs more α electrons than basis functions is rejected (
ValueErrorin Python,{error}in WASM) instead of indexing past the orbital matrix. - coordinates must contain three finite values per atom and the molecule must be non-empty.
- unsupported elements return an error with exit code 1.
Configurable UHF/ROHF (UhfConfig)
The Rust-only compute_uhf_configured entry point accepts an explicit scf::uhf::UhfConfig. run_uhf calls UhfConfig::validate before building the basis, so invalid controls fail as validation errors instead of returning a non-converged result or corrupting the DIIS history:
| Field | Contract |
|---|---|
max_iterations | integer ≥ 1 |
energy_threshold | finite and > 0 (Hartree) |
density_threshold | finite and > 0 (RMS density change) |
level_shift | finite (Hartree; 0 disables) |
damping | finite and in [0, 1] (0 disables) |
diis_size | 0 disables DIIS; any other value is the subspace size |
use_parallel_eri, rohf | booleans |
The default configuration reproduces compute_uhf exactly. Python and WASM do not expose the config object; they use the default controls.
Surfaces
| Surface | Entry point |
|---|---|
| CLI | sci-form uhf "<elements>" "<coords>" --charge 0 --multiplicity 2 |
| CLI | sci-form rohf "<elements>" "<coords>" --charge 0 --multiplicity 2 |
| Rust | compute_uhf, compute_rohf, compute_uhf_configured |
| Python | compute_uhf, compute_rohf |
Validation
- UHF water (singlet) reproduces the closed-shell HF energy −74.963023 Ha.
- CH₃ UHF: S² 0.7586; ROHF: S² 0.75, energy −39.066274 Ha > UHF −39.069691 Ha.
- ROHF energy equals
electronic_energy + nuclear_repulsionafter projection.