From 7c331261f674045853c3f70cf842706dec38666b Mon Sep 17 00:00:00 2001 From: Sam Waseda Date: Tue, 4 Jan 2022 20:11:52 +0100 Subject: [PATCH] add pbc --- tds/metadynamics_1d.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tds/metadynamics_1d.py b/tds/metadynamics_1d.py index 34383e0..2d76313 100644 --- a/tds/metadynamics_1d.py +++ b/tds/metadynamics_1d.py @@ -103,14 +103,16 @@ def _get_symmetric_x(self, x): def update_s(self, x): x = self._get_symmetric_x(x) - dx = (self.mesh[:, None] - x) / self.input.sigma + dx = self.mesh[:, None] - x + dx -= self.length * np.rint(dx / self.length) + dx /= self.input.sigma exp = np.exp(-dx**2 / 2) self.output.dBds -= self._current_increment / self.input.sigma * np.sum(dx * exp, axis=1) self.output.B += self._current_increment * np.sum(exp, axis=1) if self.input.use_gradient: - self.output.ddBdds += self._current_increment / self.input.sigma**2 * ( - dx**2 - 1 - ) * np.sum(exp, axis=1) + self.output.ddBdds += self._current_increment / self.input.sigma**2 * np.sum( + (dx**2 - 1) * exp, axis=1 + ) self._current_increment *= self.input.decay def to_hdf(self, hdf=None, group_name=None):