From e5c9c590cab12d8dd9e8d509706547d155f1bf9f Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 11 Dec 2023 20:09:55 -0500 Subject: [PATCH] docs: document external neighbor list (#3056) Signed-off-by: Jinzhe Zeng Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- doc/inference/python.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/inference/python.md b/doc/inference/python.md index 48eb1d7df0..b5d3ca1efc 100644 --- a/doc/inference/python.md +++ b/doc/inference/python.md @@ -27,3 +27,20 @@ model_devi = calc_model_devi(coord, cell, atype, graphs) ``` Note that if the model inference or model deviation is performed cyclically, one should avoid calling the same model multiple times. Otherwise, tensorFlow will never release the memory and this may lead to an out-of-memory (OOM) error. + +## External neighbor list algorithm + +The native neighbor list algorithm of the DeePMD-kit is in $O(N^2)$ complexity ($N$ is the number of atoms). +While this is not a problem for small systems that quantum methods can afford, the large systems for molecular dynamics have slow performance. +In this case, one may pass an external neighbor list that has lower complexity to {class}`DeepPot `, once it is compatible with {class}`ase.neighborlist.NewPrimitiveNeighborList`. + +```py +import ase.neighborlist + +neighbor_list = ase.neighborlist.NewPrimitiveNeighborList( + cutoffs=6, bothways=True, self_interaction=False +) +dp = DeepPot("graph.pb", neighbor_list=neighbor_list) +``` + +The `update` and `build` methods will be called by {class}`DeepPot `, and `first_neigh`, `pair_second`, and `offset_vec` properties will be used.