geom.functions.general

Functions

read_command_line(argv, inp)

Parses command-line arguments and determines the operation mode.

print_help()

Prints the help message with usage instructions and exits the program.

parse_translation(argv, inp)

Parses translation-related command-line arguments.

parse_rotation(argv, inp)

Parses rotation-related command-line arguments.

parse_mirror(argv, inp)

Parses command-line arguments for performing a mirror reflection.

parse_merge(argv, inp)

Parses command-line arguments for merging geometries.

parse_min(argv, inp)

Parses command-line arguments for calculating the minimum distance between two geometries.

parse_center(argv, inp)

Parses command-line arguments for computing the geometric center of a structure.

parse_create(argv, inp)

Parses command-line arguments for generating different types of geometries.

parse_dimer_argument(argv, inp, output)

Parses dimer-related command-line arguments and updates the inp object.

parse_bowtie_argument(argv, inp, output)

Parses bowtie-related command-line arguments and updates the inp object.

parse_alloy_arguments(argv, inp, output)

Parses alloy-related command-line arguments and updates the inp object.

check_file_exists(infile)

Checks if a given file exists.

check_FCC(atomtype, string)

Checks if the given metallic atom type follows an FCC arrangement.

check_FCC_or_BCC(atomtype)

Checks if the given metallic atom type follows either an FCC or BCC arrangement.

check_file_extension(infile, extension)

Checks if the input file has the correct extension.

check_dir_axis(inp)

Validates the direction axis input for translation or rotation.

create_results_geom()

Creates the results_geom directory if it does not already exist.

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) and simple shift translation (-t1).

  • 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, 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:
    1. -alloy atom_type -percentual float

    2. -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_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:

input_class

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