Added a charge self-consistency script

The charge self-consistency script is run from bin directory.
The corresponding Python script 'sc_dmft.py' has been modified
accordingly.
This commit is contained in:
Oleg E. Peil 2016-03-11 18:49:29 +01:00
parent ea87d5bf11
commit daf40074b2
4 changed files with 102 additions and 12 deletions

View File

@ -31,7 +31,6 @@ import sys
import time
import pytriqs.utility.mpi as mpi
import converters.plovasp.main as plovasp
from test_ham_hf import dmft_cycle
debug = True
#
@ -167,14 +166,20 @@ def run_all(vasp_pid):
mpi.report("***Done")
if __name__ == '__main__':
def main():
try:
vasp_pid = int(sys.argv[1])
except (ValueError, KeyError):
if mpi.is_master_node():
print "VASP process pid must be provided as the first argument"
raise
try:
dmft_script = re.sub("\.py$", "", sys.argv[2])
except:
if mpi.is_master_node():
print "User-defined DMFT script must be provided as the second argument"
raise
# if len(sys.argv) > 1:
# vasp_path = sys.argv[1]
# else:
@ -186,4 +191,9 @@ if __name__ == '__main__':
# raise
signal.signal(signal.SIGINT, sigint_handler)
from dmft_script import dmft_cycle
run_all(vasp_pid)
if __name__ == '__main__':
main()

View File

@ -1,9 +0,0 @@
#/bin/bash
NPROC=4
rm -f vasp.lock
stdbuf -o 0 mpirun -np $NPROC ~/Codes/vasp/build_20151202/vasp.5.4.2/build/std/vasp &
mpirun -np $NPROC ./run_build.sh sc_dmft.py $(jobs -p) || kill %1

View File

@ -3,3 +3,7 @@ configure_file(plovasp.bash.in plovasp)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plovasp DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
configure_file(vasp_dmft.bash.in vasp_dmft)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/vasp_dmft DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

85
shells/vasp_dmft.bash.in Executable file
View File

@ -0,0 +1,85 @@
#/bin/bash
MPIRUN_CMD=mpirun
show_help()
{
echo "
Usage: vasp_dmft [-n <number of cores>] -i <number of iterations> [-p <path to VASP directory>] [<dmft_script.py>]
If the number of cores is note specified it is set to 1 by default.
<dmft_script.py> must provide an importable function 'dmft_cycle()' which is invoked
once per DFT+DMFT iteration. If the script name is omitted the default name
'csc_dmft.py' is used.
If the path to VASP directory is not specified it must be provided by a
variable VASP_DIR.
"
}
while getopts ":n:i:" opt; do
case $opt in
n)
# echo "Option: Ncpu, argument: $OPTARG"
if [ -n "$OPTARG" ]; then
NPROC=$OPTARG
# echo "Number of cores: $NPROC"
fi
;;
i)
# echo "Option: Niter"
if [ -n "$OPTARG" ]; then
NITER=$OPTARG
# echo "Number of iterations: $NITER"
fi
;;
p)
if [ -n "$OPTARG" ]; then
VASP_DIR=$OPTARG
fi
;;
:)
echo " Error: Option -$OPTARG requires an argument" >&2
show_help
exit 1
;;
\?)
echo " Error: Invalid option -$OPTARG" >&2
esac
done
if [ -z "$NITER" ]; then
echo " Error: Number of iterations must be specified with option -i" >&2
show_help
exit 1
fi
if [ -z "$VASP_DIR" ]; then
echo " Error: A path to VASP directory must be given either with option -p or by setting variable VASP_DIR" >&2
show_help
exit 1
fi
if [ -z "$NPROC" ]; then
echo " Number of cores not specified, setting to 1"
NPROC=1
fi
shift $((OPTIND-1))
if [ -z "$1" ]; then
DMFT_SCRIPT=csc_dmft.py
else
DMFT_SCRIPT=$1
fi
echo " Number of cores: $NPROC"
echo " Number of iterations: $NITER"
echo " Script name: $DMFT_SCRIPT"
rm -f vasp.lock
stdbuf -o 0 $MPIRUN_CMD -np $NPROC "$VASP_DIR/vasp" &
$MPIRUN_CMD -np $NPROC pytriqs -m pytriqs.applications.dft.converters.plovasp.sc_dmft $(jobs -p) $DMFT_SCRIPT || kill %1