"vscode:/vscode.git/clone" did not exist on "6f4ec6b630d9040de7911bbac66fc141b87bb79f"
Commit 31a9036a authored by Justin MacCallum's avatar Justin MacCallum Committed by Justin MacCallum
Browse files

Precompute GBNeck terms

The previous version of this code would compute
the values of d0 and m0 for every iteration. This
was unnecessary as these values are fixed at the
start of the calculation by the radii of the particles
involved. This resulted in unnecessary computation
and memory access that dramatically slowed simulations
using the GBn or GBn2 solvation models.

The new version pre-computes the values based on the
radii that are present in the system. Linear interpolation
is used, which is consistent with Amber. The previous
version of OpenMM used cubic, which gives slightly
different results.
parent 32e08b87
...@@ -1217,6 +1217,7 @@ class CharmmPsfFile(object): ...@@ -1217,6 +1217,7 @@ class CharmmPsfFile(object):
else: else:
raise ValueError('Illegal nonbonded method for use with GBSA') raise ValueError('Illegal nonbonded method for use with GBSA')
gb.setForceGroup(self.GB_FORCE_GROUP) gb.setForceGroup(self.GB_FORCE_GROUP)
gb.finalize()
system.addForce(gb) system.addForce(gb)
force.setReactionFieldDielectric(1.0) # applies to NonbondedForce force.setReactionFieldDielectric(1.0) # applies to NonbondedForce
......
...@@ -1006,8 +1006,8 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No ...@@ -1006,8 +1006,8 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No
for i, (r, s) in enumerate(zip(radii, screen)): for i, (r, s) in enumerate(zip(radii, screen)):
if abs(r - gb_parms[i][0]) > 1e-4 or abs(s - gb_parms[i][1]) > 1e-4: if abs(r - gb_parms[i][0]) > 1e-4 or abs(s - gb_parms[i][1]) > 1e-4:
if not warned: if not warned:
warnings.warn('Non-optimal GB parameters detected for GB ' warnings.warn(
'model %s' % gbmodel) 'Non-optimal GB parameters detected for GB model %s' % gbmodel)
warned = True warned = True
gb_parms[i][0], gb_parms[i][1] = r, s gb_parms[i][0], gb_parms[i][1] = r, s
...@@ -1019,6 +1019,7 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No ...@@ -1019,6 +1019,7 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No
gb_parm[2], gb_parm[3], gb_parm[4]]) gb_parm[2], gb_parm[3], gb_parm[4]])
else: else:
gb.addParticle([charge, gb_parm[0], gb_parm[1]]) gb.addParticle([charge, gb_parm[0], gb_parm[1]])
gb.finalize()
system.addForce(gb) system.addForce(gb)
if nonbondedMethod == 'NoCutoff': if nonbondedMethod == 'NoCutoff':
gb.setNonbondedMethod(mm.NonbondedForce.NoCutoff) gb.setNonbondedMethod(mm.NonbondedForce.NoCutoff)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment