Skip to main content

Hellmann-Feynman Forces in Plane-Wave DFT

In ab initio molecular dynamics, structure optimization, and vibrational analysis, the ability to compute the analytic forces on each atom is crucial. Computing forces via finite differences—displacing each atom and re-running the self-consistent field cycle—is prohibitively expensive: for a supercell with NN atoms, it requires O(N)O(N) SCF calculations. The Hellmann-Feynman theorem provides the solution: at SCF convergence, the atomic forces follow directly from the self-consistent wavefunction and charge density, with no additional eigenvalue computation needed. This page derives the forces from first principles, explains how they decompose into Ewald, local, and nonlocal contributions, and describes KRONOS's implementation and validation against finite differences.

The Hellmann-Feynman Theorem

The Hellmann-Feynman theorem states that for an eigenstate ψn|\psi_n\rangle of a parametrized Hamiltonian H(λ)H(\lambda),

Enλ=ψnHλψn,\frac{\partial E_n}{\partial \lambda} = \left\langle \psi_n \left| \frac{\partial H}{\partial \lambda} \right| \psi_n \right\rangle,

provided the wavefunction is an eigenstate of the parametrized Hamiltonian. The key insight is that the wavefunction derivative term ψn/λ\partial|\psi_n\rangle/\partial\lambda cancels identically at convergence:

dEndλ=λψnH(λ)ψn=ψnλHψn+ψnHλψn+ψnHψnλ.\frac{dE_n}{d\lambda} = \frac{\partial}{\partial\lambda} \langle \psi_n | H(\lambda) | \psi_n \rangle = \left\langle \frac{\partial\psi_n}{\partial\lambda} \bigg| H | \psi_n \right\rangle + \left\langle \psi_n \left| \frac{\partial H}{\partial\lambda} \right| \psi_n \right\rangle + \left\langle \psi_n \bigg| H | \frac{\partial\psi_n}{\partial\lambda} \right\rangle.

Since Hψn=EnψnH|\psi_n\rangle = E_n|\psi_n\rangle, the first and third terms give En(wavefunction overlap terms)En(same overlap)E_n(\text{wavefunction overlap terms}) - E_n(\text{same overlap}), which cancels. Only the middle term survives.

Application to atomic forces: For the total energy Etot({τa})E_\mathrm{tot}(\{\boldsymbol\tau_a\}) as a function of ionic positions τa\boldsymbol\tau_a (holding the electron density fixed on the Born-Oppenheimer surface, i.e., SCF converged), the force on atom aa is

Fa=Etotτa=ΨscfHτaΨscf+(electrostatic ion-ion contribution).\mathbf{F}_a = -\frac{\partial E_\mathrm{tot}}{\partial \boldsymbol\tau_a} = \left\langle \Psi_\mathrm{scf} \left| -\frac{\partial H}{\partial \boldsymbol\tau_a} \right| \Psi_\mathrm{scf} \right\rangle + \text{(electrostatic ion-ion contribution)}.

For plane-wave DFT with pseudopotentials, this partitions into three physically distinct contributions: Ewald ion-ion repulsion, local pseudopotential, and nonlocal pseudopotential forces. Each has a different functional form and implementation path.

Force Components: The Total Force

The total force on atom aa decomposes as

Fa=FaEwald+Falocal+FaNL.\boxed{\mathbf{F}_a = \mathbf{F}_a^\mathrm{Ewald} + \mathbf{F}_a^\mathrm{local} + \mathbf{F}_a^\mathrm{NL}}.

This decomposition holds exactly for norm-conserving pseudopotentials under the Hellmann-Feynman approximation (Pulay forces vanish; see §7). PAW introduces augmentation-charge contributions, which are handled separately. All equations below work in Rydberg atomic units, consistent with KRONOS source code.

Ewald Ion-Ion Forces

The ionic configuration energy is computed via the Ewald sum, which partitions the long-range Coulomb repulsion into a short-range real-space sum and a long-range reciprocal-space sum to accelerate convergence:

