Commit 856aab50 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Update docstrings in amd.py and mtsintegrator.py

parent 98d053d4
...@@ -49,10 +49,14 @@ class AMDIntegrator(CustomIntegrator): ...@@ -49,10 +49,14 @@ class AMDIntegrator(CustomIntegrator):
def __init__(self, dt, alpha, E): def __init__(self, dt, alpha, E):
"""Create an AMDIntegrator. """Create an AMDIntegrator.
Parameters: Parameters
- dt (time) The integration time step to use ----------
- alpha (energy) The alpha parameter to use dt : time
- E (energy) The energy cutoff to use The integration time step to use
alpha : energy
The alpha parameter to use
E : energy
The energy cutoff to use
""" """
CustomIntegrator.__init__(self, dt) CustomIntegrator.__init__(self, dt)
self.addGlobalVariable("alpha", alpha) self.addGlobalVariable("alpha", alpha)
...@@ -104,11 +108,16 @@ class AMDForceGroupIntegrator(CustomIntegrator): ...@@ -104,11 +108,16 @@ class AMDForceGroupIntegrator(CustomIntegrator):
def __init__(self, dt, group, alphaGroup, EGroup): def __init__(self, dt, group, alphaGroup, EGroup):
"""Create a AMDForceGroupIntegrator. """Create a AMDForceGroupIntegrator.
Parameters: Parameters
- dt (time) The integration time step to use ----------
- group (int) The force group to apply the boost to dt : time
- alphaGroup (energy) The alpha parameter to use for the boosted force group The integration time step to use
- EGroup (energy) The energy cutoff to use for the boosted force group group : int
The force group to apply the boost to
alphaGroup : energy
The alpha parameter to use for the boosted force group
EGroup : energy
The energy cutoff to use for the boosted force group
""" """
CustomIntegrator.__init__(self, dt) CustomIntegrator.__init__(self, dt)
self.addGlobalVariable("alphaGroup", alphaGroup) self.addGlobalVariable("alphaGroup", alphaGroup)
...@@ -144,9 +153,14 @@ class AMDForceGroupIntegrator(CustomIntegrator): ...@@ -144,9 +153,14 @@ class AMDForceGroupIntegrator(CustomIntegrator):
def getEffectiveEnergy(self, groupEnergy): def getEffectiveEnergy(self, groupEnergy):
"""Given the actual group energy of the system, return the value of the effective potential. """Given the actual group energy of the system, return the value of the effective potential.
Parameters: Parameters
- groupEnergy (energy): the actual potential energy of the boosted force group ----------
Returns: the value of the effective potential groupEnergy : energy
the actual potential energy of the boosted force group
Returns
-------
the value of the effective potential
""" """
alphaGroup = self.getAlphaGroup() alphaGroup = self.getAlphaGroup()
EGroup = self.getEGroup() EGroup = self.getEGroup()
...@@ -172,13 +186,20 @@ class DualAMDIntegrator(CustomIntegrator): ...@@ -172,13 +186,20 @@ class DualAMDIntegrator(CustomIntegrator):
def __init__(self, dt, group, alphaTotal, ETotal, alphaGroup, EGroup): def __init__(self, dt, group, alphaTotal, ETotal, alphaGroup, EGroup):
"""Create a DualAMDIntegrator. """Create a DualAMDIntegrator.
Parameters: Parameters
- dt (time) The integration time step to use ----------
- group (int) The force group to apply the second boost to dt : time
- alphaTotal (energy) The alpha parameter to use for the total energy The integration time step to use
- ETotal (energy) The energy cutoff to use for the total energy group : int
- alphaGroup (energy) The alpha parameter to use for the boosted force group The force group to apply the second boost to
- EGroup (energy) The energy cutoff to use for the boosted force group alphaTotal : energy
The alpha parameter to use for the total energy
ETotal : energy
The energy cutoff to use for the total energy
alphaGroup : energy
The alpha parameter to use for the boosted force group
EGroup : energy
The energy cutoff to use for the boosted force group
""" """
CustomIntegrator.__init__(self, dt) CustomIntegrator.__init__(self, dt)
self.addGlobalVariable("alphaTotal", alphaTotal) self.addGlobalVariable("alphaTotal", alphaTotal)
...@@ -237,10 +258,16 @@ class DualAMDIntegrator(CustomIntegrator): ...@@ -237,10 +258,16 @@ class DualAMDIntegrator(CustomIntegrator):
def getEffectiveEnergy(self, totalEnergy, groupEnergy): def getEffectiveEnergy(self, totalEnergy, groupEnergy):
"""Given the actual potential energy of the system, return the value of the effective potential. """Given the actual potential energy of the system, return the value of the effective potential.
Parameters: Parameters
- totalEnergy (energy): the actual potential energy of the whole system ----------
- groupEnergy (energy): the actual potential energy of the boosted force group totalEnergy : energy
Returns: the value of the effective potential the actual potential energy of the whole system
groupEnergy : energy
the actual potential energy of the boosted force group
Returns
-------
the value of the effective potential
""" """
alphaTotal = self.getAlphaTotal() alphaTotal = self.getAlphaTotal()
ETotal = self.getETotal() ETotal = self.getETotal()
......
...@@ -10,7 +10,7 @@ Portions copyright (c) 2013-2015 Stanford University and the Authors. ...@@ -10,7 +10,7 @@ Portions copyright (c) 2013-2015 Stanford University and the Authors.
Authors: Peter Eastman Authors: Peter Eastman
Contributors: Contributors:
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, the rights to use, copy, modify, merge, publish, distribute, sublicense,
...@@ -36,49 +36,52 @@ from simtk.openmm import CustomIntegrator ...@@ -36,49 +36,52 @@ from simtk.openmm import CustomIntegrator
class MTSIntegrator(CustomIntegrator): class MTSIntegrator(CustomIntegrator):
"""MTSIntegrator implements the rRESPA multiple time step integration algorithm. """MTSIntegrator implements the rRESPA multiple time step integration algorithm.
This integrator allows different forces to be evaluated at different frequencies, This integrator allows different forces to be evaluated at different frequencies,
for example to evaluate the expensive, slowly changing forces less frequently than for example to evaluate the expensive, slowly changing forces less frequently than
the inexpensive, quickly changing forces. the inexpensive, quickly changing forces.
To use it, you must first divide your forces into two or more groups (by calling To use it, you must first divide your forces into two or more groups (by calling
setForceGroup() on them) that should be evaluated at different frequencies. When setForceGroup() on them) that should be evaluated at different frequencies. When
you create the integrator, you provide a tuple for each group specifying the index you create the integrator, you provide a tuple for each group specifying the index
of the force group and the frequency (as a fraction of the outermost time step) at of the force group and the frequency (as a fraction of the outermost time step) at
which to evaluate it. For example: which to evaluate it. For example:
<pre> <pre>
integrator = MTSIntegrator(4*femtoseconds, [(0,1), (1,2), (2,8)]) integrator = MTSIntegrator(4*femtoseconds, [(0,1), (1,2), (2,8)])
</pre> </pre>
This specifies that the outermost time step is 4 fs, so each step of the integrator This specifies that the outermost time step is 4 fs, so each step of the integrator
will advance time by that much. It also says that force group 0 should be evaluated will advance time by that much. It also says that force group 0 should be evaluated
once per time step, force group 1 should be evaluated twice per time step (every 2 fs), once per time step, force group 1 should be evaluated twice per time step (every 2 fs),
and force group 2 should be evaluated eight times per time step (every 0.5 fs). and force group 2 should be evaluated eight times per time step (every 0.5 fs).
A common use of this algorithm is to evaluate reciprocal space nonbonded interactions A common use of this algorithm is to evaluate reciprocal space nonbonded interactions
less often than the bonded and direct space nonbonded interactions. The following less often than the bonded and direct space nonbonded interactions. The following
example looks up the NonbondedForce, sets the reciprocal space interactions to their example looks up the NonbondedForce, sets the reciprocal space interactions to their
own force group, and then creates an integrator that evaluates them once every 4 fs, own force group, and then creates an integrator that evaluates them once every 4 fs,
but all other interactions every 2 fs. but all other interactions every 2 fs.
<pre> <pre>
nonbonded = [f for f in system.getForces() if isinstance(f, NonbondedForce)][0] nonbonded = [f for f in system.getForces() if isinstance(f, NonbondedForce)][0]
nonbonded.setReciprocalSpaceForceGroup(1) nonbonded.setReciprocalSpaceForceGroup(1)
integrator = MTSIntegrator(4*femtoseconds, [(1,1), (0,2)]) integrator = MTSIntegrator(4*femtoseconds, [(1,1), (0,2)])
</pre> </pre>
For details, see Tuckerman et al., J. Chem. Phys. 97(3) pp. 1990-2001 (1992). For details, see Tuckerman et al., J. Chem. Phys. 97(3) pp. 1990-2001 (1992).
""" """
def __init__(self, dt, groups): def __init__(self, dt, groups):
"""Create an MTSIntegrator. """Create an MTSIntegrator.
Parameters: Parameters
- dt (time) The largest (outermost) integration time step to use ----------
- groups (list) A list of tuples defining the force groups. The first element of each dt : time
tuple is the force group index, and the second element is the number of times that force The largest (outermost) integration time step to use
group should be evaluated in one time step. groups : list
A list of tuples defining the force groups. The first element of
each tuple is the force group index, and the second element is the
number of times that force group should be evaluated in one time step.
""" """
if len(groups) == 0: if len(groups) == 0:
raise ValueError("No force groups specified") raise ValueError("No force groups specified")
...@@ -88,7 +91,7 @@ class MTSIntegrator(CustomIntegrator): ...@@ -88,7 +91,7 @@ class MTSIntegrator(CustomIntegrator):
self.addUpdateContextState(); self.addUpdateContextState();
self._createSubsteps(1, groups) self._createSubsteps(1, groups)
self.addConstrainVelocities(); self.addConstrainVelocities();
def _createSubsteps(self, parentSubsteps, groups): def _createSubsteps(self, parentSubsteps, groups):
group, substeps = groups[0] group, substeps = groups[0]
stepsPerParentStep = substeps/parentSubsteps stepsPerParentStep = substeps/parentSubsteps
......
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