1. Introduction¶
1.1. 👋 Getting started¶
Welcome to our first lecture!
1.1.1. What is DFT?¶
Density Functional Theory (DFT) is a computational quantum mechanical method used to calculate the ground state of the electronic structure of many-body systems, particularly atoms, molecules, and solids. Unlike traditional quantum mechanics methods, which solve the Schrödinger equation for the many-electron wavefunction, DFT simplifies the problem by focusing on the electron density (in 3 dimensions) rather than the wavefunction (in $3N$ dimensions for $N$ electrons).
1.1.2. Functional¶
A functional is a function whose argument is itself a function. $f(x)$ is a function of the variable $x$ while $F[f]$ is a functional of the function $f$. $$ y = f(x) $$ $f$ is a function, it takes a number $x$ as input and output $y$ is also a number. $$ y = F[f(x)] $$ $F$ is a functional it takes function $f(x)$ as input and output $y$ is a number.
1.3. Functionals in DFT¶
The term "functional" in DFT comes from the fact that the total energy is calculated from the electron density function (which is a function of space) through the use of various functionals that describe different aspects of the system's energy.
1.2. Hohenberg-Kohn Theorem¶
Since the Hamiltonians is determined by the external potential, the Hohenberg-Kohn theorem tell us the two different Hamiltonian cannot have the same ground-state electron density. The theorem leads to two important consequences:
The Schrödinger equation says how we can get the wavefunction from a given potential. Once solved the wavefunction (which could be difficul due to the high‐dimensional partial differential equation), we can determine the density or any other properties. Now Corollary 1 says the opposite is also true. For a given density, the potential can be uniquely determined. Thus, it is possible to define the ground-state energy as a function of electronic density.
The ground state energy can therefore be found by minimizing $E[n(\textbf{r})]$ instead of solving for the many-electron wavefunction. However, the Hohenberg-Kohn theorems do not tell us how the energy depends on the electron density. It is noted that the DFT can have an exact solution if and only if $E[n(\textbf{r})]$ is known exactly. In reality, apart from some special cases, the exact $E[n(\textbf{r})]$ is unknown and only approximate functionals are used.
1.3. Kohn-Sham equation¶
For any system of $N$ interacting electrons in a given external potential $\mathcal{V}_{en} (\textbf{r})$ (i.e., Coulomb attraction between electrons and nuclei), there is a "virtual system" of $N$ non-interacting electrons with exactly the same density as the interacting one. The non-interacting electrons subjected to a effective external potential $\mathcal{V}_{eff} (\textbf{r})$ as: $$ \left[-\frac{\hbar^2 \nabla^2}{2m} + \mathcal{V}_{eff}(\textbf{r}) \right] \psi_i(\textbf{r}) = \epsilon_i \psi_i(\textbf{r}), $$ where the effective external potential is given by: $$ \mathcal{V}_{eff}(\textbf{r}) = \mathcal{V}_{en}(\textbf{r}) + \mathcal{V}_{H}(\textbf{r}) + \mathcal{V}_{xc}(\textbf{r}), $$ where the Hartree potential, which describes electrostatic interaction of electronic cloud, is defined by: $$ \mathcal{V}_{H}(\textbf{r}) = \int \frac{n(\textbf{r})}{|\textbf{r} - \textbf{r}'|} \mathrm{d}\textbf{r}', $$ and the electron density is given by: $$ n(\textbf{r}) = \sum_i f_i |\psi_i (\textbf{r})|^2, $$ where $f_i$ is the occupation factor of electrons ($0 \le f_i \le 1$). The Kohn-Sham equation looks like single particle Schrödinger equation, however $\mathcal{V}_{H}(\textbf{r})$ and $\mathcal{V}_{xc}(\textbf{r})$ (exchange-correlation potential, it includes all the remaining/unknown energy corrections) terms depend on $n(\textbf{r})$ i.e., on $\psi_i$ which in turn depends on $\mathcal{V}_{en}(\textbf{r})$. Therefore the problem is non-linear. It is usually solved computationally by starting from a trial potential and iterate to self-consistency
1.3.1. Self-Consistent Solution¶
The Kohn-Sham equations are solved iteratively:
- Guess $n(\textbf{r})$.
- Calculate $\mathcal{V}_{eff}(\textbf{r})$.
- Solve for $\psi_i$ and update $n(\textbf{r}) = \sum_i f_i |\psi_i (\textbf{r})|^2$.
- Repeat until convergence.
1.4. Exchange-correlation functional¶
1.4.1. Local Density Approximation (LDA)¶
The LDA is a widely used approximation the exchange-correlation energy of a system by assuming that the electronic density varies slowly and treating the local density as a uniform electron gas. In this case, the exchange-correlation energy at each point in space as being the same as that of a uniform electron gas with the same electron density at that point. Thus, the LDA is given by:
$$ E_{xc} = \int n(\textbf{r}) \epsilon_{xc}(n(\textbf{r})) d\textbf{r} $$ and $$ \mathcal{V}_{xc}(\textbf{r}) = \epsilon_{xc}(n(\textbf{r})) + n(\textbf{r})\frac{d\epsilon_{xc}(n)}{dn}\bigg\rvert_{n=n(\textbf{r})}, $$ where $\epsilon_{xc}(n)$ is the exchange-correlation energy per electron, which is obtained for the homogeneous electron gas of density $n$ (using Quantum Monte Carlo techniques) and fitted to some analytic form. LDA is computationally cheap compared to more advanced functionals, making it useful for large systems. However, the LDA can lead to inaccuracies in systems with rapidly varying densities (e.g., strongly correlated materials, surfaces, etc.).
1.4.2. Generalized Gradient Approximation (GGA)¶
The GGA is one of the approximations to the exchange-correlation energy functional, which improves the accuracy of exchange-correlation energy functionals by incorporating density gradients, going beyond the LDA. Thus, the GGA depends on both the local density and the local gradient of the density as: $$ E_{xc} = \int n(\textbf{r}) \epsilon_{GGA}(n(\textbf{r}), |\nabla n(\textbf{r})|) d\textbf{r}. $$
Unlike LDA, GGA considers how the electron density varies in space, improving accuracy for inhomogeneous systems. However, both the LDA and GGA underestimate band gaps in semiconductors and insulators and often fail for van der Waals (dispersion) interactions. In oder to solve these issues, there are more advanced functionals: Meta-GGA (e.g., SCAN), hybrids (e.g., B3LYP), nonlocal functionals for van der Waals forces, Grimme's DFT+D (a semi-empirical correction to GGA). They usually produces more accurate result, but computationally more expensive and sometimes numerically unstable.
1.5. Quantum ESPRESSO¶
Quantum ESPRESSO (QE) is one of the most used packages for first‐principles calculations with the DFT, and it has been developing continuously; thanks to its open‐source and excellent community support. The abbreviation ESPRESSO stands for “ESPRESSO = opEn Source Package for Research in Electronic Structure, Simulation, and Optimization.” It is completely FREE and easily installed on many platforms.
We can install QE on our personal laptops or desktops to run relatively less computationally intensive calculations. In particular, the almost of hands-on tutorials in this course can be run on a personal laptop. However, if we intend to perform computationally heavy tasks, we will need access to better computing resources with a larger number of CPU (or GPU) cores, memory, bandwidth, and disk IO.
1.5.1. Installing QE on Ubuntu¶
Easiest way to install Quantum Espresso is from the package manager of respective Ubuntu distribution. This should work fine for us and this is recommended option for this course. Following commands are for Ubuntu/Debian:
- Update list of repositories and upgrade the system
sudo apt update && sudo apt upgrade
- Important development tools and libraries: Git, wget, gcc/g++/gfortran, LAPACK, FFTW, openmpi (mpirun)
sudo apt -y install git wget build-essential
sudo apt -y install g++ gfortran
sudo apt -y install liblapack-dev libfftw3-dev libopenmpi-dev
- Quantum ESPRESSO and Wannier90 from apt repository
sudo apt -y install quantum-espresso wannier90
- Additional tools
sudo apt -y install xcrysden gnuplot
sudo apt -y install python3-dev jupyter-server
sudo apt -y install python3-numpy python3-scipy python3-sympy python3-matplotlib
1.5.2. Installing QE on Windows¶
For Windows, we recommend to use Windows subsystem for Linux (WSL) as follows:
- Open PowerShell as Administrator and run:
wsl --install
Restart your computer if needed.
Open the "Windows Terminal" and install a Linux distribution (Ubuntu is recommended).
Install QE for Ubuntu as shown above.
A Youtube video (not made by us) shows how to Quantum ESPRESSO 7.4 on Windows 11 (WSL2).
1.5.3. Installing QE on MacOS¶
We do not recommend using QE on macOS. I tested it on my MacBook Pro M1 and found it to be unstable. However, if you wish to install QE on a MacOS, you can refer to https://github.com/nguyen-group/QE-SSP/discussions/9.
1.5.4. Obtaining example files for this course¶
We provide example input/output files of QE calculations on the GitHub. You can download them by using the following command:
git clone https://github.com/nguyen-group/QE-SSP.git
1.6. Exercise¶
- Install QE on your PC.
1.7. Dive deeper¶
Level 1: Read Chapter 4 of "Quantum ESPRESSO for Solid State Physics" book for understanding DFT.
Level 2: Install Intel OneAPI Base Toolkit, then install QE with Intel MKL for optimized performance.