TABLE OF CONTENTS


13-scanpar-Si

DESCRIPTION

A somewhat better example than 12-scan-Si to perform a few convergency tests. This example uses the ::pwtk::scanpar machinery and plots the results.

This example also shows how to run non-supported QE programs (see the last part of this file).

EXAMPLE SOURCE FILE

scanpar-Si.pwtk

SOURCE

# input data for Si-bulk is imported from Si.pwtk with ::pwtk::import
import Si.pwtk

#------------------------
# scan #1: cuttofs energy
#------------------------
scanpar e [seq 10 4 30] {
    # N.B. ::pwtk::seq is analogous to the Unix 'seq' command 

    # load the new energy-cuttofs
    SYSTEM "ecutwfc = $e, ecutrho = 4*$e"
        
    # perform the pw.x calculation (I/O files: Si_e$e.scf.in & Si_e$e.scf.out)
    runPW pw.Si_e$e.scf

    # write total-energy to 'ecut.dat' datafile
    #
    # N.B. ::pwtk::write is aware that a scan over the 'e' parameter
    #      is performed and writes is automatically to the data file
    #
    # total energy is retrieved from the pw.x output file with
    # 'pwo_totene', which is a shortcut to ::pwtk::pwo::totene

    write ecut.dat [pwo_totene pw.Si_e$e.scf.out]
}
# N.B. the input data modified inside the 'scanpar' loop are
# automatically reset, once the 'scanpar' is completed. Hence, at this
# point, the above modifications were dismissed


# simple graphs can be plotted with ::pwtk::plot, which can plot into
# a window (default) or file (eps, pdf, png...)

plot -xl "ecutwfc (Ry)" -yl "Total energy (Ry)" ecut.dat


#------------------
# scan #2: k-points
#------------------
scanpar k {2 4 6 8} {
        
    # load new k-points
    K_POINTS automatic "$k $k $k   1 1 1"
        
    # perform the pw.x calculation (I/O files: Si_k$k.scf.in & Si_k$k.scf.out)
    runPW pw.Si_k$k.scf
    
    # write total-energy to 'k.dat' datafile
    write k.dat [pwo_totene pw.Si_k$k.scf.out]
}

# plot the results into a PNG image and diplay it with ::pwtk::display
#display [plot -t png -xl "k of (k × k × k)" -yl "Total energy (Ry)" k.dat] &

# alternatively, ploting into a PNG image and visualizing it can be
# achieved with the -v option
plot -v -t png -xl "k of (k × k × k)" -yl "Total energy (Ry)" k.dat


#---------------------------
# scan #3: lattice-parameter
#---------------------------
scanpar a [seq 9.2 0.2 10.8] {
        
    # load new celldm(1)
    SYSTEM " celldm(1) = $a "
    
    # perform the calculation (I/O files: Si_a$a.scf.in & Si_a$a.scf.out)
    runPW pw.Si_a$a.scf
    
    # write total-energy to a.dat datafile
    write a.dat [pwo_totene pw.Si_a$a.scf.out]
}

# plot the result into a window
plot -xl "Lattice parameter (bohr)" -yl "Total energy (Ry)" a.dat


# ev.x -- calculates the lattice parameter
#
# The ev.x executable is not directly supported by PWTK. Hence,
# the input file must be created "manually", e.g., with the
# ::pwtk::writeFile command.
#
# Non-supported QE executables are executed with the ::pwtk::run
# command; this command requires an existing input file.
#
# N.B.
# 1. ev.x is a serial code, hence we use "run -serial ..."
# 2. ev.x does not support the -in option, hence we use "run -ihandle < ..."

writeFile ev.Si.murnaghan.in "au
fcc
4
a.dat
a.out
"   
run -ihandle < -serial ev.x ev.Si.murnaghan.in

# an alternative option is to use ::pwtk::execute
execute -ignorestderr ev.x < ev.Si.murnaghan.in

# let's grep the lattice parameter
set a0 [::pwtk::grep_field "# a0" a.out 3 end]

print "
Calculated lattice of Si bulk:  [format %.3f $a0] Å
(for further details, see file a.out)
"