Commit f979a26
Fix neighbor_list_from_ase(compute_distances=True) crashing on periodic structures
_compute_distances multiplied the integer unit-shift matrix returned by
the neighbor-list kernel with the float cell; integer x float matmul is
not defined in torch, so the DEFAULT arguments of neighbor_list_from_ase
raised 'expected mat1 and mat2 to have the same dtype' on any structure
with periodic boundary conditions. Non-periodic structures dodge the path
(unit_shifts is None), which is presumably how it survived smoke tests.
Cast the shifts to the position dtype at the point of use. The new test
runs the default path on a periodic rocksalt supercell and checks the
returned distances against a float64 recomputation (1e-4) and the cutoff,
not merely the absence of a crash.
While auditing this path we also cross-checked the neighbor list itself:
on a dense triclinic 1,248-atom cell at 5.0 A the returned edge set is
bit-identical (shift vectors included) to an exact O(N^2) minimum-image
reference -- 25,242 edges, zero missing, zero spurious.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 25b3a29 commit f979a26
2 files changed
Lines changed: 43 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
221 | 225 | | |
222 | 226 | | |
223 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments