#!/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 perform"
$ECHO "Born-Oppenheimer molecular dynamics using the"
$ECHO "conjugate gradient minimization of the electronic"
$ECHO "states. It shows also the use of ensemble-DFT"
$ECHO "for metallic systems."
$ECHO "The example shows a Si dimer"
# set the needed environment variables
. ../../../environment_variables
# required executables and pseudopotentials
BIN_LIST="cp.x"
PSEUDO_LIST="Si.pbe-rrkj.UPF"
$ECHO
$ECHO " executables directory: $BIN_DIR"
$ECHO " pseudo directory: $PSEUDO_DIR"
$ECHO " temporary directory: $TMP_DIR"
$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"
# molecular dynamics calculation
cat > si2.ensemble-dyn.xml << EOF
1.0 1.5 0.0 0.0 0.0
28.086Si.pbe-rrkj.UPF0.8d0
0.0 0.0 0.0
0.0 0.0 5.5
$PSEUDO_DIR/
$TMP_DIR/
from_scratch
10
TRUE
TRUE
random
from_input
15.0
60.0
1.d-6
8
ensemble
fd
0.025
1
5
10.0d0
damp
not_controlled
10
20
20
20
1000.d0
4.d0
Gram-Schmidt
0.02
8
TRUE
0.3
250
0.0
1.0
EOF
$ECHO " running the calculation BO-MD for Si-dimer...\c"
$CP_COMMAND < si2.ensemble-dyn.xml > si2.ensemble-dyn.out
check_failure $?
$ECHO " done"
$ECHO
$ECHO "$EXAMPLE_DIR : done"