EEwald=a<bZaZb[R0erfc(ητab+R)τab+R+reciprocal-space part+self-interaction correction],E_\mathrm{Ewald} = \sum_{a<b} Z_a Z_b \left[ \sum_{\mathbf{R} \ne 0} \frac{\mathrm{erfc}(\eta |\boldsymbol\tau_{ab} + \mathbf{R}|)}{|\boldsymbol\tau_{ab} + \mathbf{R}|} + \text{reciprocal-space part} + \text{self-interaction correction} \right],

where Za,ZbZ_a, Z_b are ionic charges (from pseudopotentials), η\eta is the Ewald screening parameter (typically chosen for equal convergence of both sums), τab=τaτb\boldsymbol\tau_{ab} = \boldsymbol\tau_a - \boldsymbol\tau_b, and R\mathbf{R} ranges over lattice vectors.

Real-space contribution: The force from the real-space sum is straightforward differentiation:

FaEwald,real=ZabaZbRτa[erfc(ητab+R)τab+R].\mathbf{F}_a^\mathrm{Ewald,real} = Z_a \sum_{b \ne a} Z_b \sum_{\mathbf{R}} \frac{\partial}{\partial \boldsymbol\tau_a} \left[ \frac{\mathrm{erfc}(\eta |\boldsymbol\tau_{ab} + \mathbf{R}|)}{|\boldsymbol\tau_{ab} + \mathbf{R}|} \right].

Using ddr ⁣[erfc(ηr)r]=erfc(ηr)+2ηr/πe(ηr)2r2\frac{d}{dr}\!\left[\frac{\mathrm{erfc}(\eta r)}{r}\right] = -\frac{\mathrm{erfc}(\eta r) + 2\eta r / \sqrt{\pi} \, e^{-(\eta r)^2}}{r^2} (the chain rule and product rule), the force magnitude along the direction r^ab\hat{\mathbf{r}}_{ab} decays exponentially for short distances but remains O(1/r2)O(1/r^2) for distances beyond the Ewald cutoff—hence the need for the reciprocal-space sum to capture distant periodic images.

Reciprocal-space contribution: The reciprocal-space Ewald energy is

EEwald,recip=2πΩG0eG2/(4η2)G2aZaeiGτa2.E_\mathrm{Ewald,recip} = \frac{2\pi}{\Omega} \sum_{\mathbf{G} \ne 0} \frac{e^{-|\mathbf{G}|^2/(4\eta^2)}}{|\mathbf{G}|^2} \left| \sum_a Z_a e^{i\mathbf{G} \cdot \boldsymbol\tau_a} \right|^2.

Differentiating with respect to τa\boldsymbol\tau_a:

FaEwald,recip=2πΩG0eG2/(4η2)G2iGZaeiGτa[bZbeiGτb+c.c.].\mathbf{F}_a^\mathrm{Ewald,recip} = \frac{2\pi}{\Omega} \sum_{\mathbf{G} \ne 0} \frac{e^{-|\mathbf{G}|^2/(4\eta^2)}}{|\mathbf{G}|^2} \cdot i\mathbf{G} \, Z_a e^{i\mathbf{G} \cdot \boldsymbol\tau_a} \left[ \sum_b Z_b e^{-i\mathbf{G} \cdot \boldsymbol\tau_b} + \text{c.c.} \right].

When summed over all atoms, the reciprocal-space contribution vanishes by charge neutrality (the structure factor for G0\mathbf{G} \ne 0 sums to zero for neutral systems); for a single atom, it is nonzero and essential.

Implementation: KRONOS computes both real and reciprocal contributions in src/potential/forces.cpp::ewald_forces(). The algorithm:

  1. Real-space loop: all pairs (a,b)(a, b) with τab+R<rcut|\boldsymbol\tau_{ab} + \mathbf{R}| < r_\mathrm{cut}.
  2. Reciprocal-space loop: all G\mathbf{G} vectors up to the wavefunction cutoff, using cached structure factors aZaeiGτa\sum_a Z_a e^{i\mathbf{G} \cdot \boldsymbol\tau_a}.

