From bb15a657d54c998d56d21b33fd352df9d14c3571 Mon Sep 17 00:00:00 2001 From: Anyang Peng <137014849+anyangml@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:32:32 +0800 Subject: [PATCH 1/3] fix: make box smaller for no pbc structure --- src/mattersim/datasets/utils/convertor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mattersim/datasets/utils/convertor.py b/src/mattersim/datasets/utils/convertor.py index 186b61d..3b4c61b 100644 --- a/src/mattersim/datasets/utils/convertor.py +++ b/src/mattersim/datasets/utils/convertor.py @@ -193,10 +193,11 @@ def convert( min_z = np.min(atoms.positions[:, 2]) max_x = np.max(atoms.positions[:, 0]) max_y = np.max(atoms.positions[:, 1]) - max_z = np.max(atoms.positions[:, 2]) - x_len = max((max_x - min_x) * 10, 1000) - y_len = max((max_y - min_y) * 10, 1000) - z_len = max((max_z - min_z) * 10, 1000) + max_z = np.max(atoms.positions[:, 2]) + x_len = (max_x - min_x) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 + y_len = (max_y - min_y) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 + z_len = (max_z - min_z) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 + lattice_matrix = np.array( [[x_len, 0.0, 0.0], [0.0, y_len, 0.0], [0.0, 0.0, z_len]], dtype=float, From ea32a7cea5f25569070a5a3fe2e53f7ff8e25b22 Mon Sep 17 00:00:00 2001 From: Anyang Peng <137014849+anyangml@users.noreply.github.com> Date: Wed, 5 Feb 2025 12:24:46 +0800 Subject: [PATCH 2/3] Update src/mattersim/datasets/utils/convertor.py Co-authored-by: Han Yang --- src/mattersim/datasets/utils/convertor.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/mattersim/datasets/utils/convertor.py b/src/mattersim/datasets/utils/convertor.py index 3b4c61b..3d51302 100644 --- a/src/mattersim/datasets/utils/convertor.py +++ b/src/mattersim/datasets/utils/convertor.py @@ -194,7 +194,24 @@ def convert( max_x = np.max(atoms.positions[:, 0]) max_y = np.max(atoms.positions[:, 1]) max_z = np.max(atoms.positions[:, 2]) - x_len = (max_x - min_x) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 + x_len = (max_x - min_x) + max( + self.twobody_cutoff, self.threebody_cutoff + ) * 5 + y_len = (max_y - min_y) + max( + self.twobody_cutoff, self.threebody_cutoff + ) * 5 + z_len = (max_z - min_z) + max( + self.twobody_cutoff, self.threebody_cutoff + ) * 5 + max_len = max(x_len, y_len, z_len) + x_len = y_len = z_len = max_len + lattice_matrix = np.eye(3) * max_len + pbc_ = np.array([1, 1, 1], dtype=int) + warnings.warn( + "No PBC detected, using a large supercell with " + f"size {x_len}x{y_len}x{z_len} Angstrom**3", + UserWarning, + ) y_len = (max_y - min_y) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 z_len = (max_z - min_z) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 From 5e0dea3065c3f19405b5cad0ecbfa03cf2ae05d5 Mon Sep 17 00:00:00 2001 From: Anyang Peng <137014849+anyangml@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:06:00 +0800 Subject: [PATCH 3/3] chore: remove redundant --- src/mattersim/datasets/utils/convertor.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/mattersim/datasets/utils/convertor.py b/src/mattersim/datasets/utils/convertor.py index 3d51302..59a42a9 100644 --- a/src/mattersim/datasets/utils/convertor.py +++ b/src/mattersim/datasets/utils/convertor.py @@ -212,15 +212,7 @@ def convert( f"size {x_len}x{y_len}x{z_len} Angstrom**3", UserWarning, ) - y_len = (max_y - min_y) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 - z_len = (max_z - min_z) + max(self.twobody_cutoff, self.threebody_cutoff) * 2 - - lattice_matrix = np.array( - [[x_len, 0.0, 0.0], [0.0, y_len, 0.0], [0.0, 0.0, z_len]], - dtype=float, - ) - pbc_ = np.array([1, 1, 1], dtype=int) - warnings.warn("No PBC detected, using a large supercell", UserWarning) + atoms.set_cell(lattice_matrix) atoms.set_pbc(pbc_) else: