Quantum Espresso

Posted on  by 



Nominations are now being accepted for the third Walter Kohn Prize for quantum-mechanical materials modeling, jointly instituted and co-funded by ICTP and the Quantum ESPRESSO Foundation. The Prize is awarded biennially to a young scientist for outstanding contributions in the field of quantum-mechanical materials and molecular modeling, performed in a developing country or emerging economy, with. Quantum Espresso lets me do this by two ways: one using older 'relax' optimization where cell parameters don't change and a second one where I can optimize not only positions of atoms inside cell.

Quantum

Quantum Espresso

Quantum Espresso is a freely availablepackage of open-source codes for electronic-structure calculations andmaterials modelling at the nanoscale. It is based on density-functionaltheory, plane waves, and pseudopotentials, which you will be learning about inthe theoretical part of the course.

Quantum espresso is used via the command line. There is no graphical interfaceby default. This is typical of most electronic structure codes, where you areoften interacting with a remote HPC system solely via ssh, and submittingcalculations and text-file scripts to a queueing system which takes yourcalculation and executes it on some set of compute server nodes when theybecome available.

Cell relaxation &control calculation = 'vc-relax' prefix = 'silicon' outdir = './tmp/' pseudodir = './' etotconvthr = 1e-5 forcconvthr = 1e-4 / &system ibrav=2, celldm(1) =14, nat=2, ntyp=1, ecutwfc=30 / &electrons convthr=1e-7 mixingbeta = 0.6 / &ions / &cell celldofree='ibrav' / ATOMICSPECIES Si 28.0855 Si.pz-vbc.UPF ATOMICPOSITIONS (alat) Si 0.00 0.00 0.00 0 0 0 Si 0.25 0.25 0.25. Quantum ESPRESSO as a distribution Shobhana Narasimhan, JNCASR 9 OTHER PACKAGES WANNIER90: Maximally localized Wannier functions Pwcond: Ballistic conductance WanT: Coherent Transport from Maximally Localized.

To run a calculation you first need to make an input file, describing thevarious calculation parameters along with giving the location of any otherinput files that will be used. Then you run the code giving it your input file(redirected from stdin in the case of quantum espresso - see lab1), and it will create one more files with the result of yourcalculation and potentially intermediate data also. Darkness to light book by lamar odom.

First you’ll need to copy the material for this Lab to your home directory.You should already have a directory named MSE404 in your home directory; youcan confirm this by going to your home directory and checking the contentswith the following two commands:

If you don’t see an MSE404 folder listed, you can create it with

The above command requests the creation of a directory named MSE404 withinwhatever directory you are currently. If you weren’t in your home directoryyou could still create a directory there, by giving the absolute path: mkdir~/MSE404. Once you’ve confirmed you have the directory as expected, you canmake a copy of the lab material there so that you can run the calculations forthis lab, with cp -r /opt/Courses/MSE404/lab02 ~/MSE404.

A set of basic input files for a variety of systems have been set up in thedifferent directories here. In the material that follows you’ll need to runthe calculations in your own copy of this directory. You’ll get an error ifyou try to run calculations anywhere under the /opt directory as you don’thave the permissions needed to create files here.

You should also ensure you have a copy of the directory with thepseudopotentials used for the labs:

A basic input file

A simple example that will use the pw.x code from quantum espresso tocalculate the total energy of carbon in the diamond structure is given in thedirectory 01_carbon_diamond. Let’s first open the input fileC_diamond.in and read through it.In this case we are relying on many default values that would normally bespecified, but this lets us focus on the most important things to begin. Thereis an annotated version of this file calledC_diamond_detailed.inwhich will let us go through the input in more detail. Let’s look at this now.

Running the calculation

The quantum espresso package has been compiled as a module on the mt-studentserver. As discussed in the previous lab, modules are often used on HPCsystems to make different versions of various packages as compiled withdifferent compilers available to users. To add quantum espresso to yourenvironment, along with its dependencies type the following in a terminal:

Now to run the code: make sure you are in the 01_carbon_diamond directorythen do:

Here we redirected our input file to the stdin of pw.x, as described in theIO Redirection section of lab 1. (We could alsohave used the -i flag to specify an input file as pw.x -i C_diamond.in.)You’ll see a lot of output has been generated in your terminal, but a simplecalculation like this will finish quite quickly. It’s better to explicitlysave the output (and any error information) to a file. To do this, we caninstead run the calculation a redirect the output to a file with

