From 205cd9ac1df32710b203e0cd77a1a1275dfa48cb Mon Sep 17 00:00:00 2001 From: Benjamin Morgan Date: Fri, 20 Oct 2017 16:09:56 +0100 Subject: [PATCH] Added Python version of mkpotcar Currently named mkpotcar.py This breaks compatibility with how the environment variable POTCARDIR is used. For this version of the code, the pseudopotential set is left out (e.g. 'PBE_54' ), and then added automatically in the script. This can be switched using the '--potcar-set' flag. --- mkpotcar.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 mkpotcar.py diff --git a/mkpotcar.py b/mkpotcar.py new file mode 100755 index 0000000..7ff37de --- /dev/null +++ b/mkpotcar.py @@ -0,0 +1,28 @@ +#! /usr/bin/env python3 + +import os +import argparse +import sys + +parser = argparse.ArgumentParser( description='Construct a VASP POTCAR file' ) +parser.add_argument( 'potcars', metavar='P', type=str, nargs='+', help='the string identifying each POTCAR directory.' ) +parser.add_argument( '--potcar-set', default='PBE_54', help='choose which POTCAR set to use' ) +args = parser.parse_args() + +try: + potcardir = os.path.join( os.environ['POTCARDIR'], args.potcar_set ) +except KeyError: + raise( '$POTCARDIR is not set' ) + +if not os.path.isdir( potcardir ): + raise ValueError( 'Cannot find directory f{potcardir}' ) + +for potcar in args.potcars: + if not os.path.isdir( os.path.join( potcardir, potcar ) ): + print( '{} not found in {}'.format( potcar, potcardir ) ) + print( 'Available pseudopotentials ({})'.format( args.potcar_set) ) + os.system( 'get_potcar_list.py' ) # This should be a module call instead. + sys.exit() + +for potcar in args.potcars: + os.system( 'cat {}/POTCAR'.format( os.path.join( potcardir, potcar ) ) )