The total Ewald force on atom aa is FaEwald=FaEwald,real+FaEwald,recip\mathbf{F}_a^\mathrm{Ewald} = \mathbf{F}_a^\mathrm{Ewald,real} + \mathbf{F}_a^\mathrm{Ewald,recip}.

Local Pseudopotential Forces

The local pseudopotential contributes an energy-density term, Eloc=Vloc(r)n(r)d3rE_\mathrm{loc} = \int V_\mathrm{loc}(\mathbf{r}) n(\mathbf{r}) d^3r, where Vloc(r)V_\mathrm{loc}(\mathbf{r}) depends on atomic positions τa\boldsymbol\tau_a through the superposition of spherically symmetric potentials centered at each atom.

In G-space, Vloc(r)V_\mathrm{loc}(\mathbf{r}) expands as

Vloc(r)=aVloca(rτa),V_\mathrm{loc}(\mathbf{r}) = \sum_a V_\mathrm{loc}^a(|\mathbf{r} - \boldsymbol\tau_a|),

with Fourier components

V~loca(G)=eiGτa0Vloca(r)j0(Gr)r2dr,\tilde{V}_\mathrm{loc}^a(\mathbf{G}) = e^{-i\mathbf{G} \cdot \boldsymbol\tau_a} \int_0^\infty V_\mathrm{loc}^a(r) j_0(Gr) r^2 \, dr,

where j0(x)=sin(x)/xj_0(x) = \sin(x)/x is the zeroth-order spherical Bessel function (spherical symmetry ensures only j0j_0 appears).

The local energy and its gradient are

Eloc=Ω2G[V~loc(G)]n(G),E_\mathrm{loc} = \frac{\Omega}{2} \sum_{\mathbf{G}} [\tilde{V}_\mathrm{loc}(\mathbf{G})]^* n(\mathbf{G}),

Falocal=Elocτa=iΩG0G[V~loca(G)]n(G).\mathbf{F}_a^\mathrm{local} = -\frac{\partial E_\mathrm{loc}}{\partial \boldsymbol\tau_a} = -i\Omega \sum_{\mathbf{G} \ne 0} \mathbf{G}\, [\tilde{V}_\mathrm{loc}^a(\mathbf{G})]^* n(\mathbf{G}).

Physical interpretation: The factor iGi\mathbf{G} comes from differentiating the structure factor eiGτae^{-i\mathbf{G} \cdot \boldsymbol\tau_a} with respect to position. The force is proportional to the gradient of the local potential convolved with the electron density in G-space.

Numerical implementation: KRONOS precomputes the Fourier-transformed local pseudopotential V~loca(G)\tilde{V}_\mathrm{loc}^a(\mathbf{G}) via spherical Bessel transform at initialization and caches it. At each SCF step, the density n(G)n(\mathbf{G}) is available on the finer density grid (controlled by Ecut,rhoeE_\mathrm{cut,rhoe}). The force is computed as a loop over G\mathbf{G} vectors, accumulating G×Vloca(G)×n(G)\mathbf{G} \times V_\mathrm{loc}^a(\mathbf{G}) \times n(\mathbf{G}). Cost: O(NG,dense)O(N_\mathrm{G,dense}).

Nonlocal Pseudopotential Forces

The nonlocal pseudopotential is expressed in the Kleinman-Bylander separable form as

V^NL=almijβlm,iaDijl,aβlm,ja,\hat{V}_\mathrm{NL} = \sum_a \sum_{lm} \sum_{ij} |\beta_{lm,i}^a\rangle D_{ij}^{l,a} \langle \beta_{lm,j}^a|,

where βlm,ia(r)=Ril(rτa)Ylm(rτa^)\beta_{lm,i}^a(\mathbf{r}) = R_i^l(|\mathbf{r} - \boldsymbol\tau_a|) Y_{lm}(\widehat{\mathbf{r} - \boldsymbol\tau_a}) is a projector centered at atom aa.

The total electronic energy includes the nonlocal contribution

ENL=2nkwkfnka,lm,ijDijl,aplm,ia,(k)Dijl,aplm,ja(k),E_\mathrm{NL} = 2\sum_{n\mathbf{k}} w_\mathbf{k} f_{n\mathbf{k}} \sum_{a,lm,ij} D_{ij}^{l,a} \, p_{lm,i}^{a,\ast}(\mathbf{k}) D_{ij}^{l,a} \, p_{lm,j}^{a}(\mathbf{k}),

