TABLE OF CONTENTS


38-bonding-analysis-CORh

DESCRIPTION

This example demonstrates how to perform electronic-structure analysis of CO bonding on Rh(100) surface.

It consists of the following tasks:

   1. relaxation of CO/Rh(100)-c(2x2)
   2. DIFDEN calculation (charge-density-difference) between CO & Rh(100)-c(2x2)
   3. PDOS calculation of CO/Rh(100)-c(2x2) with a denser k-mesh
   4. ILDOS calculations of CO/Rh(100)-c(2x2)

EXAMPLE SOURCE FILE

bonding-analysis-CORh.pwtk

SOURCE

# N.B. this example takes a while. Hence, let's activate the restart
# mode with ::pwtk::restart (this implies that if we rerun this
# example, PWTK will not perform already done calculations)

restart on

# the pw.x input data are imported from CORh.pwtk with ::pwtk::import
import CORh.pwtk

# REMARK: in PWTK, pp.x, projwfc.x, ... calculations inherit the
# value of the "outdir" and "prefix" variables; hence, setting outdir
# in CONTROL namelist is enough and there is no need to set them for
# subsequent pp.x, projwfc.x, ... calculations.

# the name used for the I/O files
set name CO-Rh100

# ------------------------------------------------------------------------
# 1. pw.x RELAX calculation
# ------------------------------------------------------------------------

# N.B. instead of the below commands related to relaxation, one can also
# use the ::pwtk::relax_fromXSF workflow (see the pdos-CORh.pwtk example)

# load the structure from the XSF file with
# ::pwtk::pwi::CELL_PARAMETERS_and_ATOMIC_POSITIONS_fromXSF
CELL_PARAMETERS_and_ATOMIC_POSITIONS_fromXSF CO-Rh100-c2x2-2L.xsf

# fix the bottom layer of Rh atoms (there are two atoms per c(2x2)
# layer) with ::pwtk::pwi::fixAtomsLast
fixAtomsLast 2

# run a pw.x calculation with ::pwtk::runPW

runPW relax.$name.in

# load the optimized coordinates from the pw.x output with the
# ::pwtk::pwi::ATOMIC_POSITIONS_fromPWO

ATOMIC_POSITIONS_fromPWO relax.$name.out


# ------------------------------------------------------------------------
# 2. DIFDEN calculation
# ------------------------------------------------------------------------

# for DIFDEN, we need SCF calculation
CONTROL { calculation = 'scf' }

# SCF calculation don't need IONS namelist, clear it with
# 'input_clear', a shortcut to ::pwtk::input::clear
input_clear IONS

# pp.x specs:
#
# 1. calculate charge-density (plot_num = 0)
INPUTPP {
    plot_num = 0
}
# 2. make a fast 3D datagrid calculation of the whole unit-cell, and save
#    in the XSF file; here we use double quotes to use the $name variable
PLOT "
    iflag = 3 
    output_format = 5 
    fileout = 'difden.$name.xsf'
"
    
# DIFDEN specs: define the CO and Rh(100) fragments
DIFDEN {
    segment(1) = all
    weight(1)  = 1.0
    name(1)    = CORh100
    
    segment(2) = 1-2
    weight(2)  = -1.0
    name(2)    = CO
    
    segment(3) = 3-
    weight(3)  = -1.0
    name(3)    = Rh100
}

# let's treat the CO fragment (segment #.2) as a molecule (i.e., no smearing)
#
# To instruct PWTK to perform specialized calculation for segment #2, use
# 'difden_segmentSpec', a shortcut to ::pwtk::difden::segmentSpecialization
difden_segmentSpec 2 {  
    SYSTEM {
        ! this is how we clear the namelist variables in PWTK
        occupations = 
        smearing =
        degauss =
    }
    K_POINTS gamma
}

# DIFDEN workflow is run with 'difden_run', which is a shortcut to ::pwtk::difden::run

difden_run difden.$name

# ------------------------------------------------------------------------
# 3. PDOS calculation
# ------------------------------------------------------------------------

printTitle PDOS "PDOS calculation of $name with a denser k-mesh"

# input specs for projwfc.x 
PROJWFC {
    ngauss  = 0
    degauss = 0.01
    DeltaE  = 0.05
}

pdos_run -k {8 8 1} -t png $name

# ------------------------------------------------------------------------
# 3.1 Plot the atom projected DOS
# ------------------------------------------------------------------------

# Let's plot LDOSes of atoms involved in the CO-Rh bonding, i.e.,
# O + C + Rh(that bonds with CO).
#
# Before plotting the LDOSes, we need to sum all the constituent
# *.pdos_atm* files. To this end, we use ::pwtk::sumldos

sumldos -f $name -s O O.LDOS
sumldos -f $name -s C C.LDOS
sumldos -f $name -n 4 Rh.LDOS; # Rh that bonds with CO is the atom #.4

# get the Fermi energy from nscf.$name.out and plot the LDOSes into
# a PNG image with ::pwtk::ldos_plot

set png [ldos_plot -t png -e nscf.$name.out -xr -10:4 {O.LDOS C.LDOS Rh.LDOS} CO-Rh_ldos]
print "LDOSes plotted into a single-plot PNG image:  $png"

# let' plot each LDOS in a separate plot with ::pwtk::ldos_multiplot

set png [ldos_multiplot -t png -e nscf.$name.out -xr -10:4 -nx 1 {O.LDOS C.LDOS Rh.LDOS} CO-Rh_ldos-multi]
print "LDOSes plotted into a multi-plot PNG image:  $png"

# let's also plot unshifted LDOSes by setting the Fermi energy to 0,
# so that we can pick the proper ranges for the ILDOSes

set png [ldos_multiplot -t png -e 0.0 -xr -7:7 -nx 1 {O.LDOS C.LDOS Rh.LDOS} ldos_Ef-set-to-zero]
print "Non-shifted LDOSes plotted into a multi-plot PNG image:  $png"



# ------------------------------------------------------------------------
# 4. ILDOS calculations
# ------------------------------------------------------------------------

printTitle ILDOS "Calculating ILDOSes of $name"
    
# request ILDOS 
INPUTPP {
    plot_num = 10,
}

# these [Emin,Emax] ranges were determined by examining the
# 'ldos_Ef-set-to-zero.png' plot, generated above with "-e 0.0"

foreach {Emin Emax} {
    -6.00 -5.50
    -3.40 -3.30
    -3.05 -2.95
    -2.90 -2.70
     0.80  3.00
     4.00  6.50
} {
    set head ildos_${Emin}_${Emax}.$name

    # we use double quotes instead of curly braces to use variables
    
    INPUTPP " Emin = $Emin, Emax = $Emax "
    PLOT    " fileout = '$head.xsf' "
    
    runPP pp.$head.in
    print "ILDOS for the \[$Emin,$Emax\] eV range written to XSF file :  $head.xsf"

    # let's make a PNG image of ILDOS with xcrysden, which is executed
    # with the ::pwtk::try_exec -i command (the -i option stands for
    # "ignore error")
    
    try_exec -i xcrysden -r 2 --xsf $head.xsf -s ildos.xcrysden --print $head.png
    print "ILDOS for the \[$Emin,$Emax\] eV range printed to PNG file :  $head.png\n"
}