From ad305fdbb9a4e76b97a24b55e133289e8e4120a4 Mon Sep 17 00:00:00 2001 From: Nick Lin <33555716+nicklin96@users.noreply.github.com> Date: Fri, 23 Jul 2021 14:38:27 +0800 Subject: [PATCH 1/2] Update neighbor_stat.py add safe check and warning for atoms with no neighbor --- deepmd/utils/neighbor_stat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deepmd/utils/neighbor_stat.py b/deepmd/utils/neighbor_stat.py index 11a466faac..a80acf9c01 100644 --- a/deepmd/utils/neighbor_stat.py +++ b/deepmd/utils/neighbor_stat.py @@ -82,7 +82,12 @@ def get_stat(self, self.place_holders['box']: np.array(data_set['box'])[kk].reshape([-1, 9]), self.place_holders['default_mesh']: np.array(data.default_mesh[ii]), }) - dt = np.min(dt) + if dt.size != 0: + dt = np.min(dt) + else: + dt = self.rcut + log.warn("Atoms with no neighbors found in %s. Please make sure it's what you expected."%jj) + if dt < self.min_nbor_dist: self.min_nbor_dist = dt for ww in range(self.ntypes): From 04cc1b5ded18bca8db1524fa5e91e9cab6d106dd Mon Sep 17 00:00:00 2001 From: Nick Lin <33555716+nicklin96@users.noreply.github.com> Date: Fri, 23 Jul 2021 15:03:27 +0800 Subject: [PATCH 2/2] Update neighbor_stat.py use log.warning instead of log.warn --- deepmd/utils/neighbor_stat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepmd/utils/neighbor_stat.py b/deepmd/utils/neighbor_stat.py index a80acf9c01..24e1adc930 100644 --- a/deepmd/utils/neighbor_stat.py +++ b/deepmd/utils/neighbor_stat.py @@ -86,7 +86,7 @@ def get_stat(self, dt = np.min(dt) else: dt = self.rcut - log.warn("Atoms with no neighbors found in %s. Please make sure it's what you expected."%jj) + log.warning("Atoms with no neighbors found in %s. Please make sure it's what you expected."%jj) if dt < self.min_nbor_dist: self.min_nbor_dist = dt