where the projections are plm,ia(k)=βlm,iaψnkp_{lm,i}^a(\mathbf{k}) = \langle \beta_{lm,i}^a | \psi_{n\mathbf{k}} \rangle and the prefactor 22 accounts for double occupancy (spin for closed-shell systems).

Force calculation: Differentiating ENLE_\mathrm{NL} with respect to τa\boldsymbol\tau_a (remembering that both βlm,ia\beta_{lm,i}^a and the projections plm,iap_{lm,i}^a depend on position), the Hellmann-Feynman theorem gives

\mathbf{F}_a^\mathrm{NL} = -2\sum_{n\mathbf{k}} w_\mathbf{k} f_{n\mathbf{k}} \sum_{lm,ij} D_{ij}^{l,a} \, \mathrm{Re}\left[ p_{lm,i}^{a,\ast}(\mathbf{k}) \left\langle \psi_{n\mathbf{k}} | \nabla_a \beta_{lm,j}^a \right| \psi_{n\mathbf{k}} \right\rangle \right].

Here, the projector gradient is computed in reciprocal space. For a projector expanded as

βlm,ia(r)=GeiGτaβ~lm,ia(G)eiGr,\beta_{lm,i}^a(\mathbf{r}) = \sum_\mathbf{G} e^{-i\mathbf{G} \cdot \boldsymbol\tau_a} \, \tilde{\beta}_{lm,i}^a(\mathbf{G}) e^{i\mathbf{G} \cdot \mathbf{r}},

the spatial gradient picks up an extra factor of i(k+G)i(\mathbf{k} + \mathbf{G}) from the plane-wave exponential:

aβlm,ia=i(k+G)βlm,ia.\nabla_a \beta_{lm,i}^a = i(\mathbf{k} + \mathbf{G}) \beta_{lm,i}^a.

In practice, the projections plm,ia(k)p_{lm,i}^a(\mathbf{k}) are computed as inner products of wavefunctions with the Fourier-transformed projectors. The force requires an additional set of projections, (k+G)×β~lm,ia(G)(\mathbf{k}+\mathbf{G}) \times \tilde{\beta}_{lm,i}^a(\mathbf{G}), which are accumulated during the wavefunction-projector contraction.

Implementation in KRONOS: The function nonlocal_forces() in src/potential/forces.cpp orchestrates:

  1. For each k-point, compute the standard projections plm,ia=βlm,iaψp_{lm,i}^a = \langle \beta_{lm,i}^a | \psi \rangle.
  2. Compute gradient projections: ψ(k+G)βlm,ia\langle \psi | (\mathbf{k}+\mathbf{G}) \beta_{lm,i}^a \rangle for each projector and k-point.
  3. Accumulate force via the formula above, summing over all occupied bands.
  4. Weight by Fermi occupations fnkf_{n\mathbf{k}} and k-point weights wkw_\mathbf{k}.

Cost per k-point: O(Nbands×Natoms×Nprojectors×NPW)O(N_\mathrm{bands} \times N_\mathrm{atoms} \times N_\mathrm{projectors} \times N_\mathrm{PW}), dominated by the BLAS inner products.

XC and Hartree Forces

The exchange-correlation energy and Hartree energy depend on the electron density n(r)n(\mathbf{r}). The chain rule gives

Faxc,h=vxc(r)n(r)τad3r+vH(r)n(r)τad3r.\mathbf{F}_a^\mathrm{xc,h} = \int v_\mathrm{xc}(\mathbf{r}) \frac{\partial n(\mathbf{r})}{\partial \boldsymbol\tau_a} d^3r + \int v_\mathrm{H}(\mathbf{r}) \frac{\partial n(\mathbf{r})}{\partial \boldsymbol\tau_a} d^3r.

