data_management.generate_basis

This script will loop over a series of basis sets and write out a file that will fill them in. The format of the resulting basis sets is suitable for use with the BasisSetExchange class.

Usage

usage: generate_basis.py [-h] [-r] [-a ATOMS_DIR] basis_set_source src_dir

positional arguments:
basis_set_source      Source directory for basis set files. If combined with the "-r" flag, this directory will be recursively searched for basis sets.
src_dir               Destination directory for generated source files.

options:
-h, --help            show this help message and exit
-r, --recursive       Toggle on recursive search through the basis set source directory. Default OFF.
-a ATOMS_DIR, --atoms_dir ATOMS_DIR
                      The path to where ElementNames.txt can be found.

This script creates the following files based on the include and source directories given. The directories are not created by this script and must be present before running it.

+---src_dir
|   \---bases
|           <all_basis_set_files>
|       basis_set_list.hpp
|       load_basis_sets.cpp

Classes

Shell

Class representing a shell for an element.

Functions

_write_basis_files(→ None)

_write_bases(→ None)

Writes basis set data to C++ files.

_parse_bases_gbs(→ dict)

Parses basis set files from the filepaths given.

_parse_bases_nw(→ dict)

Parses basis set files from the filepaths given.

_parse_bases(→ dict)

Parse basis set files of the specified format.

main(→ None)

Entry point function to generate basis set files.

parse_args(→ argparse.Namespace)

Parse command line arguments.

Module Contents

class data_management.generate_basis.Shell(ls: list, num_format: str = '.10e', is_pure=True)

Class representing a shell for an element.

ls
exp = []
coefs = []
gen = 0
number_format
shelltype
add_prim(exp: str, coefs: list) None

Add a primitive for the shell.

Parameters:
  • exp (str) – Primitive exponent

  • coefs (list of str) – Primitive contraction coefficients

cxxify(center: str, tab: str = '    ') str

Create a C++ source representation of the shell.

Parameters:
  • center (str) – chemist::Center to add the shell to

  • tab (str, optional) – String representing a tab, defaults to “ “

data_management.generate_basis._write_basis_files(out_file: str, bs_name: str, basis_set: dict, tab: str = '    ') None
data_management.generate_basis._write_bases(src_dir: str, bases: dict, tab='    ') None

Writes basis set data to C++ files.

Parameters:
  • src_dir (str) – Source directory for source files.

  • bases (dict) – Collection of basis sets parsed from files

  • tab – String representing a tab, defaults to “ ” :type tab: str, optional

data_management.generate_basis._parse_bases_gbs(basis_set_filenames: list, sym2Z: dict, l2num: function) dict

Parses basis set files from the filepaths given.

Parameters:
  • basis_set_filepaths (list) – Full paths to basis set files.

  • sym2Z (dict) – Dictionary associating atomic symbols to atomic numbers

  • l2num (function) – Function associating orbital letters with a number

Returns:

Collection of basis sets and the supported elements of each.

Return type:

dict

data_management.generate_basis._parse_bases_nw(basis_set_filepaths: list, sym2Z: dict, l2num: function) dict

Parses basis set files from the filepaths given.

Parameters:
  • basis_set_filepaths (list) – Full paths to basis set files.

  • sym2Z (dict) – Dictionary associating atomic symbols to atomic numbers

  • l2num (function) – Function associating orbital letters with a number

Returns:

Collection of basis sets and the supported elements of each.

Return type:

dict

data_management.generate_basis._parse_bases(basis_set_filepaths: list, sym2Z: dict, l2num: function, format: str = 'nwchem') dict

Parse basis set files of the specified format.

This function redirects to the correct parsing function based on the file format given. The data structure returned is a dict with basis set names as keys, effectively making a mapping from basis set names to basis sets. The basis set values are another dict with atomic numbers as keys and a list of Shell as the values. This makes a structure, basis_sets, where the basis for Z in basis_name can be accessed as:

list_of_shells = basis_sets[basis_name][Z]
Parameters:
  • basis_set_filepaths (list of str) – Full paths to basis set files.

  • sym2Z (dict) – Mapping from lowercased atomic symbols to atomic numbers

  • l2num (function) – Conversion function from shell symbol (s, p, d, f, etc) to the corresponding number (0, 1, 2, 3, etc)

  • format (str, optional) – File formatting to parse, defaults to “nwchem”

Returns:

Basis sets parsed

Return type:

dict

Raises:

RuntimeError – Unsupported basis file format.

data_management.generate_basis.main(args: argparse.Namespace) None

Entry point function to generate basis set files.

Parameters:

args (argparse.Namespace) – Command line argument namespace

data_management.generate_basis.parse_args() argparse.Namespace

Parse command line arguments.

Returns:

Values of command line arguments.

Return type:

argparse.Namespace