This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts

demoAIQuantum chemistry

Excitation energies of water from the Casida equation, with and without de-excitations

Water in the 6-31G basis, from its Hartree-Fock ground state to all 40 singlet and 40 triplet excitation energies, two ways. Time-dependent Hartree-Fock (the random-phase approximation) keeps the coupling between excitations and de-excitations; the Tamm-Dancoff approximation drops it and diagonalizes alone. The lowest singlet is at 0.344074 Ha (9.363 eV) in TDHF and 0.346161 Ha in TDA, and every one of the 160 energies matches PySCF's to Ha.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • Explore

    Run it and step through what each part did, with the code, values and plots beside it.

A molecule absorbs light at the energies of its excited states above the ground state, its excitation energies. Hartree-Fock gives only the ground state, a single set of occupied orbitals. Linear response asks how that state responds to a weak oscillating field: the response diverges at frequencies that solve the eigenvalue problem above, the Casida equation. The unknowns are the amplitudes for moving an electron from an occupied orbital to a virtual one , and for the reverse.

For a closed-shell molecule with real orbitals, orbital energies , and two-electron integrals in the molecular-orbital basis (chemists' notation),

for singlets. For triplets the Coulomb terms drop out, since a spin flip moves no net charge. With the equation is time-dependent Hartree-Fock (TDHF), also called the random-phase approximation (RPA). With only is left, and its eigenvalues are the Tamm-Dancoff (TDA) energies, the same as configuration interaction with single excitations.

The program computes the integrals, the ground state and both spectra in this file, with lib/hf for the integrals and the self-consistent field. The reference is PySCF 2.5.0 (posts/refs/casida-tdhf-and-tda-for-water.py), which shares no code with it and solves both problems by Davidson iteration on matrix-vector products, without building or .

The ground state and its orbitals

The molecule is PySCF's water, written as PySCF takes it, and the 6-31G basis is found by its name in the table lib/basis/pople631g: 13 basis functions, 5 doubly occupied orbitals and 8 virtual ones, so occupied-virtual pairs. The RHF energy matches PySCF's Ha. The orbitals are the eigenvectors of the converged Fock matrix, and the integrals over them come from four quarter-transformations of the atomic-orbital integrals.

Printed

E_rhf: -75.9839
eps: [-20.5606, -1.35612, -0.70965, -0.560711, -0.501391, 0.20359, 0.299674, 1.05683, 1.16442, 1.18687, 1.21583, 1.37924, 1.69638]

Tests 1 of 1 pass

  • the RHF energy is PySCF's -75.98394849810573 to 1e-9 (passes)

Building and , and solving

The pair is stored at index .

TDA is one symmetric eigenvalue problem, .

For TDHF the problem is not symmetric, but it folds into a symmetric one of size . Adding and subtracting its two block rows gives and , so . When is positive definite, which holds when the Hartree-Fock state is stable against these rotations, it has a square root, and turns the product into the symmetric matrix under the title. Its eigenvalues are .

All 160 energies agree with PySCF's to Ha, about what is left of the self-consistent field's convergence; the tests allow .

Printed

nov: 40
lowest_singlet_ev: 9.36273
n_energies: 160
worst_pyscf_gap: 3.41116e-09

Tests 5 of 5 pass

  • all 160 energies agree with PySCF's to 3.7e-9 Ha (passes)
  • all 40 singlet TDHF energies are PySCF's to 1e-8 Ha (passes)
  • all 40 singlet TDA energies are PySCF's to 1e-8 Ha (passes)
  • all 40 triplet TDHF energies are PySCF's to 1e-8 Ha (passes)
  • all 40 triplet TDA energies are PySCF's to 1e-8 Ha (passes)

What does

couples each excitation to the de-excitations, and its effect is to pull the energies down. For the lowest root this always holds. With , the lowest TDHF is the minimum of over vectors with ; the vectors with are among them, and over those the ratio is , whose minimum is the lowest TDA energy. For water every root comes out lower in TDHF than in TDA, by 0.07 to 63 millihartree for the singlets and 0.01 to 19 for the triplets (posts/refs prints the same ranges from PySCF); the largest is the 25th singlet's, 63 millihartree. The 8 roots near 20 Ha, which move an electron out of the oxygen 1s orbital, shift by less than 0.25 millihartree.

The triplets sit below the singlets. The singlet and carry the extra term , whose diagonal is the Coulomb self-repulsion of the charge distribution and is positive. The lowest triplet is 0.3065 Ha, 1.023 eV below the lowest singlet.

The first figure shows the 32 valence excitation energies of each kind. The second shows, root by root, how far TDA lies above TDHF.

Printed

shift_singlet_min_mh: 0.0693007
shift_singlet_max_mh: 62.9741
shift_triplet_min_mh: 0.0111529
shift_triplet_max_mh: 19.0508
core_shift_max_mh: 0.235746
N_VAL: 32
shift_singlet_min: 6.93007e-05
shift_singlet_max: 0.0629741
shift_triplet_min: 1.11529e-05
shift_triplet_max: 0.0190508
singlet_triplet_gap_ev: 1.02266
Water, 6-31G: valence excitation energies
singlet, TDHFsinglet, TDAtriplet, TDHFtriplet, TDA
20406051015202530root, in order of energyexcitation energy (eV)
How far TDA lies above TDHF, root by root
singletstriplets
10⁻¹10⁰10¹10²51015202530root, in order of energyTDA - TDHF (millihartree)

Tests 5 of 5 pass

  • every TDHF root is below its TDA root: by 6.930e-5 to 6.297e-2 Ha for singlets, 1.115e-5 to 1.905e-2 for triplets (passes)
  • TDA lies above TDHF by 0.07 to 63 millihartree for singlets, largest at the 25th, and 0.01 to 19 for triplets (passes)
  • 32 of the 40 roots are valence, below the 8 oxygen 1s roots near 20 Ha (passes)
  • the 8 oxygen 1s excitations move by less than 0.25 millihartree (passes)
  • the lowest singlet is 9.3627 eV in TDHF, and the lowest triplet 1.0227 eV below it (passes)

Checked when the site was built: 11 of 11 tests passed, in 4.24 s. Download 2026-09-25-casida-tdhf-and-tda-for-water.viv