However, at SCF convergence, the density is stationary with respect to variations of the wavefunction (the variational principle). The Hellmann-Feynman theorem ensures that the implicit wavefunction derivative cancels, leaving only explicit dependencies. For a local potential like vxcv_\mathrm{xc} or vHv_\mathrm{H}, the explicit dependence on τa\boldsymbol\tau_a vanishes—only the density varies, and that variation is already captured through the stationarity condition. Thus, XC and Hartree forces contribute zero explicitly in the Hellmann-Feynman approximation (they are included implicitly through the SCF convergence condition).

This simplification—that local potentials require no special force term—is one of the key advantages of plane-wave codes over other methods.

Pulay Forces: Why They Vanish

In methods where the basis set depends on atomic positions (e.g., atom-centered Gaussian orbitals in LCAO), the basis set itself changes when atoms move, introducing additional "Pulay" or "BFGS" force terms. Mathematically,

FaPulay=ψnHτaψnτac.c.,\mathbf{F}_a^\mathrm{Pulay} = -\left\langle \psi_n \left| \frac{\partial H}{\partial \boldsymbol\tau_a} \right| \frac{\partial \psi_n}{\partial \boldsymbol\tau_a} \right\rangle - \text{c.c.},

which vanishes when the basis is orthonormal and independent of atomic coordinates.

In plane-wave codes, the basis is a fixed, infinite set of plane waves ei(k+G)re^{i(\mathbf{k}+\mathbf{G})\cdot\mathbf{r}} that does not depend on τa\boldsymbol\tau_a (only the cell shape and k-points affect it, through FFT grids and Brillouin zone symmetry). Therefore, Pulay forces vanish identically, and the Hellmann-Feynman formula becomes exact. This architectural advantage—that basis-set incompleteness errors in forces are eliminated—makes plane-wave DFT forces highly reliable.

Force Symmetrization

After computing the raw Hellmann-Feynman forces from the SCF density, numerical noise and floating-point rounding accumulate. A symmetry-enforcing post-processing step cleans up the forces and ensures they respect the point-group symmetry of the crystal.

