geom.functions.tools ==================== .. py:module:: geom.functions.tools Functions --------- .. autoapisummary:: geom.functions.tools.calc_min_distance geom.functions.tools.rotate geom.functions.tools.merge_geoms geom.functions.tools.subtract_geoms geom.functions.tools.determine_sphere_center geom.functions.tools.copy_geometry_file geom.functions.tools.delete_geometry_file geom.functions.tools.delete_all_files geom.functions.tools.create_dimer geom.functions.tools.create_bowtie geom.functions.tools.calculate_normal_and_rhs Module Contents --------------- .. py:function:: calc_min_distance(geom1, geom2) Calculates the minimum distance between two molecular geometries. :param geom1: The first molecule object. :type geom1: molecule :param geom2: The second molecule object. :type geom2: molecule :returns: The minimum distance between the two geometries. :rtype: float .. rubric:: Notes - Uses NumPy broadcasting for efficient pairwise distance computation. .. py:function:: rotate(mol, angle, dir_axis_input, mol_rot) Rotates a molecular geometry by a given angle around a specified axis. :param mol: The original molecule object. :type mol: molecule :param angle: The rotation angle in degrees. :type angle: float :param dir_axis_input: The rotation axis and sense (e.g., `+x`, `-y`). :type dir_axis_input: str :param mol_rot: A new molecule object to store the rotated geometry. :type mol_rot: molecule :returns: The rotated molecule object. :rtype: molecule .. rubric:: Notes - Rotation is performed using standard rotation matrices. - Supports rotation around x, y, and z axes. .. py:function:: merge_geoms(inp, geom1, geom2) Merges two molecular geometries while avoiding overlap based on a cutoff distance. :param inp: Input object containing cutoff distance. :type inp: input_class :param geom1: The first molecule object. :type geom1: molecule :param geom2: The second molecule object. :type geom2: molecule :returns: The merged molecular geometry. :rtype: molecule .. rubric:: Notes - Uses pairwise distance calculations to avoid overlapping atoms. - Atoms from `geom2` that are too close to `geom1` are removed. - The merged geometry retains properties such as center and bounding box. .. py:function:: subtract_geoms(inp, geom1, geom2) Subtracts one geometry from another based on a cutoff distance. :param inp: Input object containing cutoff distance. :type inp: input_class :param geom1: The first molecule object (to be subtracted). :type geom1: molecule :param geom2: The second molecule object. :type geom2: molecule :returns: A new molecule object representing `geom2 - geom1`. :rtype: molecule .. rubric:: Notes - Atoms from `geom2` that are within the cutoff distance of `geom1` are removed. - The resulting geometry retains calculated properties such as center and bounding box. .. py:function:: determine_sphere_center(inp, sense) Determines the center of a sphere within a rod-like structure. :param inp: Input object containing rod and sphere dimensions. :type inp: input_class :param sense: Direction (`'+'` or `'-'`) to position the sphere. :type sense: str :returns: The updated sphere center coordinates. :rtype: list[float] .. rubric:: Notes - The sphere's radius is computed as half the rod width. - The center is positioned based on the rod's main axis. .. py:function:: copy_geometry_file(source_file, destination_file) Copies the geometry file from 'results_geom/' to the current working directory. :param source_file: Path to the source geometry file. :type source_file: str :param destination_file: Path where the file should be copied. :type destination_file: str :param output: The output module for error handling. :type output: module :returns: None .. py:function:: delete_geometry_file(file_path) Deletes the temporary geometry file from the execution directory. :param file_path: Path to the temporary geometry file to be deleted. :type file_path: str :param output: The output module for error handling. :type output: module :returns: None .. py:function:: delete_all_files(pattern) Deletes all files matching a given pattern in the execution directory. :param pattern: File path pattern to match (e.g., "results_geom/*.xyz"). :type pattern: str :returns: None .. py:function:: create_dimer(inp) Creates a molecular dimer by translating a geometry to a controlled distance. :param inp: Input object containing: - `xyz_output` (str): Name of the geometry file. - `geom1_file`, `geom2_file` (str): Paths to the geometry files. - `move_geom_1_to_000`, `move_geom_2_to_000` (bool): Flags to center geometries at the origin. - `dir_axis_input` (str): Translation direction (`+x`, `-y`, etc.). - `distances` (list[float]): List containing the interatomic distance for the dimer. - `file_geom2_translated` (str): Name of the translated geometry file. :type inp: input_class :returns: The function updates input parameters and generates output files. :rtype: None .. rubric:: Notes - Copies the initial geometry file from `results_geom/` to the execution directory. - Prepares input parameters for translation. - Translates the second molecule to maintain the specified interatomic distance. - Reads and merges the initial and translated geometries. - Saves the final dimer structure as an output file. - Deletes temporary geometry files after processing. .. py:function:: create_bowtie(inp) Generates a molecular bowtie structure by rotating and translating a geometry. :param inp: Input object containing: - `xyz_output` (str): Name of the geometry file. - `geom1_file`, `geom2_file` (str): Paths to the geometry files. - `move_geom_1_to_000`, `move_geom_2_to_000` (bool): Flags to center geometries at the origin. - `dir_axis_input` (str): Translation direction (`+x`, `-y`, etc.). - `distances` (list[float]): List containing the interatomic distance for the bowtie. - `file_geom2_translated` (str): Name of the translated geometry file. - `angle` (float): Rotation angle in degrees. :type inp: input_class :returns: The function updates input parameters and generates output files. :rtype: None .. rubric:: Notes - Copies the initial geometry file from `results_geom/` to the execution directory. - Rotates the geometry by 180 degrees around the `+x` axis. - Copies the rotated geometries for translation. - Translates one geometry along the `+z` or `-z` axis depending on the structure type. - Merges the rotated and translated geometries into a final bowtie structure. - Saves the final structure and deletes temporary files. .. py:function:: calculate_normal_and_rhs(center_a, center_b, apex) Calculate the plane normal and RHS for the plane through three points. The plane is defined by the apex and the two points on an edge (`center_a`, `center_b`). The equation returned is: n · x + rhs = 0 where the normal vector is computed as: n = (center_a - apex) × (center_b - apex) .. rubric:: Notes * The orientation of the normal follows the right-hand rule and depends on the order of `center_a` and `center_b`. * The normal is **not** normalized. * This helper is useful for constructing side planes of a pyramid. :param center_a: 3-element sequence (x, y, z) for the first point on the edge. :type center_a: array_like :param center_b: 3-element sequence (x, y, z) for the second point on the edge. :type center_b: array_like :param apex: 3-element sequence (x, y, z) for the apex of the pyramid/face. :type apex: array_like :returns: A pair `(normal, rhs)` where: * `normal` (numpy.ndarray): The 3D normal vector of the plane (shape `(3,)`). * `rhs` (float): The right-hand-side constant so that `normal · x + rhs = 0`. :rtype: tuple