Building neighbor-lists
The ase.calculators.emt.EMT potential and the GPAW DFT calculator
both make use of ASE’s built-in neighbor-list class:
-
class ase.calculators.neighborlist.NeighborList(cutoffs, skin=0.3, sorted=False, self_interaction=True, bothways=False)[source]
Neighbor list object.
- cutoffs: list of float
- List of cutoff radii - one for each atom. If the spheres (defined by
their cutoff radii) of two atoms overlap, they will be counted as
neighbors.
- skin: float
- If no atom has moved more than the skin-distance since the
last call to the update() method, then the neighbor list
can be reused. This will save some expensive rebuilds of
the list, but extra neighbors outside the cutoff will be
returned.
- self_interaction: bool
- Should an atom return itself as a neighbor?
- bothways: bool
- Return all neighbors. Default is to return only “half” of
the neighbors.
Example:
nl = NeighborList([2.3, 1.7])
nl.update(atoms)
indices, offsets = nl.get_neighbors(0)
-
build(atoms)[source]
Build the list.
-
get_neighbors(a)[source]
Return neighbors of atom number a.
A list of indices and offsets to neighboring atoms is
returned. The positions of the neighbor atoms can be
calculated like this:
indices, offsets = nl.get_neighbors(42)
for i, offset in zip(indices, offsets):
print(atoms.positions[i] + dot(offset, atoms.get_cell()))
Notice that if get_neighbors(a) gives atom b as a neighbor,
then get_neighbors(b) will not return a as a neighbor - unless
bothways=True was used.
-
update(atoms)[source]
Make sure the list is up to date.