Skip to content

Commit be65ec6

Browse files
maxentilejchodera
andcommitted
attempted simplification of interaction-group splitting
attempted simplification Exception: Maximum allowable relative force error exceeded (was 1554.77679366; allowed 0.00000100). E alchemical_force = 1372003.46106334, reference_force = 882.44334338, difference = 1372002.43200366 Co-Authored-By: John Chodera <[email protected]>
1 parent 256f190 commit be65ec6

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

openmmtools/forcefactories.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ def clone_nonbonded_parameters(nonbonded_force,
226226

227227
def split_nb_using_interaction_groups(system, md_topology):
228228
"""Construct a copy of system where its nonbonded force has been replaced
229-
with three nonbonded forces, each using an interaction group restricted to
230-
water-water, water-solute, or solute-solute interactions. Water-water
229+
with two nonbonded forces, one using an interaction group restricted to
230+
water-water interactions, and the other using interaction groups
231+
restricted to water-solute and solute-solute interactions. Water-water
231232
interactions are in force group 0, and all other interactions are in force
232233
group 1.
233234
"""
@@ -239,27 +240,29 @@ def split_nb_using_interaction_groups(system, md_topology):
239240
force_index, nb_force = forces.find_forces(new_system, openmm.NonbondedForce, only_one=True)
240241
# create copies for each interaction. Only half in solvent/solvent and solute/solute as we double-count.
241242
nb_only_solvent_solvent = clone_nonbonded_parameters(nb_force, energy_prefactor='0.5*')
242-
nb_only_solvent_solute = clone_nonbonded_parameters(nb_force)
243-
nb_only_solute_solute = clone_nonbonded_parameters(nb_force, energy_prefactor='0.5*')
243+
nb_solute = clone_nonbonded_parameters(nb_force)
244244

245245
# NOTE: these need to be python ints -- not np.int64s -- when passing to addInteractionGroup later!
246246
solvent_indices = list(map(int, md_topology.select('water')))
247247
solute_indices = list(map(int, md_topology.select('not water')))
248248

249+
#all_indices = list(range(md_topology.n_atoms))
250+
249251
nb_only_solvent_solvent.addInteractionGroup(set1=solvent_indices, set2=solvent_indices)
250-
nb_only_solvent_solute.addInteractionGroup(set1=solute_indices, set2=solvent_indices)
251-
nb_only_solute_solute.addInteractionGroup(set1=solute_indices, set2=solute_indices)
252+
253+
nb_solute.addInteractionGroup(set1=solute_indices, set2=solute_indices)
254+
nb_solute.addInteractionGroup(set1=solute_indices, set2=solvent_indices)
255+
256+
#nb_solute.addInteractionGroup(set1=solute_indices, set2=all_indices)
252257

253258
# remove original force, add new forces
254259
new_system.removeForce(force_index)
260+
new_system.addForce(nb_solute)
255261
new_system.addForce(nb_only_solvent_solvent)
256-
new_system.addForce(nb_only_solute_solute)
257-
new_system.addForce(nb_only_solvent_solute)
258262

259263
# Set solvent-solvent to fg 0, everything else to fg1
260264
nb_only_solvent_solvent.setForceGroup(0)
261-
nb_only_solvent_solute.setForceGroup(1)
262-
nb_only_solute_solute.setForceGroup(1)
265+
nb_solute.setForceGroup(1)
263266

264267
# handle non-NonbondedForce's
265268
for force in new_system.getForces():

0 commit comments

Comments
 (0)