geom.functions.general
Functions
|
Parses command-line arguments and determines the operation mode. |
Prints the help message with usage instructions and exits the program. |
|
|
Parses translation-related command-line arguments. |
|
Parses rotation-related command-line arguments. |
|
Parses command-line arguments for performing a mirror reflection. |
|
Parses command-line arguments for merging geometries. |
|
TO DO |
|
Parses command-line arguments for calculating the minimum distance between two geometries. |
|
Parses command-line arguments for computing the geometric center of a structure. |
|
Parses command-line arguments for generating different types of geometries. |
|
Parses dimer-related command-line arguments and updates the inp object. |
|
Parses bowtie-related command-line arguments and updates the inp object. |
|
Parses alloy-related command-line arguments and updates the inp object. |
|
Checks if a given file exists. |
|
Checks if the given metallic atom type follows an FCC arrangement. |
|
Checks if the given metallic atom type follows either an FCC or BCC arrangement. |
|
Checks if the input file has the correct extension. |
|
Checks if the input file has a RDKit-supported extension. |
|
Checks if a parameter is in the list of accepted parameters. |
|
Validates the direction axis input for translation or rotation. |
Creates the results_geom directory if it does not already exist. |
|
|
Extract the argument(s) that follow a CLI flag. |
|
Extract the argument that follows a CLI flag and cast it to a given type. |
|
Extract the argument that follows a CLI flag and cast it to a given type. |
|
Checks if two input files have the same extension. If yes, raises an error. |
Module Contents
- geom.functions.general.read_command_line(argv, inp)[source]
Parses command-line arguments and determines the operation mode.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Calls the appropriate parsing function or displays help.
- Return type:
None
Notes
If no arguments are provided, an error is raised.
Recognizes different command-line options and triggers the corresponding function.
Prints help if -h or -help is passed.
- geom.functions.general.print_help()[source]
Prints the help message with usage instructions and exits the program.
- Returns:
Displays the help text and terminates execution.
- Return type:
None
- geom.functions.general.parse_translation(argv, inp)[source]
Parses translation-related command-line arguments.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Sets translation-related attributes in inp.
- Return type:
None
Notes
Handles both controlled distance translation (-t), simple shift translation (-t1), and translation of geometrical center to the center of coordinates (-tc).
Extracts input filenames, translation parameters, and verbosity settings.
- geom.functions.general.parse_rotation(argv, inp)[source]
Parses rotation-related command-line arguments.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Sets rotation-related attributes in inp.
- Return type:
None
Notes
Handles both list-based rotation (-r) and single-angle rotation (-r1).
Extracts input filenames and rotation parameters.
- geom.functions.general.parse_mirror(argv, inp)[source]
Parses command-line arguments for performing a mirror reflection.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Sets mirroring attributes in inp.
- Return type:
None
- geom.functions.general.parse_merge(argv, inp)[source]
Parses command-line arguments for merging geometries.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Sets merging attributes in inp.
- Return type:
None
Notes
Requires two geometry files and a cutoff distance.
- geom.functions.general.parse_min(argv, inp)[source]
Parses command-line arguments for calculating the minimum distance between two geometries.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Sets minimum distance calculation attributes in inp.
- Return type:
None
- geom.functions.general.parse_center(argv, inp)[source]
Parses command-line arguments for computing the geometric center of a structure.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Sets geometric centering attributes in inp.
- Return type:
None
- geom.functions.general.parse_create(argv, inp)[source]
Parses command-line arguments for generating different types of geometries.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance containing input parameters.
- Returns:
Sets attributes in inp for geometry generation.
- Return type:
None
Notes
Handles the creation of graphene structures, nanoparticles, and bulk metal structures.
Validates input parameters and extracts atomic and structural properties.
- geom.functions.general.parse_dimer_argument(argv, inp, output)[source]
Parses dimer-related command-line arguments and updates the inp object.
- Parameters:
argv (list[str]) – Command-line arguments list.
inp (input_class) – The input class instance where dimer attributes are stored.
output (module) – The output module for error handling.
- Returns:
Updates inp.create_dimer, inp.distances, and inp.dir_axis_input.
- Return type:
None
Notes
Searches for “-dimer” in argv.
Reads the next argument as a float and stores it in inp.distances as a list.
Reads the following argument as an axis specification (+x, -y, +z, etc.).
Ensures the extracted values are valid.
- geom.functions.general.parse_bowtie_argument(argv, inp, output)[source]
Parses bowtie-related command-line arguments and updates the inp object.
- Parameters:
argv (list[str]) – List of command-line arguments.
inp (input_class) – An instance of the input class where bowtie attributes are stored.
output (module) – The output module used for error handling.
- Returns:
This function does not return a value but updates inp.create_bowtie, inp.distances, and inp.dir_axis_input.
- Return type:
None
- Raises:
ValueError – If bowtie arguments are missing or contain invalid values.
Notes
This function checks if “-bowtie” is present in argv.
If found, it ensures that the bowtie structure is only available for tip, pyramid (square/pentagonal base) , cone, and microscope structures.
The function then extracts the bowtie distance (must be a positive float).
If any validation fails, it calls output.error() to handle errors.
- geom.functions.general.parse_alloy_arguments(argv, inp, output)[source]
Parses alloy-related command-line arguments and updates the inp object.
- Parameters:
argv (list[str]) – Command-line arguments list.
inp (input_class) – The input class instance where alloy attributes are stored.
output (module) – The output module for error handling.
- Returns:
Updates inp attributes based on the parsed alloy arguments.
- Return type:
None
Notes
- Handles both cases:
-alloy atom_type -percentual float
-alloy -percentual float
Ensures inp.alloy_perc is a valid float and between 0 and 100.
If atom type is omitted, it defaults to inp.atomtype.
- geom.functions.general.check_file_exists(infile)[source]
Checks if a given file exists.
- Parameters:
infile (str) – Path to the input file.
- Returns:
Raises an error if the file is not found.
- Return type:
None
- geom.functions.general.check_FCC(atomtype, string)[source]
Checks if the given metallic atom type follows an FCC arrangement.
- Parameters:
atomtype (str) – Type of metal atom.
string (str) – Structure name being validated.
- Returns:
Raises an error if the atom type is not FCC.
- Return type:
None
- geom.functions.general.check_FCC_or_BCC(atomtype)[source]
Checks if the given metallic atom type follows either an FCC or BCC arrangement.
- Parameters:
atomtype (str) – Type of metal atom.
- Returns:
Raises an error if the atom type is not FCC or BCC.
- Return type:
None
- geom.functions.general.check_file_extension(infile, extension)[source]
Checks if the input file has the correct extension.
- Parameters:
infile (str) – Path to the input file.
extension (str) – Expected file extension.
- Returns:
Raises an error if the file does not have the expected extension.
- Return type:
None
- geom.functions.general.check_file_extension_rdkit(infile, accepted_extensions)[source]
Checks if the input file has a RDKit-supported extension.
- Parameters:
infile (str) – Path to the input file.
accepted_extensions (list) – List of accepted file extensions for RDKit.
- Returns:
Raises an error if the file extension is not supported.
- Return type:
None
- geom.functions.general.check_accepted_parameters(param, accepted_params, label='Parameter')[source]
Checks if a parameter is in the list of accepted parameters.
- Parameters:
param (str) – Parameter value to check.
accepted_params (list) – List of accepted parameter values.
label (str, optional) – Label for the parameter in error messages.
- Returns:
Raises an error if the parameter is not in accepted parameters.
- Return type:
None
- geom.functions.general.check_dir_axis(inp)[source]
Validates the direction axis input for translation or rotation.
- Parameters:
inp (input_class) – An instance containing input parameters.
- Returns:
Updated inp with validated direction axis settings.
- Return type:
Notes
Ensures that the axis is properly formatted (e.g., +x, -y).
Assigns the corresponding numerical translation factor.
- geom.functions.general.create_results_geom()[source]
Creates the results_geom directory if it does not already exist.
- Returns:
Ensures that output files can be stored in the correct location.
- Return type:
None
- geom.functions.general.extract_string_or_list(argv, flag)[source]
Extract the argument(s) that follow a CLI flag.
- Accepts:
<flag> CO -> [“CO”]
<flag> “CO” -> [“CO”]
<flag> CO,OH -> [“CO”,”OH”]
<flag> [“CO”,”OH”] -> [“CO”,”OH”] (quoted or unquoted list)
<flag> [CO, OH] -> [“CO”,”OH”] (bare items)
Returns a list of strings.
- geom.functions.general.extract_value(argv, flag, value_type)[source]
Extract the argument that follows a CLI flag and cast it to a given type.
- Parameters:
argv (list) – Command-line arguments.
flag (str) – Flag to search for (case-insensitive).
value_type (type) – Expected Python type (e.g., str, int, float).
- Returns:
The value converted to the expected type.
- Raises:
ValueError – If the flag is present but has no value, or if the value cannot be converted to the expected type.
SystemExit – If the flag is not found (via output.error()).
- geom.functions.general.extract_value_or_default(argv, flag, value_type=str, default=None)[source]
Extract the argument that follows a CLI flag and cast it to a given type. If the flag is absent or has no following value, return the provided default. If the flag is present but the value is not convertible to the requested type, raise ValueError.
- Parameters:
argv (list[str]) – Command-line arguments.
flag (str) – Flag to search for (case-insensitive).
value_type (type) – One of {str, int, float}.
default (Any) – Default value if the flag is missing or has no argument. If not None, its type must match value_type.
- Returns:
The value converted to value_type, or default when appropriate.
- Return type:
Any
- Raises:
TypeError – If value_type is unsupported, or default’s type doesn’t match value_type.
ValueError – If the flag is present but the following token can’t be converted to value_type.