Skip to content

Coordination number

CoordinationNumber counts the neighbors of each atom, in total and by element, within one cutoff or a cutoff for each pair of elements.

import numpy as np
import mdapy as mp
from mdapy.analysis import CoordinationNumber
from mdapy.build import build_crystal

# a CsCl-ordered CuZn crystal of 4 x 4 x 4 cubic cells
system = build_crystal("cscl", 2.95, elements=["Cu", "Zn"], repeat=(4, 4, 4))

result = CoordinationNumber(cutoff=3.2).compute(system)
result.coordination  # 14 for every atom: 8 unlike and 6 like neighbors
result.partial["Zn"]  # neighbors of element Zn
unlike = CoordinationNumber(cutoffs={("Cu", "Zn"): 2.7}).compute(system)
system = system.with_columns(result)  # coordination, coordination_Cu, ...

On a particle, the coordination shows the facets, edges and corners:

from mdapy.build import build_crystal
from mdapy.visualization import render

crystal = build_crystal("fcc", 3.615, elements="Cu", repeat=(12, 12, 12))
center = crystal.box.matrix.diagonal() / 2
inside = np.linalg.norm(crystal["positions"] - center, axis=1) < 18.0
particle = crystal.filter(inside).with_box(mp.Box(12 * 3.615, pbc=False))

coordination = CoordinationNumber(cutoff=3.0).compute(particle).coordination
render(particle, "images/coordination.png", color=coordination, colormap="labels",
       box=False, width=800, height=700, legend="coordination")  # fmt: skip

Coordination of a copper particle

A sphere of 18 Å radius cut from copper, with one color for each number of neighbors. The inside has 12, the (111) facets 9, the (100) facets 8 and the atoms at edges and corners fewer.

Parameters

Name Type Default Unit Meaning
cutoff float64 None Å neighbors are closer than it
cutoffs dict of (str, str) to float64 None Å instead of cutoff, a cutoff for each pair of elements (a, b), in either order; pairs not given are never neighbors

compute(system, *, neighbors=None, progress=None, cancel=None) takes the arguments of every analysis. A given neighbor list must reach the largest cutoff; without one, the neighbors are counted as they are found, never stored. Partial counts and cutoffs need an element column.

Results

A CoordinationResult:

Attribute Type Meaning
coordination (N,) int64 the number of neighbors of each atom; its column coordination
partial dict of str to (N,) int64 the number of neighbors of each element, by element; columns coordination_<element>

Errors

The constructor raises InvalidParameter without exactly one of cutoff and cutoffs, for a cutoff that is not positive or an unknown element; compute raises it for a neighbor list that does not fit, and MissingProperty for cutoffs without an element column.

Definition

The neighbors of an atom are the other atoms and periodic images closer than the cutoff of their pair of elements.

See also