neighbors
Neighbour lists, with a Verlet skin.
A NeighborList is bound to a cutoff rather than to a structure, so a
calculator can hold one and reuse it across a whole relaxation. Two things make
that worth doing rather than enumerating pairs afresh each step:
- A skin. Pairs are enumerated out to
cutoff + skinand the list is reused while the geometry has not moved far enough for a new pair to have entered the cutoff. The criterion accounts for a moving cell as well as moving atoms, since a pair vector isr_j - r_i + S h; see_can_reuse. Only the distances are recomputed on a reuse. - Caching by version. Asking twice about one geometry costs nothing.
Pairs come from vesin when it is installed and from the numpy cell list in
_celllist otherwise, except for mixed periodicity -- slabs and wires -- which
neither handles and which falls back to a KD-tree over periodic images.
NeighborList
Pairs within cutoff, rebuilt only when the geometry demands it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cutoff
|
float
|
maximum pair distance in Angstroms |
required |
full
|
bool
|
return each pair from both ends. A half list is the natural input to a pair potential; a full list is what most message-passing models want. |
False
|
skin
|
float
|
extra range to enumerate, so small moves reuse the pair list. Zero disables reuse. A tenth of the cutoff is usually a good trade. |
0.0
|
self_pairs
|
bool
|
include an atom with its own periodic images |
True
|
Source code in chmpy/calc/neighbors.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
compute(system)
The pairs of system within the cutoff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
a |
required |
Returns:
| Type | Description |
|---|---|
Neighbors
|
Neighbors |
Source code in chmpy/calc/neighbors.py
Neighbors
dataclass
Pairs within a cutoff, and the vectors between them.
vectors[p] runs from atom i[p] to the image of atom j[p] displaced by
shifts[p] lattice vectors, i.e.
r[j] + shifts @ cell - r[i]. That is the quantity a pair potential
differentiates, and the one a virial needs, so it is computed once here
rather than by every caller.
Attributes:
| Name | Type | Description |
|---|---|---|
i |
ndarray
|
(P,) first atom of each pair |
j |
ndarray
|
(P,) second atom of each pair |
shifts |
ndarray
|
(P, 3) integer lattice translations applied to |
vectors |
ndarray
|
(P, 3) displacement from |
distances |
ndarray
|
(P,) lengths of |
full |
bool
|
whether each pair appears twice (once from each end) |