Skip to content

Commit

Permalink
update: restrucutre
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Aug 31, 2024
1 parent ccd5f7d commit 0c07e1f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
17 changes: 0 additions & 17 deletions src/py/mat3ra/made/tools/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,23 +483,6 @@ def get_undercoordinated_atom_indices(
return undercoordinated_atoms_indices


def calculate_norm_of_distances_between_coordinates(coords1: np.ndarray, coords2: np.ndarray) -> float:
"""
Calculate the norm of distances between two sets of coordinates.
Args:
coords1 (np.ndarray): The first set of coordinates.
coords2 (np.ndarray): The second set of coordinates.
Returns:
float: The calculated norm.
"""
tree = cKDTree(coords2)
distances, _ = tree.query(coords1)
distances = distances[~np.isinf(distances)]
return float(np.linalg.norm(distances))


def get_optimal_displacements(
material: Material, grid_size: Tuple[int, int] = (10, 10), search_range: float = 1.0
) -> List[List[float]]:
Expand Down
4 changes: 2 additions & 2 deletions src/py/mat3ra/made/tools/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import numpy as np
from mat3ra.made.tools.convert.utils import InterfacePartsEnum
from scipy.spatial import cKDTree

from .build.passivation.enums import SurfaceTypes
from .utils import calculate_norm_of_distances_between_coordinates
from ..material import Material
from .analyze import get_surface_area, get_surface_atom_indices, calculate_norm_of_distances_between_coordinates
from .analyze import get_surface_area, get_surface_atom_indices
from .build.interface.utils import get_slab
from .convert import decorator_convert_material_args_kwargs_to_atoms
from .third_party import ASEAtoms, ASECalculator, ASECalculatorEMT
Expand Down
18 changes: 18 additions & 0 deletions src/py/mat3ra/made/tools/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from mat3ra.made.material import Material
from mat3ra.made.utils import ArrayWithIds
from mat3ra.utils.matrix import convert_2x2_to_3x3
from scipy.spatial import cKDTree

from ..third_party import PymatgenStructure
from .coordinate import (
Expand Down Expand Up @@ -64,6 +65,23 @@ def get_distance_between_coordinates(coordinate1: List[float], coordinate2: List
return float(np.linalg.norm(np.array(coordinate1) - np.array(coordinate2)))


def calculate_norm_of_distances_between_coordinates(coords1: np.ndarray, coords2: np.ndarray) -> float:
"""
Calculate the norm of distances between two sets of coordinates.
Args:
coords1 (np.ndarray): The first set of coordinates.
coords2 (np.ndarray): The second set of coordinates.
Returns:
float: The calculated norm.
"""
tree = cKDTree(coords2)
distances, _ = tree.query(coords1)
distances = distances[~np.isinf(distances)]
return float(np.linalg.norm(distances))


def get_norm(vector: List[float]) -> float:
"""
Get the norm of a vector.
Expand Down

0 comments on commit 0c07e1f

Please sign in to comment.