From daf40074b2e90a00b8b6b5eb243d790a18d2156a Mon Sep 17 00:00:00 2001 From: "Oleg E. Peil" Date: Fri, 11 Mar 2016 18:49:29 +0100 Subject: [PATCH] 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. --- python/converters/plovasp/sc_dmft.py | 16 +++++- python/converters/plovasp/sc_dmft.sh | 9 --- shells/CMakeLists.txt | 4 ++ shells/vasp_dmft.bash.in | 85 ++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 12 deletions(-) delete mode 100755 python/converters/plovasp/sc_dmft.sh create mode 100755 shells/vasp_dmft.bash.in diff --git a/python/converters/plovasp/sc_dmft.py b/python/converters/plovasp/sc_dmft.py index 031d7aa6..02b5117a 100644 --- a/python/converters/plovasp/sc_dmft.py +++ b/python/converters/plovasp/sc_dmft.py @@ -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() diff --git a/python/converters/plovasp/sc_dmft.sh b/python/converters/plovasp/sc_dmft.sh deleted file mode 100755 index ec473911..00000000 --- a/python/converters/plovasp/sc_dmft.sh +++ /dev/null @@ -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 - diff --git a/shells/CMakeLists.txt b/shells/CMakeLists.txt index 3a39ed6c..42e6bc38 100644 --- a/shells/CMakeLists.txt +++ b/shells/CMakeLists.txt @@ -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) + diff --git a/shells/vasp_dmft.bash.in b/shells/vasp_dmft.bash.in new file mode 100755 index 00000000..aa17a211 --- /dev/null +++ b/shells/vasp_dmft.bash.in @@ -0,0 +1,85 @@ +#/bin/bash + +MPIRUN_CMD=mpirun + +show_help() +{ +echo " +Usage: vasp_dmft [-n ] -i [-p ] [] + + If the number of cores is note specified it is set to 1 by default. + + 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 +