The main computational effort is the search for the KohnSham wavefunctions and groundstate electronic charge density for a fixed, 3Dperiodic configuration of ions. This requires the solution of a series of oneparticle Schrödinger equations:
(2.1) 
where is the Hamiltonian, the index labels different eigenstates, also known as bands, and the index labels different sampling points (`kpoints') in the reciprocalspace Brillouin zone of the periodic simulation cell. are the KohnSham wavefunctions, the eigenstates of these Schrödinger equations, and are the corresponding bandenergies.
The equations for different kpoints are not completely independent, but interact via the electronic charge density
For the 3D periodic systems Castep is designed to simulate, the density shares the same periodicity as the simulation system and so it is natural to express it in a Fourier basis. The basis functions are planewaves whose wavevectors are reciprocal lattice vectors of the simulation cell, the socalled Gvectors. The bands themselves need not be quite periodic, but they can always be written as the product of a phase factor and a periodic function. It is these kpoints that we sample, approximating the integral in equation 2.2 by a summation over discrete kvectors drawn uniformly from the first Brillouin zone.
The Hamiltonian consists of some terms which are diagonal, or neardiagonal, in reciprocal space (e.g. the kinetic energy operator) and some terms which are diagonal in realspace (e.g. the ionic potential operator). This necessitates the use of Fourier transforms to transform the data from reciprocal to realspace and back again.
Diagonalising the Hamiltonian directly is too expensive to be practical, and yields far more eigenstates than the lowest few we require; hence the search for the groundstate is an iterative procedure to compute just the lowest eigenstates, and in Castep this search can proceed in one of two main modes: density mixing (DM) or ensemble density functional theory (EDFT).
In the DM methodology the search proceeds by computing approximate eigenstates for a fixed trial charge density, computing a new density from these eigenstates, and then employing a density mixer to produce a new estimate for the true groundstate density.
[Density mixing (DM) algorithm]
[Ensemble density functional algorithm (EDFT)]

In the EDFT method the density used is always that obtained from the KohnSham wavefunctions. A trial step is performed along the search direction and the density and energy recomputed. Castep then uses the data from this sample point, along with the data at the initial point, to fit a quadratic and estimate the socalled selfconsistent minimum step, and hence find a better trial wavefunction. For metallic systems the bandoccupancies are determined in a similar manner, updating the density and energy at each trial step of an occupancy cycle and always aiming to take steps that lower the total energy.
Because the EDFT method requires the construction of the density many more times than the DM method, it performs many more Fourier transforms of the wavefunction and is significantly slower per SCF cycle. However by fixing the Hamiltonian in the DM wavefunction updates, the DM algorithm has a tendency to overshoot the true eigenstate and it is only the density mixer itself that drives the algorithm to the correct groundstate. For this reason it is common for DM calculations to take many more SCF cycles to converge than corresponding EDFT calculations, though each DM cycle is considerably faster.