Skip to content

Instantly share code, notes, and snippets.

@mhoffman
Created November 7, 2017 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhoffman/b20e81b9cc2839f1a30ab53ad66f9d3a to your computer and use it in GitHub Desktop.
Save mhoffman/b20e81b9cc2839f1a30ab53ad66f9d3a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import os.path
import optparse
import tempfile
parser = optparse.OptionParser(usage='%script <cube-filename>')
options, args = parser.parse_args()
if not args:
raise UserWarning("Expected cube file as first argument.")
cube_filename = args[0]
seed = os.path.splitext(cube_filename)[0]
os.system('bader -vac off {cube_filename}'.format(**locals()))
if os.path.exists('ACF.dat') and os.path.exists('BCF.dat'):
with open('{seed}.bader'.format(**locals()), 'w') as outfile:
outfile.write('########## BADER ATOMIC CHARGES for {seed}\n'.format(**locals()))
with open('ACF.dat') as infile:
outfile.write(infile.read())
outfile.write('\n\n########## BADER ATOMIC VOLUMES for {seed}\n'.format(**locals()))
with open('BCF.dat') as infile:
outfile.write(infile.read())
os.remove('BCF.dat')
os.remove('ACF.dat')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment