From f3334dd7113a81e0846ef92b763d59ef477e326b Mon Sep 17 00:00:00 2001 From: Zheyong Fan Date: Sun, 13 Feb 2022 16:34:23 +0800 Subject: [PATCH] fix a bug related to small box --- src/force/nep3.cu | 6 +++--- src/force/nep4.cu | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/force/nep3.cu b/src/force/nep3.cu index 141934af2..f15f08f3f 100644 --- a/src/force/nep3.cu +++ b/src/force/nep3.cu @@ -681,9 +681,9 @@ static void get_expanded_box(const double rc, const Box& box, NEP3::ExpandedBox& double thickness_x = volume / box.get_area(0); double thickness_y = volume / box.get_area(1); double thickness_z = volume / box.get_area(2); - ebox.num_cells[0] = int(ceil(2.0 * rc / thickness_x)); - ebox.num_cells[1] = int(ceil(2.0 * rc / thickness_y)); - ebox.num_cells[2] = int(ceil(2.0 * rc / thickness_z)); + ebox.num_cells[0] = box.pbc_x ? int(ceil(2.0 * rc / thickness_x)) : 1; + ebox.num_cells[1] = box.pbc_y ? int(ceil(2.0 * rc / thickness_y)) : 1; + ebox.num_cells[2] = box.pbc_z ? int(ceil(2.0 * rc / thickness_z)) : 1; if (ebox.num_cells[0] * ebox.num_cells[1] * ebox.num_cells[2] > 1) { if (box.triclinic) { ebox.h[0] = box.cpu_h[0] * ebox.num_cells[0]; diff --git a/src/force/nep4.cu b/src/force/nep4.cu index ab39dd3cb..b8e44a312 100644 --- a/src/force/nep4.cu +++ b/src/force/nep4.cu @@ -471,9 +471,9 @@ static void get_expanded_box(const double rc, const Box& box, NEP4::ExpandedBox& double thickness_x = volume / box.get_area(0); double thickness_y = volume / box.get_area(1); double thickness_z = volume / box.get_area(2); - ebox.num_cells[0] = int(ceil(2.0 * rc / thickness_x)); - ebox.num_cells[1] = int(ceil(2.0 * rc / thickness_y)); - ebox.num_cells[2] = int(ceil(2.0 * rc / thickness_z)); + ebox.num_cells[0] = box.pbc_x ? int(ceil(2.0 * rc / thickness_x)) : 1; + ebox.num_cells[1] = box.pbc_y ? int(ceil(2.0 * rc / thickness_y)) : 1; + ebox.num_cells[2] = box.pbc_z ? int(ceil(2.0 * rc / thickness_z)) : 1; if (ebox.num_cells[0] * ebox.num_cells[1] * ebox.num_cells[2] > 1) { if (box.triclinic) { ebox.h[0] = box.cpu_h[0] * ebox.num_cells[0];