You are on page 1of 65

HANDS-ON TUTORIAL ON THE

PWscf/FPMD/CP PACKAGE

• Setting up the input files


• Post Processing
• Structural Relaxations
• Molecular Dynamics

S. Fabris and C. Sbraccia

CINECA – March 3rd 2004


• Select the appropriate unit-cell
• Input the atomic coordinates
• Choose and download the pseudopotentials
• Determine a suitable k-point sampling & smearing
• Select the size of the basis set
•…
bulk Al: cubic fcc and sc bravais lattice
defective Al:
sc bravais lattice
Al surfaces
t bravais lattice
&system
ibrav= 2,
celldm(1) =7.50,
nat= 1, ntyp=1,

ecutwfc =15.0,


ibrav structure celldm(2)-celldm(6)
0 "free", see above not used
1 cubic P (sc) not used
2 cubic F (fcc) not used
3 cubic I (bcc) not used
4 Hexagonal and Trigonal P celldm(3)=c/a
5 Trigonal R celldm(4)=cos(aalpha)
6 Tetragonal P (st) celldm(3)=c/a
7 Tetragonal I (bct) celldm(3)=c/a
… (see file INPUT_PW in O-sesame/pwdocs/)
Exercise 1: cubic supercell
• Run a self-consistent calculation for bulk Al (al.fcc.in)
run-al.fcc
run-al.fcc is a script containing the input file al.fcc.in
and producing the output file al.fcc.out
• Write down the total energy: it will be used in the following as
reference

• Edit the script file


run-al.sc
modifying the variables IBRAV and NAT so that to obtain a
simple cubic supercell with 4 atoms
IBRAV=?, …, NAT=?
Exercise 1: cubic supercell
•Add the atomic coordinates in the
ATOMIC_POSITION field
Al 0.0 0.0 0.0
Al ?? ?? ??
Al ?? ?? ??
Al ?? ?? ??

• Run a self-consistent calculation (input= al.sc.in)


run-al.sc

• Compare the total energy (file al.sc.out) with the reference one in
file al.fcc.out: do they differ? Why?
ATOMIC_POSITIONS

Atomic positions in the supercell can be defined in 4 ways:


1. in units of ALAT (this is the default) (alat)
2. in crystal coordinates (crystal)
3. In bohr (bohr)
4. In Angstrom (angstrom)

The unit is defined by specifying the right flag as


ATOMIC_POSITIONS (crystal)
Tetragonal supercell

c’

a’
a
Exercise 2: tetragonal supercell
• Have a look at the script file run-al.tet
• Modify the variables IBRAV and NAT so that to obtain a
tetragonal supercell with 2 atoms
IBRAV=??, celldm(1) =5.3033,
celldm(3) = ??, NAT=??
• Specify the (alat) instruction
ATOMIC_POSITIONS (alat)
• Add the coordinates of the second atom in units of alat
Al ?? ?? ??
ATOMIC_POSITIONS (alat)

c’ Al2

a’
Al1 a
celldm(3)= 1.41421356237 a’=sqrt(2)/2 * a
c’= a
Al 0.0 0.0 0.0 c’/a’= sqrt(2)
Al 0.5 0.5 0.707107
Exercise 2: tetragonal supercell
• Run the self consistent calculation (input= al.tet.in)
run-al.tet

• Compare the total energy (output in al.tet.out) with the


reference one calculated in Example1 (al.fcc.out)
grep ! ../Ex1/al.fcc.out
grep ! al.tet.out
why do they differ? What can you learn from the energy
difference between the two?
Exercise 3: crystal coordinates
• Have a look at the script
run-al.tet2
• Specify the (crystal) instruction
ATOMIC_POSITIONS (crystal)
• Add the coordinates of the second atom in crystal units:
Al ??? ??? ???
ATOMIC_POSITIONS (alat)

c’ Al2

a’
Al1 a
a’=sqrt(2)/2 * a
Al 0.0 0.0 0.0 c’= a
Al 0.5 0.5 0.5 c’/a’= sqrt(2)
Exercise 3: tetragonal supercells
• Run the self consistent calculation (input= al.tet.in)
run-al.tet2