The output files

Take a look in the directory with ls. You’ll see some additional files havebeen generated. We have pwscf.xml, which has all the details of the systemand results of the calculation in an xml format. If you skip to the end ofthis file (if you have opened it with less, then pressing G will gostraight to the end, while g will go back to the start) you will see theeigenvalues and other details at each k-point. Note, that while the bandenergies listed in the output file are in eV, those in the xml file are inHartree units. And we have a folder called pwscf.save. This has some otherfiles such as the charge density, another copy of the xml file we saw above, acopy of the psuedoptential that was used, and files with the calculatedwavefunction at each k-point stored in a binary format that can be used asinput to other calculations.

Now let’s take a quick look through the output that we generated. (e.g.less C_diamond.log).

  • First we have details of the code, version and date of the calculation.
  • There’s some info about the calculation details, including some numberswhere we had just accepted the defaults.
  • We have our list of automatically generated k-points. We have 10 here sincecrystal symmetries have been taken into account after generating the 64points on the 4x4x4 grid we requested.
  • Then we go into our self-consistent calculation, starting from randomizedatomic wavefunctions. At the end of each step it outputs the total energy.
  • After four steps we have converged to the default level (ethr < 1.0E-6).
  • The eigenvalues at each k-point are output in eV. Note although we have8 electrons, we have treated them as 4 doubly occupied states, so only fournumbers are output.
  • The total energy is listed, as well as its decomposition into several terms.
  • And finally some timing information. If calculations are taking a long timethis can be helpful in seeing where it is spent.

Calculating other systems

Quantum Espresso Pseudopotentials

To start with let’s focus on the input parameters that are important fordefining our system. There are input files for a number of other types ofsystems here that we’ll go through.

Silicon

Espresso

Silicon crystallises in the same diamond structure that we have alreadyseen in the carbon example. So in this case, all we need to do is change thelattice length to the silicon value, and change the atoms from carbon tosilicon, which also means we need to specify a silicon pseudopotential ratherthan use the carbon one.

If you want to see what we’ve changed in the silicon inputfile relative to the carbon diamond inputfile a useful tool isdiff. If you’re in the lab02 directoryyou can type diff 01_carbon_diamond/C_diamond.in 02_silicon/Si.in. You’ll beable to see that we’ve changed four lines in our input file and everythingelse is the same. So switching to a system with the same structure butdifferent atoms can be quite simple. Note we’ve just used the measuredlattice constant for both systems; in later labs we’ll see how to find thelattice constant predicted by DFT.

Task

  • Run pw.x using this input and save the output to Si.out.

Pseudopotentials

You’ll be learning more about pseudopotentials later your lectures. For nowyou can think of these as files describing the approximation you want the DFTcode to use for each atomic species. As you’ve seen we set the input files tolook in the current directory for the required pseudopotential file. This isby setting pseudo_dir = '.' in the CONTROL section of the input, where .represents the current directory as we saw in the last lab. We then use a linkto this file from some central directory rather than making multiple copies ofthe pseudopotential for different calculations.

An alternative way to do this would be to specify the central pseudopotentialdirectly in the input file. We’ve set this in the input file in02a_silicon/Si.in.

  • Take a look at the directory contents and you’ll see there’s only aninput file there.
  • Use the diff command again to see what’s changed compared to the previoussilicon input file.
  • Try to run the calculation again and confirm that you get the sameoutput as previously.
  • Take a look at the pseudopotential file we’ve used for silicon. The headerhas some useful information regarding how the pseudopotential was generated,such as what states are included, and what approximations are used forexchange and correlation which you will learn more about in your lectures.

Exchange & Correlation Functional

You’ll learn more about the exchange and correlation term in DFT in yourlectures. This is a key part of DFT. The functional we use determines how weapproximate all the many body interactions. By default, within quantumespresso, the exchange and correlation functionals that are used are takenfrom the header of the pseudopotential file as mentioned above. It’s possibleto override this using the input_dft variable in the system section, butit’s best to use the same approximation as was used in the pseudopotentialgeneration.

  • In the directory 02b_silion_pbe, an input file is present that isidentical to the previous calculation, except we specify a differentpseudopotential here: Si.pbe-rrkj.UPF.
  • Look at this file, and compare the header section to the pseudopotential youused previously. You’ll notice a line mentioning “PBE Exchange-Correlationfunctional” in the pseudopotential we’re using here, where it said “PZExchange-Correlation functional previously”.
    • Here PZ refers to a particular parametrisation of the Local DensityApproximation (LDA) - the simplest approximation for the exchange andcorrelation, while PBE is more advanced approximation (though notnecessarily better performing), which is classed as a GeneralizedGradient Approximation (GGA). The letters PZ and PBE are the initials ofthe authors of the papers in which the particular approximations werepublished.

