Generalized Coordination Number
This module allows for the computation of the Generalized Coordination Number (GCN) for an atomic system.
The GCN is a descriptor expanding on the better known Coordination Number (CN, the number of neighbours for each atom)
Functions
adjacency_matrix(index_frame, coords, cutoff)
Computes the adjacency matrix Ad_ij, where the entry ij is 1 if distance r_ij<=cutoff, else is 0
Source code in snow/lodispp/utils.py
apply_pbc(coords, box_size)
Apply periodic boundary conditions to atom coordinates. Maps coordinates to be within the simulation box.
Parameters
coords : np.ndarray Atom coordinates array, shape (n_atoms, 3). box_size : np.ndarray Box size array (3,) or (3,2) depending on box format.
Returns
np.ndarray Coordinates after applying PBC.
Source code in snow/lodispp/utils.py
bounding_box(points)
Calculate an axis-aligned bounding box from a set of points.
Source code in snow/lodispp/utils.py
center_of_mass(index_frame, coords, elements)
Calculate the center of mass for a given frame of coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index_frame
|
int
|
Index of the frame in the trajectory. |
required |
coords
|
ndarray
|
Array of atomic coordinates of shape (frames, atoms, 3). |
required |
elements
|
list or ndarray
|
List of element symbols corresponding to the atoms. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The center of mass as a 3D vector. |
Source code in snow/lodispp/utils.py
chemical_pddf_calculator(index_frame, coords, elements, bin_precision=None, bin_count=None)
Computes the pair distance distribution function for a given set of coordinates of atoms.
The user can either provide a bin precision or the numer of bins depending on wheter they are striving for a specific precision in the bins or on a specific number of bins for representation.
Parameters
index_frame : int Index of the frame relative to the snapshot, primarily for reference. coords : ndarray Array of the coordinates of the atoms forming the system. elements: ndarray Array of elements bin_precision: float, optional Specify a value if you want to compute the PDDF with a given bin precision (in Angstrom) bin_count: int, optional Specify a value if you want to compute the PDDF with a given number of bins
Returns
tuple - ndarray: the values of the interatomic distances for each bin - ndarray: the number of atoms within a given distance for each bin
Source code in snow/lodispp/utils.py
coordination_number(index_frame, coords, cut_off, neigh_list=False)
Computes the coordination number (number of nearest neighbours within a cutoff) for each atom in the system, optionally it also returns the neighbour list
Parameters
index_frame : int Index of the frame relative to the snapshot, primarily for reference. coords : ndarray Array of the coordinates of the atoms forming the system. cut_off : float The cutoff distance for determining nearest neighbors. neigh_list : bool, optional Option to return the neighbour list as well as the coordination number of each atom (defualt is False)
Returns
If neigh_list is True: tuple - list: neighbour list, the list of indeces of the neighbours of each atom - ndarray: the coordination numbers of each atom Otherwise: - ndarray: the coordination numbers of each atom
Source code in snow/lodispp/utils.py
distance_matrix(index_frame, coords)
Computes distance between atoms and saves them in a matrix of distances
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index_frame
|
int
|
index of the current frame if it is a movie, mostrly for reference |
required |
coords
|
array
|
array of the 3d coordinates |
required |
Returns:
Name | Type | Description |
---|---|---|
dist_mat |
array
|
distance matrix |
dist_max |
float
|
the maximum distance between atoms |
dist_min |
float
|
the minimum distance between atoms |
Source code in snow/lodispp/utils.py
hetero_distance_matrix(index_frame, coords, elements)
summary
Parameters
index_frame : type description coords : type description elements : type description
Returns
type description
Source code in snow/lodispp/utils.py
hetero_pddf_calculator(index_frame, coords, elements, bin_precision=None, bin_count=None)
summary
Parameters
index_frame : type description coords : type description elements : type description bin_precision : type, optional description, by default None bin_count : type, optional description, by default None
Returns
type description
Raises
ValueError description ValueError description
Source code in snow/lodispp/utils.py
nearest_neighbours(index_frame, coords, cut_off=None, pbc=False, box=None)
Computes nearest neighbors for each atom, considering periodic boundary conditions (PBC) if requested.
Parameters
index_frame : int Number of the frame if a movie. coords : ndarray XYZ coordinates of atoms, shape (n_atoms, 3). cut_off : float, optional Cutoff distance for finding neighbors (in Ã…). If None, an adaptive cutoff is used. pbc : bool, optional Whether to apply periodic boundary conditions (default: False). box : ndarray, optional Simulation box size in the form (3,) for orthorhombic boxes or (3,2) for lower and upper bounds.
Returns
list of lists Each sublist contains the indices of neighboring atoms for the corresponding atom.
Source code in snow/lodispp/utils.py
pair_list(index_frame, coords, cut_off=None, pbc=False, box=None)
Generates a list of all pairs of atoms within a certain adaptive cutoff distance of each other.
Parameters
index_frame : int Index of the frame if a movie (not used in the current version but can be useful for dynamic systems). coords : np.ndarray Array with the XYZ coordinates of the atoms, shape (n_atoms, 3). cut_off : float, optional Cutoff distance for finding pairs in angstroms. If None, an adaptive cutoff is used per atom. pbc : bool, optional Whether to apply periodic boundary conditions. Defaults to False. box : np.ndarray, optional Simulation box size (either [Lx, Ly, Lz] or [[xmin, xmax], [ymin, ymax], [zmin, zmax]]).
Returns
list List of tuples representing pairs of atoms that are within the cutoff distance.
Source code in snow/lodispp/utils.py
partial_rdf_calculator(index_frame, elements, coords, cut_off, bin_count=None, bin_precision=None)
Computes the radial distribution function for the system computing both the total and elemnt separated function, that is, if there are two atomic species (say Au and Pd) it computes the Au-Au, Pd-Pd and "chemical blind" RDF.
To bin the distribution the user can decide wether they want to specify the bin precision (in Angstrom) or the number of bins. One of the two has to be chosen.
To facilitate the representation and use, the cmputed RDF is returned as a dictionary.
Parameters
index_frame : int description elements : np.ndarray description coords : np.ndarray XYZ coordinates of atoms, shape (n_atoms, 3). cut_off : float Cutoff distance for finding pairs in angstroms. If None, an adaptive cutoff is used per atom. bin_count : int, optional Number of bins, by default None bin_precision : float, optional Bin precision, by default None
Returns
dict Dictionary containing as keys the element for which the rdf has been computed and as value two arrays, one continaing the bineed distance the other containg the computed RDF.
Raises
ValueError Raised if the user does not specify either the bin_count or the bin_precision.
Source code in snow/lodispp/utils.py
pddf_calculator(index_frame, coords, bin_precision=None, bin_count=None)
Computes the pair distance distribution function for a given set of coordinates of atoms.
The user can either provide a bin precision or the numer of bins depending on wheter they are striving for a specific precision in the bins or on a specific number of bins for representation.
Parameters
index_frame : int Index of the frame relative to the snapshot, primarily for reference. coords : ndarray Array of the coordinates of the atoms forming the system. bin_precision: float, optional Specify a value if you want to compute the PDDF with a given bin precision (in Angstrom) bin_count: int, optional Specify a value if you want to compute the PDDF with a given number of bins
Returns
tuple - ndarray: the values of the interatomic distances for each bin - ndarray: the number of atoms within a given distance for each bin
Source code in snow/lodispp/utils.py
pddf_calculator_by_element(index_frame, coords, elements, element='Au', bin_precision=None, bin_count=None)
Computes the pair distance distribution function (PDDF) for a given set of coordinates, considering only atoms of a specified chemical element.
Parameters
index_frame : int Index of the frame relative to the snapshot, primarily for reference. coords : ndarray Array of the coordinates of the atoms forming the system. elements : list List of atomic species corresponding to each coordinate. element: str, optional The atomic species to consider (default is 'Au'). bin_precision: float, optional Bin precision in Angstroms. bin_count: int, optional Number of bins. Returns
tuple - ndarray: the values of the interatomic distances for each bin - ndarray: the number of atoms within a given distance for each bin
Source code in snow/lodispp/utils.py
rdf_calculator(index_frame, coords, cut_off, bin_count=None, bin_precision=None, box_volume=None)
Parameters
index_frame : int description elements : np.ndarray description coords : np.ndarray XYZ coordinates of atoms, shape (n_atoms, 3). cut_off : float Cutoff distance for finding pairs in angstroms. If None, an adaptive cutoff is used per atom. bin_count : int, optional Number of bins, by default None bin_precision : float, optional Bin precision, by default None box_volume = None: float, optional Box dimension for PBC (WIP), by default None (no PBC, good for isolated systems)
Returns
tuple[np.ndarray, np.ndarray] Binned distance and rdf
Raises
ValueError description
Source code in snow/lodispp/utils.py
second_neighbours(index_frame, coords, cutoff)
Generates a list of lists of atomic indeces for each atom corresponding to aotoms that are neighbours of first neighbours excluding those which are already first neighbours.
Parameters
index_frame : int Index of the frame if a movie (not used in the current version but can be useful for dynamic systems). coords : np.ndarray Array with the XYZ coordinates of the atoms, shape (n_atoms, 3). cutoff : float Cutoff distance for finding pairs in angstroms. If None, an adaptive cutoff is used per atom.
Returns
list List of lists containing indeces of second neighbours for each atom
Source code in snow/lodispp/utils.py
sparse_adjacency_matrix(index_frame, coords, cutoff)
Create a sparse adjacency matrix where entries are 1 if the distance between points is less than or equal to the cutoff.
Parameters
index_frame : int Number of the frame if a movie. coords: ndarray Array with the XYZ coordinates of the atoms, shape (n_atoms, 3). cut_off : float Cutoff distance for finding neighbors in angstrom.
Returns
ndarray A sparse adjacency matrix with ones for adjacent points.