diff --git a/grand/samplers.py b/grand/samplers.py index 7f6fc57..60a7f1c 100644 --- a/grand/samplers.py +++ b/grand/samplers.py @@ -404,6 +404,10 @@ def adjustSpecificWater(self, atoms, new_lambda): # Get lambda values lambda_vdw, lambda_ele = get_lambda_values(new_lambda) + state = self.context.getState(getPositions=True, enforcePeriodicBox=True, getEnergy=True) + positions = state.getPositions(asNumpy=True) + box_vectors = state.getPeriodicBoxVectors(asNumpy=True) + # Loop over parameters for i, atom_idx in enumerate(atoms): # Obtain original parameters @@ -420,7 +424,10 @@ def adjustSpecificWater(self, atoms, new_lambda): # Update context with new parameters self.nonbonded_force.updateParametersInContext(self.context) self.custom_nb_force.updateParametersInContext(self.context) - + + self.context.setPositions(positions) + self.context.setPeriodicBoxVectors(*box_vectors) + return None def report(self, simulation):