Skip to content

Commit

Permalink
add pbc
Browse files Browse the repository at this point in the history
  • Loading branch information
samwaseda committed Jan 4, 2022
1 parent 329a6df commit 7c33126
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tds/metadynamics_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7c33126

Please sign in to comment.