Skip to content

Commit a0a0bec

Browse files
authored
Merge pull request #121 from OpenBioSim/fix_perturbable_system_gcmc
Fix setting of perturbable system positions for GCMC
2 parents b44c084 + 9e83618 commit a0a0bec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/somd2/runner/_repex.py

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

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

0 commit comments

Comments
 (0)