Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion snow/descriptors/lae.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import os
from snow.lodispp.utils import nearest_neighbours
from snow.descriptors.utils import nearest_neighbours
from snow.descriptors.coordination import agcn_calculator


Expand Down
26 changes: 16 additions & 10 deletions snow/descriptors/shape_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def geometric_com(index_frame: int, coords: np.ndarray):
gcom = np.mean(coords, axis=0)
return gcom

def compute_gyration_tensor(positions, masses=None, COM=True):
def gyr_tensor(positions, masses=None, COM=True):
"""
Computes the gyration tensor for a given set of coordinates. \n
This can be done in the center of mass reference system or in the raw provided coordinates.
Expand Down Expand Up @@ -86,7 +86,7 @@ def compute_gyration_tensor(positions, masses=None, COM=True):
return np.array([[Sxx, Sxy, Sxz], [Sxy, Syy, Syz], [Sxz, Syz, Szz]])


def compute_gyration_desc_from_tensor(gyration_tensor):
def gyr_desc_from_tensor(gyration_tensor):
"""
Computes general shape descriptors (gyration radius, asphericity, acylindricity, relative shape anisotropy) from the gyration tensor

Expand Down Expand Up @@ -122,7 +122,7 @@ def compute_gyration_desc_from_tensor(gyration_tensor):
return rg, b, c, k


def compute_gyration_descriptors(positions, masses=None, COM=True):
def gyr_desc(index_frame: int, positions, masses=None, COM=True):
"""
Computes general shape descriptors obtained from the gyration tensor \n
(gyration radius, asphericity, acylindricity, relative shape anisotropy) directly from the provided atomic positions. \n
Expand All @@ -132,6 +132,8 @@ def compute_gyration_descriptors(positions, masses=None, COM=True):

Parameters
----------
index_frame (int):
Index of the frame in the trajectory (for reference only - not used now).
positions : ndarray
(n,3) Array of the coordinates of the atoms forming the system.
masses : ndarray
Expand All @@ -150,11 +152,11 @@ def compute_gyration_descriptors(positions, masses=None, COM=True):
relative shape anisotropy
"""

return compute_gyration_desc_from_tensor(compute_gyration_tensor(positions, masses, COM))
return gyr_desc_from_tensor(gyr_tensor(positions, masses, COM))



def compute_inertia_tensor(positions, masses=None, COM=True):
def inertia_tensor(positions, masses=None, COM=True):

"""
Computes the inertia tensor for a given set of coordinates. \n
Expand Down Expand Up @@ -194,7 +196,7 @@ def compute_inertia_tensor(positions, masses=None, COM=True):
return np.array([[Ixx, Ixy, Ixz], [Ixy, Iyy, Iyz], [Ixz, Iyz, Izz]])


def compute_aspect_ratio_from_tensor(inertia_tensor):
def aspect_ratio_from_tensor(inertia_tensor):
"""
Computes the aspect ratio, a shape descriptor obtained from the inertia tensor.

Expand All @@ -211,13 +213,15 @@ def compute_aspect_ratio_from_tensor(inertia_tensor):



def compute_aspect_ratio(positions, masses=None, COM=True):
def aspect_ratio(index_frame: int, positions, masses=None, COM=True):
"""
Computes the aspect ratio, a shape descriptor derived from the inertia tensor, for a given set of coordinates. \n
This can be done in the center of mass reference system or in the raw provided coordinates

Parameters
----------
index_frame (int):
Index of the frame in the trajectory (for reference only - not used now).
positions : ndarray
Nx3 Array of the coordinates of the atoms in the system.
masses : ndarray
Expand All @@ -232,15 +236,17 @@ def compute_aspect_ratio(positions, masses=None, COM=True):
aspect ratio
"""

return compute_aspect_ratio_from_tensor(compute_inertia_tensor(positions, masses, COM))
return aspect_ratio_from_tensor(inertia_tensor(positions, masses, COM))

def compute_gyr_rad(positions, masses=None):
def gyr_rad(index_frame: int, positions, masses=None):
"""
Computes the gyration radius, which corresponds to the average <r^2> weighted by the masses of\n
atoms in the system.

Parameters
----------
index_frame (int):
Index of the frame in the trajectory (for reference only - not used now).
positions : ndarray
Nx3 Array of the coordinates of the atoms in the system.
masses : ndarray
Expand All @@ -257,4 +263,4 @@ def compute_gyr_rad(positions, masses=None):

centered = positions - np.average(positions, axis=0, weights=masses)

return np.sqrt( np.average( np.sum(centered**2, axis=1), weights=masses ) )
return np.sqrt( np.average( np.sum(centered**2, axis=1), weights=masses ) )
Loading