From 91175189f4a419dc2dfd8029433f3802dc73a99d Mon Sep 17 00:00:00 2001 From: Jia-Xin Zhu Date: Fri, 15 Nov 2024 10:56:30 +0800 Subject: [PATCH] fix bug: cannot set property `default_mesh` o `DeepmdDataSystem` --- deepmd_utils/utils/data_system.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/deepmd_utils/utils/data_system.py b/deepmd_utils/utils/data_system.py index a2abca85db..05052f24d8 100644 --- a/deepmd_utils/utils/data_system.py +++ b/deepmd_utils/utils/data_system.py @@ -95,6 +95,7 @@ def __init__( self.system_dirs = systems self.nsystems = len(self.system_dirs) self.data_systems = [] + self._default_mesh = None for ii in self.system_dirs: self.data_systems.append( DeepmdData( @@ -233,12 +234,18 @@ def _load_test(self, ntests=-1): @lru_cache(maxsize=None) def default_mesh(self) -> List[np.ndarray]: """Mesh for each system.""" - return [ - make_default_mesh( - self.data_systems[ii].pbc, self.data_systems[ii].mixed_type - ) - for ii in range(self.nsystems) - ] + if self._default_mesh is None: + self._default_mesh = [ + make_default_mesh( + self.data_systems[ii].pbc, self.data_systems[ii].mixed_type + ) + for ii in range(self.nsystems) + ] + return self._default_mesh + + @default_mesh.setter + def default_mesh(self, value: List[np.ndarray]): + self._default_mesh = value def compute_energy_shift(self, rcond=None, key="energy"): sys_ener = []