deepmd.dpmodel.utils.neighbor_graph.ase_builder

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_neighbor_graph_ase(...)

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) 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 center i, neighbor j and periodic shift S such that the neighbor image sits at positions[j] + S @ cell. These map directly to the graph convention (src=neighbor=j, dst=center=i), and the edge list is fed to neighbor_graph_from_ijs() which recomputes edge_vec from coord/box (ASE’s distance vectors are discarded for convention + differentiability consistency).

Parameters:
coord

(nf, nloc, 3) local coordinates.

atype

(nf, nloc) local atom types (unused for the search; carried for API parity).

box

(nf, 3, 3) simulation cell, or None for non-periodic.

rcut

cutoff radius.

layout

edge-axis length policy; None => dynamic (torch) with min_edges guards.

Returns:
graph

The carry-all NeighborGraph over the LOCAL atoms (n_node = nloc per frame), with edge_vec recomputed differentiably from coord/box.

Raises:
ImportError

if the optional ase package is not installed.