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
_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 pbc : bool whether to use pbc or not box : ndarray if you want pbc, you need to provide the simulation box. display_progress: bool Wheter to display a progress bar - needs the tqdm library
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/descriptors/cna.py
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 382 383 | |
Write CNA to file
Source code in snow/descriptors/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
_description_
coords : np.ndarray Array containing the coordinates of each atom. cut_off : float Cutoff radius for nearest-neighbor determination. pbc : bool Whether to use or not periodic boundary conditions box : np.ndarray Simulation box. Only needed if you enable PBC
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/descriptors/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
coords : np.ndarray (N, 3) array with atomic coordinates cut_off : float Cutoff radius for neighbor determination pbc : bool Whether to use or not periodic boundary conditions box : np.ndarray Simulation box. Only needed if you enable PBC display_progress: bool Wheter to display a progress bar
Returns
np.ndarray Array of integer structure IDs per atom
Source code in snow/descriptors/cna.py
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | |