TABLE OF CONTENTS
14-convergence-tests-Cu
DESCRIPTION
This example shows how to run multiple pw.x calculations (i.e., scans over several parameters, such as energy-cutoff, k-points, and lattice-constant) and plot the results.
This example is similar to scan-Si.pwtk but more convergence tests is performed and the results are plotted.
EXAMPLE SOURCE FILE
SOURCE
# this test takes a while, hence let's activate the restart mode with # ::pwtk::restart, implying that if we rerun this script, the already # done calculations will be skipped. restart on # load the scf.Cu.in pw.x input file with ::pwtk::pwi::load_fromPWI load_fromPWI scf.Cu.in # ------------------------------------------------------------------------ # convergence-test #1: # # K_POINTS # ------------------------------------------------------------------------ # title can be printed to stdout with ::pwtk::printTitle printTitle TEST-1 "Convergence test #1: K_POINTS" set dat Cu.kpoint.dat; # name of datafile # make a scan over k-points with ::pwtk::scanpar # # N.B. the input data modified inside the 'scanpar' loop are # automatically reset, once the 'scanpar' is completed because it # internally uses the input stacking mechanism of ::pwtk::input::pushpop scanpar k { 4 8 12 16 } { # set the k-points K_POINTS automatic "$k $k $k 1 1 1" # name = prefix of the I/O files set name pw.Cu.scf.k-$k # use ::pwtk::runPW to perform the pw.x calculation runPW $name; # creates I/O files $name.in & $name.out # pwo_totene is a shortcut for ::pwtk::pwo::totene, which extracts # total energy from the pw.x output file, and ::pwtk::write is # used to write the 'scanpar' parameter and total energy to the # '$dat' datafile write $dat [pwo_totene $name.out] } # text can be printed to stdout with ::pwtk::print print TEST-1 "Total energies written to : $dat\n" # simple graphs can be plotted with ::pwtk::plot, which can plot into # a window (default) or file (eps, pdf, png...) # # plotting into a window is blocking (i.e. PWTK waits for window to # close before proceeding); to plot in a non-blocking mode, prefix the # plot command with ::pwtk::bg or ::pwtk::thread bg plot -xl "k of (k × k × k)" -yl "Total energy (Ry)" -yf %.4f $dat # this is how to plot into a PNG image set png [plot -t png -xl "k of (k × k × k)" -yl "Total energy (Ry)" -yf %.4f $dat] # PNG image can be displayed with ::pwtk::display, which open the # image with a suitable image-viewer available on a computer display $png &; # "&" executes viewer in a background (i.e. non-blocking) mode # ------------------------------------------------------------------------ # convergence-test #2: # # BASIS SET: ecutwfc & dual, where dual = ecutrho/ecutwfc # ------------------------------------------------------------------------ printTitle TEST-2 "Convergence test #2: BASIS SET (ecutwfc & dual)" print TEST-2 "dual = ecutrho / ecutwfc\n" # we do not want the 'dual' parameter to appear in the datafiles, # hence we use 'foreach' instead of 'scanpar' for the topmost loop foreach dual { 4 8 12 } { set dat Cu.ecutwfc.dual$dual.dat; # name of datafile scanpar ecutwfc [seq 25 5 45] { set name pw.Cu.scf.ecutwfc-$ecutwfc.dual-$dual SYSTEM "ecutwfc = $ecutwfc ecutrho = $ecutwfc*$dual" runPW $name; # creates I/O files $name.in & $name.out # 'write' writes the 'scanpar' parameter and total energy to # the '$dat' datafile write $dat [pwo_totene $name.out] } # add the current datafile to the list of datafiles (used later for plotting) lappend datList $dat; print TEST-2 "Total energies written to : $dat\n" } # to plot in a non-blocking mode, we can also use ::pwtk::thread thread plot -xl "ecutwfc (Ry)" -yl "Total energy (Ry)" -yf %.3f {*}$datList # ------------------------------------------------------------------------ # convergence-test #3: # # SMEARING & DEGAUSS vs K_POINTS # ------------------------------------------------------------------------ printTitle TEST-3 "Convergence test #3: SMEARING & DEGAUSS vs K-POINTS" foreach nk {4 8 12 16} { K_POINTS automatic "$nk $nk $nk 1 1 1" foreach smearing { gauss m-p m-v } { set dat $smearing.k$nk.dat; # name of datafile scanpar degauss {0.01 0.03 0.06 0.09} { SYSTEM " smearing = '$smearing' degauss = $degauss " write $dat [pwo_totene [runPW pw.Cu.scf.degauss-$degauss.$smearing.k$nk]] } # add the current datafile to the list of datafiles (used later for plotting) lappend data($smearing) $dat print TEST-3 "Total energies written to : $dat\n" } } # several plots per page can be created with ::pwtk::multiplot multiplot -xl "smearing (Ry)" -yl "Total energy (Ry)" -yf %.3f $data(gauss) $data(m-p) $data(m-v)