Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Demo: Hartree-Fock with PySCF

Open in Colab

This notebook runs an actual Hartree-Fock (self-consistent field) calculation on atoms using the PySCF quantum chemistry package, and visualizes the resulting orbitals. It complements the Hartree-Fock lecture page, where the theory (Slater determinant, Fock operator, SCF cycle) is developed.

This demo uses the following libraries (already installed for the site build; on your own machine, pip install pyscf py3Dmol plotly):

Hartree-Fock energies and orbitals of alkali-metal atoms

The function below builds an atom in a minimal STO-3G basis, runs a restricted open-shell Hartree-Fock calculation, extracts the molecular-orbital energies, and writes a cube file for the highest occupied molecular orbital (HOMO) so it can be visualized with py3Dmol.

Now loop over a couple of alkali-metal atoms, run the calculation, and print the total Hartree-Fock energy, the orbital energies, and the HOMO energy for each.

converged SCF energy = -7.31552598128109
HOMO cube file saved as: Li_HOMO.cube
Loading...
Results for Li atom:
Total Energy (Hartree): -7.315525981281089
Molecular Orbital Energies (Hartree): [-2.35349063 -0.03895976  0.16052129  0.16052129  0.16052129]
HOMO energy (Hartree): -2.3534906342705435


converged SCF energy = -159.668211391143
HOMO cube file saved as: Na_HOMO.cube
Loading...
Results for Na atom:
Total Energy (Hartree): -159.66821139114347
Molecular Orbital Energies (Hartree): [-40.04250273  -2.62740763  -1.26706067  -1.26706067  -1.26706067
   0.32267877   0.80168088   0.80168088   0.80168088]
HOMO energy (Hartree): -1.2670606732956404