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

[WIP] Solvent-solute splitting #439

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update clone_nonbonded_parameters fxn
  • Loading branch information
maxentile committed Sep 25, 2019
commit 8ec3266a7c30ec4622a13e7137652b62e8e66a84
14 changes: 9 additions & 5 deletions openmmtools/forcefactories.py
Original file line number Diff line number Diff line change
@@ -184,7 +184,9 @@ def clone_nonbonded_parameters(nonbonded_force,
"""Creates a new CustomNonbonded force with the same global parameters,
per-particle parameters, and exception parameters as """

#TODO: assert that nonbonded_force.getNonbondedMethod() indicates reaction field
allowable_nb_methods = {openmm.NonbondedForce.CutoffPeriodic, openmm.NonbondedForce.CutoffNonPeriodic}
assert(nonbonded_force.getNonbondedMethod() in allowable_nb_methods)


# call constructor
# The 'energy_prefactor' allows us to easily change sign, or e.g. halve the energy if needed
@@ -193,24 +195,26 @@ def clone_nonbonded_parameters(nonbonded_force,
new_force.addPerParticleParameter('sigma')
new_force.addPerParticleParameter('epsilon')


# go through all of the setter and getter methods
new_force.setCutoffDistance(nonbonded_force.getCutoffDistance())
#new_force.setEwaldErrorTolerance(nonbonded_force.getEwaldErrorTolerance())
#new_force.setForceGroup(nonbonded_force.getForceGroup())
#new_force.setNonbondedMethod(nonbonded_force.getNonbondedMethod()) # If PME, will be an Illegal value for CustomNonbonded
new_force.setNonbondedMethod(nonbonded_force.getNonbondedMethod())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nobonded methods may not directly translate from NonbondedForce to CustomNonbondedForce.
See: https://github.com/choderalab/openmmtools/blob/master/openmmtools/alchemy.py#L1488-L1491

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will follow this example more closely

#new_force.setPMEParameters(*nonbonded_force.getPMEParameters())
#new_force.setReactionFieldDielectric(nonbonded_force.getReactionFieldDielectric())
#new_force.setReciprocalSpaceForceGroup(nonbonded_force.getReciprocalSpaceForceGroup())
new_force.setSwitchingDistance(nonbonded_force.getSwitchingDistance())
#new_force.setUseDispersionCorrection(nonbonded_force.getUseDispersionCorrection())
new_force.setUseSwitchingFunction(nonbonded_force.getUseSwitchingFunction())
new_force.setSwitchingDistance(nonbonded_force.getSwitchingDistance())
new_force.setUseLongRangeCorrection(nonbonded_force.getUseDispersionCorrection())


# now add all the particle parameters
num_particles = nonbonded_force.getNumParticles()
for i in range(num_particles):
new_force.addParticle(nonbonded_force.getParticleParameters(i))

# now add all the exceptions
# now add all the exceptions? # TODO: check if we want to do this...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you definitely want to copy all exceptions -> exclusions, or else you'll end up in NaNdyland.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

# for exception_index in range(nonbonded_force.getNumExceptions()):
# new_force.addException(nonbonded_force.getExceptionParameters(exception_index))