Commit 65ee8fd7 authored by Peter Eastman's avatar Peter Eastman
Browse files

Renamed BAOABLangevinIntegrator to LangevinMiddleIntegrator

parent ba9f6b0a
......@@ -120,7 +120,7 @@ steps.
forcefield = ForceField('amber14-all.xml', 'amber14/tip3pfb.xml')
system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME,
nonbondedCutoff=1*nanometer, constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(pdb.topology, system, integrator)
simulation.context.setPositions(pdb.positions)
simulation.minimizeEnergy()
......@@ -210,10 +210,10 @@ convenient and less error-prone. We could have equivalently specified
The units system will be described in more detail later, in Section :ref:`units-and-dimensional-analysis`.
::
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
This line creates the integrator to use for advancing the equations of motion.
It specifies a :class:`BAOABLangevinIntegrator`, which performs Langevin dynamics,
It specifies a :class:`LangevinMiddleIntegrator`, which performs Langevin dynamics,
and assigns it to a variable called :code:`integrator`\ . It also specifies
the values of three parameters that are specific to Langevin dynamics: the
simulation temperature (300 K), the friction coefficient (1 ps\ :sup:`-1`\ ), and
......@@ -295,7 +295,7 @@ found in OpenMM’s :file:`examples` folder with the name :file:`simulateAmber.p
inpcrd = AmberInpcrdFile('input.inpcrd')
system = prmtop.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer,
constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(prmtop.topology, system, integrator)
simulation.context.setPositions(inpcrd.positions)
if inpcrd.boxVectors is not None:
......@@ -389,7 +389,7 @@ with the name :file:`simulateGromacs.py`.
includeDir='/usr/local/gromacs/share/gromacs/top')
system = top.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer,
constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(top.topology, system, integrator)
simulation.context.setPositions(gro.positions)
simulation.minimizeEnergy()
......@@ -453,7 +453,7 @@ on the :class:`CharmmPsfFile`.
params = CharmmParameterSet('charmm22.rtf', 'charmm22.prm')
system = psf.createSystem(params, nonbondedMethod=NoCutoff,
nonbondedCutoff=1*nanometer, constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(psf.topology, system, integrator)
simulation.context.setPositions(pdb.positions)
simulation.minimizeEnergy()
......@@ -1031,7 +1031,7 @@ BAOAB Langevin Integrator
In the examples of the previous sections, we used Langevin integration:
::
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
The three parameter values in this line are the simulation temperature (300 K),
the friction coefficient (1 ps\ :sup:`-1`\ ), and the step size (0.004 ps). You
......@@ -1043,11 +1043,11 @@ equivalent.
Langevin Integrator
-------------------
:code:`LangevinIntegrator` is very similar to :code:`BAOABLangevinIntegrator`,
:code:`LangevinIntegrator` is very similar to :code:`LangevinMiddleIntegrator`,
but it uses a different discretization of the Langevin equation.
:code:`BAOABLangevinIntegrator` tends to produce more accurate configurational
:code:`LangevinMiddleIntegrator` tends to produce more accurate configurational
sampling, and therefore is preferred for most applications. Also note that
:code:`LangevinIntegrator` (unlike :code:`BAOABLangevinIntegrator`) is a leapfrog
:code:`LangevinIntegrator` (unlike :code:`LangevinMiddleIntegrator`) is a leapfrog
integrator, so the velocities are offset by half a time step from the positions.
Leapfrog Verlet Integrator
......@@ -1158,7 +1158,7 @@ previous section:
system = prmtop.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer,
constraints=HBonds)
system.addForce(MonteCarloBarostat(1*bar, 300*kelvin))
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
...
The parameters of the Monte Carlo barostat are the pressure (1 bar) and
......@@ -1718,7 +1718,7 @@ executing 1000 time steps at each temperature:
:autonumber:`Example,simulated annealing`
This code needs very little explanation. The loop is executed 100 times. Each
time through, it adjusts the temperature of the :class:`BAOABLangevinIntegrator` and then
time through, it adjusts the temperature of the :class:`LangevinMiddleIntegrator` and then
calls :code:`step(1000)` to take 1000 time steps.
Applying an External Force to Particles: a Spherical Container
......@@ -1750,7 +1750,7 @@ coordinates. Here is the code to do it:
system.addForce(force)
for i in range(system.getNumParticles()):
force.addParticle(i, [])
integrator = BAOABLangevinIntegrator(300*kelvin, 91/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 91/picosecond, 0.004*picoseconds)
...
.. caption::
......
......@@ -243,14 +243,14 @@ simulation might look like:
angles->addAngle(angle[i].particle1, angle[i].particle2,
angle[i].particle3, angle[i].angle, angle[i].k);
// ...create and initialize other force field terms in the same way
BAOABLangevinIntegrator integrator(temperature, friction, stepSize);
LangevinMiddleIntegrator integrator(temperature, friction, stepSize);
Context context(system, integrator);
context.setPositions(initialPositions);
context.setVelocities(initialVelocities);
integrator.step(10000);
We create a System, add various Forces to it, and set parameters on both the
System and the Forces. We then create a BAOABLangevinIntegrator, initialize a
System and the Forces. We then create a LangevinMiddleIntegrator, initialize a
Context in which to run a simulation, and instruct the Integrator to advance the
simulation for 10,000 time steps.
......@@ -1631,7 +1631,7 @@ along with the handle :code:`omm`\ , back to the calling function.
// best available Platform. Initialize the configuration from the default
// positions we collected above. Initial velocities will be zero but could
// have been set here.
omm->integrator = new OpenMM::BAOABLangevinIntegrator(temperature,
omm->integrator = new OpenMM::LangevinMiddleIntegrator(temperature,
frictionInPs,
stepSizeInFs * OpenMM::PsPerFs);
omm->context = new OpenMM::Context(*omm->system, *omm->integrator);
......
......@@ -1353,8 +1353,8 @@ random number, and :math:`\alpha=\exp(-\gamma\Delta t)`.
The same comments about the offset between positions and velocities apply to
this integrator as to VerletIntegrator.
BAOABLangevinIntegrator
***********************
LangevinMiddleIntegrator
************************
This integrator is similar to LangevinIntegerator, but it instead uses the BAOAB
discretization. :cite:`Leimkuhler2013` In each step, the positions and velocities
......
......@@ -249,7 +249,7 @@ myInitializeOpenMM( const MyAtomInfo atoms[],
// best available Platform. Initialize the configuration from the default
// positions we collected above. Initial velocities will be zero but could
// have been set here.
omm->integrator = new OpenMM::BAOABLangevinIntegrator(temperature, frictionInPs,
omm->integrator = new OpenMM::LangevinMiddleIntegrator(temperature, frictionInPs,
stepSizeInFs * OpenMM::PsPerFs);
omm->context = new OpenMM::Context(*omm->system, *omm->integrator);
omm->context->setPositions(initialPosInNm);
......
......@@ -252,7 +252,7 @@ myInitializeOpenMM( const MyAtomInfo atoms[],
* best available Platform. Initialize the configuration from the default
* positions we collected above. Initial velocities will be zero but could
* have been set here. */
omm->integrator = (OpenMM_Integrator*)OpenMM_BAOABLangevinIntegrator_create(
omm->integrator = (OpenMM_Integrator*)OpenMM_LangevinMiddleIntegrator_create(
temperature, frictionInPerPs,
stepSizeInFs * OpenMM_PsPerFs);
omm->context = OpenMM_Context_create(omm->system, omm->integrator);
......
......@@ -171,7 +171,7 @@ SUBROUTINE myInitializeOpenMM(ommHandle, platformName)
! These are the objects we'll create here thare are stored in the
! Context for later access. Don't forget to delete them at the end.
type (OpenMM_System) system
type (OpenMM_BAOABLangevinIntegrator) langevin
type (OpenMM_LangevinMiddleIntegrator) langevin
type (OpenMM_Context) context
! These are temporary OpenMM objects used and discarded here.
......@@ -236,11 +236,11 @@ SUBROUTINE myInitializeOpenMM(ommHandle, platformName)
! best available Platform. Initialize the configuration from the default
! positions we collected above. Initial velocities will be zero but could
! have been set here.
call OpenMM_BAOABLangevinIntegrator_create(langevin, &
call OpenMM_LangevinMiddleIntegrator_create(langevin, &
Temperature, FrictionInPerPs, &
StepSizeInFs * OpenMM_PsPerFs)
! Convert BAOABLangevinIntegrator to generic Integrator type for this call.
! Convert LangevinMiddleIntegrator to generic Integrator type for this call.
call OpenMM_Context_create(context, system, &
transfer(langevin, OpenMM_Integrator(0)))
call OpenMM_Context_setPositions(context, initialPosInNm)
......
......@@ -6,7 +6,7 @@ from sys import stdout
prmtop = AmberPrmtopFile('input.prmtop')
inpcrd = AmberInpcrdFile('input.inpcrd')
system = prmtop.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(prmtop.topology, system, integrator)
simulation.context.setPositions(inpcrd.positions)
if inpcrd.boxVectors is not None:
......
......@@ -21,7 +21,7 @@ params = CharmmParameterSet('charmm22.rtf', 'charmm22.par')
# Instantiate the system
system = psf.createSystem(params, nonbondedMethod=NoCutoff, constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(psf.topology, system, integrator)
simulation.context.setPositions(pdb.getPositions())
simulation.minimizeEnergy()
......
......@@ -6,7 +6,7 @@ from sys import stdout
gro = GromacsGroFile('input.gro')
top = GromacsTopFile('input.top', periodicBoxVectors=gro.getPeriodicBoxVectors())
system = top.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(top.topology, system, integrator)
simulation.context.setPositions(gro.positions)
simulation.minimizeEnergy()
......
......@@ -6,7 +6,7 @@ from sys import stdout
pdb = PDBFile('input.pdb')
forcefield = ForceField('amber14-all.xml', 'amber14/tip3pfb.xml')
system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=HBonds)
integrator = BAOABLangevinIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(pdb.topology, system, integrator)
simulation.context.setPositions(pdb.positions)
simulation.minimizeEnergy()
......
......@@ -33,7 +33,7 @@
* -------------------------------------------------------------------------- */
#include "openmm/AndersenThermostat.h"
#include "openmm/BAOABLangevinIntegrator.h"
#include "openmm/LangevinMiddleIntegrator.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/CMAPTorsionForce.h"
#include "openmm/CMMotionRemover.h"
......@@ -1129,36 +1129,36 @@ public:
};
/**
* This kernel is invoked by BAOABLangevinIntegrator to take one time step.
* This kernel is invoked by LangevinMiddleIntegrator to take one time step.
*/
class IntegrateBAOABStepKernel : public KernelImpl {
class IntegrateLangevinMiddleStepKernel : public KernelImpl {
public:
static std::string Name() {
return "IntegrateBAOABStep";
return "IntegrateLangevinMiddleStep";
}
IntegrateBAOABStepKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
IntegrateLangevinMiddleStepKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
}
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param integrator the BAOABLangevinIntegrator this kernel will be used for
* @param integrator the LangevinMiddleIntegrator this kernel will be used for
*/
virtual void initialize(const System& system, const BAOABLangevinIntegrator& integrator) = 0;
virtual void initialize(const System& system, const LangevinMiddleIntegrator& integrator) = 0;
/**
* Execute the kernel.
*
* @param context the context in which to execute this kernel
* @param integrator the BAOABLangevinIntegrator this kernel is being used for
* @param integrator the LangevinMiddleIntegrator this kernel is being used for
*/
virtual void execute(ContextImpl& context, const BAOABLangevinIntegrator& integrator) = 0;
virtual void execute(ContextImpl& context, const LangevinMiddleIntegrator& integrator) = 0;
/**
* Compute the kinetic energy.
*
* @param context the context in which to execute this kernel
* @param integrator the BAOABLangevinIntegrator this kernel is being used for
* @param integrator the LangevinMiddleIntegrator this kernel is being used for
*/
virtual double computeKineticEnergy(ContextImpl& context, const BAOABLangevinIntegrator& integrator) = 0;
virtual double computeKineticEnergy(ContextImpl& context, const LangevinMiddleIntegrator& integrator) = 0;
};
/**
......
......@@ -33,7 +33,6 @@
* -------------------------------------------------------------------------- */
#include "openmm/AndersenThermostat.h"
#include "openmm/BAOABLangevinIntegrator.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/CMAPTorsionForce.h"
#include "openmm/CMMotionRemover.h"
......@@ -57,6 +56,7 @@
#include "openmm/HarmonicBondForce.h"
#include "openmm/Integrator.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/LangevinMiddleIntegrator.h"
#include "openmm/LocalEnergyMinimizer.h"
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include "openmm/MonteCarloBarostat.h"
......
......@@ -236,7 +236,7 @@ namespace OpenMM {
* </pre></tt>
*
* The second one implements the algorithm used by the standard
* BAOABLangevinIntegrator class. kB is Boltzmann's constant.
* LangevinMiddleIntegrator class. kB is Boltzmann's constant.
*
* <tt><pre>
* CustomIntegrator integrator(dt);
......
#ifndef OPENMM_BAOABLANGEVININTEGRATOR_H_
#define OPENMM_BAOABLANGEVININTEGRATOR_H_
#ifndef OPENMM_LANGEVINMIDDLEINTEGRATOR_H_
#define OPENMM_LANGEVINMIDDLEINTEGRATOR_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
......@@ -45,16 +45,16 @@ namespace OpenMM {
* discretizations, such as the one used in LangevinIntegrator.
*/
class OPENMM_EXPORT BAOABLangevinIntegrator : public Integrator {
class OPENMM_EXPORT LangevinMiddleIntegrator : public Integrator {
public:
/**
* Create a BAOABLangevinIntegrator.
* Create a LangevinMiddleIntegrator.
*
* @param temperature the temperature of the heat bath (in Kelvin)
* @param frictionCoeff the friction coefficient which couples the system to the heat bath (in inverse picoseconds)
* @param stepSize the step size with which to integrate the system (in picoseconds)
*/
BAOABLangevinIntegrator(double temperature, double frictionCoeff, double stepSize);
LangevinMiddleIntegrator(double temperature, double frictionCoeff, double stepSize);
/**
* Get the temperature of the heat bath (in Kelvin).
*
......@@ -148,4 +148,4 @@ private:
} // namespace OpenMM
#endif /*OPENMM_BAOABLANGEVININTEGRATOR_H_*/
#endif /*OPENMM_LANGEVINMIDDLEINTEGRATOR_H_*/
......@@ -29,7 +29,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/BAOABLangevinIntegrator.h"
#include "openmm/LangevinMiddleIntegrator.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
......@@ -40,7 +40,7 @@ using namespace OpenMM;
using std::string;
using std::vector;
BAOABLangevinIntegrator::BAOABLangevinIntegrator(double temperature, double frictionCoeff, double stepSize) {
LangevinMiddleIntegrator::LangevinMiddleIntegrator(double temperature, double frictionCoeff, double stepSize) {
setTemperature(temperature);
setFriction(frictionCoeff);
setStepSize(stepSize);
......@@ -48,39 +48,39 @@ BAOABLangevinIntegrator::BAOABLangevinIntegrator(double temperature, double fric
setRandomNumberSeed(0);
}
void BAOABLangevinIntegrator::initialize(ContextImpl& contextRef) {
void LangevinMiddleIntegrator::initialize(ContextImpl& contextRef) {
if (owner != NULL && &contextRef.getOwner() != owner)
throw OpenMMException("This Integrator is already bound to a context");
context = &contextRef;
owner = &contextRef.getOwner();
kernel = context->getPlatform().createKernel(IntegrateBAOABStepKernel::Name(), contextRef);
kernel.getAs<IntegrateBAOABStepKernel>().initialize(contextRef.getSystem(), *this);
kernel = context->getPlatform().createKernel(IntegrateLangevinMiddleStepKernel::Name(), contextRef);
kernel.getAs<IntegrateLangevinMiddleStepKernel>().initialize(contextRef.getSystem(), *this);
}
void BAOABLangevinIntegrator::cleanup() {
void LangevinMiddleIntegrator::cleanup() {
kernel = Kernel();
}
vector<string> BAOABLangevinIntegrator::getKernelNames() {
vector<string> LangevinMiddleIntegrator::getKernelNames() {
std::vector<std::string> names;
names.push_back(IntegrateBAOABStepKernel::Name());
names.push_back(IntegrateLangevinMiddleStepKernel::Name());
return names;
}
double BAOABLangevinIntegrator::computeKineticEnergy() {
return kernel.getAs<IntegrateBAOABStepKernel>().computeKineticEnergy(*context, *this);
double LangevinMiddleIntegrator::computeKineticEnergy() {
return kernel.getAs<IntegrateLangevinMiddleStepKernel>().computeKineticEnergy(*context, *this);
}
bool BAOABLangevinIntegrator::kineticEnergyRequiresForce() const {
bool LangevinMiddleIntegrator::kineticEnergyRequiresForce() const {
return false;
}
void BAOABLangevinIntegrator::step(int steps) {
void LangevinMiddleIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
kernel.getAs<IntegrateBAOABStepKernel>().execute(*context, *this);
kernel.getAs<IntegrateLangevinMiddleStepKernel>().execute(*context, *this);
}
}
......@@ -905,34 +905,34 @@ private:
};
/**
* This kernel is invoked by BAOABLangevinIntegrator to take one time step.
* This kernel is invoked by LangevinMiddleIntegrator to take one time step.
*/
class CommonIntegrateBAOABStepKernel : public IntegrateBAOABStepKernel {
class CommonIntegrateLangevinMiddleStepKernel : public IntegrateLangevinMiddleStepKernel {
public:
CommonIntegrateBAOABStepKernel(std::string name, const Platform& platform, ComputeContext& cc) : IntegrateBAOABStepKernel(name, platform), cc(cc),
CommonIntegrateLangevinMiddleStepKernel(std::string name, const Platform& platform, ComputeContext& cc) : IntegrateLangevinMiddleStepKernel(name, platform), cc(cc),
hasInitializedKernels(false) {
}
/**
* Initialize the kernel, setting up the particle masses.
*
* @param system the System this kernel will be applied to
* @param integrator the BAOABLangevinIntegrator this kernel will be used for
* @param integrator the LangevinMiddleIntegrator this kernel will be used for
*/
void initialize(const System& system, const BAOABLangevinIntegrator& integrator);
void initialize(const System& system, const LangevinMiddleIntegrator& integrator);
/**
* Execute the kernel.
*
* @param context the context in which to execute this kernel
* @param integrator the BAOABLangevinIntegrator this kernel is being used for
* @param integrator the LangevinMiddleIntegrator this kernel is being used for
*/
void execute(ContextImpl& context, const BAOABLangevinIntegrator& integrator);
void execute(ContextImpl& context, const LangevinMiddleIntegrator& integrator);
/**
* Compute the kinetic energy.
*
* @param context the context in which to execute this kernel
* @param integrator the BAOABLangevinIntegrator this kernel is being used for
* @param integrator the LangevinMiddleIntegrator this kernel is being used for
*/
double computeKineticEnergy(ContextImpl& context, const BAOABLangevinIntegrator& integrator);
double computeKineticEnergy(ContextImpl& context, const LangevinMiddleIntegrator& integrator);
private:
ComputeContext& cc;
double prevTemp, prevFriction, prevStepSize;
......
......@@ -5547,26 +5547,26 @@ double CommonIntegrateLangevinStepKernel::computeKineticEnergy(ContextImpl& cont
return cc.getIntegrationUtilities().computeKineticEnergy(0.5*integrator.getStepSize());
}
void CommonIntegrateBAOABStepKernel::initialize(const System& system, const BAOABLangevinIntegrator& integrator) {
void CommonIntegrateLangevinMiddleStepKernel::initialize(const System& system, const LangevinMiddleIntegrator& integrator) {
cc.initializeContexts();
cc.setAsCurrent();
cc.getIntegrationUtilities().initRandomNumberGenerator(integrator.getRandomNumberSeed());
ComputeProgram program = cc.compileProgram(CommonKernelSources::baoab);
kernel1 = program->createKernel("integrateBAOABPart1");
kernel2 = program->createKernel("integrateBAOABPart2");
kernel3 = program->createKernel("integrateBAOABPart3");
ComputeProgram program = cc.compileProgram(CommonKernelSources::langevinMiddle);
kernel1 = program->createKernel("integrateLangevinMiddlePart1");
kernel2 = program->createKernel("integrateLangevinMiddlePart2");
kernel3 = program->createKernel("integrateLangevinMiddlePart3");
if (cc.getUseDoublePrecision() || cc.getUseMixedPrecision()) {
params.initialize<double>(cc, 2, "baoabParams");
params.initialize<double>(cc, 2, "langevinMiddleParams");
oldDelta.initialize<mm_double4>(cc, cc.getPaddedNumAtoms(), "oldDelta");
}
else {
params.initialize<float>(cc, 2, "baoabParams");
params.initialize<float>(cc, 2, "langevinMiddleParams");
oldDelta.initialize<mm_float4>(cc, cc.getPaddedNumAtoms(), "oldDelta");
}
prevStepSize = -1.0;
}
void CommonIntegrateBAOABStepKernel::execute(ContextImpl& context, const BAOABLangevinIntegrator& integrator) {
void CommonIntegrateLangevinMiddleStepKernel::execute(ContextImpl& context, const LangevinMiddleIntegrator& integrator) {
IntegrationUtilities& integration = cc.getIntegrationUtilities();
int numAtoms = cc.getNumAtoms();
int paddedNumAtoms = cc.getPaddedNumAtoms();
......@@ -5636,7 +5636,7 @@ void CommonIntegrateBAOABStepKernel::execute(ContextImpl& context, const BAOABLa
#endif
}
double CommonIntegrateBAOABStepKernel::computeKineticEnergy(ContextImpl& context, const BAOABLangevinIntegrator& integrator) {
double CommonIntegrateLangevinMiddleStepKernel::computeKineticEnergy(ContextImpl& context, const LangevinMiddleIntegrator& integrator) {
return cc.getIntegrationUtilities().computeKineticEnergy(0.0);
}
......
enum {VelScale, NoiseScale};
/**
* Perform the first part of BAOAB integration: velocity half step, then position half step.
* Perform the first part of integration: velocity step.
*/
KERNEL void integrateBAOABPart1(int numAtoms, int paddedNumAtoms, GLOBAL mixed4* RESTRICT velm, GLOBAL const mm_long* RESTRICT force,
KERNEL void integrateLangevinMiddlePart1(int numAtoms, int paddedNumAtoms, GLOBAL mixed4* RESTRICT velm, GLOBAL const mm_long* RESTRICT force,
GLOBAL const mixed2* RESTRICT dt) {
mixed fscale = dt[0].y/(mixed) 0x100000000;
for (int index = GLOBAL_ID; index < numAtoms; index += GLOBAL_SIZE) {
......@@ -19,11 +19,11 @@ KERNEL void integrateBAOABPart1(int numAtoms, int paddedNumAtoms, GLOBAL mixed4*
}
/**
* Perform the second part of BAOAB integration: apply constraint forces to velocities, then interact with heat bath,
* then position half step.
* Perform the second part of integration: position half step, then interact with heat bath,
* then another position half step.
*/
KERNEL void integrateBAOABPart2(int numAtoms, GLOBAL mixed4* RESTRICT velm, GLOBAL mixed4* RESTRICT posDelta,
KERNEL void integrateLangevinMiddlePart2(int numAtoms, GLOBAL mixed4* RESTRICT velm, GLOBAL mixed4* RESTRICT posDelta,
GLOBAL mixed4* RESTRICT oldDelta, GLOBAL const mixed* RESTRICT paramBuffer, GLOBAL const mixed2* RESTRICT dt, GLOBAL const float4* RESTRICT random, unsigned int randomIndex
) {
mixed vscale = paramBuffer[VelScale];
......@@ -50,11 +50,11 @@ KERNEL void integrateBAOABPart2(int numAtoms, GLOBAL mixed4* RESTRICT velm, GLOB
}
/**
* Perform the third part of BAOAB integration: apply constraint forces to velocities, then record
* the constrained positions in preparation for computing forces.
* Perform the third part of integration: apply constraint forces to velocities, then record
* the constrained positions.
*/
KERNEL void integrateBAOABPart3(int numAtoms, GLOBAL real4* RESTRICT posq, GLOBAL mixed4* RESTRICT velm,
KERNEL void integrateLangevinMiddlePart3(int numAtoms, GLOBAL real4* RESTRICT posq, GLOBAL mixed4* RESTRICT velm,
GLOBAL mixed4* RESTRICT posDelta, GLOBAL mixed4* RESTRICT oldDelta, GLOBAL const mixed2* RESTRICT dt
#ifdef USE_MIXED_PRECISION
, GLOBAL real4* RESTRICT posqCorrection
......
......@@ -32,7 +32,6 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "CpuBAOABDynamics.h"
#include "CpuBondForce.h"
#include "CpuCustomGBForce.h"
#include "CpuCustomManyParticleForce.h"
......@@ -40,6 +39,7 @@
#include "CpuGayBerneForce.h"
#include "CpuGBSAOBCForce.h"
#include "CpuLangevinDynamics.h"
#include "CpuLangevinMiddleDynamics.h"
#include "CpuNeighborList.h"
#include "CpuNonbondedForce.h"
#include "CpuPlatform.h"
......@@ -538,38 +538,38 @@ private:
};
/**
* This kernel is invoked by BAOABLangevinIntegrator to take one time step.
* This kernel is invoked by LangevinMiddleIntegrator to take one time step.
*/
class CpuIntegrateBAOABStepKernel : public IntegrateBAOABStepKernel {
class CpuIntegrateLangevinMiddleStepKernel : public IntegrateLangevinMiddleStepKernel {
public:
CpuIntegrateBAOABStepKernel(std::string name, const Platform& platform, CpuPlatform::PlatformData& data) : IntegrateBAOABStepKernel(name, platform),
CpuIntegrateLangevinMiddleStepKernel(std::string name, const Platform& platform, CpuPlatform::PlatformData& data) : IntegrateLangevinMiddleStepKernel(name, platform),
data(data), dynamics(0) {
}
~CpuIntegrateBAOABStepKernel();
~CpuIntegrateLangevinMiddleStepKernel();
/**
* Initialize the kernel, setting up the particle masses.
*
* @param system the System this kernel will be applied to
* @param integrator the BAOABLangevinIntegrator this kernel will be used for
* @param integrator the LangevinMiddleIntegrator this kernel will be used for
*/
void initialize(const System& system, const BAOABLangevinIntegrator& integrator);
void initialize(const System& system, const LangevinMiddleIntegrator& integrator);
/**
* Execute the kernel.
*
* @param context the context in which to execute this kernel
* @param integrator the BAOABLangevinIntegrator this kernel is being used for
* @param integrator the LangevinMiddleIntegrator this kernel is being used for
*/
void execute(ContextImpl& context, const BAOABLangevinIntegrator& integrator);
void execute(ContextImpl& context, const LangevinMiddleIntegrator& integrator);
/**
* Compute the kinetic energy.
*
* @param context the context in which to execute this kernel
* @param integrator the BAOABLangevinIntegrator this kernel is being used for
* @param integrator the LangevinMiddleIntegrator this kernel is being used for
*/
double computeKineticEnergy(ContextImpl& context, const BAOABLangevinIntegrator& integrator);
double computeKineticEnergy(ContextImpl& context, const LangevinMiddleIntegrator& integrator);
private:
CpuPlatform::PlatformData& data;
CpuBAOABDynamics* dynamics;
CpuLangevinMiddleDynamics* dynamics;
std::vector<double> masses;
double prevTemp, prevFriction, prevStepSize;
};
......
......@@ -23,17 +23,17 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __CPU_BAOAB_DYNAMICS_H__
#define __CPU_BAOAB_DYNAMICS_H__
#ifndef __CPU_LANGEVIN_MIDDLE_DYNAMICS_H__
#define __CPU_LANGEVIN_MIDDLE_DYNAMICS_H__
#include "ReferenceBAOABDynamics.h"
#include "ReferenceLangevinMiddleDynamics.h"
#include "CpuRandom.h"
#include "openmm/internal/ThreadPool.h"
#include "sfmt/SFMT.h"
namespace OpenMM {
class CpuBAOABDynamics : public ReferenceBAOABDynamics {
class CpuLangevinMiddleDynamics : public ReferenceLangevinMiddleDynamics {
public:
/**
* Constructor.
......@@ -45,12 +45,12 @@ public:
* @param threads thread pool for parallelizing computation
* @param random random number generator
*/
CpuBAOABDynamics(int numberOfAtoms, double deltaT, double friction, double temperature, OpenMM::ThreadPool& threads, OpenMM::CpuRandom& random);
CpuLangevinMiddleDynamics(int numberOfAtoms, double deltaT, double friction, double temperature, OpenMM::ThreadPool& threads, OpenMM::CpuRandom& random);
/**
* Destructor.
*/
~CpuBAOABDynamics();
~CpuLangevinMiddleDynamics();
/**
* First update step.
......@@ -105,4 +105,4 @@ private:
} // namespace OpenMM
#endif // __CPU_BAOAB_DYNAMICS_H__
#endif // __CPU_LANGEVIN_MIDDLE_DYNAMICS_H__
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