Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiCheng45 committed Mar 8, 2024
1 parent fd54e92 commit b00d55d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ def set_coordinates(self, frame: int, tolerance=0.04):

# update the atoms
coords = self._reader.read_frame(self._current_frame)
cov_radii = np.array([
CHEMICAL_ELEMENTS.get_atom_property(at, "covalent_radius") for at in self._reader.atom_types
])

atoms = vtk.vtkPoints()
atoms.SetNumberOfPoints(self._n_atoms)
Expand All @@ -589,13 +592,13 @@ def set_coordinates(self, frame: int, tolerance=0.04):
# determine and set bonds without PBC applied
tree = KDTree(coords)
bonds = vtk.vtkCellArray()
contacts = tree.query_ball_tree(tree, 2 * np.max(self._cov_radii) + tolerance)
contacts = tree.query_ball_tree(tree, 2 * np.max(cov_radii) + tolerance)
for i, idxs in enumerate(contacts):
if len(idxs) == 0:
continue
diff = coords[i] - coords[idxs]
dist = np.sum(diff * diff, axis=1)
sum_radii = (self._cov_radii[i] + self._cov_radii[idxs] + tolerance)**2
sum_radii = (cov_radii[i] + cov_radii[idxs] + tolerance)**2
js = np.array(idxs)[(0 < dist) & (dist < sum_radii)]
for j in js[i < js]:
line = vtk.vtkLine()
Expand Down Expand Up @@ -663,9 +666,6 @@ def set_reader(self, reader, frame=0):
self._atom_scales = np.array(
[CHEMICAL_ELEMENTS.get_atom_property(at, "vdw_radius") for at in self._atoms]
).astype(np.float32)
self._cov_radii = np.array([
CHEMICAL_ELEMENTS.get_atom_property(at, "covalent_radius") for at in self._reader.atom_types
])

scalars = ndarray_to_vtkarray(
self._atom_colours, self._atom_scales, self._n_atoms
Expand Down

0 comments on commit b00d55d

Please sign in to comment.