Skip to content

Commit 4abd041

Browse files
committed
Backport fix from PR #121. [ci skip]
1 parent 190b9a1 commit 4abd041

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/somd2/runner/_repex.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,22 @@ def _create_dynamics(
309309
):
310310
from openmm.unit import angstrom
311311

312+
# Get the positions from the context.
313+
positions = (
314+
dynamics.context()
315+
.getState(getPositions=True)
316+
.getPositions(asNumpy=True)
317+
) / angstrom
318+
319+
# The positions array also contains the ghost water atoms that
320+
# were added during the GCMC setup. We need to make sure that
321+
# we copy these over to the perturbed positions array.
322+
diff = len(positions) - len(perturbed_positions)
323+
if diff != 0:
324+
perturbed_positions = _np.concatenate(
325+
[perturbed_positions, positions[-diff:]]
326+
)
327+
312328
dynamics.context().setPeriodicBoxVectors(*perturbed_box * angstrom)
313329
dynamics.context().setPositions(perturbed_positions * angstrom)
314330

0 commit comments

Comments
 (0)