Algorithm:

  1. Use spglib to identify the space-group operations that leave the crystal structure invariant.
  2. For each symmetry operation S\mathbf{S}, map atom aa to its image atom aa' (possibly related by translation).
  3. Transform the force Fa\mathbf{F}_a under the symmetry operation: Fa(S)=SFa\mathbf{F}_a^{(\mathbf{S})} = \mathbf{S} \mathbf{F}_{a'}.
  4. Average the forces over all symmetry-equivalent images.

Result: The symmetrized force on atom aa is

Fasym=1NsymSGSFa,\mathbf{F}_a^\mathrm{sym} = \frac{1}{N_\mathrm{sym}} \sum_{\mathbf{S} \in \mathbf{G}} \mathbf{S} \mathbf{F}_{a'},

where the sum is over all symmetry operations and aa' is the image of aa under S\mathbf{S}.

Conservation: By construction, symmetrization conserves the total force on the unit cell: aFasym=0\sum_a \mathbf{F}_a^\mathrm{sym} = 0 (up to small numerical noise). This is a consequence of translational invariance: displacing the entire cell should produce no net force.

Implementation: In KRONOS, symmetrize_forces() (in src/io/symmetry.cpp) applies this post-processing. The symmetrized forces are used for geometry optimization and MD, improving stability by removing spurious asymmetries.

Finite-Difference Validation

The most stringent test of force accuracy is finite-difference validation: compute the energy for small ionic displacements and compare E/Ra\partial E / \partial \mathbf{R}_a with the analytic Hellmann-Feynman force.

Procedure:

  1. For atom aa and Cartesian direction α\alpha (x, y, or z), displace by δ=0.01\delta = 0.01 a.u. (or smaller).
  2. Run SCF to convergence at the displaced geometry; record E(τa+δα^)E(\boldsymbol\tau_a + \delta\hat{\alpha}).
  3. Compute numerical derivative: FαFD=[E(τa+δα^)E(τaδα^)]/(2δ)F_\alpha^\mathrm{FD} = [E(\boldsymbol\tau_a + \delta\hat{\alpha}) - E(\boldsymbol\tau_a - \delta\hat{\alpha})] / (2\delta).
  4. Compare with analytic force FαHFF_\alpha^\mathrm{HF} from the Hellmann-Feynman calculation at τa\boldsymbol\tau_a.
  5. Compute relative error: ϵ=FαFDFαHF/FαHF\epsilon = |F_\alpha^\mathrm{FD} - F_\alpha^\mathrm{HF}| / |F_\alpha^\mathrm{HF}|.

KRONOS results: For silicon diamond at Ecut=12E_\mathrm{cut} = 12 Ry with Gamma-point sampling, displacing a single atom by 0.01 fractional units (approximately 0.025 bohr along the lattice vector) yields agreement to 5 significant figures: ΔF<105\Delta F < 10^{-5} Ry/bohr for forces in the range F103|F| \sim 10^{-3} Ry/bohr. This validates the Ewald, local, and nonlocal force components jointly.

Expected accuracy: For high-quality calculations (fine k-point sampling, large cutoffs), forces agree to 10510^{-5}10610^{-6} Ry/bohr. At lower cutoffs or coarser sampling, 10410^{-4} Ry/bohr is typical. The finite-difference displacement δ\delta should be small enough to probe the linear regime (δ0.01\delta \lesssim 0.01 bohr) but large enough to keep numerical error below the analytic error (δ104\delta \gtrsim 10^{-4} bohr for double precision).

Geometry Optimization and Molecular Dynamics

The forces computed via Hellmann-Feynman are fed into two main applications:

  1. Geometry optimization (structural relaxation): KRONOS uses the BFGS algorithm (in src/solver/vc_relax.cpp) to minimize the total energy by moving atoms along the negative gradient Fa-\mathbf{F}_a. The Hessian (second-derivative matrix) is approximated using previous steps, and ions are moved until the maximum force drops below a tolerance (typically 10410^{-4} Ry/bohr) and the energy change stabilizes.

  2. Molecular dynamics: At fixed temperature, ions are advanced using the Verlet or velocity-Verlet algorithm, with forces as acceleration. KRONOS's MD infrastructure is under development (v0.2 roadmap).

In both cases, accurate, stable forces are essential for reliable predictions.

How KRONOS Implements Forces

The orchestration happens in compute_forces() (main dispatcher in src/solver/scf.cpp):

compute_forces(const SCFState& scf_state, const Crystal& crystal, ...)
|
+-- ewald_forces(crystal)
| [real-space + reciprocal-space ion-ion repulsion]
|
+-- local_pp_forces(scf_state.density, crystal)
| [gradient of local pseudopotential energy, G-space loop]
|
+-- nonlocal_forces(scf_state.wavefunctions, scf_state.eigenvalues, crystal)
| [projector overlaps with wavefunction gradients, BLAS]
|
+-- symmetrize_forces(forces, crystal)
[spglib-based averaging over symmetry operations]

The output is a vector of forces {Fa}\{\mathbf{F}_a\} in Ry/bohr. For variable-cell relaxation, stress components are computed similarly (derivative of energy with respect to cell deformation) and passed to the BFGS optimizer alongside atomic forces.

References

  • Hellmann, H. Einführung in die Quantenchemie. Deuticke, Leipzig (1937). [Original statement of the theorem.]
  • Feynman, R. P. "Forces in molecules." Phys. Rev. 56, 340–343 (1939). [Quantum mechanical derivation and application to molecular geometry.]
  • Ihm, J., Zunger, A. & Cohen, M. L. "Momentum-space formalism for the total energy of solids and the equation of state." J. Phys. C: Solid State Phys. 12, 4409–4422 (1979). [Pseudopotential forces in plane waves; local and nonlocal contributions clearly separated.]
  • Martin, R. M. Electronic Structure: Basic Theory and Practical Methods. Cambridge University Press (2004). [Chapter 9: Forces and stresses in DFT; comprehensive treatment of all force components.]
  • Gonze, X., Kresse, G., et al. "Recent developments in the ABINIT software package." Comp. Phys. Commun. 205, 106–131 (2016). [Section on forces, symmetrization, and validation in modern plane-wave codes.]