Learning Objectives
Section 4.5 ended on a frustrating high note. Hohenberg and Kohn proved that the entire ground-state physics of an interacting electron system is encoded in the density : there is a universal functional , and minimising it gives the exact ground-state energy. But they did not tell us what looks like. In particular the kinetic-energy functional — the kinetic energy of the interacting system as a functional of its density alone — is unknown and almost certainly nasty.
Walter Kohn and Lu Jeu Sham's 1965 paper turned this stuck problem into the most successful framework in computational physics. Their idea was simple, audacious, and exact: replace the interacting electrons with a fictitious system of non-interacting electrons that has the same density. That auxiliary system is solvable. The price you pay is the need for one new functional, the exchange-correlation , and one iterative loop. That deal is what every modern DFT code — VASP included — actually solves.
By the end of this section you should be able to:
- State the Kohn–Sham ansatz: an interacting density is reproduced by a system of N non-interacting fermions in some effective potential .
- Decompose the energy functional as and explain what each term is.
- Derive the Kohn–Sham equations from the variational principle.
- Recognise why these equations are self-consistent — depends on the orbitals which depend on — and walk through the SCF iteration loop step by step.
- State precisely what KS eigenvalues do and don't mean — the band-gap problem is not a bug in DFT, it is a feature of approximate .
- Read a 1D Kohn–Sham solver in NumPy, watch its self-consistency loop converge in real time, and connect every keyword in a VASP
INCAR(ALGO,NELM,EDIFF) to a specific line of that solver.
Where Section 4.5 Left Us Stranded
Recall the two Hohenberg–Kohn theorems from 4.5:
- HK-1: the ground-state density determines the external potential uniquely (up to a constant), and therefore the entire many-body Hamiltonian and all its observables.
- HK-2: there exists a universal energy functional whose minimum (over all densities integrating to N electrons) is the exact ground-state energy.
The universal functional contains the kinetic energy and the electron–electron interaction. Both pieces are functionals of the density alone, by HK-1 — but knowing they exist is not the same as having a usable formula. In fact there is a long history of trying to write down: Thomas–Fermi (1927) used the free-electron kinetic-energy density , which is exact for a uniform gas but spectacularly wrong for atoms — it cannot bind a hydrogen molecule.
The Kohn–Sham Trick: A Fictitious System
The key observation is this: for a system of non-interacting electrons in an external potential , computing the kinetic energy is trivial. The ground state is a single Slater determinant of the N lowest single-particle orbitals , and:
The subscript “s” stands for single-particle or Slater — Kohn and Sham's original notation. is the kinetic energy of the non-interacting system, expressed as an explicit functional of the orbitals. It is not equal to (the kinetic energy of the real interacting system at the same density) — these differ — but it is something we can actually compute.
The Kohn–Sham ansatz now reads:
For any interacting density , there exists a non-interacting system in some effective potential whose ground state has the very same density. We work with that auxiliary system and let absorb the difference.
The orbitals of the non-interacting system are called Kohn–Sham orbitals; the eigenvalues are Kohn–Sham eigenvalues. They are mathematical bookkeeping devices that reproduce the right density. We will be very careful in § What KS Orbitals Actually Mean about what they do and don't correspond to in the real system.
Interactive: The Mapping Visualised
Two systems, one density. Click either box to see what each picture gives us — and where each picture fails on its own.
Splitting the Energy Functional
Now we must write the energy of the real interacting system in terms of quantities we can actually compute. The Kohn–Sham decomposition is:
Term by term:
| Term | Symbol | What it is | Computable? |
|---|---|---|---|
| Kinetic | T_s[n] | kinetic energy of the non-interacting KS system | Yes — sum of orbital kinetic energies |
| External | ∫V_ext n dr | electrons feeling the nuclei (or pseudopotential) | Yes — straight integral |
| Hartree | E_H = ½∫∫ n n' / |r-r'| | classical Coulomb repulsion of the density with itself | Yes — solve Poisson eqn or convolve |
| Exchange-correlation | E_xc[n] | everything else: T-T_s + non-classical part of V_ee | No — must be approximated |
The brilliance of the decomposition is that three of the four terms are exact and computable; the only unknown is . By definition,
— the small piece of the truth that we don't know exactly. The whole DFT industry, from LDA in 1965 to PBE in 1996 to SCAN in 2015 to modern hybrids, is the search for better approximations to . The next section ( 4.7 Exchange–Correlation Functionals) is dedicated to that zoo.
Deriving the Kohn–Sham Equations
We minimise over densities of the form with the constraint . Lagrange multipliers enforce the orthonormality. After diagonalising the Lagrange multiplier matrix, the variational equations for each orbital decouple:
Computing the functional derivative term by term:
- From : .
- From with : .
- From : where .
- From : by definition , so .
Adding these up, the variational principle delivers the Kohn–Sham equations:
with the effective potential
These look like a single-particle Schrödinger equation. The trick is the potential: already contains all the average effects of every other electron through (classical Coulomb) and (quantum mechanics). What was a coupled -dimensional Schrödinger problem in has become N independent 3D problems, all sharing the same potential.
Anatomy of the Effective Potential
Three pieces, three personalities:
| Component | Sign | Physical role | Depends on n? |
|---|---|---|---|
| V_ext(r) | negative near nuclei | Pulls electrons toward nuclei (or pseudoatoms) | no — fixed by the geometry |
| V_H(r) | positive everywhere | Classical mean-field repulsion: each electron repelled by the average density of all others | yes — V_H = ∫n(r')/|r-r'| dr' |
| V_xc(r) | negative where n is large | Pauli exchange + dynamic correlation: corrects the Hartree double-counting and adds quantum effects | yes — V_xc = δE_xc/δn |
Two observations are crucial. First, both and are functionals of the density that the orbitals themselves produce — that is the seed of the self-consistency problem we tackle next. Second, contains a famous unphysical feature called the self-interaction: an electron is repelled by its own density. The exchange part of is supposed to cancel this exactly — and does, in Hartree–Fock or in the exact KS formulation, but only approximately in LDA / GGA. We will return to this when we meet hybrid functionals in Chapter 6.
The Self-Consistency Problem
Look again at the Kohn–Sham equation. The orbitals depend on ; but contains and ; and . The unknown appears on both sides.
We cannot solve this in closed form. The standard answer is iteration: guess a density, build , diagonalise to get new orbitals, build a new density, repeat. The fixed point of this iteration — where input density equals output density — is the self-consistent Kohn–Sham solution.
Interactive: The SCF Loop
Click each node to see the equation for that step. The whole DFT engine is just this loop running until the density stops changing.
In practice you do not just replace the old density with the new one (which often oscillates). Instead, you mix: with in the range 0.1–0.5. Modern codes use much fancier schemes — Pulay (DIIS) or Broyden — that extrapolate from a history of previous steps and converge in a fraction of the iterations.
EDIFF is the threshold on the energy; a value of eV is overkill for a structure relaxation but barely tight enough for phonons.Interactive 1D Solver: Watch Convergence Happen
The widget below is a real, working 1D Kohn–Sham solver running live in your browser. Four electrons live in a harmonic well ; you watch the SCF cycle build up. At iteration 1 there is no electron–electron interaction yet (the density starts at zero), so exactly — the bare harmonic well. As iterations proceed the electrons begin to repel each other through (which lifts the well at the centre) and to feel exchange through (which deepens it back). The density adjusts in response, and the eigenvalues drift to their self-consistent values.
Toggle the components on and off to dissect . Step through with prev / next, or hit run SCF to watch the loop play itself out.
What you should see. Iteration 1: the density emerges from the bare harmonic well, two-bump structure (the two lowest oscillator orbitals doubly occupied). Iterations 2–4: the electrons start “feeling” each other; the centre of the density flattens, V_eff develops a hump. Iterations 5+: small corrections, the residual plummets by orders of magnitude. By iteration 9 the density and the potential it generates agree to four decimal places. That is what self-consistency looks like.
What KS Orbitals Actually Mean (and Don’t)
Kohn–Sham gives us a wealth of objects: orbitals , eigenvalues , occupations , a density , a total energy . Which of these are real?
| Quantity | Status | Comment |
|---|---|---|
| n(r) | exact (with exact E_xc) | The whole framework is built to reproduce this. In approximate DFT it is correct to within a few percent. |
| E (total energy) | exact (with exact E_xc) | Trust this — energy differences between DFT calculations are quantitatively meaningful. |
| ψ_i (orbitals) | auxiliary | Not the real wavefunction — a bookkeeping device. But the highest occupied orbital usually looks similar to the HOMO and is hugely useful for chemical intuition. |
| ε_i (eigenvalues) | auxiliary, except ε_HOMO | By Janak's theorem in exact DFT, ε_HOMO equals the negative of the ionization potential. Other eigenvalues are NOT one-electron excitation energies. |
| KS band gap ε_LUMO − ε_HOMO | wrong by ~50% in LDA/GGA | The famous DFT band-gap problem — see below. |
The band-gap problem in one sentence
The exact KS gap differs from the true fundamental gap by a quantity called the derivative discontinuity of the exchange-correlation functional. LDA and GGA functionals have (they are smooth in n), so they miss this contribution. As a result, LDA and PBE underestimate semiconductor band gaps by 30–50%: bulk Si has a true gap of 1.17 eV, PBE gives 0.6 eV; bulk CdSe has 1.74 eV experimentally, PBE gives ~0.7 eV.
The fix is either to use a better functional (HSE06, B3LYP, SCAN) — Chapter 6 covers these — or to climb out of DFT entirely and do (Section 5.10). In the meantime every DFT band structure plot you read should come with a mental warning sticker: gap likely underestimated.
Code Walk-Through: A Working 1D Kohn–Sham Solver
Time to read code that actually solves the Kohn–Sham equations. The script below is the engine behind the interactive widget you just used: it builds a finite-difference Hamiltonian on a 100-point grid, defines the Hartree and xc potentials, and runs an SCF loop with linear mixing. Every line is annotated — click any line on the right and the matching explanation pops up on the left.
Running the script you should see something like:
1iter 1: eps_1=+0.5000 eps_2=+1.5000 dn=4.00e+00
2iter 2: eps_1=+1.0234 eps_2=+2.0145 dn=1.32e+00
3iter 3: eps_1=+1.2876 eps_2=+2.3104 dn=4.62e-01
4iter 5: eps_1=+1.4017 eps_2=+2.4982 dn=4.21e-02
5iter 10: eps_1=+1.4231 eps_2=+2.5103 dn=8.90e-05
6iter 15: eps_1=+1.4233 eps_2=+2.5104 dn=2.10e-07The first iteration is exactly the bare harmonic-oscillator spectrum: gives , . As soon as the density appears, Hartree repulsion dominates and pushes both eigenvalues up; xc partially compensates. By iteration 10 the eigenvalues have stabilised to four decimal places — the SCF is converged.
n_occ, mix, the form of vxc, or the external potential and rerun. With mix = 1.0 (no damping) the loop oscillates wildly; with a stronger xc the eigenvalues drop. This is the same playground every quantum chemist starts in — what differs in VASP is just the basis (plane waves), the potential (pseudopotentials), and the dimensionality (3D, periodic).VASP Connection: ALGO, NELM, EDIFF
Every line of our 1D solver maps onto a VASP keyword. The relationship is literal — VASP is a Kohn–Sham SCF loop, scaled up.
| 1D solver line | VASP keyword | Role |
|---|---|---|
| np.linspace + finite-diff T | ENCUT (sets plane-wave basis) | Discretises the kinetic operator. More plane waves = larger Hamiltonian per k-point. |
| np.linalg.eigh(H) | ALGO = Normal/Fast/All | Iterative diagonaliser at every k-point. Davidson, RMM-DIIS, … |
| mix linear blend | AMIX, BMIX, MIXTYPE = Pulay | Density mixing scheme — Pulay is much smarter than linear. |
| for it in range(20) | NELM = 60 (max electronic steps) | Cap on SCF iterations. 'Reached required accuracy' message means converged before NELM. |
| np.sum(np.abs(n_new - n)) | EDIFF (energy threshold) | Convergence criterion. Default 10⁻⁴ eV; tighten to 10⁻⁶ for forces and phonons. |
A minimal INCAR for an SCF run
1# INCAR — single-point Kohn-Sham SCF
2SYSTEM = bulk CdSe SCF test
3ENCUT = 400 ! plane-wave cutoff in eV
4PREC = Accurate ! tight default grids
5ALGO = Normal ! blocked Davidson diagonalisation
6NELM = 60 ! max electronic SCF steps
7EDIFF = 1E-6 ! convergence threshold (eV)
8ISMEAR = 0 ! Gaussian smearing for occupations
9SIGMA = 0.05 ! smearing width (eV)
10LWAVE = .FALSE. ! don't write WAVECAR
11LCHARG = .TRUE. ! write CHGCAR for post-processingReading the SCF trace in OUTCAR
Inside OUTCAR you will find blocks like:
1-------------------------- Iteration 1( 1) ---------------------------
2 POTLOK: cpu time 0.0234: real time 0.0238
3 SETDIJ: cpu time 0.0011: real time 0.0011
4 EDDAV : cpu time 0.6041: real time 0.6071
5 DOS : cpu time 0.0143: real time 0.0144
6 --------------------------------------------
7 LOOP: cpu time 0.6645: real time 0.6680
8
9 RMM: 1 -0.4112832E+02 -0.41128E+02 -0.10293E+03 1024 0.392E+02
10 RMM: 2 -0.3914508E+02 0.19832E+01 -0.13842E+01 1024 0.108E+02
11 RMM: 3 -0.3905116E+02 0.93920E-01 -0.39121E-01 1024 0.241E+01
12 ...
13 RMM: 18 -0.3899203E+02 -0.21431E-06 -0.10202E-08 1024 0.140E-04Each RMM line is one electronic SCF step. Column 3 is the total energy; column 4 is the energy change (analogous to our res); column 5 is the band-structure energy change. The line reached required accuracy appears once column 4 falls below EDIFF — exactly the test we hand-coded.
ISPIN = 2) and an initial magnetic moment (MAGMOM) on the Mn atom. In that case the KS equations become two coupled sets — one per spin channel — sharing only the density-derived . Section 5.6 covers the spin-polarised KS formalism in detail.Summary
- The Hohenberg–Kohn theorem guarantees that exists, but the kinetic-energy functional is unknown. Direct minimisation is therefore impossible.
- The Kohn–Sham idea: replace the interacting electrons by non-interacting ones in an effective potential chosen to reproduce the same density. The kinetic energy of this system, , is computable as the sum of orbital kinetic energies.
- The energy decomposes as . Three terms are exact and computable; everything we don't know is in .
- Variation with respect to the orbitals gives the Kohn–Sham equations with .
- Self-consistency is unavoidable because depends on the orbitals it determines. The SCF loop iterates: build → diagonalise → new density → mix → repeat — until the density stops changing.
- KS densities and total energies are exact (with the exact ); KS orbitals and eigenvalues are formal devices. The KS gap differs from the true gap by the derivative discontinuity of — this is the band-gap problem of LDA/GGA.
- In VASP,
ENCUTsets the basis,ALGOchooses the iterative diagonaliser,NELMcaps SCF iterations, andEDIFFsets the convergence threshold. EveryRMMline inOUTCARis one execution of the loop you just coded.
Next section (4.7) we open the box of approximations to : LDA, GGA, meta-GGA, hybrids. Each is a different guess for the one piece Kohn–Sham could not give us exactly — and each comes with its own predictions, its own failures, and its own sweet spots. Choosing the right functional for Mn:CdSe will be a key decision in Chapter 7.