• Compare the total energy in al.tet2.out with the one


calculated in Example2 (al.tet.out)
grep ! ../Ex2/al.tet.out
grep ! al.tet2.out
Do they differ? Why (or why not)?
K-POINTS
• Periodic system  Wave function and Hamiltonian expanded in PW

• The electron states in the BZ are naturally classified by the points k


in the Brillouin Zone
• The number of the k points is proportional to the number of repeated
unit cells N
• With periodic boundaries conditions Ninfinity & Nkinfinity
!!WF and H can not be calculated at each k point!!

SOLUTION:
WF and H are sampled on a suitable set of representable k points
in the BZ
K-POINT SAMPLING
The choice of the k-point mesh is system dependent.

Examples:
1. Non-cubic supercells
2. Surfaces
3. Molecules isloated in vacuum
Exercise 4: elongated supercell
• Have a look at the script file
run-al.tet3
• Modify the variables IBRAV, NAT, celldm(3), so that to
double the size of the tetragonal supercell in the z direction (double
the c/a ratio and double the number of atoms).
Exercise 4: elongated supercell
• Run the scf calculation (input=al.tet3.in) and check the total energy
run-al.tet3

• Reduce the size of the k-point mesh along k_z:


K_POINTS (automatic)
12 12 5 1 1 1
• Run the scf calculation again (be careful not to overwrite the
files …). Fill up the following table. Comment the difference in
the total energies (per atom) of the 4 set of calculations:
al.fcc.out al.tet.out al.tet3.out (12 12 10) al.tet3.out (12 12 5)
-4.18739 ????? ?????
-4.187028 -4.186958 ?????
-4.187028
Exercise 5: Al (001) surface
• Working input file: run-al001
• Modify the variables IBRAV and NAT so that to obtain
a tetragonal supercell with 7 atoms

• Specify the (alat) instruction


ATOMIC_POSITIONS (alat)
• Add the coordinates of the other 7 atoms in units of alat:
Al ??
Al ?? 0.0??0.0 …..0.0
Al 0.5 0.5 0.707107
Al 0.0 0.0 1.414213
Al 0.5 0.5 2.121320
…. And symmetric with respect to xy plane …
•Check theself-consistent
• Run the structure withcalculation:
Xcrysden:
xcrysden
./run-al001 –pwi al.001.in
Exercise 6: isolated molecule
Simulation of a CO molecule isolated in vacuum

• How many k-points are needed? Why?


• Have a look at the script file run-co.scf and run the calculation:
run-co.scf
Energy cut-off

• WF is expanded on a finite basis of plane waves.


• The size of the basis is controlled by the energy cut off ecut

Checking convergence of results towards the basis size

WHICH RESULTS?
• Total energy?
• Structural parameters?
• …
Exercise 7: energy-volume
Exercise 7: energy-volume
Calculation of an energy-volume curve for bulk Si

•Working input file: run-si.scf

•Set the energy cutoff to 20 Ry: ecut=20


•Set the lattice parameter to 9.8 a.u.: celldm(1)=9.8
•Run the scf calculation:
run-si.scf
• Save the output file: cp si.scf.out si-e20-a9.8.out
•Repeat the procedure for the lattice parameters:
Lattice parameter Energy
9.8 ???
10.0 ???
10.2 ???
10.4 ???
Exercise 7: energy-volume

•Write table on file: envol-ecut20.dat


9.8 ???
10.0 ???
10.2 ???
10.4 ???

•Plot the results:


Exercise 7: energy-volume
• Recalculate the energy-volume curve with a larger cutoff:
ecut=40

• Collect the results in file envol-ecut40.dat


9.8 ???
10.0 ???
10.2 ???
10.4 ???

• Plot the two files together: what do you learn?


Is the total energy converged?
Are the structural parameter converged?
Which cutoff would you choose for scientific production?
Exercise 7: energy-volume
Pseudopotentials
• Where to get the psudopotential files?

1. From the PWscf web site: http://www.pwscf.org


Pseudopotentials

You get psudopotential files ready-to-use with PWscf


Pseudopotentials
• Where to get the psudopotential files?

2. From other databases:


