Background
PyPWDFT is an educational implementation of spin-unpolarized, plane-wave Kohn–Sham density functional theory. This chapter outlines the equations and numerical choices used by the program. It is intended to connect the source code to the underlying theory; it is not a general review of every technique used by production solid-state codes.
Periodic plane-wave representation
A plane-wave calculation describes a periodically repeated unit cell. PyPWDFT currently uses a cubic cell of volume \(\Omega=L^3\) and samples only the \(\Gamma\) point. Molecules are represented by placing them in a cell with enough vacuum that interactions between periodic images become small. Cell-size convergence should therefore be checked just as cutoff convergence is checked.
The normalized plane waves are
where \(\mathbf G\) is a reciprocal lattice vector. An orbital is expanded as
Unlike a localized atomic-orbital basis, the number of basis functions is determined by the cell and a kinetic-energy cutoff. PyPWDFT retains the spherical set
Increasing \(E_\mathrm{cut}\) systematically enlarges the basis. It also increases the FFT grids and computational cost, so energies and other reported properties should be tested for cutoff convergence.
Wavefunction and density grids
Products of wavefunctions contain reciprocal components up to twice the largest wavefunction vector. Their kinetic-energy scale is consequently four times larger. The density cutoff therefore defaults to
PyPWDFT derives FFT-friendly wavefunction and density grid sizes from these two cutoffs. The current solver tracks both sizes but uses the density grid as its common working FFT grid. This avoids aliasing orbital products while retaining the spherical \(E_\mathrm{cut}\) mask as the actual variational orbital basis.
Kohn–Sham problem
For a closed-shell system, PyPWDFT solves
with
The density is constructed from the occupied orbitals as
The factor two accounts for paired spins. The present implementation therefore requires an even number of electrons and does not treat spin polarization, fractional occupations, or finite-temperature smearing.
The Hamiltonian is not assembled as a dense matrix. Instead, the code defines
its action on a vector of active plane-wave coefficients. The kinetic term is
diagonal in reciprocal space, while local potentials are applied by
transforming to real space, multiplying by the potential, and transforming
back. The selected CPU or GPU backend’s iterative eigensolver obtains only the
lowest requested states. Additional unoccupied states can be requested through
the bands SCF setting, but only occupied states contribute to the density.
Hartree potential
The classical electrostatic potential of the electrons follows from Poisson’s equation,
In reciprocal space this becomes, for \(\mathbf G\neq 0\),
The reciprocal zero component is set to zero, corresponding to the usual periodic electrostatic reference. FFTs make the transformations between \(\rho(\mathbf r)\) and \(\rho(\mathbf G)\) efficient.
Ions and GTH pseudopotentials
The recommended ionic model is the Goedecker–Teter–Hutter (GTH) pseudopotential. Core electrons are replaced by an effective potential and only the selected valence electrons enter the Kohn–Sham calculation. A GTH pseudopotential contains
a local ionic potential, evaluated on the reciprocal grid;
separable non-local projectors, applied directly to the active plane-wave coefficients; and
valence ionic charges used for the periodic ion–ion energy.
Bundled GTH-PADE parameters are paired with LDA, while bundled GTH-PBE parameters are paired with PBE. The high-level API enforces this matching unless an explicit external parameter directory is supplied.
An all-electron periodic Coulomb model remains available for educational and testing purposes. In that mode the electron–nuclear potential is evaluated in reciprocal space and the nuclear repulsion is calculated using an Ewald sum. Core states vary rapidly near a nucleus, however, and require much higher plane-wave cutoffs; GTH calculations are therefore substantially more practical for elements heavier than hydrogen and helium.
Exchange and correlation
PyPWDFT provides two spin-unpolarized exchange-correlation choices:
ldaSlater exchange combined with the Vosko–Wilk–Nusair VWN5 parameterization of Ceperley–Alder correlation data.
pbeThe Perdew–Burke–Ernzerhof generalized-gradient approximation. PBE depends on both the density and its gradient; derivatives are evaluated using the periodic reciprocal representation.
The exchange-correlation energy and potential are evaluated consistently for the selected functional. PBE calculations should use GTH-PBE parameters, and LDA calculations should use GTH-PADE parameters.
Self-consistent field procedure
Because the Hartree and exchange-correlation potentials depend on the density, the eigenvalue problem must be solved self-consistently. PyPWDFT uses the following cycle:
Start from a homogeneous density with the correct electron count.
Construct the Hartree and exchange-correlation potentials.
Build the matrix-free Kohn–Sham Hamiltonian.
Solve for the requested lowest Kohn–Sham states.
Construct a new density from the occupied states.
Form the density residual and use Pulay mixing to minimize a short history of recent residuals. The first update and ill-conditioned extrapolations fall back to damped linear mixing.
Repeat until both the total-energy change and RMS density residual satisfy their convergence thresholds.
The default Pulay mixer retains six densities and applies a mixing fraction of
0.5. This typically suppresses oscillations and reaches self-consistency in
fewer iterations than a fixed linear update. mixing="linear" remains
available for comparison and troubleshooting; reducing mixing_fraction
makes either method more conservative.
After convergence, the Hamiltonian is solved once more using the converged density. The returned orbitals, density, orbital energies, and energy components are then recomputed as one final post-convergence result. They are mutually consistent to the requested SCF tolerance rather than describing an intermediate mixed density.
The reported total energy is assembled as
Orbitals, phases, and degeneracy
Plane waves are complex, but at the \(\Gamma\) point the Kohn-Sham Hamiltonian is real in real space, so its eigenfunctions can be chosen real. An unconstrained eigensolver does not make that choice. It returns a non-degenerate orbital with an arbitrary global phase, and within a degenerate level it may return any complex unitary mixture of the real orbitals, such as \((p_x + \mathrm{i} p_y)/\sqrt{2}\). A phase factor per orbital cannot undo such mixing, and a single member of a degenerate level cannot be made real at all without its partners.
PyPWDFT therefore constrains the eigensolvers. A real function has plane-wave coefficients that obey \(c(-\mathbf{G}) = c(\mathbf{G})^{*}\). The Hamiltonian maps such vectors onto each other, and between them its matrix elements are real. Both eigensolvers work within this set, so every orbital they return is real in real space to rounding accuracy. This holds within degenerate levels too, and also when the requested number of bands cuts through a degenerate level.
For orbitals from another source, pypwdft.orbitals.rotate_orbitals_real()
applies, within every degenerate level, the unitary transformation that
minimizes the imaginary part. The plotting code uses it before displaying the
real component. It can report the residual imaginary norm, but suppressing that
diagnostic does not change the underlying orbital. Central molecular planes can
also be nodal planes. Since independently normalized contours can magnify tiny
numerical residues, plane="auto" is useful when plotting a heterogeneous
set of orbitals.
Current scope and limitations
The implementation intentionally has a focused scope:
cubic unit cells only;
\(\Gamma\)-point sampling only;
closed-shell, spin-unpolarized systems with an even electron count;
integer occupations without smearing;
LDA/VWN5 and PBE exchange-correlation functionals;
no geometry optimization, forces, stresses, molecular dynamics, or response properties; and
a common working FFT grid rather than a production-style dual-grid scheme.
These constraints keep the numerical path compact enough to study while still including spherical plane-wave cutoffs, iterative diagonalization, periodic electrostatics, local and non-local pseudopotentials, and GPU execution.
Further reading
R. M. Martin, Electronic Structure: Basic Theory and Practical Methods, Cambridge University Press.
M. C. Payne et al., “Iterative minimization techniques for ab initio total-energy calculations,” Reviews of Modern Physics 64, 1045 (1992).
S. Goedecker, M. Teter, and J. Hutter, “Separable dual-space Gaussian pseudopotentials,” Physical Review B 54, 1703 (1996).
J. P. Perdew, K. Burke, and M. Ernzerhof, “Generalized Gradient Approximation Made Simple,” Physical Review Letters 77, 3865 (1996).
An open-access introduction to Hartree–Fock and localized-orbital DFT is available in Elements of Electronic Structure Theory.
Other educational software
Acknowledgements
The bundled GTH-PADE and GTH-PBE parameter files originate from the CP2K data
repository and were obtained through
eminus. The GTH formulas and
parameter-file parsing in pypwdft/gth.py are adapted from eminus
(Apache-2.0). Licensing details and the publications to cite are listed in the
NOTICE
file distributed with the pseudopotentials.