Quantum Espresso

Beginner tutorial by Crivella

Quick start

Preliminaries

    1. Install Linux (Ubuntu or Mint Xfce)

    2. For Windows users this can be done on virtual machine. A free VMware Workstation Player is a good choice. It is recommended to create a shared folder to exchange files between Windows and Linux. Instructions can be found in Instruction 1 or Instruction 2. The later is better. Note, however, that runing vmware-config-tools.pl may result in sudo: vmware-config-tools.pl: commad not found. Then you need to install VMware Tools. In the given instruction 2 the step 10 sudo ./vmware-install.pl is not always working as mentioned in this post, therefore you may need to run sudo perl vmware-intall.pl. Finally, following 'Instruction 2' and creating a link to a desktop, this post may be useful. In brief, type in Terminal (right click in any folder to invoke Terminal): ln -s source_path link_path.

    3. Note: Ab initio quantum chemistry calculations with QE produce a lot of data. This may result in lack of the disk space on the used virtual machine. If the virtual machine disk size is needed to be expanded then it can be done in virtual machine settings. This, however, does not affect the size of partition in the guest operating system, i.e. the one that is run on VMware Workstation Player. To make this space visible for the operating system one should increase partition size. For this run GParted. If it is not installed, install it by typing in Terminal (right click in any folder to invoke Terminal): sudo apt-get install gparted.

    4. Note: If after intalling VMware Player you get an error related to Intel vt-x. Have a look at this guidance how to fix the problem.

    5. Note: virtual machines built-in Windows 7 and 10 may be also used.

    6. Note: MacOS users can run virtual machine on VM Ware Fusion. If running Ubuntu you see this problem “Cannot find a valid peer process to connect to”. Follow this video to fix it.

    7. A precompiled version of Quantum Espresso can be installed from Ubuntu repository by typing in Terminal (right click in any folder to invoke Terminal): sudo apt-get install quantum-espresso. For uninstalling type: sudo apt-get remove quantum-espresso. The given commands can be used for any programms. Simply change 'quantum espresso' to something else that you need. The online repository may contain several version of the programm to check all of them type in the Terminal: aptitude search programm_name. Use any programm name instead of the 'programm_name' placeholder.

    8. Any calculation starts by self-consistent field calculations, i.e. 'scf', using pw.x : pw.x < input_file > output_file

    9. Thus, input file is needed. The structure of the input file for pw.x is explained here.

    10. Note: The input file uses pseudopotentials. They can be downloaded from QE official page.

Convergency tests

Important parameters to control are electron wave function and density cut-offs (ecutwfc,ecutrho), lattice constant (celldm(1)), number of k points.

Band structure of a zigzag graphene nanoribbon

    1. Self-consistent field calculations. Sample pw.x input file for ZGNR(3) here

    2. Band structure calculations. Sample pw.x input file for ZGNR(3) here

    3. Re-odering of the band structure values should be done by bands.x . Sample file for ZGNR(3) here

    4. Finally the bands can be ploted by routine called plotband.x. It can be run without input file then it will guide user through all the required input parameters. Alternatively, all these parameters can be specified in an input file and provided as sigle input to the plotband.x routine. Sample file is here.

Optical absorption of a zigzag graphene nanoribbon in single electron approximation

    1. Self-consistent field calculations. Sample input file for ZGNR(3) here

    2. Non-self-consistent field calculations. Sample input file for ZGNR(3) here

    3. Run calculations by pw2gw.x: pw2gw.x<input_file>output_file. Sample of the input file is here

Some tips

    1. For quick check of the data obtained in calculations with QE (bands, optical absorption spectra or whatever) one can use gnuplot. Run in terminal gnuplot, then type a minimal example: plot [xmin:xmax] [ymin:ymax] 'file with data' w l title 'title' xlabel ylabel

    2. For shifting data by a constant use: plot [xmin:xmax] [ymin:ymax] 'file with data' u ($1+const):($2) w l title 'title' xlabel ylabel

    3. For quitting gnuplot simply type 'q'.

    4. It is convenient to store all used pseudo potentials in one selected folder rather then to copy the same pseudo potential into every working directory. For this set environmental variable $ESPRESSO_PSEUDO so that pw.x knows where to take pseudo potentials from. How to set environmental variable in Linux is discussed here. In brief, to do this type in Terminal: nano ~/.bashrc. This will open bashrc file for editing. In any place of the file excluding inner space of loops and the middle space of commands type (the most logical step is to do this at the end of the file): export ESPRESSO_PSEUDO=path_to_folder, where the actual path you are going to use must be placed instead of the 'path_to_folder' placeholder. For editing ~/.bashrc file one may also use gebit.

Further practice

Note that professional ab initio calculations of the electronic and optical properties are normally preceded with the optimization of the structure geometry. For the sake of simplicity this step has been skiped above. The details of optimization procedure realization with QE can be found in the online tutorial vc-relax, relax, dos and bands calculations for graphene

Vacuum level calculation

The electrons with energies above the vacuum level are free particles and as such cannot contribute to the electronic band structure of the system or its interband optical absorption specturm. Therefore it is important to know this quantity so that the obtained data could be cut at the corresponding energy. The vacuul level is also needed for calculations of the work function.

    1. The maximum value of the potential extracted from average.x data (E_{av, max}) must be compared to the position of the Fermi level (E_F) for a given system to get the value of the vacuum level: E_{av, max}-E_F=E_vac.

Automating calculations

The desribed in Quick start section step-by-step procedure of calculating electronic and optical properties can be automated by writing a script and runing it within the Terminal (Linux command line). The given example runs self-consistent calculation followed by the band struture, non-selfconsistent and single-electron optical absorption calculations. Note that input and output file names used in the script can be changed. These names must correspond to the actual file names in the working directory, where the calcualtion is to be carried out. The script must be placed into and run from the working directory.

Minimal example of the shell script

The basic structure of the script and how to run it is explained in this post. The key points are

    1. The first line of the script specifies which program shall interpret it: #!/bin/bash

    2. The comments in the script are defined as follows: # any_comment_here

    3. Setting shell permissions: chmod 755 script_name

    4. Running the script: ./script_name

Some further examples including conditionals, iterations and subroutines can be found here.