Fourier Transforms and Plane-Wave Expansions¶
Source code: https://github.com/osscar-org/quantum-mechanics/blob/master/notebook/band-theory/FFT_and_planewaves.ipynb
This notebook shows interactively how discrete Fourier series can represent a function with a limited amount of plane-wave components. A common way to represent a wavefunction when solving the Kohn-Sham equations is via its expansion in plane waves. This notebook focuses on a simple example (much simpler than a complete DFT calculation) in order to help the reader focus on the essential aspects of such a representation.
Goals¶
- Understand how a plane-wave basis is directly related to a Fourier series.
- Learn how to decompose a function using a FFT algorithm.
- Examine how a function is reconstructed from a finite (possibly not complete) set of plane waves.
- Understand the impact of the basis-set size on the convergence of the integral of the reconstructed function.
Background theory¶
Tasks and exercises¶
- Prove that plane waves form an orthogonal basis set.
Solution
We have to prove that $\langle w_N^j, w_N^k \rangle =\langle w_N^k, w_N^j \rangle= 0 $ for integer $j \neq k$. We can simply carry out the inner product $$ \langle w_N^j, w_N^k \rangle = \langle w_N^k, w_N^j \rangle = \int_{-\pi}^{\pi} e^{ijx} e^{-ikx}dx = \int_{-\pi}^{\pi} e^{i(j-k)x} dx = \frac 1 {i(j-k)} [e^{i(j-k)x}]_{-\pi}^{\pi} = \begin{cases} 0 & \text{if j $\neq$ k} \\ 2\pi & \text{if j = k}\end{cases}$$ - How does the number of plane waves affect the approximation of the target function? Will a function with more "oscillations" require more components to be accurately represented?
Solution
Move the slider to try different numbers of Fourier components. Observe if the FFT interpolation approximates well the original function and if the integral of the square modulus is close to the convergence value. You can also change the objective function by the drop-down menu. Generally, more sampling yields more accurate representation. For functions with more oscillations (higher frequency components), more Fourier components are needed to reach the same level of accuracy. - How can we reduce the number of plane waves needed in a DFT calculation, without sacrificing the accuracy of the representation?
Solution
Wavefunctions have the strongest oscillations near nucleus, and a very large number of plane waves is needed to accurately represent this region. Fortunately, core electrons are less relevant in chemical bonding, so we can simplify the problem and obtain a much smoother (pseudo)wavefunction by excluding the core electrons. To learn more about this approach, please check our notebook on pseudopotentials. In general, the combination of pseudopotentials and a plane-wave expansion enables fast and accurate calculation of materials and their properties. - In a DFT calculation, how can we control the number of plane waves used in the basis set?
Solution
The kinetic energy of a plane wave of momentum $\mathbf G$ is given by $\frac {\hbar^2}{2m} \lvert \mathbf G \rvert^2$. By setting a cutoff energy, we can limit the size of the plane-wave basis set. The value of the cutoff depends on the system under investigation and the pseudopotential used, and convergence tests are normally required. To have a suggestion of a converged cutoff value based on the choice of pseudopotentials, you can check the standard solid-state pseudopotentials (SSSP) library on Materials Cloud.
Legend¶
The target function, sampling points and the reconstructed function are shown in the top left plot. The real part (cosine functions) and the constant term of the discrete Fourier series are shown in the top right panel.
Note that the components are shifted vertically for clarity. The integral of the square of the functions reconstructed from truncated Fourier series with different numbers of plane waves $N_{\text{fft}}$ is shown in the bottom panel, where the current choice of sampling is indicated with a red dot. The converged value is also shown with a red horizontal line, obtained with a large number (200) of FFT components.
The number of FFT components $N_{\text{fft}}$ can be set by the slider. Two target functions can be chosen from the drop-down menu.
By clicking one of the expansions in the top-right panel, the contribution of that component will be shown in the top left panel. Click the reset button to display all expansion coefficients again.