Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/somd2/runner/_repex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,13 @@ def _reset_gcmc_sampler(gcmc_sampler, dynamics):
dynamics: sire.mol.Dynamics
The dynamics object associated with the GCMC sampler.
"""
# Ensure the water count is up to date before resetting. If the last
# move was a bulk sampling move, _is_bulk is True and num_waters()
# needs the stored context to recompute _N. Calling it here, while
# the context is still available, clears _is_bulk so that reset()
# can safely null the context.
gcmc_sampler.num_waters()

# Reset the GCMC sampler. This resets the sampling statistics and
# clears the associated OpenMM forces.
gcmc_sampler.reset()
Expand Down
6 changes: 6 additions & 0 deletions src/somd2/runner/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,12 @@ def generate_lam_vals(lambda_base, increment=0.001):
# Reset the GCMC sampler. This resets the sampling statistics and clears
# the associated OpenMM forces.
if gcmc_sampler is not None:
# Ensure the water count is up to date before resetting. If the
# last move was a bulk sampling move, _is_bulk is True and
# num_waters() needs the stored context to recompute _N. Calling
# it here, while the context is still available, clears _is_bulk
# so that reset() can safely null the context.
gcmc_sampler.num_waters()
gcmc_sampler.reset()

# Bind the GCMC sampler to the dynamics object.
Expand Down
Loading