geom.functions.tools
Functions
|
Calculates the minimum distance between two molecular geometries. |
|
Rotates a molecular geometry by a given angle around a specified axis. |
|
Merges two molecular geometries while avoiding overlap based on a cutoff distance. |
|
Subtracts one geometry from another based on a cutoff distance. |
|
Determines the center of a sphere within a rod-like structure. |
|
Copies the geometry file from 'results_geom/' to the current working directory. |
|
Deletes the temporary geometry file from the execution directory. |
|
Deletes all files matching a given pattern in the execution directory. |
|
Creates a molecular dimer by translating a geometry to a controlled distance. |
|
Generates a molecular bowtie structure by rotating and translating a geometry. |
|
Calculate the plane normal and RHS for the plane through three points. |
Module Contents
- geom.functions.tools.calc_min_distance(geom1, geom2)[source]
Calculates the minimum distance between two molecular geometries.
- Parameters:
- Returns:
The minimum distance between the two geometries.
- Return type:
float
Notes
Uses NumPy broadcasting for efficient pairwise distance computation.
- geom.functions.tools.rotate(mol, angle, dir_axis_input, mol_rot)[source]
Rotates a molecular geometry by a given angle around a specified axis.
- Parameters:
- Returns:
The rotated molecule object.
- Return type:
Notes
Rotation is performed using standard rotation matrices.
Supports rotation around x, y, and z axes.
- geom.functions.tools.merge_geoms(inp, geom1, geom2)[source]
Merges two molecular geometries while avoiding overlap based on a cutoff distance.
- Parameters:
inp (input_class) – Input object containing cutoff distance.
geom1 (molecule) – The first molecule object.
geom2 (molecule) – The second molecule object.
- Returns:
The merged molecular geometry.
- Return type:
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.
- geom.functions.tools.subtract_geoms(inp, geom1, geom2)[source]
Subtracts one geometry from another based on a cutoff distance.
- Parameters:
inp (input_class) – Input object containing cutoff distance.
geom1 (molecule) – The first molecule object (to be subtracted).
geom2 (molecule) – The second molecule object.
- Returns:
A new molecule object representing geom2 - geom1.
- Return type:
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.
- geom.functions.tools.determine_sphere_center(inp, sense)[source]
Determines the center of a sphere within a rod-like structure.
- Parameters:
inp (input_class) – Input object containing rod and sphere dimensions.
sense (str) – Direction (‘+’ or ‘-’) to position the sphere.
- Returns:
The updated sphere center coordinates.
- Return type:
list[float]
Notes
The sphere’s radius is computed as half the rod width.
The center is positioned based on the rod’s main axis.
- geom.functions.tools.copy_geometry_file(source_file, destination_file)[source]
Copies the geometry file from ‘results_geom/’ to the current working directory.
- Parameters:
source_file (str) – Path to the source geometry file.
destination_file (str) – Path where the file should be copied.
output (module) – The output module for error handling.
- Returns:
None
- geom.functions.tools.delete_geometry_file(file_path)[source]
Deletes the temporary geometry file from the execution directory.
- Parameters:
file_path (str) – Path to the temporary geometry file to be deleted.
output (module) – The output module for error handling.
- Returns:
None
- geom.functions.tools.delete_all_files(pattern)[source]
Deletes all files matching a given pattern in the execution directory.
- Parameters:
pattern (str) – File path pattern to match (e.g., “results_geom/*.xyz”).
- Returns:
None
- geom.functions.tools.create_dimer(inp)[source]
Creates a molecular dimer by translating a geometry to a controlled distance.
- Parameters:
inp (input_class) – 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.
- Returns:
The function updates input parameters and generates output files.
- Return type:
None
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.
- geom.functions.tools.create_bowtie(inp)[source]
Generates a molecular bowtie structure by rotating and translating a geometry.
- Parameters:
inp (input_class) – 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.
- Returns:
The function updates input parameters and generates output files.
- Return type:
None
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.
- geom.functions.tools.calculate_normal_and_rhs(center_a, center_b, apex)[source]
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)
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.
- Parameters:
center_a (array_like) – 3-element sequence (x, y, z) for the first point on the edge.
center_b (array_like) – 3-element sequence (x, y, z) for the second point on the edge.
apex (array_like) – 3-element sequence (x, y, z) for the apex of the pyramid/face.
- 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.
- Return type:
tuple