Common Neighbour Analysis
pySNOW contains functions that allow users to compute CNA signature for each pair of nearest neighbours as well as identify to which signature each atom in the system partecipates to. The latter is especially useful in cathegorizing the atom based on its belonging to a particular geometrical structure, extending what done in Ovito, where atoms are only catheorized based on the local cristalline structure, allowing to identify atoms belonging to a facet, an edge or a vertex.
The CNA signature is a triplet of numbers (r, s, t) for each pair of neighbours where:
- r: number of common neighbours of the pair
- s: number of bonds between the r common neighbours
- t: the longest path that can be formed by joining the r neighbours that are neighbours of each other
Functions
The CNA calculator containes a series of functions for the comutation of the CAN signatures and patterns:
Calculate CNA Fast
Faster version of calculate_cna that precomputes neighbor sets.
Parameters
index_frame : int description coords : ndarray 3xNatoms array containing the coordinates of each atom cut_off : float cutoff radius for the determination of nearest neighbors return_pair : bool, optional Whether to return an ordered list of the indices of the atoms forming a given pair, by default False
Returns
tuple[int, np.ndarray, list] The number of pairs, the cna signatures [r, s, t] for each pair and the ordered list of pairs (if return_pair == True) tuple[int, np.ndarray] The number of pairs, the cna signatures [r, s, t] for each pair
Source code in snow/lodispp/cna.py
Write CNA to file
Source code in snow/lodispp/cna.py
CNA Patterns per atoms
Optimized per-atom CNA calculation by precomputing a mapping from atom indices to pair indices. This avoids scanning the entire pair list for every atom.
Parameters
index_frame : int description coords : np.ndarray Array containing the coordinates of each atom. cut_off : float Cutoff radius for nearest-neighbor determination.
Returns
list of tuple[np.ndarray, np.ndarray] For each atom, a tuple (unique_signatures, counts) representing the unique CNA signatures from all pairs involving that atom and their respective counts.
Source code in snow/lodispp/cna.py
CNAp Index per atom
Usage:
cnap_peratom(index_frame: int, coords: np.ndarray, cut_off: float = None, pbc: bool = False) -> np.ndarray
Computes the CNA patterns per atom and assigns an integer structure ID (see README for mapping).
Parameters
index_frame : int Frame index (unused here but kept for compatibility) coords : np.ndarray (N, 3) array with atomic coordinates cut_off : float Cutoff radius for neighbor determination pbc : bool Whether to use periodic boundary conditions
Returns
np.ndarray Array of integer structure IDs per atom
Source code in snow/lodispp/cna.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |