diff --git a/src/somd2/runner/_repex.py b/src/somd2/runner/_repex.py index 058e028..fe7b34b 100644 --- a/src/somd2/runner/_repex.py +++ b/src/somd2/runner/_repex.py @@ -309,6 +309,22 @@ def _create_dynamics( ): from openmm.unit import angstrom + # Get the positions from the context. + positions = ( + dynamics.context() + .getState(getPositions=True) + .getPositions(asNumpy=True) + ) / angstrom + + # The positions array also contains the ghost water atoms that + # were added during the GCMC setup. We need to make sure that + # we copy these over to the perturbed positions array. + diff = len(positions) - len(perturbed_positions) + if diff != 0: + perturbed_positions = _np.concatenate( + [perturbed_positions, positions[-diff:]] + ) + dynamics.context().setPeriodicBoxVectors(*perturbed_box * angstrom) dynamics.context().setPositions(perturbed_positions * angstrom)