deepmd.dpmodel.utils.neighbor_graph.ase_builder#
Carry-all NeighborGraph builder backed by ASE’s O(N) cell list (optional dep).
build_neighbor_graph_ase is a carry-all search backend: it uses ASE’s neighbor_list("ijS", ...) to enumerate EVERY neighbor within rcut (no sel cutoff), then routes the resulting sparse (i, j, S) edge list through neighbor_graph_from_ijs() so edge_vec is recomputed differentiably from coord/box – ASE’s own distance vectors are intentionally NOT used, to keep the geometry convention and autograd leaf consistent with every other builder. ASE is an OPTIONAL dependency, imported lazily inside the function.
Functions#
Build a CARRY-ALL NeighborGraph using ASE's O(N) cell-list search. |
Module Contents#
- deepmd.dpmodel.utils.neighbor_graph.ase_builder.build_neighbor_graph_ase(coord: deepmd.dpmodel.array_api.Array, atype: deepmd.dpmodel.array_api.Array, box: deepmd.dpmodel.array_api.Array | None, rcut: float, layout: deepmd.dpmodel.utils.neighbor_graph.graph.GraphLayout | None = None, *, with_csr: bool = False, canonicalize: bool = False, pair_excl: deepmd.dpmodel.utils.neighbor_graph.graph.PairExcludeMask | None = None, compact: bool = False) deepmd.dpmodel.utils.neighbor_graph.graph.NeighborGraph[source]#
Build a CARRY-ALL NeighborGraph using ASE’s O(N) cell-list search.
Per frame, ASE
neighbor_list("ijS", atoms, rcut)returns centeri, neighborjand periodic shiftSsuch that the neighbor image sits atpositions[j] + S @ cell. These map directly to the graph convention (src=neighbor=j, dst=center=i), and the edge list is fed toneighbor_graph_from_ijs()which recomputesedge_vecfromcoord/box(ASE’s distance vectors are discarded for convention + differentiability consistency).- Parameters:
- coord
(nf, nloc, 3) local coordinates.
- atype
(nf, nloc) local atom types;
type < 0marks a virtual atom, excluded as center and neighbor (the search itself is type-blind).- box
(nf, 3, 3) simulation cell, or
Nonefor non-periodic.- rcut
cutoff radius.
- layout
edge-axis length policy;
None=> dynamic (torch) withmin_edgesguards.- with_csr
Whether to construct destination/source CSR views for a consumer that requires edge-grouped reductions.
- canonicalize
Whether to reorder every edge field into destination-major form. Implies
with_csr=True.- pair_excl
Optional
PairExcludeMaskfor model-levelpair_exclude_types. When given,apply_pair_exclusion()is applied after the geometric search.None(default) leaves all geometrically valid edges present.- compact
Passed to
apply_pair_exclusion(); see that function for details. Ignored whenpair_exclisNone.
- Returns:
graphThe carry-all
NeighborGraphover the LOCAL atoms (n_node = nlocper frame), withedge_vecrecomputed differentiably fromcoord/box.
- Raises:
ImportErrorif the optional
asepackage is not installed.