data_management.generate_molecules ================================== .. py:module:: data_management.generate_molecules .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: data_management.generate_molecules.Molecule Functions --------- .. autoapisummary:: data_management.generate_molecules._parse_molecules_xyz data_management.generate_molecules._parse_molecules data_management.generate_molecules._write_load_molecules data_management.generate_molecules.main data_management.generate_molecules.parse_args Module Contents --------------- .. py:class:: Molecule Representation of a molecule. .. py:attribute:: carts :value: [] .. py:attribute:: atoms :value: [] .. py:method:: add_atom(Z: int, carts: list) -> None Adds an atom at the specified cartesian coordinates. :param Z: Atomic number :type Z: int :param carts: Cartesian coordinates :type carts: list of float .. py:method:: __repr__() -> str Text representation of the molecule. :return: Text representation of the molecule :rtype: str .. py:method:: cxxify(tab: str = ' ') -> str C++ representation of the molecule. :param indent: The current indentation :type indent: str :param tab: The current tab character, defaults to " " :type tab: str, optional :return: C++ string representing the molecule :rtype: str .. py:function:: _parse_molecules_xyz(filepaths: list, sym2Z: dict, ang2au: float) -> Molecule Parses an XYZ formatted molecule file. :param file_name: Full paths to molecule files. :type file_name: list of str :param sym2Z: Mapping from lowercased atomic symbols to atomic numbers :type sym2Z: dict :param ang2au: Ratio of angstroms to atomic units :type ang2au: float :return: Molecule parsed from file. :rtype: Molecule .. py:function:: _parse_molecules(filepaths: list, sym2Z: dict, ang2au: float, extension: str = '.xyz') -> dict Parse molecule files of the specified format. :param filepaths: Full paths to molecule files. :type filepaths: list of str :param sym2Z: Mapping from lowercased atomic symbols to atomic numbers :type sym2Z: dict :param ang2au: Ratio of angstroms to atomic units :type ang2au: float :param extension: File format extension to parse, defaults to ".xyz" :type extension: str, optional :raises RuntimeError: Unsupported atomic density file format. :return: Collection of molecules :rtype: dict of Molecule .. py:function:: _write_load_molecules(src_dir: str, mols: dict, tab: str = ' ') -> None Write the load_molecules.cpp file with all parsed molecules. :param src_dir: ``src`` directory to write load_molecules.cpp to :type src_dir: str :param mols: Dictionary of names to :class:Molecule :type mols: dict of str to :class:Molecule :param tab: String representing a tab character :type tab: str .. py:function:: main(args: argparse.Namespace) -> None Entry point function to generate atomic density files. :param args: Command line argument namespace :type args: Namespace .. py:function:: parse_args() -> argparse.Namespace Parse command line arguments. :return: Values of command line arguments. :rtype: Namespace