i.e. Vanderbilt ultra-soft pseudopotential site
http://www.physics.rutgers.edu/~dhv/uspp/
Pseudopotentials
! Different xc functionals !


Pseudopotentials
• Where to get the psudopotential files?

2. From other databases:


i.e. Vanderbilt ultra-soft pseudopotential site
http://www.physics.rutgers.edu/~dhv/uspp/

You get psudopotential files not compatible with PWscf

Convert them in the UPF format:


O-sesame/upftools/uspp2upf xxx.uspp
Pseudopotentials
• Where to get the psudopotential files?

3. Generate your own PP… see Paolo Giannozzi Lecture


Self consistency: mixing

• Cc  BAD CHOICE

• Linear mixing

• Advanced mixing schemes …

It is more flexible to mix the density instead of the potential


PWscf mix the density by default
Example 8: improving convergency
• Run the scf calculation for an elongated supercell of 16 Fe atoms
run-fe16.scf &

• During the run check the convergency of the total energy


grep –e scf –e ‘total energy’ fe16.scf.out

• What do you notice??


SUGGESTION
• Try to decrease the mixing parameter: mixing_beta = 0.1
Exercise 8

OTHER SUGGESTIONS FOR DIFFICOULT CASES:


• Increase the number of calculated bands: nbnd=80
• Change the mixing method mixing_mode or the size of
history mixing_ndim
Exercise 9: DOS
• Run the scf calculation for bulk Ni
run-ni.scf

• What happens? Why does the program stop?


• Add the required input
starting_magnetization(1)=0.0
… run again the simulation. Copy the output file:
cp ni.scf.out ni.scf.out-0magn
• Modify the starting magnetization in run-ni.scf
starting_magnetization(1)=0.7
… run again the simulation.
run-ni.scf
• Compare the total energies of the two simulations: do they
differ? Why? What about the magnetization?
Exercise 9: DOS
• Run the nscf calculation for bulk Ni:
increase the number of bands to 8: nbnd=8
and the set a denser k-point mesh: 12 12 12 0 0 0

• Have a look at the input file for the DOS calculation:


more run-ni.dos
&inputpp
outdir=‘$TMP/DIR'
prefix='ni'

Emin=5.0, Emax=25.0, DeltaE=0.1 


fildos='ni.dos'
in eV!
/
… and run the DOS calculation:
run-ni.dos
Exercise 9: DOS
• Have a look at the output file containing the DOS: ni.dos
more ni.dos

# E (eV) dosup(E) dosdw(E) Int dos(E)


5.749 0.0000E+00 0.0000E+00 0.0000E+00
5.849 0.9326E-03 0.4531E-03 0.1386E-03
5.949 0.3730E-02 0.2685E-02 0.7801E-03
6.049 0.1327E-01 0.6781E-02 0.2785E-02
6.149 0.1422E-01 0.1859E-01 0.6066E-02
6.249 0.1686E-01 0.1600E-01 0.9352E-02
6.349 0.1969E-01 0.1876E-01 0.1320E-01
… … … …
Exercise 9: DOS
• Plot the density of states and notice the difference in the spin
up and spin down components:
Exercise 10: PDOS
• Have a look at the input file for the PDOS calculation:
more run-pdos.in

&inputpp
outdir=‘$TMP_DIR/'
prefix='ni'
io_choice='both'
Emax=25.0, DeltaE=0.1, smoothing=0.3
/

… and run the PDOS calculation (projwfc.x):


run-ni.pdos
Exercise 10: PDOS
• Have a look at the output files containing the s and d
components of the PDOS:
more ni.pdos_atm#1(Ni)_wfc#1(s)
more ni.pdos_atm#1(Ni)_wfc#2(d)

# E (eV) dosup(E) dosdw(E)


4.249 0.151E-13 0.545E-14
4.349 0.379E-12 0.146E-12
4.449 0.761E-11 0.314E-11
4.549 0.122E-09 0.541E-10
4.649 0.158E-08 0.746E-09
4.749 0.163E-07 0.824E-08
4.849 0.136E-06 0.731E-07
Exercise 10: PDOS
• Plot the s and d components of the density of states : interpret
the total density of states.
Exercise 11: STM images
Simulating the STM image of the AlAs (110) surface

• Run the scf calculation for the AlAs (110) surface


run-alas.scf
• Run the non scf calculation for the AlAs (110) surface:
run-alas.nscf
• Set up the input file for the post processing
(see run-AlAs.ppstm):
&inputpp
prefix = 'AlAs110'
outdir='$TMP_DIR/',


filplot = 'AlAs-1.0'
sample_bias=-0.0735d0,
stm_wfc_matching=.false.,
plot_num= 5
/
… see O-sesame/pwdocs/INPUT_PP

• How to choose the sample_bias?


Exercise 11: STM images
• How to choose the sample_bias?

• Run the post processing simulation:


run-AlAs.ppstm

• Redo the STM simulation, imaging empty states


Exercise 11: STM images
• Producing a 3D file comptatible with the XCrysDen package:
more run-AlAs.chdens
&input
nfile=1
filepp(1)='AlAsresm-1.0'

 3D plot
weight(1)=1.0
iflag=3

output_format=5  XCrysDen format


plot_out=1

e1(1)=7.0, e1(2)=0.0, e1(3)=0.0


e2(1)=0.0, e2(2)=7.07107, e2(3)=0.0
x0(1)=0.0, x0(2)=-0.18, x0(3)=3.25
nx=36 ,ny=56
fileout='AlAs110-1.0.xsf'
/
Exercise 11: STM images
• Producing a 3D file comptatible with the XCrysDen package:
run-AlAs.chdens

• Visualizing the output file with the XCrysDen package:


xcrysdens –xsf AlAs110-1.0.xsf
Exercise 11: STM images
• Visualizing the output file with the XCrysDen package:
xcrysdens –xsf AlAs110-1.0.xsf
Structural relaxation
The Potential Energy Surface

Given the ionic configuration, the total energy of the system is


obtained with the Density Functional Theory.

ρ(XI3N)] is a function of ionic configurations and


Total Energy E[XI3N,ρ
defines a 3N-dim surface called Potential Energy Surface.

The problem of identifing stable ionic configurations (where forces


are zero) is thus equivalent to the identification of the minima on the
PES.
Ionic relaxation

Steepest Descent minimization :

discretization

gradient versor
Ionic relaxation

Steepest Descent minimization :

discretization

gradient versor
Ionic relaxation

Steepest Descent minimization :

discretization

gradient versor
Ionic relaxation

Steepest Descent minimization :

discretization

gradient versor
Ionic relaxation

Steepest Descent minimization :

discretization

gradient versor
Ionic relaxation

Steepest Descent minimization :

discretization

gradient versor
Ionic relaxation

Steepest Descent minimization :

discretization

gradient versor
Ionic relaxation

Steepest Descent minimization :

discretization

The minimum is reached !!!


gradient versor
Exercise 12: surface relaxation
Structural relaxation of the Al(001) surface
• Run the self-consistent calculation for the Al (001) slab:
run-al001.scf
• Scroll to the end of the output file and analyze the forces: what
do you notice? Are the atomic forces pointing outward or inward?
more al.scf.out

• Modify the input file so that to perform a structural relaxation:


(see O-sesame/pwdocs/INPUT_PW)
&control
calculation=‘???‘
….
&ions
/
Exercise 12: surface relaxation
• Analyze the output file: how are the forces evolving during the
relaxation?

• How are the atoms relaxing? How much does the interlayer
distances change with respect to the bulk value?

• Xcrysden does not work!!

( eventually rerun the calculation in parallel distributing over the


3 k points)
Exercise 13: molecular relaxation
Finding the equilibrium structure of the CO molecule

• Run the self consistent calculation for an isolated CO molecule:


run-co.scf

• Check the output file: what is the direction of the forces?

• Modify the input file, relax the structure and find the equilibrium
C-O bond length.
Exercise 14: molecular dinamics
Molecular dynamics for bulk Si

• Run the self consistent calculation for bulk Si:


run-si.md

• During the run, check the evolution of the total energy:


md_analizer.sh
what do you notice? How does it change?
Exercise 14: molecular dinamics

You might also like