Task

  • Run pw.x with the provided input file. How does the bandwidth of thecalculated valence states compare with that of the previous calculation?(You hopefully calculated this at the end of the last lab - check backif you’re not sure what’s looked for).

Carbon Graphite

An input file for carbon graphite is given in03_carbon_graphite/C_graphite.in.Look at the diff of this input file with the carbon diamond input file.Now we have more differences than in the silicon case.

  • The input ibrav has changed. The value of 2 is used to indicate an fcclattice, while 4 is used to indicate a hexagonal lattice. Take a look atthe pw.x documentation file for more details on this variable: less~/MSE404/qe-doc/INPUT_PW.txt. You can search for ibrav by typing /ibravand pressing enter. You can press n to go to the next match if you don’tgo straight to the main entry. (The input description is also viewableonline.)
  • A has changed, and we have the additional variable C. For a hexagonallattice these variables are used to define the three lattice vectors asfollows:v1 = A(1,0,0), v2 = A(-1/2,sqrt(3)/2,0), v3 = C(0,0,1).
  • The basis is increased from 2 atoms to 4.
  • The basis has changed to a different set of fractional atomic positions.

Carbon Graphene

As you may have noticed, Quantum Espresso is set up to run periodic 3Dcrystals. So what do we do for systems that aren’t periodic in threedimensions? In this case, we just make the non-periodic dimension largeenough that the atoms are too far apart to interact in this dimension,or more accurately that the interaction is sufficiently small relative to theother interactions.

So to move from graphite to graphene, we want to take a single layer ofgraphite and extend the interlayer spacing so that the inter-layer interactionis small. The input for this is in04_carbon_graphene/C_graphene.in. diffthe graphite and graphene input files and you’ll see these changes. The otherchange that you’ll notice is to the k-point sampling. Since the system we aretrying to calculate is no longer periodic in the z-direction, we only have asingle k-point in this direction.

Task

  • Compare the total energy per atom that you have calculated for grapheneand graphite. Which is lower? Why do you think that is?
  • How does this compare to diamond? Does this seem correct?

Methane

So now we have seen a two-dimensional system, the next question is what do weneed to do for molecules or systems with no periodicity. In this case, we justput the entire system in a large box, that we hope (we check) is big enoughthat periodic images don’t interact, or interact weakly compared to theother interactions we’re interested in.

The input file for a single methane molecule is in05_methane/CH4.in. Here by setting ibrav = 1 we havechosen to use a cubic box, and A = 15.0 makes the box 15 Angstrom along anedge. And then we define the 5 atomic positions. In this case, it doesn’tmake sense to define the atomic positions in terms of an arbitrarily chosenbox size, so we use the setting ATOMIC_POSITIONS angstrom to indicate thatthe we are giving the atomic positions in Cartesian coordinates in Angstrom.

Note there are a number of equivalent ways of defining the unit cell vectorswithin Quantum Espresso. Instead of relying on choosing the correct ibravvalue, we can set ibrav = 0 and give the unit cell lattice vectorsexplicitly in a CELL_PARAMETERS section. This is shown in05a_methane/CH4.in.

Task

  • Try running pw.x with both methane input files and confirm you get thesame total energy in both cases.

Aluminium

Quantum

Aluminium forms in a standard fcc structure with one atom per cell, which weknow how to deal with at this point. The thing about Aluminium that makes itmore complicated within DFT is that it is a metal. Metals have a Fermi surfacethat can be quite complex in k-space. This means that in contrast to aninsulator or semiconductor where every k-point has the same number of occupiedstates, in a metal the number of occupied states can vary from k-point tok-point. This makes them a little more difficult to converge than othersystems. In short, there are generally two things you need to do:

  1. Use a denser k-point grid than you would need for a semiconductor orinsulator.
  2. Use some smearing scheme. This means that a state is no longer simplyoccupied or empty, but has instead some probability of occupation. In asemiconductor, if we have a system with 4 electrons, then at every k-pointthe first 2 doubly occupied states will be populated. But in a metal,whether or not a state is occupied depends on its energy and the value ofthe Fermi level (which in turn will depend on the energies of all theelectronic states we calculate). Adding a smearing helps significantly inachieving a smooth SCF convergence, as otherwise a small change in a stateenergy from once cycle to the next could lead to a very large change in itsoccupation and to the total energy in turn. You will learn more about thisin the lectures. We set the smearing scheme and width with theoccupations and degauss variables in the input file.

