Skip to content

Instantly share code, notes, and snippets.

@jdetle
Created June 27, 2016 17:50
Show Gist options
  • Save jdetle/c2930ecec569ab439fac0a89b9139c27 to your computer and use it in GitHub Desktop.
Save jdetle/c2930ecec569ab439fac0a89b9139c27 to your computer and use it in GitHub Desktop.
def _single_frame(self):
self._i = self._i + 1
iframe = self._ts.frame
i_ref = self.atoms.positions - self.atoms.center_of_mass()
# diagonal entries need not be calculated due to metric(x,x) == 0 in
# theory, _ts not updated properly. Possible savings by setting a
# cutoff for significant decimal places to sparsify matrix
for j, ts in enumerate(self._u.trajectory[self.start:self.stop:self.step]):
self._ts = ts
if self._ts.frame >= iframe:
if self._i == j:
self.dist_matrix[self._i, self._i] = 0
else:
j_ref = self.atoms.positions-self.atoms.center_of_mass()
dist = self._metric(i_ref, j_ref, weights=self._weights)
self.dist_matrix[self._i, j] = (dist if dist > self._cutoff
else 0)
self.dist_matrix[j, self._i] = self.dist_matrix[self._i, j]
self._ts = self._u.trajectory[iframe]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment