Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for OpenMM's bug on nb force update parameters #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion grand/samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down