Skip to content

Commit

Permalink
Merge pull request #72 from vanderhe/stoExponentsScript
Browse files Browse the repository at this point in the history
Utility for Slater exponent generation
  • Loading branch information
bhourahine authored Jan 24, 2024
2 parents 69b245e + fe94a7e commit d138cf2
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions sktools/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ console_scripts =
collectspinw = sktools.scripts.collectspinw:main
collectwavecoeffs = sktools.scripts.collectwavecoeffs:main
skdiff = sktools.scripts.skdiff:main
skexp = sktools.scripts.skexp:main
skgen = sktools.scripts.skgen:main
skmanip = sktools.scripts.skmanip:main

Expand Down
104 changes: 104 additions & 0 deletions sktools/src/sktools/scripts/skexp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env python3

'''
Prints STO exponents according to the usual geometric series.
(see for example DOI: 10.1063/1.1679962)
'''

import argparse
import numpy as np


USAGE = \
'''
Prints a set of Slater-type orbital exponents, following the usual geometric
series for a given atomic number.
'''


def main(cmdlineargs=None):
'''Main driver routine.'''

args = parseargs(cmdlineargs)

exponents = get_exponents(
args.atnum, args.nexp, a0=args.a0, extra=args.extra)

print(((args.nexp + int(args.extra)) * ' {:.4f}').format(*exponents))


def parseargs(cmdlineargs):
'''Parses command line arguments and returns the parser instance.'''

parser = argparse.ArgumentParser(description=USAGE)

msg = 'atomic number of element to parametrize'
parser.add_argument('atnum', metavar='Z', type=int, help=msg)

msg = 'number of exponents'
parser.add_argument('nexp', metavar='N', type=int, help=msg)

msg = 'smallest exponent (default: 0.5)'
parser.add_argument('-s', '--start', metavar='a0', dest='a0',
default=0.5, type=float, help=msg)

msg = 'adds one additional exponent beyond the atomic number, proved to' + \
' be useful for large atoms like e.g. Au (default: False)'
parser.add_argument(
'-e', '--extra', dest='extra', action='store_true', help=msg)

args = parser.parse_args(args=cmdlineargs)

# check input consistence
if args.atnum < 1 or args.atnum > 118:
raise ValueError('Invalid atomic number, choose 0 < Z < 119.')

if args.nexp < 1:
raise ValueError('Invalid number of STO exponents, choose N > 0.')

if args.a0 <= 0.0:
raise ValueError('Invalid smallest exponents, choose positive a0.')

return args


def get_exponents(atnum, nexp, a0=0.5, extra=False):
'''Generates Slater exponents according to geometric series.
a0, a0*r, a0*r**2, a0*r**3, a0*r**4, ...
Args:
atnum (int): atomic number
nexp (int): number of exponents (excluding extra one)
a0 (float): smallest exponent, usually 0.5 or similar
extra (bool): add one more exponent beyond atomic number,
proved to useful for larger atoms like e.g. Au
Returns:
exponents (1darray): generated STO exponents
'''

rr = (a0 / float(atnum))**(1.0 / float((nexp - 1)))

if extra:
nn = nexp + 1
else:
nn = nexp

exponents = np.empty(nn, dtype=float)

if extra:
for iexp in range(nn):
exponents[nn - iexp - 1] = atnum * rr**float(iexp - 1)
else:
for iexp in range(nn):
exponents[nn - iexp - 1] = atnum * rr**float(iexp)

return exponents


if __name__ == '__main__':
main()

0 comments on commit d138cf2

Please sign in to comment.