cna
Common neighbour analysis (CNA) of local crystal structure.
Each bond from an atom to one of its neighbours is labelled by three numbers:
how many neighbours the pair has in common (n_cn), how many bonds those
common neighbours share (n_b), and how many bonds the largest connected
cluster of those holds (n_lcb). An atom's multiset of labels identifies its
local structure:
FCC 12 x (4, 2, 1)
HCP 6 x (4, 2, 1) + 6 x (4, 2, 2)
ICO 12 x (5, 5, 5)
BCC 8 x (6, 6, 6) + 6 x (4, 4, 4)
Everything about one atom happens inside its own neighbour shell, so the analysis is built from layers, each usable on its own:
chmpy.calc.nearest.nearest_neighborsfinds the shell.neighbor_bondsrecords which neighbours are bonded to which as bitmasks, one integer per neighbour, bitbof entryaset when neighboursaandbare bonded. The common neighbours of the atom and neighbouraare then exactly the set bits of entrya.cna_signaturesturns the bitmasks into(n_cn, n_b, n_lcb), andclassifymatches them againstPATTERNS.
Three ways of drawing the bonds are provided:
fixed_cnauses one cutoff throughout (Honeycutt and Andersen, J. Phys. Chem. 91, 4950 (1987)).adaptive_cnasets each atom's cutoff from its own neighbour distances (Stukowski, Modelling Simul. Mater. Sci. Eng. 20, 045021 (2012)).interval_cnaneeds no cutoff, and tolerates far more thermal disorder (Larsen, arXiv:2003.08879). Bonds of equal length do not bound an interval (INTERVAL_TOLERANCE), so that the answer for an atom does not depend on the rounding error between them, or on the orientation of the structure.
Atoms are processed in chunks, on workers threads; numpy releases the GIL
for the work inside each chunk.
StructureType
adaptive_cna(positions, cell=None, pbc=None, neighbors=None, workers=-1)
Adaptive common neighbour analysis.
FCC, HCP and icosahedral atoms are tested on their 12 nearest neighbours
with a cutoff of (1 + sqrt 2) / 2 times their mean distance; atoms that
are none of those are tested for BCC on their 14 nearest, with the cutoff
scaled from the lattice parameter those imply.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
(N, 3) Cartesian positions, Angstroms |
required | |
cell
|
(3, 3) lattice vectors as rows, or None for an isolated system |
None
|
|
pbc
|
(3,) periodic directions, as for |
None
|
|
neighbors
|
|
None
|
|
workers
|
threads to use, -1 for one per CPU |
-1
|
Returns:
| Type | Description |
|---|---|
|
(N,) int8 |
Source code in chmpy/descriptors/cna.py
classify(bonds, patterns, workers=-1)
Match each atom's signatures against a set of structures.
Only atoms whose common-neighbour counts fit some structure have their signatures computed, and only the bonds whose first two numbers fit have their chains followed, so a disordered atom costs little.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bonds
|
(N, k) bitmasks from |
required | |
patterns
|
|
required | |
workers
|
threads to use, -1 for one per CPU |
-1
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(N,) int8 structure of each atom, |
ndarray
|
matches |
Source code in chmpy/descriptors/cna.py
cna_signatures(bonds, workers=-1)
The CNA signature of every bond from every atom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bonds
|
(N, k) bitmasks from |
required | |
workers
|
threads to use, -1 for one per CPU |
-1
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(N, k, 3) int |
ndarray
|
of its neighbours |
Source code in chmpy/descriptors/cna.py
fixed_cna(positions, cutoff, cell=None, pbc=None, neighbors=None, workers=-1)
Conventional common neighbour analysis with one cutoff.
Atoms with exactly 12 neighbours inside the cutoff are tested for FCC,
HCP and icosahedral order, those with exactly 14 for BCC, and the rest are
StructureType.OTHER.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
(N, 3) Cartesian positions, Angstroms |
required | |
cutoff
|
bond length cutoff, Angstroms |
required | |
cell
|
(3, 3) lattice vectors as rows, or None for an isolated system |
None
|
|
pbc
|
(3,) periodic directions, as for |
None
|
|
neighbors
|
|
None
|
|
workers
|
threads to use, -1 for one per CPU |
-1
|
Returns:
| Type | Description |
|---|---|
|
(N,) int8 |
Source code in chmpy/descriptors/cna.py
interval_cna(positions, cell=None, pbc=None, neighbors=None, workers=-1)
Interval common neighbour analysis, which needs no cutoff.
Rather than fix a cutoff, the bonds among an atom's neighbours are added shortest first. Each structure is recognised at the point where the bonds drawn so far give its signatures, and the gap to the next bond is the interval of cutoffs over which that holds. The structure with the widest interval wins.
The 12 nearest neighbours are tested for FCC, HCP and icosahedral order
and the 14 nearest for BCC. Only bonds shorter than two thirds of the way
from the first neighbour shell to the second are considered, and the
interval after the last of those ends at a longer bond chosen by
_interval_ends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
(N, 3) Cartesian positions, Angstroms |
required | |
cell
|
(3, 3) lattice vectors as rows, or None for an isolated system |
None
|
|
pbc
|
(3,) periodic directions, as for |
None
|
|
neighbors
|
|
None
|
|
workers
|
threads to use, -1 for one per CPU |
-1
|
Returns:
| Type | Description |
|---|---|
|
(N,) int8 |
Source code in chmpy/descriptors/cna.py
neighbor_bonds(vectors, cutoff, workers=-1)
Which neighbours of each atom are bonded to each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
(N, k) neighbour vectors from each atom, as in
|
required | |
cutoff
|
bond length cutoff, a scalar or one per atom (N,) |
required | |
workers
|
threads to use, -1 for one per CPU |
-1
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(N, k) uint32 bitmasks: bit |
ndarray
|
neighbours |