#!/bin/sh # run from directory where this script is cd `echo $0 | sed 's/\(.*\)\/.*/\1/'` # extract pathname EXAMPLE_DIR=`pwd` # check whether echo has the -e option if test "`echo -e`" = "-e" ; then ECHO=echo ; else ECHO="echo -e" ; fi $ECHO $ECHO "$EXAMPLE_DIR : starting" $ECHO $ECHO "This example shows how to use cp.x to calculate Wannier functions and" $ECHO "to perform dynamics with an external electric field." # set the needed environment variables . ../../../environment_variables # required executables and pseudopotentials BIN_LIST="cp.x" PSEUDO_LIST="H.blyp-vbc.UPF O.blyp-mt.UPF" $ECHO $ECHO " executables directory: $BIN_DIR" $ECHO " pseudo directory: $PSEUDO_DIR" $ECHO " temporary directory: $TMP_DIR" $ECHO $ECHO " checking that needed directories and files exist...\c" # check for directories for DIR in "$BIN_DIR" "$PSEUDO_DIR" ; do if test ! -d $DIR ; then $ECHO $ECHO "ERROR: $DIR not existent or not a directory" $ECHO "Aborting" exit 1 fi done for DIR in "$TMP_DIR" "$EXAMPLE_DIR/results" ; do if test ! -d $DIR ; then mkdir $DIR fi done cd $EXAMPLE_DIR/results # check for executables for FILE in $BIN_LIST ; do if test ! -x $BIN_DIR/$FILE ; then $ECHO $ECHO "ERROR: $BIN_DIR/$FILE not existent or not executable" $ECHO "Aborting" exit 1 fi done # check for pseudopotentials for FILE in $PSEUDO_LIST ; do if test ! -r $PSEUDO_DIR/$FILE ; then $ECHO $ECHO "Downloading $FILE to $PSEUDO_DIR...\c" $WGET $PSEUDO_DIR/$FILE \ http://www.quantum-espresso.org/pseudo/1.3/UPF/$FILE 2> /dev/null fi if test $? != 0; then $ECHO $ECHO "ERROR: $PSEUDO_DIR/$FILE not existent or not readable" $ECHO "Aborting" exit 1 fi done $ECHO " done" # how to run executables CP_COMMAND="$PARA_PREFIX $BIN_DIR/cp.x $PARA_POSTFIX" $ECHO $ECHO " running cp.x as: $CP_COMMAND" $ECHO # clean TMP_DIR $ECHO " cleaning $TMP_DIR...\c" rm -rf $TMP_DIR/* $ECHO " done" cat > h2o.scf.xml << EOF 0.0 0.0 0.0 0.0 0.0 8.0 O.blyp-mt.UPF 1.0 H.blyp-vbc.UPF 5.093750000000 5.093750000000 5.093750000000 3.648508572765 5.093750000000 3.967985471743 6.538991443058 5.093750000000 3.967985459417 $PSEUDO_DIR/ $TMP_DIR/ from_scratch 1 FALSE TRUE 70.0 1.0d-6 1.0d-2 280.0 1.d-8 4 1000 1.0d0 TRUE 50 400.d0 3.d0 1.0d-8 Gram-Schmidt TRUE 0.3 250 EOF $ECHO " running electronic minimization...\c" $CP_COMMAND < h2o.scf.xml > h2o.scf.out check_failure $? $ECHO " done" cat > h2o.wannier.xml << EOF 0.0 0.0 0.0 0.0 0.0 8.0 O.blyp-mt.UPF 1.0 H.blyp-vbc.UPF 5.093750000000 5.093750000000 5.093750000000 3.648508572765 5.093750000000 3.967985471743 6.538991443058 5.093750000000 3.967985459417 $PSEUDO_DIR/ $TMP_DIR/ restart 1 FALSE TRUE 70.0 1.0d-6 1.0d-2 280.0 1.d-8 4 1000 1.0d0 none TRUE 50 51 400.d0 3.d0 1.0d-8 200 Gram-Schmidt TRUE 0.3 250 3 4 100 100 1.0D-14 EOF $ECHO " running Wannier function calculation...\c" $CP_COMMAND < h2o.wannier.xml > h2o.wannier.out check_failure $? $ECHO " done" $ECHO "">> h2o.wannier.out $ECHO " Wannier functions centers:">> h2o.wannier.out tail -4 $TMP_DIR/h2o_mol.wfc >> h2o.wannier.out tail -4 fort.24 >> h2o.wannier.out $ECHO $ECHO "$EXAMPLE_DIR: done"