Untitled

Download as pdf or txt
Download as pdf or txt
You are on page 1of 372

Quantum ESPRESSO Course

for Solid-State Physics


Quantum ESPRESSO Course
for Solid-State Physics

Nguyen Tuan Hung


Ahmad R. T. Nugraha
Riichiro Saito
Published by

Jenny Stanford Publishing Pte. Ltd.


101 Thomson Road
#06‐01, United Square
Singapore 307591

Email: [email protected]
Web: www.jennystanford.com

British Library Cataloguing‑in‑Publication Data


A catalogue record for this book is available from the British Library.

Quantum ESPRESSO Course for Solid‑State Physics


Copyright © 2023 Jenny Stanford Publishing Pte. Ltd.

All rights reserved. This book, or parts thereof, may not be reproduced
in any form or by any means, electronic or mechanical, including
photocopying, recording or any information storage and retrieval
system now known or to be invented, without written permission from
the publisher.

For photocopying of material in this volume, please pay a copying fee


through the Copyright Clearance Center, Inc., 222 Rosewood Drive,
Danvers, MA 01923, USA. In this case permission to photocopy is not
required from the publisher.

ISBN 978‐981‐4968‐37‐9 (Hardcover)


ISBN 978‐981‐4968‐63‐8 (Paperback)
ISBN 978‐1‐003‐29096‐4 (eBook)
Contents

Preface ix

1 Introduction 1
1.1 How to read and use the book? 1
1.2 What do we need to run a program? 3
1.3 What we get, and what we do not get? 3
1.4 Organization of the book 4

2 Software Installation 5
2.1 Preparing the operating systems 5
2.1.1 Ubuntu Linux 6
2.1.2 Windows 8
2.1.3 macOS Catalina 14
2.2 Installation of Quantum ESPRESSO and its supporting
software 14
2.3 VirtualBox approach 18
2.4 Processing input and output files 20
2.4.1 Basic execution of Quantum ESPRESSO
commands 20
2.4.2 Choice of plotting software 21
2.4.3 Obtaining example files for hands‐on tutorials 23

3 Hands‐On Tutorials of Quantum ESPRESSO 25


3.1 Basic parameters 26
3.1.1 Total energy and self‐consistent field
calculations 26
3.1.2 Plane‐wave cut‐off energy 36
3.1.3 k‐points for Brillouin‐zone integration 40
3.1.4 Optimizing atomic positions 46
vi | Contents

3.1.5 Optimizing unit cell 52


3.1.6 Selecting pseudopotential 56
3.1.7 Selecting smearing function and energy 61
3.2 Electronic properties 69
3.2.1 Charge density 69
3.2.2 Electronic energy dispersion 73
3.2.3 Electronic density of states 79
3.2.4 Partial density of states 83
3.3 Lattice oscillations 87
3.3.1 Phonon dispersion 87
3.3.2 Phonon density of states 96
3.3.3 Electron‐phonon interaction 100
3.3.4 Eliashberg spectral function 108
3.4 Optical properties 113
3.4.1 Dielectric function and absorption spectra 113
3.4.2 Joint density of states 122
3.4.3 Non‐resonant Raman spectra 125
3.5 Subjects for two‐dimensional materials 129
3.5.1 Spin‐orbit coupling 130
3.5.2 Van der Waals interaction 134
3.5.3 External electric field 140
3.6 Maximally‐localized Wannier functions 150
3.6.1 Wannier functions, energy dispersion, and
tight‐binding parameters 150
3.6.2 Wannier interpolation for hybrid functional 161

4 Density‐Functional Theory 167


4.1 “Black box” Quantum ESPRESSO 167
4.2 The Schrödinger equation 169
4.3 Systems of non‐interacting electrons 173
4.4 Hartree potential 177
4.5 Self‐consistent field 179
4.6 Exchange potential 182
4.7 Correlation potential 189
4.8 Early DFT for free‐electron gas 190
4.9 Thomas‐Fermi‐Dirac theory 195
4.10 DFT: Hohenberg‐Kohn‐Sham 196
4.10.1 Hohenberg‐Kohn theorem 197
4.10.2 Kohn‐Sham equation 199
Contents | vii
4.10.3 Relationship between Kohn‐Sham energy and
total energy 201
4.11 Exchange‐correlation functional 202
4.11.1 Local‐density approximation 202
4.11.2 Generalized gradient approximation 206
4.11.3 Hybrid functionals 208
4.12 Total energy calculation 212
4.12.1 Hartree contribution 213
4.12.2 Exchange‐correlation contribution 214
4.12.3 One‐electron contribution and pseudopotential 215
4.12.4 The Ewald contribution 217
4.13 Ionic forces 219
4.14 A simple DFT‐LDA program for an atom 220
4.14.1 Radial Schrödinger equation 221
4.14.2 The Poisson equation 225
4.14.3 DFT‐LDA for helium 228

5 Solid‐State Physics for Quantum ESPRESSO 235


5.1 Unit cell and Brillouin zone 235
5.2 X‐ray analysis 237
5.3 Plane wave expansion 240
5.4 Cut‐off energy and pseudopotential 242
5.5 Energy bands and density of states 244
5.6 Experiments for E(k) and DOS 247
5.7 Phonon dispersion 248
5.8 Electron‐phonon interaction 251
5.9 Optical properties of solid 254
5.10 Transport properties of solid 259
5.11 Phonon‐phonon interaction 262
5.12 Heat conduction in a solid 265
5.13 Non‐resonant Raman scattering 267
5.14 Warnier functions 271
5.14.1 Maximally‐localized Warnier functions 273
5.14.2 Spread of the Wannier functions 274
5.14.3 Tight‐binding model and Wannier interpolation275

6 Productivity Tools 277


6.1 Quantum ESPRESSO input generators 277
6.1.1 Obtaining a structural CIF file from AFLOW 278
viii | Contents

6.1.2 Generating SCF input file from MaterialsCloud 281


6.1.3 Preparing DOS and band structure inputs 286
6.1.4 Wannier90 input generator from CIF file 290
6.2 Linux commands 291
6.2.1 File‐ and directory‐related commands 293
6.2.2 System information and process management 307
6.2.3 Running parallel calculations 315
6.2.4 Parallelization in Quantum ESPRESSO 317
6.2.5 Searching 318
6.2.6 Keyboard shortcuts 320
6.3 Shell scripts and batch jobs 322
6.3.1 Environment 323
6.3.2 Scripting 324
6.3.3 Quantum ESPRESSO job script 331
6.4 Plotting and visualization tools 332
6.4.1 Plain plotting of the data 334
6.4.2 Changing general plot parameters 336
6.4.3 Setting axes and ticks 337
6.4.4 Annotations and saving the plots 338
6.4.5 Creating and using your Matplotlib style 339
6.4.6 Plotting DOS and energy dispersion 341

Bibliography 343

Index 357
Preface

This book is based on a first‐principles workshop “An introduction


and hands‐on tutorials with Quantum ESPRESSO” held at Tohoku
University, Japan, in 2016. Since many participants of the workshop
asked us about any textbook on Quantum ESPRESSO, and since
the publisher accepted to publish such a book, we started writing
this book in 2019 and kept adding latest information on density‐
functional theory and solid‐state physics. We expect the following
two groups as the potential readers: Group 1 is experimental
researchers who wish to run the first‐principles calculation
themselves to compare experimental results of new materials
directly. Nowadays, it is not surprising to know that experimental
researchers calculate Quantum ESPRESSO by themselves. Group
2 is theoretical researchers who wish to know details of the first‐
principles calculation for running Quantum ESPRESSO. It is not easy
for a student to run Quantum ESPRESSO and learn density‐functional
theory at the same time.
Quantum ESPRESSO is one of the most used packages for first‐
principles calculations, 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.” First and foremost, we are neither developers nor
experts. We are just Quantum ESPRESSO users. We started to learn
Quantum ESPRESSO at a workshop held at the Tokyo Institute of
Technology, Japan, in 2014. After that, in 2016, Tohoku University
Program for Leading Graduate Schools supported us to organize the
first‐principles workshop by NTH and ARTN as mentioned above.
It was a very successful workshop with 51 participants, including
students and even professors. We were surprised that all participants
x | Preface

were happy to run Quantum ESPRESSO on their notebook PC only


after one day workshop. We hope the readers can have the same
experience by reading this book. The contents of this book have also
been used in first‐principles workshops organized by RS at Zhejiang
University (China) in March 2019 and by NTH at the Vietnam School
of Physics (Vietnam) in July 2019.
This book is a step‐by‐step guide to practice first‐principles
calculations with Quantum ESPRESSO. It is organized into three
parts. The first part gives instructions to install Quantum ESPRESSO
on your computer in Chapter 2 and detailed hands‐on tutorials of
Quantum ESPRESSO in Chapter 3, which is the main part of the
workshop. The second part provides the concepts of the density‐
functional theory that the readers want to know for understanding
the keywords of Quantum ESPRESSO in Chapter 4. The third part
consists of solid‐state physics in Chapter 5 and productivity tools in
Chapter 6, such as graphics and Linux command scripts, which are
used in Chapter 3. The book’s text is suitable for researchers not only
in physics but also in chemistry or materials science.
Even though the first‐principles calculations have been introduced
by many reviews and books, this book will be useful for many new
scientists and students that are interested in Quantum ESPRESSO.
The book has a reasonable balance between practical examples and
fundamental theories for learning Quantum ESPRESSO. Therefore,
we suggest the readers to first go through the examples in Quantum
ESPRESSO and then learn the details from this book. All examples,
codes, and scripts in this book are available on the following web
page: https://github.com/nguyen-group/QE-SSP and therefore,
the readers will not require to type the examples.
The authors acknowledge the efforts of the students and
collaborators who assisted in checking the examples and contents of
this book. Finally, we wish to tell the readers, “Welcome to Quantum
ESPRESSO.”

Nguyen Tuan Hung


Ahmad R. T. Nugraha
Riichiro Saito
Sendai, 2022
Chapter 1

Introduction

In this chapter, we will give a brief overview of book. Then, we will


explain the goal of the book and how to read the book for your
purpose.

1.1 How to read and use the book?

First‐principles calculation in solid‐state physics is a computer


program for calculating the energy band structure of a solid. Here,
the word “first‐principles” means that we can calculate the energy
band with no adjustable parameters but only by giving coordinates
of atoms in solid and their atomic numbers.1 Once we know how to
run the first‐principles calculation programs, we can get the ground‐
state properties from which we discuss many properties of solids.
In the 20th century, physics and computer science of the first‐
principles calculations were developed by many researchers. Only
a few people could run the program in the early times because:
(1) it was generally not open for the public, (2) it required a

1 It is noted that we have many principles in the first‐principles. Thus, we do not say

“first‐principle calculation” but “first‐principles calculation”.

Quantum ESPRESSO Course for Solid‐State Physics


Nguyen Tuan Hung, Ahmad R. T. Nugraha, and Riichiro Saito
Copyright © 2023 Jenny Stanford Publishing Pte. Ltd.
ISBN 978‐981‐4968‐37‐9 (Hardcover), 978‐981‐4968‐63‐8 (Paperback), 978‐1‐003‐29096‐4 (eBook)
www.jennystanford.com
2 | Introduction

supercomputer, and (3) it used to take a lot of experience to


operate the program. However, the situation has changed in the
21st century: (1) many computer programs are open to the public
and free of charge on the internet, (2) a desktop computer has
continuously increased its performance, and (3) many users can
share the possible problems for using, improving, and developing
the software. Thus even the experimentalists, who do not have
any experience of running the software, can do the first‐principles
calculation. Conveniently, we can compare the calculated results with
the experimentally observed ones, which we find in the database on
the internet.
Quantum ESPRESSO [Giannozzi et al. (2009)] is a first‐principles
calculation package, which is now used by many people in the
world. We currently teach how to run Quantum ESPRESSO in the
class of solid‐state physics in the university’s graduate school. It is
impressive that any student can download Quantum ESPRESSO and
run the program on their note PC. It means that the first‐principles
calculation is no more a special program that only an expert of
computational physics can use. Quantum ESPRESSO is a kind of
tool that anybody can use for understanding materials and physics.
However, it might not be easy for the reader to be accustomed to
Quantum ESPRESSO by oneself even though many documentations
are on the internet.
This book aims to give sufficient information on Quantum
ESPRESSO for the readers to run the sample programs. Furthermore,
since most readers are not always physics students or computer
experts, we will add the minimum concept of solid‐state physics and
computers relevant to the first‐principles calculation.
To use this book, please do as follows: (1) set up computers
and download sample inputs (see Chapter 2), (2) run Quantum
ESPRESSO by using the sample inputs and commands (see Chapter
3), (3) learn density‐functional theory (see Chapter 4), related solid‐
state physics (see Chapter 5), and supporting Linux commands and
Python language (see Chapter 6). After that, you can run Quantum
ESPRESSO to obtain the properties of your materials.
Quantum ESPRESSO Course for Solid‐State Physics |3
1.2 What do we need to run a program?

What we need to run Quantum ESPRESSO is (1) a personal computer


(PC) connected to the internet and (2) this book. We do not ask for
any additional cost to run the program.
Downloading the operating system called Linux, the package of
Quantum ESPRESSO, and the input files, you can quickly practice
some calculations of energy bands for graphene or monolayer
molybdenum disulfide (MoS2 ) and their physical properties. For
other known materials that you want to run the program, you can
find the input files of any existing materials on the internet with
Automatic FLOW for Materials Discovery (http://www.aflowlib.
org) or Materials Project (https://materialsproject.org).
The most crucial points that you need are your curiosity and
motivation to run Quantum ESPRESSO. Although the book contains
minimum information, it would be nice to learn Quantum ESPRESSO
with some friends. This way may reduce the height of possible
barriers of computer and physics and keep your motivation.

1.3 What we get, and what we do not get?

You will be surprised if you know what we can get from Quantum
ESPRESSO. The following concepts are what we get from Quantum
ESPRESSO: (1) lattice structure of solid and X‐ray diffraction spectra,
(2) electronic band structure and density of states, (3) phonon
dispersion, (4) optical absorption spectra, (5) Raman spectra,
(6) electronic transport properties such as carrier mobility, and
(7) thermal properties such as thermal expansion and thermal
conductivity. These concepts are subjects of solid‐state physics that
you do not need to know now. For the readers who are not familiar
with physics, we will give minimum information about solid‐state
physics by using some equations to understand the special words.
Although solid‐state physics contents are minimal, you can use this
book as the first step of understanding solid‐state physics. It is highly
desired for you to read some solid‐state physics textbooks, too.
It is important to note that running Quantum ESPRESSO does
NOT mean that (1) we can explain the phenomena of solid‐state
4 | Introduction

physics, (2) we can write a scientific paper by showing only the


calculated results of Quantum ESPRESSO, (3) all calculated results
are correct without knowing the detail of the method, and (4) we can
find new physics from the calculated results. They are all possible
misunderstandings of usage of the first‐principles calculation. The
situation is the same: we cannot be an expert on the computer
even though we buy an expensive computer. Nevertheless, if you can
use Quantum ESPRESSO, you will have a powerful tool for applying
the physical concepts to real materials. If you are an experimental
researcher of physics, you will be a strong researcher that can run
Quantum ESPRESSO as the third tool for understanding the observed
properties.

1.4 Organization of the book

In Chapter 2, we explain how to install a software on your PC,


including the operating system (Linux) and Quantum ESPRESSO
in Linux. In Chapter 3, we explain how to run a program for
each purpose of calculating materials’ properties. In Chapter 4, we
briefly explain the density‐functional theory and some keywords to
understand the description in the input files of Quantum ESPRESSO
in Chapter 3. In Chapter 5, we explain the solid‐state physics related
to the calculated results of Quantum ESPRESSO. Finally, in Chapter 6,
we briefly introduce Linux commands and Python language, which
are used in Chapter 3.

Please enjoy running Quantum ESPRESSO!


Chapter 2

Software Installation

This chapter will guide the readers to install all necessary software
for running Quantum ESPRESSO. We expect that the readers already
have a computer with an operating system (OS) such as Linux,
Windows, and macOS. Firstly, we will show you the minimum
requirements for each OS to avoid start‐up problems in installing
Quantum ESPRESSO. Next, we will show the main method to install
Quantum ESPRESSO and its supporting software. Finally, we will
show you how to run the simplest running instance of Quantum
ESPRESSO.

2.1 Preparing the operating systems

Installing Quantum ESPRESSO could be challenging for beginners,


but we are confident that by following all the steps given in this
chapter, the readers will have a smooth, working environment of
Quantum ESPRESSO. The main reason for the challenge is that
Quantum ESPRESSO is an open‐source software that consists of
various packages originally targeted for Linux (or Unix‐like OSs),
which might sound unfamiliar for most Windows users in the world.
However, current technology allows us to install Linux (or any other

Quantum ESPRESSO Course for Solid‐State Physics


Nguyen Tuan Hung, Ahmad R. T. Nugraha, and Riichiro Saito
Copyright © 2023 Jenny Stanford Publishing Pte. Ltd.
ISBN 978‐981‐4968‐37‐9 (Hardcover), 978‐981‐4968‐63‐8 (Paperback), 978‐1‐003‐29096‐4 (eBook)
www.jennystanford.com
6 | Software Installation

OS) as a “guest” OS on Windows using either Windows subsystem for


Linux (WSL) or a virtual machine (such as VirtualBox). Therefore, it
is currently possible for Windows users to “run Quantum ESPRESSO
in Windows” by using the WSL or VirtualBox.
Since we realize that the readers of this book use various
operating systems in their daily life, we will show you how to install
Quantum ESPRESSO in Linux, Windows, and macOS. We chose these
OSs simply due to their popularity although we will not explain how
to install the OSs. We assume the readers have such a specific OS and
internet access in their own computers.
It should be noted that the installation guide for Windows
users is mostly arranged in a way to show how we can utilize the
virtualization feature. It means that after installing the “virtual”
Linux on Windows, the remaining Quantum ESPRESSO installation
procedure should be the same as that on Linux. Before proceeding
to the Quantum ESPRESSO installation guide, we recommend you
ensure that your OS is updated to the latest version. We will show
you how to prepare three specific OSs, i.e., Ubuntu Linux, Windows,
and macOS Catalina.

2.1.1 Ubuntu Linux

In Ubuntu, please check that you can open a Terminal window from
the Activities panel. Terminal is a place in the OS where we
can interact with the “shell”. Simply saying, the shell is a program
that takes commands from the keyboard and returns them to the
operating system to perform.
In the old days, the shell was the only user interface available
on a Unix‐like system. Nowadays, we have graphical user interfaces
(GUIs) in addition to the shell, which is a kind of command‐line
interfaces (CLIs). To interact with the shell in the terminal, we can
type a line of “command” or (lines of commands) corresponding to
some computer operations.
The basic structure of Ubuntu Terminal is shown in Fig. 2.1.
We can see there is a prompt showing the login username, machine
hostname, and a current working directory (“∼” sign, indicating the
so‐called “home” directory of the user). The prompt ends with a
dollar ($) sign. The cursor next to the $ sign is the starting point
Quantum ESPRESSO Course for Solid‐State Physics |7

username@hostname cursor waiting for a command

Figure 2.1 Terminal in Ubuntu.

where we can type the actual Linux commands. There are so many
commands for various purposes, but we will only use a few of them to
install software and manage our Quantum ESPRESSO jobs and files.
To update all software in Ubuntu, on the terminal, type the
following commands (next to the $ sign) and press enter after each
line:

$ sudo apt update


$ sudo apt upgrade

You will be asked for “your password” (not root password) when
executing the above commands because the administrator (often
called “root”) privileges are required when installing or updating the
software in Ubuntu. The root privileges are represented by the sudo
command.
The apt command corresponds to the “Advanced Packaging
Tool”, a command‐line tool that helps in handling packages in Ubuntu.
Its main task is to retrieve the information and packages from the
authenticated sources (mostly from the internet) for installation,
upgrade, and removal of packages along with their dependencies.
In the above example, the update and upgrade texts are a set of
commands to ensure your Ubuntu software is all updated.
We also need some development tools and libraries, such as
Git (version control system), GNU Wget (file retrieval software),
GCC/G++(C/C++ compiler), GFortran (Fortran compiler), LAPACK
(linear algebra package), FFTW (Fourier transform library), and
Open MPI (parallel computing implementation). All of them are
8 | Software Installation

necessary to compile Quantum ESPRESSO. On the terminal, execute


the following commands one by one:

$ sudo apt install git wget build -essential


$ sudo apt install g++ gfortran liblapack -dev
$ sudo apt install libfftw3 -dev libopenmpi -dev

If you are prompted by a “Yes/No” question, just type “y” (or “Yes”)
and press enter to agree with the installation.

2.1.2 Windows

For Windows users, the OS should be updated to at least Windows 10


version 1903. If you want a native support for Linux GUI applications,
we recommend to use or update Windows 11 with build number
at least 22000. To perform the update, we should open Windows
Update from the Start menu in Windows, and we will either see
the option for Feature update, or we will have to click Check for
updates (see Fig. 2.2).
If you still do not see the option to update Windows to the latest
version, click Check for updates, reboot your computer, and try
the process again. There is also a possibility that you already have
this update without realizing it. You can find the OS information in
Windows by typing → About your PC in the Windows Start menu.
Under Windows specifications, check which edition and version of
Windows your computer is running. If you see version 1903 or above
(see Fig. 2.3), you can continue to the next step.
Even if Windows Update does not offer the update, we can
download Microsoft’s Update Assistant tool to install it manually.
This tool will give you the update even if Microsoft is not confident
it is ready for your computer yet. With a version of more than 1903,
it is possible for us to install Windows subsystem for Linux (WSL)
with the ability to access Linux files from File Explorer or other file
manager applications. Unlike older ways of accessing virtual Linux
files, this version of Windows offers full read‐write access without
the worry of breaking anything.
Next, we have to check whether or not our computer supports
virtualization. In most computers, the virtualization can be enabled
Quantum ESPRESSO Course for Solid‐State Physics |9

Figure 2.2 Windows Update. You can click Check for updates and
Download and install now to guarantee your Windows is in the latest
version.

Figure 2.3 Windows specifications in About your PC. Make sure that you
are running at least Windows 10 version 1903. Again, for a native support
of Linux graphical applications in WSL, we recommend at least Windows 11
build 22000.

from BIOS, which can be accessed before booting your OS. The key
you should press on the keyboard to access BIOS will depend on
the manufacturer of the computer. You can check from the computer
screen when you turn it on. Assuming the key is F2 (or DEL), below
are the steps to enable the virtualization from the BIOS settings:

• Turn on or restart the computer.


• Press F2 (or DEL) key at startup BIOS Setup.
• Press the right arrow key to System Configuration tab, select
Virtualization Technology or a similar option and then
press the Enter key.
• Select Enabled and press the Enter key.
10 | Software Installation

Figure 2.4 Opening PowerShell as the administrator.

• Press the F10 key and select Yes and press the Enter key to save
changes and Reboot into Windows.

After performing the above steps, we are ready to install Windows


Subsystem for Linux (WSL).
WSL is a Windows feature that enables us to run native Linux
command‐line tools directly on Windows. The merit of using WSL
over other virtual machines is that WSL requires fewer resources
(CPU, memory, and storage). WSL also allows us to run Linux
command‐line tools and applications (apps) alongside Windows
command‐line, desktop, and store apps and access Windows files
from Linux. This technique allows us to use Windows apps and Linux
command‐line tools on the same set of files.
To install WSL and Ubuntu Linux automatically on Windows, first
open PowerShell as an administrator by searching “PowerShell” in
the Windows menu and right‐click PowerShell to get access as an
administrator (see Fig. 2.4). Inside PowerShell, type the following
command and press enter:

wsl --install

Follow the instructions on the screen and restart the computer


when prompted. This reboot is required in order to ensure that WSL
can initiate a trusted execution environment.
Quantum ESPRESSO Course for Solid‐State Physics | 11

Figure 2.5 Launching Ubuntu from the Start menu.

After reboot, WSL should initialize the Ubuntu instance once


before the system can be used properly. If everything goes normally,
Ubuntu initialization should launch automatically when we re‐login
to Windows. If not, we should launch a new instance of Ubuntu by
clicking the “launch” button in the Microsoft Store app for Ubuntu
or launching Ubuntu from the Start menu (Fig. 2.5). Note that if
you cannot perform this kind of WSL installation, please follow
the detailed manual instructions in Microsoft Docs: https://docs.
microsoft.com/en-us/windows/wsl/install-manual
The first time a new Ubuntu instance runs, a console window
will open, and we will be asked to wait for several minutes for the
installation to complete. During this final stage of installation, the
Ubuntu files are extracted and stored on your PC. It may take a
couple of minutes, depending on the performance of your computer’s
storage devices. This initial installation phase is only required when a
Linux distribution in Windows is clean‐installed. All future launches
should take less than a second.
12 | Software Installation

Figure 2.6 First Ubuntu instances through WSL and creation of a user
account.

Once installation is complete, we will be prompted to create a


new user account (and its password), as shown in Fig. 2.6. This user
account is for the normal non‐admin user that will log in as default
when launching Ubuntu. We can choose any username and password.
There is no necessity to match the Windows username.
In our example, we set “quantum” as the username. In Fig. 2.6,
you should notice that the password is not displayed by the system.
Therefore, be careful when typing it for the first time. Next time
we open a new Ubuntu instance, we will not be prompted for the
password. Only when we want to elevate a process using sudo to
access root privilege, we need to enter the user password, so make
sure to choose a password that is difficult to forget as well as difficult
to break.
What you see in Fig. 2.6 is essentially the same shell as in
Fig. 2.1 that shows the Ubuntu terminal. Therefore, hereafter, we
loosely refer to the shell as the Ubuntu terminal. You can open a File
Explorer window directly from the terminal in the current directory,
which is the home (also denoted $HOME) directory of Linux. The
corresponding command is:

$ explorer.exe .

You can work with files normally from here (see Fig. 2.7). Use
drag and drop, copy and paste them, or even open them directly in
Windows applications.
Quantum ESPRESSO Course for Solid‐State Physics | 13

Figure 2.7 WSL $HOME directory opened in Windows.

Besides typing the above command, you can also open the $HOME
directory from Windows Explorer by directing the explorer to the
following address:

\\wsl$\Ubuntu\home\quantum

(Change “quantum” with your username of Ubuntu in WSL.)


As in Ubuntu Linux, we should update all the default software
and install development tools with libraries necessary to compile
Quantum ESPRESSO. We type the following commands one by one
in the Ubuntu terminal on WSL:

$ sudo apt update


$ sudo apt upgrade
$ sudo apt install git wget build -essential
$ sudo apt install g++ gfortran liblapack -dev
$ sudo apt install libfftw3 -dev libopenmpi -dev

Note again, the $ sign should not be typed/copied to the terminal.


You will also be asked for your password when executing the
above commands because administrator privileges are required. The
detailed explanation of the meaning of each line above can be read in
the previous section (Sec. 2.1.1).
By completing all the above steps, we consider that you are
already “having a Linux OS” on Windows. Therefore, the remaining
procedure to install Quantum ESPRESSO and its supporting software
14 | Software Installation

is the same as that in the “real” Linux OS, which will be explained in
Sec. 2.2.

2.1.3 macOS Catalina

macOS is one of Unix‐based OS, so that it already has the terminal


tool. However, some additional packages are needed before we can
install Quantum ESPRESSO. We recommend the Homebrew package
manager to install the missing development tools and libraries.
For the tutorial in this book, we tested the package installations
on macOS Catalina. On the terminal, we first have to execute the
following command to get Homebrew:

$ /bin/bash -c "$(curl -fsSL https :// raw.


githubusercontent .com/Homebrew/install/HEAD/
install.sh)"

The command is quite long, and it may look broken into several lines
in this book or your terminal, but it is still a single line of command.
You should ensure typing the command properly to the terminal as a
unified entity, without pushing “Enter” key.
By having Homebrew in macOS, the prerequisites for the
Quantum ESPRESSO installation can be obtained by another single
line of command:

$ brew install git wget gcc gfortran fftw lapack


openblas open -mpi eigen

Again, no matter how the above (long) command looks broken into
separate lines, it is a single line of command.

2.2 Installation of Quantum ESPRESSO and its


supporting software

With the various OSs that the readers have, we are ready to install
Quantum ESPRESSO using the same approach on the terminal.
Quantum ESPRESSO Course for Solid‐State Physics | 15
We will install Quantum ESPRESSO and an additional Wannier90
package, either in “real” Ubuntu Linux, WSL Ubuntu, or macOS.
For beginner users of Ubuntu Linux and WSL Ubuntu, the
following commands are sufficient to install Quantum ESPRESSO and
Wannier90:

$ sudo apt install quantum -espresso


$ sudo apt install wannier90

The above commands will install slightly earlier versions of Quantum


ESPRESSO and Wannier90 which are already sufficient for running
the tutorials given in Chapter 3. On the other hand, for readers
who want to install the latest version of Quantum ESPRESSO and
Wannier90 from source code, please follow the rest of this section.
We recommend the readers to create a new folder opt in the
$HOME directory. Type this command on the terminal:

$ mkdir opt

Then, go into the opt folder:

$ cd opt

In the opt folder, we can download the latest source files of Quantum
ESPRESSO using the Git utility as follows:

$ git clone https :// github.com/QEF/q-e.git

After the source files are downloaded, we can enter the q-e folder:

$ cd ~/opt/q-e/

In this folder, we execute the configuration command:

$ ./ configure
16 | Software Installation

Quantum ESPRESSO will automatically determine the best setting


for our OS. If no error occurs, we can continue with making the
executable files:

$ make all
$ make w90

The purpose of the first line above is to make executable files for
all standard Quantum ESPRESSO capabilities, such as electronic
structure, phonon dispersion, and optical properties calculations.
The second line is to make the additional Wannier90 package
available in the binary folder. In addition to this compilation process,
our OS must be “taught” how to find the executable files and include
them in its variable path. For this purpose, we can execute two more
commands to update the path:

$ echo 'export PATH=$PATH:$HOME/opt/q-e/bin' >> ~/.


bashrc
$ source ~/. bashrc

The above command lines enable us to access all binary files of


Quantum ESPRESSO without typing the complete path up to its bin
folder.
To check that our Quantum ESPRESSO installation is done
successfully, we can type the following command, which is the most
basic command of Quantum ESPRESSO:

$ pw.x

We will learn how to use this command briefly in Sec. 2.4 and
more extensively in Chapter 3. To exit the Quantum ESPRESSO
environment generated from the above command line, push CTRL+c
keystroke.
We can install some additional software to support our work‐
flow when performing first‐principles calculations with Quantum
ESPRESSO. Executing the following commands line by line on the
terminal will give us all necessary software:
Quantum ESPRESSO Course for Solid‐State Physics | 17

$ sudo apt install xcrysden gnuplot


$ sudo apt install python3 -dev python3 -pip
$ pip3 install numpy scipy sympy
$ pip3 install matplotlib jupyterlab
$ echo 'export PATH =" $HOME /. local/bin:$PATH"' >> ~/.

Some notes:

• XCrysden is useful for visualization of molecule and crystal


structures.
• Gnuplot is a plotting software. We may also use other plotting
software. In the above commands, we include Python numerical
libraries and graphical tools such as Matplotlib and JupyterLab
that will be mainly used in this book.
• GUI support in WSL is required to run XCrysden, Gnuplot, and
Jupyter. Windows 11 with build number at least 22000 already
natively support GUIs. If you have a lower Windows version,
you need to install an additional “X server”, e.g., VcXsrv, X410
App, or Kali App. See the following Microsoft Tech Community
for the X server installation: https://techcommunity.
microsoft.com/t5/windows-dev-appconsult/
running-wsl-gui-apps-on-windows-10/ba-p/1493242
• Depending on the system, it may take around 15‐30 minutes to
complete all the installation in this section.
• We have created a simple Bash script (see Sec. 6.3.2 to learn
more about Bash), which collects all the above commands
to install Quantum ESPRESSO and its supporting software
for Ubuntu Linux and WSL Ubuntu that can be down‐
loaded from https://github.com/nguyen-group/QE-SSP/
blob/master/QEinstall.sh. After downloading the script,
the readers can execute the following command line in the
terminal:

$ bash QEinstall.sh
18 | Software Installation

2.3 VirtualBox approach

If you have already succeeded to obtain a working Quantum


ESPRESSO environment from the previous sections, you do not need
to follow this VirtualBox approach. VirtualBox is one of the virtual
machines that can be used to run other guest OSs from a specific OS.
In Windows, for example, we can install VirtualBox to run a Linux
distribution that has already been configured to include Quantum
ESPRESSO and other necessary software inside it. There are three
recommended virtual machines for Quantum ESPRESSO:

1. Quantum Mobile:
https://quantum-mobile.readthedocs.io
2. MateriApps LIVE!:
https://cmsi.github.io/MateriAppsLive/
3. QE‐2021: http://qe2021.ijs.si

Each virtual machine has its username and password, which may
change over time. Therefore, it is better to check the documentation
on one of the websites above, depending on which virtual machine
you like. However, all of them use the same capability of VirtualBox to
host a virtual machine. Here we just explain how to install Virtual Box
and add the virtual machine. The steps to install and use the virtual
machine is as follows:

1. Download VirtualBox from: https://www.virtualbox.org/


wiki/Downloads. Choose the Windows host (or macOS if the
macOS users decide to use VirtualBox, too). Then, install and
open VirtualBox.
2. Download the extension pack from the same webpage and
install it while opening VirtualBox.
3. Download a virtual machine, either Quantum Mobile, Materi‐
Apps LIVE!, or QE‐2021 from their websites listed previously.
It is huge, around 3–4 GB, so if your internet connection is slow,
better download the file when you are going to sleep.
4. From the VirtualBox software, press Machine and then Add.
Select one of the virtual machines you have downloaded.
Quantum ESPRESSO Course for Solid‐State Physics | 19

Figure 2.8 Adding a virtual machine in VirtualBox. Click the Add button,
either from the Machine menu or from the toolbar.

Figure 2.9 Starting the virtual machine.

Figure 2.10 Example desktop appearance of a virtual machine.

5. The virtual machine will be ready in a few minutes after


extracting. Select the virtual machine from the left panel and
press the “Start” button as shown in Fig. 2.9.
6. After starting up, we can see the desktop of the virtual machine
as shown in Fig. 2.10.
20 | Software Installation

Command
Text file Text file

input.in pw.x output.out

Text editor Text editor


pw.x < input.in > output.out

Text & data files Data file


Command
Energy tmp folder
pw.x,
dispersion,
bands.x,
charge density, Text file
etc. etc.
new input.in
pw.x < input.in > output.out
Plotting software
bands.x < bands.in > bands.out

Figure 2.11 A typical Quantum ESPRESSO workflow.

2.4 Processing input and output files

With the Quantum ESPRESSO installed on our computer, we


are now able to execute the simplest running instance of Quantum
ESPRESSO, as shown in the diagram of a typical workflow of
Quantum ESPRESSO in Fig. 2.11.

2.4.1 Basic execution of Quantum ESPRESSO commands

There are two main calculations in Quantum ESPRESSO. The first


one is the self‐consistent‐field (SCF) calculation using the pw.x
command. We will learn the details of the SCF calculation in Chapter
3, but we will need to prepare an input file that will be “read” by
this command (for example: input.in), and then the calculation logs
will be written into an output file (for example: output.out). The
input file has some specifications for variables and parameters of
the material simulation that should be prepared in advance using
a text editor. We do not restrict the text editor that we use to edit
the input file or check the output contents. Any text editor should be
fine, for example, Notepad (or Notepad++) in Windows and nano, vi,
or emacs in Linux. Suppose we already have the input.in file, the
execution of the pw.x command is as follows:
Quantum ESPRESSO Course for Solid‐State Physics | 21

$ pw.x < input.in > output.out

After the mandatory SCF calculation, the second calculation


of a typical Quantum ESPRESSO simulation is the “real” stage
for calculating the physical properties of the material under
consideration. For example, in Fig. 2.11 we show another possibility
of running pw.x, which is for the non‐SCF (NSCF) calculation that
includes the band structure and density of states (DOS). There will
already be some data files produced from the NSCF calculations, but
in most cases, we need to do “post‐processing” before plotting and
interpreting the data. Examples of the post‐processing commands
in Quantum ESPRESSO are bands.x, dos.x, epsilon.x, as shown in
Table 2.1, which all will be learned in more detail in Chapter 3. The
basic structure of the command execution is the same as the pw.x
command, i.e.,

$ QEcommand < input.in > output.out

where QEcommand is any Quantum ESPRESSO command. For exam‐


ple, we may run the following in the case of bands.x command:

$ bands.x < band.in > band.out

We list some frequently‐used Quantum ESPRESSO commands


in Table 2.1. Note that besides the logs in the output.out file, the
Quantum ESPRESSO commands also give other output (or data)
files in a specified directory depending on the calculation type. The
extension of the files is specified by the input file.

2.4.2 Choice of plotting software

In most cases, only after performing the post‐processing commands


we can obtain some meaningful data files related to the properties
of the material and make some plots using our favorite plotting
software. Although there are plenty of such softwares in the market,
we decide to specifically suggest the readers of this book to
22 | Software Installation

Table 2.1 Some frequently‐used Quantum ESPRESSO commands.

Command Purpose
pw.x SCF and NSCF calculations
.................................................................................................................................................................

bands.x band structure post‐processing


.................................................................................................................................................................

dos.x DOS postprocessing


.................................................................................................................................................................

epsilon.x optical properties calculation


.................................................................................................................................................................

ph.x phonon calculation

use Matplotlib libraries from the Python programming language.


Therefore, for plotting the Quantum ESPRESSO calculation data,
we will give the hands‐on plotting examples either in .py or
.ipynb extension, which is particularly comfortable to be edited and
interacted with using the JupyterLab interface (https://jupyter.
org/). The installation of Python, Matplotlib, JupyterLab, along with
other important Python libraries, is already explained in Sec. 2.2. To
open JupyterLab, we can type the following command in the terminal

$ jupyter -lab

which results in opening a web browser (e.g., Chrome/Firefox/Sa‐


fari) with some menus shown in Fig. 2.12.
Following Fig. 2.12, there are three most important parts of
JupyterLab we should understand:

(1) The address of JupyterLab instance: This address is shown in


the web browser address locator. It will almost certainly start
with localhost, followed by 4‐digit number of the port used
by JupyterLab. You need not worry about the number because
JupyterLab will automatically determine it.
(2) List of files and folders at which we open JupyterLab: You will
be able to see the files/folders in that panel if the working
directory where we execute the jupyter lab command
already consists of some files/folders. We can also browse
through the files/folders by clicking the filename/folder name
there.
Quantum ESPRESSO Course for Solid‐State Physics | 23

Figure 2.12 Jupyter lab interface.

(3) Jupyter Notebook: We should click the icon in order to open


a Python 3 developing environment in the form of Jupyter
Notebook. Then, we can save the file with the .ipynb or .py
extension for the plotting purpose.

Note that some traditional Python users may prefer to directly access
the Jupyter notebook from the command line by typing:

$ jupyter -notebook

2.4.3 Obtaining example files for hands‐on tutorials

We provide example input/output files of Quantum ESPRESSO


calculations, additional tips, and also errata of the book in the
following public repository: https://github.com/nguyen-group/
QE-SSP. The readers can use the input files from the repository
to practice the Quantum ESPRESSO calculations directly on their
computers. A step‐by‐step guide to run these files is given in
24 | Software Installation

Chapter 3. To download the files from the terminal, we can use the
one‐line git clone utility:

$ git clone https :// github.com/nguyen -group/QE -SSP.


git

With all the information in this chapter, we are now ready to


dive into hands‐on calculations of Quantum ESPRESSO. It would be
nice to read the remaining chapters and practice all the calculations
accompanied by a cup of ESPRESSO coffee.
Chapter 3

Hands‐On Tutorials of Quantum


ESPRESSO

In this chapter, we show how to run Quantum ESPRESSO. We focus


on several topics for obtaining the electronic, optical, transport,
and mechanical properties of materials. Each section starts with
an explanation of the background and purpose. Then, we show the
command to run Quantum ESPRESSO by showing examples of input
and output files. Before practicing with these tutorials, please ensure
that Quantum ESPRESSO and all the necessary software packages
have been installed on your computer (see Chapter 2 for installation).
In Chapter 3, we only show how to run Quantum ESPRESSO. In order
to understand how Quantum ESPRESSO works, the basic concepts
of the density‐functional theory are explained in Chapter 4. The
concepts of solid‐state physics behind these hands‐on tutorials are
briefly summarized in Chapter 5. Calculation job and plotting scripts
are written in Bash and Python, which are explained in Chapter 6. We
recommend using XCrySDen and VESTA for the visualization of input
and output files.
We adopt two‐dimensional graphene as an example of a material
for these tutorials. Since graphene consists of two carbon atoms in
a hexagonal unit‐cell, we can quickly run Quantum ESPRESSO for

Quantum ESPRESSO Course for Solid‐State Physics


Nguyen Tuan Hung, Ahmad R. T. Nugraha, and Riichiro Saito
Copyright © 2023 Jenny Stanford Publishing Pte. Ltd.
ISBN 978‐981‐4968‐37‐9 (Hardcover), 978‐981‐4968‐63‐8 (Paperback), 978‐1‐003‐29096‐4 (eBook)
www.jennystanford.com
26 | Hands‐On Tutorials of Quantum ESPRESSO

graphene. The calculation takes only a few minutes on desktop or


notebook computers. Other materials such as MoS2 and GeTe also
appear in GitHub (https://github.com/nguyen-group/QE-SSP).
It is noted that the format of the input files might be modified from
version to version of Quantum ESPRESSO. In this book, we stick to
the format of Quantum ESPRESSO version 7.0. However, alternative
code lines will be provided in the input files whenever it is necessary
to provide backward compatibility. The source files and scripts from
this chapter are also available online in GitHub (https://github.
com/nguyen-group/QE-SSP). The readers can download the whole
repository, view them in a terminal, or read them at GitHub, where
they are automatically rendered.

3.1 Basic parameters

When starting a new job of simulations with Quantum ESPRESSO,


we first need to determine the parameters in the input file for each
step of the calculation. In this section, we use graphene as an example
material.

3.1.1 Total energy and self‐consistent field calculations

 Purpose: By calculating the total energy with the self‐consistent


field (SCF) method, we get the ground‐state properties, which will
be used for electron and phonon dispersion calculations in Secs. 3.2
and 3.3, respectively.
 Background: The total energy and the SCF calculation are two
concepts that we should know for this tutorial. Both concepts are
given in Secs. 4.5 and 4.12.
 How to run: To run the SCF for the input file, the readers should
type the following command lines:1

1 $ cd ~/QE -SSP/gr/scf/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &

1 If you do not find ‘mpirun’ command, you need to install libopenmpi‐dev (see

Chapter 2).
Quantum ESPRESSO Course for Solid‐State Physics | 27
‐ Line 1: Go to the scf directory that includes the input files.
‐ Line 2: Run pw.x (pw = plane‐wave, x = executable file) by using in
parallel with 4 processors (-np 4) by the command mpirun (running
a program with parallel processors) with the input file is scf.in and
the output file is scf.out. The symbol & makes the command run in
the background. Here, we select 4 processes for parallel calculations,
but the readers can run with serial calculations (without mpirun, that
is pw.x < scf.in > scf.out &) or any number of processes (e.g.,
-np 8 for Intel Core i7 or Core i9), depending on your computer. For
detailed commands for running in parallel, the readers can find on
Sec. 6.2.3.
 How to check: To check whether or not the output file exists, the
readers can use the ls command by typing:

$ ls

It will display a listing of all files in the scf directory as

scf.in scf.out

If the readers see the scf.out, the readers can check the contents of
scf.out by tail command as follows:

$ tail scf.out

The tail command prints the last few lines of the scf.out file. If the
calculation normally finishes, a message JOB DONE is written at the
end of this file as

=------------------------------------------------------=
JOB DONE.
=------------------------------------------------------=

 Input file: Now, let us explain the details of the input file. To see
the input file, the readers can use vi editor by typing:

$ vi scf.in
28 | Hands‐On Tutorials of Quantum ESPRESSO

To quit the vi editor without saving any changes, the readers must
press : (colon). Then the cursor should reappear in the lower‐left
corner of the screen beside a colon prompt. After that, the readers
need to enter q! to quit the file without saving. Since vi editor
is usually available in all Linux distributions, we would like to use
vi. However, the readers can use any text editor, such as Emacs or
Notepad, to open scf.in directly. When the readers open scf.in file,
the readers will see the input variables as

QE‑SSP/gr/scf/scf.in

1 & CONTROL
2 calculation = 'scf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'gr '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 2.4623
10 c = 10.0
11 nat = 2
12 ntyp = 1
13 occupations = 'smearing '
14 smearing = 'mv '
15 degauss = 0.02
16 ecutwfc = 60
17 /
18 & ELECTRONS
19 mixing_beta = 0.7
20 conv_thr = 1.0D-6
21 /
22 ATOMIC_SPECIES
23 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
24 ATOMIC_POSITIONS (crystal)
25 C 0.333333333 0.666666666 0.500000000
26 C 0.666666666 0.333333333 0.500000000
27 K_POINTS (automatic)
28 12 12 1 0 0 0

 Explanation of scf.in: There are three mandatory namelists


(CONTROL, SYSTEM, and ELECTRONS), which start by &, and three
mandatory input cards (ATOMIC_SPECIES, ATOMIC_POSITIONS, and
K_POINTS in lines 22, 24, and 27, respectively). The SCF calculation
is performed by selecting calculation = 'scf' in the namelist
Quantum ESPRESSO Course for Solid‐State Physics | 29
Table 3.1 Meaning of input variables in scf.in file.

Line Syntax Meaning


A mandatory namelist includes input
variables that control the flux of the
1 &CONTROL calculation and the amount of I/O on disk
and on the screen.
....................................................................................................................................................................

A string describing the task to be calculated,


2 calculation in which 'scf' is the SCF calculation.
....................................................................................................................................................................

3 pseudo_dir Directory containing pseudopotential files.


....................................................................................................................................................................

4 outdir Temporary folder to save output data.


....................................................................................................................................................................

5 prefix Filenames of output data in tmp folder.


....................................................................................................................................................................

6 / End of namelist CONTROL.


....................................................................................................................................................................

A mandatory namelist includes input


7 &SYSTEM variables that specify the system for the
calculation.
....................................................................................................................................................................

8 ibrav Bravais lattice index (see Table 3.2).


....................................................................................................................................................................

9, 10 a, c Lattice constants in Angstrom unit.


....................................................................................................................................................................

11 nat Number of atoms per unit cell.


....................................................................................................................................................................

12 ntyp Number of types of atoms in unit cell.


....................................................................................................................................................................

13 ecutwfc Cut‐off energy (Ry) for pseudopotentials.


....................................................................................................................................................................

14 occupations Gaussian smearing for the case of metal.


....................................................................................................................................................................

Smearing method, in which 'mv' is the


15 smearing Marzari‐Vanderbilt‐DeVita‐Payne cold
smearing.
....................................................................................................................................................................

Value of the gaussian spreading (Ry) for


16 degauss Brillouin‐zone integration in metal.
....................................................................................................................................................................

17 / End of namelist SYSTEM.


....................................................................................................................................................................

A mandatory namelist includes input


18 &ELECTRONS variables that control the algorithms used to
reach the SCF solution for the electrons.
....................................................................................................................................................................

19 mixing_beta Mixing factor for self‐consistency.


....................................................................................................................................................................

20 conv_thr Convergence threshold for self‐consistency.


....................................................................................................................................................................

21 / End of namelist ELECTRONS.

Continued
30 | Hands‐On Tutorials of Quantum ESPRESSO

Table 3.1 – Continued

Line Syntax Meaning


A mandatory input card includes name, mass
22, 23 ATOMIC_SPECIES and pseudopotential used for each atomic
species present in the system.
.......................................................................................................................................................................

A mandatory input card includes type and


coordinates of each atom in the unit cell. The
24–26 ATOMIC_POSITIONS option 'crystal' indicates that atomic
positions are in crystal coordinates.
.......................................................................................................................................................................

A mandatory input card includes


27, 28 K_POINTS information of the k‐points used for
Brillouin‐zone integration.

CONTROL in the input file. In the namelist ELECTRONS, we need


to set several variables that can be specified to control the SCF
calculation. A short description of the input variables is given in
Table 3.1. If the readers want to know the original information of
input variables, the readers can visit the following web page: https:
//www.quantum-espresso.org/Doc/INPUT_PW.html.
 Visualizing structure from scf.in: To ensure that structure of
the material is correctly represented by the input file, it is crucial to
visualize the structure by reading the input file in XCrySDen software.
XCrySDen is one of the visualization tools that we can use to check the
structure directly. To run XCrySDen, we enter the command:

$ xcrysden &

One the window of XCrySDen is opened as shown in Fig. 3.1, we


select tabs: File → Open PWscf → Open PWscf Input File and
select scf.in. In the box [PWSCF Input: “scf.in”], we click on the
OK button, XCrySDen will automatically identify the structure of
graphene from the input file (see Fig. 3.1).
The structure of graphene in Fig. 3.1 includes two concepts:
“bravais lattice” and “atomic basis”. A bravais lattice is specified by
an integer number ibrav and six lattice constants a, b, c, cosAB,
cosAC, and cosBC in the namelist SYSTEM. Here, cosAB = cosine of
the angles between a and b (γ), cosAC = cosine of the angles between
Quantum ESPRESSO Course for Solid‐State Physics | 31

Hexagonal lattice (ibrav = 4)

Atomic positions
c = 10.0 Å

C (1/3, 2/3, 1/2)


C (2/3, 1/3, 1/2)

a a = 2.4623 Å

Figure 3.1 Visualizing structure of material from Quantum ESPRESSO input


file by using XCrySDen.

a and c (β), and cosBC = cosine of the angles between b and c


(α). The list of the bravais lattice indexes in Quantum ESPRESSO
is shown in Table 3.2. Since graphene has a hexagonal lattice, we
select ibrav = 4 (hexagonal lattice) and the lattice constants a =
b = 2.4623 Å and c = 10 Å as shown in Fig. 3.1. To confirm that our
unit cell is hexagonal or not, let us increase the number of unit cells in
XCrySDen. From XCrySDen in Fig. 3.1, we select Modify → Number
of Unit Drawn. In the box [Modify Number of Unit Drawn], we
choose 3, 3, and 2 in the x, y, and z directions, respectively. Then
we can see a 3 × 3 × 2 supercell, as shown in Fig. 3.2. Since the
periodic boundary conditions are always applied for any directions
in Quantum ESPRESSO, for the “two‐dimensional graphene”, we set
c = 10.0 Å as a sufficiently large value compared with distance
of two graphene layers in graphite (3.35 Å) to avoid undesirable
interactions in the z‐direction. Nevertheless, too large c requires
computational power.
32 | Hands‐On Tutorials of Quantum ESPRESSO

Figure 3.2 Visualizing a supercell 3 × 3 × 2 of graphene by using XCrySDen.


We can see hexagonal lattice.

 Note: For the lattice constants, we can specify either [a,


b, c, cosAB, cosAC, and cosBC] OR [celldm(1)‐ celldm(6)]
but NOT both, in which celldm(1) = a (in a.u.), celldm(2) =
b/a (in a.u.), celldm(3) = c/a (in a.u.), celldm(4) = cosAB,
celldm(5) = cosAC, and celldm(6) = cosBC.
Since the bravais lattice is set, we now check the atomic
basis. The atomic basis consists of the number, type, and positions
of atoms in the unit cell, in which the number and type of
atoms are specified by the integer numbers nat and ntyp in
the namelist SYSTEM, respectively, while the positions of atoms
are specified in the card ATOMIC_POSITIONS in the crystal coor‐
dinates (crystal), i.e., the values of the positions are between
0.0 and 1.0 for each direction. For graphene, there are two C
atoms in the unit cell. Thus, we set nat = 2, ntyp = 1, and the
atomic positions are (0.333333333 0.666666666 0.500000000)
Quantum ESPRESSO Course for Solid‐State Physics | 33
Table 3.2 Bravais lattice table in Quantum ESPRESSO.

ibrav Structure Lattice vectors


Lattice vectors are given in card
0 Free
CELL_PARAMETERS
....................................................................................................................................................................

1 Cubic P v1 = a(1, 0, 0), v2 = a(0, 1, 0), v3 = a(0, 0, 1)


....................................................................................................................................................................

v1 = 2a (−1, 0, 1), v2 = 2a (0, 1, 1),


2 Cubic F
v3 = 2a (−1, 1, 0)
....................................................................................................................................................................

v1 = 2a (1, 1, 1), v2 = 2a (−1, 1, 1),


3 Cubic I
v3 = 2a (−1, −1, 1)
....................................................................................................................................................................

v1 = 2a (−1, 1, 1), v2 = 2a (1, −1, 1),


Cubic I
−3 v3 = 2a (1, 1, −1)
....................................................................................................................................................................

Hexagonal and v1 = a(1, 0, 0), v2 = a(− 12 , 3


, 0),

4 2
Trigonal P v3 = a(0, 0, ac )
....................................................................................................................................................................

v1 = a(x, −y, z), v2 = a(0, 2y, z),


Trigonal R, v3 = a(−x, −y, z), where x = 1−c ,

5
3‐fold axis c
2

y = 1−c , z = 1+2c , c = cos γ


√ √
6 3
....................................................................................................................................................................

Trigonal R, v1 = √a (u, v, v),


3
v2 = √a (u, v, v),
3
3‐fold axis v3 = √a (v, v, u), where u = z − 2 2y and

−5 3√
⟨111⟩ v=z+ (2)y with y, z as for case ibrav = 5
....................................................................................................................................................................

6 Tetragonal P v1 = a(1, 0, 0), v2 = a(0, 1, 0), v3 = a(0, 0, ac )


....................................................................................................................................................................

v1 = 2a (1, −1, ac ), v2 = 2a (1, 1, ac ),


7 Tetragonal I
v3 = 2a (−1, −1, ac )
....................................................................................................................................................................

Orthorhombic v1 = (a, 0, 0), v2 = (0, b, 0), v3 = (0, 0, c)


8
P
....................................................................................................................................................................

9 Orthorhombic v1 = ( 2a , 2b , 0), v2 = (− 2a , 2b , 0), v3 = (0, 0, c)


....................................................................................................................................................................

−9 Orthorhombic v1 = ( 2a , − 2b , 0), v2 = ( 2a , 2b , 0), v3 = (0, 0, c)


....................................................................................................................................................................

91 Orthorhombic v1 = (a, 0, 0), v2 = (0, 2b , − 2c ), v3 = (0, 2b , 2c )


....................................................................................................................................................................

10 Orthorhombic v1 = ( 2a , 0, 2c ), v2 = ( 2a , 2b , 0), v3 = (0, 2b , 2c )


....................................................................................................................................................................

v1 = ( 2a , 2b , 2c ), v2 = (− 2a , 2b , 2c ),
11 Orthorhombic
v3 = (− 2a , − 2b , 2c )
....................................................................................................................................................................

Monoclinic P v1 = (a, 0, 0), v2 = (b cos γ, b sin γ, 0), v3 =


12
(unique axis c) (0, 0, c)

Continued
34 | Hands‐On Tutorials of Quantum ESPRESSO

Table 3.2 – Continued

ibrav Structure Lattice vectors


Monoclinic P
v1 = (a, 0, 0), v2 = (0, b, 0),
(unique axis
−12 v3 = (c cos β, 0, c sin β)
b)
....................................................................................................................................................................

Monoclinic
v1 = ( 2a , 0, − 2c ), v2 = (b cos γ, b sin γ, 0),
13 base‐centered
v3 = ( 2a , 0, 2c )
(unique axis c)
....................................................................................................................................................................

Monoclinic
base‐centered v1 = ( 2a , 2b , 0), v2 = (− 2a , 2b , 0, 0),
(unique axis v 3 = (c cos β, 0, c sin β)
−13
b)
....................................................................................................................................................................

v1 = (a, 0, 0), v2 = (b cos γ, b sin γ, 0),


14 Triclinic v3 = (c cos β, c cos α−cos sin γ
β cos γ
,
c

1+2 cos α cos β cos γ−cos2 α−cos2 β−cos2 γ
sin γ
)
Note: α, β, and γ are angles between axis b and c, a and c, and a and b, respectively.

and (0.666666666 0.333333333 0.500000000) in the crystal co‐


ordinates.
 Note: In the card ATOMIC_POSITIONS, the positions of atoms can
specify in units of the lattice parameter (either a or celldm(1)) with
(alat) option. It is noted that (alat) is default option in the card
ATOMIC_POSITIONS. For the (alat) option, the lines 24–26 in the
scf.in file will be changed as follows:

ATOMIC_POSITIONS (alat)
C 0.0000000 0.5773503 2.0306218
C 0.5000000 0.2886751 2.0306218

 Output file: Now let us see the output file by command:


vi scf.out. The total energy, as well as its decomposition into
several terms, is obtained at the end of the scf.out as

QE‑SSP/gr/scf/scf.out

! total energy = -23.90991271 Ry


Harris -Foulkes estimate = -23.90991328 Ry
estimated scf accuracy < 0.00000084 Ry
Quantum ESPRESSO Course for Solid‐State Physics | 35
The total energy is the sum of the following terms:

one -electron contribution = -90.80734321 Ry


hartree contribution = 47.24141117 Ry
xc contribution = -8.30684749 Ry
ewald contribution = 27.96304915 Ry
smearing contrib. (-TS) = -0.00018232 Ry

convergence has been achieved in 13 iterations

If the readers want to see only the total energy from scf.out, the
readers can use the grep command to find the lines containing the
symbol ! from scf.out as follows:

$ grep ! scf.out

The total energy is printed in the terminal as

$ ! total energy = -23.90991271 Ry

 Explanation of scf.out: This output file shows that the total


energy of graphene is −23.90991271 Ry (1 Ry = 13.60569301 eV),
and it is obtained in 13 SCF iterations. The total energy contains
one‐electron, Hartree, xc, ewald, and smearing contributions. These
energy contributions are explained in Sec. 4.12. The smearing con‐
tribution is much small compared with other energy contributions.
The magnitude of the total energy is not physically meaningful for
a given cut‐off energy and k‐points grid, but the convergence of the
total energy with the related parameters is essential to determine the
correct parameters. In the next tutorials, we discuss the total‐energy
value depending on the cut‐off energy (Sec. 3.1.2) and the k‐points
grid (Sec. 3.1.3).

Try It Yourself

1. Make scf.in file for the bulk Si with a face‐centered‐cubic


structure (ibrav = 2) and visualize the Si structure by
using XCrySDen.
2. Make scf.in file and calculate total energy of monolayer
MoS2 .
36 | Hands‐On Tutorials of Quantum ESPRESSO

3.1.2 Plane‐wave cut‐off energy

 Purpose: The controllable parameter to test the convergence is


the cut‐off energy related to how many plane waves are used in the
calculation. The large numbers of plane waves give a better result
through the memory and CPU time increase with increasing the cut‐
off energy. In this tutorial, we show how to select a suitable value of
the cut‐off energy.
 Background: The concept of plane‐wave cut‐off energy is given
in Sec. 5.4. In Quantum ESPRESSO, the electronic wavefunction is
represented by the linear combination of plane waves, where the
maximum value of Gmax is related to the cut‐off energy Ecut‐off =
2m Gmax in Ry (1 Ry = 13.6 eV). We will change the value of the cut‐
h̄2 2

off energy from 20 to 80 Ry to check the convergence of total energy


in this tutorial.
 How to run: To run this tutorial, the readers should enter the
following command lines:

1 $ cd ~/QE -SSP/gr/ecut/
2 $ ./run.sh &

‐ Line 1: Change directory to the ecut that includes the input files.
‐ Line 2: Run a bash script file run.sh, which generates and runs
many jobs with changing the cut‐off energies.
 How to check: To check whether or not the output file exists, the
readers can use the ls command by typing:

$ ls

The ls command displays a listing of the many input and output files
including run.sh in the ecut directory as

calc -ecut.dat ecut .30. in ecut .50. out ecut .75. in


ecut .20. in ecut .30. out ecut .55. in ecut .75. out
ecut .20. out ecut .35. in ecut .55. out ecut .80. in
ecut .22. in ecut .35. out ecut .60. in ecut .80. out
ecut .22. out ecut .40. in ecut .60. out plot -ecut.ipynb
ecut .24. in ecut .40. out ecut .65. in run.sh
ecut .24. out ecut .45. in ecut .65. out
ecut .26. in ecut .45. out ecut .70. in
ecut .26. out ecut .50. in ecut .70. out
Quantum ESPRESSO Course for Solid‐State Physics | 37
 Input file: All input files are generated automatically by a bash
script file run.sh as

QE‑SSP/gr/ecut/run.sh

1 #!/bin/bash
2 # Convergence test of cut -off energy.
3 # Set a variable ecut from 20 to 80 Ry.
4 for ecut in 20 22 24 26 30 35 40 45 50 55 60 65 \
5 70 75 80; do
6 # Make input file for the SCF calculation.
7 # ecutwfc is assigned by variable ecut.
8 cat > ecut.$ecut.in << EOF
9 & CONTROL
10 calculation = 'scf '
11 pseudo_dir = '../ pseudo/'
12 outdir = '../tmp/'
13 prefix = 'gr '
14 /
15 &SYSTEM
16 ibrav = 4
17 a = 2.4623
18 c = 10.0
19 nat = 2
20 ntyp = 1
21 occupations = 'smearing '
22 smearing = 'mv '
23 degauss = 0.02
24 ecutwfc = ${ecut}
25 /
26 & ELECTRONS
27 mixing_beta = 0.7
28 conv_thr = 1.0D-6
29 /
30 ATOMIC_SPECIES
31 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
32 ATOMIC_POSITIONS (crystal)
33 C 0.333333333 0.666666666 0.500000000
34 C 0.666666666 0.333333333 0.500000000
35 K_POINTS (automatic)
36 12 12 1 0 0 0
37 EOF
38 # Run SCF calculation.
39 mpirun -np 4 pw.x <ecut.$ecut.in > ecut.$ecut.out
40 # Write cut -off and total energies in calc -ecut.dat.
41 awk '/!/ {printf "%d %s\n",'$ecut ',$5}' ecut.$ecut.
out >> calc -ecut.dat
42 # End of for loop
43 done
38 | Hands‐On Tutorials of Quantum ESPRESSO

 Explanation of run.sh: The parameter of cut‐off energy is


controlled with the parameter ecutwfc in the namelist SYSTEM,
which is changed from 20 to 80 Ry.
 Output file: The readers can open calc-ecut.dat generated by
another pick‐up‐and‐edit command awk in line 41 to make a plot of
the total energy as a function of the cut‐off energy.

$ vi calc -ecut.dat

QE‑SSP/gr/ecut/calc‑ecut.dat

1 20 -23.58222934
2 22 -23.74580589
3 24 -23.82861718
4 ...
5 70 -23.91018738
6 75 -23.91023390
7 80 -23.91024577

‐ Column 1: Cut‐off energy in units of Ry.


‐ Column 2: Total energy of graphene in units of Ry.

 Plotting data from calc‑ecut.dat: To investigate how the total


energy decreases with increasing the cut‐off energy, we adopt
Matplotlib, a plotting library for the Python programming language.
Note that the readers can use any plotting software such as Gnuplot
or Grace. Here, we would like to recommend the readers to install
Matplotlib because it is synchronized for all examples in this book.
For running Matplotlib, we make a JupyterLab plot-ecut.ipynb as
an input file to automatically generate a plot from the extracted data
in the output file. There is a detailed description of how to run a
JupyterLab in Sec. 6.4. In order to run plot-ecut.ipynb, the readers
can type as follows:

$ jupyter -lab plot -ecut.ipynb

QE‑SSP/gr/ecut/plot‑ecut.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
Quantum ESPRESSO Course for Solid‐State Physics | 39
4 import numpy as np
5
6 # Open and read the file calc -ecut.dat
7 ecut , ener = np.loadtxt('calc -ecut.dat', delimiter='
', unpack=True)
8
9 # Create figure object
10 plt.figure ()
11 # Plot the data , using scatter plot
12 plt.scatter(ecut , ener , s=150)
13 # Plot a dashed line at 80 Ry
14 plt.axhline(ener [14], c='gray ', ls='--')
15 # Add the x and y-axis labels
16 plt.xlabel('Cut -off energy (Ry)')
17 plt.ylabel('Total energy (Ry)')
18 # Set the axis limits
19 plt.xlim (20, 80)
20 plt.ylim ( -23.94 , -23.56)
21 # Save the figure
22 plt.savefig('plot -ecut.pdf')
23 # Show the figure
24 plt.show ()

By running jupyter-lab, we obtain the total‐energy plot for


the plane‐wave cut‐off energy as shown in Fig. 3.3. The total energy
rapidly converges around 30 Ry, and it shows a best‐converged value
at 40 Ry. In principle, the result of the lowest total energy is obtained
for infinity cut‐off energy by a variational principle. However,
the higher the cut‐off energy leads to more time‐consuming the
calculation. Therefore, in practice, 40 Ry is good enough for this
tutorial. The total energy difference
< between 40 Ry and 80 Ry is only
1.15 meV, which is much smaller than kB T = 25 meV (at T = 300 K)
or optical phonon energy (> 100 meV). Since most quantities that can
be computed using Quantum ESPRESSO critically depend on the cut‐
off energy, it is essential to perform this test when running Quantum
ESPRESSO calculations. Note that, sometimes, the pseudopotential
files will suggest cut‐off energy. By referring to this value, we can
select the cut‐off energy. The suggested minimum cut‐off energy
is usually 40–60 Ry for ultrasoft pseudopotentials, while it is 80–
120 Ry for norm‐conserving pseudopotentials. The cut‐off energy
dependence of the type of pseudopotential is explained in Sec. 5.4.
40 | Hands‐On Tutorials of Quantum ESPRESSO

Figure 3.3 Total energy as a function of plane‐wave cut‐off energy. The


dashed line is the total energy at 80 Ry. The cut‐off energy shows a best‐
converged value at 40 Ry.

Try It Yourself

Check convergence value of cut‐off energy for bulk Si and


monolayer MoS2 .

3.1.3 k‐points for Brillouin‐zone integration

 Purpose: Other controllable parameter to test for convergence of


the total energy is k‐points grid. The integration on k in the Brillouin
zone (BZ) is approximated by summation of finite numbers of k‐
points that is called k‐points grid. In this tutorial, we show how to
select the k‐points grid.
 Background: The concept of k‐points in the BZ is given in Sec. 5.5.
In Quantum ESPRESSO, there are six values to determine a k‐points
grid, in which the first three values are set as the number of k‐points
mesh of each axis, and the last three values are a parameter to move
the lattice of each axis. The total number of k‐points is obtained by
multiplying the first three values. For example, k1 , k2 , and k3 are set to
10, 10, and 1, respectively, then the total number of k‐points is 10 ×
10 × 1 = 100. Table 3.3 shows the rule for selecting the k‐points grid
based on the dimensions of the system.
Quantum ESPRESSO Course for Solid‐State Physics | 41
Table 3.3 Selecting rule for k‐points grid based on dimension of system.

System k‑points grid


Three‐dimensional (3D) system k1 × k2 × k3
....................................................................................................................................................................

Two‐dimensional (2D) system in xy‐plane k1 × k2 × 1


....................................................................................................................................................................

One‐dimensional (1D) system along z‐direction 1 × 1 × k3


....................................................................................................................................................................

Zero‐dimensional (0D) system 1×1×1

Table 3.4 Selecting a rule for shifting (0 or 1) based on symmetry of system.

System Shifting
Cubic, tetragonal, orthorhombic, and monoclinic systems 1
....................................................................................................................................................................

Hexagonal and trigonal systems 0


....................................................................................................................................................................

Rhombohedral and triclinic systems 1 or 0

The last three values should be set to either 0 or 1, where 0


indicates the default Gamma (Γ) position and 1 means that the k‐
points grid is moved parallel, as shown in Fig. 3.4. Even though
the k‐points are set with the same density by selecting the shift to
move the k‐point mesh by selecting either 0 or 1, the number of
inequivalent k‐points (red points in Fig. 3.4) can be reduced. The
number of inequivalent k‐points depends on the crystal system of a
cell. In Fig. 3.4 (a) and (b), we show a schematic diagram of the k‐
point sampling in a cubic cell and hexagonal cell, respectively. In the
cubic‐cell case, the shifting decreases the number of inequivalent k‐
points from 6 to 3 in the first BZ (see Fig. 3.4 (a)). However, in the case
of a hexagonal cell, setting the shift breaks the hexagonal symmetry
in the BZ. After the shift = 1 is set, symmetry operation is performed,
and it needs more k‐points than the mesh with the case of shift = 0.
Thus, the number of inequivalent k‐points increases due to the three‐
fold symmetry of the hexagonal cell, as shown in Fig. 3.4 (b). We thus
should carefully select a shifting (0 or 1) depending on the symmetry
of the system to calculate. Table 3.4 shows the selecting rule for shift
based on the symmetry of the system.
Based on Tables 3.3 and 3.4, the k‐points grid for graphene is
selected as “k k 1 0 0 0” with k is an integer from 4 to 14 in this tutorial.
42 | Hands‐On Tutorials of Quantum ESPRESSO

(a) b2 b2

Γ b1 Γ b1

shift = 0 shift = 1
(b) b2 b2 b2

Γ b1 Γ b1 Γ b1

shift = 1 &
shift = 0 shift = 1
symmetrization
Figure 3.4 Schematic diagram of the k‐point sampling in a cubic cell (a) or a
hexagonal cell (b). We also illustrate how to shift the k‐points by specifying
“shift=1” and “symmetrization”. Red points denote the inequivalent k‐points
in the first Brillouin zone.

Next, we will learn how to perform the convergence test for this
k‐points grid.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/k-point/
2 $ ./run.sh &

‐ Line 1: Go to directory k-point that includes input files.


‐ Line 2: Run a bash script file run.sh, which consists of many jobs
with changing the k‐points grid.
 How to check: To check whether or not the output file exists, the
readers can use the ls command by typing:

$ ls

The ls command displays a listing of the many output files in the


k-point directory as
Quantum ESPRESSO Course for Solid‐State Physics | 43

calc -kpoint.dat kpoint .14. in kpoint .7. out


kpoint .10. in kpoint .14. out kpoint .8.in
kpoint .10. out kpoint .4.in kpoint .8. out
kpoint .11. in kpoint .4. out kpoint .9.in
kpoint .11. out kpoint .5.in kpoint .9. out
kpoint .12. in kpoint .5. out plot -kpoint.ipynb
kpoint .12. out kpoint .6.in run.sh
kpoint .13. in kpoint .6. out
kpoint .13. out kpoint .7.in

 Input file: All input files are generated automatically by a bash


script file run.sh as

QE‑SSP/gr/k‑point/run.sh

1 #!/bin/bash
2 # Convergence test of k-points grid.
3 # Set a variable k-point from 4 to 14.
4 for k in 4 5 6 7 8 9 10 11 12 13 14; do
5
6 # Make input file for the SCF calculation.
7 # k-points grid is assigned by variable n.
8 cat > kpoint.$k.in << EOF
9 & CONTROL
10 calculation = 'scf '
11 pseudo_dir = '../ pseudo/'
12 outdir = '../tmp/'
13 prefix = 'gr '
14 /
15 &SYSTEM
16 ibrav = 4
17 a = 2.4623
18 c = 10.0
19 nat = 2
20 ntyp = 1
21 occupations = 'smearing '
22 smearing = 'mv '
23 degauss = 0.02
24 ecutwfc = 40
25 /
26 & ELECTRONS
27 mixing_beta = 0.7
28 conv_thr = 1.0D-6
29 /
30 ATOMIC_SPECIES
31 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
32 ATOMIC_POSITIONS (crystal)
33 C 0.333333333 0.666666666 0.500000000
34 C 0.666666666 0.333333333 0.500000000
44 | Hands‐On Tutorials of Quantum ESPRESSO

35 K_POINTS (automatic)
36 ${k} ${k} 1 0 0 0
37 EOF
38
39 # Run pw.x for SCF calculation.
40 mpirun -np 4 pw.x <kpoint.$k.in >kpoint.$k.out
41 # Write the number of k-points (= k*k*1) and
42 # the total energy in calc -kpoint.dat
43 awk '/!/ {printf "%d %s\n",'$k*$k ',$5}' kpoint.$k.out
>> calc -kpoint.dat
44 # End of for loop.
45 done

 Explanation of run.sh: The k‐points grid is controlled with


the card K_POINTS in line 35, wherein a k‐points grid needs
to be set to determine how much density is necessary for the
BZ integration. By selecting the automatic option in the card
K_POINTS, it allows the k‐points grid through the Monkhorst‐Pack
method [Monkhorst and Pack (1976)].
 Output file: The number of k‐points (= k × k × 1) and the total
energy are written in calc-kpoint.dat. The readers can open the
calc-kpoint.dat file in the terminal by typing:

$ vi calc -kpoint.dat

QE‑SSP/gr/ecut/calc‑kpoint.dat

1 16 -23.91186965
2 25 -23.90766485
3 36 -23.90599780
4 ...
5 144 -23.90913362
6 169 -23.90963897
7 196 -23.90953385

‐ Column 1: The number of k‐points.


‐ Column 2: Total energy of graphene in units of Ry.

 Plotting data from calc‑kpoint.dat: The total energy as


a function of the k‐point is plotted by running JupyterLab
plot-kpoint.ipynb:

$ jupyter -lab plot -kpoint.ipynb


Quantum ESPRESSO Course for Solid‐State Physics | 45

Figure 3.5 Total energy as a function of number of k‐points. It shows


significant oscillations around the converged value. The dashed line is the
total energy at 14 × 14 × 1 = 196 k‐points. A k‐points grid of 10 × 10 ×
1 = 100 shows a good convergence.

QE‑SSP/gr/k‑point/plot‑kpoint.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5
6 # Open and read the file calc -kpoint.dat
7 kp , ener = np.loadtxt('calc -kpoint.dat', delimiter='
', unpack=True)
8
9 # Create figure object
10 plt.figure ()
11 # Plot the data , using black color
12 plt.scatter(kp , ener , s=150)
13 # Plot a dashed line at 14 x14x1
14 plt.axhline(ener [10], c='gray ', ls='--')
15 # Add the x and y-axis labels
16 plt.xlabel('Number of $\bm k$ -points ')
17 plt.ylabel('Total energy (Ry)')
18 # Set the axis limits
19 plt.xlim(0, 200)
20 plt.ylim ( -23.913 , -23.905)
21 # Save the figure
22 plt.savefig('plot -kpoint.pdf')
23 # Show the figure
24 plt.show ()
46 | Hands‐On Tutorials of Quantum ESPRESSO

In Fig. 3.5, we plot the total energy as a function of the


total number of k‐points. Compared with the calculation of the
cut‐off energy convergence, the k‐points convergence does not
occur monotonically, but it may show some oscillations around the
converged value. Since a convergence of 1 meV or less for the entire
system is our goal here, as shown in Sec. 3.1.2, a k‐points grid k × k ×
1 = 10 × 10 × 1 = 100 is a reasonable choice.

Try It Yourself

1. Plot running‐time, which can be found at the end of


scf.out file, as a function of number of k‐points for
graphene.
2. Check convergence value of k‐points grid for bulk Si and
monolayer MoS2 .

3.1.4 Optimizing atomic positions

 Purpose: In this tutorial, we are going to learn how to optimize


atomic positions of the system.
 Background: In Quantum ESPRESSO, the default algorithm
for structural optimization is the BFGS algorithm, which was
proposed by Broyden [Broyden (1970)], Fletcher [Fletcher (1991)],
Goldfarb [Goldfarb (1970)], and Shanno [Shanno (1970)], indepen‐
dently. The BFGS algorithm is one of the most powerful methods
to solve unconstrained optimization problem. Let us consider the
unconstrained optimization problem as

minf(x), x ∈ Rn , (3.1)

where f(x) is a general function that has continuous second


derivatives. The goal of the optimization problem is to find a
stationary point x∗ such that ∇f(x∗ ) = 0. Given a starting point x0
and an initial estimate of H−1
0 ≈ ∇ f(x0 ), the (k + 1)‐th iteration of
2
Quantum ESPRESSO Course for Solid‐State Physics | 47

New atomic positions


Initial atomic positions

SCF calculation

Energy & Forces

NO

BFGS algorithm
Check convergence criteria
YES
Optimal 

atomic positions

Figure 3.6 Flowchart of the optimizing atomic positions in Quantum


ESPRESSO.

the BFGS algorithm is

xk+1 = xk − H−1
k ∇f(xk ),

sk = xk+1 − xk ,
yk = ∇f(xk+1 ) − ∇f(xk ), (3.2)

Hk sk sTk Hk yk yTk
Hk+1 = Hk − , with k = 0, 1, 2, …
sTk Hk sk yTk sk
+

The initial matrix H−1


0 is usually taken to be a positive multiple of the
identity matrix, which means that the initial search direction will be
the steepest descent direction. The advantage of the BFGS algorithm
is that it does not need to compute ∇2 f(xk ) for each iteration, which
can be time‐consuming.
In Fig. 3.6, we show the flowchart of the optimizing atomic
positions in Quantum ESPRESSO. At each step of the BFGS algorithm,
the new positions of the atoms are obtained. Then the total energy
and the forces are calculated by using the SCF method and the
Hellmann‐Feynman theorem, respectively. When the change of the
total energy and all components of all forces are smaller than the
convergence criteria, which are given in the input file, the optimized
atomic positions are obtained. In Fig. 3.6, we show the flowchart of
48 | Hands‐On Tutorials of Quantum ESPRESSO

the optimizing atomic positions in Quantum ESPRESSO. At each step


of the BFGS algorithm, the new positions of the atoms are obtained.
Then the total energy and the forces are calculated by using the SCF
method and the Hellmann‐Feynman theorem, respectively. When the
change of the total energy and all components of all forces are smaller
than the convergence criteria, which are given in the input file, the
optimized atomic positions are obtained.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/relax/
2 $ mpirun -np 4 pw.x <relax.in > relax.out &

‐ Line 1: Go to relax directory that includes input files.


‐ Line 2: Run pw.x by using in parallel with 4 processors (-np 4).
 How to check: The calculation will finish when JOB DONE is
written at the end of the output file relax.out.
 Input file: The input file is showed in terminal by typing:

$ vi relax.in

QE‑SSP/gr/relax/relax.in

1 & CONTROL
2 calculation = 'relax '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'gr '
6 etot_conv_thr = 1.0D-5
7 forc_conv_thr = 1.0D-4
8 /
9 &SYSTEM
10 ibrav = 4
11 a = 2.4623
12 c = 10.0
13 nat = 2
14 ntyp = 1
15 occupations = 'smearing '
16 smearing = 'mv '
17 degauss = 0.02
18 ecutwfc = 60
19 /
Quantum ESPRESSO Course for Solid‐State Physics | 49
20 & ELECTRONS
21 mixing_beta = 0.7
22 conv_thr = 1.0D-9
23 /
24 &IONS
25 ion_dynamics = 'bfgs '
26 /
27 ATOMIC_SPECIES
28 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
29 ATOMIC_POSITIONS (crystal)
30 C 0.333333333 0.666666666 0.500000000 0 0 0
31 C 0.666666666 0.333333333 0.400000000
32 K_POINTS (automatic)
33 12 12 1 0 0 0

 Explanation of relax.in: The calculation of optimizing atomic


position can be performed by selecting calculation = 'relax'
(line 2) in the namelist CONTROL. The convergence criteria for the
change of total energy and the forces are set by etot_conv_thr
and forc_conv_thr (lines 6 and 7) in the namelist CONTROL,
respectively. The BFGS algorithm is set in the namelist IONS as
ion_dynamics = 'bfgs' (line 25). It is noted that the namelist IONS
is the only mandatory addition. There are several variables that can
be specified within this namelist, which control the algorithm used
to find the optimized atomic positions. However, the readers can
leave it empty if the readers are happy with selecting all defaults. The
description of input variables is given in Tables 3.1, and 3.5. Here a.u.
refers to the atomic unit (1 a.u. = 1 Hartree = 27.2 eV).
In order to observe the displacement of the carbon
atoms in a unit cell of graphene, one carbon atom is fixed
at a position (0.333333333 0.666666666 0.500000000) by
adding (0 0 0), and other carbon atom is set at position
(0.666666666 0.333333333 0.400000000). We expect
that this carbon atom will move to the optimal position at
(0.333333333 0.666666666 0.500000000).
 Note: We can select the coordinates that will be fixed or
not in relaxation by adding either 0 or 1, respectively, in the
atomic positions. For example, (0 0 1) means that the x and y
coordinates are fixed, while z coordinate can be changed in structural
optimization. If no option is specified, (1 1 1) is assumed.
50 | Hands‐On Tutorials of Quantum ESPRESSO

Table 3.5 Meaning of input variables in relax.in file.

Line Syntax Meaning


Convergence threshold on total energy (a.u.) for
6 etot_conv_thr atomic minimization between two consecutive
BFGS steps.
....................................................................................................................................................................

Convergence threshold on forces (a.u.) for


atomic minimization: the convergence criterion
7 forc_conv_thr is satisfied when all components of all forces are
smaller than this value.
....................................................................................................................................................................

A namelist must be specified in the case of


24 &IONS structural relaxation or molecular dynamics
calculations.
....................................................................................................................................................................

Specify the type of atomic dynamics, in which


25 ion_dynamics bfgs (default) use BFGS quasi‐newton
algorithm.
....................................................................................................................................................................

26 / End of namelist IONS.

 Output file: The optimized atomic positions are given in the


output file relax.out. The readers can open output file in terminal
by typing:

$ vi relax.out

To search forward for final coordinates, press Esc and then enter
/final, vi editor will search the word 'final' in relax.out.

QE‑SSP/gr/relax/relax.out
Forces acting on atoms (cartesian axes , Ry/au):

atom 1 type 1 force = 0.00000000 0.00000000 -0.00001508


atom 2 type 1 force = 0.00000000 0.00000000 0.00001508

Total force = 0.000015 Total SCF correction = 0.000001

bfgs converged in 8 scf cycles and 7 bfgs steps


(criteria: energy < 1.0E-05 Ry , force < 1.0E-04 Ry/Bohr)

End of BFGS Geometry Optimization

Final energy = -23.9099132232 Ry


Begin final coordinates

ATOMIC_POSITIONS (crystal)
C 0.3333333330 0.6666666660 0.5000000000 0 0 0
C 0.6666666660 0.3333333330 0.4999977356
Quantum ESPRESSO Course for Solid‐State Physics | 51
End final coordinates

Initial ionic positions

Optimized ionic positions

Figure 3.7 Visualizing optimized atomic positions from Quantum ESPRESSO


output file by using XCrySDen. Top figure is the initial atomic positions (1/8
steps) and bottom figure is the optimized atomic positions (8/8 steps).

 Explanation of relax.out: This output file shows


that the BFGS optimization is converged in 7 steps with
the energy difference between two consecutive steps
52 | Hands‐On Tutorials of Quantum ESPRESSO

< 1.0 × 10−5 Ry and the force < 1.0 × 10−4 Ry/Bohr. The
second carbon atoms is moved from the initial position
(0.6666666660 0.3333333330 > 0.4000000000) to the final
position (0.6666666660
>
0.3333333330 0.4999977356).
 Note: The Total force in the output file is the square root
of the sum of all the squared force components rather than the
sum of the magnitudes of the individual forces on the atoms. If the
Total SCF correction is large or comparable to the Total force,
the output file will show a message "SCF correction compared to
forces is large: reduce conv_thr to get better values".
It usually means the readers need to try with a relatively smaller
conv_thr.
 Visualizing optimized ionic positions: The readers can visualize
the optimized ionic positions by using XCrySDen as

$ xcrysden &

Then the readers can go through the following steps: File → Open
PWscf → Open PWscf Output File and select relax.out. In the box
[PWSCF Input: “relax.out”], we click on the OK button, then in the
box [Question], we select Display All Coordinates as Animation
and click on the Continue button. The initial or optimized ionic
positions can be showed by choosing Current slide in the box
[Animation Control Center], as shown in Fig. 3.7.

Try It Yourself

Run optimizing atomic positions for monolayer MoS2 by


changing position of only Mo atom.

3.1.5 Optimizing unit cell

 Purpose: In this tutorial, we show how to optimize the lattice


vectors of the unit cell (or the variable‐cell relaxation).
 Background: Similar to optimization the atomic positions, we can
optimize the unit cell by using the BFGS algorithm.
 How to run: To run this tutorial, the readers should type as

1 1
Quantum ESPRESSO Course for Solid‐State Physics | 53

1 $ cd ~/QE -SSP/gr/vc -relax/


2 $ mpirun -np 4 pw.x <vc -relax.in > vc -relax.out &

‐ Line 1: Go to vc-relax directory that includes input files.


‐ Line 2: Run pw.x by using in parallel calculation.
 How to check: The calculation will finish when JOB DONE is
written at the end of the output file vc-relax.out.
 Input file: The readers can open the input file in terminal by
typing:

$ vi vc -relax.in

QE‑SSP/gr/vc‑relax/vc‑relax.in

1 & CONTROL
2 calculation = 'vc -relax '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'gr '
6 etot_conv_thr = 1.0D-5
7 forc_conv_thr = 1.0D-4
8 /
9 &SYSTEM
10 ibrav = 4
11 a = 2.5
12 c = 15.0
13 nat = 2
14 ntyp = 1
15 occupations = 'smearing '
16 smearing = 'mv '
17 degauss = 0.02
18 ecutwfc = 60
19 /
20 & ELECTRONS
21 mixing_beta = 0.7
22 conv_thr = 1.0D-9
23 /
24 &IONS
25 ion_dynamics = 'bfgs '
26 /
27 &CELL
28 cell_dynamics = 'bfgs '
29 press_conv_thr= 0.05
30 cell_dofree = '2Dxy '
54 | Hands‐On Tutorials of Quantum ESPRESSO

Table 3.6 Meaning of input variables in vc-relax.in file.

Line Syntax Meaning


A namelist must be specified in the case of
27 &CELL calculation = 'vc-relax'.
......................................................................................................................................................................

Specify the type of cell dynamics, in which bfgs


28 cell_dynamics (default) use BFGS quasi‐newton algorithm.
......................................................................................................................................................................

Convergence threshold on the pressure for


29 press_conv_thr variable cell relaxation. Default value is 0.5 Kbar.
......................................................................................................................................................................

Select the cell parameters to change, in which


30 cell_dofree '2Dxy' is only x and y components are allowed
to change.
......................................................................................................................................................................

31 / End of namelist CELL.

31 /
32 ATOMIC_SPECIES
33 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
34 ATOMIC_POSITIONS (crystal)
35 C 0.333333333 0.666666666 0.500000000
36 C 0.666666666 0.333333333 0.500000000
37 K_POINTS (automatic)
38 12 12 1 0 0 0

 Explanation of vc‑relax.in: The calculation of the optimizing unit


cell can be performed by setting calculation = 'vc-relax' (line
2) in the namelist CONTROL. We need to specify both the namelist
IONS, as shown in Sec. 3.1.4, and CELL. Note that the convergence
criterion for optimizing unit cell is based on the pressure, which
is set by press_conv_thr (line 29) in the namelist CELL. For
the two‐dimensional material as graphene, we also need to set
cell_dofree = '2Dxy' (line 30) in the namelist CELL, that means
that only x and y components are optimized. The description of input
variables is given in Tables 3.1, 3.5, and 3.6.
 Output file: Both the optimized ionic positions and the lattice
vectors are given in the output file vc-relax.out. The readers can
open output file in terminal by typing:
Quantum ESPRESSO Course for Solid‐State Physics | 55

$ vi vc -relax.out

To search forward for final coordinates, press Esc and then enter
/final, vi editor will display as

QE‑SSP/gr/vc‑relax/vc‑relax.out
Computing stress (Cartesian axis) and pressure

negative rho (up , down): 1.211E-04 0.000E+00


total stress (Ry/bohr 3) (kbar) P= -0.13
0.00000002 0.00000000 -0.00000000 0.00 0.00 -0.00
0.00000000 0.00000002 -0.00000000 0.00 0.00 -0.00
0.00000000 0.00000000 -0.00000259 0.00 0.00 -0.38

bfgs converged in 5 scf cycles and 4 bfgs steps


(criteria: energy <1.0E-05 Ry , force <1.0E-04Ry/Bohr , cell <5.0E-02 kbar)

End of BFGS Geometry Optimization

Final enthalpy = -23.9099689524 Ry


Begin final coordinates
new unit -cell volume = 532.18989 a.u.^3 ( 78.86240 Ang^3 )
density = 0.50580 g/cm^3

CELL_PARAMETERS (alat= 4.72431533)


0.985562233 -0.000000000 0.000000000
-0.492781117 0.853521931 0.000000000
0.000000000 0.000000000 6.000000000

ATOMIC_POSITIONS (crystal)
C 0.3333333330 0.6666666660 0.5000000000
C 0.6666666660 0.3333333330 0.5000000000
End final coordinates

 Explanation of vc‑relax.out: This output file shows that the


optimized structure (i.e., both ionic positions and lattice constants
are optimized) with the convergence criteria of the energy difference
< 1.0 × 10−5 Ry, the total forces of each atom < 1.0 × 10−4 Ry/Bohr
and the in‐plane pressures of unit cell < 5.0 × 10−2 kbar. Since
we optimize the two‐dimensional structure, the absolute value of
the pressure in the z direction can be larger than the convergence
threshold (5.0 × 10−2 kbar). To reduce the absolute value of the
pressure in the z direction, the lattice constant in the z direction
should be large enough. Here, we choose c = 15.0 Å as shown in the
input file.
The optimized lattice vectors are given in CELL_PARAMETERS
in the block of the final coordinates. Note that the lattice
vectors are given explicitly in Bohr (1 Bohr = 0.529177211 Å)
along with a scaling factor alat = 4.72431533, which is converted
from a = 2.5 Å in the input file. The optimized lattice constant
56 | Hands‐On Tutorials of Quantum ESPRESSO

is a = 2.5×0.985562233 = 2.4639055825 Å, which is consistent


with experimental value (a ∼ 2.46 Å) [Ohta et al. (2006)]. Note
that the c = 15 Å constant does not change because of setting
cell_dofree = '2Dxy'.

Try It Yourself

Run optimizing unit cell for bulk Si and monolayer MoS2 . It is


noted that cell_dofree is set to all for the bulk Si.

3.1.6 Selecting pseudopotential

 Purpose: In this tutorial, we learn how to select the pseudopoten‐


tial in the input file of Quantum ESPRESSO.
 Background: As discussed in Sec. 5.4, the pseudopotential (PP)
is an approximation of atomic potentials to minimize the number
of plane wave basis, and PP contains various information for
simulating a system. The PP in Quantum ESPRESSO uses a unified
PP format (UPF).2 Three types of PPs, including norm‐conserving
(NC) PPs, ultra‐soft (US) PPs, and projector‐augmented wave (PAW),
are supported. Some calculations (e.g., Γ‐point phonon, third‐
order energy derivatives, non‐resonance Raman, anharmonic force
constants) work only with the NC PPs because the NC PPs provide
wavefunctions that we can use in the integration for calculating some
physical properties. Thus, the readers should check what type of PP
is supported and select a proper PP for each atom before calculating.
The main library of the PPs is PSlibrary, which includes the
scalar relativistic and fully relativistic US PPs and PAW data sets for
many elements. The readers can download the PPs from PSlibrary
in this link: http://pseudopotentials.quantum-espresso.org/
legacy_tables/ps-library. In Fig. 3.8, we show the naming
convention for the PP file. A PP file includes not only the type
of pseudopotential (NC, US, or PAW) but also the type of the
exchange‐correlation functional (LDA, GGA, or meta‐GGA). The detail

2 Unified pseudopotential format is the Extensible Markup Language (XML)‐like

structure to store pseudopotentials.


Quantum ESPRESSO Course for Solid‐State Physics | 57
Full-relativistic Nonlinear core- Name and version
(optional) correction (optional) of library (optional)

C.rel-pbe-n-rrkjus_psl.1.0.0.UPF

Exchange-correlation functional types Pseudopotential types


pz Perdew-Zunger (LDA) ae All-Electron (no pseudization)
vwn Vosko-Wilk-Nusair (LDA) mt Martins-Troullier (NC PPs)
Perdew-Burke-Ernzerhof bhs Bachelet-Hamann-Schlueter
pbe
(GGA) (NC PPs)
pbesol Modification of PBE (GGA) vbc Von-Barth-Car (NC PPs)
blyp Becke-Lee-Yang-Parr (GGA) van Vanderbilt (US PPs)
pw91 Perdew-Wang 91 (GGA) rrkj Rappe-Rabe-Kaxiras-
Joannopoulos (NC PPs)
Tao-Perdew-Staroverov-
tpss
Scuseria (meta-GGA) rrkjus Rappe-Rabe-Kaxiras-
Joannopoulos (US PPs)
coulomb Coulomb bare -Z/r potential
kipaw Kresse-Joubert (PAW)
bpaw Bloechl (PAW)

Figure 3.8 Naming convention for the pseudopotential from PSlibrary in


unified pseudopotentials format (UPF).

of the exchange‐correlation functional is given in Sec. 4.7. Besides


PSlibrary, other libraries are also available as
‐ Standard Solid‑State PPs (SSSP): a collection of the best
verified PPs, maintained by THEOS and MARVEL. Available on the
Materials Cloud web site is https://www.materialscloud.org/
discover/sssp/table/efficiency.
‐ Pseudo Dojo: a complete set of PPs and PAW sets. Available on
the web site is http://www.pseudo-dojo.org/index.html.
‐ GBRV high‑throughput PPs: a highly accurate and computation‐
ally inexpensive open‐source US PP library. Available on the web
site is http://www.physics.rutgers.edu/gbrv.
‐ Optimized NC Vanderbilt PP (ONCVPSP): an accurate and
inexpensive NC PPs by D. R. Hamann. Available on the web site
is http://www.quantum-simulation.org/potentials/sg15_
oncv/upf/.
‐ Hartwigesen‑Goedecker‑Hutter PPs: a collection of NC PPs
from CPMD, by Matthias Krack. Available on the web site is
58 | Hands‐On Tutorials of Quantum ESPRESSO

http://pseudopotentials.quantum-espresso.org/legacy_
tables/hartwigesen-goedecker-hutter-pp.
A recommended way of selecting a good PP is based on testing
and comparing the preliminary results to experimental data. Note
that when comparing Quantum ESPRESSO calculation results, you
should not directly compare the energy values by using different PPs.
Since each PP has a different option or condition, using a different
type of PP results in different energy values, which does not have
any meaning. It is recommended to compare the properties such as
lattice constant, energy band gap, etc., with experiments for observed
materials. Since we showed how to obtain the lattice constant of
graphene in Sec. 3.1.5, in this tutorial, we will compare the lattice
constant for several PPs.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/pps/
2 $ ./run.sh &

‐ Line 1: Go to pps directory that includes input files.


‐ Line 2: Run a bash script file run.sh.
 How to check: To check whether or not the output file exists, the
readers can use the ls command by typing:

$ ls

The ls displays a listing of the all files in the pps folder as

run.sh
vc -relax.C.pbe -hgh.UPF.in
vc -relax.C.pbe -hgh.UPF.out
vc -relax.C.pbe -n-kjpaw_psl .1.0.0. UPF.in
vc -relax.C.pbe -n-kjpaw_psl .1.0.0. UPF.out
vc -relax.C.pbe -n-rrkjus_psl .0.1. UPF.in
vc -relax.C.pbe -n-rrkjus_psl .0.1. UPF.out
vc -relax.C.pz -hgh.UPF.in
vc -relax.C.pz -hgh.UPF.out
vc -relax.C.pz -n-kjpaw_psl .0.1. UPF.in
vc -relax.C.pz -n-kjpaw_psl .0.1. UPF.out
vc -relax.C.pz -n-rrkjus_psl .0.1. UPF.in
vc -relax.C.pz -n-rrkjus_psl .0.1. UPF.out
Quantum ESPRESSO Course for Solid‐State Physics | 59
 Input file: All input files are generated automatically by a bash
script file run.sh as

QE‑SSP/gr/pps/run.sh

1 #!/bin/bash
2 # Set a variable pp for 6 PPs.
3 for pp in C.pbe -hgh.UPF \
4 C.pz -hgh.UPF \
5 C.pbe -n-rrkjus_psl .0.1. UPF \
6 C.pz -n-rrkjus_psl .0.1. UPF \
7 C.pbe -n-kjpaw_psl .1.0.0. UPF \
8 C.pz -n-kjpaw_psl .0.1. UPF; do
9 # Make input file for the vc -relax calculation.
10 cat > vc -relax.$pp.in << EOF
11 & CONTROL
12 calculation = 'vc -relax '
13 pseudo_dir = '../ pseudo/'
14 outdir = '../tmp/'
15 prefix = 'gr '
16 etot_conv_thr = 1.0D-5
17 forc_conv_thr = 1.0D-4
18 /
19 &SYSTEM
20 ibrav = 4
21 a = 2.4639055825
22 c = 15.0
23 nat = 2
24 ntyp = 1
25 occupations = 'smearing '
26 smearing = 'mv '
27 degauss = 0.02
28 ecutwfc = 80
29 /
30 & ELECTRONS
31 mixing_beta = 0.7
32 conv_thr = 1.0D-9
33 /
34 &IONS
35 ion_dynamics = 'bfgs '
36 /
37 &CELL
38 cell_dynamics = 'bfgs '
39 press_conv_thr= 0.05
40 cell_dofree = '2Dxy '
41 /
42 ATOMIC_SPECIES
43 C 12.0107 $pp
44 ATOMIC_POSITIONS (crystal)
60 | Hands‐On Tutorials of Quantum ESPRESSO

Table 3.7 Calculated lattice constants (a) by 6 pseudopotentials.

Pseudopotential Type a (Å)


C.pbe-hgh.UPF NC + GGA 2.4529
....................................................................................................................................................................

C.pz-hgh.UPF NC + LDA 2.4321


....................................................................................................................................................................

C.pbe-n-rrkjus_psl.0.1.UPF US + GGA 2.4643


....................................................................................................................................................................

C.pz-n-rrkjus_psl.0.1.UPF US + LDA 2.4456


....................................................................................................................................................................

C.pbe-n-kjpaw_psl.1.0.0.UPF PAW + GGA 2.4673


....................................................................................................................................................................

C.pz-n-kjpaw_psl.0.1.UPF PAW + LDA 2.4456

45 C 0.333333333 0.666666666 0.500000000


46 C 0.666666666 0.333333333 0.500000000
47 K_POINTS (automatic)
48 12 12 1 0 0 0
49 EOF
50 # Run pw.x for vc -relax calculation.
51 mpirun -np 4 pw.x <vc -relax.$pp.in > vc -relax.$pp.out
52 # End of for loop.
53 done

 Explanation of run.sh: Six PP files are adopted in this tutorial.


The folder path containing these PP files is set in syntax pseudo_dir
(line 13) the namelist CONTROL, and the filename of PP is set as $pp
in the namelist ATOMIC_SPECIES (line 43).
 Output file: The optimized lattice constants are obtained from
the output files vc-relax.*.out (see Sec. 3.1.5) and listed in
Table 3.7. Compared with the measured lattice constant of graphene
(∼ 2.46 Å [Ohta et al. (2006)]), the calculated lattice constant of
C.pbe-n-rrkjus_psl.0.1.UPF (US PP + GGA) is in good agree‐
ment. The PP with GGA often overestimates the lattice constants of
solids, while LDA almost always underestimates the lattice constants.
In both cases, the typical errors amount to 1–2% of the lattice
parameters.
Quantum ESPRESSO Course for Solid‐State Physics | 61
Try It Yourself

Calculate lattice constants of bulk Si for several PP files, and


compare the obtained results with the experimental value
(5.431 Å).

3.1.7 Selecting smearing function and energy

 Purpose: Smearing is a concept for suppressing unstable electron


density during the iteration in the calculation of metal. In this tutorial,
we learn how to select the smearing function and energy.
 Background: Let us briefly explain the concept of smearing. In
the DFT, the electron density n(r) is calculated from the Kohn‐Sham
wavefuntion ϕ(r) as

n(r) = fi |ϕi (r)|2 , (3.3)




where the index i runs over all states and fi are the occupation
numbers, which can be either 1 or 0 depending on that the i‐th state
is occupied or not, respectively, as shown in Fig. 3.9 (a). In Quantum
ESPRESSO, the sum of Eq. (3.3) is replaced by an integration over the
Brillouin zone (BZ) of the system as

n(r) = fik |ϕik (r)|2 dk,



(3.4)
i BZ

where k is the wavevector in the BZ. In practice, this integration is


carried out numerically by summing over a finite set of k‐points.
For the semiconductor or insulator, electrons in the valence band
can not occupy the conduction band during the calculation since
the energies of the valence and conduction bands are sufficiently
separated. Therefore, the electron density and derived quantities
(e.g., the total energy) converge quickly with the finite number of k‐
points used in the integration. However, in the case of the metal or
semimetal, the valence bands that cross the Fermi level are partially
occupied. Thus, the electrons may occupy the unoccupied states
during one iteration, making the algorithm unstable. In this case, it
62 | Hands‐On Tutorials of Quantum ESPRESSO

(a) (b)
f fFD Determined by σ

1 1

0 0
EF E EF E

Figure 3.9 (a) The step function f and (b) the smooth Fermi‐Dirac function
fFD are plotted as a function of the energy E. The width of the Fermi‐Dirac
function is determined by σ.

often needs a large number of k‐points in order to make calculations


converge. To stabilize the algorithm and reduce the number of k‐
points, we employ a smearing function, in which fik is replaced by
a function that varies smoothly from 1 to 0 at near the Fermi level.
By smoothly changing fi as a function of energy, we can suppress the
unstable change of electron density for each SCF iteration.
The Fermi‑Dirac smearing: A simple smearing function
is the Fermi‐Dirac‐like distribution function, which is defined
by [Mermin (1965)]

1 Eik − EF
fFD = , with x = , (3.5)
exp(x) + 1 σ

where EF is the Fermi energy, and σ is the smearing energy,


analogous to kB T in the Fermi‐Dirac statistics. Note that when σ → 0,
f approaches the step function. As shown in Fig. 3.9 (b), f is a smooth
function. Thus, Eq. (3.4) does not cause problems during calculation.
However, this approach has a problem. In order to calculate with
a relatively small number of k‐points sampling, we need to use a
very large σ value about 0.1 − 0.5 eV, corresponding to thousands of
degrees of the temperature, and the distribution has long tails. Thus,
we need to calculate a relatively large number of unoccupied states
compared with slowly decay to zero occupation.
The Gaussian smearing: Another smearing function is the
Gaussian smearing, in which the step function is approximated by
the (Gaussian) complementary error function (erfc), which is defined
Quantum ESPRESSO Course for Solid‐State Physics | 63
by [Fu and Ho (1983)]

1
fG = (3.6)
2
erfc(x),

where erfc(x) is defined as erfc(x) = √2π x exp(−t2 )dt. As shown


∞

in Fig. 3.10, the width of the Gaussian smearing is smaller than that
of the Fermi‐Dirac smearing. This means that in order to get similar
k‐points convergence as for the Fermi‐Dirac smearing, the Gaussian
smearing can use a smaller value of σ.
The Methfessel‑Paxton smearing: Methfessel and Paxton
proposed a more sophisticated approximation to the step function
based on the Gaussian smearing [Methfessel and Paxton (1989)].
The first‐order Methfessel‐Paxton approximation is expressed as

1 1
fMP = erfc(x) − √ x exp −x2 , (3.7)
 
2 2 π

where the first term on the right‐hand side corresponds to the


Gaussian smearing, while the second term serves to correct the error
introduced by the Gaussian smearing. Although only fewer k‐points
are needed for the Methfessel‐Paxton smearing, the occupation
numbers become lower than zero, or larger than 1, as shown
in Fig. 3.10. Note that while occupation numbers that are larger
than 1 are less worrisome, negative occupation numbers can be
conceptually problematic in the Methfessel‐Paxton smearing.
The Marzari‑Vanderbilt smearing: The Marzari‐Vanderbilt
approach has been proposed in order to avoid the negative
occupancies introduced by the Methfessel‐Paxton smearing. In this
case, the step function is approximated by a Gaussian function
multiplied by a first‐order polynomial as [Marzari et al. (1999)]

1 2 1
  
fMV exp(−x − 2x − 1/2) + erfc x + √
2
. (3.8)

2 2
=
π

As shown in Fig. 3.10, the Marzari‐Vanderbilt smearing is asymmetric


but does not have negative values and thus the problem with negative
electron density is safety avoided.
64 | Hands‐On Tutorials of Quantum ESPRESSO

Marzari-Vanderbilt

Fermi-Dirac
f (x) Gaussian

Methfessel-Paxton

x
Figure 3.10 The several smearing functions f(x) are plotted as a function of
x = (Eik − EF )/σ.

In this tutorial, we plot the total energy as function of the


smearing energy σ by using the Fermi‐Dirac, Gaussian, Methfessel‐
Paxton, and Marzari‐Vanderbilt smearing functions.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/smearing/
2 $ ./run.sh &

‐ Line 1: Go to smearing directory that includes input files.


‐ Line 2: Run a bash script file run.sh, which consists of many jobs
with changing both the smearing function and smearing energy.
 How to check: To check whether or not the output file exists, the
readers can use the ls command by typing:

$ ls

The ls command displays a listing of the all files in the smearing


folder as

calc -smearing.dat gauss .0.020. in mp .0.035. out


fd .0.005. in gauss .0.020. out mp .0.040. in
fd .0.005. out gauss .0.025. in mp .0.040. out
fd .0.010. in gauss .0.025. out mv .0.005. in
fd .0.010. out gauss .0.030. in mv .0.005. out
fd .0.015. in gauss .0.030. out mv .0.010. in
Quantum ESPRESSO Course for Solid‐State Physics | 65
fd .0.015. out gauss .0.035. in mv .0.010. out
fd .0.020. in gauss .0.035. out mv .0.015. in
fd .0.020. out gauss .0.040. in mv .0.015. out
fd .0.025. in gauss .0.040. out mv .0.020. in
fd .0.025. out mp .0.005. in mv .0.020. out
fd .0.030. in mp .0.005. out mv .0.025. in
fd .0.030. out mp .0.010. in mv .0.025. out
fd .0.035. in mp .0.010. out mv .0.030. in
fd .0.035. out mp .0.015. in mv .0.030. out
fd .0.040. in mp .0.015. out mv .0.035. in
fd .0.040. out mp .0.020. in mv .0.035. out
gauss .0.005. in mp .0.020. out mv .0.040. in
gauss .0.005. out mp .0.025. in mv .0.040. out
gauss .0.010. in mp .0.025. out plot -smearing.ipynb
gauss .0.010. out mp .0.030. in run.sh
gauss .0.015. in mp .0.030. out
gauss .0.015. out mp .0.035. in

 Input file: All input files are generated automatically by a bash


script file run.sh as

QE‑SSP/gr/smearing/run.sh

1 #!/bin/bash
2 # Set a variable sf for the smearing functions.
3 for sf in fd gauss mp mv; do
4
5 # Set a variable se for the smearing energies.
6 for se in 0.005 0.010 0.015 0.020 0.025 0.030 \
7 0.035 0.040; do
8
9 # Make input file for the scf calculation.
10 cat > $sf.$se.in << EOF
11 & CONTROL
12 calculation = 'scf '
13 pseudo_dir = '../ pseudo/'
14 outdir = '../tmp/'
15 prefix = 'gr '
16 /
17 &SYSTEM
18 ibrav = 4
19 a = 2.4639055825
20 c = 15.0
21 nat = 2
22 ntyp = 1
23 occupations = 'smearing '
24 smearing = '$sf '
25 degauss = $se
26 ecutwfc = 40
27 /
28 & ELECTRONS
66 | Hands‐On Tutorials of Quantum ESPRESSO

29 mixing_beta = 0.7
30 conv_thr = 1.0D-6
31 /
32 ATOMIC_SPECIES
33 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
34 ATOMIC_POSITIONS (crystal)
35 C 0.333333333 0.666666666 0.500000000
36 C 0.666666666 0.333333333 0.500000000
37 K_POINTS (automatic)
38 12 12 1 0 0 0
39 EOF
40
41 # Run pw.x for SCF calculation.
42 mpirun -np 4 pw.x <$sf.$se.in > $sf.$se.out
43
44 # Write the name of the smearing functions , the
smearing energies , and total energies
45 awk -v var="$sf" '/!/ {printf "%-6s %1.3f %s\n",var ,'
$se ',$5}' $sf.$se.out >> calc -smearing.dat
46 # End of for sf loop.
47 done
48 # End of for se loop.
49 done

 Explanation of run.sh: The smearing option is set by


occupations = 'smearing' (line 23) in the namelist SYSTEM.
The smearing function and energy σ in Ry are set in the syntaxes
occupations (line 24) and degauss (line 25), respectively.
The Fermi‐Dirac, Gaussian, Methfessel‐Paxton, and Marzari‐
Vanderbilt smearing can selected by setting smearing = 'fd',
smearing = 'gauss', smearing = 'mp', and smearing = 'mv',
respectively.
 Note: For the metal and semimetal materials such as graphene, the
readers should select the smearing option, otherwise the program
might be stopped with the error as

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error in routine electrons (1):
charge is wrong: smearing is needed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Output file: The smearing functions, the smearing energies, and


the total energy are written in calc-smearing.dat. The readers can
open this file in terminal by typing:
Quantum ESPRESSO Course for Solid‐State Physics | 67

$ vi calc -smearing.dat

QE‑SSP/gr/smearing/calc‑smearing.dat

1 fd 0.005 -23.90915383
2 fd 0.010 -23.90934651
3 fd 0.015 -23.90954805
4 ...
5 mv 0.030 -23.90923457
6 mv 0.035 -23.90927836
7 mv 0.040 -23.90931451

‐ Column 1: The abbreviation of the smearing function.


‐ Column 2: The smearing energy in units of Ry.
‐ Column 3: The total energy in units of Ry.
 Plotting data from calc‑smearing.dat: The total energy as a
function of the smearing energy is plotted by running JupyterLab
plot-smearing.ipynb:

$ jupyter -lab plot -smearing.ipynb

QE‑SSP/gr/smearing/plot‑smearing.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4
5 # Open and read the file calc -smearing.dat
6 f = open('calc -smearing.dat', 'r')
7 f_smearing = [line for line in f.readlines () if line
.strip ()]
8 f.close ()
9 nsf = 4 # Number of the smearing functions
10 nse = 8 # Number of the smearing energies
11 # Read the smearing energy (se) and total energy (
ener) for each smearing function
12 se = []
13 ener = []
14 for i in range(nsf):
15 se.append ([])
16 ener.append ([])
17 for j in range(nse):
18 tmp1 = f_smearing[i* nse+j]. split ()[1]
19 tmp2 = f_smearing[i* nse+j]. split ()[2]
68 | Hands‐On Tutorials of Quantum ESPRESSO

Figure 3.11 Total energy as a function of smearing energy by using the


Fermi‐Dirac, Gaussian, Methfessel‐Paxton, and Marzari‐Vanderbilt smearing
functions.

20 se[i]. append(float(tmp1))
21 ener[i]. append(float(tmp2))
22
23 # Create figure object
24 plt.figure ()
25 # Plot the data
26 plt.plot(se[0], ener [0],'o-', label='Fermi -Dirac ')
27 plt.plot(se[1], ener [1],'s-', label='Gaussian ')
28 plt.plot(se[2], ener [2],'v-', label='Methfessel -
Paxton ')
29 plt.plot(se[3], ener [3],'^-', label='Marzari -
Vanderbilt ')
30 # Add the legend
31 plt.legend(loc='lower left ')
32 # Add the x and y-axis labels
33 plt.xlabel('Smearing energy (Ry)')
34 plt.ylabel('Total energy (Ry)')
35 # Set the axis limits
36 plt.xlim (0.003 , 0.042)
37 plt.ylim ( -23.914 , -23.908)
38 # Save the figure.
39 plt.savefig('plot -smearing.pdf')
40 # Show the figure
41 plt.show ()

In Fig. 3.11, we show the total energy of graphene as a


function of smearing energy by using the Fermi‐Dirac, Gaussian,
Methfessel‐Paxton, and Marzari‐Vanderbilt smearing functions. We
Quantum ESPRESSO Course for Solid‐State Physics | 69
can see that the total energy decreases significantly as the smearing
energy increases for the Fermi‐Dirac function. In contrast, for the
Methfessel‐Paxton (MP) or Marzari‐Vanderbilt (MV) functions, the
decrease is not significant, and therefore it is possible to use relatively
large smearing energy for the MP or MV functions. Note that the
smearing energy is to treat the Fermi surface efficiently, and we
should use small smearing energy from 0.01 to 0.02 Ry for the MP and
MV functions. Thus the selection of the MV smearing is reasonable
for graphene, and we will use this smearing for the next tutorials of
graphene.

Try It Yourself

Plot total energy as a function of smearing energy with


different smearing functions for monolayer MoS2 .

3.2 Electronic properties

In Sec. 3.1, we show how to converge our calculations with respect


to the cut‐off energy and the sampled k‐points grid. By using these
parameters, the unit cell is optimized with a specific pseudopotential
and smearing function. This section shows how to visualize and
calculate charge density, band structure, and density of state of an
optimized unit cell.

3.2.1 Charge density

 Purpose: In this tutorial we visually check the electron charge


density in space.
 Background: By running pw.x in the SCF calculation as shown
in Sec. 3.1.1, you can find tmp/gr.save directory containing the
charge density file (charge-density.dat) and other output files.
Now in order to do a post‐process for converting the file format
of charge-density.dat into another file format that we can
visualize, we use the executable pp.x inside the Quantum ESPRESSO
distribution. This code can read the output files produced by pw.x
70 | Hands‐On Tutorials of Quantum ESPRESSO

and convert them into files compatible with various visualization


programs such as XCrySDen or VESTA.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/rho/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pp.x < pp.in > pp.out &

‐ Line 1: Go to rho directory.


‐ Line 2: Run pw.x with the input file scf.in to obtain scf.out.
‐ Line 3: Run pp.x with the input file pp.in to obtain pp.out.
 How to check: When the calculations finish, a message JOB DONE
is written at the end of both output files scf.out and pp.out.
 Input file: The detail of the scf.in file is given in Sec. 3.1.1. For
other input file pp.in, the readers can use vi editor by typing:

$ vi pp.in

QE‑SSP/gr/rho/pp.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'gr '
4 plot_num = 0
5 /
6 &PLOT
7 iflag = 3
8 output_format= 6
9 fileout = 'gr_rho.cube '
10 nx = 64
11 ny = 64
12 nz = 12
13 /

The description of input variables of pp.in is given in Table 3.8.


 Note: outdir and prefix must be the same as for scf.in for
pw.x calculation.
 Visualizing charge density: To see the electron charge density,
we launch VESTA and load the file gr_rho.cube by typing:
Quantum ESPRESSO Course for Solid‐State Physics | 71
Table 3.8 Meaning of input variables in pp.in file.

Line Syntax Meaning


A mandatory namelist includes input variables,
which read the output produced by pw.x and
1 &INPUTPP extract or calculate the desired quantities (rho,
V, ...).
......................................................................................................................................................................

Directory includes input data, i.e. the same as in


2 outdir pw.x.
......................................................................................................................................................................

3 prefix Prefix of files saved by program pw.x.


......................................................................................................................................................................

Select the output quantities, in which 0 =


4 plot_num electron charge density.
......................................................................................................................................................................

5 / End of namelist INPUTPP.


......................................................................................................................................................................

A mandatory namelist includes input variables,


which provide the desired quantity for
6 &PLOT outputting file in a suitable format for various
plotting programs.
......................................................................................................................................................................

7 iflag Type of plot, in which 3 = 3D plot.


......................................................................................................................................................................

Type of format, in which 6 = Gaussian cube file,


8
which can be read by VESTA software.
output_format
9 fileout Name of the file to which the plot is written.
......................................................................................................................................................................

10‐12 nx,ny,nz To determine the 3D grid for iflag = 3.


......................................................................................................................................................................

13 / End of namelist PLOT.

$ VESTA gr_rho.cube

VESTA will automatically identify the 3D charge density of graphene


as shown in Fig. 3.12 top. The readers might want to look at the
charge density as a 2D contour plot or heat map. From VESTA, we go
to Utilities → 2D Data Display..., then in the box [2D Data Display
‑ (gr_rho.cube)], we click on the Slice button to put the values for
Miller indices, then click to Ok button. We will obtain the 2D plot of
the charge density (see Fig. 3.12 bottom).
Quantum ESPRESSO Course for Solid‐State Physics | 73
3.2.2 Electronic energy dispersion

 Purpose: As discussed in Sec. 5.5, the electronic energy disper‐


sion gives the electronic energy as a function of k wavevector, which
we call energy band structure. The band structure can tell us useful
information, such as a material is metallic or semiconductor. In this
tutorial, we show how to calculate the energy dispersion of graphene.
 Background: In order to calculate the energy dispersion of
graphene, we need three‐step process as follows:
1. Calculate the Kohn‐Sham states with a standard scf calculation.
As discussed in Sec. 4.10.2, although the Kohn‐Sham states
are not strictly the real electronic states of the systems, they
are often good first‐approximations for the electronic states.
Therefore, the band structure, which is plotted by the Kohn‐Sham
eigenvalues, is meaningful to understand the electronic property
of the material.
2. Use the output data of the scf calculation to perform a non‐
self‐consistent (non‐SCF) calculation for many k‐points along
the selected high‐symmetry lines. The non‐SCF calculates the
Kohn‐Sham eigenfunctions and eigenvalues without upgrading
the Kohn‐Sham Hamiltonian at every step.
3. Extract the energies from the non‐SCF calculation and convert it
to a dataset we can plot with Gnuplot or Python. For this step, we
use the executable bands.x from Quantum ESPRESSO.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/bands/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pw.x < nscf.in > nscf.out &
4 $ mpirun -np 4 bands.x < bands.in > bands.out &

‐ Line 1: Go to bands directory.


‐ Line 2: Run pw.x with the input file scf.in for step (1).
‐ Line 3: Run pw.x with the input file nscf.in for step (2).
‐ Line 4: Run bands.x with the input file bands.in for step (3).
 How to check: When the calculations finish, a message JOB DONE
is written at the end of all output files scf.out, nscf.out, and
bands.out.
74 | Hands‐On Tutorials of Quantum ESPRESSO

 Input file: The detail of the scf.in file is given in Sec. 3.1.1. For
input file nscf.in, the readers can use vi editor by typing:

$ vi nscf.in

QE‑SSP/gr/bands/nscf.in

1 & CONTROL
2 calculation = 'bands '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'gr '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 2.4639055825
10 c = 15.0
11 nat = 2
12 ntyp = 1
13 nbnd = 16
14 occupations = 'smearing '
15 smearing = 'mv '
16 degauss = 0.020
17 ecutwfc = 40
18 /
19 & ELECTRONS
20 mixing_beta = 0.7
21 conv_thr = 1.0D-6
22 /
23 ATOMIC_SPECIES
24 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
25 ATOMIC_POSITIONS (crystal)
26 C 0.333333333 0.666666666 0.500000000
27 C 0.666666666 0.333333333 0.500000000
28 K_POINTS (crystal_b)
29 4
30 gG 40
31 K 20
32 M 30
33 gG 0

 Explanation of nscf.in: The non‐SCF for the band structure calcu‐


lation is performed by using the keyword calculation = 'bands'
(line 2) in the namelist CONTROL. Here, we select the number of Kohn‐
Sham states with the keyword nbnd = 16 (line 13) in the namelist
Quantum ESPRESSO Course for Solid‐State Physics | 75
ibrav = 1 ibrav = 2 b3
b3
R
L
U
Γ X Γ b2
b1 b2
M
b1 K W X

ibrav = 3 b3 ibrav = 4
b3

P H A L

Γ b2
H
Γ K
b1 N b2 M
b1

Figure 3.13 The labels of high‐symmetry points in the Brillouin‐zone of


several structures. The Γ‐point is denoted by gG in the input file.

SYSTEM, which means that 16 bands are calculated for the case of
graphene.
We also need to specify the k‐points in the card
K_POINTS (crystal_b) (line 28), in which crystal_b allows
us to use the labels of high‐symmetry points in the Brillouin‐
zone. In Fig. 3.13, we show the labels for several structures with
ibrav = 1, 2, 3, and 4. Note that the Γ‐point is denoted by gG
(line 30) in the input file. The labels of all structures can be found
in Ref. [Setyawan and Curtarolo (2010)]. It is noted that the k‐point
path must be continuous in the Brillouin‐zone.
To see the input file bands.in, the readers can type:

$ vi bands.in

QE‑SSP/gr/bands/bands.in

1 &BANDS
2 outdir = '../tmp/'
3 prefix = 'gr '
4 filband = 'gr.bands '
5 /
76 | Hands‐On Tutorials of Quantum ESPRESSO

 Note: outdir and prefix must be the same as for scf.in for
pw.x calculation. By setting lp = .true. in the namelist &BANDS,
the readers can obtain the square of the absolute value of the
matrix elements of the momentum operator between valence and
conduction bands in the output file p_avg.dat.
 Output file: The band structure of graphene is given by gr.bands,
which is output of bands.x. The readers can use vi editor to see the
gr.bands file as follows:

$ vi gr.bands

QE‑SSP/gr/bands/gr.bands

1 &plot nbnd= 16, nks= 91 /


2 0.000000 0.000000 0.000000
3 -21.257 -9.357 -4.798 -4.798 1.157 1.900 2.126 4.139
4 4.937 6.590 6.590 8.097 9.243 9.721 10.839 13.470
5 0.016667 0.000000 0.000000
6 -21.252 -9.351 -4.819 -4.809 1.164 1.907 2.133 4.146
7 4.943 6.593 6.612 8.103 9.250 9.703 10.848 13.476
8 0.033333 0.000000 0.000000
9 -21.237 -9.334 -4.880 -4.842 1.184 1.927 2.153 4.166
10 4.963 6.603 6.676 8.123 9.270 9.651 10.874 13.494
11 ...

‐ Line 1: nbnd is the number of bands and nks is the number of


k‐points.
‐ Line 2: The coordinates (kx , ky , kz ) of the first k‐point in crystal
coordinates.
‐ Line 3 and 4: The list of 16 energies at the first k‐point in units of
eV.
‐ Next lines: This format from line 2 to line 4 is repeated until the
final k‐point.
Other output file is gr.bands.gnu, which has a simpler format
than gr.bands. The gr.bands.gnu file contains two columns, the
first column is the k‐points, and the second column is the energies
(eV). We will use this file for plotting as below.
 Plotting data from gr.bands.gnu: The band structure is plotted by
running JupyterLab plot-bands.ipynb, which reads the data from
the gr.bands.gnu file:
Quantum ESPRESSO Course for Solid‐State Physics | 77

$ jupyter -lab plot -bands.ipynb

QE‑SSP/gr/bands/plot‑bands.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5
6 # The Fermi energy , find it in scf.out
7 efermi = -1.6790
8
9 # Load data from gr.bands.gnu
10 data = np.loadtxt('gr.bands.gnu')
11 k = np.unique(data[:, 0])
12 bands = np.reshape(data[:, 1], (-1, len(k)))
13
14 # Set high -symmetry points from nscf.in
15 gG1 = k[0]; K = k[40]; M = k[60]; gG2 = k[90]
16
17 # Create figure object
18 plt.figure ()
19 # Plot dotted line at Fermi energy
20 plt.axhline (0, c='gray ', ls=':')
21 # Plot dotted lines at high -symmetry points
22 plt.axvline(K, c='gray ')
23 plt.axvline(M, c='gray ')
24
25 # Plot band structure
26 for band in range(len(bands)):
27 plt.plot(k, bands[band , :]-efermi , c='b')
28
29 # Add the x and y-axis labels
30 plt.xlabel('')
31 plt.ylabel('Energy (eV)')
32 # Set the axis limits
33 plt.xlim(gG1 , gG2)
34 plt.ylim (-20, 20)
35 # Add labels for high -symmetry points
36 plt.xticks ([gG1 , K, M, gG2], ['$\Gamma$ ', 'K', 'M',
'$\Gamma$ '])
37 # Hide x-axis minor ticks
38 plt.tick_params(axis='x', which='minor ', bottom=
False , top=False)
39 # Save the figure
40 plt.savefig('plot -bands.pdf')
41 # Show the figure
78 | Hands‐On Tutorials of Quantum ESPRESSO

20

10
Energy (eV)
0

10

20
K M
Figure 3.14 Electronic band structure of graphene. The blue lines plot the
calculated electron dispersion. Dirac point is the transition between the
valence and conduction bands at the K point and zero energy. The ARPES
intensity of graphene appears on the electron dispersion of the valence band,
which is reproduced with permission [Ohta et al. (2007)].

42 plt.show ()

By running plot-bands.ipynb, we obtain the band structure,


as shown in Fig. 3.14. It shows that the graphene is a semimetal
with a zero band gap at E = 0 eV at the K point, which is
called the Dirac point since the linear dispersion relation near the
K point [Geim and Novoselov (2007)]. In order to compare with
the experiment, the angle‐resolved photoemission spectroscopy
(ARPES) intensity of the electron dispersion of the valence band is
plotted below the Dirac point (Fig. 3.14) [Ohta et al. (2007)]. The
readers can see that the ARPES intensity is reproduced by the
calculated electron dispersion (blue lines).

Try It Yourself

1. Calculate electronic energy dispersion of graphene by


selecting a LDA functional such as C.pz-hgh.UPF and
compare it with the GGA functional in Fig. 3.14.
2. Calculate electronic energy dispersion of bulk Si and
monolayer MoS2 , and compare calculated energy band gaps
with the experiment values (1.12 eV and 2.15 eV for bulk Si
and monolayer MoS2 , respectively).
Quantum ESPRESSO Course for Solid‐State Physics | 79
3.2.3 Electronic density of states

 Purpose: As discussed in Sec. 5.5, the electronic density of states


(DOS) is a property on how many electronic states exist per volume
per energy. In this tutorial, we will plot the DOS of graphene.
 Background: In a similar way to calculate the band structure in
Sec. 3.2.2, we produce the DOS calculation in the following three
steps:
1. Perform the SCF calculation as shown in Sec. 3.2.2.
2. Take the data in the previous step and use it to perform a non‐SCF
calculation on a more dense grid of k‐points. Since the DOS needs
an integration over the Brillouin zone, we use a much denser
grid for the non‐SCF than that for the SCF. In this case, we use
the tetrahedron method (see Sec. 5.5), in which the Brillouin
zone is divided into non‐overlapping small tetrahedra, and the
integrated quantity is assumed to take a linear interpolation of
energy for each tetrahedron. The obtained DOS is equivalent to a
very large number of the k‐points grid.
3. Convert the state energies calculated on the dense grid of the k‐
points to the DOS by using the executable dos.x from Quantum
ESPRESSO. This step will produce gr.dos file, which can be
plotted by JupyterLab.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/edos/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pw.x < nscf.in > nscf.out &
4 $ mpirun -np 4 dos.x < dos.in > dos.out &

‐ Line 1: Go to edos directory.


‐ Line 2: Run pw.x with the input file scf.in for step (1).
‐ Line 3: Run pw.x with the input file nscf.in for step (2).
‐ Line 4: Run dos.x with the input file dos.in for step (3).
 How to check: When the calculations finish, a message JOB DONE
is written at the end of all output files scf.out, nscf.out, and
dos.out.
 Input file: The detail of the scf.in file is given in Sec. 3.1.1. For
input file nscf.in, the readers can use vi editor by typing:
80 | Hands‐On Tutorials of Quantum ESPRESSO

$ vi nscf.in

QE‑SSP/gr/edos/nscf.in

1 & CONTROL
2 calculation = 'nscf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'gr '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 2.4639055825
10 c = 15.0
11 nat = 2
12 ntyp = 1
13 nbnd = 16
14 occupations = 'tetrahedra '
15 ecutwfc = 40
16 /
17 & ELECTRONS
18 mixing_beta = 0.7
19 conv_thr = 1.0D-6
20 /
21 ATOMIC_SPECIES
22 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
23 ATOMIC_POSITIONS (crystal)
24 C 0.333333333 0.666666666 0.500000000
25 C 0.666666666 0.333333333 0.500000000
26 K_POINTS (automatic)
27 48 48 1 0 0 0

 Explanation of nscf.in: The non‐SCF for the DOS is performed by


using the keyword calculation = 'nscf' (line 2) in the namelist
CONTROL, while the tetrahedron method is applied by using the
keyword occupations = 'tetrahedra' (line 14) in the namelist
SYSTEM. Here, a k‐points grid 48 × 48 × 1 in the namelist K_POINTS
is selected for the non‐SCF calculation.
To see the input file dos.in, the readers can type:

$ vi dos.in
Quantum ESPRESSO Course for Solid‐State Physics | 81
QE‑SSP/gr/edos/dos.in

1 &DOS
2 outdir = '../tmp/'
3 prefix = 'gr '
4 fildos = 'gr.dos '
5 /

 Note: outdir and prefix must be the same as for scf.in for
pw.x calculation.
 Output file: The output file for the DOS of graphene is given by
gr.dos, which is output of step (3). The readers can use vi editor to
see the gr.dos file as follows:

$ vi gr.dos

QE‑SSP/gr/edos/gr.dos

1 # E (eV) dos(E) Int dos(E) EFermi = -1.722 eV


2 -21.257 0.0000E+00 0.0000E+00
3 -21.247 0.4960E+00 0.2480E-02
4 -21.237 0.2942E+00 0.5277E-02
5 ...

‐ Column 1: The energies in units of eV.


‐ Column 2: The DOS in units of state/eV/unit‐cell.
‐ Column 3: The integrated DOS in units of state/unit‐cell.
 Note: The readers can find a difference between the Fermi energy
value (EF = −1.6708 eV) of the SCF calculation and EF = −1.722
eV of the non‐SCF calculation. EF = −1.6708 eV can be found in
scf.out, while EF = −1.722 eV is given in the header row of gr.dos.
This inconsistency might come from a small underestimation in the
tetrahedron method.
 Plotting data from gr.dos: The DOS is plotted by running
JupyterLab plot-dos.ipynb as follows:

$ jupyter -lab plot -dos.ipynb


 | +DQGV2Q 7XWRULDOV RI 4XDQWXP (635(662

'JHVSF  (OHFWURQLF GHQVLW\ RI VWDWHV '26 RI JUDSKHQH

3'552ITGFQURNQVFQUKR[PD

 O AKTQ`i i?2 M2+2bb`v T+F;2b M/ KQ/mH2b


 BKTQ`i KiTHQiHB#XTvTHQi b THi
 THiXbivH2Xmb2U^XXfXXf KiTHQiHB#fb+BXKTHbivH2 ^V
 BKTQ`i MmKTv b MT

 O h?2 62`KB 2M2`;v BM ?2/2` `Qr Q7 ;`X/Qb
 272`KB 4 @RXdk9

 O PT2M M/ `2/ i?2 7BH2 ;`X/Qb
 2M2` - /Qb - B/Qb 4 MTXHQ/itiU^;`X/Qb^- mMT+F4h`m2V

 O *`2i2 7B;m`2 Q#D2+i
 THiX7B;m`2 UV
 O SHQi i?2 .Pa rBi? i?2 62`KB 2M2`;v b?B7iBM;
 THiXTHQiU2M2` @272`KB - /Qb - +4^F^V
 O // i?2 t M/ v@tBb H#2Hb
 THiXtH#2HU^1M2`;v U2oV^V
 THiXvH#2HU^.Pa Ubii2f2ofmMBi @+2HHV^V
 O a2i i?2 tBb HBKBib
 THiXtHBKU@ky- kyV
 THiXvHBKUy- kX8V
 O ap2 i?2 7B;m`2
 THiXbp27B;U^THQi @/QbXT/7^V
 O a?Qr i?2 7B;m`2
 THiXb?Qr UV
Quantum ESPRESSO Course for Solid‐State Physics | 83
By running plot-pdos.ipynb, we obtain the DOS of graphene,
as shown in Fig. 3.15. Since graphene is a zero‐band‐gap semimetal
with bands intersecting at the Dirac point at E = 0 (see Fig. 3.14), the
DOS is zero at the Dirac point.

Try It Yourself

1. Calculate the DOS of bulk Si and monolayer MoS2 .


2. Check if DOS(E) ∝ E for the 3D DOS, where E is measured

from the bottom of the conduction band.

3.2.4 Partial density of states

 Purpose: Partial density of states (PDOS) is the relative contribu‐


tion of a particular atom/orbital to the total DOS. In this tutorial, we
will plot the PDOS of graphene.
 Background: For the SCF calculation in Sec. 3.2.2, we selected the
pseudopotential C.pbe-n-rrkjus_psl.0.1.UPF, which gives us the
information of the particular orbital for the C atom. The readers can
find this information in C.pbe-n-rrkjus_psl.0.1.UPF as

Valence configuration:
nl pn l occ Rcut Rcut US E pseu
2S 1 0 2.00 1.000 1.300 -1.010676
2P 2 1 2.00 1.000 1.450 -0.388489

The pseudopotential shows that the C atom contains the 2s and


2p orbitals. We can calculate the PDOS of the 2s and 2p orbitals for
each C atom in the unit cell by using the executable projwfc.x from
Quantum ESPRESSO.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/pdos/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pw.x < nscf.in > nscf.out &
4 $ mpirun -np 4 projwfc.x < projwfc.in > projwfc.out
&
84 | Hands‐On Tutorials of Quantum ESPRESSO

‐ Line 1: Go to pdos directory.


‐ Line 2: Run SCF calculation by using pw.x.
‐ Line 3: Run non‐SCF calculation by using pw.x.
‐ Line 4: Run projwfc.x with the input file projwfc.in.
 Note: The SCF and non‐SCF calculations can be omitted if the
readers have successfully finished the DOS calculation in Sec. 3.2.2.
 How to check: When the calculations finish, a message JOB DONE
is written at the end of the all output files scf.out, nscf.out, and
projwfc.out.
 Input file: The detail of the input files scf.in and nscf.in are
given in Sec. 3.1.2. For input file projwfc.in, the readers can use vi
editor by typing:

$ vi projwfc.in

QE‑SSP/gr/pdos/projwfc.in

1 &projwfc
2 prefix = 'gr '
3 outdir = '../tmp/'
4 /

 Note: outdir and prefix in projwfc.in must be the same as for


scf.in and nscf.in.
 Output file: The PDOS is written to output files
gr.pdos_atm#N(X)_wfc#M(l), where X is atom symbol (C),
N is atom number (1, 2) in the unit cell, M is wavefunction
number, and l is orbital (s, p, d, etc.). We can open the file
gr.pdos_atm#1(C)_wfc#1(s) for the PDOS of 2s orbital of the
first C atom in the unit cell as follows:

$ vi gr.pdos_atm#1\(C\) _wfc #1\(s\)

QE‑SSP/gr/pdos/gr.pdos_atm#1(C)_wfc#1(s)

1 # E (eV) ldos(E) pdos(E)


2 -21.259 0.000E+00 0.000E+00
3 -21.249 0.243E+00 0.243E+00
4 -21.239 0.144E+00 0.144E+00
5 ...
Quantum ESPRESSO Course for Solid‐State Physics | 85
6 17.041 0.126E-03 0.126E-03
7 17.051 0.557E-04 0.557E-04
8 17.061 0.000E+00 0.000E+00

‐ Column 1: The energies (in eV).


‐ Column 2: The “total” PDOS of the 2s orbital (LDOS) in
state/eV/unit‐cell. It is noted that since we consider only wavefunc‐
tion for s orbital, the LDOS is equal to the PDOS. In general, LDOS =
PDOS_1 + PDOS_2 + ...
‐ Column 3: The PDOS of the 2s orbital with the first wavefunction
of the first C atom (in state/eV/unit‐cell).
 Plotting data from gr.dos: The PDOS of graphene is plotted by
running JupyterLab plot-pdos.ipynb as follows:

$ jupyter -lab plot -dos.ipynb

QE‑SSP/gr/edos/plot‑dos.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5
6 # The Fermi energy , find it in nscf.out
7 efermi = -1.7241
8
9 # Define the function to read the data file
10 def r_dos(name):
11 ener , dos = np.loadtxt(name , usecols =(0 ,1),
unpack=True)
12 return ener , dos
13
14 # Read the total PDOS
15 ener , dos = r_dos('gr.pdos_tot ')
16 # Read the PDOS of C atom number 1
17 ener1 , p1C1s = r_dos('gr.pdos_atm #1(C)_wfc #1(s)')
18 ener1 , p1C2p = r_dos('gr.pdos_atm #1(C)_wfc #2(p)')
19 # Read the PDOS of C atom number 2
20 ener2 , p2C1s = r_dos('gr.pdos_atm #2(C)_wfc #1(s)')
21 ener2 , p2C2p = r_dos('gr.pdos_atm #2(C)_wfc #2(p)')
22
23 # Create figure object
24 plt.figure ()
25 # Plot the DOS
86 | Hands‐On Tutorials of Quantum ESPRESSO

DOS

PDOS of 2p orbital
PDOS of 2s orbital

Figure 3.16 The DOS and PDOS of 2s and 2p orbital of graphene.

26 plt.plot(ener -efermi , dos , c='k')


27 # Plot the PDOS of s-orbital
28 plt.plot(ener1 -efermi , p1C1s+p2C1s , c='b')
29 # Plot the PDOS of p-orbital
30 plt.plot(ener2 -efermi , p1C2p+p2C2p , c='r')
31 # Add the x and y-axis labels
32 plt.xlabel('Energy (eV)')
33 plt.ylabel('PDOS (state/eV/unit -cell)')
34 # Set the axis limits
35 plt.xlim(-20, 20)
36 plt.ylim(0, 4)
37 # Save the figure
38 plt.savefig('plot -pdos.pdf')
39 # Show the figure
40 plt.show ()

In Fig. 3.16, we show the DOS and the PDOS of the 2s and 2p
orbitals as functions of energy E. For the valence bands (E < 0),
the<DOS is equal to the total PDOS since all valence bands mainly
come from the 2s and 2p orbitals. For the conduction bands, > with
E > 2.5 eV, the DOS is not equal to the sum of PDOS because the
high energy bands include not only the 2s and 2p orbitals but also
more delocalized wavefunctions far from the atoms, which are called
interlayer‐bands [Fretigny et al. (1989)].
Quantum ESPRESSO Course for Solid‐State Physics | 87
Try It Yourself

Calculate the contribution of the PDOS of the S and Mo atoms


to the total DOS of monolayer MoS2 .

3.3 Lattice oscillations

In this section, we learn how to calculate the frequencies of


oscillations of solid. The oscillations of atoms in a crystal with a
finite amplitude around the equilibrium positions, known as phonon
modes (see Sec. 5.7), are essential to understand the dynamical
properties of the material, such as thermal conductance or the
Raman spectra.

3.3.1 Phonon dispersion

 Purpose: As discussed in Sec. 5.7, the phonon dispersion is the


phonon frequency as a function of phonon wavevector.3 The phonon
dispersion, which is observed by neutron scattering, can tell us useful
information of the material such as elastic constants or thermal
conductivity. In this tutorial, we show how to plot the phonon
dispersion of graphene.
 Background: The phonon angular frequencies ωq are determined
by solving the simultaneous equation of motion for each q as

D̃Iα,Jβ (q)ũJβ (q) = ω2q ũIα (q) with (Iα = 1, …, 3N), (3.9)


where N is the number of atoms in the unit cell and α (β) corresponds
to x, y, z components of oscillation. ũIα (ũJβ ) is a phonon eigenvector
(or the amplitude of the phonon) of the I‐th (J‐th) atom. Summation
on Jβ is taken for neighbor atoms from a given I‐th atom up to several
nearest neighbors. D̃Iα,Jβ (q) is called the dynamical matrix, which is

3We use k‐points to refer to electron wavevectors and q‐points to refer to phonon
wavevectors
88 | Hands‐On Tutorials of Quantum ESPRESSO

defined by

1
D̃Iα,Jβ (q) =  F̃Iα,Jβ (q), (3.10)
MI MJ

where MI (MJ ) is mass of the I‐th (J‐th) atom. F̃Iα,Jβ is second


derivatives of the total energy Etot with respect to the displacements
(ũIα , ũJβ ) of atomic positions, which is called the inter‐atomic force
constant (IFC), which is given by

∂2 Etot
F̃Iα,Jβ (q) = . (3.11)
∂ũIα (q)∂ũJβ (q)

D̃Iα,Jβ (q) in Eq. (3.10) is calculated by the executable ph.x


in Quantum ESPRESSO within the density‐functional perturbation
theory4 (DFPT) [Baroni et al. (2001)]. Then, ωq is obtained from
Eq. (3.9) by diagonalizing D̃Iα,Jβ (q). By repeating this procedure for
several q, we obtain ωq as a function of q and plot the phonon
dispersions. However, the DFPT calculation is time‐consuming
compared with the SCF calculation. Thus, we will calculate D̃Iα,Jβ (q)
for a small set of q vectors and take an interpolation for ωq over the
Brillouin zone.
In order to plot the ωq by interpolation, we use the executables
q2r.x and matdyn.x in Quantum ESPRESSO. q2r.x reads D̃Iα,Jβ (q),
which is calculated by ph.x for a uniform mesh of (q1 , q2 , q3 ) vectors.
Then, the IFC of a q1 × q2 × q3 supercell in the real space, FIα,Jβ (R), is
calculated from F̃Iα,Jβ (q) by using the inverse Fourier transform as

Nq
1 
FIα,Jβ (R) = F̃Iα,Jβ (qijk )eiqijk ·R , (3.12)
Nq
i=1

where Nq = q1 × q2 × q3 , R is an atomic position in the q1 × q2 × q3


supercell, and qijk is defined by

i−1 j−1 k−1


qijk = G1 + G2 + G3 , (3.13)
q1 q2 q3

4 The DFPT is a method that can directly calculate the second‐order derivatives of the

energy in Eq. (3.11) by a self‐consistent procedure.


Quantum ESPRESSO Course for Solid‐State Physics | 89
where i = 1, …, q1 , j = 1, …, q2 , k = 1, …, q3 , and G1 , G2 , and G3 are
the reciprocal lattice vectors. Then, matdyn.x reads the IFC that is
calculated by q2r.x and calculates the IFC at an interpolated q′ by
using the Fourier transform as

F̃Iα,Jβ (q′ ) = FIα,Jβ (R)eiq ·R . (3.14)


 ′

Eqs. (3.12) and (3.14) allow the interpolation of the dynamical matrix
at arbitrary q′ , by a few IFCs. It is noted that the Fourier interpolation
works well if the IFCs decay rapidly in the real space. Therefore, the
Fourier interpolation might fail in some special cases when IFCs do
not decay. For example, when the Kohn anomaly occurs in a metal, the
dynamical matrix is not a smooth function of q, and the IFCs decay
slowly in the real space.
The calculation of the phonon dispersion of graphene has the
following four steps:
1. Perform the SCF with pw.x calculation.
2. Calculate the dynamical matrix in Eq. (3.10) on a uniform mesh of
q‐points by using ph.x.
3. Perform the inverse Fourier transform of the dynamical matrix in
Eq. (3.12) to obtain a set of the IFCs in the real space by using
q2r.x.
4. Perform the Fourier transform of the real space IFCs in Eq. (3.14)
to obtain the dynamical matrix at any q′ by using matdyn.x. This
allows us to calculate the phonon frequencies for a set of points
along lines between high‐symmetry points in the Brillouin zone,
which is similar to the electronic band structure in Sec. 3.2.2.
 How to run: The readers can run the following command lines:

1 $ cd ~/QE -SSP/gr/phonon/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 ph.x < ph.in > ph.out &
4 $ mpirun -np 4 q2r.x < q2r.in > q2r.out &
5 $ mpirun -np 4 matdyn.x < matdyn.in > matdyn.out&

‐ Line 1: Go to phonon directory.


‐ Line 2: Run SCF calculation with pw.x for step (1).
‐ Line 3: Run phonon calculation with ph.x for step (2).
‐ Line 4: Run q2r.x for step (3).
90 | Hands‐On Tutorials of Quantum ESPRESSO

‐ Line 5: Run matdyn.x for step (4).


 How to check: When the calculations finish, a message JOB DONE
is written at the each end of the output files; scf.out, ph.out,
q2r.out, and matdyn.out.
 Input file: The input file scf.in can be opened as follows:

$ vi scf.in

QE‑SSP/gr/phonon/scf.in

1 & CONTROL
2 calculation = 'scf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'gr '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 2.4639055825
10 c = 15.0
11 nat = 2
12 ntyp = 1
13 occupations = 'smearing '
14 smearing = 'mv '
15 degauss = 0.02
16 ecutwfc = 80
17 assume_isolated = '2D'
18 /
19 & ELECTRONS
20 mixing_beta = 0.7
21 conv_thr = 1.0D-6
22 /
23 ATOMIC_SPECIES
24 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
25 ATOMIC_POSITIONS (crystal)
26 C 0.333333333 0.666666666 0.500000000
27 C 0.666666666 0.333333333 0.500000000
28 K_POINTS (automatic)
29 12 12 1 0 0 0

Explanation of scf.in: Compared with the scf.in file in


the previous tutorials (see Sec. 3.2.2 or 3.2.3), a new syntax
assume_isolated = '2D' (line 17) is added in the namelist
SYSTEM. This syntax can help to avoid the “flexural” phonons
Quantum ESPRESSO Course for Solid‐State Physics | 91
(negative or imaginary acoustic frequencies at near Gamma point)
in the 2D materials [Sohier et al. (2017)].
Note: For phonon calculation, the readers should use a larger
value of ecutwfc = 80 (line 16) compared with the SCF calculation
(ecutwfc = 40). This is because that the phonon frequencies have
the unit of cm−1 (∼ 0.00012 eV), which requires a large cutoff
energy.
To see the input file ph.in, the readers can type:

$ vi ph.in

QE‑SSP/gr/phonon/ph.in

1 phonon calc.
2 & INPUTPH
3 outdir = '../tmp/'
4 prefix = 'gr '
5 tr2_ph = 1d-14
6 ldisp = .true.
7 nq1 = 6
8 nq2 = 6
9 nq3 = 1
10 fildyn = 'gr.dyn '
11 /

Explanation of ph.in: In order to obtain the phonon dispersion,


we need to set ldisp = .true. (line 6) and a grid of q‐points
specified by nq1, nq2, nq3. In the case of the 2D materials, we
can put nq3 = 1. Since the ph.x calculation is time‐consuming, nq1,
nq2, nq3 are usually taken smaller than nk1, nk2, nk3 of the pw.x
calculation. The description of input variables of ph.in is given in
Table 3.9.
To see the input file q2r.in, the readers can type:

$ vi q2r.in

QE‑SSP/gr/phonon/q2r.in

1 &INPUT
2 fildyn = 'gr.dyn '
3 zasr = 'crystal '
92 | Hands‐On Tutorials of Quantum ESPRESSO

Table 3.9 Meaning of input variables in ph.in file.

Line Syntax Meaning


Title of the job, i.e., a line that is reprinted on
1 title_line output
....................................................................................................................................................................

4 prefix Prefix of files saved by program pw.x.


5 tr2_ph Threshold for self‐consistency.
....................................................................................................................................................................

The default is ldisp = .false.. If we set ldisp


6 = .true., the dynamical matrix is calculated for
a grid of q‐points specified by nq1, nq2, nq3.
ldisp
....................................................................................................................................................................

Parameters of the Monkhorst‐Pack grid (no


offset) used when ldisp = .true.. It is same
7–9 nq1, nq2, nq3 meaning as for nk1, nk2, nk3 in the input of
pw.x.
....................................................................................................................................................................

File name where the dynamical matrix is


10
written.
fildyn

4 flfrc = 'gr.fc '


5 /

Explanation of q2r.in: The syntax zasr is used to impose the IFCs


to adopt the acoustic sum rule (ASR).5 There are several options for
the ASR imposed. Here, we select zasr = 'crystal' (line 3), i.e.,
three translational ASR are imposed by optimized correction of the
dynamical matrix. The file containing the IFCs in the real space is
given by the gr.fc file.
 Note: fildyn in q2r.in must be the same as that for ph.in for
ph.x calculation.
To see the input file matdyn.in, the readers can type:

$ vi matdyn_disp.in

5 The ASR is a requirement for IFCs by translational and rotational invariance of the

crystal. If we translate the whole solid by a uniform displacement or if we rotate the


solid, the inter‐atomic forces by the displacements on rotation should not appear. As
a consequence of ASR, the frequencies of the acoustic modes become zero
[Madelung (1978)].
Quantum ESPRESSO Course for Solid‐State Physics | 93
QE‑SSP/gr/phonon/matdyn.in

1 &INPUT
2 asr = 'crystal '
3 flfrc = 'gr.fc '
4 flfrq = 'gr.freq '
5 flvec = 'gr.modes '
6 loto_2d = .true.
7 q_in_band_form = .true.
8 /
9 4
10 gG 40
11 K 20
12 M 30
13 gG 0

Explanation of matdyn.in: The syntax loto_2d is set to .true.


(line 6) to activate two‐dimensional treatment of LO‐TO splitting,6
which occurs in a polar 2D materials as h‐BN or MoS2 . It is noted
that LO‐TO splitting does not occur in the case of graphene since it is
not a polar material. The setting q_in_band_form = .true (line 7)
allows us to use the labels of high‐symmetry points in the Brillouin‐
zone (see Sec. 3.2.2) to plot the phonon dispersion.
 Note: By changing asr = 'crystal' (line 2) to asr = 'simple'
in matdyn.in, the readers might obtain the negative phonon
frequency at near the Γ point. The option asr = 'crystal' is
usually better than asr = 'simple'.
 Output file: The output file for the phonon frequencies of
graphene is given by gr.freq. The readers can open this file by

$ vi gr.freq

QE‑SSP/gr/phonon/gr.freq
1 &plot nbnd= 6, nks= 91 /
2 0.000000 0.000000 0.000000
3 -0.0000 -0.0000 -0.0000 876.7549 1488.7595 1488.7595
4 0.016667 0.000000 0.000000
5 7.4052 31.1526 49.6068 876.5584 1489.4337 1490.5041
6 ...

6In the ionic crystal, we know the splitting between LO and TO as


ω2LO = (ε0 /ε∞ )ω2TO [Kittel (1976)].
94 | Hands‐On Tutorials of Quantum ESPRESSO

‐ Line 1: nbnd is the number of phonon modes and nks is the


number of q‐points.
‐ Line 2: The coordinates (qx , qy , qz ) of the first q‐point in crystal
coordinates.
‐ Line 3: The list of 6 phonon frequencies at the first q‐point in
units of cm−1 .
‐ Next lines: This format from line 2 to line 3 is repeated until the
final q‐point.
The matdyn.x calculation in the step (4) also automatically
outputs a file gr.freq.gp, which has a simpler format than gr.freq.
The gr.freq.gp file contains 7 columns, in which the first column is
the q‐points and other columns are phonon frequencies (cm−1 ). We
will use this file for plotting as below.
 Plotting data from gr.freq.gp: The phonon dispersion is plotted
by running JupyterLab plot-phonon.ipynb, which reads the data
from the gr.freq.gp file:

$ jupyter -lab plot -phonon.ipynb

QE‑SSP/gr/phonon/plot‑phonon.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5 # Number of phonon modes and q-points gr.freq
6 nbnd = 6; nks = 91
7 # Open gr.freq.gp file
8 qs , * ph = np.loadtxt('gr.freq.gp', unpack=True)
9 # Read phonon at each phonon index
10 ph0 = []
11 for iq in range(nks):
12 ph0.append ([])
13 for ib in range(nbnd):
14 tmp = ph[ib][iq]
15 ph0[iq]. append(float(tmp))
16 # Set high -symmetry points from matdyn.in
17 G1 = qs [0]; K = qs [40]; M = qs [60]; G2 = qs [90]
18 # Create figure object
19 plt.figure ()
20 # Plot dotted lines at high -symmetry points
21 plt.axvline(K, c='gray ')
22 plt.axvline(M, c='gray ')
Quantum ESPRESSO Course for Solid‐State Physics | 95
LO

TO

ZO

LA

TA
ZA

Figure 3.17 Phonon dispersion of graphene along the high symmetry‐lines


of hexagonal Brillouin zone. The red boxes show the Kohn anomalies at the
Γ and the K points of the Brillouin zone.

23 # Plot phonon dispersion


24 plt.plot(qs , ph0 , c='b')
25 # Add the x and y-axis labels
26 plt.xlabel('')
27 plt.ylabel('Frequency (cm$ ^{-1}$)')
28 plt.xlim(G1 , G2)
29 plt.ylim(0, 1700)
30 # Add labels for high -symmetry points
31 plt.xticks ([G1 , K, M, G2], ['$\Gamma$ ', 'K', 'M', '$
\Gamma$ '])
32 # Hide x-axis minor ticks
33 plt.tick_params(axis='x', which='minor ', bottom=
False , top=False)
34 # Save the figure
35 plt.savefig('plot -phonon.pdf')
36 # Show the figure
37 plt.show ()

By running plot-phonon.ipynb, we obtain the phonon disper‐


sion of graphene, as shown in Fig. 3.17. There are 6 phonon modes
including three acoustic branches (ZA, TA, and LA) and three optical
branches (ZO, TO, and LO). The red boxes in Fig. 3.17 show the
Kohn anomaly7 [Kohn (1959)] for certain phonon modes at the Γ

7 The Kohn anomaly is an anomaly in the phonon dispersion of a metal. For a specific

wavevector, the frequency of the associated phonon is softened, and there is a


discontinuity in the derivative of frequency.
96 | Hands‐On Tutorials of Quantum ESPRESSO

and the K points of the Brillouin zone, arising from perturbation


of a phonon by electron‐phonon interaction. Specifically, the Kohn
anomaly is manifested by a non‐zero slope of LO and TO at the Γ point
and a non‐zero slope of TO at the K point. This effect was observed
experimentally by the Raman spectra of the G band, due to the LO/TO
phonon, at different charge doping level [Lazzeri and Mauri (2006)].
 Visualizing phonon dispersion: The readers can also visualize
the phonon dispersion calculated with a display graphically the
phonon modes of the lattice vibrations. First, the readers need
to upload the input file scf.in and the output files scf.out
and gr.modes to the website: https://www.materialscloud.org/
work/tools/interactivephonon, as shown in the red box of
Fig. 3.18 (top). Then, the readers click on the button “Calculate
phonon dispersion”. A new window will appear, as shown in Fig. 3.18
(bottom). In the phonon section, the readers can click on any point in
the phonon dispersion and see an animation of how the atoms vibrate
according to this model.

Try It Yourself

1. Calculate phonon dispersion of graphene without


assume_isolated = '2D' option in scf.in, and check if
the negative phonon frequency appears for the ZA mode.
2. Calculate phonon dispersion of monolayer MoS2 .

3.3.2 Phonon density of states

 Purpose: Phonon density of states (DOS) is defined in exactly the


same way as the electronic density of states (see Sec. 3.2.3), i.e., the
number of phonon modes per volume per frequency. In this tutorial,
we will plot the phonon DOS of graphene.
 Background: The phonon DOS can be obtained by choosing some
input options for matdyn.x in step (4) of the phonon calculation (see
Sec. 3.3.1). Therefore, the readers are asked to finish the phonon
calculation in Sec. 3.3.1 before this tutorial.
 How to run: To run this tutorial, the readers should type the
following command lines:
Quantum ESPRESSO Course for Solid‐State Physics | 97

Figure 3.18 Visualizing phonon dispersion by using free‐online‐tool “Inter‐


active phonon visualizer”.

1 $ cd ~/QE -SSP/gr/phdos/
2 $ cp ../ phonon/gr.fc ./
3 $ mpirun -np 4 matdyn.x < matdyn.in > matdyn.out &

‐ Line 1: Go to phdos directory.


98 | Hands‐On Tutorials of Quantum ESPRESSO

‐ Line 2: Copy the IFCs file gr.fc from Sec 3.3.1.


‐ Line 3: Run matdyn.x with the input file matdyn.in for the
phonon DOS calculation. It is noted that this matdyn.in file is
different with the matdyn.in file in Sec 3.3.1.
 How to check: When the calculations finish, you can find a
message JOB DONE at the end of the output file matdyn.out.
 Input file: To see the input file matdyn.in, the readers can type:

$ vi matdyn.in

QE‑SSP/gr/phdos/matdyn.in

1 &INPUT
2 asr = 'crystal '
3 flfrc = 'gr.fc '
4 flfrq = 'gr.freq '
5 flvec = 'gr.modes '
6 loto_2d = .true.
7 fldos = 'gr.dos '
8 dos = .true.
9 nk1 = 48
10 nk2 = 48
11 nk3 = 1
12 /

Explanation of matdyn.in: The syntax dos is set to .true. (line 8)


to obtain the phonon DOS. This is similar to the electronic density of
states in Sec. 3.2.3, we need to select a dense q‐points grid to calculate
the phonon DOS compared with q‐points of the ph.x calculation.
Here, we select 48 × 48 × 1 for the case of graphene.
 Output file: The output file for the phonon DOS of graphene is
given by gr.dos. The readers can use vi editor to see the gr.dos file
as follows:

$ vi gr.dos

QE‑SSP/gr/phdos/gr.dos

1 # Frequency[cm^-1] DOS PDOS


2 -2.4978196418E-05 0.0000000000E+00 0.0000E+00 0.0000E+00
3 9.9997502180E-01 2.4555277523E-05 1.2278E-05 1.2278E-05
Quantum ESPRESSO Course for Solid‐State Physics | 99
4 1.9999750218E+00 4.9110570407E-05 2.4555E-05 2.4555E-05
5 ...

‐ Column 1: The phonon frequencies in units of cm−1 . We can


neglect a tiny negative value -2.4978196418E-05 and assumed to be
zero.
‐ Column 2: The phonon DOS in units of state/cm−1 /unit‐cell.
‐ Columns 3 and 4: The partial phonon density of states (PDOS) for
the C atoms 1 and 2 in the unit cell (in state/cm−1 /unit‐cell).
 Plotting data from gr.dos: The phonon DOS is plotted by running
JupyterLab plot-phdos.ipynb, which reads the data from the
gr.dos file:

$ jupyter -lab plot -phdos.ipynb

QE‑SSP/gr/edos/plot‑dos.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5 # Load data from gr.dos
6 omega , ph_tot , ph_c1 , ph_c2 = np.loadtxt('gr.dos',
unpack=True)
7 # Create figure object
8 plt.figure ()
9 # Plot the phonon DOS
10 plt.plot(omega , ph_tot , c='b', label='Total ')
11 plt.plot(omega , ph_c1 , c='r', ls='dashed ', label='C
atom ')
12 # Add the x and y-axis labels
13 plt.xlabel('Frequency (cm$ ^{-1}$)')
14 plt.ylabel('Phonon DOS (state/cm$ ^{-1}$/unit -cell)')
15 # Add the legend
16 plt.legend(loc='upper left ')
17 # Set the axis limits
18 plt.xlim(0, 1700)
19 plt.ylim(0, 0.025)
20 # Save the figure
21 plt.savefig('plot -phdos.pdf')
22 # Show the figure
23 plt.show ()
100 | Hands‐On Tutorials of Quantum ESPRESSO

Figure 3.19 Phonon density of states (solid line) and phonon PDOS of a C
atom (dashed line) of graphene.

By running plot-phdos.ipynb, we obtain the phonon DOS of


graphene, as shown in Fig. 3.19. The total phonon DOS (solid line)
of graphene is twice as large as the PDOS of a single C atom (dashed
line) since there are two C atoms in the unit cell of graphene.

Try It Yourself

Calculate contributions of the phonon DOS of the Mo and S


atoms to total phonon DOS of monolayer MoS2 .

3.3.3 Electron‐phonon interaction

 Purpose: In solids, the electron‐phonon interaction plays an


important role in a variety of physical phenomena, such as
temperature‐dependent energy band, the Kohn anomaly, electrical
conductivity, or superconductivity. As discussed in Sec. 5.8, the origin
of electron‐phonon interaction is the oscillation of atomic potential
by lattice oscillation. In this tutorial, we calculate the electron‐
phonon interaction of graphene.
 Background: In Quantum ESPRESSO, the electron‐phonon matrix
elements, gνq , for the phonon mode ν at a wavevector q are defind as
Quantum ESPRESSO Course for Solid‐State Physics | 101


 1/2
gνq (k, i, j) = (3.15)
2Mωνq
⟨ψi,k |∂νq VSCF |ψj,k+q ⟩,

where M is the total mass of the atoms in the unit cell, ωνq is the
phonon frequency, ∂νq VSCF is the derivative of the self‐consistent
potential VSCF by ionic displacement by phonon mode ν at q, and
ψi,k and ψj,k+q are the wavefunctions at initial state i and final state
j, respectively.
The phonon linewidth γ νq , which is the imaginary part of the
phonon self‐energy, is defined by gνq in Eq. (3.15) as

|gνq (k, i, j)|2 δ(ϵi,k − ϵF )δ(ϵj,k+q − ϵF ),



γ νq = 2πωνq
dk
ij BZ ΩBZ

(3.16)

where ΩBZ is the volume of the Brillouin zone (BZ), ϵF is the Fermi
energy, and ϵi,k and ϵj,k+q are the energies of the initial state i and
final state j, respectively.
The electron‐phonon coupling constant λνq is defined by γ νq in
Eq. (3.16) as

, (3.17)
γ νq
λνq =
πh̄D(ϵF )ω2νq

where D(ϵF ) is the density of states (DOS) at the Fermi energy.


The calculation of the electron‐phonon interaction of graphene
consists the following 5 steps:
1. Perform the SCF for a dense k‐points grid with pw.x calculation.
The dense grid must contain all k and k + q points, which is used
in the electron‐phonon calculation and must be dense enough to
produce the phonon linewidth accurately.
2. Perform other SCF for a grid of k‐points that is suitable for the
phonon calculation by using pw.x.
3. Perform the phonon calculation based on the SCF in step (2) by
using ph.x.
102 | Hands‐On Tutorials of Quantum ESPRESSO

4. Perform the inverse Fourier transform of dynamical matrix and


the phonon linewidth, which are obtained in step (3), in real
space by using q2r.x.
5. Perform the Fourier transform to obtain the dynamical matrix and
the phonon linewidth for a set of points along lines between high‐
symmetry points in the Brillouin zone by using matdyn.x.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/elph/
2 $ mpirun -np 4 pw.x < scf -dense.in > scf -dense.out &
3 $ mpirun -np 4 pw.x < scf.in > scf.out &
4 $ mpirun -np 4 ph.x < ph.in > ph.out &
5 $ mpirun -np 4 q2r.x < q2r.in > q2r.out &
6 $ mpirun -np 4 matdyn.x < matdyn.in > matdyn.out &

‐ Line 1: Go to elph directory.


‐ Line 2: Run pw.x for the SCF calculation with a dense k‐points
grid.
‐ Line 3: Run pw.x for the SCF calculation with a suitable k‐points
grid for phonon calculation.
‐ Line 4: Run ph.x with the input file ph.in for the electron‐
phonon calculation.
‐ Line 5: Run q2r.x with the input file q2r.in.
‐ Line 6: Run matdyn.x with the input file matdyn.in.
 How to check: When the calculations finish, you can find a
message JOB DONE at the end of each output file.
 Input file: The readers can open the input file scf-dense.in as
follows:

$ vi scf -dense.in

QE‑SSP/gr/elph/scf‑dense.in

1 & CONTROL
2 calculation = 'scf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'gr '
6 /
Quantum ESPRESSO Course for Solid‐State Physics | 103
7 &SYSTEM
8 ibrav = 4
9 a = 2.4639055825
10 c = 15.0
11 nat = 2
12 ntyp = 1
13 occupations = 'smearing '
14 smearing = 'mv '
15 degauss = 0.020
16 ecutwfc = 80
17 assume_isolated = '2D'
18 la2F = .true.
19 /
20 & ELECTRONS
21 mixing_beta = 0.7
22 conv_thr = 1.0D-6
23 /
24 ATOMIC_SPECIES
25 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
26 ATOMIC_POSITIONS (crystal)
27 C 0.333333333 0.666666666 0.500000000
28 C 0.666666666 0.333333333 0.500000000
29 K_POINTS (automatic)
30 36 36 1 0 0 0

Explanation of scf‑dense.in: The option la2F = .true. (line 18)


in the namelist SYSTEM instructs the pw.x to save the eigenvalues on
the dense k‐points grid into a file gr.a2Fsave, which can be found in
outdir (line 4). Here, we select a dense k‐points grid is 36 × 36 × 1
(line 30) in the namelist K_POINTS. The remaining part is same as
Sec. 3.3.1.
Note: The dense k‐points grid must be unshifted (line 30) because
the grid should include the Γ point (see Sec. 3.1.3). Since the dense
grid must contain all k and k + q points, it should be a multiple of
q‐point grid in ph.in for phonon calculations, otherwise the ph.x
calculation will be stopped by showing the following error:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
task # 3
from elphsum : error # 2
q is not a vector in the dense grid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The input file scf.in is same as Sec. 3.3.1. For the input file
ph.in, the readers can open by typing:
104 | Hands‐On Tutorials of Quantum ESPRESSO

$ vi ph.in

QE‑SSP/gr/elph/ph.in

1 phonon calc.
2 & INPUTPH
3 outdir = '../tmp/'
4 prefix = 'gr '
5 tr2_ph = 1d-14
6 ldisp = .true.
7 nq1 = 6
8 nq2 = 6
9 nq3 = 1
10 fildyn = 'gr.dyn '
11 fildvscf = 'grdv '
12 electron_phonon = 'interpolated '
13 el_ph_nsigma = 10
14 el_ph_sigma = 0.02
15 /

Explanation of ph.in: The electron‐phonon calculation is per‐


formed by setting electron_phonon = 'interpolated' (line 12).
The option fildvscf = 'grdv' (line 11) is the file name of
derivative of the self‐consistent potential ∂νq VSCF in Eq. (3.15), which
is stored at _ph0 in outdir (line 3) for each q point. el_ph_nsigma
(line 13) is the number of the Gaussian broadening values, which
is used for delta functions in Eq. (3.16). el_ph_sigma (line 14) is
the spacing (in Ry) between the Gaussian broadening values. The
remaining part is same as Sec. 3.3.1.
Explanation of q2r.in and matdyn.in: The input files q2r.in and
matdyn.in are the same as Sec. 3.3.1, but the option la2F = .true.
should be added in the namelist INPUT of these input files to obtain
the electron‐phonon coupling along lines between high‐symmetry
points in the Brillouin zone.
 Output file: The output files of both the phonon linewidth
and the electron‐phonon coupling are stored in the files
elph_dir/elph.inp_lambda.* for each q point. For example,
the readers can open the file elph_dir/elph.inp_lambda.1 for the
Γ point as
Quantum ESPRESSO Course for Solid‐State Physics | 105

$ vi elph_dir/elph.inp_lambda .1

QE‑SSP/gr/elph/elph_dir/elph.inp_lambda.1

1 0.000000 0.000000 0.000000 10 6


2 0.119733E-06 0.119733E-06 0.173580E-06 0.638932E-04
0.183390E-03 0.183390E-03
3 Gaussian Broadening: 0.020 Ry , ngauss= 0
4 DOS = 0.122860 states/spin/Ry/Unit Cell at Ef= -4.238911
eV
5 lambda( 1)= 0.3002 gamma= 0.05 GHz
6 lambda( 2)= 0.1533 gamma= 0.02 GHz
7 lambda( 3)= 0.0001 gamma= 0.00 GHz
8 lambda( 4)= 0.0000 gamma= 0.00 GHz
9 lambda( 5)= 1.3810 gamma= 321.60 GHz
10 lambda( 6)= 1.3816 gamma= 321.72 GHz
11 Gaussian Broadening: 0.040 Ry , ngauss= 0
12 DOS = 0.242754 states/spin/Ry/Unit Cell at Ef= -4.244465
eV
13 lambda( 1)= 2.5752 gamma= 0.77 GHz
14 ...

‐ Line 1: The coordinates (qx , qy , qz ) of q, el_ph_nsigma, and the


number of phonon modes 3*nat.
‐ Line 2: ω2νq (in Ry2 ) for each phonon mode ν from 1 to 6.
‐ Line 3: The Gaussian broadening value (in Ry).
‐ Line 4: The DOS at the Fermi energy (in states/spin/Ry/unit‐
cell).
‐ Lines 5 to 10: λνq and γ νq (in GHz) for each ν.
‐ From line 11: The DOS, λνq , and γ νq for next Gaussian broadening
value.
It is noted that only γ νq is interpolated by matdyn.x cal‐
culation for each Gaussian broadening value. The name of this
file is elph.gamma.*. For example, the readers can open the file
elph.gamma.1, which corresponds to the Gaussian broadening =
0.02 Ry, as follows:

$ vi elph.gamma .1

QE‑SSP/gr/elph/elph.gamma.1

1 &plot nbnd= 6, nks= 91 /


2 0.000000 0.000000 0.000000
3 0.0000 -0.0000 0.0000 -0.0000 321.6265 321.6265
106 | Hands‐On Tutorials of Quantum ESPRESSO

4 0.016667 0.000000 0.000000


5 -0.0000 -0.0715 -0.1440 -0.0000 316.9246 316.9963
6 ...

‐ Line 1: nbnd is the number of phonon modes and nks is the


number of q‐points.
‐ Line 2: The crystal coordinates (qx , qy , qz ) of the first q‐point.
‐ Line 3: The values of γ νq for 6 phonon modes.
‐ Next lines: This format from line 2 to line 3 is repeated for 91
q‐points.
 Plotting data from elph.gamma.*: We will select the
elph.gamma.5 file to plot the phonon linewidth γ νq . Other files
can be plotted similarly. First, the readers run the file plotband.in
as

$ plotband.x < plotband.in

QE‑SSP/gr/elph/plotband.in

1 elph.gamma .5
2 -30 300
3 elph.gamma .5. gnu
4 elph.gamma .5.ps
5 0.0
6 0.0 0.0

The plotband.x calculation will read the elph.gamma.5 file, and


output the elph.gamma.5.gnu and elph.gamma.5.ps files. Next,
we will use the elph.gamma.5.gnu file to plot with the JupyterLab
gamma.ipynb as

$ jupyter -lab gamma.ipynb

QE‑SSP/gr/elph/gamma.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5 # Convert from GHz to meV
Quantum ESPRESSO Course for Solid‐State Physics | 107
6 ghz2mev = 4.13567587265e-3
7 # Load elph.gamma .5. gnu file
8 data = np.loadtxt('elph.gamma .5. gnu')
9 k = np.unique(data[:, 0])
10 gamma = np.reshape(data[:, 1], (-1, len(k)))
11 # Set high -symmetry points from matdyn.in
12 gG1 = k[0]; K = k[40]; M = k[60]; gG2 = k[90]
13 # Create figure object
14 plt.figure ()
15 plt.axhline (0, c='gray ', ls=':')
16 # Plot dotted lines at high -symmetry points
17 plt.axvline(K, c='gray ')
18 plt.axvline(M, c='gray ')
19 # Plot phonon linewidth
20 for i in range(len(gamma)):
21 plt.plot(k, gamma[i, :]* ghz2mev , c='r', ls='None
', marker='o', markersize =7)
22 # Add the x and y-axis labels
23 plt.xlabel('')
24 plt.ylabel('Phonon linewidth (meV)')
25 # Set the axis limits
26 plt.xlim(gG1 , gG2)
27 plt.ylim (-0.1, 1.1)
28 # Add labels for high -symmetry points
29 plt.xticks ([gG1 , K, M, gG2], ['$\Gamma$ ', 'K', 'M',
'$\Gamma$ '])
30 # Hide the x-axis minor ticks
31 plt.tick_params(axis='x', which='minor ', bottom=
False , top=False)
32 # Save the figure
33 plt.savefig('plot -gamma.pdf')
34 # Show the figure
35 plt.show ()

In Fig. 3.20, we plot the phonon linewidth γ νq of graphene. At the


Γ point, both the TO and LO modes show the maximum values about
γ νq = 1.0 meV, while at the K point, only the TO shows the maximum
value about γ νq = 0.75 meV. The maximum values of the phonon
linewidth at the Γ and K points are consistent with the observed Kohn
anomaly at the Γ point (TO and LO) and the K point (TO) of graphene,
as discussed in Fig. 3.17 in Sec. 3.3.1.
108 | Hands‐On Tutorials of Quantum ESPRESSO

1.00

Phonon linewidth (meV)


0.75

0.50
TO
0.25
LO
0.00
Γ K M Γ
Figure 3.20 Phonon linewidth of graphene along the high symmetry‐lines of
the Brillouin zone.

Try It Yourself

1. Plot the phonon linewidth γ νq with the Gaussian broaden‐


ing about 0.02, 0.08, 0.14, and 0.2.
2. Calculate the electron‐phonon coupling λνq based on γ νq
from the elph.gamma.5 file by using Eq. (3.17), and plot λνq
along lines between high‐symmetry points in the Brillouin
zone.

3.3.4 Eliashberg spectral function

 Purpose: The Eliashberg spectral function α2 F(ω) is


a sum over the contributions from scattering processes,
in which the electrons are scattered by the phonons
on the Fermi surface [Eliashberg (1960)]. α2 F(ω) is an
important parameter to determine the critical temperature of
superconductors [McMillan (1968)]. In this tutorial, we will
calculate α2 F(ω) of graphene.
 Background: From Eq. (3.17) in Sec. 3.3.3, the isotropic Eliash‐
berg spectral function [Eliashberg (1960)] can be obtained by taking
Quantum ESPRESSO Course for Solid‐State Physics | 109
an average over the Brillouin zone (BZ) as

1
α2 F(ω) =

(3.18)
dq
2 ν
ωνq λνq δ(ω − ωνq ).
BZ ΩBZ

The parameter λ, which is a dimensionless measure of the strength


of α2 F(ω), can also be defined as

α2 F(ω)

λ=2 λνq . (3.19)

dω =
ω νq

The superconducting critical temperature Tc using the McMillan


formula as a function of λ [McMillan (1968)] is given by
 
Tc = , (3.20)
ωln −1.04(1 + λ)
1.2 λ(1 − 0.62μ∗ ) − μ∗
exp

where ωln is defined by [Dynes (1972)]

2
  
α F(ω) log(ω) , (3.21)
dω 2
ωln = exp
λ ω

and μ∗ in Eq. (3.20) is an empirical parameter that describes the


Coulomb screening. μ∗ has typical values between 0.1 and 0.16.
Since α2 F(ω) is obtained by using λνq in Eq. (3.17), the readers
are asked to finish the electron‐phonon calculation in Sec. 3.3.3
before this tutorial.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/alpha/
2 $ cp -rf ../ elph/elph_dir/ ../ elph/gr.fc ./
3 $ mpirun -np 4 matdyn.x < matdyn.in > matdyn.out &

‐ Line 1: Go to alpha directory.


‐ Line 2: Copy the elph_dir directory, which contains γ νq and
λνq in Sec. 3.3.3, and gr.fc, which contains the inter‐atomic force
constants in the real space, to the current direction (./).
‐ Line 3: Run matdyn.x with the input file matdyn.in to obtain
α2 F(ω) and λ.
110 | Hands‐On Tutorials of Quantum ESPRESSO

 How to check: When the calculations finish, you can find a


message JOB DONE at the end of each output file.
 Input file: The input file matdyn.in is same as Sec. 3.3.2. We need
to add the option la2F = .true. and select ndos = 100 (number of
energy steps for DOS calculation) in the namelist INPUT.
 Output file: The Eliashberg spectral function α2 F(ω) is given by
the output files a2F.dos* for each Gaussian broadening. For example,
the readers can open the file a2F.dos1 for the Γ point as follows:

$ vi a2F.dos1

QE‑SSP/gr/alpha/a2F.dos1

1 # Eliashberg function a2F (per both spin)


2 # frequencies in Rydberg
3 # DOS normalized to E in Rydberg: a2F_total , a2F(mode)
4
5 0.739762E-04 -0.382895E-04 0.000000E+00 -0.291145E-04
-0.917506E-05 0.000000E+00 0.000000E+00 0.000000E
+00
6 0.221929E-03 -0.344606E-03 -0.105875E-29 -0.262031E-03
-0.825757E-04 0.000000E+00 0.000000E+00 0.000000E
+00
7 ...

‐ Lines 1–3: The head of the a2F.dos1 file.


‐ Lines 5–6: The 1st column is ω in Ry unit, the 2nd column is
the total of α2 F(ω), the 3rd–7th columns are the α2 F(ω) for the each
phonon mode ν from 1 to 6.
‐ Next lines: The format from lines 5 and 6 is repeated until the last
value of ω.
 Plotting data from a2F.dos*: The readers can plot the file
a2F.dos* as follows:

$ jupyter -lab alpha.ipynb

QE‑SSP/gr/alpha/alpha.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
Quantum ESPRESSO Course for Solid‐State Physics | 111
5
6 # Convert from Ry to cm^-1
7 ry2cm = 109737.07176
8
9 # Load data for the broadening of 0.1 Ry
10 omega1 , aF1 = np.genfromtxt('a2F.dos5 ', usecols
=(0 ,1), skip_footer =1, unpack=True)
11 # Load data for the broadening of 0.2 Ry
12 omega2 , aF2 = np.genfromtxt('a2F.dos10 ', usecols
=(0 ,1), skip_footer =1, unpack=True)
13
14 # Create figure object
15 plt.figure ()
16 # Plot the JDOS
17 plt.plot(omega1* ry2cm , aF1 , c='b', label='Broadening
0.1 Ry')
18 plt.plot(omega2* ry2cm , aF2 , c='r',ls='--', label='
Broadening 0.2 Ry')
19 # Add the x and y-axis labels
20 plt.xlabel(r'$\omega$ (cm$ ^{-1}$)')
21 plt.ylabel(r'$\alpha ^2 F(\ omega)$')
22 # Add the the legend
23 plt.legend(loc='upper left ')
24 # Set the axis limits
25 plt.xlim(0, 1700)
26 plt.ylim(0, 0.45)
27 # Save a figure to the pdf file
28 plt.savefig('plot -aF.pdf')
29 # Show plot
30 plt.show ()

In Fig. 3.21, we plot the total α2 F(ω) as a function of the phonon


frequency ω of graphene with the Gaussian broadening of 0.1 Ry
(solid line) and 0.2 Ry (dashed line). As shown in Fig. 3.20, the TO
and LO modes show the highest electron‐phonon coupling at the Γ
and the K points, which correspond to ω = 1500 cm−1 and 1400
cm−1 , respectively (see Fig. 3.17). Moreover, the phonon DOS in
Fig. 3.19 also shows highest value around ω = 1500 cm−1 . Therefore,
α2 F(ω) becomes a highest value around ω = 1500 cm−1 , as shown in
Fig. 3.21. It is noted that the calculated result of α2 F(ω) might not
be converged since α2 F(ω) converges very slowly with increasing
size of the k‐point and q‐point grids. The readers should check the
convergence by increasing k‐point and q‐point grids, and it is time‐
consuming for electron‐phonon calculation.
112 | Hands‐On Tutorials of Quantum ESPRESSO

Figure 3.21 Electron‐phonon Eliashberg spectral function α2 F(ω) of


graphene with the Gaussian broadening of 0.1 Ry (solid line) and 0.2 Ry
(dashed line).

For the parameters λ and ωln , they are given by the output file
lambda for each Gaussian broadening. The readers can open lambda
as follows:

$ vi lambda

QE‑SSP/gr/alpha/lambda

1 Electron -phonon coupling constant , lambda


2
3 Broadening 0.0200 lambda 0.1516 dos(Ef) 0.1229
omega_ln [K] 3612.2615
4 Broadening 0.0400 lambda 0.0507 dos(Ef) 0.2428
omega_ln [K] 3600.9008
5 ...

This output file shows that λ = 0.1517 and ωln = 3611.6988


K at the broadening of 0.02 Ry. By inserting these values and the
constant μ∗ = 0.1 into Eq. (3.20), we obtain the critical temperature
Tc ∼ 0 for the graphene. This is because that graphene has the DOS =
0 at the Fermi energy. Thus, it is not good for superconductivity.
Nevertheless, graphene can become a superconductor by heavily
electron‐doped or twisted bilayer graphene. For example, Ca‐
intercalated graphite (CaC6) is a superconductor with Tc = 11.5
Quantum ESPRESSO Course for Solid‐State Physics | 113
K [Emery et al. (2009)]. Cao et al. [Cao et al. (2018)] showed that
bilayer graphene with a twist angle of about 1.1◦ shows Tc of up to
1.7.

Try It Yourself

1. Calculate the α2 F(ω) and Tc for the 3D Pb. The 3D Pb has


the structure of face centered cubic and Tc = 7.2 K.
2. Explain why is Tc of the 3D Pb higher than that of graphene?

3.4 Optical properties

In this section, we learn how to calculate the optical properties of


solids, such as optical absorption spectra and non‐resonant Raman
spectra. We select monolayer MoS2 as an example for this section
since it is a semiconductor. It is noted that some optical calculations
in Quantum ESPRESSO work only for semiconductors or insulators.
This is because the metallic system has an infinite dielectric constant
at ω = 0, which is required in some calculations.

3.4.1 Dielectric function and absorption spectra

 Purpose: In this tutorial, we show how to obtain the optical


absorption of the monolayer MoS2 .
 Background: The optical absorption spectra α(ω) can be calcu‐
lated by using the real and imaginary parts of the dielectric function
ε(ω), as shown in Eq. (5.32) in Sec. 5.9. ε(ω) is calculated by using
the the executable epsilon.x in Quantum ESPRESSO. epsilon.x is
based on the single‐particle approximation.8
Note: epsilon.x supports for only the norm‐conserving pseu‐
dopotentials.
 How to run: To run this tutorial, the readers should type the
following command lines:

8 In optical absorption, we have either single‐particle excitation of an electron or

collective excitations of electrons. In single‐particle approximation, we calculate a


sum of independent excitation of an electron from occupied state to empty states.
114 | Hands‐On Tutorials of Quantum ESPRESSO

1 $ cd ~/QE -SSP/mos2/optic/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pw.x < nscf.in > nscf.out &
4 $ mpirun -np 4 epsilon.x < epsilon.in > epsilon.out
&

‐ Line 1: Go to optic directory.


‐ Line 2: Run SCF by using pw.x with the input file scf.in.
‐ Line 3: Run non‐SCF by using pw.x with the input file nscf.in. It
is noted that the non‐SCF calculation might take about 20 minutes.
‐ Line 4: Run epsilon.x with the input file epsilon.in.
 How to check: When calculation finishes, a message JOB DONE
is written at the end of each output file scf.out, nscf.out, and
epsilon.out.
 Input file: The readers can use vi editor to open the input file
scf.in as follows:

$ vi scf.in

QE‑SSP/mos2/optic/scf.in

1 & CONTROL
2 calculation = 'scf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'mos2 '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 3.1378055413
10 c = 20.0
11 nat = 3
12 ntyp = 2
13 ecutwfc = 80.0
14 /
15 & ELECTRONS
16 mixing_beta = 0.7
17 conv_thr = 1.0d-10
18 /
19 ATOMIC_SPECIES
20 Mo 95.94 Mo.pz -hgh.UPF
21 S 32.065 S.pz -hgh.UPF
22 ATOMIC_POSITIONS (crystal)
Quantum ESPRESSO Course for Solid‐State Physics | 115

Figure 3.22 Atomic structure of monolayer MoS2 in a 3 × 3 × 1 supercell.

23 Mo -0.0000000000 -0.0000000000 0.5000000000


24 S 0.3333333333 0.6666666667 0.4218571774
25 S 0.3333333333 0.6666666667 0.5781427066
26 K_POINTS (automatic)
27 6 6 1 0 0 0

 Visualizing structure from scf.in: By using the XCrySDen


software to open the scf.in file, the readers can see the structure
of the monolayer MoS2 , as shown in Fig. 3.22.
For the input file nscf.in, the readers can see it by typing as
follows:

$ vi nscf.in
116 | Hands‐On Tutorials of Quantum ESPRESSO

QE‑SSP/mos2/optic/nscf.in

1 & CONTROL
2 calculation = 'nscf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'mos2 '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 3.1378055413
10 c = 20.0
11 nat = 3
12 ntyp = 2
13 nbnd = 40
14 ecutwfc = 80.0
15 nosym = .true.
16 noinv = .true.
17 /
18 & ELECTRONS
19 mixing_beta = 0.7
20 conv_thr = 1.0d-10
21 /
22 ATOMIC_SPECIES
23 Mo 95.94 Mo.pz -hgh.UPF
24 S 32.065 S.pz -hgh.UPF
25 ATOMIC_POSITIONS (crystal)
26 Mo -0.0000000000 -0.0000000000 0.5000000000
27 S 0.3333333333 0.6666666667 0.4218571774
28 S 0.3333333333 0.6666666667 0.5781427066
29 K_POINTS (automatic)
30 24 24 1 0 0 0

Explanation of nscf.in: It is noted that epsilon.x does not sup‐


port the reduction of the k‐points grid into the irreducible Brillouin
zone.9 Therefore, the non‐SCF calculation must be performed with
a uniform k‐points grid, and all k‐points weights must be equal
to each other. Since the auto‐symmetrization of k‐points grid in
the namelist K_POINTS (automatic) can produce a non‐uniform
distribution of k‐points weights, we need to set nosym = .true.
and noinv = .true. (lines 16 and 17), respectively, in the namelist
SYSTEM to disable the auto‐symmetrization.

9 Irreducible Brillouin zone is the first Brillouin zone, which is reduced by all

symmetries in the point group of the lattice.


Quantum ESPRESSO Course for Solid‐State Physics | 117
Note: For the non‐SCF calculations, the k‐points grid should be
checked carefully to obtain the convergence of the dielectric function.
In particular, for graphene, an extremely high density of k‐points is
needed to obtain accuracy near the Dirac point (for low transition
energies) because the Fermi surface is reduced to a dot. A k‐points
grid of 600 × 600 × 1 might be possible to get a good result. It is
important<to note that the default maximum number of the k‐points
in Quantum ESPRESSO is 40,000. In order to run with the number of
k‐points > 40, 000, the readers need to change the variable “npk” in
Modules/parameters.f90 and recompile the Quantum ESPRESSO
package.
For the input file epsilon.in, the readers can open as follows:

$ vi epsilon.in

QE‑SSP/mos2/optic/epsilon.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'mos2 '
4 calculation = 'eps '
5 /
6 & ENERGY_GRID
7 smeartype = 'gauss '
8 intersmear = 0.15
9 intrasmear = 0.0
10 wmin = 0.0
11 wmax = 10.0
12 nw = 500
13 shift = 0.0
14 /

Explanation of epsilon.in: The dielectric function ε(ω) is cal‐


culated by using the keyword calculation = 'eps' (line 4) in
the namelist INPUTPP. The type of broadening of syntax smeartype
(line 7) can be gauss or lorentz for a Gaussian or Lorentzian
broadening, respectively. intersmear and intrasmear (lines 8
and 9), respectively, are the broadening parameters in eV for the
interband and intraband transitions, respectively. It is noted that we
do not use intrasmear for the semiconductor, but it is mandatory
for a metal, like graphene. The readers should try several values for
118 | Hands‐On Tutorials of Quantum ESPRESSO

intersmear and intrasmear to find a best‐converged value. A good


value should be between 0.1 and 0.2 eV. [wmin, wmax] is the range
of values for the photon energy (in units of eV), which is given by
h̄ω, where h̄ is the reduced Planck constant and ω is the angular
frequency of light. nw (line 12) is the number of points of the photon
energy mesh. Finally, shift (line 13) is an optional rigid shift (in
units of eV) of the imaginary part of the dielectric function. shift
is used when we want to correct the calculated energy band gap with
an experimental value.
Note: outdir and prefix for epsilon.in must be the same as that
for scf.in and nscf.in.
 Output file: There are four output files epsr_mos2.dat,
epsi_mos2.dat, eels_mos2.dat, and ieps_mos2.dat. The first and
second files contain the real Re(ε(ω)) and imaginary Im(ε(ω)) parts
of diagonal part of the dielectric tensor, respectively, as a function
of photon energy h̄ω in eV. The third file contains the electron
energy loss spectra, Im(1/ε(ω)), calculated from the diagonal
elements of the dielectric tensor. The last file contains the diagonal
components of the dielectric tensor, ε(iω), which is calculated on the
imaginary axis of frequency. Let us open the file epsr_mos2.dat as
follows:  Output file: There are four output files epsr_mos2.dat,
epsi_mos2.dat, eels_mos2.dat, and ieps_mos2.dat. The first
and second files two contain the real Re(ε(ω)) and imaginary
Im(ε(ω)) parts of diagonal part of the dielectric tensor, respectively,
as a function of photon energy h̄ω in eV. The third file contains
the electron energy loss spectra, Im(1/ε(ω)), calculated from the
diagonal elements of the dielectric tensor. The last file contains
the diagonal components of the dielectric tensor, ε(iω), which is
calculated on the imaginary axis of frequency. Let us open the file
epsr_mos2.dat as follows:

$ vi epsr_mos2.dat

QE‑SSP/gr/optic/epsr_mos2.dat

1 # energy grid [eV] epsr_x epsr_y epsr_z


2 #
3 0.000000000 4.485200865 4.485200862 2.930873960
4 0.020040080 4.485316552 4.485316549 2.930898420
5 0.040080160 4.485663685 4.485663682 2.930971808
Quantum ESPRESSO Course for Solid‐State Physics | 119
6 ...

‐ Column 1: The photon energies, h̄ω, in units of eV.


‐ Columns 2 to 4: The real parts of the dielectric function,
Re(εxx (ω)), Re(εyy (ω)), and Re(εzz (ω)) in the x‐, y‐, and z‐directions,
respectively.
Other output files can be opened in a similar way.
 Note: For the 2D material, we must reduce the value of Re(ε(ω))
and Im(ε(ω)) by a dimensionless c/L, where c is the height of the unit
cell including the vacuum region and L is the real thickness of the 2D
material. For the monolayer MoS2 , c is 20 Å in scf.in and L = 6.5 Å
is given by the experiment [Eda et al. (2011)].
 Plotting data from epsr_mos2.dat and epsi_mos2.dat: In order
to plot the dielectric function and the absorption coefficient, the
readers can run the JupyterLab eps.ipynb, which reads both real
and imaginary parts of the dielectric function:

$ jupyter -lab eps.ipynb

QE‑SSP/mos2/optic/eps.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5 # Set parameter
6 c = 299792458 # velocity of light (m/s)
7 hbar = 6.582119569e-16 # reduced Planck constant (eV
.s)
8 l = 2.0/0.65 # to reduce thinkness the unit cell (2
nm) to real thickness (0.65 nm)
9 # Load the real part of dielectric tensor
10 ener , repsx , repsy , repsz = np.loadtxt('epsr_mos2.
dat', unpack=True)
11 # Load the imaginary part of dielectric tensor
12 ener , iepsx , iepsy , iepsz = np.loadtxt('epsi_mos2.
dat', unpack=True)
13 # Absorption coefficient in x-, y-, z-directions
14 alphax = 2*( ener/hbar)*np.sqrt ((np.sqrt ((l*repsx)
**2+(l* iepsx)**2) -l* repsx)/2)/c
15 alphay = 2*( ener/hbar)*np.sqrt ((np.sqrt ((l*repsy)
**2+(l* iepsy)**2) -l* repsy)/2)/c
120 | Hands‐On Tutorials of Quantum ESPRESSO

16 alphaz = 2*( ener/hbar)*np.sqrt ((np.sqrt ((l*repsz)


**2+(l* iepsz)**2) -l* repsz)/2)/c
17 # Create figure object
18 fig , (ax1 , ax3) = plt.subplots (1, 2,
constrained_layout =True , figsize =(10, 4))
19 ax2 = ax1.twinx ()
20 # Plot the epsilon
21 ax1.plot(ener , l* repsx , 'b-')
22 ax2.plot(ener , l* iepsx , 'r--')
23 # Add the x and y-axis labels
24 ax1.set_xlabel('Photon energy (eV)')
25 ax1.set_ylabel(r'Re$(\ varepsilon_{xx})$', color='b')
26 ax1.tick_params(axis='y', labelcolor='b')
27 ax2.set_ylabel(r'Im$(\ varepsilon_{xx})$', color='r')
28 ax2.tick_params(axis='y', labelcolor='r')
29 # Set the axis limits
30 ax1.set_xlim (0, 6)
31 ax1.set_ylim (0, 36)
32 ax2.set_ylim (0, 36)
33 # Plot the abosorption coefficient
34 ax3.plot(ener , alphax /10**8 , c='k')
35 # Add the x and y-axis labels
36 ax3.set_xlabel('Photon energy (eV)')
37 ax3.set_ylabel(r'$\alpha_{xx}\ times 10^8$ (1/m)')
38 # Set the axis limits
39 ax3.set_xlim (0, 6)
40 ax3.set_ylim (0, 1.4)
41 # Save the figure
42 plt.savefig('plot -optic.pdf')
43 # Show the figure
44 plt.show ()

By running eps.ipynb, we obtain the in‐plane optical properties


of monolayer MoS2 , as shown in Fig. 3.23. In Fig. 3.23 (a), we plot
the real part and imaginary part of isotropic dielectric function in
the in‐plane with εxx = εyy , in which x‐ and y‐directions correspond to
zigzag and armchair directions, as shown in Fig. 3.22. The dielectric
function shows two peaks A and B (see Fig. 3.23 (a)) around 2 eV,
which correspond to transition energies at the K point of the Brillouin
zone [Li et al. (2014)].10 We highly recommend readers to calculate
the electronic energy dispersion of the monolayer MoS2 (see the

10 Quantum ESPRESSO does not support the calculation of exciton energies.

Nevertheless, peaks A and B show excitation energy. This is because the correction to
the transition energy from the exciton binding energy is largely offset by many‐body
corrections to the band gap in the DFT. Therefore, the predicted transition energy
within a single‐particle calculation is closer to the experiment than might be
expected [Li et al. (2014)].
Quantum ESPRESSO Course for Solid‐State Physics | 121
(a) (b)
C C
C

AB

AB
AB

Figure 3.23 In‐plane optical properties of monolayer MoS2 . (a) Real part
Re(εxx ) and imaginary part Im(εxx ) of the dielectric tensor are plotted by the
solid and dashed lines, respectively. (b) Absorption coefficient in x‐direction,
αxx=yy , of the monolayer MoS2 . It is noted that εxx = εyy and αxx = αyy . The
peaks labeled A and B correspond to transition energies at the K point of the
Brillouin zone, and C peak corresponds to higher‐lying interband transitions,
including the transitions between the K and Γ points.

tutorial in Sec. 3.2.2). By checking the energy dispersion, the readers


will see that the transitions occur at the K point for the photon energy
of 2 eV. For the peak C in Fig. 3.23 (a), the transitions occur between
the K and Γ points in the Brillouin zone. Based on Re(εxx ) and Im(εxx ),
we can obtain the in‐plane absorption coefficient αxx by using the Eq.
5.32, as shown in Fig. 3.23 (b). It is noted that εxx = εyy and αxx = αyy .
The calculated αxx is consistent with the experiment, in which αxx ∼
0.25 × 108 1/m for the peaks A and B, and αxx ∼ 1.0 × 108 1/m for
the peak C [Liu et al. (2020)].

Try It Yourself

1. Change the values of nbnd and the number of k‐points


grid in nscf.in to check the convergence of the dielectric
function of monolayer MoS2 .
2. Change the values of intersmear and check the conver‐
gence of the dielectric function of monolayer MoS2 .
3. Calculate absorption coefficient of graphene. It is noted
that, for graphene, since the Fermi surface is reduced to a
dot at low transition energies, an extremely high density
of k‐points in nscf.in have to be used to achieve accurate
results near the Fermi level.
122 | Hands‐On Tutorials of Quantum ESPRESSO

3.4.2 Joint density of states

 Purpose: In this tutorial, we calculate the joint density of


states (JDOS) to understand the peaks of the absorption spectra in
Sec. 3.4.1.
 Background: As discussed in Sec. 5.9, the JDOS is the number
of states for a pair of the initial and final states by given energy.
Therefore, a large peak in the JDOS corresponds to the peak in the
absorption spectra.11 The JDOS is defined by Eq. (5.34), and the JDOS
is obtained by using the executable epsilon.x.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/mos2/optic/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pw.x < nscf.in > nscf.out &
4 $ mpirun -np 4 epsilon.x < epsilon -jdos.in > epsilon
-jdos.out &

‐ Line 1: Go to optic directory.


‐ Line 2: Run SCF calculation by using pw.x.
‐ Line 3: Run non‐SCF calculation by using pw.x.
‐ Line 4: Run JDOS calculation by using epsilon.x
 Note: The SCF and non‐SCF calculations can be omitted if the
readers have successfully finished the tutorial in Sec. 3.4.1.
 How to check: When the calculations finish, a message JOB DONE
is written at the end of each output file scf.out, nscf.out, and
epsilon-jdos.out.
 Input file: The input files scf.in and nscf.in are shown in
Sec. 3.4.1. For the input file epsilon-jdos.in, the readers can see
by typing as follows:

$ vi epsilon -jdos.in

11 The optical absorption intensity is proportional to the product of JDOS and the

square of the matrix element of the electron‐photon matrix element.


Quantum ESPRESSO Course for Solid‐State Physics | 123
QE‑SSP/mos2/optic/epsilon‑jdos.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'mos2 '
4 calculation = 'jdos '
5 /
6 & ENERGY_GRID
7 smeartype = 'gauss '
8 intersmear = 0.15
9 intrasmear = 0.0
10 wmin = 0.0
11 wmax = 10.0
12 nw = 500
13 shift = 0.0
14 /

Explanation of epsilon‑jdos.in: The JDOS calculation is per‐


formed by using the keyword calculation = 'jdos' (line 4) in the
namelist INPUTPP. The remaining part is same as Sec. 3.4.1.
 Output file: The executable epsilon.x produces the file
jdos_mos2.dat, which contains the photon energy in the first
column in eV and the JDOS in the second column in states/eV/unit‐
cell.
 Plotting data from jdos_mos2.dat: In order to plot the JDOS of
the monolayer MoS2 , the readers can run the JupyterLab jdos.ipynb
as follows:

$ jupyter -lab jdos.ipynb

QE‑SSP/mos2/optic/jdos.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5 # Load data
6 ener , jdos = np.loadtxt('jdos_mos2.dat', unpack=True
)
7 # Create figure object
8 plt.figure ()
9 # Plot the JDOS
10 plt.plot(ener , jdos , c='b')
124 | Hands‐On Tutorials of Quantum ESPRESSO

Figure 3.24 Joint density of states (JDOS) of monolayer MoS2 .

11 # Add the x and y-axis labels


12 plt.xlabel('Energy (eV)')
13 plt.ylabel('JDOS (1/eV/unit -cell)')
14 # Set the axis limits
15 plt.xlim(0, 6)
16 plt.ylim(0, 0.022)
17 # Save the figure
18 plt.savefig('plot -jdos.pdf')
19 # Show the figure
20 plt.show ()

In Fig. 3.24, we show the JDOS of the monolayer MoS2 . Since


the peaks A and B of the absorption coefficient in Fig. 3.23 (b) are
relatively weak, we can not see the corresponding peaks in the JDOS.
Nevertheless, we can see the peak in the JDOS around 3 eV, which
corresponds to the peak C in Fig. 3.23 (b).

Try It Yourself

Change the values of nbnd and the number of k‐points grid in


nscf.in to check the convergence of the JDOS of monolayer
MoS2 .
Quantum ESPRESSO Course for Solid‐State Physics | 125
3.4.3 Non‐resonant Raman spectra

 Purpose: The Raman spectroscopy is a common spectroscopic


technique, which is used to determine phonon modes of a solid.
As discussed in Sec. 5.13, the peak positions of Raman spectra
correspond to the optical phonon frequency of the Raman active
mode. In this tutorial, we show how to plot the non‐resonant Raman
spectra of monolayer MoS2 .
 Background: The Raman calculation in Quantum ESPRESSO is
implemented based on second‐order response of DFT developed
by Lazzeri and Mauri [Lazzeri and Mauri (2003)]. The non‐resonant
Raman intensities are given by Eq. (5.53) in Sec. 5.13, which can be
obtained by using the executable dynmat.x in Quantum ESPRESSO.
It is noted that the calculation is only implemented for norm‐
conserving pseudopotentials and LDA functional. If the material is
a metal, the dielectric function will become infinite, which is not
suitable for non‐resonant Raman calculation, in which we use the
dielectric function. Thus, the non‐resonant Raman calculation works
only for the semiconductor and insulator systems.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/mos2/raman/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 ph.x < ph.in > ph.out &
4 $ mpirun -np 4 dynmat.x < dynmat.in > dynmat.out &

‐ Line 1: Go to raman directory.


‐ Line 2: Run SCF by using pw.x with the input file scf.in.
‐ Line 3: Run phonon by using ph.x with the input file ph.in.
‐ Line 4: Run dynmat.x with the input file dynmat.in.
 How to check: When the calculations finish, a message JOB DONE
is written at the end of each output file scf.out, ph.out, and
dynmat.out.
 Input file: The input file scf.in is shown in Sec. 3.4.1. It is
noted that the option assume_isolated = '2D' (not shown here) is
added to scf.in in the namelist SYSTEM for the phonon calculation of
the 2D materials (see Sec. 3.3.1). For the input file ph.in, the readers
can open with vi editor as follows:
126 | Hands‐On Tutorials of Quantum ESPRESSO

$ vi ph.in

QE‑SSP/mos2/raman/ph.in

1 phonon calc.
2 & INPUTPH
3 outdir = '../tmp/'
4 prefix = 'mos2 '
5 fildyn = 'mos2.dmat '
6 tr2_ph = 1d-14
7 lraman = .true.
8 epsil = .true.
9 trans = .true.
10 asr = .true.
11 /
12 0.0 0.0 0.0

Explanation of ph.in: The non‐resonant Raman calculation is


performed by setting lraman = .true. (line 7) in the namelist
&INPUTPH. We also have to set epsil = .true. (line 8) and
trans = .true. (line 9) to calculate the effective charges. We apply
the acoustic sum rule (see Sec. 3.3.1) for the dynamical matrix by
setting asr = .true. (line 10). Since we only consider the first‐
order Raman scattering, only the Γ point (0.0 0.0 0.0) (line 12) is
calculated.
For the input file dynmat.in, the readers can see by typing as
follows:

$ vi dynmat.in

QE‑SSP/mos2/raman/dynmat.in

1 &INPUT
2 fildyn = 'mos2.dmat '
3 asr = 'crystal '
4 /

 Output file: The output file containing the Raman intensities is


dynmat.out. The readers can use vi editor to open the output as
follows:
Quantum ESPRESSO Course for Solid‐State Physics | 127

$ vi dynmat.out

QE‑SSP/mos2/raman/dynmat.out

IR activities are in (D/A)^2/ amu units


Raman activities are in A^4/ amu units
multiply Raman by 0.256128 for Clausius -Mossotti
correction

# mode [cm -1] [THz] IR Raman depol.fact


1 -0.00 -0.0000 0.0000 0.0018 0.7500
2 -0.00 -0.0000 0.0000 0.2344 0.7500
3 0.00 0.0000 0.0000 0.2361 0.7500
4 283.62 8.5028 0.0000 0.0008 0.7500
5 283.62 8.5028 0.0000 0.0008 0.7500
6 384.72 11.5335 1.2891 178.7551 0.7500
7 384.72 11.5335 1.2891 178.7551 0.7500
8 403.67 12.1018 0.0000 176.8187 0.1061
9 464.86 13.9363 0.0045 0.0000 0.7500

For lines 6 to 14:


‐ Column 1: The ordering numbers of photon modes.
‐ Column 2: The phonon frequencies in units of cm−1 .
‐ Column 3: The infrared (IR) intensities.
‐ Column 4: The Raman intensities.
‐ Column 5: The depolarization ratio factor.12
 Plotting data from dynmat.out: The Raman spectra I(ω) can be
plotted as a smoothed function of the frequency ω by fitting the
Gaussian function, which is defined by
  2 
I(ω) = I0 exp − , (3.22)
ω − ω0
Γ

where ω0 and I0 are the phonon frequencies and Raman intensities,


respectively, which are obtained from the dynmat.out file. Γ is a
broadening parameter, which can be obtained by the full width at
half maximum (FWHM) in the experiment.13 We run the JupyterLab
raman.ipynb to plot the Raman spectra as follows:

12 Depolarization ratio is the intensity ratio of the perpendicular component to the

parallel component for the Raman peak intensity.


13 FWHM is inversely proportional to phonon lifetime. A typical value of the FWHM is

10 cm−1 , whose phonon lifetime is 2 ps.


128 | Hands‐On Tutorials of Quantum ESPRESSO

$ jupyter -lab raman.ipynb

QE‑SSP/mos2/raman/raman.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5 # Define the Gaussian function
6 def gaussian(w, G, w0 , I0):
7 return I0*np.exp(-((w-w0)/G)**2)
8 # Peaks list of non -resonant Raman in dynmat.out
9 peak =[(384.72 ,178.7551) ,(403.67 ,176.8187)]
10 # Fitting with the Gaussian function
11 def fit(w, G):
12 fit = gaussian(w, G, 0, 0)
13 for w0 , I0 in peak:
14 fit = fit + gaussian(w, G, w0 , I0)
15 return fit
16 w = np.linspace (300, 500, 500)
17 # Create figure object
18 plt.figure ()
19 # Plot the non -resonant Raman
20 plt.plot(w, fit(w,2), c='b')
21 # Add the x and y-axis labels
22 plt.xlabel('Raman shift (cm$ ^{-1}$)')
23 plt.ylabel('Intensity (a.u.)')
24 # Hide y-axis minor ticks
25 plt.tick_params(axis='y', which='both ', right=False ,
left=False , labelleft=False)
26 plt.tick_params(axis='x', which='both ',top=False)
27 # Set the axis limits
28 plt.xlim (370, 420)
29 # Save the figure
30 plt.savefig('plot -raman.pdf')
31 # Show the figure
32 plt.show ()

In Fig. 3.25, we plot the non‐resonant Raman spectra of


monolayer MoS2 . The calculated result shows the two peaks at
385 cm−1 and 404 cm−1 , which correspond to the E12g and A1g
Raman active modes [Li et al. (2012)]. These peaks have the same
intensity and it is consistent with the experimentally observed
Raman spectra (∼ 384 cm−1 and ∼ 403 cm−1 for the E12g and A1g
modes, respectively [Li et al. (2012)]).
Quantum ESPRESSO Course for Solid‐State Physics | 129

Figure 3.25 Non‐resonant Raman spectra of monolayer MoS2 .

Try It Yourself

1. Change lattice constant a in the scf.in of monolayer MoS2 ,


and plot the Raman spectra as a function of the lattice
constant.
2. Calculate non‐resonant Raman spectra of bulk Si.

3.5 Subjects for two‐dimensional materials

This section will calculate three important tutorials for two‐


dimensional (2D) materials: the spin‐orbit coupling in the monolayer
MoS2 , the van der Waals interaction of bilayer graphene, and an
external electric field to bilayer graphene. These calculations can
modify the electronic energy dispersion and the optimized structure
of the materials.
130 | Hands‐On Tutorials of Quantum ESPRESSO

3.5.1 Spin‐orbit coupling

 Purpose: In Sec. 3.4, the monolayer MoS2 is calculated without


spin‐orbit coupling14 (SOC). However, it is observed that the
SOC leads to the band splitting in the valence bands at the K
points [Roch et al. (2019)] for the monolayer MoS2 . In this tutorial,
we show how to calculate the band splitting of the monolayer MoS2
in the presence of the SOC.
 Background: Since the SOC is a relativistic effect, we
need to use the fully relativistic pseudopotentials (PPs) for
SOC calculation. As shown in Sec. 3.1.6, the fully relativistic
PPs can be obtained from the PSlibrary (https://www.
quantum-espresso.org/pseudopotentials/ps-library). In
this tutorial, we select Mo.rel-pbe-spn-rrkjus_psl.1.0.0.UPF
and S.rel-pbe-nl-rrkjus_psl.1.0.0.UPF for the Mo and S
atoms, respectively.
 Note: Some calculation does not support the fully relativistic
PPs, for example, the optimizing structure (relax or vc-relax).
Therefore, the readers should optimize the structure by using
scalar relativistic PPs, such as Mo.pbe-spn-rrkjus_psl.1.0.0.UPF
and S.pbe-nl-rrkjus_psl.1.0.0.UPF for the Mo and S atoms,
respectively. Then, replacing the scalar relativistic PPs with the fully
relativistic PPs for the SOC calculation.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/mos2/soc/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pw.x < nscf.in > nscf.out &
4 $ mpirun -np 4 bands.x < bands.in > bands.out &

‐ Line 1: Go to soc directory.


‐ Line 2: Run SCF calculation by using pw.x.
‐ Line 3: Run non‐SCF calculation by using pw.x.
‐ Line 4: Run bands.x with the input file bands.in.

14 The spin‐orbit coupling is a relativistic interaction between a spin and an orbital

angular momentum of an electron.


Quantum ESPRESSO Course for Solid‐State Physics | 131
 How to check: When the calculations finish, a message JOB DONE
is written at the end of each output file scf.out, nscf.out, and
bands.out.
 Input file: For the input file scf.in, the readers can open with vi
editor as follows:

$ vi scf.in

QE‑SSP/mos2/soc/scf.in

1 & CONTROL
2 calculation = 'scf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'mos2 '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 3.1825188839
10 c = 20.0
11 nat = 3
12 ntyp = 2
13 ecutwfc = 60.0
14 noncolin = .true.
15 lspinorb = .true.
16 /
17 & ELECTRONS
18 mixing_beta = 0.7
19 conv_thr = 1.0d-6
20 /
21 ATOMIC_SPECIES
22 Mo 95.94 Mo.rel -pbe -spn -rrkjus_psl .1.0.0. UPF
23 S 32.065 S.rel -pbe -nl -rrkjus_psl .1.0.0. UPF
24 ATOMIC_POSITIONS (crystal)
25 Mo 0.0000000000 0.0000000000 0.5000000000
26 S 0.3333333333 0.6666666667 0.4217548051
27 S 0.3333333333 0.6666666667 0.5782450789
28 K_POINTS (automatic)
29 6 6 1 0 0 0

Explanation of scf.in: The SOC calculation is performed by setting


noncolin = .true. and lspinorb = .true. (lines 14 and 15),
respectively. The first setting allows a non‐collinear calculation, and
the second one allows using a PP with spin‐orbit such as fully
relativistic PP. In collinear calculation, up‐ or down‐spin is taken
132 | Hands‐On Tutorials of Quantum ESPRESSO

into account on the calculation. In non‐collinear calculation, the spin


direction can be taken in any direction. If all PPs are scalar relativistic,
the calculation is non‐collinear, but there is no SOC.
For the input file nscf.in, the readers can open as follows:

$ vi nscf.in

QE‑SSP/mos2/soc/nscf.in

1 & CONTROL
2 calculation = 'bands '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'mos2 '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 3.1825188839
10 c = 20.0
11 nat = 3
12 ntyp = 2
13 nbnd = 60
14 ecutwfc = 60.0
15 noncolin = .true.
16 lspinorb = .true.
17 /
18 & ELECTRONS
19 mixing_beta = 0.7
20 conv_thr = 1.0d-6
21 /
22 ATOMIC_SPECIES
23 Mo 95.94 Mo.rel -pbe -spn -rrkjus_psl .1.0.0. UPF
24 S 32.065 S.rel -pbe -nl -rrkjus_psl .1.0.0. UPF
25 ATOMIC_POSITIONS (crystal)
26 Mo 0.0000000000 0.0000000000 0.5000000000
27 S 0.3333333333 0.6666666667 0.4217548051
28 S 0.3333333333 0.6666666667 0.5782450789
29 K_POINTS (crystal_b)
30 4
31 gG 40
32 K 20
33 M 30
34 gG 0

Note for nscf.in: Since we consider both spin‐up and spin‐down


of an electron, the number of Kohn‐Sham states (nbnd) should be
Quantum ESPRESSO Course for Solid‐State Physics | 133
(a) With SOC (b) Without SOC

Δ = 0.15 eV

Figure 3.26 Electronic band structure of monolayer MoS2 (a) with SOC and
(b) without SOC.

selected more than twice the number of electrons. Here, we set


nbnd = 60 (line 13) since there are 26 electrons in the monolayer
MoS2 , which can be found in the scf.out file.
For the input file bands.in, the readers can open as follows:

$ vi bands.in

QE‑SSP/mos2/soc/bands.in

1 &BANDS
2 outdir = '../tmp/'
3 prefix = 'mos2 '
4 filband = 'mos2.bands '
5 /

 Plotting band structure with SOC: The band structure including


the SOC is given by output file mos2.bands.gnu. To plot this output
file, the readers can run JupyterLab plot-bands.ipynb as follows:

$ jupyter -lab plot -bands.ipynb

It is noted that plot-bands.ipynb is obtained from the


Python script in page 77 (Sec. 3.2.2) by changing the filename to
134 | Hands‐On Tutorials of Quantum ESPRESSO

mos2.bands.gnu and the value of the Fermi energy to -0.0925. By


running plot-bands.ipynb, we obtain the band structure of the
monolayer MoS2 with the SOC, as shown in Fig. 3.26 (a). Compared
with the band structure without SOC in Fig. 3.26 (b), we can see
that the electronic bands split by the spin‐orbit interaction that
is generally larger in the valence band than in the conduction
band. The split bands have the energy difference, Δ, because the
two electronic states with spin‐up and spin‐down are separated.
As discussed above, we can not separate spin‐up and spin‐down
in the band structure for non‐collinear calculation. The largest
value Δ = 0.15 eV is found at the K point for the valence bands,
which reproduces the experimental value for bulk MoS2 (Δ = 0.17
eV [Latzke et al. (2015)]).

Try It Yourself

1. Calculate band structure of monolayer MoS2


without SOC by selecting noncolin = .false. and
lspinorb = .false. with the scalar relativistic PPs. The
band structure will be obtained as shown in Fig. 3.26 (b).
2. Calculate the spin‐orbit splitting (Δ) of monolayer WSe2 ,
and discuss the reason why Δ of monolayer WSe2 is larger
than that of monolayer MoS2 ?

3.5.2 Van der Waals interaction

 Purpose: Van der Waals (vdW) interaction is a weak attractive


interaction between induced dipole moments that occurs even
where there is no overlap between electron densities. Therefore, the
vdW interaction is important for stacking layered materials. In this
tutorial, we check the effect of the vdW interaction by calculating
the interlayer distance of the bilayer graphene. We use the bilayer
graphene with the AB‐stacking (Bernal) structure, as shown in
Fig. 3.27.
 Background: The vdW energy should be included in the total
energy calculated by the exchange‐correlation functional. However,
the exchange‐correlation functionals, such as LDA and GGA, do not
describe the vdW energy since the LDA and GGA assume overlapping
Quantum ESPRESSO Course for Solid‐State Physics | 135

Interlayer
distance

Figure 3.27 Atomic structure of bilayer graphene with the AB‐stracking in a


3 × 3 × 1 supercell.

electron densities (see Sec. 3.1.1). Therefore, several methods have


been developed to solve this problem. Each method has a different
way of calculating vdW energy from others. Details of each method
are listed as follows:
DFT‑D: It is empirically known that the vdW energy is described
by damped inter‐atomic potential, which is proportional to 1/R6 ,
where R is the inter‐atomic distance [Grimme (2004)]. Thus, a simple
method is that we add an energy term with 1/R6 into the total energy
as

EDFT‐D = EDFT + EvdW , (3.23)

where EvdW denotes the vdW energy. EvdW is given by

s6  CIJ6
EvdW = − fd (RIJ ), (3.24)
2
I̸=J
R6IJ
136 | Hands‐On Tutorials of Quantum ESPRESSO

where s6 is a global scaling factor depending on the specific GGA


and CIJ6 denotes the dispersion coefficient for atom pair IJ. The CIJ6
coefficients are taken by a least‐square fitting procedure from the
work of Wu and Yang [Wu and Yang (2002)]. fd (RIJ ) is a damping
function, which is given by [Grimme (2004)]:

1
fd (RIJ ) = , (3.25)
1+ e−d(RIJ /Rr −1)

where the parameters d and Rr are fitted to experimental or


accurate theoretical data. The DFT‐D method is an inexpensive
and straightforward calculation, but it is not a fully first‐principles
approach.
DFT‑D3: This method is a refined model of the DFT‐
D method with more parameters and more interaction
terms [Grimme et al. (2010)].
Tkatchenko‑Scheffler (TS): For the TS method, the CIJ6
coefficients in Eq. (3.24) are computed from the ground‐
state electron density and reference values for the free
atoms [Tkatchenko and Scheffler (2009)].
Exchange‑dipole model (EDM): The EDM shows another
way to obtain the CIJ6 coefficients in Eq. (3.24) based on
second‐order perturbation theory [Becke and Johnson (2007),
Otero‐De‐La‐Roza and Johnson (2012)], which is referred to as
exchange‐dipole model.
Nonlocal vdW functionals: This method replaces the vdW
energy term EvdW in Eq. (3.23) by a nonlocal energy functional of the
electron density n(r), which is given by a six‐dimensional integral as

1
Enl n(r)Φ(r, r′ )n(r′ )drdr′ ,

(3.26)
vdW [n(r)] =
2

where Φ(r, r′ ) is a function depending on r − r′ and the


densities n in the vicinity of r and r′ [Dion et al. (2004)].
Several nonlocal vdW functionals have been proposed, such
as vdW‐DF [Dion et al. (2004), Thonhauser et al. (2015)], vdW‐
DF2 [Lee et al. (2010)], vdW‐DF3‐opt1 [Chakraborty et al. (2020)],
vdW‐DF3‐opt2 [Chakraborty et al. (2020)], vdW‐DF‐
C6 [Berland et al. (2019)], or rVV10 [Sabatini et al. (2013)]. A
Quantum ESPRESSO Course for Solid‐State Physics | 137
full list of the nonlocal vdW functionals that are supported by
Quantum ESPRESSO can be found in Modules/funct.f90.
Since the nonlocal vdW functionals implemented in Quantum
ESPRESSO are sufficiently fast and can be calculated at almost the
same cost as LDA and GGA, we recommend using the nonlocal vdW
functionals (vdW‐DF, rVV10, etc.) for calculating the vdW interaction.
Therefore, in this tutorial, we consider only the nonlocal vdW
functionals to optimize the structure of bilayer graphene.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/bi -gr/vdw/


2 $ ./run.sh &

‐ Line 1: Go to vdw directory.


‐ Line 2: Run a bash script file run.sh, which generates and runs
many jobs with changing the vdW functionals in scf.in.
 How to check: To check whether or not the output file exists, the
readers can use the ls command by typing:

$ ls

The ls displays a listing of the all files in the vdw folder as

run.sh vc -relax.vdw -df3 -opt1.out


vc -relax.pbe.in vc -relax.vdw -df3 -opt2.in
vc -relax.pbe.out vc -relax.vdw -df3 -opt2.out
vc -relax.rvv10.in vc -relax.vdw -df -C6.in
vc -relax.rvv10.out vc -relax.vdw -df -C6.out
vc -relax.vdw -df2.in vc -relax.vdw -df.in
vc -relax.vdw -df2.out vc -relax.vdw -df.out
vc -relax.vdw -df3 -opt1.in

 Input file: All input files are generated automatically by a bash


script file run.sh as

QE‑SSP/bi‑gr/vdw/run.sh

1 #!/bin/bash
2 # Set a variable vdw for 1 GGA and 6 vdW functionals
.
138 | Hands‐On Tutorials of Quantum ESPRESSO

3 for vdw in pbe vdw -df vdw -df2 vdw -df3 -opt1 \
4 vdw -df3 -opt2 vdw -df -C6 rvv10; do
5 # Make input file for the vc -relax calculation.
6 cat > vc -relax.$vdw.in << EOF
7 & CONTROL
8 calculation = 'vc -relax '
9 pseudo_dir = '../ pseudo/'
10 outdir = '../tmp/'
11 prefix = 'bi -gr '
12 etot_conv_thr = 1.0D-5
13 forc_conv_thr = 1.0D-4
14 /
15 &SYSTEM
16 ibrav = 4
17 a = 2.4639055825
18 c = 20.0
19 nat = 4
20 ntyp = 1
21 occupations = 'smearing '
22 smearing = 'mv '
23 degauss = 0.02
24 ecutwfc = 60
25 input_dft = '$vdw '
26 /
27 & ELECTRONS
28 mixing_beta = 0.7
29 conv_thr = 1.0D-9
30 /
31 &IONS
32 ion_dynamics = 'bfgs '
33 /
34 &CELL
35 cell_dynamics = 'bfgs '
36 press_conv_thr= 0.05
37 cell_dofree = '2Dxy '
38 /
39 ATOMIC_SPECIES
40 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
41 ATOMIC_POSITIONS (crystal)
42 C 0.000000000 0.000000000 0.412500000
43 C 0.333333333 0.666666666 0.412500000
44 C 0.000000000 0.000000000 0.587500000
45 C 0.666666666 0.333333333 0.587500000
46 K_POINTS (automatic)
47 8 8 1 0 0 0
48 EOF
49 # Run pw.x for vc -relax calculation.
50 mpirun -np 4 pw.x <vc -relax.$vdw.in > vc -relax.$vdw.
out
Quantum ESPRESSO Course for Solid‐State Physics | 139
51 # End of for loop.
52 done

 Explanation of run.sh: Six nonlocal vdW functionals (vdW‐DF,


vdW‐DF2, vdW‐DF‐opt1, vdW‐DF‐opt2, vdW‐DF‐C6, and rVV10) are
calculated in this tutorial. These vdW functionals are controlled by
setting input_dft = $vdw (line 26) in the namelist SYSTEM, in which
the values of $vdw (line 3) are selected as a loop of vdw. For the case
of input_dft = pbe, the bilayer graphene is calculated by the GGA
without the vdW correction. It is noted that, in order to apply other
methods DFT‐D, DFT‐D3, TS, and EMD, input_dft = $vdw should be
replaced by vdw_corr = $vdw with vdw = dft-d, dft-d2, ts, and
emd, respectively.
Note: If the readers are using the Quantum ESPRESSO version <
6.5, the readers might get an error in the output as follows:
>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
from read_kernel_table : error # 1
No \" vdW_kernel_table \" file could be found
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

In order to solve this error, the readers need to run:


<
<Quantum ESPRESSO-PATH>/bin/generate_vdW_kernel_table.x
to generate the vdW_kernel_table file. For the the Quantum
ESPRESSO version > 6.5, the vdW_kernel_table is no longer
needed for calculation.
 Output file: The interlayer distance d can be obtained from
the optimized structures from the output files vc-relax.*.out. In
Fig. 3.28, we show d − dexp for the PBE and the vdW functionals,
in which dexp = 3.48 Å is taken by the experimental value of
bilayer graphene [Razado‐Colambo et al. (2018)]. Without the vdW
correction (or the PBE case), d is larger than the experimental value
dexp = 3.48 Å about 0.77 Å. With the vdW correction, d becomes close
to dexp , and the closest value is 0.06 Å of vdW‐DF2. We note that
even vdW‐DF2 shows a good vdW functional for the case of bilayer
graphene, there is no strict guideline for the proper use of the vdW
functionals. Therefore, for any system, the readers should carefully
select several vdW functionals to find the suitable one.
140 | Hands‐On Tutorials of Quantum ESPRESSO

Figure 3.28 Interlayer distance d of bilayer graphene is calculated with PBE


and 6 nonlocal vdW functionals. The experimental value dexp of bilayer
graphene is 3.48 Å [Razado‐Colambo et al. (2018)].

Try It Yourself

Calculate the interlayer distance d of the 3D MoS2 with the


vdW correction, and find the suitable vdW functional for
the 3D MoS2 . The experimental value of d for MoS2 is 6.15
Å [Rasamani et al. (2017)].

3.5.3 External electric field

 Purpose: The bilayer graphene in Sec. 3.5.3 has a zero band gap.
However, the band gap can be tuned by applying an external electric
field perpendicular to the graphene layer, in which a band gap is
opened at the Dirac point. In this tutorial, we show how to obtain the
electrostatic potential and the band structure of the bilayer graphene
under the external electric field.
 Background: In Quantum ESPRESSO, an external electric field E
can be applied for a 2D system by using a saw‐tooth potential Vext , as
shown in Fig. 3.29. Assuming that the 2D material is set to be in the
Quantum ESPRESSO Course for Solid‐State Physics | 141

2D material

E* E
Vext(z)

Vacuum Vacuum

c Z
emaxpos ℓ
emaxpos + eopreg

Figure 3.29 Schematics of saw‐tooth potential. The dark area represents the
2D material and the light gray spaces are the vacuums in the unit cell. The
solid lines with labels E and E∗ denote the linear external electric potential
and its counterpart, respectively. c is the size of the periodic cell along z
direction, and ℓ is the length of external electric potential. emaxpos and
eopreg are input parameters for Quantum ESPRESSO.

xy plane and E is applied in the z direction, Vext is defined by

Vext (z) = −eEz. (3.27)

If Vext (z) changes monotonically, Vext (z) would violate periodic


boundary conditions. In order to satisfy periodic boundary condi‐
tions, we need to change the electric field in some irrelevant region
(e.g., in the vacuum far from any surfaces), so that the potential
restores its original value on the boundary. In Fig. 3.29, we show the
schematic of the saw‐tooth potential Vext (z) in the z direction with the
unit cell containing 2D material (shaded area). As shown in Fig. 3.29,
the external electric field E changes abruptly in the vacuum. The saw‐
tooth potential also leads to an artificial field E∗ , which is always
opposite to E and given by

E∗ = −E , (3.28)
c−ℓ

where ℓ and c are the length of the external electric field E and the
size of the unit cell in the z direction, respectively.
We note that the unit cell of the 2D material contains a dipole
moment in the vacuum space. In particular, when the bottom and top
layers of the 2D material are not equivalent to each other, there is a
142 | Hands‐On Tutorials of Quantum ESPRESSO

dipole moment between these layers due to the periodic boundary


conditions. This dipole moment introduces an artificial electric field
in the z direction of the unit cell. In Quantum ESPRESSO, a dipole
correction can be applied to suppress the artificial dipole field
by introducing an additional ramp‐shaped potential Vdip . Assuming
that the 2D material is set to be in the xy plane, Vdip is given
by [Bengtsson (1999)]:

z 1
 
Vdip (z) = 4πm , (3.29)
c 2

where m is a surface dipole moment. The dipole correction


introduces a jump in electrostatic potential which should be placed
within the vacuum region of the cell.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/bi -gr/elec -field/


2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 pp.x < pp.in > pp.out &
4 $ average.x < average.in > average.out &
5 $ mpirun -np 4 pw.x < nscf.in > nscf.out &
6 $ mpirun -np 4 bands.x < bands.in > bands.out &

‐ Line 1: Go to elec-field directory.


‐ Line 2: Run SCF calculation by using pw.x.
‐ Line 3: Run pp.x to obtain the electrostatic potential.
‐ Line 4: Run average.x to obtain the planar‐average potential
along the z direction from the electrostatic potential. It is noted that
this program supports for only single processor.
‐ Line 5: Run non‐SCF calculation by using pw.x.
‐ Line 6: Run bands.x to obtain the band structure.
 How to check: When the calculations finish, a message JOB DONE
is written at the end of each output file scf.out, pp.out,
average.out, nscf.out, and bands.out.
 Input file: For the input file scf.in, the readers can open with vi
editor as follows:

$ vi scf.in
Quantum ESPRESSO Course for Solid‐State Physics | 143
QE‑SSP/bi‑gr/elec‑field/scf.in

1 & CONTROL
2 calculation = 'scf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'bi -gr '
6 tefield = .true.
7 dipfield = .true.
8 /
9 &SYSTEM
10 ibrav = 4
11 a = 2.4857910097
12 c = 20.0
13 nat = 4
14 ntyp = 1
15 occupations = 'smearing '
16 smearing = 'mv '
17 degauss = 0.02
18 ecutwfc = 80
19 input_dft = 'vdw -df2 '
20 edir = 3
21 emaxpos = 0
22 eopreg = 0.05
23 eamp = 0.0097234527
24 /
25 & ELECTRONS
26 mixing_beta = 0.7
27 conv_thr = 1.0D-9
28 /
29 ATOMIC_SPECIES
30 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
31 ATOMIC_POSITIONS (crystal)
32 C 0.0000000000 0.0000000000 0.4115083725
33 C 0.3333333333 0.6666666667 0.4114773543
34 C 0.0000000000 0.0000000000 0.5884916275
35 C 0.6666666667 0.3333333333 0.5885226457
36 K_POINTS (automatic)
37 8 8 1 0 0 0

Explanation of scf.in: The external electric field and the dipole


correction are performed by setting tefield = .true. and
dipfield = .true. (lines 6 and 7), respectively, in the namelist
CONTROL. For the direction of the electric field or dipole correction
is parallel to the z‐direction, we set edir = 3 (line 20). The atomic
structure (lines 32–35) of the bilayer graphene was optimized by
using the van der Walls correction (vdW‐DF2), as shown in Sec. 3.5.2,
144 | Hands‐On Tutorials of Quantum ESPRESSO

in which the positions of the C atoms are located at the center of the
unit cell. Thus, as shown in Fig. 3.29, the position of the maximum
of the saw‐tooth potential will be set to 0 by emaxpos = 0 (line
21). We set the width of the window, where the saw‐tooth potential
decreases, about 1 Å by eopreg = 0.05 (line 22). We note that
emaxpos and eopreg have the unit of c = 20 Å. The magnitude of the
electric field is set to 0.5 V/Å by eamp = 0.0097234527 (line 23), in
which eamp has the unit of a.u. (1 V/Å= 0.0194469054 a.u.).
Note: For the external electric field, the readers should use a
large value of ecutwfc (line 18). For example, if the readers use
ecutwfc = 60, the readers might get an error in scf.out as follows:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error in routine electrons (1):
charge is wrong
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

For the input file pp.in, the readers can open as follows:

$ vi pp.in

QE‑SSP/bi‑gr/elec‑field/pp.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'bi -gr '
4 filplot = 'bi -gr.dat '
5 plot_num = 11
6 /

Explanation of pp.in: In order to plot the electrostatic potential


that considers the bare potential (local part of the ionic potential) and
Hartree potential, we set plot_num = 11 (line 5). The name of the
output file of the potential is set by filplot = 'bi-gr.dat' (line
4).
For the input file average.in, the readers can open as follows:

$ vi average.in
Quantum ESPRESSO Course for Solid‐State Physics | 145
QE‑SSP/bi‑gr/elec‑field/average.in

1 1
2 bi -gr.dat
3 1.0
4 300
5 3
6 3.0

Explanation of average.in: The program average.x from Quan‐


tum ESPRESSO is used to calculate the planar‐ and macroscopic‐
average potential from the potential file bi-gr.dat that is generated
by pp.x. The input variables of average.in are given as follows:
‐ Line 1: The number of files containing the desired quantities.
‐ Line 2: The name of the file.
‐ Line 3: The weight of the quantity read from file.
‐ Line 4: The number of points for the final interpolation of the
planar‐ and macroscopic‐average.
‐ Line 5: The direction (1, 2, and 3 correspond to x‐, y‐, and z‐
direction, respectively), in which the planar‐average is calculated in
the plane orthogonal to this direction.
‐ Line 6: The size of the window for macroscopic average (a.u.).
For the input file nscf.in, the readers can open as follows:

$ vi nscf.in

QE‑SSP/bi‑gr/elec‑field/nscf.in

1 & CONTROL
2 calculation = 'bands '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'bi -gr '
6 tefield = .true.
7 dipfield = .true.
8 /
9 &SYSTEM
10 ibrav = 4
11 a = 2.4857910097
12 c = 20.0
13 nat = 4
14 ntyp = 1
146 | Hands‐On Tutorials of Quantum ESPRESSO

15 nbnd = 30
16 occupations = 'smearing '
17 smearing = 'mv '
18 degauss = 0.02
19 ecutwfc = 80
20 input_dft = 'vdw -df2 '
21 edir = 3
22 emaxpos = 0
23 eopreg = 0.05
24 eamp = 0.0097234527
25 /
26 & ELECTRONS
27 mixing_beta = 0.7
28 conv_thr = 1.0D-9
29 /
30 ATOMIC_SPECIES
31 C 12.0107 C.pbe -n-rrkjus_psl .0.1. UPF
32 ATOMIC_POSITIONS (crystal)
33 C 0.0000000000 0.0000000000 0.4115083725
34 C 0.3333333333 0.6666666667 0.4114773543
35 C 0.0000000000 0.0000000000 0.5884916275
36 C 0.6666666667 0.3333333333 0.5885226457
37 K_POINTS (crystal_b)
38 4
39 gG 40
40 K 20
41 M 30
42 gG 0

For the input file nscf.in, the readers can open as follows:

$ vi bands.in

QE‑SSP/bi‑gr/elec‑field/bands.in

1 &BANDS
2 outdir = '../tmp/'
3 prefix = 'bi -gr '
4 filband = 'bi -gr.bands '
5 /

 Output file: The planar‐average of electrostatic potential is


written in avg.dat, which is output file of average.x. The readers
can use vi editor to see the avg.dat file as following:
Quantum ESPRESSO Course for Solid‐State Physics | 147

$ vi avg.dat

QE‑SSP/bi‑gr/elec‑field/avg.dat

1 0.000000000 0.550530876 0.441707911


2 0.125981742 0.519365693 0.424317560
3 0.251963483 0.477007077 0.405271088
4 0.377945225 0.443319530 0.384610570
5 ...

‐ Column 1: The coordinate (a.u) along z direction.


‐ Column 2: The planar‐averaged potential in units of Ry.
‐ Column 2: The macroscopic‐averaged potential in units of Ry.
 Plotting data from avg.dat: The planar‐averaged electrostatic
potential is plotted by running plot-potential.ipynb, which reads
the data from the avg.dat file:

$ jupyter -lab plot -potential.ipynb

QE‑SSP/bi‑gr/elec‑field/plot‑potential.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../../ matplotlib/sci.mplstyle ')
4 import numpy as np
5
6 # Load data
7 z, V = np.loadtxt('avg.dat', usecols =(0 ,1), unpack=
True)
8 # Convert a.u. to Angstrom
9 au2a = 0.529177249
10
11 # Create figure object
12 plt.figure(figsize =(4.5 ,4.5))
13 # Plot the data , using blue color
14 plt.plot(z* au2a , V, c='b')
15 # Plot a dashed line at zero
16 plt.axhline (0, c='gray ', ls='--')
17 # Set the axis limits
18 plt.xlim(0, 20)
19 plt.ylim(-3, 1)
20 # Add the x and y-axis labels
21 plt.xlabel('z ($\AA$)')
22 plt.ylabel('Electrostatic potential (Ry)')
148 | Hands‐On Tutorials of Quantum ESPRESSO

(a) E = 0.5 V/Å (b) E = 0.0 V/Å

Figure 3.30 Planar‐averaged electrostatic potential along the z direction of


bilayer graphene with an external electric field E of (a) 0.5 V/Å and (b) 0.0
V/Å.

23 # Save the figure


24 plt.savefig('plot -V.pdf')
25 # Show the figure
26 plt.show ()

By running plot-potential.ipynb, we obtain the planar‐


averaged electrostatic potential along the z direction of bilayer
graphene in the presence of E = 0.5 V/Å, as shown in Fig. 3.30 (a).
There are two minimum values of the electrostatic potential at z =
8.2 Å and 11.8 Å, which correspond to the positions of each graphene
layer. We can see that the saw‐tooth potential decreases from z = 0
Å to 1 Å and increases from z = 1 Å to 20 Å. In contrast, for E =
0.0 V/Å, the electrostatic potential does not change in the vacuum
region, as shown in Fig. 3.30 (b). If the readers want to calculate
the electrostatic potential without the external electric field (E = 0.0
V/Å), the readers can set eamp = 0.0 (line 23) in the scf.in file.
 Plotting data band structure: The band structure is given by
bi-gr.bands.gnu, which is the output file of bands.x. In a similar
way to plot band structure of single‐layer graphene in Sec. 3.2.2,
the readers can run the file plot-bands.ipynb to plot the band
structure of the bilayer graphene. In Fig. 3.31 (a) and (b), we show
the band structures of the bilayer graphene for E = 0.5 V/Å and 0.0
V/Å, respectively. If there is no external electric field (i.e., E = 0.0
V/Å), the bilayer graphene has zero‐gap, as shown in Fig. 3.31 (b),
Quantum ESPRESSO Course for Solid‐State Physics | 149
(a) E = 0.5 V/Å (b) E = 0.0 V/Å

0.3 eV

Figure 3.31 Electronic band structures of bilayer graphene with an external


electric field E of (a) 0.5 V/Å and (b) 0.0 V/Å. In the presence of E, a band gap
is opened at the K point for the bilayer graphene.

which is similar to the case of single‐layer graphene. However, if the


electric field is applied perpendicular to bilayer graphene, the two
layers are no longer identical. Therefore, the two 2pz orbitals around
the Fermi energy change the energies since the electric field affects
the pz orbital, but not for the px and py orbitals, which are parallel
to the graphene plane. The band gap thus increases by increasing
the external electric field. In particular, the band gap is opened
about 0.3 eV for E = 0.5 V/Å, as shown in Fig. 3.31 (a). It is noted
that the vacuum size will affect the electric field screening, which
modifies the energy band gap. Therefore, the readers should consider
a sufficiently large vacuum size by changing the value of c in the input
files.

Try It Yourself

Plot the planar‐average of electrostatic potential with the size


of the unit cell c = 30, 40, and 50 Å. The positions of the C
atoms in the namelist ATOMIC_POSITIONS in scf.in must
rescale for each c value since these postions are in crystal
coordinates.
150 | Hands‐On Tutorials of Quantum ESPRESSO

3.6 Maximally‐localized Wannier functions

Maximally‐localized Wannier functions (MLWFs) are helpful to


compute the properties of the materials that require very dense
grid of k‐points and to build a tight‐binding model (see Sec. 5.14).
In Quantum ESPRESSO, the MLWFs are employed by Wannier90
code [Mostofi et al. (2008), Pizzi et al. (2020)] (see Chapter 2 for the
Wannier90 installation). In this section, we learn how to calculate
the MLWFs from Wannier90 and Quantum ESPRESSO (Sec. 3.6.1) and
apply the Wannier interpolation for hybrid functional (Sec. 3.6.2).

3.6.1 Wannier functions, energy dispersion, and


tight‐binding parameters

 Purpose: In this tutorial, we visually check the Wannier functions


(WFs), and we show how to plot energy dispersion and obtain tight‐
binding parameters based on the MLWFs of graphene.
 Background: The WFs can be obtained from the Bloch functions
by using Eq. (5.59). As discussed in Sec. 5.14, there is a freedom of
choice in the Bloch function that corresponds to the shape and the
spatial distribution of the WF. We can select any phases of the Bloch
function, which modifies the spatial distribution of the WF.
In order to obtain the MLWFs, we minimize the spread
of the WF, Ω in Eq. (5.66), by using a steepest‐descent algo‐
rithm [Marzari et al. (2012a)]. After a ground state ψnk is obtained
from the SCF calculation, the Wannier90 code will calculate the
MLWFs, which require the following two matrices:
• The overlap matrix Mk,b mn = ⟨umk |un,k+b ⟩ between the periodic
part of the Bloch functions |un,k+b ⟩ (see Eq. (5.72)).
• A starting guess the projection matrix Akmn = ⟨ψmk |gn ⟩ of the
Bloch function ψnk onto trial localized orbitals |gn ⟩ (see Eq. (5.78)).
The calculation of the MLWF of graphene consists of the
following five steps:
1. First, we perform the SCF to take the Bloch functions from a
ground‐state calculation by using pw.x. In the case that we need
the Bloch functions in a more dense k‐mesh compared with the
previous SCF step, we can run non‐SCF after the SCF is finished.
Quantum ESPRESSO Course for Solid‐State Physics | 151
2. It is important to note that Wannier90 requires a full list of k‐
points in the Brillouin zone, while pw.x in step (1) uses a reduced
k‐points. Therefore, an executable open_grid.x in Quantum
ESPRESSO is used to obtain the full grid of k‐points from the
reduced one.
3. Next, we run Wannier90 in post‐processing mode
(wannier90.x -pp) to obtain the .nnkp file, which contains the
relevant information from the Wannier90 input file in a format
to be used in the next step.
4. Then, we run the executable pw2wannier90.x (of the Quantum
ESPRESSO distribution), which reads the Bloch functions from
the SCF (or non‐SCF) and the .nnkp file to compute Mk,b mn and Amn
k

that will be written in the .mmn and .amn files, respectively.


5. Finally, we run Wannier90 (wannier90.x) by reading the files
produced by the previous step to minimize the spread to
calculate the MLWFs.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/gr/w90/
2 $ mpirun -np 4 pw.x < scf.in > scf.out &
3 $ mpirun -np 4 open_grid.x < open_grid.in >
open_grid.out &
4 $ wannier90.x -pp gr &
5 $ mpirun -np 4 pw2wannier90.x < pw2wan.in > pw2wan.
out &
6 $ wannier90.x gr &

‐ Line 1: Go to w90 directory.


‐ Line 2: Run pw.x for the SCF calculation for the step (1).
‐ Line 3: Run open_grid.x to unfold the reduced k‐points onto the
full k‐points for the step (2).
‐ Line 4: Run Wannier90 post‐processing for the step (3). It
requires the second input file gr.win.
‐ Line 5: Run Wannier90 interface pw2wannier90.x with the input
file pw2wan.in for the step (4).
‐ Line 6: Run wannier90.x with the input file gr.win for the step
(5).
152 | Hands‐On Tutorials of Quantum ESPRESSO

 Note: wannier90.x can only run on a single processor (mpirun


can not be used), while pw2wannier90.x can run in parallel, in which
the number of processors -np 4 must to be the same as pw.x.
 How to check: When the calculations finish, you can find a
message JOB DONE at the end of scf.out, open_grid.out, and
pw2wan.out files, and a message All done: wannier90 exiting
at the end of the output file gr.wout. To obtain the final value of
the spread of the WFs (see Sec. 5.14.2), the readers can use grep
command as follows:

$ grep 'Final Spread ' gr.wout

The total spread is printed in the terminal as

Final Spread (Ang ^2) Omega Total = 3.773324125

 Input file: The input file scf.in is similar to scf.in in Sec. 3.1.1
for graphene, but we add nbnd = 16 in the namelist SYSTEM. For
the input file open_grid.in, the readers can open with vi editor as
follows:

$ vi open_grid.in

QE‑SSP/gr/w90/open_grid.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'gr '

Note for open_grid.in: outdir and prefix for open_grid.in


must be the same as that for scf.in in the step (1).
For the input file gr.win, the readers can open as

$ vi gr.win
Quantum ESPRESSO Course for Solid‐State Physics | 153
QE‑SSP/gr/w90/gr.win

1 # CONTROL
2 num_bands = 16
3 num_wann = 5
4
5 dis_win_min = -22
6 dis_win_max = 11
7 dis_froz_min = -22
8 dis_froz_max = 0.5
9
10 num_iter = 20
11
12 # TIGHT -BINDING
13 write_hr = .true.
14
15 # PLOTTING
16 wannier_plot = .true.
17 bands_plot = .true.
18
19 wannier_plot_supercell = 3
20
21 begin kpoint_path
22 G 0.0000 0.0000 0.0000 K 0.3333 0.3333 0.0000
23 K 0.3333 0.3333 0.0000 M 0.5000 0.0000 0.0000
24 M 0.5000 0.0000 0.0000 G 0.0000 0.0000 0.0000
25 end kpoint_path
26
27 # SYSTEM
28 begin unit_cell_cart
29 ang
30 2.463906 0.000000 0.000000
31 -1.231953 2.133805 0.000000
32 0.000000 0.000000 15.000000
33 end unit_cell_cart
34
35 begin atoms_frac
36 C 0.333333333 0.666666666 0.500000000
37 C 0.666666666 0.333333333 0.500000000
38 end atoms_frac
39
40 # PROJECTIONS
41 guiding_centres = .true.
42
43 begin projections
44 C: pz
45 f= 0.5, 0.5, 0.5: s
46 f= 0.5, 0.0, 0.5: s
47 f= 0.0, 0.5, 0.5: s
154 | Hands‐On Tutorials of Quantum ESPRESSO

20

Energy (eV) 10

dis_win
0

froz_win
10

20
K M
Figure 3.32 An optimized selection for the frozen froz_win and the
disentanglement dis_win for the band structure of graphene. Solid lines
are the energy bands that are calculated by the DFT. Solid lines with circles
are “fitted energy bands” to the WFs, while only solid lines denote “not‐
fitted energy bands”. froz_win should be taken as large as possible with the
condition that we should not include “not‐fitted bands” (only solid lines).
dis_win should be taken as small as possible with the condition that we
should include all “fitted bands” (lines with circles).

48 end projections
49
50 # KPOINTS
51 mp_grid = 12 12 1
52
53 begin kpoints
54 0.00000000 0.00000000 0.00000000 0.0069444
55 0.00000000 0.08333333 0.00000000 0.0069444
56 ...
57 -0.083333333 -0.08333333 0.00000000 0.0069444
58 end kpoints

Explanation of gr.win: The input variables in gr.win are listed in


Table 3.10. The gr.win file can be divided into 6 parts starting with a
hash mark "#". It is noted that the comments in Wannier90 can begin
with "#", "%", or "!". Each part is explained as follows:
1. CONTROL: This part contains the parameters for minimizing the
spread of the WF. These parameters are essential to obtain well‐
localized WFs. Here, we show how to choose these parameters.
First, the number of energy bands num_bands (line 2) should
be equal to nbnd = 16 in scf.in. Second, the number of the
Quantum ESPRESSO Course for Solid‐State Physics | 155
Table 3.10 Meaning of input variables in gr.win file.

Line Syntax Meaning


Number of energy bands, which is
equal to the number of the
2 num_bands Kohn‐Sham states nbnd = 16 in
scf.in.
.......................................................................................................................................................................

Number of the WFs, which is equal to


3 num_wann the number of projections.
.......................................................................................................................................................................

Minimum energy (in eV) of the


5 dis_win_min disentanglement window.
.......................................................................................................................................................................

Maximum energy (in eV) of the


6 dis_win_max disentanglement window.
.......................................................................................................................................................................

Minimum energy (in eV) of the


7 dis_froz_min frozen window.
.......................................................................................................................................................................

Maximum energy (in eV) of the


8 dis_win_max frozen window.
.......................................................................................................................................................................

Maximum number of iterations for


10 num_iter the minimization of spread.
.......................................................................................................................................................................

If write_hr = .true., the code will


write the tight‐binding Hamiltonian
13 write_hr in output file *_hr.dat. The default
is .false.
.......................................................................................................................................................................

If wannier_plot = .true., the


code will write out the Wannier
16 wannier_plot functions in in output files *.xsf,
which are opened by XCrySDen or
VESTA codes. The default is false.
.......................................................................................................................................................................

If bands_plot = .true., the code


will calculate the band structure,
17 bands_plot through Wannier interpolation, and
write in output file *_band.dat. The
default is false.
.......................................................................................................................................................................

Size of the supercell for plotting the


19 wannier_plot_supercell WF. The default value is 2.
.......................................................................................................................................................................

Defines the path in k‐space along


21–25 kpoint_path which to calculate the bandstructure.
.......................................................................................................................................................................

Lattice vectors in the Cartesian


28–32
coordinates.
unit_cell_cart

Continued
156 | Hands‐On Tutorials of Quantum ESPRESSO

Table 3.10 – Continued

Line Syntax Meaning


The unit of the lattice vectors
33 ang (Angstrom).
....................................................................................................................................................................

Atomic positions in fractional


35–38
coordinates.
atoms_frac
If guiding_centres = .true., the
projection centres are used as the
41 guiding_centres guiding centres during the
minimization to avoid local minima.
The default is false.
....................................................................................................................................................................

Defines a set of localized functions


43–48 used to generate the projections
matrix Akmn .
projections
....................................................................................................................................................................

51 mp_grid Dimensions of the k‐points grid.


....................................................................................................................................................................

53–58 kpoints The positions of each k point.

WFs num_wann (line 3) should be equal to the number of the


projectors, which will be explained in part (5). We can see
that num_wann is not equal to num_bands. In order to solve
this problem, Souza et al. [Souza et al. (2001)] introduced the
disentanglement method in Wannier90. This method requires
the disentanglement dis_win and frozen froz_win energy
windows. The optimized way to choose dis_win and froz_win
is shown in Fig. 3.32. dis_win is a window to extract the
target bands for the WFs. Therefore, dis_win should cover
the energy range of all WFs, and dis_win should be as small
as possible to reduce the computational cost. For graphene,
the WFs include four valence bands and one conduction band
since we have five WFs. These bands have the energy range
from −20 to 12 eV (see Fig. 3.14). Therefore, after shifting
with the Fermi energy (−1.6786 eV, see in scf.out), we can
choose dis_win_min = -22 and dis_win_max = 11 in units of
eV (lines 5 and 6), respectively. It is noted that these values do
not need to be very precise. However, if dis_win is too small, the
readers will get an error in gr.wout as follows:
Quantum ESPRESSO Course for Solid‐State Physics | 157

Exiting .......
dis_windows: Energy window contains fewer states
than number of target WFs

froz_win is a window used for the disentanglement


procedure. This window should not contain “not‐fitted energy
bands”, and it should be as large as possible for optimizing the
disentanglement procedure. For graphene, the lowest energy of
6‐th band at 2.5 eV, as shown in Fig. 3.14. Therefore, after shifting
with the Fermi energy, we can choose froz_win_min = -22 and
froz_win_max = 0.5 in units of eV (lines 5 and 6), respectively.
We recommend to run the energy band structure in Sec. 3.2.2 to
estimate the values for the froz_win and dis_win.
Finally, we choose the maximum number of iterations
num_iter = 20 for the minimization of spread. Large number of
num_iter would mix the WFs such that the output WFs are not
atomic like. Therefore, if you want atomic like WFs, it is better to
set num_iter less than 20.
2. TIGHT‑BINDING: By setting write_hr = .true., the tight‐
binding Hamiltonian in the WF basis (see Sec. 5.14.3) will be
written in output file gr_hr.dat.
3. PLOTTING: This part contains the parameters for plotting.
It is noted that the WF is not periodic in the unit cell.
Therefore, it is not generally sufficient to plot it in a single unit
cell. wannier_plot_supercell controls the number of units
cell in which we construct the WF. For graphene, we select
wannier_plot_supercell = 3 (line 19), which is sufficient to
give a good picture of a WF. In order to plot the band structure
with bands_plot = .true. (line 17), the path in k‐space need
to list in the block of kpoint_path from line 22 to line 24. Each
line gives the start and end points (with labels) for a section of
the path. Values are in fractional coordinates with respect to the
primitive reciprocal lattice vectors. The number of k points along
each path is given in output file gr_band.labelinfo.dat.
4. SYSTEM: This part includes two blocks unit_cell_cart
(lines 28–33) and atoms_frac (lines 35–38), in which
unit_cell_cart are the lattice vectors (in Cartesian
coordinates) and atoms_frac are the atomic positions (in
158 | Hands‐On Tutorials of Quantum ESPRESSO

fractional coordinates). These values can be obtained from


scf.in. The unit of lattice vectors is defined by ang (line 29) for
Angstrom or bohr for Bohr.
5. PROJECTIONS: This part includes the parameters for selecting
the initial projections, which need to generate the matrix Akmn .
For graphene, we project the Bloch functions onto the s and pz
orbitals of the C atoms. The positions of these orbitals are set in
the block projections from line 44 to line 47. C: pz (line 44)
means that the pz orbitals are located at the positions of the C
atoms, while s orbitals are located at the center of the C‐C bonds.
Since we have two C atoms and three C‐C bonds in the unit cell,
we have the 5 WFs. Therefore, we can set num_wann = 5 (line
3). It is noted that the option guiding_centres = .true. (line
41) is used during the minimization to avoid local minima. For
this reason, we recommend to use guiding_centres = .true.
where the block projections is defined.
6. KPOINTS: The grid of k‐points is mp_grid = 12 12 1 (line 51),
which is same as k‐points in scf.in. The full list of k‐points
in the block kpoints is copied and pasted from the output file
open_grid.out in the step (2).
For the input file pw2wan.in, the readers can open by

$ vi pw2wan.in

QE‑SSP/gr/w90/pw2wan.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'gr_open '
4 seedname = 'gr '
5 write_unk = .true.
6 /

 Explanation of pw2wan.in: The executable open_grid.x in the


step (2) generates a new folder gr_open.save (in the tmp directory),
to store the wavefunctions of the full k‐points, while gr.save stores
the wavefunctions of the reduced k‐points. Therefore, we must to
setting prefix = 'gr_open' (line 3). In order to plot the Wannier
functions in real space, we need to set write_unk = .true. (line
Quantum ESPRESSO Course for Solid‐State Physics | 159

Figure 3.33 The Wannier functions of graphene includes pz (left) and s (right)
orbitals.

5). This option also produces a set of wavefunctions unk (r) on a real‐
space grid in the output files UNK00001.1, UNK00002.1, …
Note: If the k‐points in gr.win and open_grid.out are not the
same or prefix in pw2wan.in is not correct, the readers will get an
error in pw2wan.out as follows:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error in routine pw2wannier90 (144):
Wrong number of k-points
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Output file: The main output files for this tutorial are gr_*.xsf,
gr_band.dat, and gr_hr.dat. We will visualize the WFs from
gr_*.xsf, plot the band structure from gr_band.dat, and extract the
tight‐binding parameters from gr_hr.dat.
 Visualizing the Wannier functions: The gr_*.xsf file can open
directly by using VESTA. For XCrySDen, we can open as File →
Open Structure → Open XSF (XCrySDen Structure File) and select
gr_*.xsf file. Then, we select Tools → Data Grid, click on the OK
button, enter a value in the box Isovalue (2 is a good choice for
graphene), click on the Submit button. In Fig. 3.33 (a) and (b), we
show the pz and s orbitals for the output files gr_00001.xsf and
gr_00003.xsf, respectively.
 Plotting energy dispersion: By running step (5), the band
structure based on the Wannier interpolation (see Sec. 5.14.3) is
written in the output file gr_band.dat. In a similar way to plot
band structure of graphene in Sec. 3.2.2, the readers can run the
file plot-bands.ipynb to plot the band structure from output file
gr_band.dat. The band structure is plotted in Fig. 3.32, in which
160 | Hands‐On Tutorials of Quantum ESPRESSO

$ vi gr_hr.dat
...
0 0 0 5 1 -0.000004 0.000014
0 0 0 1 2 -2.910519 0.000006
0 0 0 2 2 -1.391550 -0.000000
...
0 0 0 5 5 -12.557218 0.000000
0 1 0 1 1 0.224064 -0.000001
0 1 0 2 1 0.019864 0.000001
...
Ty
Tx Tz n n’
Translation vector WF Real & imaginary parts
of unit cell indices of hopping parameters

Figure 3.34 The meaning of output file gr_hr.dat.

the open dots and solid lines denote the band structure obtained
from wannier90.x and pw.x, respectively. For five lowest energy‐
bands, which correspond to three s‐ and two pz ‐orbitals, the Wannier
interpolation can reproduce the band structure from SCF calculation.
The advantage of the Wannier interpolation is that the band structure
can be accurately calculated for a dense k‐mesh based on the SCF
calculation for a coarse k‐mesh. This is helpful for the case that the
SCF calculation is time‐consuming for a dense k‐mesh, such as the
hybrid functional calculation, which will be explained in Sec. 3.6.2.
 Extracting tight‑binding parameters: The tight‐binding param‐
eters of graphene are given by the output file gr_hr.dat, as shown
in Fig. 3.34. The readers can use the vi editor to open this file.
Each line in gr_hr.dat includes 7 values as follows: the first three
values give the translation vector T of the unit cell in x, y, and z
directions, respectively, the next two values give the WF indices n
and n′ , and the least two values are the real and imaginary parts of the
hopping parameters in units of eV tnn′ = ⟨wn,0 |H|wn′ ,T ⟩ (see Eq. 5.80).
For graphene, we consider the hopping parameters up to the 1st
nearest neighbor unit cell, i.e., t12 and t11 for T = (0, 0, 0) and (0, 1, 0),
respectively. Then, we obtain t12 = −2.91 eV and t11 = 0.224 eV, as
shown in Fig. 3.34.
Quantum ESPRESSO Course for Solid‐State Physics | 161
Try It Yourself

1. Recompute band structure of graphene by changing the


values of dis_win_max and dis_froz_max.
2. Calculate the MLWFs and band structure of monolayer
MoS2 .

3.6.2 Wannier interpolation for hybrid functional

 Purpose: In this tutorial, we show how to obtain the band


structure of the monolayer MoS2 with the HSE (Heyd‐Scuseria‐
Ernzerhof) hybrid functional and Wannier interpolation.
 Background: As discussed in Sec. 4.11.3, the LDA and GGA
approximations often underestimate the value of the energy band
gap. In order to obtain a reasonable energy gap, the HSE functional
can be used in the SCF calculation in Quantum ESPRESSO. However,
Quantum ESPRESSO only supports the HSE functional for a uniform
k‐mesh. In addition, the HSE functional requires a non‐local term
of the Hartree‐Fock exchange interaction, which is time‐consuming
for a dense k‐mesh. For this reason, the Wannier interpolation is
necessary to plot the band structure along with the high‐symmetry
points using a non‐uniform and dense k‐mesh for HSE functional.
 How to run: To run this tutorial, the readers should type the
following command lines:

1 $ cd ~/QE -SSP/mos2/w90/
2 $ mpirun -np 8 pw.x < scf.in > scf.out &
3 $ mpirun -np 8 open_grid.x < open_grid.in >
open_grid.out &
4 $ wannier90.x -pp mos2 &
5 $ mpirun -np 8 pw2wannier90.x < pw2wan.in > pw2wan.
out &
6 $ wannier90.x mos2 &

The meaning of each step is given by the tutorial in Sec. 3.6.1.


Since the SCF calculation with the HSE functional (line 2) is time‐
consuming, we run 8 processes in parallel (mpirun -np 8).
162 | Hands‐On Tutorials of Quantum ESPRESSO

 How to check: When the calculations finish, the messages


JOB DONE and All done: wannier90 exiting are written at the
end of the output files, as shown in Sec. 3.6.1.
 Input file: For the input file scf.in, the readers can open as
follows:

$ vi scf.in

QE‑SSP/mos2/w90/scf.in

1 & CONTROL
2 calculation = 'scf '
3 pseudo_dir = '../ pseudo/'
4 outdir = '../tmp/'
5 prefix = 'mos2 '
6 /
7 &SYSTEM
8 ibrav = 4
9 a = 3.1825188839
10 c = 20.0
11 nat = 3
12 ntyp = 2
13 nbnd = 30
14 ecutwfc = 60.0
15 input_dft = 'hse '
16 exx_fraction = 0.25
17 nqx1 = 2
18 nqx2 = 2
19 nqx3 = 1
20 /
21 & ELECTRONS
22 mixing_beta = 0.7
23 conv_thr = 1.0d-6
24 /
25 ATOMIC_SPECIES
26 Mo 95.94 Mo.pbe -spn -rrkjus_psl .1.0.0. UPF
27 S 32.065 S.pbe -nl -rrkjus_psl .1.0.0. UPF
28 ATOMIC_POSITIONS (crystal)
29 Mo 0.0000000000 0.0000000000 0.5000000000
30 S 0.3333333333 0.6666666667 0.4217548051
31 S 0.3333333333 0.6666666667 0.5782450789
32 K_POINTS (automatic)
33 6 6 1 0 0 0
Quantum ESPRESSO Course for Solid‐State Physics | 163
Explanation of scf.in: The HSE functional is calculated by
setting input_dft = 'hse' (line 15) in the namelist SYSTEM.
exx_fraction (line 16) is the mixing coefficient, which is 0.25 for
the HSE functional, as shown in Table 4.3. nqx1, nqx2, and nqx3
(lines 17, 18, and 19), respectively, are dimensions of the q‐grid for
the Hartree‐Fock exchange interaction. The readers should check
the convergence of the energy band by changing the q‐grid. The
calculation of the q‐grid convergence will be very time‐consuming
compared to the k‐grid convergence in Sec. 3.1.3. Therefore, we
recommend increasing the number of processes in parallel, which
might require a workstation. Here, we select a coarse 2 × 2 × 1 grid
for q‐points, which is appropriate to run with a PC with 8 processes,
such as Intel Core i7 or i9.
For the input file open_grid.in, the readers can open as follows:

$ vi open_grid.in

QE‑SSP/mos2/w90/open_grid.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'mos2 '
4 /

For the input file mos2.win, the readers can open as follows:

$ vi mos2.win

QE‑SSP/mos2/w90/mos2.win

1 # CONTROL
2 num_bands = 30
3 num_wann = 11
4
5 num_iter = 20
6
7 dis_win_min = -8
8 dis_win_max = 5
9 dis_froz_min = -8
10 dis_froz_max = 3.5
164 | Hands‐On Tutorials of Quantum ESPRESSO

11
12 # PLOTTING
13 bands_plot = .true.
14
15 begin kpoint_path
16 G 0.0000 0.0000 0.0000 K 0.3333 0.3333 0.0000
17 K 0.3333 0.3333 0.0000 M 0.5000 0.0000 0.0000
18 M 0.5000 0.0000 0.0000 G 0.0000 0.0000 0.0000
19 end kpoint_path
20
21 #SYSTEM
22 begin unit_cell_cart
23 ang
24 3.182518 0.000000 0.000000
25 -1.591259 2.756142 0.000000
26 0.000000 0.000000 20.000000
27 end unit_cell_cart
28
29 begin atoms_frac
30 Mo 0.0000000000 0.0000000000 0.5000000000
31 S 0.3333333333 0.6666666667 0.4217548051
32 S 0.3333333333 0.6666666667 0.5782450789
33 end atoms_frac
34
35 # PROJECTIONS
36 guiding_centres = .true.
37
38 begin projections
39 Mo: dxy; dyz; dxz; dx2 -y2; dz2
40 S: px; py; pz
41 end projections
42
43 # KPOINTS
44 mp_grid = 6 6 1
45
46 begin kpoints
47 0.00000000 0.00000000 0.00000000 0.0277777
48 0.00000000 0.16666666 0.00000000 0.0277777
49 ...
50 -0.16666666 -0.16666666 0.00000000 0.0277777
51 end kpoints

Explanation of mos2.win: The detail of parameters in


the mos2.win file is given in Table 3.10. Here, five d orbitals
(dxy , dyz , dxz , dx2 −y2 , and dz2 ) and three p orbitals (px , py , and pz ) are
selected as the initial projectors for the Mo and S atoms, respectively.
Thus, we have 11 WFs num_wann = 11 (line 3).
Quantum ESPRESSO Course for Solid‐State Physics | 165

Figure 3.35 Energy band structure of monolayer MoS2 . Solid and dashed
lines denote the band structure with the GGA and HSE functionals,
respectively.

For the input file pw2wan.in, the readers can open as follows:

$ vi pw2wan.in

QE‑SSP/mos2/w90/pw2wan.in

1 & INPUTPP
2 outdir = '../tmp/'
3 prefix = 'mos2_open '
4 seedname = 'mos2 '
5 /

 Output file: The band structure is written in the output file


mos2_band.dat. The readers can run the file plot-bands.ipynb to
plot the band structures from mos2_band.dat (with HSE functional)
and mos2_bands.gnu (with only GGA functional). It is noted that
the file mos2_bands.gnu is obtained by bands.x for a non‐SCF
calculation (see Sec. 3.2.2). In Fig. 3.35, we show the band structure
of the monolayer MoS2 with the GGA (solid lines) and HSE (dashed
lines) functionals. The energy gaps are 1.688 and 2.578 eV for
the GGA and HSE functionals, respectively. Compared with the
experimental value (2.40 ± 0.05 eV [Huang et al. (2015)]), the HSE
functional gives a better value of the energy gap.
166 | Hands‐On Tutorials of Quantum ESPRESSO

Try It Yourself

1. Calculate the energy gap of the bulk Si with the LDA, GGA,
and HSE functionals, and compare to the experimental
value (1.12 eV).
2. Plot the Wannier function of the bulk Si with the HSE
functional.
Chapter 4

Density‐Functional Theory

In this chapter, we provide a density‐functional theory (DFT) that


becomes the basis of Quantum ESPRESSO. In order to understand
how the DFT code works, we explain and apply the DFT on a simple
example of the ground‐state calculation of a helium atom. A simple
Python code is also given for the helium atom calculation. This
chapter will help the readers to understand Quantum ESPRESSO’s
techniques in Chapter 3, such as the self‐consistent field (SCF)
calculation, the ground‐state total energy, the pseudopotential, etc.

4.1 “Black box” Quantum ESPRESSO

By giving input files to Quantum ESPRESSO, we can obtain output


files containing the materials’ information and properties. Therefore,
Quantum ESPRESSO works like a black box, as shown in Fig. 4.1
(a). The readers may run a computer program successfully without
understanding the black box. However, a successful run does not
mean that you have run it properly. To understand what you are
running, the readers need to know what is inside the black box.

Quantum ESPRESSO Course for Solid‐State Physics


Nguyen Tuan Hung, Ahmad R. T. Nugraha, and Riichiro Saito
Copyright © 2023 Jenny Stanford Publishing Pte. Ltd.
ISBN 978‐981‐4968‐37‐9 (Hardcover), 978‐981‐4968‐63‐8 (Paperback), 978‐1‐003‐29096‐4 (eBook)
www.jennystanford.com
168 | Density‐Functional Theory

(a)
Quantum
Input Output
ESPRESSO

(b) Electrons + Nuclei Electron density

Structures Properties
of materials of materials

The Schrödinger Density-functional


equation theory

Figure 4.1 (a) Quantum ESPRESSO as a black box. (b) Density‐functional


theory is used in Quantum ESPRESSO to solve the Schrödinger equation of
materials.

The purpose of Quantum ESPRESSO is to calculate the properties


of materials at the atomic scale. Since “materials = electrons +
nuclei”, the properties of the materials are given by the complicated
interactions of the electrons and nuclei. The electrons and nuclei
hold together in the materials with a detailed balance between the
repulsive and attractive Coulomb interactions between them. These
interactions are described by an equation in quantum mechanics, the
so‐called Schrödinger equation (Eq. (4.1)) [Schrödinger (1926)].
An analytical solution of the Schrödinger equation only exists
for systems of one electron (e.g., a hydrogen atom), while most
atoms, molecules, and materials consist of many electrons and
nuclei. For any system of more than two electrons, the Schrödinger
equation can be solved only after using some approximations due
to the complexity of the Coulomb interactions. Therefore, a good
approximation is necessary to solve the Schrödinger equation. In
Quantum ESPRESSO, the density‑functional theory (DFT) is used
as an approximation to solve the Schrödinger equation, as shown in
Fig. 4.1 (b).
Quantum ESPRESSO Course for Solid‐State Physics | 169
4.2 The Schrödinger equation

A system of electrons and nuclei is described by the Schrödinger


equation as

HΨ = Etot Ψ, (4.1)

where H is the Hamiltonian of the system, Etot is the total energy of the
electrons and nuclei, and Ψ(r1 , …, rNe , R1 , …, RNn ) is the wavefunction
of many particles (electrons and nuclei). By using the atomic units
listed in Table 4.1, a general Hamiltonian in Eq. (4.1) is given by
kinetic energies T and potential energies V of the electrons and
nuclei as

H = Tn + Vn + Te + Ve + Ven

ZI ZJ
Nn Nn
 ∇2RI 1
2MI 2 |RI − RJ |
=− +
I=1 I̸=J
(4.2)
  
nuclei
Ne Ne Ne Nn
∇2r 1 1 −ZI
.
 
i

2 2 |ri − rj | |ri − RI |
− + +
i=1 i̸=j i=1 I=1
    
electrons mixed

Tn : kinetic energy of nuclei Te : kinetic energy of electrons


Vn : Coulomb repulsion Ve : Coulomb repulsion
between a pair of nuclei between a pair of electrons
Ven : Coulomb attraction ∇: nabla operators
between electrons and nuclei
R: nuclear position r: electronic position
Nn : number of nuclei Ne : number of electrons
I, J: label for a nucleus i, j: label for an electron
M: nuclear mass Z: nuclear charge (atomic number)

Notice that a factor of 1/2 appears in the sums of Vn and Ve to take


into account the double counting on the summation i and j (i ̸= j).
Here, we adopt the atomic units e = h̄ = c = me = 1 (see Table 4.1)
and cgs unit for the Coulomb interaction. If SI unit is adopted, Te + Ve
170 | Density‐Functional Theory

Table 4.1 Atomic unit (a.u.).

Symbol Quantity a.u. Value in SI


t Time 1 2.419 × 10−17 s
....................................................................................................................................................................

c (1/α) Speed of light 1 2.998 × 108 m/s


....................................................................................................................................................................

h̄ h/2π (angular momentum) 1 1.055 × 10−34 Js


....................................................................................................................................................................

h Planck’s constant 2π 6.626 × 10−31 Js


....................................................................................................................................................................

Ha (Eh ) Hartree (atomic energy) 1 4.360 × 10−18 J


....................................................................................................................................................................

me Electron mass 1 9.110 × 10−31 kg


....................................................................................................................................................................

e Electron charge 1 1.602 × 10−19 C


....................................................................................................................................................................

a0 Bohr radius (atomic distance) 1 5.292 × 10−11 m


....................................................................................................................................................................

e/a30 Charge density 1 1.081 × 1012 C/m3


....................................................................................................................................................................

eEh /h̄ Current 1 6.623 × 10−3 A


....................................................................................................................................................................

Eh /(ea20 ) Electric field 1 9.717 × 1021 V/m2


....................................................................................................................................................................

μB Bohr magneton 1/2 9.274 × 10−24 J/T


....................................................................................................................................................................

4πϵ0 Vacuum permittivity ×4π 1 1.113 × 10−10 C2 /Jm


....................................................................................................................................................................

Eh /a0 Force 1 8.238 × 10−8 N


....................................................................................................................................................................

Eh /a30 Pressure 1 2.942 × 1013 Pa


Helpful conversions: 1 Ha = 27.2114 eV = 2 Ry.

is expressed by

h̄2 ∇2ri e2
Ne Ne
1
. (4.3)

2me 2 4πϵ0 |ri − rj |
− +
i=1 i̸=j

The Hamiltonian in Eq. (4.2) is considered as a coupled nuclear


and electronic problem. However, the nuclei are much heavier than
the electrons (e.g., MH /me = 1, 836 in hydrogen or MC /me = 21, 868
in carbon). Moreover, the average speed of the nuclei is much
smaller than that of the electrons. Therefore, we can assume that
the electrons will follow the nuclear motions without any delay,
and we can decouple the electronic and nuclear motions to the
first approximation, which is known as the Born‑Oppenheimer
Quantum ESPRESSO Course for Solid‐State Physics | 171
z

e–
r1 |r1 – r2|
e–
r2

2e+
x y

Figure 4.2 Two electrons in a helium atom, where ri (i = 1, 2) are the


positions of the i‐th electron, and |r1 − r2 | is the distance between two
electrons.

approximation (BOA) [Born and Oppenheimer (1927)]. The nuclei


in the material are almost immobile except for hydrogen atoms, and
their positions can be determined precisely by X‐ray crystallography
(see Sec. 5.2). Thus, we can fix the positions of the nuclei in the
real space with zero kinetic energy (i.e., Tn = 0) for calculating the
electronic energy band. Then Vn becomes an external potential (or
simply a constant). In this case, the problem that we have to solve
becomes a purely electronic one as

He ψ = (Te + Ve + Ven )ψ = Eψ, (4.4)

where E = Etot − Vn is the total energy of the electrons and ψ is a


wavefunction of the N electrons, in which ψ is a many‐body function
of the positions of N electrons ri (i = 1, 2, …, N): ψ(r1 , r2 , …, rN ). Since
an electron interacts with the rest of the electrons due to the Coulomb
repulsion Ve , the many‐body state has to account for all the degrees
of freedom of N electrons in the system (or the 3N‐dimensional
configuration space).

 The Schrödinger equation for a helium atom: Let us consider


the case of a helium (He) atom, which consists of one nucleus
with Z = 2 and two electrons at r1 and r2 , as shown in Fig. 4.2.
172 | Density‐Functional Theory

Equation (4.4) for a helium atom is given by

1 1 1 2 2
 
− ∇2r1 − ∇2r2 + ψ(r1 , r2 )
2 2 |r1 − r2 | |r1 | |r2 | (4.5)
− −

= Eψ(r1 , r2 ).

Although Eq. (4.5) looks simple, an analytical solution cannot be


found because Eq. (4.5) is a six‐dimensional partial differential
equation (PDE). High‐dimensional PDEs are hard to solve in physics,
in which they occur not only in quantum mechanics but also in
classical mechanics (e.g., the Hamilton‐Jacobi equation1 with a large
number of degrees of freedom).
Since the Schrödinger equation is a PDE where all terms are
known, one can try to solve it numerically on a grid.2 This approach
can solve Eq. (4.5) for an electron, but it fails for a system with more
than two electrons. For example, if we take 3D silicon as an example,
it has a unit cell volume of a3 /4, where a = 5.431 Å is the lattice
constant. If we consider a grid of the unit cell with points spaced
by Δd ∼ 0.2 Å, this grid consists of (a3 /4)/(Δd3 ) ∼ 5000 points.
Since two silicon atoms in the unit cell contain 28 electrons, the grid
has 28 × 3 = 84 coordinates. Therefore, a complete specification of
a wavefunction ψSi (r1 , r2 , …, r28 ) requires 500084 complex numbers.
We need a stack of DVDs from the earth to the sun to store this
wavefunction. To overcome this problem, many researchers have
been developing methods of approximation since the late 1920s.
The most successful method in physics is the density‐functional
theory (DFT). The DFT is defined by the theory of approximation in
which the Coulomb interaction between electrons is expressed by a
functional3 of the electron density. With the DFT, the Schrödinger
equation can be reformulated in terms of the electron density.
Therefore, the 3N‐dimensional PDE is reduced to N PDE’s of 3‐
dimension, so that we can solve Eq. (4.2) for silicon and store their
wavefunction by using a PC.

1 The Hamilton‐Jacobi equation is an alternative formulation of classical mechanics,

equivalent to other formulations such as the Newton second law.


2 In a grid approach, functions are represented by their values at certain grid points

and derivatives are approximated through differences in these values.


3 A functional is a function whose variable is another function such as V(n(r)).
Quantum ESPRESSO Course for Solid‐State Physics | 173
4.3 Systems of non‐interacting electrons

Before explaining the DFT, we would like to show some approxi‐


mations for solving Eq. (4.5), which are regarded as the conceptual
origin of the DFT. As discussed in Sec. 4.2, the problem to solve the
Schrödinger equation comes from the Coulomb repulsion between
electrons Ve . If we assume that the Ne electrons in the system are
non‐interacting to one another, we can set Ve = 0, and Eq. (4.4) can
be rewritten as a function of ri (i = 1, …, Ne )

Ne Ne 
Nn
 
∇2r
ψ = Eψ.
−ZI
(4.6)
 
i

|ri − RI |
(Te + Ven )ψ =
2
− +
i=1 i=1 I=1

Here we define a single‑particle Hamiltonian of one electron as

N
∇2r n

h(r) = −
−ZI
, (4.7)
2 |r − RI |
+
I=1

so that Eq. (4.6) can be rewritten as

h(ri )ψ(ri ) = Eψ(ri ), with (i = 1, …, Ne ). (4.8)

From Eq.(4.8) we can say that, for the case of the non‐interacting
electrons, the Hamiltonian of the system can be written as Ne
independent single‐particle Hamiltonian, and the wavefunction
is written by ψ(ri ). Eq. (4.8) is used to obtain the energy of
electrons for the following two cases: (1) distinguishable4 and (2)
indistinguishable5 electrons. For simplicity, we consider the two
electrons in a helium atom as follows:
(1) Two distinguishable electrons: Let us consider electron 1
in one state ϕa (r1 ) and electron 2 in another state ϕb (r2 ). Since two
electrons are independent of each other, the probability of finding
(electron 1 at r1 ) and (electron 2 at r2 ) can be given by the product
as |ψ(r1 , r2 )|2 = |ϕa (r1 )|2 |ϕb (r2 )|2 . In this case, the wavefunction can

4 If the electrons are distinguishable, the physical properties of the system are

changed by switching the positions of two electrons.


5 If the electrons are indistinguishable, switching the positions of two electrons

makes no physical change.


174 | Density‐Functional Theory

be expressed by the product of one‐body wavefunction, ψ(r1 , r2 ) =


ϕa (r1 )ϕb (r2 ), which is known as one‑body approximation. In this
case, Eq. (4.8) can be written as

[h(r1 ) + h(r2 )] ϕa (r1 )ϕb (r2 ) = Eϕa (r1 )ϕb (r2 ). (4.9)

Since h(ri ) (i = 1, 2) acts only on ϕα (ri ) (α = a, b) as

h(ri )ϕα (ri ) = ϵα ϕα (ri ), (4.10)

where ϵα is the energy of one electron, the left‐hand side of Eq. (4.9)
is rewritten as

[h(r1 ) + h(r2 )] ϕa (r1 )ϕb (r2 )


= [h(r1 )ϕa (r1 )]ϕb (r2 ) + ϕa (r1 )[h(r2 )ϕb (r2 )]
(4.11)
= ϵa ϕa (r1 )ϕb (r2 ) + ϕa (r1 )ϵb ϕb (r2 )
= (ϵa + ϵb )ϕa (r1 )ϕb (r2 ).

By substituting Eq. (4.11) into Eq. (4.9), we obtain

E = ϵa + ϵb . (4.12)

Thus, for the case of the non‐interacting system with the distinguish‐
able electrons, the total energy of the electrons is the sum of the
energy of each electron.
(2) Two indistinguishable electrons: In quantum mechanics,
two electrons are indistinguishable (i.e., ϕa (r1 )ϕb (r2 ) is equivalent to
ϕa (r2 )ϕb (r1 )). Thus, one possible shape of the wavefunction ψ(r1 , r2 )
is a linear combination of two states as [Kittel (1976)]

1
ψ(r1 , r2 ) = √ [ϕa (r1 )ϕb (r2 ) − ϕb (r1 )ϕa (r2 )], (4.13)
2

where the prefactor √12 is for normalizing the wave function,


|ψ(r1 , r2 )|2 dr1 r2 = 1. Eq. (4.13) shows that the wavefunction is


anti‐symmetric for exchanging r1 and r2 as ψ(r1 , r2 ) = −ψ(r2 , r1 ).


When we put r1 = r2 for ψ(r1 , r2 ), we get ψ = 0. It means that two
electrons cannot occupy the same position, in accordance with the
Quantum ESPRESSO Course for Solid‐State Physics | 175
Pauli exclusion principle [Pauli (1925)]. Eq. (4.13) can also be
written by using a matrix determinant as

1 ϕa (r1 ) ϕb (r1 )


 
ψ(r1 , r2 ) = , (4.14)
2 ϕa (r2 ) ϕb (r2 )

which is known as the Slater determinant [Slater (1929)].


By substituting Eq. (4.13) into Eq. (4.8), we get the same energy
as the case of two distinguishable electrons (i.e., E = ϵa + ϵb ). The
probability of finding an electron at position r, i.e., the electron
density, is given by

n(r) = P1 (r) + P2 (r), (4.15)

where P1 (r) = |ψ(r, r2 )|2 dr2 and P2 (r) = |ψ(r1 , r)|2 dr1 are prob‐
 

abilities of finding first and second electrons at r, respectively, while


other electrons can exist anywhere except for r. Since two electrons
are indistinguishable (i.e., P1 (r) = P2 (r)), Eq. (4.15) can be rewritten
as

n(r) = 2 |ψ(r, r2 )|2 dr2 .



(4.16)

By substituting Eq. (4.13) into Eq. (4.16) and using the normalization
and orthogonality conditions, respectively, as
 
ϕ∗a (r)ϕa (r)dr = ϕ∗b (r)ϕb (r)dr = 1 (4.17)

and
 
ϕ∗b (r)ϕa (r)dr = ϕ∗a (r)ϕb (r)dr = 0, (4.18)

the electron density is expressed by

n(r) = |ϕa (r)|2 + |ϕb (r)|2 . (4.19)

Therefore, the electron density of the non‐interacting electrons is


simply equal to the sum of the squares of the occupied states.

 Electron density and energy of a helium atom without


176 | Density‐Functional Theory

Figure 4.3 Electron density in atomic unit of a helium atom as a function of


r in the approximation of non‐interacting electrons.

Coulomb repulsion: Let us recall that the wavefunction of s‐orbital


and the energy of a hydrogen‐like atom with a nucleus +Ze are given
by

Z3/2 Z2
ϕ(r) = √ exp(−Z|r|) and ϵ = − , (4.20)
π 2

respectively. We note that the hydrogen atom is a special case that


contains only one electron and Eq. (4.20) gives an analytical solution
for Z = 1. By substituting Eq. (4.20) into Eqs. (4.19) and (4.12), the
electron density and energy of the helium atom are given by

2Z3
n(r) = exp(−2Z|r|) and E = −Z2 , (4.21)
π

respectively, when we neglect the interaction between two electrons.


Since the atomic number of a helium atom is Z = 2, the electron
density and total energy are

16
n(r) = exp(−4|r|) (4.22)
π

and E = −4 Ha, respectively. In Fig. 4.3, we plot n(r) of Eq. (4.22) as


a function of the distance r = |r| from the nucleus, respectively.
Quantum ESPRESSO Course for Solid‐State Physics | 177
To compare the calculated energy E with the experimental
values, we remove two electrons from the helium atom as

He+ + e− −
I I
He −
→1
→2
He++ + 2e− , (4.23)

where I1 and I2 are the first and second ionization energies,


respectively. I1 is the minimum energy required to remove the first
electron from the helium atom and is experimentally given as 0.9
Ha (24.59 eV) [Sucher (1958)]. I2 can be calculated exactly since
He+ is a hydrogen‐like ion, thus I2 = −ϵ(He+ ) = 2 Ha. Therefore, the
energy of the helium atom is given by −(I1 + I2 ) = −2.9 Ha, which is
larger than the calculated energy (−4 Ha). In other words, the non‐
interacting electrons approximation gives a large deviation of the
total energy. The reason for the deviation is that we do not consider
the energy of the Coulomb repulsion between the two electrons.

4.4 Hartree potential

In Sec. 4.3, we show that the non‐interacting electrons without


the Coulomb repulsion give a large deviation of the energy. Here
we would like to keep the expression of n(r) as the for the non‐
interacting electrons (Eq. (4.19)), and we will take the Coulomb
repulsion into account in the energy E. When we consider the
Coulomb interaction, Eq. (4.4) can be rewritten as

1
 
h(r1 ) + h(r2 ) + ϕ (r1 )ϕb (r2 ) = Eϕa (r1 )ϕb (r2 ). (4.24)
|r1 − r2 | a

If we multiply ϕ∗b (r2 ) to Eq. (4.24) and integrate both sides of


Eq. (4.24) on r2 with using the normalization condition in Eq. (4.17),
we can obtain the single‑particle Schrödinger equation for the
first electron as

|ϕb (r2 )|2


 
h(r1 ) +

dr2 ϕa (r1 ) = ϵHa ϕa (r1 ), (4.25)
|r1 − r2 |
178 | Density‐Functional Theory

where ϵHa is expressed by

ϵHa = E − ϕ∗b (r2 )h(r2 )ϕb (r2 )dr2 = E − ϵb ,



(4.26)

where ϵb is the energy of the second electron in the non‐interacting


Hamiltonian h(r2 ) as defined by Eq. (4.10). The single‐particle
Schrödingerequation for the second electron also can be written by
multiplying ϕ∗a (r1 )dr1 as

|ϕa (r1 )|2


 
h(r2 ) +

dr1 ϕb (r2 ) = ϵHb ϕb (r2 ), (4.27)
|r1 − r2 |

with

ϵHb = E − ϵa , (4.28)

where ϵa is the energy of the first electron.


The integration in Eq. (4.25) can be rewritten in term of electron
density, n(r2 ) = |ϕa (r2 )|2 + |ϕb (r2 )|2 , as

|ϕb (r2 )|2 n(r2 ) |ϕa (r2 )|2


  
dr2 . (4.29)
|r1 − r2 | |r1 − r2 | |r1 − r2 |
dr2 = dr2 −
     
VH (r1 ) VHsic (r1 )

The first term VH is called the Hartree potential [Hartree (1928)],


which describes the Coulomb repulsion potential as a function of
r1 . The second term VHsic (r1 ) is called the self‑interaction correction
of the Hartree potential, which takes into account that the electron
at the state ϕa shall not interact with itself, but with the remaining
electrons. When the system has many electrons (∼ 1023 ), VHsic can
be neglected since VHsic might contribute negligibly small to the total
energy [Parr and Yang (1989)].
From Eq. (4.25), we can write the energy as a functional of the
wavefunctions as

|ϕb (r2 )|2


 
ϵa = ϕa (r1 ) h(r1 ) +
 
H
|r1 − r2 |

dr2 ϕa (r1 )dr1
(4.30)
|ϕa (r1 )|2 |ϕb (r2 )|2

dr1 dr2 .
|r1 − r2 |
= ϵa +
Quantum ESPRESSO Course for Solid‐State Physics | 179
By substituting Eq. (4.26) into Eq. (4.30), the total energy E is given
by

|ϕa (r1 )|2 |ϕb (r2 )|2


E = ϵa + ϵb +

dr1 dr2 . (4.31)
|r1 − r2 |

Now the total energy E is not equal neither to ϵa + ϵb nor to ϵHa +


ϵHb . This is because the positive Coulomb interaction between the
two electrons is included twice in ϵHa + ϵHb (Eqs. (4.25) and (4.27)).
Therefore, only one term from the inter‐electron interaction is added
to ϵa + ϵb in the expression for E as shown in Eq. (4.31).

4.5 Self‐consistent field

A difficulty in solving the single‐particle Schrödinger equation is that


the Hartree potential VH in Eq. (4.29) requires the value of the state ϕ,
which is not known before we solve the single‐particle Schrödinger
equation in Eq. (4.25). This is called a self‑consistent problem.
The Hartree potential can be expressed in a differential form of
the Maxwell equation as ∇ · E = 4πn(r), where n(r) is the electron
density at r and E = −∇VH (r), where VH (r) is generally called the
electrostatic potential. Combining the two equations, we get the
Possion equation [Jackson (1999)]:

∇2 VH (r) = −4πn(r). (4.32)

The solution of the Poisson equation is given as follows:

n(r′ )

dr′ . (4.33)
|r − r′ |
VH (r) =

Now let us introduce a self‑consistent field (SCF) method that


can be applied to solve the single‐particle Schrödinger equation by
using the Poisson equation. As shown in Fig. 4.4, first, guessing
an initial electron density n(r) for the solution, we put n(r) into
Eq. (4.33) to get the Hartree potential VH (r). Then we put the VH
into the single‐particle Schrödinger equation to get eigenstate ϕ(r)
to obtain the new n(r) = |ϕ(r)|2 , where the sum runs over the


occupied states. We repeat the procedure until n(r) does not change
180 | Density‐Functional Theory

“Guess” initial density

Mixing with α The Poisson equation

The single-particle Schrödinger equation

“New” electron density

Yes Comparison, if and differ

No End

Figure 4.4 Flow‐chart of the self‐consistent field method for the solution of
the single‐particle Schrödinger equation with the Hartree potential VH .

appreciably, that is, the convergence of the solution. This procedure


is called the SCF method. Here, we construct the next guess of n(r)
by mixing nnew (r) with the previous n(r). If the mixing parameter α
(0 < α < 1) is large, we might find oscillating behavior of n(r). We
note that the self‐interaction term VHsic in Eq. (4.29) is neglected in
this>procedure.
Let us consider the example of silicon in Sec. 4.2. By using the SCF
>

method, the 3N‐dimensional configuration space of the Schrödinger


equation is reduced to an N‐single‐particle Schrödinger equations of
three dimensions. In this case, the characteristic size of the arrays
needed for describing the wavefunctions becomes 28 × 50003 for
silicon with 28 electrons in a unit cell, instead of 500084 in Sec. 4.2.
These arrays correspond approximately to a few GB of computer
storage.

 Hartree potential for helium: In order to solve the Poisson


equation for a helium atom, it is more convenient to use spherical
Quantum ESPRESSO Course for Solid‐State Physics | 181
coordinates (r, θ, φ) rather than Cartesian coordinates r = (x, y, z).
These are related to each other by r = |r|, x = r cos θ sin φ, y =
r sin θ cos φ, and z = r cos θ. Referring back to Eq. (4.33), the
Laplacian ∇2 is expressed in spherical coordinates as follows:

1 ∂ ∂
 
2
r 2
r ∂r ∂r
∇ = 2
(4.34)
1 ∂ ∂ 1 ∂2
 
.
r2 sin θ ∂θ ∂θ r2 sin θ ∂φ2
+ sin θ + 2

When we assume that the Hartree potential VH has a spherical


symmetry, the derivatives of VH with respect to θ and φ become zero.
Then the Poisson equation is given by a differential equation on r as
follows:

1 ∂ 2 ∂VH
 
r (4.35)
r2 ∂r ∂r
= −4πn(r).

Integrating Eq. (4.35) on r we obtain

r
1 r′
C
r′′ n(r′′ )dr′ dr′′ −
 
. (4.36)
2
r′2 r
VH (r) = −4π
0 0

It is noted that C/r in Eq. (4.36) is a solution of Eq. (4.35) for any value
of C. Then by substituting the electron density of the helium atom in
Eq. (4.21) into Eq. (4.36) and using

x
1 x′
2
x′′ exp(x′′ )dx′ dx′′ = (1 −
 
(4.37)
2
x′2 x
) exp(x),
0 0

Eq. (4.36) becomes

1 C
 
VH (r) = −2 Z + . (4.38)
r r
exp(−2Zr) −

At the limit of r → ∞, from Eq. (4.33), we have VH (r) −−−→


r→∞

1
r n(r′ )dr′ = Zr . Applying this boundary condition for Eq. (4.38), we
obtain C = −Z, and Eq. (4.38) can be rewritten for the helium atom
182 | Density‐Functional Theory

Figure 4.5 The Hartree potential VH (r) (solid line), the Coulomb attraction
between electrons and nuclei Ven (dotted line), and the total potential Ven +
VH (r) (dashed line) of helium atom are plotted in atomic unit as functions of
r.

as

1 Z
 
VH (r) = −2 Z + exp(−2Zr) + . (4.39)
r r

In Fig. 4.5, we show VH (r) with Z = 2 (solid line), the Coulomb


attractive interaction between electrons and nuclei Ven (r) = −2/r
(dotted line), and the total potential Ven (r) + VH (r) (dashed line)
of the helium atom as functions of r. When r increases, the total
potential decays exponentially. This trend is incorrect since the
total potential of the helium atom decays as −1/r at a large
distance [Umrigar and Gonze (1994)]. This is because we neglect
some interactions, which will be introduced in the next section.

4.6 Exchange potential

In Sec. 4.5, we show that the Schrödinger equation can be solved by


using the Hartree approximation and the SCF method. In the Hartree
approximation, the Coulomb repulsion between two electrons in
the system is approximated by the Hartree potential, in which
each individual electron moves independently of each other, only
Quantum ESPRESSO Course for Solid‐State Physics | 183
feeling the averaged electrostatic potential by the other electrons.
However, in 1930, Slater pointed out that the Hartree method
did not take into account the Pauli exclusion principle for many
electrons [Slater (1930b)]. That is, if two electrons have parallel
spins to each other, they are not allowed to occupy the same states
at the same time. Since the two electrons can not be close to each
other by the Pauli principle, the Coulomb repulsion can not be very
large. In order to take account of the Pauli exclusion principle, we
introduce an exchange potential, which is an attractive Coulomb
interaction between two electrons with parallel spins. We note < that
the Hartree potential is a repulsive Coulomb interaction between
an electron and electron density of the other electrons (VH > 0, see
Fig. 4.5). Exchange potential is a correction term to VH , which is over‐
estimated compared with the real case.
By using the Slater determinant in Eq. (4.14), Eq. (4.8) can be
rewritten as

1
 
h(r1 ) + h(r2 ) +
|r1 − r2 |
[ϕa (r1 )ϕb (r2 ) − ϕb (r1 )ϕa (r2 )]
(4.40)
= E[ϕa (r1 )ϕb (r2 ) − ϕb (r1 )ϕa (r2 )].

By multiplying ϕ∗b (r2 ) in Eq. (4.40) and integrating over r2 with the
normalization and orthogonality conditions (Eqs. (4.17) and (4.18)),
we obtain:

h(r1 )ϕa (r1 ) + ϕa (r1 )



ϕ∗b (r2 )ϕb (r2 )
|r1 − r2 |
dr2
 (4.41)
ϕ∗b (r2 )ϕb (r1 )
ϕa (r2 )dr2 = ϵHF
|r1 − r2 | a ϕa (r1 ),

where ϵHF
a is defined by

=E− ϕ∗b (r2 )h(r2 )ϕb (r2 )dr2 = E − ϵb .



ϵHF
a (4.42)
184 | Density‐Functional Theory

By substituting Eq. (4.29) into Eq. (4.41), we obtain the single‐


particle Schrödinger equation for ϕa (r1 ) as

γ(r2 , r1 )

a ϕa (r1 ), (4.43)
ϕ (r2 )dr2 = ϵHF
|r1 − r2 | a
[h(r1 ) + VH (r1 )] ϕa (r1 ) −

where γ(r2 , r1 ) is defined as

γ(r2 , r1 ) = ϕ∗a (r2 )ϕa (r1 ) + ϕ∗b (r2 )ϕb (r1 ). (4.44)

The single‐particle Schrödinger equation also can be written for


ϕa (r2 ) as

γ(r1 , r2 )

b ϕb (r2 ), (4.45)
ϕ (r1 )dr1 = ϵHF
|r1 − r2 | b
[h(r2 ) + VH (r2 )] ϕb (r2 ) −

in which ϵHF
b is symmetrically given by

b = E − ϵa .
ϵHF (4.46)

Eq. (4.43) or (4.45) is known as the Hartree‑Fock equa‑


tion [Fock (1930)], in which the exchange potential Vx in Eq. (4.43)
is defined by

γ(r2 , r1 )
Vx (r1 , r2 ) = − . (4.47)
|r1 − r2 |

Vx exists only for two electrons at r1 and r2 , which have the same
quantum state ϕa or ϕb including spin, i.e., the exchange potential
is the effective Coulomb interaction between the electrons with
parallel spins in the system. The origin of Vx is that two‐electrons
with the same spin can not exist at the same position (r1 = r2 ), in
which VH should be small by the restriction of the Pauli principle. By
considering both VH and Vx in Eq. (4.39), two electrons are interacted
not only by their electronic charge but also by their spins. Therefore,
the quantum behavior of electrons is included by Vx term in the
Hartree‐Fock equation. It is important to note that Vx is a non‑local
potential on r1 since it depends on an integration over the additional
variable r2 . Therefore, the practical solution of the Hartree‐Fock
equation becomes more complicated and time‐consuming.
Quantum ESPRESSO Course for Solid‐State Physics | 185
Let us discuss the energy that is obtained by the Hartree‐Fock
equation. From Eq. (4.43), we can write the energy by integrating the
wavefunctions as


ϵHF
a = ϕ∗a (r1 )[h(r1 ) + VH (r1 )]ϕa (r1 )dr1

γ(r2 , r1 ) (4.48)
ϕ (r2 )dr1 r2


|r1 − r2 | a
+ ϕ∗a (r1 )

=ϵa + J − K,

where J and K are called the Coulomb and exchange integrals,


respectively, which are given by

|ϕa (r1 )|2 |ϕb (r2 )|2


J=

(4.49)
|r1 − r2 |
dr1 dr2

and

K=

dr1 dr2 . (4.50)
ϕ∗a (r1 )ϕb (r1 )ϕ∗b (r2 )ϕa (r2 )
|r1 − r2 |

J represents the Coulomb repulsion between the electron at the state


ϕa (r1 ) and the other electron at the state ϕb (r2 ). K has a physical
interpretation of the overestimate of the Coulomb interaction for two
electrons in the case of the parallel spins. It means that with the
parallel spins, the two electrons can not be close to each other by the
Pauli exclusion principle. It is noted that both values of J and K are
the positive values and J ≥ K, as shown below [Roothaan (1951)]:
By substituting Eq. (4.46) into Eq. (4.48), the total electron
energy E in the Hartree‐Fock approximation is expressed by

E = ϵa + ϵb + J − K. (4.51)
186 | Density‐Functional Theory

On the other hand, from Eq. (4.40), the total electron energy can be
obtained, too, as

E= ψ∗ (r1 , r2 )[h(r1 ) + h(r2 )]ψ(r1 , r2 )dr1 dr2




1
ψ∗ (r1 , r2 ) ψ(r1 , r2 )dr1 r2

(4.52)
|r1 − r2 |
+

|ψ(r2 , r1 )|2
dr1 r2 .


|r1 − r2 |
= ϵa + ϵb +

By subtracting Eq. (4.52) from Eq. (4.51), we obtain:

|ψ(r1 , r2 )|2
J−K=

dr1 dr2 ≥ 0. (4.53)
|r1 − r2 |

Therefore, J ≥ K and the total electron energy E is always larger than


the sum of the one‐electron energies (ϵa + ϵb ) because of the net
repulsion Coulomb interaction between two electrons.

 Total energy of helium atom: In the case of the helium atom, two
electrons at the 1s state ϕ must have different spin directions, up ↑
and down ↓ because of the Pauli principle. Let us consider the spin
states of two electrons, respectively, as

1 0
   
and ϕ↓ (r) = ϕ(r) , (4.54)
0 1
ϕ↑ (r) = ϕ(r)

where 10 and 01 correspond to up‐ and down‐spin wavefunctions,


 

respectively. From Eq. (4.54), we define the product of two spin‐


functions as follows:

  1
 
ϕ∗↑ (r)ϕ↑ (r) = ϕ2 (r) 1 0 = ϕ2 (r), (4.55)
0

and

  0
 
ϕ∗↑ (r)ϕ↓ (r) = ϕ2 (r) 1 0 = 0. (4.56)
1
Quantum ESPRESSO Course for Solid‐State Physics | 187
By substituting Eqs. (4.55) and (4.56) into Eqs. (4.49) and (4.50),
respectively, we obtain:

2 2
J=
 
drdr′ ,
ϕ∗↑ (r)ϕ↑ (r)ϕ∗↓ (r′ )ϕ↓ (r′ ) |ϕ(r)| |ϕ(r′ )|
|r − r′ |2 |r − r′ |2
drdr′ =

(4.57)

and

K=

drdr′ = 0. (4.58)
ϕ∗↑ (r)ϕ↓ (r)ϕ∗↓ (r′ )ϕ↑ (r′ )
|r − r′ |2

K = 0 is consistent with fact that the exchange potential is zero since


there are no parallel spins. Since the electronic density is expressed
as n(r′ ) = |ϕ↑ (r′ )|2 + |ϕ↓ (r′ )|2 = 2|ϕ(r′ )|2 , the Coulomb integral in
Eq. (4.57) can be rewritten as

1 |ϕ(r)|2 n(r′ ) 1
J=
 
|ϕ(r)|2 VH (r)dr. (4.59)
2 |r − r′ |2 2
drdr′ =

By substituting J in Eq. (4.59) and K = 0 in Eq. (4.58) into Eq. (4.51),


the total electron energy E is expressed as

1
E = 2ϵ +

|ϕ(r)|2 VH (r)dr. (4.60)
2

In order to apply Eq. (4.60) for the helium atom, we define an effective
atomic number Z, i.e., ϕ(r, Z), which gives minimized E when subject
to the Hartree potential VH (r). Eq. (4.60) can be obtained by the
following steps:
• Step 1: Using a beginning value Z = 2, from Eq. (4.39), the
Hartree potential VH (r) is given by

1 2
 
VH (r) = −2 2 + exp(−4r) + . (4.61)
r r
188 | Density‐Functional Theory

E = 2ϵ + J − K

Eexp = − 2.9 Ha

E = 2ϵ

Figure 4.6 Total electron energy of helium atom as a function of effective


atomic number Z. E = 2ϵ and E = 2ϵ + J − K are corresponding to the cases
of non‐interacting electrons and Hartree‐Fock approximation, respectively.
Experimental value Eexp of the helium atom is −2.9 Ha [Sucher (1958)].

• Step 2: By substituting Eq. (4.61) and ϕ(r, Z) = Z√


exp(−Z|r|) in
3/2

Eq. (4.20) into Eq. (4.60), we obtain:


π

E = Z2 − 4Z +2π r2 |ϕ(r, Z)|2 VH (r)dr



  

(4.62)
Z3 (Z + 4)
= Z − 3Z +
2
.
(Z + 2)3

• Step 3: According to the variational principle,6 we minimize E


with respect to the variational parameter Z, i.e., dE/dZ = 0 for E in
Eq. (4.62). We can obtain the effective atomic number Zeff = 1.826
and the value of E at Z = Zeff is about −2.777 Ha.
In Fig. 4.6, we show the energies for the two cases of the non‐
interacting electrons, E = 2ϵ, and the Hartree‐Fock approximation,
E = 2ϵ + J − K, as functions of the effective atomic number Z. For E =
2ϵ, the electrons feel a potential corresponding to the nucleus with a
charge Z = 2, but it makes the error for E as discussed in Sec. 4.3. For
E = 2ϵ + J − K, the electrons feel a potential with a reduced charge
Z = 1.826. Eq. (4.60) can also be solved by the SCF method. This

6 The variational principle states that the energy of any approximate wavefunction is

higher than or equal to the energy of ground‐state wavefunction. The lower the
energy is the better the approximation to the ground state.
Quantum ESPRESSO Course for Solid‐State Physics | 189
could be done by recalculating the Hartree potential with new state
ϕ(r, Zeff = 1.826) in Step 1, then we recalculate Steps 2 and 3 until
the value of Zeff does not change significantly. Finally, we can obtain
the Eeff = −2.85 Ha, which is not too far from the exact value from the
experiment about −2.9 Ha. Slater derived a formula to determine Zeff
as Zeff = Z − S, where S is the shielding constant, which is known as
Slater’s rule [Slater (1930a)]. For the 1s state in the helium atom,
S = 0.3 and Zeff = 1.7, which is close to the result of the SCF method
(Zeff = 1.826).

4.7 Correlation potential

In Sec. 4.6, we show that due to the Pauli exclusion principle, the
electrons with parallel spins have an exchange term of the Coulomb
interaction Vx . The two electrons with the parallel spin move to avoid
each other because the electrons can not overlap. Avoiding picture
should exist for the two electrons with anti‐parallel spins because
these electrons also move with keeping apart to lower the Coulomb
repulsion. This behavior of the electrons with anti‐parallel spins is
missing in the Hartree approximation as well as in the Hartree‐Fock
approximation. A complete picture of the motion of an electron in a
system is shown in Fig. 4.7. In general, the correlation interaction,
Vc , is defined by the remaining term that is missing in the Hartree‐
Fock method.7 Thus, an effective potential in the single‐particle
Schrödinger equation is defined by

Veff = Ven + VH + Vxc , (4.63)

where Vxc ≡ Vx + Vc is called the exchange‑correlation potential.


Since VH is obtained by the total electron density n(r), it suggests
that if Vxc can be expressed by a functional of n(r), the single‐particle
Schrödinger equation can be written as

∇2r
 
(4.64)
2
− + Veff [n(r)] ϕ(r) = ϵϕ(r).

7 The correlation interaction is defined in the field of the density‐functional theory.


190 | Density‐Functional Theory

Vx
VH Vc

Vc

Figure 4.7 The motion of an electron with up‐spin in a system is affected by


three interactions, including the Hartree VH , exchange Vx , and correlation Vc
potentials. VH is the Coulomb interaction between one electron and the total
charge density, which is generated by all electrons in the system. Vx arises
due to the Pauli exclusion principle, in which the electrons with parallel spins
can not exist at the same position at the same time. Vc arises due to the
fact that the electrons with anti‐parallel spins also keep apart to lower their
mutual Coulomb repulsion.

When we know the value of Vxc [n(r)], Eq. (4.64) can be solved by
using the SCF method as discussed in Sec. 4.5. However, we do not
know the exact shape of Vxc [n(r)]. Many people proposed the many
functionals for Vxc [n(r)] over the past few decades. The efforts to
develop the accurate approximations for Vxc [n(r)] led to a theory,
the so‐called density‐functional theory (DFT). We will discuss these
approximations in the next section.

4.8 Early DFT for free‐electron gas

Let us consider how to obtain Vxc [n(r)] for a free‐electron gas, where
the contribution of ions is treated as a uniform‐positive‐charge
background, which is called the Jellium model [Brack (1993)], as
shown in Fig. 4.8. Since the potential is uniform, the electronic states
are expressed by plane waves as (see Sec. 5.3)

1
ϕk,σ (r) = √ exp(ikr)χ σ , (4.65)
V
Quantum ESPRESSO Course for Solid‐State Physics | 191
Positive ion charges Uniform background
+ + + + + + +
+
+ + + + + + + +

+ + + + + + + +
+ + + + + + +
+

Figure 4.8 A free‐electron gas, where the contribution of nuclear ions is


treated as a uniform‐positive‐charge background.

where V is the volume of the system, k is the wavevector, and χ σ is


the spin function, in which 10 for spin‐up and 01 for spin‐down.
 

Since the unit cell can not be defined by the uniform background,
the value of k is taken not from the Brillouin zone but all the k
space. Since ϕk,σ (r) is a one‐electron wavefunction, ϕk,σ (r) can be
a solution of the Hartree‐Fock equation in Eq. (4.43). Moreover, in
the free‐electron gas, the electron density of the ground state is
also a uniform‐negative‐charge background. Therefore, the electron
density cancels the positive charge background, i.e., Ven + VH = 0
and only the exchange term Vx survives in Eq. (4.43). Thus, the single‐
particle Schrödinger equation of a free‐electron gas can be written as

Vx (r′ , r)ϕk,σ (r′ )dr′ = ϵk ϕk,σ (r),



∇r
(4.66)
2 k,σ
− ϕ (r) +
  
Ix

where the integral Ix is given by

Ix = −
   ϕ∗k′ ,σ′ (r′ )ϕk′ ,σ′ (r)
|r − r′ |
ϕk,σ (r′ )dr′
k
(4.67)
σ ′ ′

 ∗
ϕk′ ,σ′ (r′ )ϕk,σ (r′ ) ′
dr .

|r − r′ |
=− ϕk′ ,σ′ (r)
′ σ′ k
192 | Density‐Functional Theory

By substituting the electronic states in Eq. (4.65) into Eq. (4.67),


we obtain:

 1 exp − i(k′ − k)r′


 
Ix = − exp(ik r)χ σ


V3/2 |r − r′ |

dr′
k ′

 1  exp − i(k′ − k)(r′ − r)


   
dr′ ϕk,σ (r) (4.68)
V r
= −
k′
|r − ′|

 
f(k − k) ϕk,σ (r),
 ′
= −
k′

where the function f is defined as

1 1 4π
f(q) =

, (4.69)
exp(−iqx)
V V q2
dx =
|x|

with q = k′ − k and x = r′ − r. By substituting Eq. (4.69) into


Eq. (4.68), we obtain:

1 4π
 
Ix = −
V ′ |k′ − k|2
ϕk,σ (r)
k

1 4π
  kF 
(4.70)
(2π)3 0 |k′ − k|2
= − dk ϕk,σ (r)

kF k
 
=− F
kF
ϕk,σ (r),
π

where k = |k|, kF is the Fermi wavevector, and F is called the


Lindhard function:

1 − x2  1 + x  k
 
F(x) = 1 + , with x = . (4.71)
2x 1 − x kF
ln 

The function F(x) is shown in Fig. 4.9. F(x) monotonically decreases


from 2 at x = 0 (or k = 0) to 1 at x = 1 (or k = kF ).
Quantum ESPRESSO Course for Solid‐State Physics | 193

k = kF

Figure 4.9 The Lindhard function F(x) is plotted as a function of the


dimensionless x = k/kF .

By substituting Eq. (4.70) into Eq. (4.66), Eq. (4.66) can be


rewritten as

kF k
  
− F
∇r
(4.72)
kF
ϕk,σ (r) = ϵk ϕk,σ (r).
2

π

Then we can obtain the energy as a function of wavevector k as

k2 kF k
 
− F . (4.73)
kF
ϵk,σ
2
=
π

By taking the sum of all occupied states, we obtain the total energy
as
  k2 1   kF
 
k
E= F
2 2 σ kF

σ |k| < kF
π
|k|<kF

2V k kF V k
 kF 2  kF  
F
(2π)3 >0 2 π (2π)3 0 kF
= dk − dk

V k kF V k
 kF 4  kF  
4π dk − 4 4π k F
2
(4.74)
4π3 2 8π k
= dk
0 0 F

V 5 V 4 1 2
k − k x F(x)dx


10π2 F 2π3 F 0
=
  

V 5 V
=1/2

kF − 3 k4F ,
10π 2 4π
=
194 | Density‐Functional Theory

with the factor of 1/2 in the second term of the right‐hand side in the
first line of Eq. (4.74) is needed to compensate for double counting
of the exchange interaction.
For the free‐electron gas, the number of electrons Ne is equal to
the number of occupied states in the systems:

kF
V kF
k3F
Ne = k2 dk = V
 
= 2V . (4.75)
 dk
(2π)3 3π2
= 2
σ k 0 π 0

Therefore, the electron density n is expressed by

Ne k3
n= = F2 . (4.76)
V 3π

By substituting Eqs. (4.75) and (4.76) into Eq. (4.74), the total energy
per electron is expressed by

E
= C1 n2/3 + C2 n1/3 , (4.77)
Ne

where C1 and C2 are constants given by

3 3 3
 1/3
C1 = (3π2 )2/3 = 2.871 and C2 = − = −0.738. (4.78)
10 4 π

The first term (C1 n2/3 ) in Eq. (4.77) represents the kinetic energy, and
the second term (C2 n1/3 ) represents the effective electron‐electron
interaction due to exchange potential. We can see that the exchange
potential reduces the total energy of the system from the kinetic
energy.
For a system with the free electron gas, n is a constant. However,
for a system with the non‐uniform‐electron charge, n becomes
a function of r. Slater [Slater (1951)] introduced the exchange
potential as a function of n(r) as

3 3
 1/3
Vx [n(r)] = 2C2 n1/3 (r) = − n1/3 (r), (4.79)
2 π

where an extra factor of 2 is introduced to account in Eq. (4.79)


because the Vx term in the single‐particle equation (Eq. (4.64)) is
Quantum ESPRESSO Course for Solid‐State Physics | 195
twice as large as the corresponding term in the total energy per
particle (Eq. (4.77)).
For an approximation to include the correlation effects, Slater
and Johnson [Slater and Johnson (1972)] introduced a “fudge factor”
α in Eq. (4.79) as

Vxc [n(r)] = 2αC2 n1/3 (r), (4.80)

where α usually taken in the range 2/3 < α < 1. For example, α =
0.772 and 0.978 [Schwarz (1972)] for He and H atoms, respectively.
Eq. (4.80) is called the Xα potential. > >

4.9 Thomas‐Fermi‐Dirac theory

In Sec. 4.8, we consider a free‐electron gas with a uniform‐positive


background. However, the ions are not represented by a uniform‐
positive background in the real materials. The Thomas‐Fermi‐
Dirac theory gives a first approximation to calculate the total
energy of non‐uniform systems. It is important to note that both
papers [Thomas (1927), Fermi (1928)] published by Thomas and
Fermi in 1927 and 1928, respectively, before the development of the
Hartree‐Fock theory in 1930. Although Thomas and Fermi neglected
exchange and correction potentials, the approximation was extended
by Dirac [Dirac (1930)] in 1930 based on the Hartree‐Fock theory.
Let us consider an atom with Ne electrons, and thus the
atomic number is Z = Ne . We assume that the presence of the non‐
uniform‐positive charge does not change the Hartree‐Fock results
significantly (in Sec. 4.8) for kinetic and exchange energies of the
uniform background. In this case, the total energy per atom in
Eq. (4.77) is modified by adding two terms as follows:

E Z 1 n(r′ )
= C1 n2/3 + C2 n1/3 −

dr′ , (4.81)
Ne |r| 2 |r − r′ |
+

where Z/|r| is the external potential that each electron feels the
presence of the ions and the last term is the Coulomb repulsion
between an electron at position r and all other electrons at r′ , which
is expressed by the density n(r′ ). The factor of 1/2 of the last term
196 | Density‐Functional Theory

is given by avoiding the double‐counting of the Coulomb interaction.


For the non‐uniform systems, Ne is defined by

Ne = n(r)dr.

(4.82)

By substituting Eq. (4.82) into Eq. (4.81), the total energy of the
system is expressed as

E[n(r)] = C1 n (r)dr + C2 n4/3 (r)dr


 
5/3

(4.83)
n(r) 1 n(r)n(r′ ) ′
−Z
 

2 |r − r′ |
dr + dr dr,
|r|

where the first and second terms of the right‐hand side are the
kinetic and exchange energies of the free‐electron gas, respectively,
the third term is the Coulomb attraction between the ions and the
electron density, and the last term describes Coulomb repulsion
between the electrons. n(r) for the ground‐state and the total
energy of the system can be obtained by minimizing the energy
functional E[n(r)]. Although the Thomas‐Fermi‐Dirac approximation
is not accurate good‐enough compared with the present electronic
structure calculation, the approach shows a prototype expression of
the DFT, in which n(r) is a crucial physical quantity to calculate the
ground‐state properties of a many‐electron system.

4.10 DFT: Hohenberg‐Kohn‐Sham

The DFT is established by two papers by Hohenberg and


Kohn in 1964 [Hohenberg and Kohn (1964)] and Kohn and
Sham [Kohn and Sham (1965)] in 1965. The original formulation
discussed in the first paper of Hohenberg and Kohn, which is known
as the Hohenberg‑Kohn theorem. The second paper of Kohn and
Sham developed a method to apply the Hohenberg‐Kohn theorem,
which is referred to as the Kohn‑Sham equation.
Quantum ESPRESSO Course for Solid‐State Physics | 197
4.10.1 Hohenberg‐Kohn theorem

Theorem: There is a one‐to‐one correspondence between


an external potential Ven (r) and an electron density
n(r) [Hohenberg and Kohn (1964)].

Proof: To prove the theorem, we suppose that two different external


potentials, Ven (r) and Ven

(r), give the same electron density n(r). We
will show that this situation is not possible. Let us consider the two
Hamiltonians H and H′ , which contain Ven and Ven ′
, respectively, as
follows:

H = F + Ven and H′ = F + Ven



, (4.84)

where F includes all the terms in the Hamiltonian except for the
external potential. That means that F contains the kinetic energy and
electron‐electron interaction terms. Therefore, F has the same shape
for all Ne ‐electrons systems with any external potentials.
The total energies of the ground states of the Hamiltonians is
given by

E = ⟨ψ|H|ψ⟩ and E′ = ⟨ψ′ |H′ |ψ′ ⟩, (4.85)

where ψ and ψ′ are the wavefunctions of the ground states of H and


H′ , respectively. Here we can say that E ̸= E′ and ψ ̸= ψ′ because the
potentials are not the same. According to the variational principle,
we have:

E < ⟨ψ′ |H|ψ′ ⟩ = ⟨ψ′ |H′ − Ven + Ven |ψ′ ⟩


(4.86)

= E′ + ⟨ψ′ |Ven − Ven



|ψ′ ⟩,
>
and

E′ < ⟨ψ|H′ |ψ⟩ = ⟨ψ|H − Ven + Ven


(4.87)

|ψ⟩
= E − ⟨ψ|Ven − Ven

|ψ⟩.
198 | Density‐Functional Theory

By adding Eqs. (4.86) and (4.87), we obtain:

(E + E′ ) < (E + E′ ) + ⟨ψ′ |Ven − Ven



|ψ′ ⟩ − ⟨ψ|Ven − Ven

|ψ⟩. (4.88)

If the both Ven and Ven



gave the same electron density n(r), the two
terms on the right‐hand side of Eq. (4.88) would be expressed by

(r)] n(r)dr

⟨ψ |Ven −

Ven

|ψ′ ⟩ = [Ven (r) − Ven

(4.89)

and

(r)] n(r)dr.

⟨ψ|Ven − Ven

|ψ⟩ = [Ven (r) − Ven

(4.90)

Eqs. (4.88), (4.89), and (4.90) lead to the contradictory relation


E + E′ < E + E′ . Therefore, our assumption that n(r) is the same
with the different external potentials is not correct. This proves the
Hohenberg‐Kohn theorem.
Corollary 1: The electron density n(r) uniquely specifies the external
>

potential Ven (r) and hence the Hamiltonian H. Because the ground‐
state wavefunction ψ is obtained by solving the Schrödinger equation
for H, ψ must be a unique functional of n(r). Therefore, we obtain the
following equation:

⟨ψ|H − Ven |ψ⟩ = ⟨ψ|F|ψ⟩ = F[n(r)], (4.91)

which tells us that F must be a functional of n(r).


We can also conclude that the total energy E is a functional of
n(r), and E is given by

E[n(r)] = ⟨ψ|H|ψ⟩ = F[n(r)] +



Ven (r)n(r)dr. (4.92)

According to the variational principle, we can deduce that for a given


Ven (r), Eq. (4.92) gives the global minimum value for the correct
electron density n(r). This is because that for any other density n′ (r),
Quantum ESPRESSO Course for Solid‐State Physics | 199
we get a larger E[n′ (r)]:

E[n′ (r)] = F n′ (r) +



 <
Ven (r)n′ (r)dr
(4.93)
= ⟨ψ′ |H|ψ′ ⟩ > ⟨ψ|H|ψ⟩ = E[n(r)].

Corollary 2: If the functional F[n(r)] was known, then by minimizing


the total energy in Eq. (4.92), with respect to variations in the electron
density n(r), the ground state of the electron density and the total
energy are obtained. Therefore, it is important to develop adequate
approximations for the functional F[n(r)] that will be discussed
in Sec. 4.10.2. It is noted that the functional F[n(r)] determines
only non‐degenerated ground state, and thus the Hohenberg‐Kohn
theorem does not provide any guidance concerning excited states.

4.10.2 Kohn‐Sham equation

In Sec. 4.10.1, we discussed the Hohenberg‐Kohn theorem, which


guarantees to give the ground‐state energy. However, the theorem
does not provide any analytical solution of the ground state since
the functional F[n(r)] of Eq. (4.92) is not explicitly given. Kohn and
Sham [Kohn and Sham (1965)] provided an explicit form for F[n(r)]
and constructing the Schrödinger‐like equation based on F[n(r)]
with the SCF method (see Sec. 4.5), which allows the implementation
to computer codes.
Let us write the functional F[n(r)] for the single‐particle states
ϕi (r) as

1 n(r)n(r′ )

drdr′ + Exc [n(r)], (4.94)
|r − r′ |
F[n(r)] = Ke [n(r)] +
2

where electron density n(r) is given by Eq. (4.19) as

n(r) = |ϕi (r)|2 , (4.95)




i
200 | Density‐Functional Theory

Ke [n(r)] represents the kinetic energy of single‐particle states:

 ∇2 
  

Ke [n(r)] = ϕi − r  ϕi , (4.96)
i
2

the second term of the right‐hand side represents the electrostatic


Coulomb repulsion between electrons, with a factor of 1/2 due
to the double counting, and Exc [n(r)] is the exchange‑correlation
functional, which contains all other contributions to the many‐body
energy of electrons. It is noted that Ke [n(r)] is not the exact kinetic
energy of the many‐body system of electrons; thus Exc [n(r)] is needed
to reproduce the correct functional Ke [n(r)].
When we apply the Hohenberg‐Kohn theorem by substituting
Eq. (4.94) into Eq. (4.92), the total energy is given by

1 n(r)n(r′ )
E[n(r)] = Ke [n(r)] +


2 |r − r′ |
drdr′
 (4.97)
+ Exc [n(r)] + Ven (r)n(r)dr,

that we need to minimize with respect to n(r) in order to obtain


the ground‐state energy. We consider a variation in the electron
density with the constraint that the total number of electrons does
not change:

δn(r)dr = 0. (4.98)

By using the Lagrange multiplier, ϵi , with the constraint in Eq. (4.98),


we obtain the Kohn‑Sham equation as

∇2r
 
+ Veff [n(r)] ϕi (r) = ϵi ϕi (r), (4.99)
2

where the effective potential Veff [n(r)] is given by

n(r′ )

δExc [n(r)]
, (4.100)
|r − r′ |
Veff [n(r)] = Ven (r) + dr′ +
δn(r)

where the first term Ven (r) is the external potential due to the ions,
the second term is the Hartree potential VH (see Eq. (4.33)) and the
Quantum ESPRESSO Course for Solid‐State Physics | 201
last term is the variational functional derivative of the exchange‐
correlation interaction Exc [n(r)]. The last term in Eq. (4.100) is
defined as the exchange‑correlation potential:

δExc [n(r)]
Vxc [n(r)] = . (4.101)
δn(r)

By assuming that one knows Exc [n(r)] or at least an adequate


approximation, the Kohn‐Sham equation in Eq. (4.99) can be solved
by the SCF method (see Sec. 4.5) by the following steps:

1. Make an initial guess of nin (r).


2. Calculate Vxc [nin (r)] in Eq. (4.101) and therewith Veff [nin (r)]
in Eq. (4.100).
3. Solve Eq. (4.99) to get ϕi (r).
4. Calculate the new electron density nnew (r) via Eq. (4.95).
5. If nnew (r) is not equal to nin (r), we go back to step (1).
6. If nnew (r) is equal to nin (r), we calculate the total energy by
using Eq. (4.97).

The SCF calculation is an essential step in Quantum ESPRESSO.


The run‐time tutorial for the SCF calculation is shown in Sec. 3.1.1.

4.10.3 Relationship between Kohn‐Sham energy and total


energy

Multiplying the Kohn‐Sham equation in Eq. (4.99) by ϕ∗i (r) from the
left and summing over all occupied states, we obtain the Kohn‑Sham
energy as


(4.102)

ϵi = Ke [n(r)] + Veff (r)n(r)dr.
i
202 | Density‐Functional Theory

By substituting Veff (r) from Eq. (4.100) into Eq. (4.102), then
subtracting the total energy E[n(r)] in Eq. (4.97), we find:

1 n(r)n(r′ )
E[n(r)] =
 

|r − r′ |
ϵi −
2
drdr′ − ΔExc [n(r)]
i
(4.103)
1
 
ϵi − VH (r)n(r)dr − ΔExc [n(r)],
2
=
i

where ΔExc [n(r)] is the difference between exchange and correlation


potentials as

ΔExc [n(r)] = Vxc (r)n(r)dr − Exc [n(r)]. (4.104)

4.11 Exchange‐correlation functional

In Sec. 4.10, we show that how the ground‐state properties are


calculated by the Kohn‐Sham equation. Unfortunately, the exact form
of the exchange‐correlation functional Exc [n(r)] is not known, and we
should take an approximation from many proposed approximations.
The most common approximations are the local‑density approxi‑
mation (LDA) and the generalized gradient approximation (GGA),
which will be discussed in Sec. 4.11.1 and Sec. 4.11.2, respectively. We
also discuss the hybrid functionals in Sec. 4.11.3, which is beyond
the LDA and GGA.

4.11.1 Local‐density approximation

The LDA is an approximation of Exc [n(r)] based on the uniform‐


electron system as discussed in Sec. 4.8. As shown in Eq. (4.77),
the contribution of exchange interaction to the total energy for the
uniform‐electron charge is:

Ex (n) = Ne C2 n1/3 , (4.105)

with C2 = −0.738 (see Eq. (4.78)).


Quantum ESPRESSO Course for Solid‐State Physics | 203
Now, let us consider Eq. (4.105) for the case of the non‐uniform‐
electron charge, in which n is a function of r. If n(r) is a slowly varying
function, the exchange functional Ex [n(r)] is approximated as

ExLDA [n(r)] ≈ Ne C2 n1/3 (r). (4.106)

By substituting the number of electrons Ne in Eq. (4.82) into


Eq. (4.83), we obtain:

ExLDA [n(r)] = ϵx (r)n(r)dr, (4.107)

where ϵx (r) is the exchange energy, which is defined by

ϵx (r) = C2 n1/3 (r). (4.108)

Eq. (4.108) allows to calculate the exchange potential Vx [n(r)] as

δExLDA [n(r)] ∂[ϵx (r)n(r)] 4


= C2 n1/3 (r). (4.109)
∂n(r)
Vx [n(r)] =
3
=
δn(r)

Note that the ratio of the exchange potential in Eq. (4.109) to the
Slater exchange potential in Eq. (4.79) is 2/3.
Since Eq. (4.107) is based on the free‐electron gas (see Sec. 4.8),
the correlation interaction is needed to capture accurately the many‐
body system. Therefore, the energy of correlation interaction ϵc (r) is
added to Eq. (4.107) as

LDA
Exc [n(r)] = [ϵx (r) + ϵc (r)]n(r)dr. (4.110)

When we consider two limit cases of high‐density limit (n → ∞)


and low‐density limit (n → 0), ϵc (r) is proposed in analytic forms by
many groups as follows:
For the high‑density limit:

[ai ln rs + bi ]ris = a0 ln rs + b0 + … (rs ≪ 1), (4.111)




ϵc (rs ) =
i=0
204 | Density‐Functional Theory

where rs is the radius of a sphere containing a single electron in the


atomic unit, which is defined by

4πr3s 1 3
 1/3
, or rs = , (4.112)
3 n(r) 4πn(r)
=

and a0 = 0.0311 and b0 = −0.048 are given by Gell‐Mann and


Brueckner [Gell‐Mann and Brueckner (1957)] with neglecting con‐
tributions to the coefficients of higher order terms (i ≥ 1).
For the low‑density limit:

ci c0 c1 c2
+ 3/2 + 2 + … (rs ≫ 1), (4.113)


rs rs
ϵc (rs ) =
i=0 rs rs
i/2+1
=

where c0 = −1.792, c1 = 2.65, and c2 = −0.73 are given by Carr et


al. [Carr Jr et al. (1961)] for a body‐centered‐cubic lattice system, in
which the higher order terms i ≥ 2 are neglected.
The more accurate numerical calculation of ϵc (rs ) is given by
Ceperley and Alder [Ceperley and Alder (1980)]. They calculated the
total energy for the uniform‐electron system for different values of
rs by using the quantum Monte Carlo method.8 Then the correlation
energy was obtained by subtracting the corresponding kinetic and
exchange energies from the total energy. Based on fitting functions
to the numerical results of Ceperley and Alder, several forms of ϵc (rs )
are proposed by Vosko, Wilk, and Nusair (VWN) [Vosko et al. (1980)],
Perdew and Zunger (PZ) [Perdew and Zunger (1981)], and Perdew
and Wang (PW) [Perdew and Wang (1992)], which are listed in
Table 4.2. Although the expressions of ϵc (rs ) do not depend on
the spin, the parameters of ϵc (rs ) depend on the relative spin
polarization, which is defined by

n↑ (r) − n↓ (r)
, (4.114)
n(r)
ζ=

8 The quantum Monte Carlo method is a set of computational methods to provide a

reliable solution (or an accurate approximation) of the quantum many‐body problem,


in which the anti‐commutation relation of two electrons are taken into account.
Quantum ESPRESSO Course for Solid‐State Physics | 205
Table 4.2 Correlation energy ϵc (rs ) in various models (VWN = Vosko‐Wilk‐
Nusair, PZ = Perdew‐Zunger, and PW = Perdew‐Wang). rs is in atomic unit
(a0 = 1) and ϵc (rs ) is in units of Ry. ζ = [n↑ (r) − n↓ (r)]/n(r) is the relative
spin polarization. Parameters are set for ζ = 0 and ζ = 1 in units of a.u.

Model Correlation energy ϵc (rs ) for ζ = 0 for ζ = 1


{
A ln X(x) x Q
2
+ 2b Q
arctan 2x+b −
A = 0.031091 0.015545
[
bx0 2

b
0)
X(x0 ) X(x)
3.72744 7.06042
ln (x−x +
VWN
c = 12.9352
=
18.0578
]}
2(b+2x0 )
arctan 2x+b , where
Q
Q x0 = −0.10498 −0.32500
x = rs , Q = 4c − b2 , and
√ √

X(x) = x + bx + c 2
....................................................................................................................................................................

A = 0.0311 0.0311
B = −0.048
A ln(rs ) + B + Crs ln(rs ) + Drs ,
C = 0.0020
−0.048
0.0007
where rs < 1 and
PZ D = −0.0116
γ/(1 + β1 rs + β2 rs ) with
√ −0.0048
rs ≥ 1
γ = −0.1423 −0.0843
β1 = 1.0529 1.3981
0.3334 0.2611
>
β 2 =
....................................................................................................................................................................

A = 0.031091 0.015545
α1 = 0.21370 0.20548
[
−2A(1 + α1 rs ) ln 1 + β1 = 7.5957 14.1189
PW ] β2 = 3.5876 6.1977
1 β3 = 1.6382 3.3662
β4 = 0.49294 0.6251)
 p+1

2A β1 rs +β2 rs +β3 rs +β4 rs
1/2 3/2

p = 1.0 1.0

where n↑ (r) and n↓ (r) are the electron densities of up‐spin and
down‐spin states. ζ = 0 and 1 are the spin‐unpolarized and spin‐
polarized systems, respectively.
In Fig. 4.10, we show −ϵc by VWN, PZ, and PW parameters
as a function of rs for the uniform electron system with both
the spin‐unpolarized and spin‐polarized systems by using the
parameters in Table 4.2. All functions fit very well with the
numerical results (the circles and diamonds symbols for the spin‐
unpolarized and spin‐polarized cases, respectively) of Ceperley and
Alder [Ceperley and Alder (1980)]. For rs < 5, which is relevant for
condensed metals, the correlation energy becomes more important.
On the other hand, the correlation energy > becomes a small
206 | Density‐Functional Theory

WVN PZ PW
spin-unpolarized spin-unpolarized spin-unpolarized
spin-polarized spin-polarized spin-polarized

Figure 4.10 The Vosko‐Wilk‐Nusair (VWN), Perdew‐Zunger (PZ), and


Perdew‐Wang (PW) correlation energies −ϵc (rs ) are plotted as functions of
rs for both spin‐unpolarized (solid lines) and spin‐polarized (dashed lines)
systems. The expressions and parameters of ϵc (rs ) are given in Table 4.2. The
circle and diamond symbols are the accurate numerical results (by Ceperley
and Alder) of the uniform electron system with the spin‐unpolarized and
spin‐polarized systems, respectively.
<

contribution for rs > 10, which are relevant for semiconductors or


insulators. Although all functions give the same results in the case
of the uniform electron system, for a specific material, they can
give somewhat different results of the total energy. Among these
functions, the PZ function is often used in Quantum ESPRESSO.

4.11.2 Generalized gradient approximation

As discussed in Sec. 4.11.1, the LDA is an approximation in the


case that n(r) is a slowly varying function. However, n(r) often
changes rapidly in the real material. Moreover, n(r) is generally
spin‐dependent. There are many attempts to improve the accuracy
of the LDA for the real systems where n(r) varies rapidly. The
most successful one is the generalized gradient approximation
(GGA). In the GGA, for the exchange term, an enhancement factor
Fx is added in Eq. (4.107) by Perdew, Burke, and Ernzerhof
(PBE) [Perdew et al. (1996a)] as

ϵx (r)n(r)Fx (s)dr = C2 n4/3 (r)Fx (s)dr, (4.115)


 
ExGGA [n(r)] =
Quantum ESPRESSO Course for Solid‐State Physics | 207
where s is the dimensionless gradient of n(r), which is defined by

s= , with kF = 3π2 n(r)


1/3
, (4.116)

2kF n(r)
|∇n(r)|

and the enhancement factor Fx (s) is expressed by

Fx (s) = 1 + κ − , (4.117)
κ
1 + μs2 /κ

where κ = 0.804 and μ = 0.21951 are constants. Note that the range
of s for the real systems is 0 ≤ s ≤ 3. Eqs. (4.115) and (4.117) show
that

ExGGA [n(r)] ≥ ExLDA [n(r)] with s ≥ 0. (4.118)

Therefore, ExGGA [n(r)] satisfies the Lieb‐Oxford lower


bound [Lieb and Oxford (1981)] as shown in Eq. (4.118).
9

For the correlation term, EcGGA [n(r)] is expressed by ϵc (r) of the


uniform electron system (see Table 4.2) plus an additional term
H[n(r), ζ , which depends on both the gradient ∇n(r) and the spin
polarization ζ. The EcGGA [n(r)] functional is given by PBE as

{ϵc (r) + H[n(r), ζ]} n(r)dr,



EcGGA [n(r)] = (4.119)

where H[n(r), ζ] is given by

1 + At2
  
H[n(r), ζ] = γϕ3 ln 1 + t2 . (4.120)
β
γ 1 + At2 + A2 t4

Here the function A in Eq. (4.120) is given by


   −1
A=
ϵc (r)
exp − 3 − 1 , (4.121)
β
γ γϕ

where β = 0.066725 and γ = 0.031091 are non‐empirical constants,


and ϕ(ζ) = (1 + ζ) + (1 − ζ)
2/3 2/3
/2 is the spin‐scaling factor.


9 The repulsive Coulomb energy (exchange plus correlation energy) has a lower

bound of the form C2 n4/3 (r)dr, where n(r) is the single‐particle electron density.

208 | Density‐Functional Theory

LDA-PW

Expt.

GGA-PW91 GGA-PBE

H2 N2 O2 F2 P2 Cl2 OH CO NO NH3 CH4 H2O

Figure 4.11 Errors of atomization energies of several molecules in units of


eV. The dashed line at zero error corresponds to the experimental values. The
square, cross, and circle symbols are the LDA‐PW functional, the GGA‐PW91
functional, and the GGA‐PBE functional, respectively. All numerical data are
taken from Ref. [Perdew et al. (1996a)].

The function t in Eq. (4.120) is given by t = |∇n(r)|/2ϕks ∇n(r),


which is another dimensionless gradient of n(r), where ks =
4kF /π is the Thomas‐Fermi screening wave number. The F(s) and

H[n(r), ζ] functions in Eqs. (4.115) and (4.119), respectively, are also


developed by Perdew and Wang (PW91) [Perdew et al. (1992)] with
the slightly different forms and parameters. Although both PBE and
PW91 are available in Quantum ESPRESSO, the PBE functional is
often used for many materials (see Sec. 3.1.6).
In Fig. 4.11, we show the error of atomization energies for small
molecules, in which the experimental values are set to zero error.
The atomization energies are calculated by the LDA‐PW, GGA‐PW91,
and GGA‐PBE. Both GGA‐PW91 and GGA‐PBE give almost the same
results, and they are closer to the experimental values than LDA‐
PW. Although LDA‐PW overestimates the atomization energies of
molecules and solids, LDA‐PW remains a popular approximation for
realistic solid‐state calculations since it has a simple form of the
functional compared with GGA.

4.11.3 Hybrid functionals

Hybrid functional is a functional that combines the GGA functional


with a fraction of the non‐local Hartree‐Fock exchange interaction.
The hybrid functionals are developed for solving the famous “band‐
gap problem” [Sham and Schlüter (1983)], in which the LDA and
Quantum ESPRESSO Course for Solid‐State Physics | 209
N electrons N+1 electrons
ϵk ϵk

μ (N+1)
Δxc
ϵg Eg

μ (N)

k k
Figure 4.12 Illustration of the contribution of Δxc , the discontinuity in
Vxc [n(r)]. The energies ϵ of the Kohn‐Sham equation are shown in the form
of a band structure for the (N)‐ and (N + 1)‐ electron systems. The two
differ in a uniform increase of the eigenvalues by Δxc . The quasiparticle
band‐gap Eg is the difference between the two eigenvalues as Eg = ϵN+1 −
(N+1)

ϵN , which leads to Eg = ϵg + Δxc , where the Kohn‐Sham gap is given by


(N)

ϵg = ϵN+1 − ϵN .
(N) (N)

GGA always underestimate the band gap. First, let us explain the
reason why both the LDA and GGA underestimate the band gaps
for semiconductors and insulators even though they are the basis of
good approximations for the ground‐state properties.
The origin of the band‐gap problem is the discontinuity
of chemical potential in the exchange‐correlation potential
Vxc [Sham and Schlüter (1985)]. This is because the density
is given by the summation up to the chemical potential μ as
n(r) = i Θ(μ − ϵi )|ϕi |2 , where Θ is the Heaviside step function.10


Therefore, a change δn(r) leads to a discontinuous jump of μ


from the top of valence band to the bottom of conduction band
when we change from (N) to (N + 1)‐electron systems. Since
Vxc [n(r)] = δExc [n(r)]/δn(r) in Eq. (4.101) is given by derivative
on δn(r), we also expect a discontinuity Δxc (positive value) in
Vxc [n(r)]. Thus, the quasiparticle band‐gap Eg can be divided into

<
10 The Heaviside step function Θ(x) is a discontinuous function, whose value is zero
for negative arguments x < 0 and one for positive arguments x > 0.

>
210 | Density‐Functional Theory

two components as follows [Perdew and Levy (1983)]

Eg = ϵg + Δxc , (4.122)

where ϵg is the gap obtained from the Kohn‐Sham equation for the
ground state. In Fig. 4.12, we show the contribution of Δxc to Eg =
ϵN+1 − ϵN , where ϵJ denotes J‐th energy for (N)‐electron system.
(N+1) (N) (N)

As shown in Secs. 4.11.1 and 4.11.2, both the LDA and GGA do not
consider the discontinuity in Vxc [n(r)] since they are the smooth and
local functions of n(r). Therefore, the LDA and GGA would give zero
Δxc , which is the reason why they always underestimate the value of
Eg even they give a good approximation to ϵg .
Several hybrid functionals have been proposed to obtain non‐
zero value of Δxc . The idea of the hybrid functional is based on a
non‑local functional to the exchange‐correlation functional Exc [n(r)].
As discussed in Sec. 3.6, the exchange potential of the Hartree‐
Fock equation is a non‑local potential (see Eq. (4.47)). The exchange
energy can be obtained from the Hartree‐Fock exchange potential as

1

ϕ∗i (r1 )ϕ∗j (r2 )ϕj (r1 )ϕi (r2 )
ExHF dr1 dr2 , (4.123)
2 i,j |r1 − r2 |
=−

where a factor of 1/2 accounts for double counting of the exchange


interactions. Here, the exchange potential as a function of r1 is given
by as a function of r2 , which is the origin of non‐local potential. By
using ExHF in Eq. (4.123), the expressions of the hybrid functionals
are given in Table 4.3, which are usually constructed as a linear
combination of a non‑local term ExHF and the local terms from the
LDA or GGA. The most popular hybrid functional is B3LYP (B =
Becke, 3 = three coefficients, LYP = Lee‐Yang‐Parr) [Becke (1993),
Stephens et al. (1994)]. For B3LYP, ExGGA and EcGGA are the exchange
functional of Becke (B88) [Becke (1988)] and the correlation func‐
tional of Lee, Yang, and Parr [Lee et al. (1988)], respectively, and the
coefficients ao , ax , and ac are empirically fitted to atomic and molec‐
ular data. The next hybrid functional is PBE0 [Perdew et al. (1996b)]
(PBE = Perdew‐Burke‐Ernzerhof, 0 = no empirical coefficient),
in which the coefficient a = 1/4 is determined by fourth‐order
perturbation theory [Adamo and Barone (1999)].
Quantum ESPRESSO Course for Solid‐State Physics | 211
Table 4.3 Hybrid functionals of B3LYP (Becke, 3‐parameter, Lee‐Yang‐Parr),
PBE0 (Perdew‐Burke‐Ernzerhof), and HSE (Heyd‐Scuseria‐Ernzerhof).

Exchange‑correlation functional Mixing


Model
Exc coefficients
a0 = 0.20,
VWN
+ a ExHF − ExVWN + ax ExGGA +
ax = 0.72,
( )
B3LYP
Exc
( GGA 0 VWN
ac Ec − Ec ac = 0.81
)
....................................................................................................................................................................

PBE0 aExHF + (1 − a)ExPBE + EcPBE a = 1/4


....................................................................................................................................................................

aExHF,SR (η) + (1 − a)EPBE,SR


HSE x
a = 1/4, η = 0.106
(η) +
ExPBE,LR (η) + EcPBE

Although B3LYP and PBE0 are very successful for quantitative


calculations in molecules, they might not be suitable for solids.
This is because the Hartree‐Fock approximation is problematic for
delocalized electrons such as metals. As discussed in Sec. 4.8, the
Hartree‐Fock equation leads to the Lindhard function F(k/kF ) in the
energy ϵk of a uniform‐electron system (see Eq. (4.73)). Therefore,
the velocity dϵk /dk diverges at the Fermi surface, which contradicts
the experiment. The singularity of the Lindhard function at the
Fermi surface, which was pointed out by Bardeen [Bardeen (1936)],
is a consequence of long‐range Coulomb interaction. However, the
divergence of dϵk /dk can be avoided by either if there is a finite gap
(i.e., in an insulator) or if the Coulomb interaction is screened to be
effectively short range, which is explained below.
The Coulomb interaction can be divided into short‐range
(SR) and long‐range (LR) parts by using the Ewald summa‐
tion [Ewald (1921)] as

1 1 − erf(ηr) erf(ηr)
, (4.124)
r r r 
= +
    
SR LR

where erf is the error function11 and η is an adjustable


parameter. Applying Eq. (4.124), the HSE (Heyd‐Scuseria‐

11 The error function


x is a function of a variable x, which is defined as
erf(x) = √2π exp(−t2 )dt.
0
 | 'HQVLW\)XQFWLRQDO 7KHRU\

'JHVSF  &RQWULEXWLRQV RI WKH +DUWUHH HQHUJ\ E*  WKH H[FKDQJH


FRUUHODWLRQ HQHUJ\ EZE  WKH RQHHOHFWURQ HQHUJ\ ERQHH  DQG WKH (ZDOG HQHUJ\
E(ZDOG WR WRWDO HQHUJ\ 'WRW RI JUDSKHQH

(UQ]HUKRI >+H\G GV CN  @ K\EULG IXQFWLRQDO WKH H[SUHVVLRQ LV


JLYHQ LQ 7DEOH  LV REWDLQHG IURP WKH 3%( IXQFWLRQDO 7KH IRUP RI
+6( KDV WKH DGYDQWDJH WKDW LW FDQ EH DSSOLHG WR PHWDOV DQG LW UHGXFHV
WR WKH 3%( IXQFWLRQDO IRU ȅ → ∞ DQG WKH 3%( K\EULG IXQFWLRQDO IRU
ȅ →  $OO %/<3 3%( DQG +6( RSWLRQV DUH DYDLODEOH LQ 4XDQWXP
(635(662 $OWKRXJK WKH K\EULG IXQFWLRQDOV JLYH D EHWWHU YDOXH WKH\
DUH VLJQLILFDQWO\ WLPHFRQVXPLQJ FRPSDUHG ZLWK WKH /'$ DQG **$

 5PUBM FOFSHZ DBMDVMBUJPO

,Q WKH GLVFXVVLRQ XS WR QRZ ZH RQO\ FRQVLGHU WKH WRWDO HQHUJ\ RI


WKH HOHFWURQV E\ VROYLQJ WKH .RKQ6KDP HTXDWLRQ VHH 6HF  
+RZHYHU LQ 4XDQWXP (635(662 WKH WRWDO HQHUJ\ RI D VROLG FRQWDLQV
ERWK WKH HOHFWURQ DQG LRQ FRQWULEXWLRQV DV

'WRW = E* + EZE + ERQHH + E(ZDOG  


     
HOHFWURQV LRQV

ZKHUH E* LV WKH +DUWUHH HQHUJ\ EZE LV WKH H[FKDQJHFRUUHODWLRQ


HQHUJ\ ERQHH LV WKH NLQHWLF HQHUJ\ RI WKH HOHFWURQV SOXV WKH SVHXGRSR
WHQWLDO HQHUJ\ DQG E(ZDOG LV WKH &RXORPE UHSXOVLRQ EHWZHHQ SDLUV
RI LRQV 7KHVH YDOXHV RI WKH HQHUJLHV FDQ EH IRXQG RQ WKH RXWSXW
ILOH RI WKH 4XDQWXP (635(662 FDOFXODWLRQ DV VKRZQ LQ )LJ  IRU
JUDSKHQH VHH RXWSXW ILOH LQ 6HF   ,Q WKLV VHFWLRQ ZH ZLOO H[SODLQ
HDFK HQHUJ\ E\ XVLQJ WKH RNCPG YCXG GZRCPUKQP 6HF   :LWK WKH
Quantum ESPRESSO Course for Solid‐State Physics | 213
plane waves, the convergence of physical properties is controlled by
the cut‑off energy, which can be tested (see Sec. 3.1.2).

4.12.1 Hartree contribution

First, let us discuss the Hartree energy EH , which is expressed as

1

EH [n(r)] = VH (r)n(r)dr, (4.126)
2

where a factor of 1/2 takes into account the double counting and
VH (r) is the Hartree potential, which is given in Eq. (4.33).
For a periodic solid, the total electron density and the potentials
can be expressed in the terms of the plane waves, eiGr , with G is the
reciprocal lattice vectors (see Sec. 5.3) as

n(r) = eiGr n(G), and VH (r) = eiGr VH (G), (4.127)


 

G G

where n(G) and VH (G) are, respectively, given by

n(G) = n(r)e
 
−iGr
dr, and VH (G) = VH (r)e−iGr dr. (4.128)

For the neutral case, the total negative charge of the electrons is
canceled by the total positive charge of the ions. Therefore, the
average potential is zero. Since G = 0 in Eq. (4.127) corresponds
to the average potential over all the space, we can omit G = 0 in
the summation due to charge neutrality.12 Then, by substituting

12 There might be a contribution from the G = 0 term if the systems have an intrinsic

electric dipole moment.


214 | Density‐Functional Theory

Eq. (4.127) into Eq. (4.126), we obtain

1
ei(G+G )r VH (G)n(G′ )dr

EH [n(r)] =
2 ′

GG

Ω
δG+G′ ,0 VH (G)n(G′ )
2
=

Ω (4.129)
VH (G)n(−G)
2
=
G̸=0

Ω
VH (G)n(G),
2
=
G̸=0

where Ω is the volume of the unit cell. Here we assume that n(+G) =
n(−G). On the other hand, by substituting Eq. (4.127) into the Poisson
equation (see Sec. 4.5), we have

n(G)
∇2 VH (r) = −4πn(r) ⇐⇒ VH (G) = 4π . (4.130)
|G|2

By substituting Eq. (4.130) into Eq. (4.129), we obtain

 n2 (G)
EH = 2πΩ . (4.131)
|G|2
G̸=0

4.12.2 Exchange‐correlation contribution

From Eq. (4.110), the exchange‐correlation energy is defined by



Exc [n(r)] = ϵxc (r)n(r)dr, (4.132)

where ϵxc (r) = ϵx (r) + ϵc (r) can be expressed in the terms of the
plane waves as

eiGr ϵxc (G). (4.133)



ϵxc (r) =
G̸=0
Quantum ESPRESSO Course for Solid‐State Physics | 215
By substituting Eqs. (4.133) and (4.127) into Eq. (4.132), we obtain

(4.134)

Exc [n(r)] = Ω ϵxc (G)n(G).
G̸=0

4.12.3 One‐electron contribution and pseudopotential

In Quantum ESPRESSO, Eone‐e defined in Eq. (4.125) is the sum of the


kinetic energy Ke and the external energy Eext of the electrons in the
potential of the atom cores:

Eone‐e [n(r)] = Ke [n(r)] + Eext [n(r)]. (4.135)

The expression of Ke [n(r)] is given by Eq. (4.96), which can be


rewritten in the terms of the plane waves as

|k + G|2 |Ci,k (G)|2 , (4.136)


Ω 
Ke [n(r)] =
2 i
k G

where Ci,k (G) are the coefficients of the wavefunctions ϕi .


The expression of Eext [n(r)] is given by

Eext [n(r)] = Ven (r)n(r)dr. (4.137)

Since the external potential term Ven (r) in Eq. (4.137) is costly
computation with the plane waves, Ven (r) is replaced by a pseudopo‑
tential Vps (r), which is related to replacing the effects of the core
electrons with an effective potential.
A local form of the pseudopotential of a single ion, vps (r),
is proposed by Ashcroft‐Heine‐Abarenkov [Ashcroft (1966),
Heine and Abarenkov (1964)] as
<
v0 r < rcut

vps (r) = , (4.138)
−r Z
r > rcut

where Z is the charge of the ionic core and rcut is the effective radius,
>

which is determined by the radius of core electrons, as shown in Fig.


4.14. The constants rcut and v0 are chosen such that the energy levels
216 | Density‐Functional Theory

v
Core electrons Shell electrons
rcut
r
v0
vps

Z

r

Figure 4.14 The Ashcroft‐Heine‐Abarenkov pseudopotential for a single ion.

of the shell electrons are reproduced for the single‐atom calculations.


For example, let us consider 1s‐ and 2s‐electrons of the C atom as
core electrons. Then, rcut and v0 are adjusted by solving the one‐
particle equation to reproduce the observed ionization energy of the
2p‐electron.
A global form of the pseudopotential can be obtained by taking
into account the contribution of the individual atoms of a unit cell as

vIps (|r − T − RI |), (4.139)



Vps (r) =
I T

where T are the lattice translation vectors, RI denotes the relative


positions of the I‐th atom in the unit cell, and vIps is the pseudopo‐
tential of the I‐th atom. Eq. (4.139) can be expressed by the Fourier
transform as

1
vIps (|r − T − RI |)e−iGr dr
 

V
Vps (G) =
I T

Ncell
e vIps (|r|)e−iGr dr
 

V
−iGRI
=
I
(4.140)
1
e vIps (|r|)e−iGr dr
 
−iGRI
=
I
Ω

SI (G)FI (G),

=
I
Quantum ESPRESSO Course for Solid‐State Physics | 217
in which SI (G) and FI (G) are defined by

1
SI (G) = e−iGRI , and FI (G) = vIps (|r|)e−iGr dr,

(4.141)
Ω

where Ncell is the number of unit cells in the crystal, V = Ncell Ω is


the crystal volume, and I SI (G) and FI (G) are called the structure


factor13 and the atomic form factor14 of the I‐th atom, respectively.
For a given pseudopotential such as Eq. (4.138), the external
energy can be expressed as

(4.142)

Eext [n(r)] = Vps (r)n(r)dr = Ω Vps (G)n(G).
G

Then by substituting Eq. (4.140) into Eq. (4.142), we obtain

SI (G)FI (G)n(G). (4.143)



Eext [n(r)] = Ω
G I

For Quantum ESPRESSO, the Vps is often used with norm‐


conserving or ultra‐soft (non‐local) pseudopotentials (see Sec. 5.4).
In the case of non‐local pseudopotential, however, the expression
of the external energy is rather complicated and needs special
treatment for an efficient implementation [Pickett (1989)].

4.12.4 The Ewald contribution

Finally, we will discuss the last term EEwald in Eq. (4.125). In Quantum
ESPRESSO, EEwald denotes the ion‐ion Coulomb energy, which is given
by

ZI ZJ
N
1n

. (4.144)
2 |RI − RJ |
EEwald =
I̸=J

13 The structure factor contains all the information about the lattice structure. The

structure factor gives the extinction rule for X‐ray diffraction (see Sec. 5.2).
14 The atomic form factor contains the information of each atom, which can be

calculated or obtained by fitting experimental data. The form factor is important for
obtaining the intensity of X‐ray scattering.
218 | Density‐Functional Theory

This sum converges slowly since the potentials of the Coulomb


interaction is a long‐range function of |RI − RJ |. Thus, in order to
converge Eq. (4.144) rapidly, we can apply the Ewald summa‑
tion [Ewald (1921)], which splits the potential into short‐range (SR)
and long‐range (LR) parts. As shown in Eq. (4.124), the Ewald
summation of the ionic potential can be expressed as

ZJ 1 − erf(η|R − RJ |)
Nn n N
ZI
 
|R − RJ | |R − RJ |
=
J J
  
SR
(4.145)
erf(η|R − RJ |)
Nn
ZJ ,

|R − RJ |
+
J
  
LR

in which, the LR part can be expressed in reciprocal space


as [Marder (2010)]

erf(η|R − RJ |) e−|G| /(4η) eiG(R−RJ )


Nn Nn 
4π 
2 2

ZJ ZJ . (4.146)

|R − RJ | V J |G|2
=
J G̸=0

Then the both SR and LR parts can converge quickly with increasing
|G| and |R| for a given value of η. Therefore, the ion‐ion Coulomb
energy can be obtained by a few terms in the summations over |G|
and J.
When we insert Eqs. (4.145) and (4.146) into Eq. (4.144), we
must subtract separately the term for R = RJ in Eq. (4.146), to avoid
the divergence. If we adopt the following equation:

erf(η|R − RJ |)
 
= 2√ , (4.147)
η
|R − RJ |
lim
R→RJ π
Quantum ESPRESSO Course for Solid‐State Physics | 219
Eq. (4.144) can be rewritten as

1 − erf(η|RI − RJ |)
N
1n

ZI ZJ
2 |RI − RJ |
EEwald =
I̸=J

e−|G| /(4η) eiG(RI −RJ )


Nn 
2π 
2 2

ZI ZJ (4.148)
V I,J |G|2
+
G̸=0

Nn
Z2J √ .
 η

J
π

Thus, we can avoid the divergence, too.

4.13 Ionic forces

The ionic forces are used to study the dynamics of ions such as
optimizing ionic positions (see Sec. 3.1.4). Using the total energy in
Sec. 4.12, we can calculate the forces that act to the ion I, which is
given by taking the derivative of the total energy with respect to
individual ionic position RI as

∂Etot ∂EEwald ∂Eext


FI = − . (4.149)
∂RI ∂RI ∂RI
=− −

There are two contributions to the ionic forces, one from the
ion‐ion interaction energy EEwald in Eq. (4.148), and one from the
ion‐electron interaction energy Eext in Eq. (4.142). For the ion‐ion
interaction energy, the force of ion I is given by Eq. (4.148) as follows:

∂EEwald ZI ZJ
n N
Fion (RI − RJ ), (4.150)

I
∂RI |RI − RJ |3
=− =
J̸=I

which can be solved by a method analogous to the Ewald summation


that is used in Sec. 4.12.4.
220 | Density‐Functional Theory

As for the ion‐electron interaction energy, the force is calculated


by adopting the Hellmann‑Feynman theorem15 [Feynman (1939),
Hellmann (1937)] as

∂Eext    ∂Vps  
 
Fion‐e ϕ . (4.151)
I
∂RI ∂RI  i
=− =− ϕi 
i

For the I‐th pseudopotential Vps I


(r) = T vIps (|r − T − RI |) (see


Eq. (4.139)), Eq. (4.151) is rewritten in term of n(r) as

∂Vps (r)
Fion‐e n(r)dr.

(4.152)
I
∂RI
=−

Eq. (4.152) tells us that Fion‐e


I does not depend on any derivative of
n(r). The Hellmann‐Feynman force is straightforwardly calculated
by the calculated n(r) once the self‐consistent electronic density is
obtained.

4.14 A simple DFT‐LDA program for an atom

This section shows a step‐by‐step calculation of the ground‐state


energy of a helium atom for understanding the DFT for an atom.
The DFT calculation of an atom is also important since Quantum
ESPRESSO does not support the package for an atom. We use Python
language (version 3) to write the simplest DFT code for the LDA (see
Sec. 4.11.1). The present tutorial contains three main calculations:
(1) to solve the radial Schrödinger equation by using the Numerov
algorithm, (2) to solve the radial Possion equation by using the Verlet
algorithm, and (3) incorporating to calculate the ground‐state energy
of the helium atom by using the LDA with PZ parameters. This tutorial
requires the basic Python programming and Jupyter notebook, which
are given in Chapter 6.

15 The Hellmann‐Feynman theorem states that the forces are given by the

expectation value of the derivative of the external potential.


Quantum ESPRESSO Course for Solid‐State Physics | 221
4.14.1 Radial Schrödinger equation

 Purpose: The purpose of the first step is to calculate the electron


density of the helium atom by solving a radial Schrödinger equa‑
tion, which is the Schrödinger equation in spherical coordinates.
 Background: In spherical coordinates, the wavefunction ϕ(r) =
ϕ(r, θ, φ) can be written as the product of a radial function R(r) and
an angular function Y(θ, φ):

ϕ(r, θ, φ) = R(r)Y(θ, φ). (4.153)

Then we obtain the radial Schrödinger equation for R(r) as


follows [Kittel (1976)]

1 d ℓ(ℓ + 1)
   
r2 R(r) = ϵR(r), (4.154)
d
2r2 dr 2r2
− + + V(r)
dr

where ℓ is azimuthal quantum number ℓ = 0, 1, 2, … . Let us define a


reduced radial wavefunction u(r) as

u(r) = rR(r). (4.155)

By substituting Eq. (4.155) into Eq. (4.154), we obtain the


reduced radial equation for 1s orbital by substituting ℓ = 0 as

1 d2
 
u(r) = ϵu(r). (4.156)
2 dr2
− + V(r)

Eq. (4.156) can be rewritten in the form of a second‐order differential


equation as

d2 u
(4.157)
dr2
= −k(r)u(r),

where k(r) is defined by

k(r) = 2 [ϵ − V(r)] . (4.158)


222 | Density‐Functional Theory

A method to solve Eq. (4.157) is the Numerov algorithm.16


In the Numerov algorithm, the reduced radial wavefunction u(r) is
expressed as

2c0 un (r) − c1 un−1 (r)


un+1 (r) = , (4.159)
c2

where c0 , c1 , and c2 are defined by

c0 = 1 − 12 h kn (r)

 5 2 2

c1 = 1 + 12 h kn−1 (r)
1 2 2 , (4.160)
c = 1 +
12 h kn+1 (r)
1 2 2


2

where h = rn+1 − rn . By given two initial values, u0 (r) and u1 (r),


Eq. (4.159) can be used to determine un (r) for n = 2, 3, 4, … with an
error in the order of h6 .
We normalize u(r) as

u2 (r)dr = 1.

(4.161)

Then, the electron density n(r) of a single electron for the 1s state
(Y(θ, φ) = 1/ 4π) is given by

R2 (r) u2 (r)
n(r) = . (4.162)
4π 4πr2
=

Note that, for the helium atom, the total electron density is 2n(r) since
we have two electrons.
 How to run: To run this tutorial, the readers will do the following
command lines:

$ cd ~/SSP -QE/dft -he


$ jupyter -lab check -schrodinger.ipynb

‐ Line 1: Go to the dft-he directory that includes the input files.


‐ Line 2: Run check-schrodinger.ipynb by JupyterLab.

16 The Numerov algorithm is a numerical method to solve ordinary differential

equations of second order in which the first‐order term does not appear.
Quantum ESPRESSO Course for Solid‐State Physics | 223
 Input file: The input files include a subroutine file
(schrodinger.py) and a main file (check-schrodinger.ipynb).
The subroutine contains the Numerov algorithm in Eq. (4.159) and
the radial Schrödinger equation in Eq. (4.157), and the main file
calculates the ground‐states energy and wavefunction for the helium
atom.

SSP‑QE/dft‑he/schrodinger.py

1 # Import the numpy modules


2 import numpy as np
3 # The Numerov algorithm for equation:
4 # u"(r) = -k(r)u(r) with k(r)=2(eps -V)
5 # Input: k(r), two initial values u0(r) and u1(r)
6 # Output: u(r)
7 def numerov(k, u0 , u1 , dr):
8 u = np.zeros_like(k)
9 u[0] = u0
10 u[1] = u1
11 for i in range (2, len(k)):
12 dr_sqr = dr**2
13 c0 = (1 + 1/12.* dr_sqr*k[i -2])
14 c1 = 2*(1 - 5/12.* dr_sqr*k[i -1])
15 c2 = (1 + 1/12.* dr_sqr*k[i])
16 u[i] = (c1*u[i-1] - c0*u[i -2])/c2
17 return u
18 # Solve the reduced radial Schrodinger equation:
19 # u"(r) = -2(eps -V)u(r)
20 # Inputs: r and V(r)
21 # Outputs: eigen energy eps and u(r)
22 def solve_schrodinger (r, V, eps_min =-4, eps_max =0,
maxiter =100, stoptol = 0.0001):
23 dr = r[1] - r[0]
24 for i in range(maxiter):
25 eps = (eps_min + eps_max)/2.
26 k = 2*( eps - V)
27 # starting from r*exp(-r)
28 u0 = r[-1]* np.exp(-r[-1])
29 u1 = r[-2]* np.exp(-r[-2])
30 # call the Numerov algorithm
31 u = numerov(k[::-1], u0 , u1 , dr)
32 u = u[:: -1]
33 num_nodes = np.sum(u[1:]* u[:-1] < 0)
34 if num_nodes == 0 and np.abs(u[0]) <=
stoptol:
35 return (eps , u)
36 if num_nodes == 0 and u[0] > 0:
37 eps_min = eps
224 | Density‐Functional Theory

38 else:
39 assert num_nodes > 0, 'expect #nodes >0
since u[0]<0 while u[infty]>0'
40 eps_max = eps
41 raise Exception('Not converged after %d
iterations.' %( maxiter))

SSP‑QE/dft‑he/check‑schrodinger.ipynb

1 # Import the necessary packages and modules


2 # sci.mplstyle is customized Matplotlib style
3 import matplotlib.pyplot as plt
4 plt.style.use('../ matplotlib/sci.mplstyle ')
5 import numpy as np
6 from schrodinger import solve_schrodinger
7
8 # Set r from 0 to 15 bohr with 50000 steps
9 r, dr = np.linspace (0, 15, 50001 , retstep=True)
10 r = r[1:] # Skip r = 0
11 # Set kinetic energy of helium
12 Z = 2
13 V_en = -Z/r
14
15 # Solve the reduced radial equation:
16 # u"(r) = -2(eps -V_en)u(r)
17 eps , u = solve_schrodinger (r, V_en)
18 # Normalize u(r)
19 u /= np.linalg.norm(u)* np.sqrt(dr)
20
21 # Total electron density of helium
22 n = 2*(u**2/4/ np.pi/r**2)
23 # Compare with exact density of helium
24 n_exact = (2*Z**3/ np.pi)*np.exp(-2*Z*r)
25
26 # Plot the comparison
27 plt.figure ()
28 plt.plot(r, n, label='numerov ')
29 plt.plot(r, n_exact , ':', lw=4, label='exact ')
30 plt.xlabel('$r$ ($a_0$)')
31 plt.ylabel('$n(r)$ (a.u.)')
32 plt.title('Electron density of helium ')
33 plt.legend(loc='best ')
34 plt.xlim(0, 5)
35 plt.show ()

 Output data: In main work area of the JupyterLab interface,


the readers can see the plot as shown in Fig. 4.15. We can see
Quantum ESPRESSO Course for Solid‐State Physics | 225

Figure 4.15 Electron density of helium. Solid and dashed lines denote the
electron densities, which are obtained by the Numerov algorithm and
analytical methods, respectively.

that the electron density from the numerical method (the Numerov
algorithm) reproduces the exact electron density of the helium atom
given by Eq. (4.21).

4.14.2 The Poisson equation

 Purpose: Next, let us calculate the Hartree potential from the


reduced radial wavefunction u(r).
 Background: Let us define a Hartree potential as a function of r,
UH (r) = rVH (r), then the Poisson equation in Eq. (4.32) reduces to the
following differential equation:

∇2 UH (r) = −4πrn(r). (4.163)

Eq. (4.163) is an ordinary second‐order differential equation


which can be solved by using the Verlet algorithm.17 By substituting
Eq. (4.162) into Eq. (4.163), we have

u2 (r)
∇2 UH (r) = − . (4.164)
r
17 The Verlet algorithm is a simple method for integrating second order differential

equations of the form x′′ (t) = f[x(t), t].


226 | Density‐Functional Theory

The Verlet algorithm for Eq. (4.164) is expressed as following:

UH (r + δr) = 2UH (r) − UH (r − δr) + δr2 ∇2 UH (r). (4.165)

The boundary conditions are also applied to solve Eq. (4.164).


For the hydrogen, the conditions are UH (0) = 0 and UH (rmax ) = 1.
Note that, for the helium case, the Hartree potential is 2UH (r)/r since
the electron density is 2n(r).
 How to run: To run this tutorial, the readers will do the following
command lines:

$ cd ~/SSP -QE/dft -he


$ jupyter -lab check -poisson.ipynb

‐ Line 1: Go to the dft-he directory that includes the input files.


‐ Line 2: Run check-poisson.ipynb by JupyterLab.
 Input file: The input files include two subroutine
files (schrodinger.py and poisson.py) and a main file
(check-poisson.ipynb). The subroutine poisson.py contains
the Verlet algorithm in Eq. (4.165) and the Poisson equation in
Eq. (4.164), and the main file calculates the Hartree potential for the
helium atom.

SSP‑QE/dft‑he/poisson.py

1 # Import the numpy modules


2 import numpy as np
3 # The Verlet algorithm
4 def verlet(f, U0 , U1 , dr):
5 dr_sqr = dr**2
6 U_H = np.zeros_like(f)
7 U_H [0] = U0
8 U_H [1] = U1
9 for i in range (2, len(f)):
10 U_H[i] = 2* U_H[i-1] - U_H[i-2] + f[i -1]*
dr_sqr
11 return U_H
12 # Solve the Poisson equation
13 # Inputs: r and u(r)
14 # Outputs: U_H(r)
15 def solve_poisson(r, u):
16 # start the Verlet algorithm
17 dr = r[1]-r[0]
Quantum ESPRESSO Course for Solid‐State Physics | 227
18 f = -u**2/r
19 U0 , U1 = r[0], r[1]
20 U_H = verlet(f, U0 , U1 , dr)
21 # fix the boundary condition
22 U_H = U_H - (U_H [-1]-1)/r[-1]* r
23 return U_H

SSP‑QE/dft‑he/check‑poisson.ipynb

1 # Import the necessary packages and modules


2 # sci.mplstyle is customized Matplotlib style
3 import matplotlib.pyplot as plt
4 plt.style.use('../ matplotlib/sci.mplstyle ')
5 import numpy as np
6 from schrodinger import solve_schrodinger
7 from poisson import solve_poisson
8
9 # Set r from 0 to 15 bohr with 50000 steps
10 r, dr = np.linspace (0, 15, 50001 , retstep=True)
11 r = r[1:] # Skip r = 0
12 # Set kinetic energy of helium
13 Z = 2
14 V_en = -Z/r
15
16 # Solve the radial Schrodinger equation
17 eps , u = solve_schrodinger (r, V_en)
18 # Normalize the radial wave function u(r)
19 u /= np.linalg.norm(u)* np.sqrt(dr)
20
21 # Solve the Poisson equation
22 U_H = solve_poisson(r, u)
23 # Convert U_H(r) to the Hartree potential V_H(r)
24 # The factor of 2 since helium has two electrons
25 V_H = 2* U_H/r
26 # Compare with the exact Hartree potential
27 V_exact = -2*(Z + 1/r)*np.exp(-2*Z*r) + Z/r
28
29 # Plot the comparison
30 plt.plot(r, V_H , label='verlet ')
31 plt.plot(r, V_exact , ':', lw=4, label='exact ')
32 plt.xlabel('r (bohr)')
33 plt.ylabel('$\mathcal{V}_H(r)$ (a.u.)')
34 plt.title('Hartree potential of helium ')
35 plt.legend(loc='best ')
36 plt.xlim(0, 5)
37 plt.show ()
228 | Density‐Functional Theory

Figure 4.16 The Hartree potential of helium. Solid and dashed lines denote
the Hartree potential, which are obtained by the Verlet algorithm and
analytical methods, respectively.

 Output data: In the main work area of the JupyterLab interface,


the readers can see the plot as shown in Fig. 4.16. We can see that the
Hartree potential from the numerical method (the Verlet algorithm)
reproduces the exact Hartree potential of the helium atom given by
Eq. (4.39), too.

4.14.3 DFT‐LDA for helium

 Purpose: Finally, we calculate the ground‐state energy of the


helium atom within LDA.
 Background: For the LDA, the exchange function ϵx (r) and the
exchange potential Vx [n(r)] are defined by (see Sec. 4.11.1):

4
ϵx (r) = C2 n1/3 (r) and Vx [n(r)] = C2 n1/3 (r), (4.166)
3

respectively, where C2 = −0.738.


We adopt the PZ correlation function ϵc (rs ), which is defined by
(see Table 4.2):

A ln(rs ) + B + Crs ln(rs ) + Drs if rs < 1



ϵc (rs ) = , (4.167)
γ/(1 + β1 rs + β2 rs ) if rs ≥ 1

>
Quantum ESPRESSO Course for Solid‐State Physics | 229
where the parameters A, B, C, D, γ, β1 , β2 are given in Table 4.2, too.
Then, the correlation potential is given by

∂[ϵc (r)n(r)]
. (4.168)
∂n(r)
Vc [n(r)] =

By substituting the electron density n(r) = 3/(4πr3s ) from Eq. (4.112)


into Eq. (4.168), we obtain:

rs d
 
Vc (rs ) = 1− ϵc (rs ). (4.169)
3 drs

By substituting Eq. (4.167) into Eq. (4.169), we


obtain [Thijssen (2007)]:

A ln(rs ) + B − A3 + 23 Crs ln(rs ) + 2D−C


3 rs , for rs < 1

Vc (rs ) = .
γ(1 + 6 β1 rs + β2 rs )/(1 + β1 rs + β2 rs )2 ,
7
for rs ≥ 1
√ √

(4.170)
>

With the presence of the exchange‐correlation potential,


Eq. (4.156) becomes:

1 d2
 
en H xc u(r) = ϵu(r), (4.171)
2 dr2
− + V (r) + V (r) + V [n(r)]

where Vxc [n(r)] = Vx [n(r)] + Vc (rs ). Then, the total energy of the
helium atom in Eq. (4.103) can be rewritten by

E = 2ϵ −

VH (r)u2 (r)dr − ΔExc [n(r)], (4.172)

where ΔExc [n(r)] is expressed by



ΔExc [n(r)] = Vxc [n(r)]n(r)dr − Exc [n(r)]

= {Vxc [n(r)] − ϵxc [n(r)]}n(r)dr (4.173)

=2 {Vxc [n(r)] − ϵxc [n(r)]}u2 (r)dr,
230 | Density‐Functional Theory

where ϵxc [n(r)] = ϵx [n(r)] + ϵc (rs ). Note that we have to use the
electron density n(r) and VH (r) for the helium atom.
 How to run: To run this tutorial, the readers will do the following
command lines:

$ cd ~/SSP -QE/dft -he


$ jupyter -lab dft -lda -he.ipynb

‐ Line 1: Go to the dft-he directory that includes the input files.


‐ Line 2: Run dft-lda-he.ipynb with JupyterLab.
 Input file: The input files include two subroutine
files (schrodinger.py and poisson.py) and a main file
(dft-lda-he.ipynb). The main file calculates the total energy
of the helium atom.

SSP‑QE/dft‑he/dft‑lda‑he.ipynb

1 # Import the necessary packages and modules


2 import numpy as np
3 from schrodinger import solve_schrodinger
4 from poisson import solve_poisson
5
6 # Set r from 0 to 15 bohr with 50000 steps
7 r, dr = np.linspace (0, 15, 50001 , retstep=True)
8 r = r[1:] # Skip r = 0
9 # Parameter for exchange potential Vx
10 C2 = -0.738;
11 # PZ parameters for correlation functional Vc
12 Aa = 0.0311; B= -0.048; C= 0.002; D= -0.0116; gamma=
-0.1423; beta1= 1.0529; beta2= 0.3334;
13
14 # Define the exchange potential
15 def exc(n):
16 V_x = (4/3)*C2*n**(1/3)
17 e_x = C2*n**(1/3)
18 return (V_x , e_x)
19
20 # Define the correlation potential
21 def cor(n):
22 rs = (3/4/ np.pi/n)**(1/3)
23 V_c = np.piecewise(rs ,[rs <1,rs >=1] ,[ lambda rs:
Aa* np.log(rs)+B-Aa /3+2/3* C* rs* np.log(rs)+(2*
D-C)*rs/3, lambda rs: gamma /(1+ beta1* rs
**(1/2)+beta2*rs)*(1+7/6* beta1*rs **(1/2)+
beta2* rs)/(1+ beta1* rs **(1/2)+beta2* rs)])
Quantum ESPRESSO Course for Solid‐State Physics | 231
24 e_c = np.piecewise(rs ,[rs <1,rs >=1] ,[ lambda rs:
Aa*np.log(rs)+B+C*rs*np.log(rs)+D*rs , lambda
rs: gamma /(1+ beta1* rs **(1/2)+beta2* rs)])
25 return (V_c , e_c)
26
27 # The main DFT for helium with the LDA
28 def dft(V_en , maxiter =100, stop =0.001 , correlation=
False , verbose=False):
29 V_H = np.zeros_like(V_en)
30 V_x = np.zeros_like(V_en)
31 V_c = np.zeros_like(V_en)
32 e_x = np.zeros_like(V_en)
33 e_c = np.zeros_like(V_en)
34 eps = None
35 for i in range(maxiter):
36 eps_old = eps
37 V = V_en + V_H + V_x + V_c
38 V_xc = V_x + V_c
39 e_xc = e_x + e_c
40 # eigen energy and u(r)
41 eps , u = solve_schrodinger (r, V)
42 # normalize u(r)
43 u /= np.linalg.norm(u)* np.sqrt(dr)
44 # convergence of eigen energy
45 if eps_old is not None:
46 if verbose:
47 print('Step %02d: eps = %f, |eps -
eps_old| = %f' %(i, eps , abs(eps
- eps_old)))
48 if abs(eps - eps_old) < stop:
49 return 2* eps - dr*np.dot(V_H , u**2)
- 2* dr*np.dot(V_xc - e_xc , u**2)
50 elif verbose:
51 print
52 # update Hartree potential
53 U_H = solve_poisson(r, u)
54 V_H = 2* U_H/r
55 # total electron density
56 n = 2*(u**2/4/ np.pi/r**2)
57 # update exchange potential
58 V_x , e_x = exc(n)
59 # update correlation potential
60 if correlation:
61 V_c , e_c = cor(n)
62 elif correlation:
63 V_c = 0
64 e_c = 0
232 | Density‐Functional Theory

65 raise Exception('Not converged after %d


iterations; |eps - eps_old| = %f' %(maxiter ,
abs(eps - eps_old)))
66
67 print('Total energy of He without correlation ')
68 print('JOB DONE: total energy E = %f Ha' %(dft(-2/r,
correlation=False ,verbose=True)))
69 print('--------------------------------------')
70 print('Total energy of He with correlation ')
71 print('JOB DONE: total energy E = %f Ha' %(dft(-2/r,
correlation=True , verbose=True)))

 Output data: In main work area of the JupyterLab interface, the


readers can see the total energy of the helium atom as follows:

Total energy of He without correlation


Step 01: eps = -0.320312 , |eps - eps_old| = 1.674937
Step 02: eps = -0.625862 , |eps - eps_old| = 0.305550
Step 03: eps = -0.470276 , |eps - eps_old| = 0.155586
Step 04: eps = -0.537201 , |eps - eps_old| = 0.066925
Step 05: eps = -0.505615 , |eps - eps_old| = 0.031586
Step 06: eps = -0.519958 , |eps - eps_old| = 0.014343
Step 07: eps = -0.513306 , |eps - eps_old| = 0.006653
Step 08: eps = -0.516357 , |eps - eps_old| = 0.003052
Step 09: eps = -0.514954 , |eps - eps_old| = 0.001404
Step 10: eps = -0.515625 , |eps - eps_old| = 0.000671
JOB DONE: total energy E = -2.716883 Ha
--------------------------------------
Total energy of He with correlation
Step 01: eps = -0.376953 , |eps - eps_old| = 1.618296
Step 02: eps = -0.661568 , |eps - eps_old| = 0.284615
Step 03: eps = -0.528656 , |eps - eps_old| = 0.132912
Step 04: eps = -0.582932 , |eps - eps_old| = 0.054276
Step 05: eps = -0.559113 , |eps - eps_old| = 0.023819
Step 06: eps = -0.569275 , |eps - eps_old| = 0.010162
Step 07: eps = -0.564880 , |eps - eps_old| = 0.004395
Step 08: eps = -0.566772 , |eps - eps_old| = 0.001892
Step 09: eps = -0.565948 , |eps - eps_old| = 0.000824
JOB DONE: total energy E = -2.826743 Ha

The total energy without the correlation energy is −2.716 Ha,


which is close to the reported value (−2.72 Ha [Thijssen (2007)]).
However, it is less accurate than the Hartree‐Fock method (−2.85 Ha,
see Sec. 4.6). This is because the exchange potential by the LDA is an
approximation for the uniform‐electron charge. Therefore, the total
energy can be improved by considering the correlation potential.
As a result, we obtain the total energy with the PZ correlation
functional is −2.827 Ha, which is close to the reported value (−2.83
Ha [Thijssen (2007)]). Although −2.827 Ha is still worse than the
Quantum ESPRESSO Course for Solid‐State Physics | 233
Hartree‐Fock result, it is an important improvement with respect to
−2.716 Ha. The experimental value of the total energy of the helium
atom is −2.9 Ha [Sucher (1958)].
Chapter 5

Solid‐State Physics for Quantum


ESPRESSO

In order to understand the input and output files of Quantum


ESPRESSO, the readers need to know the meaning of technical words
in solid‐state physics. Here we give minimum information of solid‐
state physics for Quantum ESPRESSO. The authors wish that the
readers take interest in solid‐state physics even though their major
is not physics.

5.1 Unit cell and Brillouin zone

Unit cell: In Quantum ESPRESSO, we consider a crystal. A crystal is


solid with a periodic structure on the position of atoms in the solid.
Thus, in order to express the structure of a crystal, it is sufficient to
show a minimum block of the periodicity, which is called a unit cell.
The unit cell is a box or a parallelepiped,1 which can be represented
by three vectors, each of which is called a unit vector, ai (i = 1, 3).
The angles between the unit vectors can be 90◦ , 120◦ , or any value

1 A parallelepiped is a box in which consists of three pairs of parallel faces.

Quantum ESPRESSO Course for Solid‐State Physics


Nguyen Tuan Hung, Ahmad R. T. Nugraha, and Riichiro Saito
Copyright © 2023 Jenny Stanford Publishing Pte. Ltd.
ISBN 978‐981‐4968‐37‐9 (Hardcover), 978‐981‐4968‐63‐8 (Paperback), 978‐1‐003‐29096‐4 (eBook)
www.jennystanford.com
236 | Solid‐State Physics for Quantum ESPRESSO

depending on the symmetry of the crystal. In three‐dimensional


materials, we have 230 distinct crystal shapes, which are defined
in the space group. The 230 kinds of crystals are classified by (A)
5 crystal families, (B) 14 Bravais lattices, or (C) 32 point groups of
the unit cell. Here the Bravais lattice is defined by the nonequivalent
translational symmetry of the lattice. In the input file of Quantum
ESPRESSO, we input the information of ai (i = 1, 3). The relative
coordinate of the j‐th atom in the unit cell, rj is given by fractional
numbers sij (i = 1, 3, 0 ≤ sij < 0) in the input file:

3
rj = sij ai . (5.1)
 >
i

It should be careful to set sij in the unit cell when the unit cell is not
cubic or cuboid. A lattice vector which is defined by

R = pa1 + qa2 + ra3 , (p, q, r; integers), (5.2)

where R represents a position of the unit cell in the crystal. Thus, the
coordinate of any atom in a crystal is given by the sum of R + rj .
Reciprocal lattice vector: Any wave in the crystal2 that
propagates in the direction of k is expressed by f(k, r) ≡ exp(ik · r)
which we call a plane wave. The product of k · r in exp(ik · r) is called
a phase of the wave that has a periodicity of 2π. If we take r = ai and
k = bi so that ai · bi = 2π, we get the same amplitude of f for r and
r + ai , that is f(bi , r) = f(bi , r + ai ). Further, if we take r = ai , we get
f(k, ai ) = f(k + bi , ai ). It means that the wave has a periodicity not
only in the real space but also in the k space, which we call reciprocal
lattice.3 The vector bi is a reciprocal lattice vector. The unit box in
the k space which consists of the three bi is called the Brillouin
zone. Similar to the lattice vector R, we can define reciprocal lattice
vector, G,

G = ℓb1 + mb2 + nb3 ≡ (ℓ, n, m), (ℓ, n, m; integers), (5.3)

2 In quantum mechanics, electron behaves as a wave. Lattice oscillation is a wave like

earthquake in the earth. X‐ray propagates in the lattice as electro‐magnetic wave.


3 If you know the Fourier transform, you can imagine that the r and k can be

converted to each other. In physics, we call the extended 6 dimensional space of {r, k}
as a phase space. Any motion of a particle is expressed by a curve in the phase space.
Quantum ESPRESSO Course for Solid‐State Physics | 237
where G represents the position of the Brillouin zone in the k space.
The integers of (ℓ, n, m) are called the Miller indices which are used
in X‐ray analysis (Sec. 5.2).
The bi is obtained in the output file of Quantum ESPRESSO since
bi can be calculated by the ai in the input file as follows:

1 if i = j

ai · bj = 2πδij , . (5.4)
0 if i ̸= j
δij ≡

In fact, we have the following formula for bi which satisfies Eq. (5.4):

2π(a2 × a3 ) 2π(a3 × a1 ) 2π(a1 × a2 )


b1 = , b2 = , b3 = , (5.5)
a1 · (a2 × a3 ) a2 · (a3 × a1 ) a3 · (a1 × a2 )

where × denotes a vector product or cross product. Because of


the properties of the vector product that the vector a2 × a3 is
perpendicular to the both a2 and a3 , we can check that Eq. (5.5)
satisfies Eq. (5.4). The Brillouin zone is given by six vertical bisectors4
of bi and −bi , (i = 1, 3).

5.2 X‐ray analysis

Once we define the unit vectors ai in the input file of Quantum


ESPRESSO, we can plot the 3D picture of the unit cell and
lattice, Brillouin zone (see Sec. 5.1) by XCrySDen (see Sec. 3.1.1).
Experimentally the lattice structure of a crystal is observed by X‐ray
spectroscopy. The most popular X‐ray analysis is the Debye‐Scherrer
method in which the incident X‐ray is scattered in the direction of an
angle so‐called 2θ from the propagating direction of incident X‐ray
(ki n in Fig. 5.1 (b)).5 Thus, if we measure the intensity of the scattered
X‐ray as a function of 2θ for calculating the lattice, we can directly
compare the calculated results with the experimental results, which
can also be automatically calculated by XCrySDen. The X‐ray spectra

4 A vertical or perpendicular bisector for a given vector is a plane that is

perpendicular to the vector and that intersects at the center of a vector.


5 2θ is called diffraction angle. The factor 2 of 2θ can be understood by Fig. 5.1.
238 | Solid‐State Physics for Quantum ESPRESSO

(a) λ (b)
kin kout

θ θ Δk

θ θ d

Figure 5.1 (a) Bragg’s condition in the real space. (b) Bragg’s condition is the
k space.

have one peak at a 2θ, which we can label by a Miller index (ℓ, n, m)
(see Sec. 5.1), which we explain below.
Bragg’s condition: For a periodic lattice, we can define a crystal
plane as is shown by thin lines in Fig. 5.1 (a) on which many atoms
exist. Since the lattice is periodic, we have many equivalent crystal
planes parallel to the crystal plane. In Fig. 5.1 (a), we show the side‐
view of the crystal planes as parallel lines. When the incident X‐ray
with the wavelength λ enters the crystal with an angle θ (solid dots
in Fig. 5.1 (a)) measured from the plane, the diffracted X‐ray that
propagates in the direction of θ, too, interfere to each other from
two adjacent planes as shown in Fig. 5.1 (a). The condition of the
constructive interference of the diffracted light is given by


2d sin θ = nλ, , (5.6)
2d
sin θ =

where d denotes the distance between two adjacent planes and n =


1, 2, … is an integer. Since d and λ are given, respectively, by the crystal
and incident X‐ray, only θ’s for a given n are possible direction of
diffracted light. It is noted that the constructive interference occurs
not only for the two planes but also for all (say 108 ) parallel crystal
planes in the crystal, which gives a strong X‐ray intensity.6 In Fig. 5.1
(b), we show that the diffraction angle of the scattered X‐ray becomes
2θ which is the reason why we use 2θ in the horizontal axis of X‐
ray intensity plot. Since |kin | = |kout | = k = 2π/λ, the change of the

6 If you know diffraction grating, the concept of the diffracting grating comes from

the Bragg condition of one‐dimensional periodicity.


Quantum ESPRESSO Course for Solid‐State Physics | 239
wavevector Δk is given by

nλ 2π
Δk = 2k sin θ = 2k · · n, (5.7)
2d d
=

where we use Eq. (5.6). The value of 2π/d corresponds to a reciprocal


lattice vector for a given d, which should be one of G defined by
Eq. (5.3) for being d as a distance of crystal plane. In fact, a crystal
plane is defined by three points in the space, which is given by the
end point of the three vectors of ℓ−1 a1 , m−1 a2 , n−1 a3 . The normal
vector of the crystal plane is given by G with the Miller index (ℓ, m, n).
Thus, d (2θ) for a given Miller index (ℓ, m, n) is expressed by

2π 2π
d= . (5.8)
(ℓb1 + mb2 + nb3 )2
=
|G|

When we plot X‐ray intensity as a function of 2θ, we do the


following procedure:

1. We assign the shape of the unit cell by ai , (i = 1, 2, 3).


2. We get the reciprocal lattice vector bi , (i = 1, 2, 3) by Eq. (5.5).
3. For a given Miller index, (ℓ, m, n), we calculate d by Eq. (5.8).
4. From the calculated d, we get θ by Eq. (5.7) by putting n = 1 and
λ = 1.54 Å.7
5. Then we calculated X‐ray intensity at 2θ.

For calculation of X‐ray intensity, we need to know the concepts


of “structure factor” and “atomic form factor”. However, we will not
explain in detail those words for simplicity. Since the software or
database gives the X‐ray intensity automatically, it is sufficient for
the reader to know the meaning of 2θ. If you wish to know how
to calculate the two factors, please take a look at the solid‐state
textbook.
Nevertheless, we should comment on an important concept
of the “structure factor” for assigning the crystal symmetry. The
scattering amplitude of solid is given by the sum of the scattering

7This wavelength of X‐ray is called for Cu Kα line. If there is no specification of the


wavelength in the experiment, you can use this value for comparison.
240 | Solid‐State Physics for Quantum ESPRESSO

amplitude of atoms in the unit cell. The intensity of the X‐ray is


calculated by taking the square of the sum of scattering amplitudes
of atoms in the unit cell. When the number of atoms in the unit cell is
more than one, the destructive interface of the scattering amplitude
occurs for two in‐equivalent atoms in a unit cell. In this case, the X‐
ray intensity for some (ℓ, m, n) becomes zero, which is known as X‑
ray extinction law. The extinction law is calculated by calculating
the structure factor. Since the extinct (ℓ, m, n) values depend on the
lattice symmetry, the extinction law is important for identifying the
symmetry of the lattice.

5.3 Plane wave expansion

The main results of Quantum ESPRESSO are energy dispersion or


simply energy bands. The energy band is a function of electronic
energy for an electron in the solid as a function of the wavevector
(or crystal momentum) of the electron. The energy band is obtained
by solving the Schrödinger equation in quantum mechanics (or more
precisely the Kohn‐Sham equation of the density‐functional theory
(Sec. 4.10.2)), HΨ = EΨ, where H is the Hamiltonian operator, Ψ
denote the wavefunction and E is energy. For a given H, we solve
HΨ = EΨ to obtain an eigenvalue E and an eigenfunction Ψ.8
When there is a periodicity of the unit cell in the real space, we
have another periodicity of the reciprocal lattice vector G in the k
space (Sec. 5.1). In this case, the wavevector k is a conserved variable
and thus a good quantum number for expressing both E(k) and Ψk (r).
For the energy E(k), we have the periodicity of E(k) = E(k + G) for
any G. For the wavefunction Ψ, using the periodicity of G, we can
expand Ψk (r) as follows:

CG (k)ei(k+G)r , (5.9)

Ψk (r) =
G

where CG (k) is the coefficient to be solved for each k and the


summation on G is taken for many G. This expansion is called plane

8 The Schrödinger equation is given by the differential equation, and thus we solve

the eigenvalue problem of the differential equation.


Quantum ESPRESSO Course for Solid‐State Physics | 241
wave expansion. The plane expansion is one of the Fourier series
expansion9 for a periodic function and thus if we take more number
of G, we get more precise value of the function.
Let us explain how to solve the Schrödinger equation by using
the plane wave expansion. The Hamiltonian H is given by

h̄2
(5.10)
2m
H(r) = − Δ + V(r),

where − 2m

Δ and V(r) are kinetic and potential energy operators,
2

respectively, that satisfy the periodicity of the unit cell.10 Thus, we


can expand V by the reciprocal lattice vector G as follows:

1
VG e , where VG =

iGr
dr′ V(r′ )e−iGr . (5.11)

Nu

V(r) =
G

Here integration on r′ is taken over the crystal and Nu denotes


the number of the unit cells in the crystal. By substituting
Eqs. (5.9), (5.10), and (5.11) into HΨ = EΨ, we get

 h̄2
(k + G)2 CG ei(k+G)r + VG′ CG′′ ei(k+G +G )r

2m
′ ′′

G G′ ,G′′ (5.12)
=E CG ei(k+G)r .


9 For a periodic function f(x) with a period L, we can express

f(x) = fp ei2πpx/L


p=0

which is called the Fourier series expansion. Here 2π/L is the reciprocal lattice
vector for L.
10 The Laplacian Δ are invariant for transformation of x′ = x + a and

V(r + a) = V(r).
242 | Solid‐State Physics for Quantum ESPRESSO

In the second term, we put G′ + G′′ = G and take the term of ei(k+G)r ,
we get the following equation,11

h̄2
(k + G)2 CG + VG−G′′ CG′′ = ECG . (5.13)

2m ′′ G

Eq. (5.13) is simultaneous equation for obtaining CG . In the real


calculation, when we define N × N Hamiltonian matrix

 h̄2

HGG′ = 2m (k + G) , if (G = G ) .
2
(5.14)

 V ′,
G−G if (G ̸= G′ )

Eq. (5.13) is expressed by a matrix equation HC = EC from which


we can obtain eigenvalue E and eigenvector C by diagonalizing the
matrix by numerical calculation.12

5.4 Cut‐off energy and pseudopotential

The size of the Hamiltonian matrix, N, is given by the number of


reciprocal lattice vectors G. Although the accuracy of calculation
monotonically increases with increasing N, the memory size and
computational time of the computer quickly increases with increas‐
ing N. Thus, we must find a reasonable N by plotting the total energy
and computational time as a function of N.
Cut‑off energy: In the first‐principles calculation, we do not
usually compare N for different calculations but cut‑off energy in
units of atomic unit (see Table 4.1) which is defined by

h̄2 2
Ecut‐off = G , (5.15)
2m max

where Gmax is the largest reciprocal lattice vector. We use the cut‐
off energy because the values of N depend on the size of the unit

11 Since ei(k+G)r are independent functions for different values of G, the coefficients
of the both‐hand sides should be identical. Further, we change the summation on G′
and G′′ to the sum on G and G′′ . Note that G′ = G − G′′ .
12 LAPACK is the name of a famous software package for linear algebra calculation

including diagonalizing a matrix (zheev).


Quantum ESPRESSO Course for Solid‐State Physics | 243
(a) (b)

Figure 5.2 Cut‐off energy. Dots in the k space represent the reciprocal lattice
vectors G. When we define a sphere whose diameter is |Gmax |, we will use
G’s in the sphere. Then cut‐off energy is given by Eq. (5.15). (a) When the
unit cell is large, G becomes small, and thus we have more G’s in the sphere.
(b) When the unit cell is relatively small, the number of G’s becomes small
even for the same cutting energy. Reprinted with permission from Asakura
Publishing Co. Ltd.

cell. When the size of the unit cell is relatively large because of many
atoms in the unit cell, the corresponding absolute value of G becomes
small as shown in Fig. 5.2 (a). In order to obtain the same accuracy for
calculating the atomic potentials in the smaller unit cell (Fig. 5.2 (b)),
a larger Gmax is needed. On the other hand, when we use the same cut‐
off energy for two different sizes of unit cells, we expect the accuracy
of the calculation to be similar to each other.
The selection of cut‐off energy also depends on the selection of
pseudopotential for each atom, which we explain below. As shown
in Eq. (5.12), the off‐diagonal matrix element of the Hamiltonian
matrix is the Fourier transform of the crystal potential V, which
is given by the sum of atomic potentials. If we adopt the real
atomic potential for an atom, we expect a large Coulomb potential,
−Ze2 /(4πϵ0 r) (Z is the atomic number of the atom). Fourier
transform of 1/r is 1/|G|2 which is a slowly decreasing function of
|G| compared with exp(−C|G|) (C is a constant) in three dimensions.
Thus, it is not a good idea that we do not adopt the real atomic
potential in the plane wave expansion.
Pseudopotential: For discussing most of the solid‐state proper‐
ties, inner‐core electrons in the 1s, 2s, 2p atomic orbitals for a heavy
element are not so important. Only the valence electrons near the
highest occupied orbitals contribute to the properties. The valence
244 | Solid‐State Physics for Quantum ESPRESSO

electrons feel screened Coulomb potentials by core electrons except


for the core region of the atom. Pseudopotential is a potential in
which the core region of an atom is artificially smoothed out near
r = 0 so that we do not need many G (or N) for obtaining VG with the
same numerical accuracy.
In history, pseudopotentials have been proposed by many
researchers, which we select from the list of pseudopotentials on the
web pages as input files of Quantum ESPRESSO. The pseudopotential
is given as a function of distance from the center of atom r and
the density of electrons based on the density‐functional theory
(Sec. 4.12.3).
Norm‑conserving pseudopotential: Although we will not go
to in detail of the selection of pseudopotential, it is important
to point out that the readers should select so‐called norm‑
conserving pseudopotential if they want to use the wavefunction
for calculating some matrix elements such as for calculating optical
absorption spectra. For norm‐conserving pestilential, (1) the pseudo
wavefunction that is obtained by solving the Kohn‐Sham (or the
Schrödinger equation in the DFT) equation coincides with the real
wavefunction for a larger r than a cut‐off radius, rcut . (2) At rcut ,
the values and derivative of the pseudo wavefunction and real
wavefunction should be the same. (3) For r < rcut , the norms of the
pseudo wavefunction and real wavefunction are selected to be the
same, though the pseudo wavefunction does > not have a node as a
function of r. (4) The eigenvalues or energies for pseudopotentials
are the same as those by real potentials. The solid‐state properties
calculated by norm‐conserving pseudopotentials can be compared
with experimental results with reasonably high accuracy. On the
other hand, ultra‑soft pseudopotential is another direction of
pseudopotentials in which the number of plane waves can be reduced
significantly by neglecting the norm‐conserving conditions. If one
wants to obtain the energy band of many atoms in a large unit‐cell,
the selection of ultra‐soft pseudopotential is important.

5.5 Energy bands and density of states

Energy bands: By selecting k points on high symmetry lines in the


Brillouin zone in the input file of bands.x (see Sec. 3.2.2), we can
Quantum ESPRESSO Course for Solid‐State Physics | 245
obtain the energy as a function of k, E(k), which we call energy
dispersion or simply energy bands. The name of energy bands
comes from the fact that the energy dispersion exists in a finite
energy region. For a given energy dispersion, two electrons with the
up‐ and down‐spin of electron per unit cell can be occupied. As far
as two energy dispersion does not cross each other, we can occupy
two electrons per energy band from the lowest bands to the valence
band which is the highest occupied energy band. Suppose two energy
bands cross each other before filling the lower energy band fully. In
that case, the electron starts to occupy the higher energy band with
keeping the common highest occupied energies of the two energy
bands, which is called the Fermi energy, EF .
Density of states: For a given energy dispersion E(k), when we
denote dN for the number of states in the energy region from E to
E + dE, we define density of states (DOS), D(E), as D(E) ≡ dN/dE.
The unit of DOS can be “states/eV/unit cell”. DOS becomes large when
E(k) is flat in the energy dispersion.
Since the wavevector of a crystal in one direction is given by k =
2πp/Na, (p = 0, 1, 2, …, N − 1), where N is the number of the unit cell
in the direction and a is the lattice constant. In a single crystal with a
size of 1 cm, since N is large N(∼ 108 ), the wavevector k exists almost
continuously, which is why energy dispersion E(k) is generally given
a function of k. For each k state, we can put two electrons with up‐
spin and down‐spin, and thus in total, we can put 2N electrons for N
k states. Since there are N unit cells in the direction, we can say that
we can occupy two electrons per unit cell, whose situation is the same
as the case of three dimensions.
In Quantum ESPRESSO, DOS is calculated by making a mesh of k
in the Brillouin zone. For a given E and for a given three‐dimensional
box made of mesh, if there is an equi‐energy surface of E(k) = E, the
area of the surface in the mesh is proportional to DOS. The number
of mesh specified by the input file of DOS (see Sec. 3.2.3) is about 10
× 10 × 10 since we can interpolate E(k) in the box of the mesh. This
method is called the “tetrahedron method”, from which you can learn
more about the tetrahedron method for obtaining DOS.
Metal, semimetal, semiconductor, insulator: Using the output
values of the energy bands, the Fermi energy, and density of states,
we classify the materials. When the Fermi energy is located in the
middle energy of the energy band, electrons in the energy band can
246 | Solid‐State Physics for Quantum ESPRESSO

easily excite the unoccupied states within the same energy band. This
situation is called “metal”. We can say that metal is defined by a finite
density of states at the Fermi energy, D(EF ) ̸= 0. When the valence
band is fully occupied, and the next higher energy band, that is
conduction band is unoccupied, we usually have an energy gap. An
energy gap, Eg , is defined by an energy difference between the highest
energy of valence band and the lowest energy of conduction bands.13
Since there are no states in the energy gap region, the occupied
electron in the valence band needs at least Eg for exciting the electron.
This situation corresponds to “semiconductor” or “insulator”. The <
difference between “semiconductor” or “insulator” is the value of Eg .
If Eg <3eV, we can say that the material is semiconductor, while Eg > 5
eV, we call “insulator”.14
When Eg = 0 or Eg is a small value compared with the thermal
energy kB T (kB is the Boltzmann constant), part of electrons in
>

the valence band can be excited at the finite temperature. In this


situation, if the density of states at the Fermi energy is much smaller
than D(EF ) of three‐dimensional metal, the number of carriers for
flowing an electric current15 becomes small, too. Such material is
called semimetal. A typical example of semimetal is graphene in
which Eg = 0 and D(EF ) = 0.
k sampling points: It is noted that Quantum ESPRESSO
calculation of a metal takes more computational time than that
of a semiconductor in the SCF calculation (Sec. 4.5). In the SCF
calculation, we evaluate the charge density ρ(r) by occupying
electrons in the energy bands, which require more k points in the
case of metal. When we evaluate ρ(r) for a semiconductor, we can
use a few numbers of sampling k points in the Brillouin zone. When
all energy bands are fully occupied or unoccupied, we need only a few
(even one) k points. However, in the case of metal, on the other hand,
since we need to consider the occupation up to the Fermi energy,
more k points are needed for obtaining the Fermi surface (a closed

13 If you are a chemist, you can imagine that an energy gap is a kind of HOMO‐LUMO

gap of a molecule in solid.


14 For 3 < E < 5 eV, we can say “wide‐gap semiconductor”.
g
15 Carrier is either an electron or a hole that conducts an electronic current in a solid.

A hole is an unoccupied state in the almost occupied energy band. Like a going‐up
beer bubble,
> the > unoccupied states carry a positive charge in the solid in the
direction opposite to that of the electron.
Quantum ESPRESSO Course for Solid‐State Physics | 247
(a) D(E) | M |2 (b)
E
A
I
0

EF + eV −I tip −V
EF
sample tip sample

−V 0
Figure 5.3 Scanning tunneling spectroscopy. (a) Tunneling current I (Eq.
(5.16)) flows from the metallic materials (left) to a scanning metallic tip
(right) in the energy region between EF and EF + eV, in which electrons
occupied in the metallic side while not occupied in the tip side. (b) In the
experiment, we fix the position of the tip, we change the voltage. Then the
value dI/dV is proportional to the density of state D(EF + eV) (Eq. (5.17)).

surface in the k space on which the energy is the Fermi surface) which
costs more CPU times. Total energy depends on the number of the
sampling points, which should be checked by increasing the sampling
points.

5.6 Experiments for E(k) and DOS

The calculated E(k) and DOS D(E) by Quantum ESPRESSO can


be directly compared with ARPES (angle‐resolved photo‐electron
spectroscopy) and STS (scanning tunneling spectroscopy) measure‐
ments, respectively. In ARPES, we can measure a kinetic energy E
of photo‐excited electron which emitted from the materials as a
function of the momentum direction of photo‐electron k emitted
into the vacuum by illuminated by light (photoelectric effect), which
can be directly compared with the calculated electronic energy
dispersion, E(k). Since the electrons exist in the occupied energy
bands, we can compare the E(k) only for the occupied energy bands
down to 10–20 eV below the Fermi energy. The range of energy that
we can observe by ARPES depends on the light source.
In STS measurement (see Fig. 5.3 (b)), we measure the tunneling
electric current I on a sharp metallic tip, which is electrically biased
by an applied voltage. If we assumed that the tunneling probability
248 | Solid‐State Physics for Quantum ESPRESSO

|M|2 does not depend on the energy of electrons, the tunneling


current I is given by
EF +eV
I= |M|2 D(E)dE,

(5.16)
EF

from which the differential conductance, dI/dV is calculated as


follows:

= |M|2 D(EF + eV) ∝ D(EF + eV). (5.17)


dI
dV

We get from Eq. (5.17) that the differential conductance defined by


dI/dV is proportional to the density of state at E = EF + eV. Thus, we
can measure D(E) by changing V near the EF . In the case of STS, the
sample should be a conductor to have a finite I. Further, in order to
avoid thermal broadening of the Fermi distribution function, the STS
measurement is performed at a much lower temperature than the
room temperature.

5.7 Phonon dispersion

Phonon dispersion relation is the phonon frequencies in units of


cm−1 (1 eV = 8065 cm−1 ) as a function of the wavevector of
phonon, q. In Fig. 5.4, we show (a) phonon dispersion and phonon
density of states of graphene. In Quantum ESPRESSO, we specify q
by connecting symmetric points in the Brillouin zone, as is the case
of the electronic energy band. When we have N atoms in a unit cell,
we have 3N phonon dispersion in the Brillouin zone in which 3 of the
3N phonon dispersion are acoustic phonon modes whose frequency
is zero at the zone‐center (or the Γ point) of the Brillouin zone. The
remaining 3N − 3 phonon modes are optical phonon modes. For the
three acoustic modes, one of the three acoustic modes is longitudinal
acoustic (LA) phonon mode, in which the oscillational direction is
parallel to the propagation direction of the wave of oscillation. The
remaining two acoustic phonon modes are transverse acoustic (TA)
phonon modes, in which the oscillational direction is perpendicular
to the propagation direction. For optical phonon modes, N − 1 modes
are longitudinal optic (LO) modes, and the remaining 2N − 2 are
Quantum ESPRESSO Course for Solid‐State Physics | 249
(a) 1600 (b)
Frequency (cm-1)
1200

800

400

0 -2
0.0 1.0 x 10
Γ M K Γ -1
State/1C-atom/cm
Figure 5.4 (a) Phonon dispersion of graphene. The unit of frequency is cm−1
(1 eV = 8065 cm−1 ). (b) Phonon density of states.

transverse optic (TO) modes. The assignment of LA, TA, LO, and TO is
possible by looking at the direction of oscillation of each atom at the
Γ point (or near the Γ point for acoustic modes by the Material Cloud
(see Sec. 3.3.1.)).
When the material is two‐dimensional, such as graphene as
shown in Fig. 5.4, TA modes are further classified by in‐plane TA
(iTA) and out‐of‐plane TA (oTA), and TO modes are classified by in‐
plane TO (iTO) and out‐of‐plane TO (oTO) phonon modes. In LA and
LO modes, since the propagation direction is in‐plane, we do not
usually say iLA or iLO. On the other hand, we sometimes call oTA and
oTO modes as ZA and ZO modes which shows that the oscillational
direction is in the direction of z axis for xy plane of two‐dimensional
materials.
Phonon dispersion of a given material is calculated by solving
the so‐called dynamical matrix. In the dynamical matrix, we define
force constants between two atoms in the crystal. In order to
define the force constant, any atom should have a restoring force
for all directions of the displacement of the atom. This situation
corresponds to the ground state in which the total energy has a
minimum at the optimized position as a function of displacement of
each atom. The restoring force can be calculated by the gradient of the
total energy by displacing an atom in the unit cell with keeping other
250 | Solid‐State Physics for Quantum ESPRESSO

V(r)

rmin
r

Figure 5.5 Anharmonicity of oscillation. When we expand the potential V(r)


as a displacement x measured from the minimum of V(r), rmin the potential
can be approximated by a harmonic potential (∝ x2 ) as shown in the dashed
line. When the amplitude of oscillation becomes relatively large, the centers
of oscillation that are shown as dots shift to large values of r because of the
deviation of V(r) from the harmonic potential. The shift of dots corresponds
to the thermal expansion of the materials. Thus, the anharmonicity of the
potential is essential for thermal expansion.

atoms at the optimized position. If the optimization of the lattice


structure is not sufficient, some restoring force might be negative,
which gives an imaginary phonon frequency for the acoustic phonon
modes at the Γ point.
In the phonon calculation by Quantum ESPRESSO, we usually
adopt so‐called “density‐functional perturbation theory (DFPT)”
[Baroni et al. (2001)] in which we need to optimize structure in
relatively high precision by calculating the norm of the restoring
forces of each atom, which takes a much more computational time
than that of the electronic energy band.
When we get the minimum of the total energy by optimization,
we can expand the total energy by a displacement x in which the
quadratic function of the displacement, kx2 /2, corresponds to the
harmonic oscillation with a spring constant k. However, when the
displacement is relatively large (for example, 10% of the lattice
constant, a), an anharmonic term which is proportional to x3 can not
be neglected anymore as shown in Fig. 5.5. When the amplitude of
oscillation becomes relatively large, the center of oscillation that is
shown a dot for each amplitude shift to a larger value of r than rmin
because of the deviation of V(r) from the harmonic potential (dashed
line). The shift of dots corresponds to the thermal expansion of the
materials. Thus, the anharmonicity of the potential is essential for
thermal expansion.
Quantum ESPRESSO Course for Solid‐State Physics | 251
5.8 Electron‐phonon interaction

Since both electrons and phonons exist as a function of wavevector


in solid, we expect the interaction between an electron and a
phonon, that is, electron‐phonon interaction, when the energy and
momentum conservation satisfies in the interaction. The origin of
electron‐phonon interaction can be understood by the oscillation of
atomic potential by lattice oscillation which modifies the electronic
energy. In Quantum ESPRESSO, we obtain the electronic energy band
by assuming that the atoms do not move. However, this assumption
is an approximation in the case of finite temperature,16 in which
we have a finite amplitude of lattice oscillation, 0.01–0.1 Å, whose
energy is the order of kB T (kB is the Boltzmann constant). Thus,
the oscillation of the lattice accelerates (or decelerates) the velocity
of an electron to have a thermal equilibrium state. Because of the
law of action and reaction, the motion of an electron can modify
the lattice oscillation, too. However, since the mass of an atom is
103 − 105 times larger than that of an electron, like a small bird on
the shoulder of a person, the energy of the electron depends only on
the position but not on the velocity of the atom. This means that the
electron can easily follow the motion of the atom without any delay
of the motion of the electron. This approximation is called “adiabatic
approximation”. In this approximation, the motion of the lattice is
not affected much by the motion of electrons as the motion of the
human is not affected by the motion of the bird on the shoulder even
though the person feels the bird.
When we denote distortion of an atom, δR, from the original
position of R as shown in Fig. 5.6, the distorted atomic potential
v(r − δR − R) can be expanded by

v(r − R − δR) = v(r − R) + v′ (r − R)δR, (5.18)

in which the second term of the right‐hand side of Eq. (5.18) is called
deformation potential. When we adopt the adiabatic approximation

16 Lattice does move even at T = 0 K, which is known as zero‐point motion of the

atom. An origin of the zero‐point motion is the uncertainty principles of quantum


mechanics. It is known that the zero‐point motion gives a not‐negligible contribution
to thermal properties of materials.
252 | Solid‐State Physics for Quantum ESPRESSO

δR
t t t t t

v(r−R)
v(r﹣R)

Figure 5.6 Deformation potential. Solid lines are atomic potentials. When an
atom shifts position by δR, the potential energy for an electron (showing
solid circles) of the nearest neighbor atom increases (or decreases) by
moving away (or approaching) the atom. Further the absolute value of the
transfer integral |t| decreases or increases by moving away (or approaching)
the atom.

(a) (b)
R k′
R′′
R1
R2 k
q
R′
Figure 5.7 (a) Three‐centers integral M(R′ , R, R′′ ) in Eq. (5.20) is a function of
the positions of three atoms, R′ , R, R′′ . The integration is given as a function
of the relative coordinate R1 = R − R′ , R2 = R′′ − R′ . (b) The momentum of
an electron h̄k is scattered to h̄k′ = h̄k′ − h̄q by emitting a phonon with the
crystal momentum h̄q.

that the atomic wavefunction follows the position of the atom, the
atomic wavefunction of the distorted atom is given by

φ(r − R − δR) = φ(r − R) + φ′ (r − R)δR. (5.19)

When we consider the integration of the atomic potential by the


atomic wavefunction, ⟨φ|v|φ⟩, the correction of ⟨φ|v|φ⟩ by putting
Eqs. (5.18) and (5.19), up to the linear term of δR, we get the
expression of electron‐phonon interaction. The correction of ⟨φ|v|φ⟩
appears in the diagonal and off‐diagonal matrix element of the
Hamiltonian matrix, which we call on‐site and off‐site electron‐
phonon interaction, respectively.
When we consider electron‐phonon interaction in solid, an
electron is scattered from k to k′ states in the k space. When we
Quantum ESPRESSO Course for Solid‐State Physics | 253
consider the Bloch orbital Φ(k, r) for electronic states and the lattice
distortion of a phonon with the wavevector, q, δR = A exp(−iqR), the
matrix element between the Bloch orbitals of k and k′ is given by

Vk′ ,k ≡ A⟨Φ(k′ , r)|v′ (r) exp(−iqR)|Φ(k, r)⟩


1 
exp(−ik′ R + ikR′′ − iqR′ )M(R, R′ , R′′ ), (5.20)
N ′ ′′
=
R,R ,R

where M(R′ , R, R′′ ) is three‐centers integral as a function of R′ , R, R′′ ,


M = A⟨φ(r − R)|v′ (r − R′ )|φ(r − R′′ )⟩. When we adopt the relative
coordinates R1 = R − R′ , R2 = R′′ − R′ to the coordinate R′ , as
shown in Fig. 5.7, M can be expressed as a function of R1 and R2 ,
M(R1 , R2 ). Then we can take the summation on R′ in Eq. (5.20), and
we get

1 
Vk′ ,k = exp(−ik′ R1 + ikR2 + i(−q − k′ + k)R′ )M(R1 , R2 )
N
R1 ,R ,R2
= δ(−q − k′ + k) exp(−ik′ R1 + ikR2 )M(R1 , R2 )



R1 ,R2

(5.21)

where δ(−q − k′ + k) is the delta function that shows the conser‐


vation of momentum, k = k′ + q, before and after the scattering.
In Fig. 5.7 (b), we show that the momentum of an electron h̄k is
scattered to h̄k′ = h̄k − h̄q by emitting a phonon with the crystal
momentum h̄q. It is noted here that the delta function is satisfied
even when k = k′ + q + G (G is the reciprocal lattice vector) since the
exponential function exp(i(−q − k′ + k)R′ ) = exp(iGR′ ) becomes
the unity. The scattering with G ̸= 0 in which additional momentum
from the lattice is given (or released) to electron is called the
Umklapp process while the scattering with G = 0 is called normal
process. In both cases the energy and momentum that include the
crystal momentum conserved during the scattering processes. The
electron‐phonon interaction is essential for occurrence of electrical
resistance, superconductivity, and Raman spectroscopy.
In Quantum ESPRESSO, the electron‐phonon matrix element is
calculated as a function of k and q (see Sec. 3.3.3). The calculated
254 | Solid‐State Physics for Quantum ESPRESSO

Figure 5.8 When light comes to a material, the light is transparent (left),
reflected (center), or scattered (right). Even for the case of transparent, the
direction of light changes after the transmission. Reprinted with permission
from Asakura Publishing Co. Ltd.

matrix elements are used for estimating the critical temperature of


the superconductivity or resonant Raman intensity.

5.9 Optical properties of solid

When light hits a material (see Fig. 5.8), the light is transparent (left),
reflected (center), or scattered (right). Even in the case of transparent
properties, the direction of light changes after the transmission. It
means that all phenomena are related to the interaction of a photon
and materials.
Light or a photon interacts with an electron (or electrons) in
the materials. The optical properties of the materials consist of
(1) absorption, (2) emission, and (3) scattering of light. In the
case of semiconductors, optical absorption (or emission) occurs
for the photon whose energy is more than the energy gap of the
semiconductor. Suppose the momentum and energy of a photon are
matched to the difference of momentum and energy between the
initial and final electronic states. In that case, the optical absorption
occurs by annihilating the photon and by exciting the electron from
the initial to the final states. This type of excitation for the electron
is called single‐particle excitation. On the other hand, for metal
or heavily doped semiconductors, an electric field of a photon as
Quantum ESPRESSO Course for Solid‐State Physics | 255
an electro‐magnetic wave can excite an electric current of metal.
The optical absorption occurs by the Joule heat by the current. In
this case, since the current is the collective motion of electrons,
this type of excitation is called collective excitation. Usually, the
single‐particle excitation and collective excitation occur exclusively
or simultaneously for a given energy of the photon.
Scattering of light in the semiconductor is defined as a sequential
process of optical absorption and emission, in which the emitted light
propagates in any direction of solid angle. The scattering amplitude
depends on materials as a function of photon frequency, which
determines the color of the materials. On the other hand, in metal, the
reflection of light occurs by screening the electric field of the photon
by the induced electric current, which is the origin of metallic luster.
For the region of the wavelength of the visible light, from 400 to
800 nm, there are two kinds of scattering of light: elastic and inelastic
scattering of light, which we call the Rayleigh and Raman scattering,
respectively. In the Rayleigh (Raman) scattering, the scattered light
does not (does) change the energy from that of the incident light.
The scattering amplitude becomes strong if the energy difference of
the initial and the final electronic states is the same as the photon
energy for either the incident or scattered photon. This effect is
called resonant Rayleigh (Raman) scattering. The resonant Rayleigh
scattering can be one of the reasons the materials have an intrinsic
color.17
Optical absorption can be explained by the perturbation theory
for electronic structure in which the perturbation Hamiltonian is
given by the vector potential of the electromagnetic field as follows:

1
{−ih̄∇ − eA(t)} + V(r)
2
2m
H=
1  2
−h̄ Δ + ieh̄A(t) · ∇ + ieh̄∇ · A(t) + e2 A(t)2 + V(r).

2m
=

(5.22)

Both electric field (E = iωA) and magnetic field (B = ∇ × A = ik ×


A) of the electro‐magnetic wave can be expressed by the vector

17 Other reasons are (1) absorption spectra by induced current, (2) structural color,

and so on.
256 | Solid‐State Physics for Quantum ESPRESSO

potential A(t). In Eq. (5.22), we adopt the Coulomb gauge (divA =


0),18 we get that ∇ · A = divA + A · ∇ = A · ∇. When we neglect the
term of e2 A(t)2 /2m compared with the term ieh̄A · ∇, which is a good
approximation for the conventional power of laser light, we get the
perturbation Hamiltonian as follows:

ieh̄
A(t) · ∇. (5.23)
m
H′ =

When we used the Fermi golden rule,19 the transition probability


per unit time, dP/dt from the initial state i to the final state f is given
by

dP
= 2 | ⟨f|H′ |i⟩ |2 δ(Ef − Ei − h̄ω), (5.24)
π
dt h̄

where δ is the Dirac delta function. The delta function tells us that
the optical transition occurs when the energy difference between
the initial state Ei and the final state Ef is matched to the energy
of the phonon h̄ω, which we call resonant optical transition. In the
mathematics, the delta function δ(x) describes a singular function at
x = 0. However, in physics, because of the uncertainty principles for
the energy, ΔEΔt ∼ h̄, the strict condition of x = 0 can be relaxed for
the fast optical transition with a small Δt. For example, if Δt = 1 ps
(or 1 THz), ΔE becomes about 1 meV. ΔE = 1 meV means that the
optical absorption spectra have a spectral width of 1 meV. For the
case of Raman scattering, a typical value of scattering is Δt = 10 fs,
ΔE becomes 0.1 eV.20
⟨f|H′ |i⟩ in Eq. (5.24), which is called transition dipole moment,
is calculated by putting the wavefunction of valence and conduction

18 The gauge is an additional condition for a vector potential combined with a scalar

electro‐static potential that does not change the value of electric and magnetic fields.
If we adopt the Coulomb gauge, the scalar electro‐static potential satisfies the
Poisson equation, while if we adopt the Lorentz gauge, the scalar electro‐static
potential satisfies the wave equation.
19 The Fermi golden rule is a general formula of the rate of transition from the initial

to the final states for a given time‐dependent perturbation that has a time
dependence of exp −iωt. See detail in any textbook on quantum mechanics.
20 ΔE = 0.1 eV means that the resonance Raman scattering occurs within 0.1 eV

energy width as a function of incident laser energy, which we call resonance Raman
profile. It is noted that the spectral width of Raman spectra comes from the lifetime
of a phonon.
Quantum ESPRESSO Course for Solid‐State Physics | 257
bands for the initial and final states, respectively. Here we can express
the vector potential of the light by polarization vector P that is the
unit vector in the direction of A (or E),

i I0

A= exp {i(kopt · r ± ωt)}P, (5.25)
ω cε0

where I0 is the intensity of incident laser light (W/m2 ), ε0 , kopt and ω


denote, respectively, the permittivity of the vacuum, the wavevector
and angular frequency of the light. When we define the dipole vector:

Dfi (k) = ⟨f|∇|i⟩, (5.26)

we express the matrix element by an inner product of Dfi and P, as


follows:

eh̄ I

exp {i(ωf − ωi ± ω)t}Dfi · P. (5.27)
mω cε0

⟨f|H |i⟩ =

In the Quantum ESPRESSO, since the wavefunction is expanded by


the plane waves (Eq. (5.9)), by putting Eq. (5.9) to Eq. (5.26), Dfi (k)
is expanded as follows:

Dfi (k) = i CG′ (k)CiG (k)(k + G) exp {i(G − G′ )r}dr


  f∗ 

G G′

=i Cf∗
G′ (k)CG (k)(k + G)δ G,G
i


G G′

=i Cf∗
G (k)CG (k)(k + G).
i
(5.28)


Thus using the output of the coefficients of the wavefunction, we can


calculate the optical absorption spectra.
The optical absorption spectra can be calculated in Quantum
ESPRESSO once we calculate the dielectric functions as a function
of ω, ε(ω) (Sec. 3.4.1). Using the calculated dielectric functions, the
real and imaginary part of the refractive index, n(ω) and κ(ω) are,
respectively, given by

|ε(ω)| + Re(ε(ω))

n(ω) = , (5.29)
2
258 | Solid‐State Physics for Quantum ESPRESSO

and

|ε(ω)| − Re(ε(ω))

. (5.30)
2
κ(ω) =

The dimensionless reflectance, R(ω), and absorption coefficient,


α(ω) in units of 1/m are expressed by n(ω) and κ(ω) as follows:

(n(ω) − 1)2 + κ(ω)2


R(ω) = , (5.31)
(n(ω) + 1)2 + κ(ω)2

and

2ωκ(ω)
, (5.32)
c
α(ω) =

where c denotes the velocity of light. The absorption coefficient, α(ω),


is defined by the Lambert‑Beer law in which the intensity of the
transmitting light, I(z), for a given incident intensity, I0 , is expressed
by

I(z) = I0 exp (−iαz). (5.33)

The absorption coefficient becomes large when the number of states


is large for a pair of the initial and final states for a given energy
difference E is large. The number of states for the pair is calculated
by Quantum ESPRESSO as joint density of states (JDOS(E)) which is
defined by

V
JDOS(E) = dkδ {Ecσ (k) − Evσ (k) − E},

(5.34)


σ
(2π)3

where the summation is taken for the spin of electrons, V is


the volume of the sample, Ecσ (k) (Evσ (k)) represents the energy
dispersion of conduction (valence) band with the spin σ. Here, we
assume that the photon wavevector is sufficiently small compared
with the reciprocal lattice vector, and thus the photon wavevector is
neglected for the momentum conservation. The assumption is valid
for h̄ω < 3eV. In the case of X‐ray, on the other hand, the wavevector of
the photon can not be neglected in the calculation of X‐ray absorption
spectra> [Chowdhury et al. (2012)]. In one‐dimensional materials
Quantum ESPRESSO Course for Solid‐State Physics | 259
such as carbon nanotubes, it is known that the JDOS becomes
singular (1/ E − E0 at the energy bottom or top (E = E0 ), which is

known as one‐dimensional van Hove singularity [Saito et al. (1992)].


In the two‐dimensional materials, van Hove singularity (log |E − E0 |)
appears at the saddle point of energy dispersion. In the case of
graphene, the saddle points exist at the M point (E = E0 ) in the two‐
dimensional Brillouin zone.

5.10 Transport properties of solid

When we apply the voltage to the electrodes at both ends of the


materials, electric current flows. If you can control the current
electronically, we can make a solid‐state device such as a transistor.
Further, applying a magnetic field to the devices can create an electric
current with the aligned spin of an electron, which we call spin
current. In this section, we discuss the electric current as a transport
property of solid.
When we consider a cuboid with a width W and a length L,
electrical resistance R in SI unit Ω (Ohm) is defined by

L
R=ρ , (5.35)
W2
(Ω)

where W2 is a cross‐section of the cuboid and ρ (Ωm) is called


resistivity. The inverse of R is conductance G in SI unit S (Siemens):

W2
G=σ , (5.36)
L
(S)

where σ ≡ 1/ρ is conductivity (S/m). It is clear from Eqs. (5.35) and


(5.36) that R and G depend on the shape of material such as W and L
while ρ and σ do not depend on the shape but only on the materials.
When an electron (or a hole) feels a constant force of −eE
(eE) in the presence of the constant electric field E, the velocity is
proportional to the time t, as eEt/m, where m is the effective mass
of the electron. On the other hand, the electron loses velocity by
scattering in the materials. If we assume that the electron loses the
velocity after a time 2τ, where τ is called a relaxation time, the
averaged velocity, v̄ of the electron can be expressed by eEτ/m since
260 | Solid‐State Physics for Quantum ESPRESSO

the velocity changes from 0 to 2eEτ/m. The current density J in units


of C/m2 s, is defined by the number of electrons (or holes) passing a
unit area of 1 m2 per unit time, which is given by

nc e2 τE
J = nc ev̄ = , (5.37)
m

where nc denotes the carrier21 density in units of 1/m3 . Since the


conductivity is defined in electromagnetism by J = σE, we get the
formula for the conductivity by comparing with Eq. (5.37),

n c e2 τ
. (5.38)
m
σ=

Further, the conductivity is given by a product of (number of carriers)


and mobility. Mobility is a physical quantity of how much velocity
increases with respect to a given electric field. When we denote
the number of electrons and hole per unit volume by n and p,
respectively, the mobility of electron and hole, μe and μh are defined
by

σ = −neμe + peμh . (5.39)

The unit of mobility is m2 /V·s. By comparing Eq. (5.38) and


Eq. (5.39), the mobility can be expressed by

μi = eτ i /mi (i = e, h). (5.40)

Eq. (5.40) means that the mobility is proportional to the recombi‐


nation time, τ i , and inversely proportional to the effective mass, mi .
In order to get a relatively large current density, J, either a large
carrier density or a large mobility are needed. In semiconductors, the
number of carriers can be controlled by the number of impurities
doped to the semiconductor. However, since the impurity can be a
center of scattering for carriers, too much doping gives relatively low
mobility.
In Quantum ESPRESSO, the relaxation time for the n‐th band,
τ n (k), is given as a function of k by the inverse of the scattering rate,

21 Carrier is either an electron or a hole that carries charges.


Quantum ESPRESSO Course for Solid‐State Physics | 261
Γnk (k), as

1
τ n (k) = , (5.41)
Γn (k)

in which Γn (k) is calculated by EPW package [Poncé et al. (2016)]


with using the electron‐phonon interaction as

2π  dq
|Mmn (k + q, k)|2 ×


h̄ mμj
Γn (k) =
ΩBZ
(5.42)
1+j
 
− jfm,k+q + nq.μ δ (ΔEk.q − jh̄ωqμ ),
0
2

where Mmn (k + q, k) represents the electron‐phonon matrix element


for an electron to be scattered from the initial state (n, k) to the final
state (m, k + q) by the μ‐th phonon at q with the phonon frequency
ωqμ . The integer j represents either phonon emission (j = +1) or
phonon absorption (j = −1). fm,k+q
0
and nq.μ denote, respectively, the
Fermi and Bose‐Einstein distribution functions for the electron and
the phonon. ΩBZ denotes the volume of the Brillouin zone in the
k space. The delta function shows the energy conservation in the
Fermi golden rule for the time‐dependent perturbation theory. The
summation is taken over the possible intermediated states specified
by m, μ, and j and the integration on q is taken over the Brillouin zone.
It is noted that the Mmn (k + q, k) for a given q is calculated
by the so‐called Wannier interpolation (see Sec. 5.14.3) in EPW
(electron‐phonon Wannier) package. The EPW package can usually
install directly inside Quantum ESPRESSO by doing "make epw" after
installing Wannier90 by "make w90". Even though the tutorials for
the EPW package are beyond the scope of this book, several tutori‐
als are available at https://docs.epw-code.org/doc/Tutorial.
html. We also recommend that the readers practice with Quantum
ESPRESSO and Wannier90 in Chapter 3 before running the tutorials
for EPW.
262 | Solid‐State Physics for Quantum ESPRESSO

(a) (b)
ℏω′ ℏω
q′ q
ℏω ℏω′′
q q′′
ℏω′′ ℏω′
q′′ q′

Figure 5.9 Phonon‐phonon scattering by cubic term of the anharmonic


potential, (a) phonon‐emission and (b) phonon‐absorption processes. The
energy and momentum before and after the scattering conserve. It is noted
that there is the Umklapp scattering in which the reciprocal lattice vector G
can be added in the momentum after the scattering.

5.11 Phonon‐phonon interaction

A phonon with the angular frequency ω and an energy Eph = h̄ω(n +


1/2) (n = 0, 1, 2, …) is an eigenstate of harmonic Hamiltonian in
which the harmonic potential is given by Kx2 /2, where K is a spring
constant and x is distortion of an atom from x = 0. Further, phonon in
a crystal is given a propagating wave of oscillation as a function of the
wavevector q. For a given q, we have 3N phonon modes in which N is
the number of atoms in the unit cell. All the 3N modes are orthogonal
to one another.
When we consider anharmonic terms of the potential, which is
proportional to x3 or x4 , as a perturbation Hamiltonian, a phonon
state specified by an integer n in Eph = h̄ω(n + 1/2) is no more
eigenstate but has a finite life‐time. When we solve time‐dependent
perturbation theory for the cubic anharmonic potential that is
proportional to x3 , a phonon is scattered into two phonons, or two
phonons are scattered into a phonon by creating or annihilating a
new phonon, respectively. In Fig. 5.9, we show the three phonon
scattering processes for a phonon (a) emitting and (b) absorbing
processes. This phonon scattering occurs by keeping the energy and
momentum of the phonons before and after the scattering. In this
scattering, not only the wavevector q but also the phonon modes are
changed, which we call phonon‐phonon interaction.
When the cubic anharmonic term, x3 is considered, the potential
is not symmetric around the minimum of V(r), rmin , though the
Quantum ESPRESSO Course for Solid‐State Physics | 263
potential minimum still exists at rmin (see Fig. 5.5). As shown in
Fig. 5.5, the averaged position of the oscillation is shifted from x = 0
whose shifted value increases with increasing the amplitude of the
oscillation. This situation corresponds to the phenomena of thermal
expansion (Sec. 5.7).
The x4 term, on the other hand, does not contribute to the
thermal expansion since the potential is symmetric around x = 0
but contributes to the energy transfer from one phonon mode to the
other phonon modes. This situation corresponds to the diffusion of
the phonon and thus is related to thermal conductivity. It is noted
that the x3 term also contributes to the thermal conductivity. Since
the terms of x3 and x4 are given by Taylor expansion around rmin , the
x4 term is generally smaller than the x3 term.
Because of the phonon‐phonon scattering, each phonon mode
with the wavevector q at a temperature, T, has a finite relaxation time
τ j (q, T) and a mean free path by multiply the τ j (q, T) and the group
velocity ∂ω(q)/∂q of the phonon. It is important to note here that
the mean free path we discuss here is not the same as the mean free
path for calculating the thermal conductivity (see Sec. 5.12). In the
thermal equilibrium at T, the probability to find the j‐th phonon with
the energy h̄ωj (q) is given by the Bose‐Einstein distribution function,
nqj , as a function of ωj (q) and T as follows:

1
nqj ≡ , (5.43)
e h̄ωj (q)/kB T −1

since a phonon is a boson. The values of nqj should not be changed


even if we consider the phonon‐phonon scattering by anharmonicity
of the potential because of the detailed valance of the scattering
processes.
The scattering rate for the j‐th phonon at the temperature T,
γ j (q, T), is inversely proportional of τ j (q, T) which is given by the
Fermi golden rule as follows:

1
γ j (q, T) ≡
τ j (q, T)
2
Vqj,q′ j′ ,q′′ j′′  δ(−q + q′ + q′′ + G) (5.44)
π  
h̄ Nq ′ ′′ ′
 (3) 
= 2
q ,q ,j ,j′′
×[(1 + nq′ j′ + nq′′ j′′ )δ(ωqj − ωq′ j′ − ωq′′ j′′ )
+2(nq′ j′ − nq′′ j′′ )δ(ωqj + ωq′ j′ − ωq′′ j′′ )] ,
264 | Solid‐State Physics for Quantum ESPRESSO

where Nq represents the number of q points in the Brillouin zone in


the calculation. Three delta functions corresponds to the momentum
and energy conservation in the phonon‐phonon scattering processes
as shown in Fig. 5.9. Here G denotes the reciprocal lattice vector.
When G = 0 (G ̸= 0), we call normal (the Umklapp) scattering
process. The Umklapp process is important for thermal conductivity
since the normal process does not give a net thermal flow but only
contributes to τ j (q, T). The factors (1 + nq′ j′ + nq′′ j′′ ) and 2(nq′ j′ −
nq′′ j′′ ) in Eq. (5.44) are factors that the scattering rate for Fig. 5.9
(a) and (b), respectively, which is relevant to the nqj before and after
scattering. The derivation of these factors are long, and we do not
discuss the origin more. See, for example, Eq. (6.68) in “The Physics
of Phonons” [Srivastava (1990)]. It is noted that the two terms are
equivalent to more meaningful terms by the identities

(nq′ j′ + 1)nq′′ j′′


nq′ j′ − nq′′ j′′ = ,
nqj (5.45)
nq′ j′ nq′′ j′′
1 + nq′ j′ + nq′′ j′′ = ,
nqj

where we used Eq. (5.43) and the energy conservation. In the


calculation of Eq. (5.44), we used so‐called “single‐mode relaxation‐
time approximation (SMTA)”. In the SMTA, when we consider the
deviation of nqj for the j‐th phonon mode at q from the thermal
equilibrium, we assume that the other phonon‐modes are in the
thermal equilibrium.
Since the phonon has a finite lifetime, the uncertainty principle
(ΔEΔt ≥ h̄) tells us that the phonon energy can not be determined
precisely. In fact, h̄γ j (q, T) corresponds an energy width of the
energy dispersion of the j‐th phonon modes. When the width is
large, it means that the phonon has a short lifetime, and thus we
can see h̄γ j (q, T) in the spectral width of the j‐th phonon at q
in the neutron scattering measurement of Raman spectra. This is
important for us to discuss the resonant conditions of the scattering
event. In Quantum ESPRESSO, the linewidth of the phonon energy
dispersion is calculated by d3.x. However, since version 6.0 of
Quantum ESPRESSO, the d3.x code has been superseded by the D3Q
code (https://anharmonic.github.io/d3q/). Please be aware
that each release of the D3Q code is developed and tested on top
Quantum ESPRESSO Course for Solid‐State Physics | 265
of a specific version of Quantum ESPRESSO, and it will probably not
work on any other version. Therefore, the readers should choose the
correct package.
It is noted that there are other origins of phonon scattering
besides anharmonicity. For example, isotope or lattice defect breaks
the periodicity of the lattice, which makes the phonon scattering. In
the case of carbon, 1.1% of carbon is 13 C isotope. When a phonon
propagates in two‐dimension, a phonon meets a 13 C in 10 × 10 unit
cells which can not be negligible. Electron‐phonon interaction is
another origin for phonon scattering indirectly in which a phonon is
absorbed to or emitted from an electron, which gives a finite lifetime
of the phonon.

5.12 Heat conduction in a solid

When there are hot and cold points in material, heat flows from the
hot to the cold points. The heat flux J in units of W/m2 at a point is
proportional to the gradient of temperature ∇T, (K/m), that is,

J = −κ∇T, < (5.46)

which is called the Fourier law, and the coefficient κ > 0 is called
thermal conductivity (W/m/K). In Quantum ESPRESSO, we can
calculate the thermal conductivity by Thermal2 code (https://
anharmonic.github.io/thermal2/), which comes bundled with
the D3Q code. Both Thermal2 and D3Q codes can usually install
directly inside Quantum ESPRESSO by doing "make d3q". The
thermal conductivity κ becomes large when the amplitude of the
oscillation is large compared with a few % of the bond length.
Diamond and carbon nanotubes are known to be materials with a
large thermal conductivity since (1) the mass of carbon atoms is
relatively small for a given spring constant and (2) the anharmonicity
of the potential is large compared with other materials. It is noted
here that the thermal conductivity of metal is generally large, too,
because phonons are interacted by electron‐phonons interactions.
Thus, the phonon scattering process is relevant to the thermal
conductivity.
266 | Solid‐State Physics for Quantum ESPRESSO

When we use the equation of continuity, temporal change of a


heat Q at r is given by

dQ
(5.47)
dt
= −divJ,

where Q (J/m3 ) per unit volume is expressed by the density ρ


(kg/m3 ) and the specific heat C (J/kg/K) as follows:

Q = ρCT. (5.48)

When we assume that ρ and C are constants for a given material,


we put Eqs. (5.48) and (5.46) to Eqs. (5.47) and obtain the following
equation:

dQ dT
(5.49)
dt dt
= ρC = −divJ = κΔT.

Eq. (5.49) is a diffusion equation for T, which we call the heat


equation. The value of κ/(ρC) (m2 /s) is called the thermal
diffusivity.
Temperature of the lattice in thermal equilibrium is defined by
the Bose‐Einstein distribution function, nqj (Eq. (5.43)). Using the
Boltzmann transport theory, the diffusive thermal conductivity κ is
expressed by [Saito et al. (2018)]

h̄2  2
ω τ j (q, T)nqj (nqj + 1)|vqj |2 . (5.50)
2VkB T2 qj qj
κ=

where V denotes the volume of material, τ j (q, T) is defined by


Eq. (5.44), and vqj represents the group velocity of the phonon (vqj =
∇q ωqj ). In Eq. (5.50), we can define the specific heat per volume of
the lattice for the j‐th phonon at q and the specific heat C as follows:

h̄2 V 
Cvqj = ω2 nqj (nqj + 1), C= Cvqj . (5.51)
VkB T2 qj 2N qj

In Thermal2 code, we can select as an option either (1) single‐


mode approximation (SMA) or (2) full consideration by “conjugate
gradient algorithm with precoding” (CGP) [Atkinson (1988)]. It is
Quantum ESPRESSO Course for Solid‐State Physics | 267
natural that it takes more computational time if we adopt (2). The
product of the group velocity and the relaxation time corresponds
to the phonon mean free path. When the sample size, L, is smaller
than the phonon mean free path, thermal conductivity by the phonon
becomes “ballistic” in which the phonon with a positive velocity
directly contributes to the thermal conductivity as follows:

κ ball = L Cvqj vqjx θ(vqjx ), (5.52)




qj

where θ is the Heaviside function. When part of phonon modes


becomes ballistic, the diffusive thermal conductivity can not be
used. Further, we must consider the thermal resistivity by isotope
scattering [Saito et al. (2018)] and by electron‐phonon interaction if
we want to compare the calculated results with the experimental
results.
When we decrease the temperature, the thermal conductivity
increases monotonically up to the maximum and then becomes zero
since the specific heat becomes zero at T = 0 K. It is not generally
easy to calculate thermal conductivity by first‐principles calculation
at low temperatures since the mean free path becomes long
compared with the size of the computation. Fitting the anharmonicity
to the anharmonic results of Quantum ESPRESSO, the tight‐binding
method for thermal conductivity is a possible way to calculate
thermal conductivity at low temperature [Saito et al. (2018)].
We note that the D3Q and Thermal2 codes are beyond the scope
of this book. The readers can find the tutorials for graphene and
silicon at https://anharmonic.github.io/. We recommended the
readers to practice the phonon tutorials in Sec. 3.3 before running the
tutorials of the D3Q and Thermal2 codes.

5.13 Non‐resonant Raman scattering

Raman scattering is the inelastic scattering of light, in which energy


of the incident light is partially consumed for exciting a phonon.22

22 Any other elementary excitations such as a magnon can be an origin of Raman

scattering.
268 | Solid‐State Physics for Quantum ESPRESSO

The energy difference between the incident light and the scattered
light is called the Raman shift, whose unit is cm−1 (1 eV = 8065
cm−1 ). In the experiment, they observe the intensity of the scattered
light as a function of the Raman shift, which is called Raman spectra.
The peak positions of Raman spectra correspond to the phonon
modes, which are Raman active modes. The Raman active modes
are defined by the optical phonon modes in which the photo‐excited
electron emits a phonon by the electron‐phonon interaction. The
Raman active modes have the symmetry of quadratic form of x,
y, z such as x2 + y2 , x2 − y2 , xz, etc. The quadratic function for
each phonon mode is obtained as functions for the irreducible
representation in the character table of point group for the unit cell
if we know the information of the irreducible representation of the
phonon mode in the point group.23
In Quantum ESPRESSO, we can calculate the so‐called non‐
resonant Raman spectra to obtain the phonon mode’s frequency
and symmetry and the relative intensity in the Raman spectra,
which we call density‐functional perturbation theory (DFPT).
The non‐resonant Raman intensities are calculated within the
DFPT [Lazzeri and Mauri (2003)] as

nν + 1
I(ν) ∝ |⃗es · R(ν) · ⃗ei | , (5.53)
2
ων

in which ⃗ei (⃗es ) is the polarization vector of incident (scattered)


light. Here the polarization vector is defined by a unit vector of
the direction of electric field of the incident (or scattered) light. nν
(= eh̄ωv /k1B T −1 ) is the occupation number of ν th phonon at temperature
T. R(ν) is so‐called Raman tensor (a 3 × 3 matrix) for the ν‐th phonon
mode which connects the polarization vectors, ⃗ei and ⃗es . Depending
on the symmetry of the phonon mode, Raman tensor does have non‐
zero matrix element. For example, the group theory tells us that the
degenerate E2g phonon modes with x2 − y2 and xy symmetry have

23 Number of the Raman active modes and their irreducible representation are

obtained by decomposing the reducible character of “atomic site character” ×


“irreducible representations of x, y, z” into irreducible representations
[Dresselhaus et al. (2008)].
Quantum ESPRESSO Course for Solid‐State Physics | 269
the following shapes

a 0 0 0b0
   

R(E2g : x2 − y2 ) =  0 −a 0  , R(E2g : xy) =  b 0 0  , (5.54)


0 0 0 000

respectively, where a and b are non‐zero constants at xx (yy) and


xy (yx) components, which are calculated by Quantum ESPRESSO.
The matrix elements of non‐resonant Raman tensor are calculated by
DFPT in Quantum ESPRESSO by differentiating the electric energy,
Eel , with electric field components, ⃗Eα or ⃗Eβ (α, β = x, y, z), and the
lattice deformation of a phonon as follows:

∂3 Eel uν
Rαβ (ν) = √ ζδ , (5.55)

∂Eα ∂Eβ ∂rζδ Mδ
ζδ

where Mδ the mass of the δth atom, rζδ the position of the δth atom
along the direction ζ (ζ = x, y, z), and uζδ the atomic displacement of
the δth atom along the ζ direction for the eigenmode ν.
For the calculated Raman tensor and polarization vectors, we
can calculate the relative Raman intensities by |⃗es · R(ν) · ⃗ei | in
2

Eq. (5.53). For example, when the polarization of the incident light
lies in the x direction, ⃗ei =t (1, 0, 0), we get a non‐zero intensity for
the x or y polarizations of the scattered light ⃗es = ex ≡t (1, 0, 0), or
⃗es = ey ≡t (0, 1, 0) for R(E2g : x2 − y2 ) or R(E2g : xy), respectively, as
follows:

a 0 0 1
  
t
ex R(E2g : x2 − y2 )ex = (1, 0, 0)  0 −a 0   0  = a, (5.56)
0 0 0 0

or

0b0 1
  
t
ey R(E2g : xy)ex = (0, 1, 0)  b 0 0   0  = b. (5.57)
000 0

From the calculated phonon dispersion relation as a function


of q, we obtain the Raman shift frequency of each phonon at the
optical phonon frequency at the Γ point in the Brillouin zone, which
270 | Solid‐State Physics for Quantum ESPRESSO

is called zone‐center phonon mode. The reason why only the Γ point
phonon is observed in the first‐order Raman spectra is understood
by the three Raman sub‐processes: (1) optical absorption of an
electron with the wavevector k in which the electron can excite
almost “vertically” in the k space, (2) the photo‐excited electron can
emit a phonon with a phonon wavevector q, and (3) the scattered
electron is recombined with a hole at the original k. In order for the
scattered electron to recombine with a hole, the phonon wavevector
should be q = 0.
If we can not find the corresponding phonon frequency in
the observed Raman spectra, the Raman spectra might be two‐
phonon Raman spectra whose frequency is the sum of two‐phonons.
In the two‐phonon Raman scattering, the restriction of q = 0 in
the case of one‐phonon scattering is relaxed, and a pair of q ̸= 0
and −q can be possible for the wavevectors of the emitted two
phonons, which enables the photo‐excited electron to recombine
with the hole. Thus we expect that the two phonon spectra are
generally broad and weak. When two of the three intermediate states
are resonant to the electronic states, the Raman intensity of the
two‐phonon Raman scattering becomes comparable or even larger
than the intensity of one‐phonon Raman scattering. This situation
is called “double‐resonance Raman scattering” [Saito et al. (2002b),
Saito et al. (2003), Saito et al. (2002a)]. The double resonance Ra‐
man occurs, too, when one of the two scattering processes with
q and −q is an elastic scattering of a photo‐excited electron by
impurity. One famous example of defect‐oriented, double reso‐
nance Raman spectra is the D‐band of graphite at 1350 cm−1
[Pimenta et al. (2007)] in which iTO phonon mode at the K point is
relevant to the Raman spectra. The two‐phonon Raman spectra of the
iTO phonon mode at the K point appear at 2700 cm−1 which we call
G′ band (or 2D band). It is noted that the G′ band is an intrinsic Raman
spectra of graphite without any defects.
When the intermediate state of the photo‐excited electrons
is a real electronic state, the Raman intensity is enhanced sig‐
nificantly compared with non‐resonant Raman spectra, which we
call resonant Raman spectra. In order to calculate the resonant
Raman intensity by first‐principles calculation, we need to calculate
electron‐phonon and electron‐photon matrix elements. See detail in
the references [Tatsumi and Saito (2018), Tatsumi et al. (2018)].
Quantum ESPRESSO Course for Solid‐State Physics | 271
5.14 Warnier functions

Wannier functions (WFs) [Wannier (1937)] are Fourier‐transformed


Bloch functions of DFT calculation into a smaller set that is localized
in real space. While the Bloch function is oscillating and delocalized
in the real spaces, as shown in Fig 5.10 (a), the WFs that are
localized in the real space offer more microscopic insights for the
chemical and physical properties. In particular, the WFs are useful
for analyzing chemical bonding, building accurate tight‐binding
models, or calculating the material properties that require a dense
integration in the Brillouin zone.
Let us start with the Bloch states of energy band n, ψnk (r), in
terms of a Fourier series of R as

eik·R wnR (r), (5.58)



ψnk (r) =
R

where R is a lattice vector labeling a unit cell within a supercell


that is conjugate to the k‐points grid. Here, wnR (r) is the WF that
is localized at each atomic position of R, as shown in Fig. 5.10
(b). The Bloch functions of the 1D system can be plotted for k =
0, k1 and k2 in Fig. 5.10 (a). In the case of k ̸= 0, we can see
that the amplitude of ψnk (r) is oscillating with k1 (or k2 ). The
inverse Fourier transformations of ψnk (r) on k for a given R gives a
WF [Wannier (1937)]:

1  −ik·R
wnR (r) = e (5.59)
Nk
ψnk (r),
k

where Nk is the number of k points. The set of the WFs forms an


orthogonal and complete basis set, respectively, as

w∗nR (r)wn′ R′ (r)dr = δ(R − R′ )δnn′ ,



(5.60)

and

w∗nR (r)wnR (r′ ) = δ(r − r′ ). (5.61)




nR
272 | Solid‐State Physics for Quantum ESPRESSO

(a) Bloch functions e ik⋅r (b) Wannier functions


wnR
0
ψnk WF’s spread
k1

k2
0 R1 R2
Unit cell

Figure 5.10 (a) The Bloch functions ψnk (r) of a single band n in 1D system for
three different values of the wave vector k. (b) The Wannier functions wnR (r)
for the same band n for the three different values of the lattice vector R.

According to the Bloch theorem [Kittel (1976)], ψnk (r) is


expressed by

ψnk (r) = eik·r unk (r), (5.62)

where unk (r) is a periodic function (unk (r) = unk (r − R)). By substi‐
tuting Eq. (5.62) into Eq. (5.59), we obtain:

1  ik(r−R)
wnR (r) = e unk (r)
Nk
k

1  (5.63)
ψnk (r − R)
Nk
=
k

= wn,0 (r − R).

Therefore, wnR (r) has the same periodicity as the atomic structure of
the crystal, as shown in Fig. 5.10 (b).
It is important to note that the WFs are not unique because the
Bloch functions are not unique. For each ψnk (r), we can obtain the
same electron density by multiplying a different phase α in front of
the Bloch function (i.e., eiα ψnk (r)). However, by choosing a different
phase of the Bloch functions, we get new Wannier functions that
may exhibit very different shapes in real space. When we consider
Ne energy bands, Ne Bloch functions at a given k can be rotated by
Quantum ESPRESSO Course for Solid‐State Physics | 273
the unitary operator as

Ne
Ukmn ψmk (r), (5.64)

ψnk (r) =
m=1

where Ukmn is an Ne × Ne unitary matrix at each k. Then the WFs in


Eq. (5.59) can be rewritten as
 N
1  −ik·R 

e

wnR (r) = e Umn ψmk (r) .


k
(5.65)
Nk
k m=1

For Eq. (5.65), the question is how to choose Ukmn to obtain a


maximally‐localized WF in real space.

5.14.1 Maximally‐localized Warnier functions

Among several methods, maximally‑localized Wannier functions


(MLWFs) [Marzari and Vanderbilt (1997)] are an effective method
for minimizing the mean‐square spread of the WFs, Ω, to choose
Umn . The MLWFs are employed in Quantum ESPRESSO by Wannier90
(k)

package. Ω is defined as [Marzari and Vanderbilt (1997)]

Ne Ne
⟨(r − r̄n )2 ⟩n = ⟨r ⟩n − r̄2n , (5.66)
     2 
Ω=
n=1 n=1

where r̄n and ⟨r2 ⟩n are the center and the second moment of the
average for WF at R = 0 that are defined by

r̄n = ⟨wn,0 |r|wn,0 ⟩ and ⟨r2 ⟩n = ⟨wn,0 |r2 |wn,0 ⟩. (5.67)

For the 1D system, the spread of the WFs is shown in Fig. 5.10 (b).
Since wn,0 is a function of Ukmn (see Eq. (5.65)), Ω is a functional
of Ukmn . Thus, it allows us to minimize the spread Ω by variation
of these unitary matrices. To perform this minimization, steepest‐
descent or conjugate‐gradient algorithms can be applied if dΩ/dUkmn
is known [Marzari et al. (2012b)].
274 | Solid‐State Physics for Quantum ESPRESSO

5.14.2 Spread of the Wannier functions

As shown by Blount [Blount (1962)], the center of the WFs can be


expressed in terms of the Bloch states as

1   ∂
   
r̄n = ⟨wn,0 |r|wn,0 ⟩ = unk i  unk . (5.68)
Nk ∂k
k

Thus, the second moment of the WFs can also be expressed as

1  ∂ 2
    
⟨r2 ⟩n = ⟨wn,0 |r2 |wn,0 ⟩ = − unk  u . (5.69)

Nk  ∂k  nk
 
k

In a numerical approach, we can use the finite‐difference


expressions for ∂/∂k and (∂/∂k)2 [Marzari and Vanderbilt (1997)] in
Eqs. (5.68) and (5.69), respectively, and we get:

i 
r̄n = wb b[⟨unk |un,k+b ⟩ − 1], (5.70)
Nk
k,b

and
1 
⟨r2 ⟩n = wb [2 − 2Re⟨unk |un,k+b ⟩], (5.71)
Nk
k,b

where b denotes the vectors connecting the points k to neighboring


points k + b, and wb denotes the associated weights that come from
the finite difference representation.
Let us define an overlap matrix element Mk,b
mn as

Mk,b
mn = ⟨umk |un,k+b ⟩. (5.72)

It is proved that Mk,b


mn satisfies the following
conditions [Marzari and Vanderbilt (1997)]:

nn − 1 = iIm ln Mnn ,
Mk,b k,b
(5.73)
 

and

nn = 1 − Mnn
 + Im ln Mk,b
 k,b 2   2
2 − 2ReMk,b  nn . (5.74)
Quantum ESPRESSO Course for Solid‐State Physics | 275
By substituting Eqs. (5.73) and (5.74) into Eqs. (5.70) and (5.71), we
obtain:

1 
r̄n = − wb bIm ln Mk,b
nn , (5.75)
 
Nk
k,b

and

1 
wb 1 − Mk,b M
2   k,b 2
. (5.76)
  
⟨r2 ⟩n =

Nk nn nn
 + Im ln
k,b

From Eqs. (5.66), (5.75), and (5.76), we can see that the spread
Ω with respect to the unitary matrix Ukmn can be expressed as a
mn . Therefore, Mmn is needed
function of the overlap matrix element Mk,b k,b

to minimize the spread Ω to obtain the optimized choice of Ukmn . On


the other hand, the iterative minimization of Ω will starts with an
initial guess orbitals as

1  k
|w̃n,0 ⟩ = Amn |ψmk ⟩, (5.77)
Nk
mk

where Akmn is projected matrix element, which is defined by

Akmn = ⟨ψmk |gn ⟩, (5.78)

where gn are projections such as s, p, or hybrids. In Quantum


ESPRESSO, Mk,bmn and Amn are calculated from pw2wannier90.x after
k

the Bloch states calculated by pw.x.

5.14.3 Tight‐binding model and Wannier interpolation

The unique set of the MLWFs constitutes an orthogonal and complete


basis, which enables us to use these orbitals for setting up the
effective model Hamiltonian in real space for the tight‐binding
model as

tnn′ (R, R′ )|wnR ⟩⟨wn′ R′ |, (5.79)



H=
RR′ nn′
276 | Solid‐State Physics for Quantum ESPRESSO

where tnn′ (R, R′ ) are the hopping parameters that depend on only the
distance vector connecting the MLWFs as

tnn′ (R, R′ ) = ⟨wnR |H|wn′ R′ ⟩


= ⟨wn,0 |H|wn′ ,R′ −R ⟩ (5.80)
= tnn′ (R′ − R).

Using a Fourier transformation of H in the basis of the MLWFs,


we can obtain H in momentum space as

eiq·R tnn′ (R)



Hnn′ (q) =
R
(5.81)
1  −ik·R  k †
 
e iq·R
e (U ) ϵ(k)Uk nn′ ,
 
Nk
=
R k

where ϵ(k) are the Kohn‐Sham eigenvalues by given a k‐grid in


the DFT calculation. By diagonalizing the tight‐binding Hamiltonian
Hnn′ (q) in Eq. (5.81), we can obtain the energy dispersion, ϵ(q), in
which q‐grid can be much denser than k‐grid. This calculation is
known as the Wannier interpolation, which is useful to calculate
transport properties (e.g., electrical conductivity) that require a
dense k‐grid in the Brillouin zone.
Chapter 6

Productivity Tools

In practical use of first‐principles calculation software, we will


need to manage and visualize our data in an attractive manner.
Furthermore, when we research some unknown materials, we have
to know the starting point for generating the Quantum ESPRESSO
input files. In most cases, we should repeat similar procedures
to check the consistency of the first‐principles calculations. Such
situations require us to supplement our skills of using Quantum
ESPRESSO with other utilities. In particular, understanding the way
of plotting figures and using a few Linux commands along with
basic shell‐scripting will be useful for us to be more productive
when performing research. In this chapter, we will learn these extra
tools, from the preparation of our own Quantum ESPRESSO files,
some useful Linux commands/scripts, plotting with Matplotlib in the
Python environment, to additional packages online.

6.1 Quantum ESPRESSO input generators

Recent advances in artificial intelligence and machine learning have


allowed us to obtain pre‐defined input files for Quantum ESPRESSO
calculations from input generator tools available online. Two out‐

Quantum ESPRESSO Course for Solid‐State Physics


Nguyen Tuan Hung, Ahmad R. T. Nugraha, and Riichiro Saito
Copyright © 2023 Jenny Stanford Publishing Pte. Ltd.
ISBN 978‐981‐4968‐37‐9 (Hardcover), 978‐981‐4968‐63‐8 (Paperback), 978‐1‐003‐29096‐4 (eBook)
www.jennystanford.com
278 | Productivity Tools

standing examples are AFLOW (aflowlib.org) and MaterialsCloud


(materialscloud.org). We can generate Quantum ESPRESSO input
files based on the information provided in those websites for a
particular material. The two websites also provide us with the
structure visualization tools that can be used to confirm the structure
of the material under study and to select the possible k‐path for the
band structure plot, which is helpful to accelerate our work.
As an example of this section, we will learn how to make
the Quantum ESPRESSO input files for bulk germanium telluride
(GeTe) so that we can obtain its density of states (DOS) and energy
dispersion. The input files will be named as follows:

1. gete.scf.in for the SCF calculation.


2. gete.nscfdos.in for the NSCF DOS calculation.
3. gete.dos.in for post‐processing the DOS data.
4. gete.nscfbands.in for the energy dispersion calculation.
5. gete.bands.in for post‐processing the dispersion data.

Let us see how we can make all the input files.

6.1.1 Obtaining a structural CIF file from AFLOW

The first step to creating the Quantum ESPRESSO input files is


obtaining a structure definition for the material that we are studying.
We will use AFLOW to get the structure information that will define
the material in all Quantum ESPRESSO input files. We can click the
address of the AFLOW website (aflowlib.org) in the web browser,
and we will see its front page as shown in Fig. 6.1. There are several
menus available in the top panel of the website. What we need is the
Search menu, highlighted by the box on the top right of Fig. 6.1.
After clicking the Search menu, we can see the search page as
shown in Fig. 6.2. We highlight four steps in the case of specifying
GeTe for obtaining its structural information:

1. Click atom Ge.


2. Click atom Te.
3. Make sure “Ge, Te” appear in the search box.
Quantum ESPRESSO Course for Solid‐State Physics | 279

Figure 6.1 The front page of the AFLOW website.

Figure 6.2 AFLOW search page with some highlighted steps for obtaining the
GeTe information. (1) Push Ge, (2) push Te and then we get Ge, Te in (3) and
we select “2” for the number of species.

4. Set the number of species to “2” because we want to focus on


finding compounds that strictly consist of Ge and Te atoms only,
without other atoms.

It is also possible to skip Steps 1–2 and jump directly to Step 3 by


manually writing “Ge, Te” in the search box.
After specifying the Ge and Te atoms on the AFLOW search page,
as shown in Fig. 6.2, we can click the Search button beside the
search box to let AFLOW find all relevant information about GeTe
compounds. A screenshot of the search results is shown in Fig. 6.3. At
the time of writing this book, there are 29 entries found related to our
280 | Productivity Tools

Figure 6.3 Sample search results for GeTe. We click the first entry to get the
information of bulk GeTe in its cubic phase with the Fm3̄m (#225) space
group.

specified “Ge, Te” keyword. The different entries mean that various
structures and parameters for the GeTe calculations are reported to
be explored.
For example, in the “space group” column, we can find Fm3̄m
(#225) and R3m (#160) groups that correspond to the cubic and
rhombohedral lattice systems, respectively, as shown in the first and
the second rows of Fig. 6.3. The same space groups may appear
several times, indicating the other details of the parameters used in
the structures. Here we take the first row of the search results as
our example and click the corresponding GeTe entry as highlighted
in Fig. 6.3. This GeTe entry gives information about the bulk GeTe in
its cubic phase.
By opening the page after clicking the first entry of GeTe, we
will see several structural details and physical properties of the
bulk cubic GeTe. The first information available on that page is the
structure visualization. The screenshot is given in Fig. 6.4, from
which we can obtain the crystallographic information file (CIF) of the
material. It is recommended to set the relaxed structure as calculated
in AFLOW by clicking the corresponding button indicated by number
1 in Fig. 6.4. Then, we can save it in the CIF format by clicking the
button number 2 in Fig. 6.4. We may save it as any filename we like.
In this example, we use the default one given by AFLOW:
Quantum ESPRESSO Course for Solid‐State Physics | 281

Figure 6.4 Structure visualization of bulk cubic GeTe in AFLOW. Button 1


should be clicked to set the relaxed structure as calculated originally in
AFLOW. Button 2 is to save as the CIF format.

Ge1Te1_ICSD_638014.cif

Note that AFLOW, in this case, already gives us the relaxed geometry
of GeTe. If we are not satisfied with the relaxed structure, we may
repeat the structural optimization process in Quantum ESPRESSO by
following the related hands‐on in Sec. 3.1.5. However, for simplicity,
in this chapter, we will not do such a process again. Instead, we rely
on the relaxed structure given by AFLOW.

6.1.2 Generating SCF input file from MaterialsCloud

On the same AFLOW page of Fig. 6.4 below the structure visual‐
ization, we can explore physical properties such as thermodynamic,
magnetic, and electronic properties calculated by AFLOW. When
we further scroll down the page, there are also AFLOW calculation
282 | Productivity Tools

Figure 6.5 The default view of Quantum ESPRESSO input generator and
structure visualizer in MaterialsCloud (materialscloud.org).

details such as cutoff energy, k‐point grid, and pseudopotential


version used for the material under investigation, but all the results
are given there are not calculated by using Quantum ESPRESSO.
Therefore, we turn to the other website, i.e., MaterialsCloud, for
obtaining the Quantum ESPRESSO inputs. The relevant tool for
generating the SCF input file in MaterialsCloud can be accessed
at the following address: https://materialscloud.org/work/
tools/qeinputgenerator. The web address written above may
change in the future depending on the MaterialsCloud developers.
However, we should be able to access it from the main page of
MaterialsCloud through the following order of menus: Work →
Tools → Quantum ESPRESSO input generator and structure
visualizer. The default view of this tool is shown in Fig. 6.5
What we need now is only a structure file, which has been
obtained for the GeTe example as explained in Sec. 6.1.1 in the CIF
format. Provided the CIF file, we can do the following steps:

1. Click the Browse button in the Quantum ESPRESSO input


generator on the MaterialsCloud website as shown in Fig. 6.5
and find the CIF file that we want to calculate.
2. Select the CIF file format in MaterialsCloud (either by ASE or
pymatgen parser is fine; do not use the qetools parser).
Quantum ESPRESSO Course for Solid‐State Physics | 283
3. Choose the PBE or PBEsol SSSP pseudopotential libraries.
For each library, there are two versions: (i) a more accurate
one, called “Precision” and (ii) a general‐purpose one, called
“Efficiency”. Later, we may change the pseudopotential files
manually if we do not want to use those recommended by
MaterialsCloud.
4. Decide if we want to treat our system as (i) a non‐magnetic
metal (i.e., using smearing/fractional occupations), (ii) as a
non‐magnetic insulator (i.e., using fixed occupations equal to
2), or (iii) as a magnetic system (in this case, it is safer to use
smearing/fractional occupations). When we are not sure about
the metallicity and magnetism, just leave them and choose the
default.
5. Decide the density of the k‐points sampling. The default value
is 0.2 Å−1 , which is a conservative, all‐purpose choice. We call
this “fine” sampling, and the appropriate smearing (“degauss”)
value is 0.2 eV. The two other options are “very fine” sampling
(0.15 Å−1 , 0.1 eV), and “normal” (0.3 Å−1 , 0.3 eV). Note that
we change the “degauss” parameter since a coarser sampling
benefits from more smearing. See Sec. 3.1.1 for the other details
about the smearing parameter.
6. Finally, we can choose whether or not we want to refine the cell.
Normally we do not need to do it, so we can directly click the
“Generate” button.

In the above steps, beware that there is no point in sampling


the Brillouin Zone in a direction where there should not be any
dispersion, i.e., in the case of a 0D, 1D, or 2D system in which 3, 2,
or 1 direction(s) should not be sampled, we should update the input
file manually. We may also want to use a shifted Monkhorst‐Pack
mesh instead of the unshifted one by changing 0 0 0 to 1 1 1 in the
last three numbers of the k‐point entry from the input file generated
by Materials Cloud (c.f. Sec. 3.1.3). All these manual modifications
can be done after we obtain the PWscf input file generated by the
MaterialsCloud tool.
For the GeTe example, we show our selected options as
highlighted in Fig. 6.6. We mostly select the default options, except
the file format, which is CIF, and the magnetism, which we select as
284 | Productivity Tools

Figure 6.6 Options selected to generate the SCF input file for the bulk cubic
GeTe in MaterialsCloud.

Figure 6.7 Downloading the SCF input file generated by MaterialsCloud.

“non‐magnetic insulator” because we already expect GeTe to have


a band gap. After we click the “Generate” button, we will see the
resulting SCF input file given by MaterialsCloud. Note that it may take
a few seconds until we can see the input file fully. It is recommended
to download the SCF input file along with the pseudopotentials that
are zipped in a file called PWscf.zip. We can click the download
button as shown in Fig. 6.7. It is recommended to save the zip file
under the QE-SSP folder following all the examples in this book.
The zipped file can be unzipped in the Linux terminal by the
following command:

$ unzip PWscf.zip

After unzipping the file, we will see that there is a folder named
PWscf containing a PWscf.in file and a pseudo directory with the
suggested pseudopotential files from MaterialsCloud. To match with
the material’s name (GeTe), it is better if we rename the folder and
the SCF input file by the following set of command lines:

$ mv PWscf gete
$ cd gete
$ mv PWscf.in gete.scf.in
Quantum ESPRESSO Course for Solid‐State Physics | 285
The first line means that we change the name of the PWscf folder
to gete. The second line is to enter the gete folder (which was
previously named PWscf). In this folder, by using the third command
line, we rename one more file, i.e., PWscf.in to gete.scf.in. Now
we can see the contents of gete.scf.in by either opening it with a
text editor or by typing the cat command in the terminal:

$ cat gete.scf.in

QE‑SSP/gete/gete.scf.in

1 & CONTROL
2 calculation = 'scf '
3 outdir = './out/'
4 prefix = 'gete ' # originally 'aiida '
5 pseudo_dir = './ pseudo/'
6 verbosity = 'high '
7 /
8 &SYSTEM
9 ecutrho = 3.2000000000d+02
10 ecutwfc = 4.0000000000d+01
11 ibrav = 0
12 nat = 2
13 ntyp = 2
14 /
15 & ELECTRONS
16 conv_thr = 4.0000000000d-10
17 mixing_beta = 4.0000000000d-01
18 /
19 ATOMIC_SPECIES
20 Ge 72.64 ge_pbesol_v1 .4. uspp.F.UPF
21 Te 127.6 te_pbesol_v1.uspp.F.UPF
22 ATOMIC_POSITIONS crystal
23 Ge 0.0000000000 0.0000000000 0.0000000000
24 Te 0.5000000000 0.5000000000 0.5000000000
25 CELL_PARAMETERS angstrom
26 4.2603675143 0.0000000000 0.0000000000
27 2.1301837572 3.6895864968 0.0000000000
28 2.1301837572 1.2298621656 3.4785755089
29 K_POINTS automatic
30 13 13 13 1 1 1 # originally 10 10 10 0 0 0

Note in gete.scf.in above, we need to change the prefix


variable, which originally read ‘aiida’ in the MaterialsCloud
input generator, to gete in our computer (at line 4). We also
286 | Productivity Tools

use slightly denser k‐points and shifted Monkhorst‐Pack mesh


(13 13 13 1 1 1) and remove some variables, such as
etot_conv_thr, force_conv_thr, tprnfor, tstress, nosym,
electron_maxstep, and occupations, which are too detailed to be
specified in the SCF file. In the next section, for the DOS calculation,
we will need to set the occupations variable back in the NSCF
(non‐SCF) input file.

6.1.3 Preparing DOS and band structure inputs

Next, let us prepare the input files for DOS and band structure
calculations from the information already available in the previous
subsection combined with the new information we will gather here.
In the following example, we use gete.scf.in as the starting
point for the DOS and band structure calculations, which are both
categorized as the NSCF calculations. We can copy the SCF input file
to make new input files for the NSCF calculations of DOS and band
structure:

$ cp gete.scf.in gete.nscfdos.in
$ cp gete.scf.in gete.nscfbands.in

Then, we should edit gete.nscfdos.in and gete.nscfbands.in


according to our needs.

DOS input files


As explained in Sec. 3.2.3, the main differences between the SCF
and NSCF inputs for the DOS calculation are the appearance of
occupations parameter (= 'tetrahedra_opt') and setting much
denser k‐points mesh in the NSCF input file. In this GeTe example, we
set the number of k‐points twice larger than that in the SCF input file
(line 28). It is also recommended to make the nbnd parameter same
as in the NSCF input for the band structure calculation. The input file
for the DOS calculation is shown as below:

QE‑SSP/gete/gete.nscfdos.in

1 & CONTROL
2 calculation = 'nscf '
Quantum ESPRESSO Course for Solid‐State Physics | 287
3 outdir = './out/'
4 prefix = 'gete '
5 pseudo_dir = './ pseudo/'
6 verbosity = 'high '
7 /
8 &SYSTEM
9 ecutrho = 3.2000000000d+02
10 ecutwfc = 4.0000000000d+01
11 ibrav = 0
12 nat = 2
13 ntyp = 2
14 nbnd = 30 # same as in *. nscfbands.in
15 occupations = 'tetrahedra_opt ' # only for DOS
16 /
17 & ELECTRONS
18 conv_thr = 4.0000000000d-10
19 mixing_beta = 4.0000000000d-01
20 /
21 ATOMIC_SPECIES
22 Ge 72.64 ge_pbesol_v1 .4. uspp.F.UPF
23 Te 127.6 te_pbesol_v1.uspp.F.UPF
24 ATOMIC_POSITIONS crystal
25 Ge 0.0000000000 0.0000000000 0.0000000000
26 Te 0.5000000000 0.5000000000 0.5000000000
27 K_POINTS automatic
28 26 26 26 1 1 1 # twice the SCF 's case
29 CELL_PARAMETERS angstrom
30 4.2603675143 0.0000000000 0.0000000000
31 2.1301837572 3.6895864968 0.0000000000
32 2.1301837572 1.2298621656 3.4785755089

Besides gete.nscfdos.in, we should create a post‐processing


input file to gather the DOS data. In this case, we do not have to copy
the SCF input file, just make a new file with a few lines of information
for the DOS post‐process using the &DOS namelist. The specifications
of outdir (line 2) and prefix (line 3) should be consistent with
the *.nscfdos.in file. We also add parameters emin and emax in eV
(lines 5 and 6) in the following DOS post‐processing file:

QE‑SSP/gete/gete.dos.in

1 &DOS
2 outdir = './out/'
3 prefix = 'gete '
4 fildos = 'gete.dos '
5 emin = -5
288 | Productivity Tools

Figure 6.8 Obtaining the k‐path and high‐symmetry points of bulk cubic GeTe
in MaterialsCloud.

6 emax = 25
7 /

Band structure input file


The most important point when creating the band input file is
the k‐path for plotting the energy dispersion. MaterialsCloud has
an additional tool called “SeeK‐path” that can accept a CIF format,
which is used for finding and visualizing a possible k‐path, as
shown in Fig. 6.8. The SeeK‐path tool will show the coordinates
of the high‐symmetry points that we can copy to the band input
file. The SeeK‐path tool can be accessed at the following address:
https://materialscloud.org/work/tools/seekpath or through
the following order of MaterialsCloud menus: Work → Tools →
SeeK-path: the k-path finder and visualizer.
In Fig. 6.8, we show how to obtain the k‐path and high‐symmetry
points of bulk cubic GeTe in MaterialsCloud. We only need to
browse/upload the CIF file of GeTe obtained earlier (from Sec. 6.1.1)
and specify, for example, the ase parser for the CIF format. After
pressing the button to “Calculate my structure” in the SeeK‐path tool,
we will be able to see the high‐symmetry points of bulk cubic GeTe,
as shown in Fig. 6.9.
Now suppose that we want to calculate and plot the energy dis‐
persion along the path of W–L–U–X–Γ–K high‐symmetry points. We
just need to change the automatic K_points setup into crystal_b
in the gete.nscfbands.in file and list all the corresponding high‐
Quantum ESPRESSO Course for Solid‐State Physics | 289

Figure 6.9 The high‐symmetry points of bulk cubic GeTe in the scaled units
or crystal_b coordinates given by the SeeK‐path tool in MaterialsCloud.

symmetry points along which we want to obtain the dispersion data


(lines 31–37). In this GeTe example, we list the 6 high‐symmetry
points for the specified path using the coordinate information from
the SeeK‐path tool. Do not forget that in gete.nscfbands.in we
should set the nbnd parameter (line 14), which was not written in the
gete.scf.in file. It is recommended to use the same value of nbnd
in both gete.nscfbands.in and gete.nscfdos.in files.

QE‑SSP/gete/gete.nscfbands.in

1 & CONTROL
2 calculation = 'bands '
3 outdir = './out/'
4 prefix = 'gete '
5 pseudo_dir = './ pseudo/'
6 verbosity = 'high '
7 /
8 &SYSTEM
9 ecutrho = 3.2000000000d+02
10 ecutwfc = 4.0000000000d+01
11 ibrav = 0
12 nat = 2
13 ntyp = 2
14 nbnd = 30 # same as in *. nscfdos.in
15 /
16 & ELECTRONS
17 conv_thr = 4.0000000000d-10
18 mixing_beta = 4.0000000000d-01
19 /
290 | Productivity Tools

20 ATOMIC_SPECIES
21 Ge 72.64 ge_pbesol_v1 .4. uspp.F.UPF
22 Te 127.6 te_pbesol_v1.uspp.F.UPF
23 ATOMIC_POSITIONS crystal
24 Ge 0.0000000000 0.0000000000 0.0000000000
25 Te 0.5000000000 0.5000000000 0.5000000000
26 CELL_PARAMETERS angstrom
27 4.2603675143 0.0000000000 0.0000000000
28 2.1301837572 3.6895864968 0.0000000000
29 2.1301837572 1.2298621656 3.4785755089
30 K_POINTS crystal_b # was automatic in SCF file
31 6
32 0.5000000000 0.2500000000 0.7500000000 50 !W
33 0.5000000000 0.5000000000 0.5000000000 30 !L
34 0.6250000000 0.2500000000 0.6250000000 20 !U
35 0.5000000000 0.0000000000 0.5000000000 50 !X
36 0.0000000000 0.0000000000 0.0000000000 50 !G
37 0.3750000000 0.3750000000 0.7500000000 1 !K

Similar to the DOS part, we create a post‐processing input file to


gather the energy dispersion data. We can make a new file with a few
lines of information for post‐processing the band structure using the
&BANDS namelist. The specifications of outdir and prefix should be
consistent with the *.nscfbands.in file.

QE‑SSP/gete/gete.bands.in

1 &BANDS
2 outdir = './out/'
3 prefix = 'gete '
4 filband = 'gete.bands '
5 /

Having created the above file, we have completed all the steps in
the preparation of Quantum ESPRESSO input files for the DOS and
band structure calculations.

6.1.4 Wannier90 input generator from CIF file

In addition to the SCF, NSCF, and DOS or band processing input files,
we may want to generate the Wannier90 input file directly from the
provided CIF file. For this purpose, there is a useful tool in the forms
Quantum ESPRESSO Course for Solid‐State Physics | 291
of Python script named as cif2qewan, which can be downloaded by
the following command:

$ git clone https :// github.com/wannier -utils -dev/


cif2qewan.git

The above command will create a cif2qewan directory in the current


working directory. We should also execute the following command if
we do not have some packages needed by cif2qewan tool:

$ pip install docopt toml cif2cell

Now, move to the cif2qewan directory and copy the


Ge1Te1_ICSD_638014.cif file to this directory. Suppose that
the CIF file was located in ~/QE-SSP/gete directory.

$ cd cif2qewan
$ cp ~/QE -SSP/ Ge1Te1_ICSD_638014 .cif .
$ python cif2qewan.py Ge1Te1_ICSD_638014 .cif
cif2qewan.toml

With the above set of command lines, we can obtain the Quan‐
tum ESPRESSO and Wannier90 input files automatically (scf.in,
nscf.in, pw2wan.in, and pwscf.win). In order to understand
and run these files, please check Sec. 3.6.1. Make sure that the
pseudo_dir in \cif2qewan.toml file has been edited properly to
be the location of “PS Library” pseudopotentials as explained in
Sec. 3.1.6, and the name of the pseudopotential of each atom in
pp_psl_rrkj.csv file is correct.

6.2 Linux commands

The most basic way that we have explained in Chapters 2 and 3 for
running the Quantum ESPRESSO calculations is using the following
Linux commands typed in the terminal:
292 | Productivity Tools

$ QEcommand < input.in > output.out

where QEcommand is one of any Quantum ESPRESSO binary (appli‐


cation) file such as pw.x, bands.x, dos.x, etc. For obtaining the DOS
and band structure of bulk cubic GeTe, we might want to execute the
following commands one by one in the terminal:

$ pw.x < gete.scf.in > gete.scf.out


$ pw.x < gete.nscfdos.in > gete.nscfdos.out
$ dos.x < gete.dos.in > gete.dos.out
$ pw.x < gete.nscfbands.in > gete.nscfbands.out
$ bands.x < gete.bands.in > gete.bands.out

However, as we become more experienced with Quantum ESPRESSO


and when we want to perform many different calculations (usually at
the same time), we will realize that typing commands one by one is
not efficient. Furthermore, if we have parallel computing resources,
we will need to type an additional command, such as mpirun -np 4,
before the QEcommand for specifying the parallel calculations. This
situation will force us to type longer command lines repeatedly.
Imagine also when the calculation takes a lot of hours (or even
days and weeks), we surely do not want to wait in front of our
computer without doing other productive works just to see that the
calculation is still running. Therefore, it is better for us to learn some
Linux commands and so‐called scripts that will run even after we log
out. We also need to manage Quantum ESPRESSO calculations as well
as for the administration of files and folders in our working directory.
We expect that the workflow or calculation routine developed
by using sufficient (“not so much”) knowledge of Linux commands
and scripts should be more efficient than repeating long commands.
We may notice in Chapter 3 there is a script file like run.sh, which
consists of several Linux commands in a single file. This file is also
known as a “batch” file because it is useful for running many jobs
one‐by‐one by a single execution of the file. In this section, we review
some commonly‐used Linux commands. If the readers are familiar
with Linux commands, the readers can go to in Sec. 6.3, in which we
explain how to make shell scripts.
Quantum ESPRESSO Course for Solid‐State Physics | 293

bin/ usr/ var/ etc/ lib/ home/ ...

... ... ... user1/ user2/ quantum/ ...

Figure 6.10 Linux directory structure.

6.2.1 File‐ and directory‐related commands

In Linux (also in macOS or other Unix‐like systems), every file


and directory is put under the root directory, which is the first or top‐
most directory in the directory tree. The root directory is referred
to by a single leading slash (/). Then, as shown in Fig. 6.10, under
the root directory, there can be several default directories, such as
bin/, usr/, var/, etc/, lib/, and home/, depending on the Linux
distribution we install in our computer.
When navigating the file and directory structure, we can use
either the absolute path or the relative path to the resource. For
example, a user in Linux with a specific username usually has
their main working directory as /home/username/ in its absolute
path that starts by “/”. If our username is quantum, the home
directory will be /home/quantum/ (unless we specified another
directory during the Linux installation). Suppose we are already
inside /home/quantum/ and we have a folder named QE-SSP, we can
refer to that folder as ./QE-SSP or simply QE-SSP in its relative path
(while the absolute path is /home/quantum/QE-SSP).
Now let us learn some frequently‐used commands that will be
useful for the file and directory management as shown in Table 6.1.

pwd: Show present working directory


The present working directory is the directory in which the user is
currently working. Each time we interact with the command prompt,
we are working within a directory. We can use the pwd command to
find out what directory we are currently working in:
294 | Productivity Tools

Table 6.1 File‐ and directory‐related commands in Linux, where file1 or dir1
are the name of file or directory, respectively.

Command Purpose
pwd show present directory
....................................................................................................................................................................

cd dirname change directory to dirname


....................................................................................................................................................................

cd change to home directory


....................................................................................................................................................................

ls list the current directory


....................................................................................................................................................................

ls -al list the current directory with hidden files


....................................................................................................................................................................

touch filename create or update filename


....................................................................................................................................................................

ln -s filename create a symbolic link called linkname to


linkname filename; it can also works for directory
....................................................................................................................................................................

mkdir dirname create a directory called dirname


....................................................................................................................................................................

rm filename delete a file called filename


....................................................................................................................................................................

rm -r dirname delete dirname


....................................................................................................................................................................

rm -f filename force remove filename


....................................................................................................................................................................

rm -rf dirname force remove dirname


....................................................................................................................................................................

copy filename1 to filename2


cp filename1
filename2
....................................................................................................................................................................

cp -r dirname1 copy dirname1 to dirname2; create


dirname2 dirname2 if it does not exist
....................................................................................................................................................................

rename or move filename1 to filename2;


mv filename1 however, if filename2 is an existing
filename2 directory, moves file1 into directory
filename2
....................................................................................................................................................................

cat > filename place standard input into filename


....................................................................................................................................................................

more filename output the contents of filename


....................................................................................................................................................................

head filename output the first 10 lines of filename


....................................................................................................................................................................

tail filename output the last 10 lines of filename


....................................................................................................................................................................

output the contents of filename as it grows,


starting with the last 10 lines
tail -f filename
....................................................................................................................................................................

change the permissions of filename (or


dirname) to octal (see the main text for the
chmod octal
detailed explanation)
filename
Quantum ESPRESSO Course for Solid‐State Physics | 295

$ pwd

The pwd command displays the absolute (full) path of our present
working directory. Below is an example of pwd execution along with
its output:

$ pwd
/home/quantum/QE -SSP

cd: Change directory


The cd (“change directory”) command is used to move from
the present working directory to another directory. Without any
argument, cd will take us to our home folder:

$ cd

We can check its output by the pwd command

$ pwd
/home/quantum

Now to change to a particular directory, we can use its absolute


path or relative path. Assuming that the directory QE-SSP exists in
the home folder, we can navigate to QE-SSP by using the relative path
as follows

$ cd QE -SSP

or

$ cd QE -SSP/

For better clarity of the relative path, we may also add a period
character (.) before the directory name we want to enter since
the period character emphasizes the path of the current working
296 | Productivity Tools

directory. The following command will give the same output as


before:

$ cd ./QE -SSP/

If we prefer to navigate to the directory using its absolute path,


we should specify the full path of the directory starting from the root
“/” until the folder name we want to enter. Using the same directory
example as before, we should type the cd command as follows in its
absolute path:

$ cd /home/quantum/QE -SSP

Note that the home directory in Linux (in this example:


/home/quantum) also has an alias denoted by a tilde symbol
(~). Therefore, the following command:

$ cd ~/QE -SSP

is equivalent to the previous one.


What if we want to move back from QE-SSP to /home/quantum
and to /home? Two dots (..) represent the parent directory, which
is the directory immediately above the current one. It means the
parent directory of QE-SSP in this case is /home/quantum, while the
parent directory of /home/quantum is /home (see Fig. 6.10 for the
illustration). Therefore, to switch to /home/quantum from the current
working directory QE-SSP, we would type:

$ cd ../

If we want to directly move two levels up from QE-SSP to /home,


it is possible to type the following command

$ cd ../../
Quantum ESPRESSO Course for Solid‐State Physics | 297
Note that if the directory that we want to change has spaces in
its name, we should either surround the path with quotes (single or
double quotes):

$ cd "dirname with space"

or use the backslash (\) character to escape the space:

$ cd dirname\ with\ space

ls: List directory contents


The ls command will list information about files and directories
within a directory. If we use it without any options and arguments,
ls displays a list in alphabetical order of the names of all files in the
current working directory:

$ ls

If we are already in /home/quantum/QE-SSP/gete, the output of


the ls command execution would be similar to the following:

gete.bands.in gete.nscfdos.in
gete.dos.in gete.scf.in
gete.nscfbands.in pseudo

To list files in a specific directory, we can pass the path


to the directory as an argument. For example, if we are in
/home/quantum/QE-SSP/, the following command will give exactly
the same output as before:

$ ls gete
gete.bands.in gete.nscfdos.in
gete.dos.in gete.scf.in
gete.nscfbands.in pseudo
298 | Productivity Tools

We see that the default output of the ls command shows only the
names of the files and directories. We can use the -l option to print
files in a “long” listing format:

$ ls -l

The command output includes file/directory size, file/directory


type, permissions, number of files/directories therein, owner, and
timestamps (of latest modifications). An example of the output is
given below:

$ ls -l
total 24K
-rw -r--r-- 1 user group 74 Jul 10 06:39 file1
-rw -r--r-- 1 user group 100 Jul 10 06:39 file2
-rw ------- 1 user group 1.2K Jul 10 06:39 file3
-rw ------- 1 user group 892 Jul 10 06:39 file4
-rw ------- 1 user group 829 Jul 10 06:39 file5
drwxr -xr -x 2 user group 4.0K Jul 10 06:39 dir1
drwxr -xr -x 1 user group 4.0K Jul 10 06:39 dir2

The first line of the output is the total size of files (and directory)
in the directory. Then, the next lines list the full information of the
files and directories. The leftmost character in each line will be either
a dash (-), which represents a file or a letter (d), which represents
a directory. The set of following letters (rwxrwxrwx) indicate the
permissions given to the particular file or directory.
The permissions are broken into three roles, i.e. rwx, rwx, and
rwx for a user, a group, and others, respectively. The name of the user
and the group are listed in user and group columns in the output
of ls -al. Then, each role has specified permission for the file or
directory in the following order: read (r), write (w), and execute (x).
A dash character (-) is shown if there is no permission to read, write,
or execute. Therefore, the following line,

rw-r--r-- ... file1

means that file1 is

• rw-: readable, writable, and unexecutable by the user;


Quantum ESPRESSO Course for Solid‐State Physics | 299
• r--: readable, unwritable, and unexecutable by the group;
• r--: readable, unwritable, and unexecutable by the others
(beyond the user and the group).

Similarly,

rwxr-xr-x ... dir2

means that dir2 is

• rw-: readable, writable, and executable by the user;


• r--: readable, unwritable, and executable by the group;
• r--: readable, unwritable, and executable by the others.

Note that the ls command does not list the hidden files by
default. A hidden file is any file that begins with a period character.
To display all files, including the hidden files, use the -a option:

ls -al

We can then combine different options in one line, whether with an


argument or not.

$ ls -al
$ ls -al /home/quantum/QE -SSP/gete

The first command above will list all files and folders in the current
working directory, including the hidden files therein in the long
listing format. Meanwhile, the second command will output the list
for the specified directory. An example of the output is given below:

$ ls -al
total 36K
drwxr -xr -x 3 user group 4.0K Jul 10 06:39 .
drwxr -xr -x 5 user group 4.0K Jul 10 06:39 ..
-rw -r--r-- 1 user group 74 Jul 10 06:39 file1
-rw -r--r-- 1 user group 100 Jul 10 06:39 file2
-rw ------- 1 user group 1.2K Jul 10 06:39 file3
-rw ------- 1 user group 892 Jul 10 06:39 file4
300 | Productivity Tools

-rw ------- 1 user group 829 Jul 10 06:39 file5


-rw ------- 1 user group 829 Jul 10 06:39 .file6
drwxr -xr -x 2 user group 4.0K Jul 10 06:39 dir1
drwxr -xr -x 1 user group 4.0K Jul 10 06:39 dir2
drwxr -xr -x 2 user group 4.0K Jul 10 06:39 .dir3

In this example, .file6 and .dir3, which were previously not


shown, are now listed in the output. You can practice the ls -al
command to the other directories that contain hidden files.

touch: Create files


The touch command is used to update the timestamps on existing
files and directories as well as to create new and empty files, which
previously do not exist.
To create a file, specify the file name as an argument:

$ touch new -file.txt

If the file already exists, the touch command will change the file’s
last access and modification times to the current time. If the file does
not exist yet, the command creates an empty new-file.txt with a
zero‐byte size.

ln: Create symbolic links


A symbolic link (or symlink) is a special type of file that points to
another file or directory. The concept is similar to making a shortcut
in Windows operating system (OS). In Linux‐based OS, to create a
symbolic link to a given file, we use the ln command with the -s
option, the name of the file as the first argument, and the name of
the symbolic link as the second argument:

$ ln -s sourcefile symboliclink

Suppose our current working directory is the home folder. We want to


create a symbolic link to ~/QE-SSP/gete and put it under the home
directory as GeTe. We should type
Quantum ESPRESSO Course for Solid‐State Physics | 301

$ cd ~
$ ln -s ~/QE -SSP/gete gete

The above commands will give a symlink named as gete in the home
directory so we can access gete folder directly from the home
directory.

$ cd ~/ gete

If only one file/directory is given as an argument, ln creates a


link to that file/directory in the current working directory with the
same name as the file/directory it points to. The following command
executed in the home directory will give the same result as the
previous symlink:

$ ln -s ~/QE -SSP/gete

mkdir: Create a new directory


We can create a new directory using the mkdir command. To create
a directory, pass the name of the directory as the argument to the
mkdir command. For example,

$ mkdir /tmp/newdirectory

mkdir can take one or more directory names as its arguments. If the
argument is a directory name, without the full path, the new directory
is created in the present working directory.
To create directories along with the parent directory, we should
use the -p option. For example,

$ mkdir -p QE -SSP/gete/out

creates the whole directory structure in the present working


directory, from QE-SSP going to gete, and finally out. Note that
when mkdir is invoked with the -p option, the command creates the
directory only if it does not exist.
302 | Productivity Tools

rm: Remove files or directories


To remove files or directories in Linux, use the rm command. We
should be very careful when using this command because we cannot
(in most cases) recover the files after removing them. By default (and
also for safety), the rm command will not work when it is executed
without any option.
To delete a file or a symbolic link, use the rm command followed
by the file name as an argument:

$ rm file.txt

The rm command accepts one or more files or directories as


its arguments. Note that when we delete a symlink, the original
sourcefile will not be removed by the rm command.
The -i option tells rm to prompt the user for each given file
before removing it:

$ rm -i file.txt
...
rm: remove regular empty file 'file.txt'?

Only when we answer the above question with “y” (without quotes),
the rm command will perform.
Use the ‐d option to remove one or more empty directories:

$ rm -d dirname

To remove non‐empty directories and all the files within them


recursively, use the -r (recursive) option:

$ rm -rf dirname

The -f option does not prompt the user, and rm -rf command
deletes all files and arguments under the directory without asking
remove or not. It should be carefully noted that the rm -rf ./*
command is considered as the most dangerous command in Linux
since all files and folders under the current working directory will
Quantum ESPRESSO Course for Solid‐State Physics | 303
completely disappear. Imagine if we execute this command in our
home directory, all our works will be wiped out, and if we execute
the command in the root (/), our OS can be broken. Therefore, the
readers should not use this command or use it after to back up the
contents of the directory before performing the command.

cp: Copy files and directories


The cp command allows us to copy files and directories. To copy a
file in the present working directory, use the source file as a first
argument and the new file as the second:

$ cp file.txt filebackup.txt

To copy a file to another directory, we should specify the absolute


or the relative path to the destination directory. When only the
directory name is specified as a destination, the copied file under the
destination will have the same name as the original file. For example,
the following command

$ cp file.txt /home/quantum/QE -SSP

will copy file.txt in the present working directory to the


/home/quantum/QE-SSP (or ~/QE-SSP) folder with the same file‐
name (file.txt). Note that by default, if the destination file exists, it
will be overwritten without asking you unless you do not use cp -i.
To copy a directory, including all its files and subdirectories, use
the -R or -r option, as in the following example:

$ cp -r QE -SSP QE -SSP -backup

mv: Move and rename files/directories


The mv command (short from move) is used to rename and move
files/directories from one location to another. For example, to move
a file named file.txt to the /tmp folder, we execute:

$ mv file.txt /tmp
304 | Productivity Tools

To rename the file, we need to specify the destination file name:

$ mv file.txt filerenamed.txt

The command order for moving directories is the same as when


moving files. To move multiple files and directories at once, specify
the destination directory as the last argument:

$ mv file1.txt file2.txt /tmp

cat: Show file contents


The cat command shows the contents of one or more files and merge
(concatenate) files by appending one file’s contents to the end of
another file. To display the contents of a file on the screen, pass the
file name to cat as an argument. For example, executing

$ cat gete.scf.in

will output the contents of gete.scf.in (Sec. 6.1.1) to the terminal’s


screen. Adding an operator of standard output (>) after the cat
command can make the command act as the cp. The following
command line:

$ cat gete.scf.in > gete.scf.in.backup

will give an exact copy of the gete.scf.in file in the


gete.scf.in.backup file.

more and less: Show file contents interactively


The more or less command is used to view the text files in the
command prompt, displaying one screen at a time in case the file has
many lines. The two commands are very similar, so we will consider
that they are just the same command for our purpose of navigating
large output files of Quantum ESPRESSO calculations. The merit of
the commands is that they allow us to scroll up and down the file page
by page. For example, we can check the usage of the more command
on the gete.scf.out file:
Quantum ESPRESSO Course for Solid‐State Physics | 305

$ more gete.scf.out

After executing the above command, we will be prompted with an


output page (starting from the first line down to a certain line
number) waiting for instruction. Press the space bar (or letter f) key
to go to the next page. If we want to go back to the previous page, we
can press letter b or p key. Use letter q key to quit the prompt.

head (or tail): Display the beginning (or end) of the file
The head and tail commands can be used to display the beginning
and end of the file, respectively. By default, the number of lines shown
by the two commands is limited to 10. If we want to change the
number of lines printed on the screen, we can use the -n option
followed by the desired number. We can try performing the head and
tail commands on the gete.scf.out file. For the head command,
the example execution along with the resulting output is as follows:

$ head -n 13 gete.scf.out

Program PWSCF 6.7 starts on 13 Aug2021 at 6:53:15

This program is part Quantum ESPRESSO suite


for quantum simulation of materials; please cite
"P. Giannozzi et al., JPCM 21 395502 (2009);
"P. Giannozzi et al., JPCM 29 465901 (2017);
URL http :// www.quantum -espresso.org",
in publications or presentations.
More details at http :// www.quantum -espresso.org/

Parallel version (MPI), running on 8 processors

For the tail command (this is useful to see JOB DONE message):

$ tail -n 8 gete.scf.out
PWSCF : 10m33 .89s CPU 16m 8.73s WALL

This run was terminated on: 7: 9:24 13 Aug2021

=-----------------------------------------------=
JOB DONE.
306 | Productivity Tools

=-----------------------------------------------=

Similar to the cat command, we can combine either head or tail


command with the standard output operation.

$ tail -n 8 gete.scf.out > log.txt

The above command will print the last 8 lines of gete.scf.out into
the log.txt file, which can be opened later by a text editor.
The tail command also has a special option: -f, which is useful
for displaying the contents of the file as it grows, starting with the
last 10 lines. We can benefit from such an option, in particular, when
monitoring a job running on the background. For example, when we
execute

$ pw.x < gete.scf.in > gete.scf.out

we may want to observe the evolution of gete.scf.out during the


running process of pw.x, which can take several minutes or even
hours depending on the size of the calculated system. After executing
the above command, we can follow it by the tail -f command to see
the output (gete.scf.out) in real time when the tail -f command
is entered:

$ tail -f gete.scf.out

highest occupied level (ev): 7.1721

! total energy = -239.63636259 Ry


estimated scf accuracy < 3.6E-11 Ry

The total energy is the sum of following terms:


one -electron contribution = -147.05152059 Ry
hartree contribution = 88.78504266 Ry
xc contribution = -71.86764050 Ry

Note that, depending on the time of execution, it is normal if the


output obtained by the readers is different from the above example.
If pw.x calculation is successfully completed, the same “JOB DONE”
Quantum ESPRESSO Course for Solid‐State Physics | 307
Table 6.2 Process management and system information commands.

Command Purpose
whoami display who we are logged in as
....................................................................................................................................................................

w display who is online on the computer


....................................................................................................................................................................

df show disk usage


....................................................................................................................................................................

du show directory space usage


....................................................................................................................................................................

show possible locations of an application


named app
whereis app
....................................................................................................................................................................

which app show which app will be run by default


....................................................................................................................................................................

lists stopped or background jobs; resume a


stopped job in the background
bg
....................................................................................................................................................................

fg bring the most recent job to foreground


....................................................................................................................................................................

top display all running processes


kill pid kill a process whose “id” number is pid
....................................................................................................................................................................

killall proc kill all processes named proc


....................................................................................................................................................................

show cpu information, a shortened version of


cat /proc/cpuinfo command
lscpu
....................................................................................................................................................................

show memory and swap usage, a shortened


version of cat /proc/meminfo command
free
....................................................................................................................................................................

mpirun -np N app run app in parallel with N processors


....................................................................................................................................................................

keep command (or app) process running even


nohup command if we exit the shell (but not when the
computer is shutdown)
....................................................................................................................................................................

exit logout from the current session

message for gete.scf.out (and other kinds of Quantum ESPRESSO


calculation outputs) should appear.

6.2.2 System information and process management

Linux and other Unix‐based systems allow multiple processes to


operate simultaneously without interfering with each other. Due to
308 | Productivity Tools

this nature, there are many commands dedicated to managing the


processes and for displaying system information in Linux. We will not
discuss all the commands, but we will list some of them that can be
used along with the Quantum ESPRESSO calculations. The summary
of Linux commands for process management and for displaying
system information is given in Table. 6.2. We briefly describe each
command one by one below.

whoami: Ensuring we know ourselves


The whoami command is used to check our own username. Suppose
our username is quantum, the output of this command will also be
quantum.

$ whoami
quantum

At a glance, we may consider this command not useful if we only


have a simple username that is easy to memorize. However, in multi‐
user environments such as high‐performance computing (HPC)
clusters and supercomputers, we usually cannot set the username by
ourselves because the system administrator will create the account
for us. It is also possible that we obtain several usernames for one
HPC system. In that case, the usernames can be a combination of
letters and numbers that could be difficult to memorize. When we log
into one username and switch to another username, we can forget
who we are. In such a situation, the whoami command is a handy
command to rescue us.

w: Display online users


The w command is used to know who is online on the computer we
are logged in to. This command also shows other details such as the
load average of the computer, the terminal number (“tty”) we are
connected to, how long the computer is already on, and how long the
users have been logged in (or oppositely, have been idle). We simply
type the letter w to run this command.

$ w
Quantum ESPRESSO Course for Solid‐State Physics | 309

Figure 6.11 Example output of the w command in a HPC.

An example output of this command performed on a HPC is shown


in Fig. 6.11. The username of one of the book authors is ahma079,
running the w command, shown with other users who are online at
that time. When more than two users use a computer, it would be nice
to check it other users run Quantum ESPRESSO by w command.

df and du: Disk and directory space usage


Sometimes we want to know the disk (or file system in Linux) and
directory space usage. For that purpose, we can use the df and du
commands. In particular, if we are a user of a computer with limited
space, we might be concerned with the directory space usage (the
du command). Suppose we are in the directory where the input and
output of the GeTe calculation files are located. We can use the du
command to check the space used by all these files. An example
execution and output of the du command is given below.

$ du -h
392K ./out
1.0M ./ pseudo
6.7M .

From the output above, we can see the usage of that directory
(denoted by the period symbol) is around 6.7 MB. The output
obtained by the readers may be different with this example
depending on the readers’ activities in the directory.

whereis and which: Understanding app locations


To know possible locations of an application named app, we can use
the whereis command:
310 | Productivity Tools

$ whereis app

For example, in a HPC system at which one of the book authors is


registered, the output of whereis pw.x is as follows.

$ whereis pw.x
pw:
/apps/tools/qe -6.4.1/ bin/pw.x
/home/ahma079/qe -6.7/ bin/pw.x

The output indicates that there are two locations of pw.x. The first
one is /apps/tools/qe-6.4.1/bin/pw.x and the second one is
/home/ahma079/qe-6.7/bin/pw.x. This output can vary depending
on the system used by the readers.
The question now is, “Which app is used by default when we call
pw.x?” To get the answer, we can execute the which command with
the following format:

$ which app

For example, in the HPC system same as before:

$ which pw.x
/apps/tools/qe -6.4.1/ bin/pw.x

The output above informs us that the pw.x command from


/apps/tools/qe-6.4.1/bin/ folder will be used when we execute
the pw.x command without its absolute path. If we want to use pw.x
from /home/ahma079/qe-6.7/bin/ instead, we must supply its full
absolute path to pw.x, i.e.,

$ /home/username/qe -6.7/ bin/pw.x < input > output

bg and fg: Background and foreground jobs


The bg command is used to resume a stopped job in the background.
On the other hand, the fg command is used to bring the most recent
job to the foreground. To understand the concepts of background
Quantum ESPRESSO Course for Solid‐State Physics | 311
and foreground in the Linux terminal, we can try running the SCF
calculation of GeTe on our computer.

$ pw.x < gete.scf.in > gete.scf.out

By entering the above command only, we should notice that the


cursor in the terminal does not return to the original command
prompt. The cursor waits until the system finishes running pw.x as a
foreground job, which actually takes a long time.
If we want to stop the calculation temporarily, we can press
CTRL+z keystroke combination and continue writing other com‐
mands in the terminal as we wish. An example output message that
appears after we press CTRL+z is given below.

^Z
[1]+ Stopped pw.x < gete.scf.in > gete.scf.out

Now the command prompt returns to the original state with the
cursor waiting for our action. What happens to the pw.x calculation
above is that it stops until we enter either the fg command or bg
command. First, let us try the fg command. Its execution with the
example output is as follows.

$ fg
pw.x < gete.scf.in > gete.scf.out

In the above case, after executing the fg command, we can


realize that pw.x continues running as a foreground job, indicated
by the appearance of the second line (pw.x < gete.scf.in >
gete.scf.out) on the screen, but then the cursor gets stuck until the
calculation finishes. If the calculation is fast enough, we can do this
kind of fg command and just wait for a moment with the inability
of typing further commands in the terminal. However, we might
not want to wait for the calculation, especially when the calculation
takes a very long time. Instead, we want to continue other works
in the terminal. In this case, it is a good idea to send the job to
the background. We can press CTRL+z again, followed with the bg
command.
312 | Productivity Tools

$ bg
[1]+ pw.x < gete.scf.in > gete.scf.out &

The output message appearing on the second line indicates that


pw.x is running as a background job, and the calculation will continue
running while at the same time we can type other commands on the
terminal. The ampersand character (&) in the example above tells
the job to be run in the background. Therefore, instead of pressing
CTRL+z and the bg command, we can also accompany the pw.x
command line with the ampersand character if we decide to run the
calculation on the background since the beginning of the calculation.

$ pw.x < gete.scf.in > gete.scf.out &

This command will take several minutes or hours depending on the


computing resources we have in our PC. It is then natural to ask how
we can monitor the process and how we can stop it when we wish to
do so. The top and kill command will be helpful now.

top: Displaying all running processes


The top command is used to show the Linux processes. The
command provides a dynamic real‐time view of the running system,
including the summary information of the system and the list
of processes. As soon as we run this command, it will open an
interactive command mode where the top half portion will contain
the statistics of processes and resource usage. The lower half
contains a list of the currently running processes. Pressing the letter
q will exit the top command mode.
After we run the SCF calculation in our PC, we can check its
status by the top command. Below is an example of the top command
execution with some parts of its output.

$ top
Tasks: 16 total , ...
...
PID USER ... COMMAND
850 quantum ... pw.x
...
Quantum ESPRESSO Course for Solid‐State Physics | 313
There are actually further details (…) of the output but we just show
the number of tasks, the process number (PID), the user who has
the process, and the command related to the process. Note that the
output of PID and USER may vary. However, if we run the same pw.x
command for the SCF calculation of GeTe, we can see it somewhere
below the COMMAND information of the top output. If we think that the
calculation was run wrongly or if we just want to stop it, we should
write down its PID, press q to exit the top command mode, and run
the kill command as will be explained next.

kill: Termination of jobs in the middle


Suppose we want to stop the SCF calculation with PID already known
from the previous example of top command, we can execute

$ kill pid

In our example of GeTe above, we should perform

$ kill 850

Is the process killed completely? Sometimes, no! We should confirm


it by executing the top command again. If we still see the pw.x
command with the same PID, we have two ways to completely kill
the process. The first way is by using -9 option:

$ kill -9 850

The second way is by using the killall with the process (or
command) name as its argument.

$ killall pw.x

lscpu and free: CPU and memory information


We can use the lscpu and free commands to check the processor
(CPU) and memory information of the computer we are logged in.
The lscpu command can be considered as a shortened version of cat
/proc/cpuinfo command, while the free command is a shortened
314 | Productivity Tools

version of cat /proc/meminfo. The example execution of lscpu and


free are shown below with some parts of their outputs.

$ lscpu
Architecture: x86_64
CPU op -mode(s): 32-bit , 64-bit
Byte Order: Little Endian
CPU(s): 8
On -line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
...

$ free
total used free ...
Mem: 11337068 143932 10964292 ...
Swap: 3145728 0 3145728 ...

nohup: No hang up
When exiting the terminal or shell of a Linux System, all running
processes are usually terminated or hang up. If we want to keep the
processes running when exiting the terminal, we can use the nohup
command. It should be noted, however, that if the computer (not only
a physical computer but also a virtual machine or WSL) is shut down,
the nohup command and the processes to which it is assigned will
also stop. Therefore, if we want to run very long Quantum ESPRESSO
jobs, in addition to using the nohup command, we should make sure
that the computer can survive running within the calculation time
frame.
The nohup command can be combined with the background
operator & as follows

$ nohup command &

where command can also be an app or other processes. For example, if


we want to keep running the GeTe calculation in the background and
safely exit our terminal, we can execute
Quantum ESPRESSO Course for Solid‐State Physics | 315

$ nohup pw.x < gete.scf.in > gete.scf.out &

When we re‐login to the terminal (as long as the computer is


not shutdown), we can find by using the top command that the
calculation is not interrupted. The nohup command is often used with
a batch script as we will explain in Sec. 6.3.

exit: Quitting the session


As the name clearly tells us, the exit command is used to quit or
logout from the current session of terminal/shell. We can simply type
this command without any argument

$ exit

We can practice the exit command after the nohup command


executed previously, and then login again to check (by using the top
command) that the Quantum ESPRESSO calculations we submitted
to the computer are still running.

6.2.3 Running parallel calculations

Recently, with the availability of “multicore” and “multithread”


processors, most personal computers already allow us to perform
parallel calculations with the mpirun command. However, to use
this command, we should make sure that mpirun is installed in
our system. If it is not installed in a Debian/Ubuntu Linux‐based
distribution, we can select one of few messages passing interfaces
(MPI) implementations such as Open MPI, MPICH, and Intel MPI. The
following is an example installation for the Open MPI library:

$ sudo apt install libopenmpi -dev

Note that we should have already done this step in Chapter 2 if we


compile Quantum ESPRESSO with the parallel processing option.
A generic way to use the mpirun command is by using the -np
option followed by the number of cores (more precisely threads) in
a CPU (or CPUs) (N) for parallel processing:
316 | Productivity Tools

mpirun -np N app

In simple HPC systems, the number of cores (threads) given by lscpu


command is usually the maximum limit that we can assign to mpirun
when running Quantum ESPRESSO in parallel. For example, if the
number of CPUs from the lscpu output is 8, we can put 8 as the value
of N for the -np option in the mpirun command, combined with pw.x
or other Quantum ESPRESSO apps. However, we recommend not to
use the maximum number for the ‐np option since OS is also running
at least one core.

$ mpirun -np 8 pw.x < gete.scf.in > gete.scf.out

The majority of the codes that come with the Quantum ESPRESSO
package can run in parallel similarly to the above way.
In a more sophisticated HPC system (let us say a supercom‐
puter), the result of lscpu should not be taken into consideration
for deciding the value of the -np option because when we login
to that supercomputer, we are only brought to the “control node”
that will distribute our job to the other nodes dedicated for parallel
processing. In this case, we should consult the system administrator
or the manual of the supercomputer for the best setting of the CPU
number we can use for our calculations. On the other hand, if we are
just running Quantum ESPRESSO calculations on our own laptop, it
is safe to use a smaller CPU number than what is indicated by lscpu.
We should also be aware that plane‐wave DFT calculations (like
that in Quantum ESPRESSO) do not scale linearly. Our calculation
will get faster to a certain value of N, after which the calculation
will become slow if we add more parallel processes. The situation
can vary depending on the PC hardware (chipset, memory size, etc.),
software, and type of calculation we are doing, but usually we will see
a reduction in the speedup after around 8–32 processes.
If we do the generic way of mpirun above (such as mpirun -np
8 pw.x < gete.scf.in > gete.scf.out), we accept the default
“strategy” for parallelizing the calculation. Using this default strategy
for the pw.x command, in most cases, is already a good choice.
However, if we are not satisfied with the speedup given by the default
Quantum ESPRESSO Course for Solid‐State Physics | 317
strategy, we can use other parallelization schemes as discussed
in detail in the Quantum ESPRESSO documentation, especially for
pw.x (“PWscf”) and ph.x (“PHonon”) applications, in the sections of
performances and parallelism, respectively.

6.2.4 Parallelization in Quantum ESPRESSO


In the following, we just briefly discuss some types of parallelization
that can be implemented in Quantum ESPRESSO because advanced
users may want to play by themselves with the possible paralleliza‐
tion strategies beyond the default one.
Parallelization for several independent calculations. If the
calculation we have asked for involves running several similar
calculations, the computers can break up these calculations between
parallel processes. Quantum ESPRESSO offers this functionality for
some applications, particularly ph.x), which refers to these sets of
calculations as “images”. We can set how many of these images are
used for a parallel calculation with -nimage or -ni. If we run with
20 processors and specify -ni 2, each image will use 10 processors.
The default for -ni is just 1.
Parallelization of k‑points. This parallelization strategy needs
very little communication between processes and thus can offer good
scaling, as each k‐point can be treated as effectively an independent
calculation where results are added together at the end. This strategy
will be effective when the number of k‐points in our calculation is
quite large (typically larger than 10 × 10 × 10 k‐point grid in the
Monkhorst‐Pack scheme). We can set how many parallel groups of
k‐points for our calculation with the -npool or -nk flag in Quantum
ESPRESSO (e.g., add -nb 2 option next to the pw.x command). The
default -nk is 1.
Parallelization over bands. The calculation for each energy
band can also be parallelized. This strategy may cut down the
amount of memory used by each process but requires a bit more
communication between processes. We can set the number of bands
to be grouped in the parallel calculation by using the -nband or -nb
flag (e.g., add -nb 2 option next to the pw.x command). The default
-nb is 1.
Parallelization for plane waves. For the sake of completeness
of the information, we should note that Quantum ESPRESSO by
318 | Productivity Tools

Table 6.3 Search in Linux using the grep commands.

Command Purpose
grep pattern files search for pattern in files
....................................................................................................................................................................

search recursively for pattern in dirname


grep - r pattern
dirname
....................................................................................................................................................................

search for pattern in the output of command


command | grep
pattern

default already distributes the plane wave basis sets efficiently to


the parallel processors. This strategy is always turned on if Quantum
ESPRESSO is compiled and run in parallel.

6.2.5 Searching

For searching files and patterns, Linux has some powerful commands
such as grep, find, and locate. For our purpose of analyzing and
understanding Quantum ESPRESSO output files, it is sufficient for
us to focus on the grep command. The usage summary of the grep
command is given in Table. 6.3. Let us practice this command for
obtaining some important information about our calculation.
The most basic syntax for grep is

$ grep pattern files

where the pattern can be a character, a word, a sentence, or


any string we want to find in files. Suppose we already have a
gete.scf.out file in the ~/QE-SSP/gete/ directory, we can search
for all occurrences of “total energy” in gete.scf.out as follows:

$ grep "total energy" gete.scf.out

The output will be similar to as follows:


Quantum ESPRESSO Course for Solid‐State Physics | 319

total energy = -239.63505730 Ry


total energy = -239.63624073 Ry
total energy = -239.63633447 Ry
total energy = -239.63635918 Ry
total energy = -239.63636081 Ry
total energy = -239.63636155 Ry
total energy = -239.63636227 Ry
total energy = -239.63636260 Ry
total energy = -239.63636259 Ry
total energy = -239.63636258 Ry
! total energy = -239.63636259 Ry
The total energy is the sum of the following terms
:

In this case, since the SCF calculation performed iterations for finding
the minimum total energy, we see the words “total energy” several
times according to the number of iterations. The one with the
exclamation mark (!) is the final result of total energy. Therefore,
if we just want to know this final result, we can change the search
pattern to the exclamation mark. The grep execution with its output
in this case is

$ grep ! gete.scf.out
! total energy = -239.63636259 Ry

The grep command can be used recursively to find the pattern


in a specified directory. The syntax is

$ grep - r pattern dirname

We can practice this syntax for finding the Fermi energy in the gete
working directory (~/QE-SSP/gete/).

$ grep -r Fermi .

Remember that the period (.) sign denotes the current directory,
so that the above syntax will look for all occurrences of “Fermi” in
all files of the current directory. The example of the output is given
below:
320 | Productivity Tools

./ gete.nscfdos.out: the Fermi energy is 7.2526 ev


./ gete.dos : ... EFermi = 7.253 eV

The output tells us that the grep command could find the word
“Fermi” in the gete.nscfdos.out and gete.dos files in the current
directory.
The grep command can also be combined with the other Linux
commands through the “piping” method with the pipe (|) character.
The syntax is

$ command | grep pattern

where command is any command or app. For example, we can list the
current directory and find any file or directory which contains “out”
pattern. The example execution and some parts of its output are given
below.

$ ls -al | grep out


-rw -r--r-- 1 ... gete.bands.out
-rw -r--r-- 1 ... gete.dos.out
-rw -r--r-- 1 ... gete.nscfbands.out
-rw -r--r-- 1 ... gete.nscfdos.out
-rw -r--r-- 1 ... gete.scf.out
drwxr -xr -x 2 ... out

6.2.6 Keyboard shortcuts

There are some useful shortcuts available in the Linux terminal. The
summary of these keyboard shortcuts is given in Table. 6.4. You can
try them one by one following the table.

Self‐contained “help” of the command


Usually, a Linux command can have many options that are specified
by a single hyphen (-) or double hyphen (--). If we do not use
the command frequently, we might forget its options. However,
memorizing command options is not necessary because almost all
Linux commands have a --help option, which prints a short message
Quantum ESPRESSO Course for Solid‐State Physics | 321
Table 6.4 Keyboard shortcuts in the terminal.

Shortcut Purpose
CTRL+c halt the current command
....................................................................................................................................................................

stop the current command, resume with fg


in the foreground or bg in the background
CTRL+z
....................................................................................................................................................................

logout from the current session, similar to


CTRL+d
exit
....................................................................................................................................................................

erase one word before the cursor in the


current line
CTRL+w
....................................................................................................................................................................

CTRL+k erase any characters after the cursor


....................................................................................................................................................................

CTRL+u erase the whole line


....................................................................................................................................................................

move to a command backward;


CTRL+p browse/recover previous command(s)
according to the terminal history
....................................................................................................................................................................

move to a command forward; in combination


with CTRL+p, browse/recover previous
command(s) according to the terminal
CTRL+n
history
....................................................................................................................................................................

move the cursor forward to the end of the


next word in the current line
ALT+f
....................................................................................................................................................................

move the cursor backward to the beginning


of the previous word in the current line
ALT+b
....................................................................................................................................................................

CTRL+e move the cursor to the end of the current line


....................................................................................................................................................................

move the cursor to the beginning of the


current line line
CTRL+a

about how to use the command. The way we write it in the terminal
is as follows.

$ command --help

For example,
322 | Productivity Tools

$ cp --help

will give us the details of the cp command as well as its possible


options.
The Linux commands are also often distributed together
with manual (man) pages. A man or manual page is a form of
documentation that explains what the command does, examples of
how you run the command, and what arguments it accepts. The man
command is used to display the manual page of a given command.

$ man command_name

For example, to open the man page of the command to change the
directory (cd), you would type

$ man cd

To navigate the man pages, use the Arrow, Page Up, and Page
Down keys. We can also press the Enter key to move one line at a time,
the Space bar to move to the next screen, and the letter b key to go
one screen back. To exit the man page, press the letter q key.

6.3 Shell scripts and batch jobs

Shell scripts are useful for automating processes and running many
jobs simultaneously because shell scripts allow us to string together
sets of commands. With the shell scripts, we could write a script
that runs calculations, parses the important results to another file,
and even generates a plot. In this section, we will learn basic shell
scripting to be able to automate Quantum ESPRESSO calculations and
to submit batch jobs as a background job with nohup command.
There are often several different shells installed on a Linux
system, and bash is typically the default one in most Linux
distributions. The bash shell is running in the terminal, and it
interprets and executes the commands we type in.
Quantum ESPRESSO Course for Solid‐State Physics | 323
6.3.1 Environment

On startup, such as when a new terminal is opened, or when we


connect to a remote system over the network, bash will read several
configuration files.

• For login shells (the shells where we are prompted to login


when we start it), bash will read configuration options in
~/.bash_profile or ~/.profile if this file exist. Note ~ is
interpreted by the shell as the users home directory.
• For non‐login shells (such as when we open the terminal
emulator), bash will read configuration options in ~/.bashrc.
• For simplicity, we can put all our configuration options in
~/.bashrc and leave the ~/.profile file empty except for a
command to read the ~/.bashrc file.

These files can be used to configure many aspects of the shell,


such as how the prompt looks in the terminal and also how specific
apps such as Quantum ESPRESSO can be found by defining the so‐
called environment variables.
Many important aspects of how bash behaves are governed
by environment variables. These variables can be modified to our
preference in the configuration files. To see the current value of one
of these variables, e.g., the PATH variable, we can do the following

$ echo $PATH

The $ symbol in front of the variable (e.g., PATH variable) is used


when referring to the data stored in a variable, and echo is a built‐in
bash command that outputs something to the terminal.
The PATH variable tells bash which directories to look in for
executables so they can be run without typing in their full path.
For example, we can just type in nano in the terminal to launch
the program, as the PATH variable contains the directory holding an
executable of this name. Different directories are separated by “:”.
To add the directory ~/.bin to our path, we can add the line
export PATH="~/bin:$PATH" to the .bashrc file. Here the export
statement is used to allow the variable to be usable by any child
324 | Productivity Tools

processes rather than local to the script. Note when we are naming
the variable we want to assign a value to we do not use a $. Also we
just want to add a directory to the existing PATH so we add :$PATH to
keep all the existing directories.
We can practice updating the PATH variable to include not
only the ~/bin directory but also the Quantum ESPRESSO binary
directory. Suppose we install Quantum ESPRESSO latest version
(q-e) under ~/opt directory, we can add the export statements for
the PATH variable as follows:

~/.bashrc

export PATH="~/bin:$PATH"
export PATH="~/opt/q-e/bin:$PATH"

We need to execute the following command in the terminal to ensure


that the updated variables will be read by the shell without logout.

$ source ~/. bashrc

When you login the next time, you do not need this.

6.3.2 Scripting

This part covers basic scripting. If readers are interested in


developing more advanced scripts, we suggest referring to the http:
//tldp.org/LDP/abs/html/index.html.
Let us make a simple example script to output “Hello World!”. We
can use the nano text editor to create it.

$ nano helloworld.sh

The contents are as follows:

QE‑SSP/scripts/helloworld.sh

#!/ bin/bash
# Simple script that outputs " Hello World !"
Quantum ESPRESSO Course for Solid‐State Physics | 325

echo "Hello World!"

The first line above tells the system what command is used to
interpret the contents of the script. This line should always begin
with #! and then the path to the executable. For bash the executable
will almost always be /bin/bash. In the script, comments are
represented by #. Linux commands can be typed the same as we
would enter them to the terminal. After writing the script, we will
need to make the script executable with chmod u+x hello.sh.

$ chmod u+x helloworld.sh

Then, we can run it by typing ./helloworld.sh. The execution and


example output are given below.

$ ./ helloworld.sh
Hello World!

Note that if we move the helloworld.sh file to ~/bin/ that has


been added to the PATH variable, we can execute the script from any
directory without specifying the current working directory (./).

$ mv helloworld.sh ~/bin/
$ helloworld.sh
Hello World!

Variables in shell scripts


In the bash shell scripts, variables need not be declared in any way,
we can assign a value and start using them. For example:

QE‑SSP/scripts/helloworld‑rev.sh

#!/ bin/bash
# Example using variables .

var1="Hello"
var2="World!"
326 | Productivity Tools

echo $var1 $var2


# Note the use of the $ symbol when
# we want to use the value stored in the variable .

# Any command can use these variables


dirname="tmpdir"
mkdir $dirname

We can also read a value from standard input using the read
command as follows:

QE‑SSP/scripts/enterinput.sh

#!/ bin/bash
# Example showing how the read command is used.

echo "Please enter some text:"


read user_text

echo "The text you entered was:" $user_text

Variable names are case sensitive in bash. The usual convention


used is that environment variables (e.g., PATH), and internal shell
variables (e.g., BASH_VERSION) are capitalized, while other variables
are in lowercase. Adopting this convention will ensure that we do not
accidentally overwrite any important variables in our scripts.

Command substitution
Command substitution allows the result of a command to replace the
command itself, acting much like a variable in practice. For example:

QE‑SSP/scripts/substitute.sh

#!/ bin/bash
# Example of command substitution .

# This can be done by


# enclosing the command in $( )
echo "It is now $(date)."
# Note: the "date" command outputs
# the current date and time.

# This can also be done by


# enclosing the command in backtics ` `
Quantum ESPRESSO Course for Solid‐State Physics | 327
echo "The files in this directory are:" `ls `

Conditional statements
The conditional if statements can be used in bash, and many types
of conditional tests are possible. We can test if the value stored in a
variable equals something as follows:

QE‑SSP/scripts/if1.sh

#!/ bin/bash
# Example using if statements

echo "Please enter a yes or no: "


read user_response

# Note the spaces


# following `[` and before `]` are important .
if [ $user\_response = yes ]
then
echo "You entered yes."
elif [ $user\_response = no ]
# "elif" is the same as "else if"
then
echo "You entered no."
else
echo "You didn 't enter yes or no."
fi
# "if" statements are always ended with "fi ".

We can also check, e.g., if a file or directory exists:

QE‑SSP/scripts/if2.sh

#!/ bin/bash
# Check if the directory " tmpdir " exists , and if not
, create it , then check
# if the file " tmpdir / testfile " exists , and if not ,
create it.

dirname="tmpdir"
filename="testfile"

if [ ! -d "$dirname" ]
# The "!" is logical negation
# -d tests that a file exists and is a directory .
328 | Productivity Tools

then
mkdir $dirname
fi

if [ ! -f "$dirname/$filename" ]
# -d tests that a file exists and is a regular file
(i.e., not a directory ).
then
touch "$dirname/$filename"
fi

Arithmetic and testing


To test numeric values, the (( ... )) construction can be used. For
example:

QE‑SSP/scripts/arithmetictest.sh

#!/ bin/bash
# Example showing the use of the (( )) construction

var1 =4
var2 =5
var3 =8

if (( var1 + var2 > var3 ))


# Note within the (( ))
# don 't use $ symbols before variables .
then
echo "$var1 + $var2 > $var3"
else
echo "$var1 + $var2 <= $var3"
fi

# We can also use the construction


# to perform basic arithmetic
var4=$(( var1 var3 ))echo "\$var1 $var3 = $var4"

Looping
In bash shell, we can use the for loops to iterate a variable over a
range of values. For example:
Quantum ESPRESSO Course for Solid‐State Physics | 329
QE‑SSP/scripts/loop1.sh

#!/ bin/bash

# Simple for loop example .


# This construction loops
# over a space separated list of values .

# A variable whose contents contains spaces


# would work in the same way.

for i in 1 2 3
do
echo "Iteration number $i"
done

The for loop can be used to apply a command repeatedly to a set


of files. For example:

QE‑SSP/scripts/loop2.sh

#!/ bin/bash

# Example showing a simple for loop


# over a list of arguments used to convert
# a set of data files with comma separated columns
# to tab separated columns .

for csvfile in "$(ls .csv)"dodatfile="\$(basename


\$csvfile .csv).dat"sed 's/,/
/g' \$csvfile >
\$datfiledone

In the above example, basename is a tool to strip the suffix from a file.
Here we use it to construct a new filename with the .dat extension.
Bash also supports numeric loop ranges using the syntax
{start..finish..increment). For example:

#!/ bin/bash
# Example of for loop with numeric increments

for i in {0..6..2}
do
echo "The value of i is $i"
done
330 | Productivity Tools

In addition to the for loops, the bash shell also supports while
loops, where a set of commands are repeated continuously when a
given condition is true. For example:

QE‑SSP/scripts/while1.sh

#!/ bin/bash
# Example of while loop in bash

counter =0

# Here -lt means less than


while [ $counter -lt 10 ]
do
echo $counter
counter=$(( counter + 1))
done

It is often convenient to use while loops to operate on every line


of a file. For example:

QE‑SSP/scripts/while2.sh

#!/ bin/bash
# Example of while loop reading lines from a file

linenumber =0

while read line


do
linenumber=$(( linenumber + 1))
echo "$linenumber: $line"
# This will prepend each line of a file with its
line number .
done < test.txt

Arguments
We can pass arguments to bash scripts from the command line. For
example:

QE‑SSP/scripts/argument1.sh

#!/ bin/bash
# Example using command line arguments .
Quantum ESPRESSO Course for Solid‐State Physics | 331

# Call this script with several arguments .


echo "The first argument is $1"
echo "The second argument is $2"
echo "The number of arguments is $#"
echo "The full list of arguments is $@"

We can loop over arguments using a for loop as follows:

QE‑SSP/scripts/argument2.sh

#!/ bin/bash
# Example using a for loop to iterate over command
line arguments .

for arg in $@
do
echo $arg
done

6.3.3 Quantum ESPRESSO job script

Now let us make a simple script for submitting batch jobs of Quantum
ESPRESSO calculations. The script runEnDOS.sh includes Quantum
ESPRESSO calculations of SCF, NSCF for obtaining DOS, and NSCF for
obtaining the energy dispersion.

QE‑SSP/gete/runEnDOS.sh

#!/ bin/bash
# Simple QE job script
# This script can be re -used for other materials
# Later we just need to change
# the following 3 variables :
# first is the Quantum ESPRESSO binary location
export QEBIN =/ home/quantum/opt/q-e/bin/
# second is the number of CPUs
export NCPU =4
# last is the prefix of the calculations
export PREFIX=gete
# QE binaries that we want to use
export PW=$QEBIN/pw.x
export DOS=$QEBIN/dos.x
332 | Productivity Tools

export BND=$QEBIN/bands.x
# define variables for calculations of
# SCF , DOS , and energy dispersion
export SCF=$PREFIX.scf
export NSCFD=$PREFIX.nscfdos
export POSTD=$PREFIX.dos
export NSCFB=$PREFIX.nscfbands
export POSTB=$PREFIX.bands
echo "start SCF"
mpirun -np $NCPU $PW < $SCF.in > $SCF.out
echo "SCF done"
echo "start NSCF DOS"
mpirun -np $NCPU $PW < $NSCFD.in > $NSCFD.out
echo "NSCF DOS done"
echo "start Postprocessing DOS"
mpirun -np $NCPU $DOS < $POSTD.in > $SCF.out
echo "Postprocessing DOS done"
echo "start NSCF BANDS"
mpirun -np $NCPU $PW < $NSCFB.in > $NSCFB.out
echo "NSCF BANDS done"
echo "start Postprocessing BANDS"
mpirun -np $NCPU $BND < $POSTB.in > $POSB.out
echo "Postprocessing BANDS done"
echo "All jobs are finished"

The script can be run in the background using the nohup


command. This method will ensure that we can leave our terminal
safely and continue with other works.

$ nohup runEnDOS.sh &

6.4 Plotting and visualization tools

Plotting a graph is essential for the readers of the scientific paper to


understand the numerical output values in a consistent and scientific
way. There are several libraries in the Python programming language
that can be used for plotting. Matplotlib is one of the most well‐
known and free Python libraries that can be used to produce a variety
of plots and graphics in many styles and can be interacted with in
flexible ways. Therefore, in this book, we choose Matplotlib in the
Python environment as the platform to produce graphical outputs
Quantum ESPRESSO Course for Solid‐State Physics | 333
from Quantum ESPRESSO data. The Matplotlib official site at https:
//matplotlib.org/users/tutorials.html gives us a full list of
tutorials and various options we can adopt for any visualization
project. We also use the JupyterLab (https://jupyter.org/), which
is the next‐generation web‐based user interface for Python and
Matplotlib. The installation of Python, Matplotlib, JupyterLab, along
with other important Python libraries, is already explained in Sec.
2.2. This section will show you the most direct and relevant practice
of using Matplotlib that will give us a reasonable publication quality,
which is good enough to appear in a scientific paper.
Hereafter, we will explain how to write a Python plotting script
file with the *.ipynb extension, which can be opened and run directly
by JupyterLab as

$ jupyter -lab plot.ipynb

In the Python script, we have to put import statements to load


some libraries related to the plotting and numerical computations.
We will load Matplotlib along with NumPy libraries for our purpose.
It is also recommended to create a “short form” of the library (e.g.,
mpl for matplotlib) so that we can refer to its functions using the
this short form instead of typing out matplotlib every single time.
The # sign is used for comments.

QE‑SSP/scripts/plot.ipynb

1 # Import required packages


2 import matplotlib as mpl
3 import matplotlib.pyplot as plt
4 import numpy as np

Now suppose we have a data file called “gr.dos”, which can be


found in QE-SSP/scripts/gr.dos. The readers can also obtain the
gr.dos file by running the tutorial in Sec. 3.3.2. The gr.dos file is the
output file of the phonon density of states (phonon DOS) of graphene,
which contains four columns separated by space. The 1st column
corresponds to the frequency ω in cm−1 , the 2nd column is the total
phonon DOS in state/cm−1 /unit‐cell, and 3rd and 4th columns are
the partial phonon DOS of the C atom number 1 and number 2,
334 | Productivity Tools

respectively. We can load this data using the loadtxt function from
the NumPy package that we imported as np.

QE‑SSP/scripts/plot.ipynb

1 # Use numpy.loadtxt to import our data


2 omega , ph_tot , ph_c1 , ph_c2 = np.loadtxt('gr.dos',
unpack=True)

In the above blocks, we read the variable set omega, ph_tot,


ph_c1, and ph_c2 by the np.loadtxt function. By setting
unpack=True (line 2), we transpose each column into an array.

6.4.1 Plain plotting of the data

Once we have loaded the data, we can make a default plot by


plt.figure() (the short form of matplotlib.pyplot.figure())
and inspect the dataset with the following code:

QE‑SSP/scripts/plot.ipynb

1 # Create figure and add axes object


2 fig = plt.figure ()
3 ax = fig.add_axes ([0, 0, 1, 1])
4
5 # Plot our data
6 ax.plot(omega , ph_tot)
7 ax.plot(omega , ph_c1)
8
9 # Save and show our data
10 plt.savefig('plot.pdf', bbox_inches='tight ')
11 plt.show ()

Some brief explanations for this block of code are as follows:

• fig = plt.figure(): assigns a figure object with the default


setting of Matplotlib.
• ax = fig.add_axes([0, 0, 1, 1]): defines default axes of
the fig object with the axis origin (the corner of the axis at the
bottom left) located at (0, 0), width = 1, and height = 1 in the
scaled units.
Quantum ESPRESSO Course for Solid‐State Physics | 335

Figure 6.12 A default plot of gr.dos, which is not suitable for a scientific paper.

• ax.plot(omega, ph_tot): calls the plot function for the ax


axes defined earlier, for which we plot ph_tot as a function of
omega.
• ax.plot(omega, ph_c1): on the same ax axes, calls the plot
function again to plot ph_c1 as a function of omega.
• plt.savefig('plot.pdf', bbox_inches='tight'):
saves the figure to “plot.pdf”, in which the setting
bbox_inches='tight' will remove all of the extra white
space around the figure.
• plt.show(): displays the figure on the web‐based user
interface of JupyterLab.

We can see that the plot shown in Fig. 6.12 has a few meanings
already, but we notice that the default Matplotlib settings do not give
the figure with sufficient publication quality. For example, there is no
axis label, the font size is too small, and we may also not like the tick
marks outside the main frame. As we change some of the parameters
described in the next subsections, we can get a better looking plot
that is good enough for publication as shown in Fig. 6.13.
It is safe to say that the appearance of Fig. 6.13 is better than
Fig. 6.12 in many ways. In particular, the plot now has axis labels
for variables along with their units, readable fonts with a reasonable
size, standard colors, clear tick marks for both the major and minor
336 | Productivity Tools

Figure 6.13 An improved, polished version of Fig. 6.12.

ticks, and also well‐placed annotations or legends to distinguish two


plots of different samples. Note that to clearly distinguish the two
plots, if we use the only color, it would be troublesome for black‐
white printing or for people who have difficulties in recognizing
colors. We should use both different colors and line styles at the same
time, such as “blue‐solid line” and “red‐dashed line”. All such details
can be precisely managed through some Matplotlib settings that will
be discussed below.

6.4.2 Changing general plot parameters

There are at least three general parameters that we need to set at the
beginning of the Python plotting script: (1) font, (2) font size, and (3)
axis line width. These three are essentially global parameters defined
at the beginning of the Python script that we do not change later, i.e.,
we do not have to explicitly set font/sizes for each label down the
line). We can add the following code before we generate any figures:

QE‑SSP/scripts/plot.ipynb

1 # Edit the font , font size , and axes width


2 mpl.rcParams['font.family '] = 'Arial '
Quantum ESPRESSO Course for Solid‐State Physics | 337
3 plt.rcParams['font.size '] = 22
4 plt.rcParams['axes.linewidth '] = 2

This block of code is typically put after importing packages.


You may change the font with other fonts you like, but it is
recommended to use the “Sans” font family, such as “Helvetica”,
“Arial”, and “Verdana”. The “Sans” font family is suitable for reading
the font clearly even when we reduce the size of the graph. If you
are not sure whether or not the font is available, you can type the
following command in Python and see the output that lists all the font
names available to Matplotlib in your computer.

QE‑SSP/scripts/plot.ipynb

1 import matplotlib.font_manager as fm
2
3 # Collect all the available fonts
4 font_names = [f.name for f in fm.fontManager.ttflist
]
5 print(font_names)

6.4.3 Setting axes and ticks

We should not forget to add a label to each axis. The tick widths and
lengths should be edited to match our axis parameters. If we have
minor ticks, we can also specify by a parameter which='mirror'.

QE‑SSP/scripts/plot.ipynb

1 # Add the x and y-axis labels


2 ax.set_xlabel(r'Frequency (cm$ ^{-1}$)')
3 ax.set_ylabel(r'Phonon DOS (state/cm$ ^{-1}$/unit -
cell)')
4 # Set the axis limits
5 ax.set_xlim (0, 1700)
6 ax.set_ylim (0, 0.025)
7 # Edit the major and minor ticks
8 ax.xaxis.set_tick_params(which='major ', size =10,
9 width=2, direction='in', top='on')
10 ax.xaxis.set_tick_params(which='minor ', size=6,
11 width=2, direction='in', top='on')
12 ax.yaxis.set_tick_params(which='major ', size =10,
338 | Productivity Tools

13 width=2, direction='in', right='on')


14 ax.yaxis.set_tick_params(which='minor ', size=6,
15 width=2, direction='in', right='on')
16 # Edit the major and minor ticks of x and y axes
17 ax.xaxis. set_major_locator(mpl.ticker.
MultipleLocator (500))
18 ax.xaxis. set_minor_locator(mpl.ticker.
MultipleLocator (100))
19 ax.yaxis. set_major_locator(mpl.ticker.
MultipleLocator (0.01))
20 ax.yaxis. set_minor_locator(mpl.ticker.
MultipleLocator (0.002))

Note that Matplotlib can accept special mathematical formatting


from the LaTeX such as cm$^{-1}$.

6.4.4 Annotations and saving the plots

After all basic settings are ready, we can plot the dataset and give
annotations or legends to the plots.

QE‑SSP/scripts/plot.ipynb

1 # Plot our data


2 ax.plot(omega , ph_tot , linewidth =2, color='blue ',
linestyle='solid ')
3 ax.plot(omega , ph_c1 , linewidth =2, color='red',
linestyle='dashed ')
4
5 # Add annotate
6 ax.annotate('Total ', color='blue ',
7 xy =(1390 , 0.015) , xycoords='data ',
8 xytext =(1000 , 0.018) , textcoords='data ',
9 arrowprops=dict(arrowstyle="->", color='
blue ')
10 )
11 ax.annotate('C atom ', color='red',
12 xy =(1300 , 0.002) , xycoords='data ',
13 xytext =(950 , 0.01) , textcoords='data ',
14 arrowprops=dict(arrowstyle="->", color='
red')
15 )
16
17 # Save and show figure
18 plt.savefig('plot -rev.pdf', bbox_inches='tight ')
Quantum ESPRESSO Course for Solid‐State Physics | 339
19 plt.show ()

At the very last, do not forget to save the plot. The PDF format
is recommended because it is a vector image that will not lose the
resolution.

6.4.5 Creating and using your Matplotlib style

When the readers want to plot many figures with the same style,
making your Matplotlib style is helpful to save time. You do not
need to copy/paste settings in Matplotlib whenever you create a new
figure. By importing a style file, you can ensure consistency while still
maintaining the ability to override settings as you wish within the
individual scripts.
The readers can find a style file for this book at
QE-SSP/matplotlib/sci.mplstyle. The sci.mplstyle file
can open and edit by any text editor for example, nano:

$ nano sci.mplstyle

QE‑SSP/matplotlib/sci.mplstyle

1 # Figure properties
2 figure.figsize : 6.5, 5
3
4 # Font properties
5 font.family : Arial
6 font.size : 22
7
8 #### LaTeX
9 mathtext.default : regular
10
11 # Axes properties
12 axes.titlesize : medium # fontsize of the axes
title
13 axes.titlepad : 10 # pad between axes and
title in points
14 axes.titleweight : normal # font weight for axes
title
15 axes.linewidth : 2 # edge linewidth
340 | Productivity Tools

16 axes.labelpad : 10 # space between label


and axis
17 axes.prop_cycle : cycler(color =['1f77b4 ', 'd62728
', '2ca02c ', 'ff7f0e ', '9467 bd', '8c564b ', '
e377c2 ', '7f7f7f ', 'bcbd22 ', '17 becf '])
18
19 # Tick properties
20 # x-axis
21 xtick.top : True
22 xtick.direction : in
23 xtick.major.size : 9
24 xtick.major.width : 2
25 xtick.major.pad : 4
26 xtick.minor.visible: True
27 xtick.minor.size : 6
28 xtick.minor.width : 2
29 xtick.minor.pad : 4
30
31 # y-axis
32 ytick.right : True
33 ytick.direction : in
34 ytick.major.size : 9
35 ytick.major.width : 2
36 ytick.major.pad : 4
37 ytick.minor.visible: True
38 ytick.minor.size : 6
39 ytick.minor.width : 2
40 ytick.minor.pad : 4
41
42 # Line properties
43 lines.linewidth : 2
44 lines.markersize : 10
45
46 # Legend properties
47 legend.framealpha : 1
48 legend.frameon : False
49 legend.fontsize : 19
50
51 # Increase the default DPI , and change the file type
from png to pdf
52 savefig.dpi : 600 # figure dots per inch
53 savefig.format : pdf # png , ps , pdf , svg
54 savefig.bbox : tight # {tight , standard}
55 savefig.transparent: True # transparent background

The readers can modify the file freely. The details for each setting
can be found at https://matplotlib.org/stable/tutorials/
Quantum ESPRESSO Course for Solid‐State Physics | 341

Figure 6.14 Energy dispersion (left) and density of state (DOS) (right) of
GeTe.

introductory/customizing.html. Now, when we want to use this


style, we need to add the following line in our Python script:

plt.style.use('~/QE -SSP/matplotlib/sci.mplstyle ')

It is important to note that the directory path of sci.mplstyle must


be correct.

6.4.6 Plotting DOS and energy dispersion

With the knowledge of Python and Matplotlib we have obtained


before, we can create our own script for plotting DOS and band
structure of Quantum ESPRESSO calculation outputs. We show an
example for GeTe in Fig. 6.14 with the following plot-gete.ipynb
script.

QE‑SSP/gete/plot‑gete.ipynb

1 # Import the necessary packages and modules


2 import matplotlib.pyplot as plt
3 plt.style.use('../ matplotlib/sci.mplstyle ')
4 import numpy as np
5
6 # Load data from gete.bands.gnu
7 data = np.loadtxt('gete.bands.gnu')
342 | Productivity Tools

8 k = np.unique(data[:, 0])
9 bands = np.reshape(data[:, 1], (-1, len(k)))
10 # Load data from gete.dos
11 ener , dos , idos = np.loadtxt('gete.dos', unpack=True
)
12
13 # Fermi energy from ./out /*. xml :
14 HOMO = 2.635710373417968e-1
15 LUMO = 2.758546355831248e-1
16 unitE = 27.2114
17 E_F = (HOMO+LUMO)* unitE /2
18
19 # Set high -symmetry points from *. nscf.in file
20 rW = k[0]; rL = k[50]; rU = k[80]; rX = k[100]; rG =
k[150]; rK = k[200]
21
22 # Create figure object
23 fig = plt.figure(figsize =(6, 3))
24 # Add x and y-axes
25 axE = fig.add_axes ([0.00 , 0.0, 0.60, 1])
26 axD = fig.add_axes ([0.70 , 0.0, 0.30, 1])
27
28 # Plot band structure
29 for band in range(len(bands)):
30 axE.plot(k, bands[band , :]-E_F , c='b')
31 # Plot dotted line at Fermi energy
32 axE.axhline (0, c='gray ', ls=':')
33 # Plot dotted lines at high -symmetry points
34 axE.axvline(rL , c='gray ')
35 axE.axvline(rU , c='gray ')
36 axE.axvline(rX , c='gray ')
37 axE.axvline(rG , c='gray ')
38 # Add labels for high -symmetry points
39 axE.set_xticks ([rW , rL , rU , rX , rG , rK])
40 axE. set_xticklabels (['W', 'L', 'U', 'X', '$\Gamma$ ',
'K'])
41 # Hide x-axis minor ticks
42 axE.tick_params(axis='x', which='both ', length =0)
43 # Set the axis limits
44 axE.set_xlabel('')
45 axE.set_ylabel('Energy (eV)')
46 # Set the axis limits
47 axE.set_xlim(rW , rK)
48 axE.set_ylim (-2.2, 2.2)
49
50 # Plot the DOS
51 axD.plot(dos , ener -E_F , c='r')
52 # Set the axis limits
53 axD.set_xlim (0, 2)
Quantum ESPRESSO Course for Solid‐State Physics | 343
54 axD.set_ylim (-2.2, 2.2)
55 # Add the x label
56 axD.set_xlabel('DOS (state/eV/u.c.)')
57
58 # Save figure to the pdf file
59 plt.savefig('GeTeEnDOS.pdf')
60 # Show figure
61 plt.show ()
Bibliography

Adamo, C. and Barone, V. (1999). Toward reliable density


functional methods without adjustable parameters: The pbe0
model, J. Chem. Phys. 110, pp. 6158–6170.
Ashcroft, N. W. (1966). Electron‐ion pseudopotentials in metals,
Phys. Lett. 23, pp. 48–50.
Atkinson, K. E. (1988). An Introduction to Numerical Aanalysis
(John Wiley & Sons).
Bardeen, J. (1936). Theory of the work function. II. The surface
double layer, Phys. Rev. 49, p. 653.
Baroni, S., De Gironcoli, S., Dal Corso, A. and Giannozzi, P.
(2001). Phonons and related crystal properties from density‐
functional perturbation theory, Rev. Mod. Phys. 73, p. 515.
Becke, A. D. (1988). Density‐functional exchange‐energy approx‐
imation with correct asymptotic behavior, Phys. Rev. A 38, p.
3098.
Becke, A. D. (1993). Density‐functional thermochemistry. III. The
role of exact exchange, J. Phys. Chem. 98, p. 5648–5652.
Becke, A. D. and Johnson, E. R. (2007). Exchange‐hole dipole
moment and the dispersion interaction revisited, J. Chem.
Phys. 127, p. 154108.
Bengtsson, L. (1999). Dipole correction for surface supercell
calculations, Phys. R. B 59, p. 12301.
Berland, K., Chakraborty, D. and Thonhauser, T. (2019). van
der Waals density functional with corrected c6 coefficients,
Physical Review B 99, 19, p. 195418.
Blount, E. I. (1962). Formalisms of Band Theory (Academic Press).
346 | Bibliography

Born, M. and Oppenheimer, R. (1927). Zur quantentheorie der


molekeln, Annalen der Physik 389, 20, pp. 457–484.
Brack, M. (1993). The physics of simple metal clusters: self‐
consistent jellium model and semiclassical approaches, Rev.
Mod. Phys. 65, p. 677.
Broyden, C. G. (1970). The convergence of a class of double‐rank
minimization algorithms 1. General considerations, J. Inst.
Math. Appl. 6, pp. 76–90.
Cao, Y., Fatemi, V., Fang, S., Watanabe, K., Taniguchi, T., Kaxiras, E.
and Jarillo‐Herrero, P. (2018). Unconventional superconduc‐
tivity in magic‐angle graphene superlattices, Nature 556, pp.
43–50.
Carr Jr, W. J., Coldwell‐Horsfall, R. A. and Fein, A. E. (1961).
Anharmonic contribution to the energy of a dilute electron
gas‐interpolation for the correlation energy, Phys. Rev. 124,
p. 747.
Ceperley, D. M. and Alder, B. J. (1980). Ground state of the electron
gas by a stochastic method, Phys. Rev. Lett. 45, p. 566.
Chakraborty, D., Berland, K. and Thonhauser, T. (2020). Next‐
generation nonlocal van der Waals density functional, J. Chem.
Theory Comput. 16, pp. 5893–5911.
Chowdhury, M. T., Saito, R. and Dresselhaus, M. S. (2012).
Polarization dependence of X‐ray absorption spectra in
graphene, Phys. Rev. B 85, p. 115410.
Dion, M., Rydberg, H., Schröder, E., Langreth, D. C. and Lundqvist,
B. I. (2004). Van der waals density functional for general
geometries, Phys. Rev. Lett. 92, p. 246401.
Dirac, P. A. M. (1930). Note on exchange phenomena in the
Thomas atom, in Proc. Cambridge Phil. Soc., Vol. 26 (Cam‐
bridge University Press), pp. 376–385.
Dresselhaus, M. S., Dresselhaus, G. and Jorio, A. (2008). Group
Theory: Application to the Physics of Condensed Matter
(Springer, Berlin).
Dynes, R. C. (1972). McMillan’s equation and the Tc of supercon‐
ductors, Solid State Commun. 10, pp. 615–618.
Quantum ESPRESSO Course for Solid‐State Physics | 347
Eda, G., Yamaguchi, H., Voiry, D., Fujita, T., Chen, M. and Chhowalla,
M. (2011). Photoluminescence from chemically exfoliated
MoS2 , Nano Lett. 11, 12, pp. 5111–5116.
Eliashberg, G. M. (1960). Interactions between electrons and
lattice vibrations in a superconductor, Sov. Phys. JETP 11, 3,
pp. 696–702.
Emery, C., N.and Hérold, Marêché, J. F. and Lagrange, P. (2009).
Synthesis and superconducting properties of CaC6 , Sci.
Technol. Adv. Mater 9, p. 044102.
Ewald, P. P. (1921). Die berechnung optischer und elektrostatis‐
cher gitterpotentiale, Annalen der Physik 369, pp. 253–287.
Fermi, E. (1928). Eine statistische methode zur bestimmung
einiger eigenschaften des atoms und ihre anwendung auf die
theorie des periodischen systems der elemente, Z. Physik 48,
pp. 73–79.
Feynman, R. P. (1939). Forces in molecules, Phys. Rev. 56, p. 340.
Fletcher, R. (1991). A new variational result for quasi‐newton
formulae, SIAM J. Optim. 1, pp. 18–21.
Fock, V. (1930). Näherungsmethode zur lösung des quanten‐
mechanischen mehrkörperproblems, Zeitschrift für Physik
61, 1‐2, pp. 126–148.
Fretigny, C., Saito, R. and Kamimura, H. (1989). Electronic
structures of unoccupied bands in graphite, J. Phys. Soc. Jpn.
58, pp. 2098–2108.
Fu, C. L. and Ho, K. M. (1983). First‐principles calculation of
the equilibrium ground‐state properties of transition metals:
Applications to Nb and Mo, Phys. Rev. B 28, p. 5480.
Geim, A. K. and Novoselov, K. S. (2007). The rise of graphene, Nat.
Mater. 6, p. 183–191.
Gell‐Mann, M. and Brueckner, K. A. (1957). Correlation energy of
an electron gas at high density, Phys. Rev. 106, p. 364.
Giannozzi, P., Baroni, S., Bonini, N., Calandra, M., Car, R., Cavazzoni,
C., Ceresoli, D., Chiarotti, G. L., Cococcioni, M., Dabo, I., Corso,
A. D., de Gironcoli, S., Fabris, S., Fratesi, G., Gebauer, R.,
Gerstmann, U., Gougoussis, C., Kokalj, A., Lazzeri, M., Martin‐
Samos, L., Marzari, N., Mauri, F., Mazzarello, R., Paolini,
S., Pasquarello, A., Paulatto, L., Sbraccia, C., Scandolo, S.,
348 | Bibliography

Sclauzero, G., Seitsonen, A. P., Smogunov, A., Umari, P. and


Wentzcovitch, R. M. (2009). QUANTUM ESPRESSO: a modular
and open‐source software project for quantum simulations of
materials, J. Phys. Condens. Matter 21, p. 395502.
Goldfarb, D. (1970). A family of variable‐metric methods derived
by variational means, Math. Comp. 24, pp. 23–26.
Grimme, S. (2004). Accurate description of van der Waals
complexes by density functional theory including empirical
corrections, J. Comput. Chem. 25, pp. 1463–1473.
Grimme, S., Antony, J., Ehrlich, S. and Krieg, H. (2010). A consistent
and accurate ab initio parametrization of density functional
dispersion correction (DFT‐D) for the 94 elements H‐Pu, J.
Chem. Phys. 132, p. 154104.
Hartree, D. R. (1928). The wave mechanics of an atom with a non‐
coulomb central field. Part I. Theory and methods, in Math.
Proc. Camb. Philos. Soc., Vol. 24 (Cambridge University Press),
pp. 89–110.
Heine, V. and Abarenkov, I. V. (1964). A new method for the
electronic structure of metals, Phil. Mag. 9, pp. 451–465.
Hellmann, H. (1937). Einführung in die quantenchemie (Deuticke,
Leipzig).
Heyd, J., Scuseria, G. E. and Ernzerhof, M. (2003). Hybrid
functionals based on a screened coulomb potential, J. Chem.
Phys. 118, pp. 8207–8215.
Hohenberg, P. and Kohn, W. (1964). Inhomogeneous electron gas,
Phys. Rev. 136, p. B864.
Huang, Y. L., Chen, Y., Zhang, W., Quek, S. Y., Chen, C. H., Li, L. J.,
Hsu, W. T., Chang, W. H., Zheng, Y. J., Chen, W. and Wee, A.
T. S. (2015). Bandgap tunability at single‐layer molybdenum
disulphide grain boundaries, Nat. Commun. 6, pp. 1–8.
Jackson, J. D. (1999). Classical Electrodynamics (3rd ed.) (Wiley
New York).
Kittel, C. (1976). Introduction to Solid State Physics (Wiley New
York).
Kohn, W. (1959). Image of the fermi surface in the vibration
spectrum of a metal, Phys. Rev. Lett. 2, p. 393.
Quantum ESPRESSO Course for Solid‐State Physics | 349
Kohn, W. and Sham, L. J. (1965). Self‐consistent equations
including exchange and correlation effects, Phys. Rev. 140, p.
A1133.
Latzke, D. W., Zhang, W., Suslu, A., Chang, T. R., Lin, H., Jeng, H. T.,
Tongay, S., Wu, J., Bansil, A. and Lanzara, A. (2015). Electronic
structure, spin‐orbit coupling, and interlayer interaction in
bulk MoS2 and WS2 , Phys. Rev. B 91, p. 235202.
Lazzeri, M. and Mauri, F. (2003). First‐principles calculation of
vibrational raman spectra in large systems: Signature of small
rings in crystalline SiO2 , Phys. Rev. Lett. 90, p. 036401.
Lazzeri, M. and Mauri, F. (2006). Nonadiabatic Kohn anomaly in a
doped graphene monolayer, Phys. Rev. Lett. 97, p. 266407.
Lee, C., Yang, W. and Parr, R. G. (1988). Development of the colle‐
salvetti correlation‐energy formula into a functional of the
electron density, Phys. Rev. B 37, p. 785.
Lee, K., Murray, E. D., Kong, L., Lundqvist, B. I. and Langreth, D. C.
(2010). Higher‐accuracy van der Waals density functional,
Phys. Rev. B 82, p. 081101.
Li, H., Zhang, Q., Yap, C. C. R., Tay, B. K., Edwin, T. H. T., Olivier,
A. and Baillargeat, D. (2012). From bulk to monolayer MoS2 :
evolution of raman scattering, Adv. Funct. Mater. 22, pp.
1385–1390.
Li, Y., Chernikov, A., Zhang, X., Rigosi, A., Hill, H. M., Van Der Zande,
A. M., Chenet, D. A., Shih, E. M., Hone, J. and Heinz, T. F.
(2014). Measurement of the optical dielectric function of
monolayer transition‐metal dichalcogenides: MoS2 , MoSe2 ,
WS2 , and WSe2 , Phys. Rev. B 90, p. 205422.
Lieb, E. H. and Oxford, S. (1981). Improved lower bound on the
indirect coulomb energy, Int. J. Quantum Chem. 19, pp. 427–
439.
Liu, H. L., Yang, T., Chen, J. H., Chen, H. W., Guo, H., Saito, R., Li, M. Y.
and Li, L. J. (2020). Temperature‐dependent optical constants
of monolayer MoS2 , MoSe2 , WS2 , and WSe2 : spectroscopic
ellipsometry and first‐principles calculations. Sci. Rep. 10, p.
15282.
Madelung, O. (1978). Introduction to Solid‑State Theory
(Springer).
350 | Bibliography

Marder, M. P. (2010). Condensed Matter Physics (John Wiley &


Sons).
Marzari, N., Mostofi, A. A., Yates, J. R., Souza, I. and Vanderbilt, D.
(2012a). Maximally localized Wannier functions: Theory and
applications, Rev. Mod. Phys. 84, pp. 1419–1475.
Marzari, N., Mostofi, A. A., Yates, J. R., Souza, I. and Vanderbilt, D.
(2012b). Maximally localized Wannier functions: Theory and
applications, Rev. Mod. Phys. 84, p. 1419.
Marzari, N. and Vanderbilt, D. (1997). Maximally localized
generalized Wannier functions for composite energy bands,
Phys. Rev. B 56, 20, p. 12847.
Marzari, N., Vanderbilt, D., De Vita, A. and Payne, M. C. (1999).
Thermal contraction and disordering of the Al (110) surface,
Phys. Rev. Lett. 82, p. 3296.
McMillan, W. L. (1968). Transition temperature of strong‐coupled
superconductors, Phys. Rev. 167, p. 331.
Mermin, N. D. (1965). Thermal properties of the inhomogeneous
electron gas, Phys. Rev. 137, p. A1441.
Methfessel, M. P. A. T. and Paxton, A. T. (1989). High‐precision
sampling for Brillouin‐zone integration in metals, Phys. Rev.
B 40, p. 3616.
Monkhorst, H. J. and Pack, J. D. (1976). Special points for brillouin‐
zone integrations, Phys. Rev. B 13, p. 5188.
Mostofi, A. A., Yates, J. R., Lee, Y. S., Souza, I., Vanderbilt, D.
and Marzari, N. (2008). Wannier90: A tool for obtaining
maximally‐localised Wannier functions, Comput. Phys. Com‑
mun. 178, pp. 685–699.
Ohta, T., Bostwick, A., McChesney, J. L., Seyller, T., Horn, K. and
Rotenberg, E. (2007). Interlayer interaction and electronic
screening in multilayer graphene investigated with angle‐
resolved photoemission spectroscopy, Phys. Rev. Lett. 98, p.
206802.
Ohta, T., Bostwick, A., Seyller, T., Horn, K. and Rotenberg,
E. (2006). Controlling the electronic structure of bilayer
graphene, Science 313, pp. 951–954.
Quantum ESPRESSO Course for Solid‐State Physics | 351
Otero‐De‐La‐Roza, A. and Johnson, E. R. (2012). Van der waals
interactions in solids using the exchange‐hole dipole moment
model, J. Chem. Phys. 136, p. 174109.
Parr, R. G. and Yang, W. (1989). Density‑Functional Theory of Atoms
and Molecules (Oxford University Press).
Pauli, W. (1925). Über den zusammenhang des abschlusses der
elektronengruppen im atom mit der komplexstruktur der
spektren, Zeitschrift für Physik 31, 1, pp. 765–783.
Perdew, J. P., Burke, K. and Ernzerhof, M. (1996a). Generalized
gradient approximation made simple, Phys. Rev. Lett. 77, p.
3865.
Perdew, J. P., Chevary, J. A., Vosko, S. H., Jackson, K. A., Pederson,
M. R., Singh, D. J. and Fiolhais, C. (1992). Atoms, molecules,
solids, and surfaces: Applications of the generalized gradient
approximation for exchange and correlation, Phys. Rev. B 46,
p. 6671.
Perdew, J. P., Ernzerhof, M. and Burke, K. (1996b). Rationale for
mixing exact exchange with density functional approxima‐
tions, J. Chem. Phys. 105, pp. 9982–9985.
Perdew, J. P. and Levy, M. (1983). Physical content of the
exact Kohn‐Sham orbital energies: band gaps and derivative
discontinuities, Phy. Rev. Lett. 51, p. 1884.
Perdew, J. P. and Wang, Y. (1992). Accurate and simple analytic
representation of the electron‐gas correlation energy, Phys.
Rev. B 45, p. 13244.
Perdew, J. P. and Zunger, A. (1981). Self‐interaction correction
to density‐functional approximations for many‐electron sys‐
tems, Phys. Rev. B 23, p. 5048.
Pickett, W. E. (1989). Pseudopotential methods in condensed
matter applications, Comput. Phys. Rep. 9, pp. 115–197.
Pimenta, M. A., Dresselhaus, G., Dresselhaus, M. S., Cançado, L. G.,
Jorio, A. and Saito, R. (2007). Studying disorder in graphite‐
based systems by Raman spectroscopy, Physical Chemistry
Chemical Physics 9, pp. 1276–1291.
Pizzi, G., Vitale, V., Arita, R., Blügel, S., Freimuth, F., Géranton,
G., Gibertini, M., Gresch, D., Johnson, C., Koretsune, T. et al.
352 | Bibliography

(2020). Wannier90 as a community code: new features and


applications, J. Phys.: Cond. Matt. 32, p. 165902.
Poncé, S., Margine, E. R., Verdi, C. and Giustino, F. (2016). Epw:
Electron–phonon coupling, transport and superconducting
properties using maximally localized Wannier functions,
Comput. Phys. Commun. 209, pp. 116–133.
Rasamani, K. D., Alimohammadi, F. and Sun, Y. (2017). Interlayer‐
expanded MoS2 , Mater. Today 20, pp. 83–91.
Razado‐Colambo, I., Avila, J., Vignaud, D., Godey, S., Wallart,
X., Woodruff, D. P. and Asensio, M. C. (2018). Structural
determination of bilayer graphene on SiC (0001) using
synchrotron radiation photoelectron diffraction, Sci. Rep. 8,
pp. 1–10.
Roch, J. G., Froehlicher, G., Leisgang, N., Makk, P., Watanabe, K.,
Taniguchi, T. and Warburton, R. J. (2019). Spin‐polarized
electrons in monolayer MoS2 , Nat. Nanotech. 14, pp. 432–436.
Roothaan, C. C. J. (1951). New developments in molecular orbital
theory, Rev. Mod. Phys. 23, p. 69.
Sabatini, R., Gorni, T. and De Gironcoli, S. (2013). Nonlocal van der
Waals density functional made simple and efficient, Phys. Rev.
B 87, p. 041108.
Saito, R., Fujita, M., Dresselhaus, G. and Dresselhaus, M. S. (1992).
Electronic structure of chiral graphene tubules, Appl. Phys.
Lett. 60, pp. 2204–2206.
Saito, R., Grüneis, A., Cançado, L. G., Pimenta, M. A., Jorio, A.,
Souza Filho, A. G., Dresselhaus, M. S. and Dresselhaus, G.
(2002a). Double resonance Raman spectra in disordered
graphite and single wall carbon nanotubes, Mol. Cryst. Liq.
Cryst. 387, pp. 287–296.
Saito, R., Grüneis, A., Samsonidze, G. G., Brar, V. W., Dresselhaus, G.,
Dresselhaus, M. S., Jorio, A., Cançado, L. G., Fantini, C., Pimenta,
M. A. and Souza Filho, A. G. (2003). Double resonance Raman
spectroscopy of single wall carbon nanotubes, New J. Phys. 5,
pp. 157.1–157.15.
Saito, R., Jorio, A., Souza Filho, A. G., Dresselhaus, G., Dresselhaus,
M. S. and Pimenta, M. A. (2002b). Probing phonon dispersion
Quantum ESPRESSO Course for Solid‐State Physics | 353
relations of graphite by double resonance Raman scattering,
Phys. Rev. Lett. 88, p. 027401.
Saito, R., Masashi, M. and Dresselhaus, M. S. (2018). Ballistic and
diffusive thermal conductivity of graphene, Phys. Rev. Appl. 9,
2, pp. 024017.
Schrödinger, E. (1926). An undulatory theory of the mechanics of
atoms and molecules, Phys. Rev. 28, 6, p. 1049.
Schwarz, K. (1972). Optimization of the statistical exchange
parameter α for the free atoms H through Nb, Phys. Rev. B 5,
p. 2466.
Setyawan, W. and Curtarolo, S. (2010). High‐throughput elec‐
tronic band structure calculations: Challenges and tools,
Comput. Mater. Sci. 49, pp. 299–312.
Sham, L. J. and Schlüter, M. (1983). Density‐functional theory of
the energy gap, Phys. Rev. Lett. 51, p. 1888.
Sham, L. J. and Schlüter, M. (1985). Density‐functional theory of
the band gap, Phys. Rev. B 32, p. 3883.
Shanno, D. F. (1970). Conditioning of quasi‐newton methods for
function minimization, Math. Comp. 24, pp. 647–656.
Slater, J. C. (1929). The theory of complex spectra, Phys. Rev. 34,
10, p. 1293.
Slater, J. C. (1930a). Atomic shielding constants, Phys. Rev. 36,
p. 57.
Slater, J. C. (1930b). Note on Hartree’s method, Phys. Rev. 35, 2, p.
210.
Slater, J. C. (1951). A simplification of the Hartree‐Fock method,
Phys. Rev. 81, p. 385.
Slater, J. C. and Johnson, K. H. (1972). Self‐consistent‐field xα
cluster method for polyatomic molecules and solids, Phys. Rev.
B 5, p. 844.
Sohier, T., Calandra, M. and Mauri, F. (2017). Density functional
perturbation theory for gated two‐dimensional heterostruc‐
tures: Theoretical developments and application to flexural
phonons in graphene, Phys. Rev. B 96, p. 075448.
354 | Bibliography

Souza, I., Marzari, N. and Vanderbilt, D. (2001). Maximally


localized Wannier functions for entangled energy bands, Phys.
Rev. B 65, p. 035109.
Srivastava, G. P. (1990). The Physics of Phonons (CRC Press).
Stephens, P. J., Devlin, F. J., Chabalowski, C. F. and Frisch, M. J.
(1994). Ab initio calculation of vibrational absorption and
circular dichroism spectra using density functional force
fields, J. Phys. Chem. 98, pp. 11623–11627.
Sucher, J. (1958). Energy levels of the two‐electron atom to order
α3 ry; ionization energy of helium, Phys. Rev. 109, 3, p. 1010.
Tatsumi, Y., Kaneko, T. and Saito, R. (2018). Conservation law of
angular momentum in helicity‐dependent raman and rayleigh
scattering, Physical Review B 97, 19, pp. 195444.
Tatsumi, Y. and Saito, R. (2018). Interplay of valley selection and
helicity exchange of light in raman scattering for graphene
and mos2 , Phys. Rev. B 97, pp. 115407.
Thijssen, J. (2007). Computational Physics (Cambridge University
Press).
Thomas, L. H. (1927). The calculation of atomic fields, in Proc.
Cambridge Phil. Soc., Vol. 23 (Cambridge University Press), pp.
542–548.
Thonhauser, T., Zuluaga, S., Arter, C. A., Berland, K., Schröder, E. and
Hyldgaard, P. (2015). Spin signature of nonlocal correlation
binding in metal‐organic frameworks, Phys. Rev. Lett. 115, p.
136402.
Tkatchenko, A. and Scheffler, M. (2009). Accurate molecular van
der Waals interactions from ground‐state electron density
and free‐atom reference data, Phys. Rev. Lett. 102, p. 073005.
Umrigar, C. J. and Gonze, X. (1994). Accurate exchange‐correlation
potentials and total‐energy components for the helium
isoelectronic series, Phys. Rev. A 50, 5, p. 3827.
Vosko, S. H., Wilk, L. and Nusair, M. (1980). Accurate spin‐
dependent electron liquid correlation energies for local spin
density calculations: a critical analysis, Can. J. Phys. 58, pp.
1200–1211.
Wannier, G. H. (1937). The structure of electronic excitation levels
in insulating crystals, Phys. Rev. 52, p. 191.
Quantum ESPRESSO Course for Solid‐State Physics | 355
Wu, Q. and Yang, W. (2002). Empirical correction to density
functional theory for van der Waals interactions, J. Chem. Phys.
116, pp. 515–524.
Index

Absorption coefficient, 258 Brillouin‐zone integration, 40, 61


Acoustic phonon, 249
Acoustic sum rule, 92, 126 Carrier, 246
AFLOW, 278 CGP, 266
Angle‐resolved photo‐electron Charge density, 69
spectroscopy, 247 Collective excitation, 255
Anharmonic term, 262 Conductance, 259
ARPES, 77, 247 Conjugate gradient algorithm with
Ashcroft‐Heine‐Abarenkov precoding, 266
pseudopotential, 216 Correlation potential, 189
Atomic basis, 30 Coulomb attraction, 169, 196
Atomic form factor, 239 Coulomb gauge, 255
Atomic units, 169 Coulomb integral, 185
Coulomb repulsion, 169, 185, 196
B3LYP, 210 Coulomb screening, 109
B88, 210 Critical temperature, 108
ballistic, 267 Crystal, 235
Band splitting, 129 Cut‐off energy, 36, 242
Band structure, 72 Cut‐off radius, 244
Band‐gap problem, 209
Bash, 323 D‐band, 270
Bernal structure, 134 Damping function, 135
BFGS algorithm, 46, 49 Debye‐Scherrer method, 237
Bilayer graphene, 134 Density functional perturbation
Bloch function, 150 theory, 250
Bloch theorem, 272 Density of states, 78, 245
Boltzmann transport theory, 266 Density‐functional perturbation
Born‐Oppenheimer approximation, theory, 88
171 Density‐functional theory, 167, 190
Bose‐Einstein distribution Depolarization ratio factor, 127
function, 266 DFPT, 250
Bragg’s condition, 238 DFT, 167, 172
Bravais lattice, 30 DFT‐D, 134
Brillouin zone, 235, 236 DFT‐D3, 136
358 | Index

Dielectric function, 113, 257 Fourier law, 265


Dipole correction, 142 Fourier transform, 216
Dipole moment, 141 Free‐electron gas, 190, 203
Dipole vector, 257 Frozen energy window, 155
Disentanglement energy window, Full width at half maximum, 127
155 FWHM, 127
Dispersion coefficient, 135
Distinguishable electrons, 173 G′ band, 270
DOS, 78 Gaussian broadening, 117
Double‐resonance Raman Gaussian functio, 127
scattering, 270 Gaussian smearing, 62
Dynamical matrix, 87, 249 Generalized gradient
approximation, 206
Effective charge, 126 GGA, 206
Effective model Hamiltonian, 275 Graphene, 25
Effective potential, 189
Electron density, 175 Hamilton‐Jacobi equation, 172
Electron‐phonon coupling, 104 Hamiltonian, 169
Electron‐phonon interaction, 100, Hartree energy, 213
250 Hartree potential, 178
Electron‐phonon matrix element, Hartree‐Fock equation, 184
261 Helium atom, 171, 176, 180, 186,
Electronic density of states, 245 228
Electronic energy dispersion, 72, Hellmann‐Feynman theorem, 47,
244 220
Electrostatic potential, 144 Hexagonal lattice, 31
Eliashberg spectral function, 108 Hohenberg‐Kohn theorem, 197
Energy gap, 245 Homebrew, 14
Ewald summation, 218 Hopping parameters, 160
Exchange integral, 185 HSE, 212
Exchange potential, 183 Hybrid functional, 160, 208
Exchange‐correlation energy, 214 Hydrogen atom, 176
Exchange‐correlation functional,
134, 200 IFC, 88
Exchange‐correlation potential, Indistinguishable electrons, 174
189, 201 Infrared intensity, 127
Exchange‐dipole model, 136 Inter‐atomic force constant, 88
External electric field, 140 Interband transitions, 117
Intraband transitions, 117
Fermi energy, 245 Ionic forces, 219
Fermi golden rule, 256 Ionization energy, 177
Fermi‐Dirac smearing, 62 Irreducible Brillouin zone, 116
First‐order Raman scattering, 126 Isotope, 265
Form factor, 217
Fourier interpolation, 89 JDOS, 121
Index | 359
Jellium model, 190 Nonlocal vdW functional, 136
Joint density of states, 121, 258 Norm‐conserving PP, 56
JupyterLab, 22 Norm‐conserving pseudopotential,
244
Kinetic energy, 169, 194 Normal process, 253
Kohn anomaly, 95, 100 Numerov algorithm, 222
Kohn‐Sham equation, 199
One‐body approximation, 174
LA, 249 One‐electron contribution, 215
Lambert‐Beer law, 258 Operating system, 5
Lattice vector, 236 Optical absorption, 113, 254
LDA, 202 Optical phonon, 249
Lieb‐Oxford lower bound, 207 Optimized structure, 55
Lindhard function, 192 Optimizing atomic positions, 46
Linear combination, 174 Overlap matrix, 274
Linux, 292
LO, 249 Parallellization, 317
LO‐TO splitting, 93 Partial density of states, 83
Local‐density approximation, 202 Partial differential equation, 172
Lorentzian broadening, 117 Path variable, 324
Pauli exclusion principle, 175
macOS, 14 PAW, 56
Marzari‐Vanderbilt smearing, 63 PBE, 206, 208
MaterialsCloud, 278 PBE0, 210
Matplotlib, 277, 333 PDE, 172
Maximally‐localized Wannier PDOS, 83
functions, 149, 273 Periodic boundary condition, 31
Maxwell equation, 179 Perturbation Hamiltonian, 262
McMillan formula, 109 Phonon density of states, 96
Mean free path, 263 Phonon dispersion, 87, 248
Metal, 245 Phonon frequency, 87
Methfessel‐Paxton smearing, 63 Phonon linewidth, 101
Miller index, 237 Phonon wavevector, 87
Mixing coefficient, 162 Plane wave expansion, 240
MLWFs, 149, 273 Poisson equation, 225
Mobility, 260 Possion equation, 179
Monkhorst‐Pack method, 44 Projection, 157
Monolayer MoS2 , 114 Projection matrix, 150
Projector‐augmented wave, 56
Neutron scattering, 87 Pseudopotential, 56, 215, 243
Non‐collinear, 131 PW, 204
Non‐interacting electrons, 173 PW91, 208
Non‐resonant Raman spectra, 124, Python, 277, 333
267, 268 PZ, 204, 228
Non‐SCF, 73
360 | Index

Quantum Mobile, 18 Software installation, 5


Space group, 236
Radial Schrödinger equation, 221 Spin‐orbit coupling, 129
Raman active mode, 268 Steepest‐descent algorithm, 150
Raman intensity, 127 Structure factor, 217, 239
Raman scattering, 255, 267 STS, 247
Raman shift, 268 Superconductivity, 100
Raman spectra, 124
Raman tensor, 268 TA, 249
Rayleigh scattering, 255 Terminal, 6
Reciprocal lattice vector, 236 Tetrahedron method, 79
Recombination time, 260 Thermal conductivity, 263, 265
Reflectance, 258 Thermal diffusivity, 266
Refractive index, 257 Thermal expansion, 263
Relativistic effect, 129 Thomas‐Fermi‐Dirac theory, 195
Relaxation time, 259 Three phonon scattering, 262
Repulsive Coulomb interaction, Tight‐binding Hamiltonian, 157,
183 276
Resistance, 259 Tight‐binding model, 275
Resistivity, 259 Tight‐binding parameters, 159
Resonant Raman spectra, 270 TO, 249
Total energy, 26, 35, 202, 212
Saw‐tooth potential, 140 Transition dipole moment, 256
Scanning tunneling spectroscopy, Transport properties, 259
247 Two‐dimensional materials, 129
Scattering rate, 263 Two‐phonon Raman spectra, 270
SCF, 26
SCF method, 179 Ubuntu, 6
Schrödinger equation, 169, 241 Ultra‐soft PP, 56
Self‐consistent field, 26, 179 Ultra‐soft pseudopotential, 244
Self‐interaction correction, 178 Umklapp process, 253, 264
Shell scripts, 323 Uncertainty principles, 256
Single‐mode relaxation‐time Unit cell, 235
approximation, 264 Unit vector, 235
Single‐particle approximation, 113
Single‐particle excitation, 254 Valence band, 245
Single‐particle Hamiltonian, 173 Van der Waals interaction, 134
Single‐particle Schrödinger Van der Walls correction, 143
equation, 177, 184, 191 Van Hove singularity, 259
Slater determinant, 175, 183 Variational principle, 188, 197
Smearing energy, 61 vdW, 134
Smearing function, 61 Verlet algorithm, 225
Smoothed function, 127 VirtualBox, 18
SMTA, 264 Visible light, 255
SOC, 129 VWN, 204
Index | 361
Wannier functions, 150 X‐ray analysis, 237
Wannier interpolation, 160, 261, X‐ray extinction law, 240
276
Wannier90, 291 Zero‐point motion, 251
Warnier functions, 271 Zone‐center phonon mode, 270
Windows, 8
Windows subsystem for Linux, 8

You might also like