Skip to content

Commit

Permalink
Added Python version of mkpotcar
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bjmorgan committed Oct 20, 2017
1 parent 122c517 commit 205cd9a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions mkpotcar.py
Original file line number Diff line number Diff line change
@@ -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 ) ) )

0 comments on commit 205cd9a

Please sign in to comment.