# INSTRUCTIONS FOR DAY 1, EXERCISE 2

In this exercise, we will examine some of the 'post-processing' that you can do once you have run your scf calculations.

In the previous exercise, there was only one output quantity that we cared about ...the total energy. Here we will see some other things that we can extract from the files produced when one does a PW calculation...e.g., charge densities, and eigenvalues (which we will use to get band structure plots and densities of states). We will continue to work with Si, which was the subject of exercise1.
Enter the directory ex2. You will see the following files:

• day1_exercise2_instructions.html this file!
• Si.scf.in this is an input file for scf calculations.
• bands.in this is an input file for collecting bands.
• k-point-path this is a file containing list of k-points along symmetry directions in Brillouin zone.
• Si.plotband.in this is an input file for putting band structure data into a plottable format.
• Si.pp_rho.in this is an input file to extract charge density using post-processing.
• Si.plotrho.in this is an input file to plot charge density.
• dos.in this is an input file to calculate density of states.

### Self-consistent (scf) calculations for Si

• Open and read the sample file Si.scf.in
• We chose values of celldm(1) , ecutwfc, nk1, nk2 and nk3 based upon our results for exercise1. You may choose the same values as these, or substitute your values.

Run the scf calculation:

```    pw.x < Si.scf.in > Si.scf.out
```

## Band structure of Si

• Copy Si.scf.in to Si.band.in
• Edit Si.band.in to perform non-self consistent calculations that will be used to obtain band structure, by setting calculation='bands'.
• Add the nbnd=8 to the &SYSTEM namelist to specify the number of bands computed. Note that for a 2-atom Si cell, we have 8 electrons and therefore only 4 occupied bands, but we are going to compute some extra (empty) bands.
• Define the K_POINTS card to specify the path along symmetry directions in Brillouin zone. In order to this, you can use the information supplied in the file called k-point-path, which contains a list of k-points along high symmetry directions in the BZ, i.e., L (½, ½, ½) to Gamma (0, 0, 0) to X (0, 0, 1) to W (0, ½, 1) to X (0, 1, 1) to Gamma (0, 0, 0). You can paste that file to Si.band.in after the K_POINTS card.

Run a 'bands' calculation:

```pw.x < Si.band.in > Si.band.out
```

What differences do you see between the output file you obtain here, and the output file that you obtained from your scf calculation?

Collect band results for plotting

• Look at bands.in
• Note that you have to use the same prefix in this calculation as was used in scf AND bands calculations.
• The flag filband defines the name of the file in which bands data is stored.

Run:

```bands.x < bands.in > bands.out
```

Have a look at bands.out and bands.dat and note the minimum and maximum energy eigenvalues at different k-points.

Now let's get the data in a format to plot

• Look at Si.plotband.in
• The file contains
• input file (= bands.dat obtained in the earlier step).
• Emin and Emax (= -6.00 and 10.00).
• output file in xmgrace format (bands.xmgr)
• output file in ps format (bands.ps)
• Fermi energy (= 6.337 eV)
• deltaE and reference energy (= 1.00 6.337)
• Run the plotting program: \$plotband.x < Si.plotband.in > Si.plotband.out
• You can view the plotted band structure written in ps format (bands.ps) using a postscript viewer (e.g., ghostview or ggv).

## Charge density for Si

Now we do the post-processing to extract the charge density

• Look at Si.pp_rho.in
• Make sure that the value of prefix is the same as the values as were used in scf calculations.
• filplot = 'Si.charge' saves the extracted charge density and is used for plotting by defining filepp(1) = 'Si.charge' and the data to be plotted in written in fileout='Si.rho.dat'.
• plotnum = 0 indicatesthat the quantity to be extracted is the charge denisty (for other possible options, see INPUT_PP.
• in the directory Doc in the espresso package).
• iflag and output_format specify the dimensionality for the plot.
• e1(i) and e2(i) (i = x, y and z) are 3D vectors that determine the plotting plane and must be orthogonal to eact other.
• nx and ny are number of points in the plane.

Run the post-processing code:

``` pp.x < Si.pp_rho.in > Si.pp_rho.out
```

Now make a plot the extracted charge density

• Examine Si.plotrho.in
• The first line contains the name of the output file from the earlier step (Si.rho.dat)
• The second line contains the name of the file to which output is to be written, that is Si.rho.ps (in ps format).

Run the plotting code:

```      plotrho.x < Si.plotrho.in > Si.plotrho.out
```

Use ghostview or ggv to view the charge density of Si.

### Density of states plot for Si

• First run a nscf calculation to obtain the states for the DOS
• Copy Si.scf.in to Si.nscf.in
• Change the flag calculation='nscf'
• Change the number of bands to add a few empty states in the namelist &SYSTEM (nbnd = 8).
• Define occupations='tetrahedra' in the namelist &SYSTEM.
• Modify the K_POINTS card from '6 6 6 1 1 1' to '12 12 12 1 1 1', this is because we now want to compute eigenvalues on a finer mesh in k-space.
• Remember that the same wavefunctions (as obtained from scf calculations) have to be used, so do NOT change prefix.

Run the nscf calculations:

```pw.x < Si.nscf.in > Si.nscf.out
```

DOS calculations

• Look at dos.in
• Make sure that it has the same prefix as used in the scf calculations.
• The DOS results are written in fildos = (dos.dat)

Run density of states calculations:

```dos.x < dos.in > dos.out
```
• Have a look at dos.out and the data file dos.dat.
• Plot dos.dat to see the DOS plot (you can use gnuplot or xmgrace programs).