Shape descriptors
This module contains functions to compute descriptors of the shape of a nanoparticle. These are generally derived from either the inertia tensor or the gyration tensor.
snow.descriptors.shape_descriptors
eccentricity(coords, round_step=None)
Compute the eccentricity (smallest/largest bounding box dimension), a measure of shape anisotropy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
Coordinates of the atoms in your systems. |
required | |
round_step
|
precision for rounding - optional |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ratio |
float
|
computed eccentricity |
Source code in snow/descriptors/shape_descriptors.py
center_of_mass(elements, coords)
Calculate the center of mass for a given frame of coordinates.
Atomic masses are read from snow.misc.constants and used as weights for the
weighted average of positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
list or ndarray
|
List of element symbols corresponding to the atoms, for weighted sum on masses |
required |
coords
|
ndarray
|
Array of atomic coordinates of shape ( n_atoms, 3). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
com |
ndarray
|
The center of mass as a 3D vector (x_{com}, y_{com}, z_{com}). |
Source code in snow/descriptors/shape_descriptors.py
geometric_com(coords)
Computes the geometric center of mass (average of the coordinates)
Computes the average of the coordinates, which is the geometrical center of mass (thus, not considering different weights due to different atomic masses)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
Array of atomic coordinates of shape ( n_atoms, 3). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
gcom |
ndarray
|
The geometric center of mass as a 3D vector (x_{com}, y_{com}, z_{com}). |
Source code in snow/descriptors/shape_descriptors.py
gyr_tensor(positions)
Computes the gyration tensor for a given set of coordinates. This is done in the center of positions reference system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
(n,3) Array of the coordinates of the atoms forming the system. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tensor |
ndarray
|
3x3 gyration tensor |
Source code in snow/descriptors/shape_descriptors.py
gyr_desc_from_tensor(gyration_tensor)
Computes general shape descriptors (asphericity, acylindricity, relative shape anisotropy) from the gyration tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gyration_tensor
|
ndarray
|
3x3 gyration tensor |
required |
Returns:
| Name | Type | Description |
|---|---|---|
b |
float
|
asphericity |
c |
float
|
acylindricity |
k |
float
|
relative shape anisotropy |
Source code in snow/descriptors/shape_descriptors.py
gyr_desc(positions)
Computes general shape descriptors obtained from the gyration tensor.
Computes asphericity, acylindricity, and relative shape anisotropy from the provided atomic positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
(n,3) Array of the coordinates of the atoms forming the system. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
b |
float
|
asphericity |
c |
float
|
acylindricity |
k |
float
|
relative shape anisotropy |
Source code in snow/descriptors/shape_descriptors.py
inertia_tensor(positions, masses=None, COM=True)
Computes the inertia tensor for a given set of coordinates.
This can be done in the center of mass reference system or in the raw provided
coordinates - switch with the boolean COM variable
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
Nx3 Array of the coordinates of the atoms in the system. |
required |
masses
|
ndarray
|
Masses of the atoms, shape (n_atoms,). If None (default), all masses are set to 1 (equal masses). |
None
|
COM
|
bool
|
if True, the calculation is performed in the center of mass reference system. Otherwise, it is performed with the raw coordinates provided by the user |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
tensor |
ndarray
|
3x3 inertia tensor |
Source code in snow/descriptors/shape_descriptors.py
aspect_ratio_from_tensor(inertia_tensor)
Computes the aspect ratio, a shape descriptor obtained from the inertia tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inertia_tensor
|
ndarray
|
3x3 inertia tensor |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ar |
float
|
aspect ratio |
Source code in snow/descriptors/shape_descriptors.py
aspect_ratio(positions, masses=None, COM=True)
Computes the aspect ratio, a shape descriptor derived from the inertia tensor, for a given set of coordinates.
This can be done in the center of mass reference system or in the raw provided coordinates (switch with the COM boolean variable).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
Nx3 Array of the coordinates of the atoms in the system. |
required |
masses
|
ndarray
|
array of the masses of the atoms in the system. Default to all equal masses. |
None
|
COM
|
bool
|
if True, the calculation is performed in the center of mass reference system. Otherwise, it is performed with the raw coordinates provided by the user |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
ar |
float
|
aspect ratio |
Source code in snow/descriptors/shape_descriptors.py
gyr_rad(positions, masses=None)
Computes the gyration radius, which corresponds to the average
atoms in the system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
Nx3 Array of the coordinates of the atoms in the system. |
required |
masses
|
ndarray
|
array of the masses of the atoms in the system. Default to all equal masses |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
gr |
float
|
Gyration radius |