Run the pw.x calculation with the supplied input file in06_aluminium/Al.in and take a look through the output.

You’ll need to look in the pwscf.xml file and find the various ks_energiesentries towards the end. These give the various k-points used in thecalculation and the energies and occupations of each state for this k-point.Note, for a metal the default number of bands is at least four more than areneeded for the number of electrons per cell. The pseudopotential we have usedhas 3 valence electrons, which could be represented with two potentiallydoubly occupied bands, so we have four more bands in the calculation for atotal of 6.

  • Try removing the occupations and degauss variables from the input fileand see what happens when you try to run the calculation.

Quantum Espresso Gw

Summary

  • In this lab we’ve looked at how to create an input file for many differenttypes of system:
    • Carbon in the diamond structure
    • Silicon, which has the same diamond structure, but the atomic speciesare different and the bond length is different.
    • Carbon in the graphite structure, where the unit cell is different andthe number of atoms per unit cell is different with respect to carbonin the diamond structure.
    • Carbon in the graphene structure, where we now have a 2D system ratherthan a 3D system.
    • Methane, which is a molecule in contrast to the previous periodicexamples.
    • Aluminium, which is a metal and needs some additional inputs to take careof the complications associated with this.
  • We’ve looked at how we specify the pseudopotentials for our atomic species.
  • We’ve seen an example of using different approximations for exchange andcorrelation within our DFT calculations.

Extra - Visualising Structures

There are many different tools that can be used to visualize atomicstructures. xcrysden is installed as a module on the server you’re using forthis course, and conveniently can read Quantum Espresso input files. Tryloading the module with module load xcrysden, running the command xcrysdenand opening the input files for the various structures we’ve looked at in thislab. There are many options to control how the structure looks, and you cangrab and rotate the structure with your mouse.

Task

  • See if you can figure out how to save an image of each structure as a pngfile.

Quantum ESPRESSO is an integrated suite of computer codes for electronic structure calculations and materials modeling at the nanoscale. It builds on the electronic structure codes PWscf, PHONON, CP90, FPMD, and Wannier. It is based on density-functional theory, plane waves, and pseudopotentials (both norm-conserving and ultrasoft).

Quantum Espresso Download

Using Quantum ESPRESSO at NERSC¶

NERSC provides modules with precompiled Quantum ESPRESSO installations.

Quantum Espresso Manual

Available versions can be found by running:

and the specific version is loaded via

Examples¶

For all routines except pw.x, run QE in full MPI mode as there is currently no efficient OpenMP implementation available.

Cori Haswell

Warning

Pay close attention to the explicit setting of OMP_NUM_THREADS=1 when running in pure MPI mode. This is optimal when intending to run with only MPI tasks.

hybrid DFT¶

We have optimized the hybrid DFT calculations in Quantum ESPRESSO (pw.x). These changes are described in our Quantum ESPRESSO case study and available in the espresso/6.1 module we provide.

The following scripts provides the best pw.x performance for hybrid functional calculations:

Quantum Espresso Gui

Voicemac. Cori Haswell

Cori KNL

Tip

For band-group parallelization, it is recommended to run one band group per MPI rank. However, please keep in mind that it is not possible to use more band-groups than there are bands in your system, so adjust the number accordingly if issues are encountered.

Note

The new implementation is much more efficient, so you might be able to use much fewer nodes and still get the solution within the same wallclock time.

Compilation Instructions¶

Some users may be interested in tweaking the Quantum ESPRESSO build parameters and building QE themselves. Our build instructions for the QE module are listed below. The following procedure was used to build Quantum ESPRESSO versions >5.4 on Cori. In the root QE directory:

where <version> specifies the version, <arch> the architecture (usually hsw or knl for Haswell and KNL respectively) and <comp> the compiler (usually gnu or intel).

Note

Not all versions are available for all architectures or compilers.





Coments are closed