data_management.generate_molecules

This script will read each molecule file in the provided directory and generate a C++ source file with commands to make each molecule.

Usage

usage: generate_molecules.py [-h] [--ang2au ANG2AU] [-r] [-a ATOMS_DIR] molecule_dir src_dir

positional arguments:
  molecule_dir          Data directory for molecule files. If combined with the "-r" flag, this directory will be recursively searched.
  src_dir               Destination directory for generated source files.

options:
  -h, --help            show this help message and exit
  --ang2au ANG2AU       Ratio of angstroms to atomic units. (Default: 1.8897161646320724)
  -r, --recursive       Toggle on recursive search through molecule_dir 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
|       load_molecules.cpp

Classes

Molecule

Representation of a molecule.

Functions

_parse_molecules_xyz(→ Molecule)

Parses an XYZ formatted molecule file.

_parse_molecules(→ dict)

Parse molecule files of the specified format.

_write_load_molecules(→ None)

Write the load_molecules.cpp file with all parsed molecules.

main(→ None)

Entry point function to generate atomic density files.

parse_args(→ argparse.Namespace)

Parse command line arguments.

Module Contents

class data_management.generate_molecules.Molecule

Representation of a molecule.

carts = []
atoms = []
add_atom(Z: int, carts: list) None

Adds an atom at the specified cartesian coordinates.

Parameters:
  • Z (int) – Atomic number

  • carts (list of float) – Cartesian coordinates

__repr__() str

Text representation of the molecule.

Returns:

Text representation of the molecule

Return type:

str

cxxify(tab: str = '    ') str

C++ representation of the molecule.

Parameters:
  • indent (str) – The current indentation

  • tab (str, optional) – The current tab character, defaults to “ “

Returns:

C++ string representing the molecule

Return type:

str

data_management.generate_molecules._parse_molecules_xyz(filepaths: list, sym2Z: dict, ang2au: float) Molecule

Parses an XYZ formatted molecule file.

Parameters:
  • file_name (list of str) – Full paths to molecule files.

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

  • ang2au (float) – Ratio of angstroms to atomic units

Returns:

Molecule parsed from file.

Return type:

Molecule

data_management.generate_molecules._parse_molecules(filepaths: list, sym2Z: dict, ang2au: float, extension: str = '.xyz') dict

Parse molecule files of the specified format.

Parameters:
  • filepaths (list of str) – Full paths to molecule files.

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

  • ang2au (float) – Ratio of angstroms to atomic units

  • extension (str, optional) – File format extension to parse, defaults to “.xyz”

Raises:

RuntimeError – Unsupported atomic density file format.

Returns:

Collection of molecules

Return type:

dict of Molecule

data_management.generate_molecules._write_load_molecules(src_dir: str, mols: dict, tab: str = '    ') None

Write the load_molecules.cpp file with all parsed molecules.

Parameters:
  • src_dir (str) – src directory to write load_molecules.cpp to

  • mols (dict of str to :class:Molecule) – Dictionary of names to :class:Molecule

  • tab (str) – String representing a tab character

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

Entry point function to generate atomic density files.

Parameters:

args (Namespace) – Command line argument namespace

data_management.generate_molecules.parse_args() argparse.Namespace

Parse command line arguments.

Returns:

Values of command line arguments.

Return type:

Namespace