TABLE OF CONTENTS
62-xxxrun
DESCRIPTION
This example shows how to use the ::pwtk::prerun and ::pwtk::postrun mechanisms with which we instruct PWTK to execute the supplied script snippets just before and after the calculation, respectively. This possibility allows reusing existing workflows in various circumstances, as illustrated below with a simple example.
In this example, the CO and NO molecules on Rh(100) are relaxed with the ::pwtk::relax_fromXSF workflow.
EXAMPLE SOURCE FILE
SOURCE
# import the pw.x input data from CORh.pwtk import CORh.pwtk # for the NO molecule, we also need the N pseudopotential cardPrepend ATOMIC_SPECIES { N 1.0 N.pbe-rrkjus.UPF } # With ::pwtk::prerun, we instruct PWTK to evaluate a supplied script # snippet just before running the calculation. This possibility allows # to reuse workflows in various circumstances. # # To illustrate the point, this example uses the ::pwtk::relax_fromXSF # workflow, which loads the ATOMIC_POSITIONS from the XSF file and # performs a full relaxation calculation. # # However, instead of a full relaxation, we would like to fix some # atoms instead. This can be achieved with ::pwtk::prerun as follows: prerun pw.x { # let's fix the bottom layer Rh atoms with ::pwtk::pwi::fixAtomsLast, # which are the two last atoms in CO-Rh100-c2x2-2L.xsf and NO-Rh100-c2x2-2L.xsf print "Fixing the bottom layer Rh atoms" fixAtomsLast 2 } # With ::pwtk::postrun, we instruct the PWTK to evaluate a supplied # script snippet just after the calculation is completed. postrun pw.x { # let's print some info to stdout, i.e. the number of relaxation # iterations and the last total energy # # N.B. in the postrun script, the name of the output file is # stored in the $output variable set niter [llength [pwtk::egrep ^! $output]] set totene [pwo_totene $output] print "Relaxed total energy = $totene Ry\nRelaxation took $niter iterations.\n" } # the ::pwtk::relax_fromXSF workflow loads the ATOMIC_POSITIONS from # the XSF file and performs a structural relaxation. # # If the -cell option is specified, also the CELL_PARAMETERS are # loaded from the XSF file. relax_fromXSF pw.x -cell CO-Rh100-c2x2-2L.xsf relax_fromXSF pw.x -cell NO-Rh100-c2x2-2L.xsf # N.B. # the ::pwtk::relax_fromXSF workflow has the command-line options for # fixing atoms, but here we pretended it has not as to illustrate the # utility of the ::pwtk::prerun mechanism.