Commit 047934e2 authored by Rafal P. Wiewiora's avatar Rafal P. Wiewiora
Browse files

Merge remote-tracking branch 'upstream/master'

parents ce3a5dc0 d12c9bd1
...@@ -517,3 +517,15 @@ ...@@ -517,3 +517,15 @@
year = {2014}, year = {2014},
type = {Journal Article} type = {Journal Article}
} }
@article{Wennberg2015
author = {Wennberg, Christian L. and Murtola, Teemu and Páll, Szilárd and Abraham, Mark J. and Hess, Berk and Lindahl, Erik},
title = {Direct-Space Corrections Enable Fast and Accurate {Lorentz–Berthelot} Combination Rule {Lennard-Jones} Lattice Summation},
journal = {Journal of Chemical Theory and Computation},
volume = {11},
number = {12},
pages = {5737-5746},
year = {2015},
type = {Journal Article}
}
...@@ -412,7 +412,7 @@ and the number of nodes in the mesh along each dimension as ...@@ -412,7 +412,7 @@ and the number of nodes in the mesh along each dimension as
.. math:: .. math::
n_\mathit{mesh}=\frac{2\alpha d}{{3d}^{1/5}} n_\mathit{mesh}=\frac{2\alpha d}{{3\delta}^{1/5}}
where *d* is the width of the periodic box along that dimension. Alternatively, where *d* is the width of the periodic box along that dimension. Alternatively,
...@@ -432,6 +432,38 @@ to numerical round-off error than Ewald summation. For Platforms that do ...@@ -432,6 +432,38 @@ to numerical round-off error than Ewald summation. For Platforms that do
calculations in single precision, making :math:`\delta` too small (typically below about calculations in single precision, making :math:`\delta` too small (typically below about
5·10\ :sup:`-5`\ ) can actually cause the error to increase. 5·10\ :sup:`-5`\ ) can actually cause the error to increase.
Lennard-Jones Interaction With Particle Mesh Ewald
==================================================
The PME algorithm can also be used for Lennard-Jones interactions. Usually this
is not necessary, since Lennard-Jones forces are short ranged, but there are
situations (such as membrane simulations) where neglecting interactions beyond
the cutoff can measurably affect results.
For computational efficiency, certain approximations are made\ :cite:`Wennberg2015`.
Interactions beyond the cutoff distance include only the attractive :math:`1/r^6`
term, not the repulsive :math:`1/r^{12}` term. Since the latter is much smaller
than the former at long distances, this usually has negligible effect. Also,
the interaction between particles farther apart than the cutoff distance is
computed using geometric combination rules:
.. math::
\sigma=\sqrt{\sigma_1 \sigma_2}
The effect of this approximation is also quite small, and it is still far more
accurate than ignoring the interactions altogether (which is what would happen
with PME).
The formula used to compute the number of nodes along each dimension of the mesh
is slightly different from the one used for Coulomb interactions:
.. math::
n_\mathit{mesh}=\frac{\alpha d}{{3\delta}^{1/5}}
As before, this is an empirical formula. It will usually produce an average
relative error in the forces less than or similar to :math:`\delta`\ , but that
is not guaranteed.
.. _gbsaobcforce: .. _gbsaobcforce:
GBSAOBCForce GBSAOBCForce
...@@ -920,7 +952,8 @@ of four particles. That is, the interaction energy of each bond is given by ...@@ -920,7 +952,8 @@ of four particles. That is, the interaction energy of each bond is given by
where *f*\ (\ *...*\ ) is a user defined mathematical expression. It may where *f*\ (\ *...*\ ) is a user defined mathematical expression. It may
depend on an arbitrary set of positions {\ :math:`x_i`\ }, distances {\ :math:`r_i`\ }, depend on an arbitrary set of positions {\ :math:`x_i`\ }, distances {\ :math:`r_i`\ },
angles {\ :math:`\theta_i`\ }, and dihedral angles {\ :math:`\phi_i`\ }. angles {\ :math:`\theta_i`\ }, and dihedral angles {\ :math:`\phi_i`\ }
guaranteed to be in the range [-π, π].
Each distance, angle, or dihedral is defined by specifying a sequence of Each distance, angle, or dihedral is defined by specifying a sequence of
particles chosen from among the particles that make up the bond. A distance particles chosen from among the particles that make up the bond. A distance
......
...@@ -63,11 +63,13 @@ def runOneTest(testName, options): ...@@ -63,11 +63,13 @@ def runOneTest(testName, options):
else: else:
method = app.CutoffPeriodic method = app.CutoffPeriodic
cutoff = 1*unit.nanometers cutoff = 1*unit.nanometers
friction = 1*(1/unit.picoseconds)
else: else:
ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml') ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml')
pdb = app.PDBFile('5dfr_minimized.pdb') pdb = app.PDBFile('5dfr_minimized.pdb')
method = app.CutoffNonPeriodic method = app.CutoffNonPeriodic
cutoff = 2*unit.nanometers cutoff = 2*unit.nanometers
friction = 91*(1/unit.picoseconds)
if options.heavy: if options.heavy:
dt = 0.005*unit.picoseconds dt = 0.005*unit.picoseconds
constraints = app.AllBonds constraints = app.AllBonds
...@@ -77,7 +79,7 @@ def runOneTest(testName, options): ...@@ -77,7 +79,7 @@ def runOneTest(testName, options):
constraints = app.HBonds constraints = app.HBonds
hydrogenMass = None hydrogenMass = None
system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass) system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass)
integ = mm.LangevinIntegrator(300*unit.kelvin, 91*(1/unit.picoseconds), dt) integ = mm.LangevinIntegrator(300*unit.kelvin, friction, dt)
print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds)) print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds))
properties = {} properties = {}
initialSteps = 5 initialSteps = 5
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
Sparse_Matrix_CompRow(const Sparse_Matrix_CompRow &S); Sparse_Matrix_CompRow(const Sparse_Matrix_CompRow &S);
Sparse_Matrix_CompRow(int M, int N, int nz, const T *val, Sparse_Matrix_CompRow(int M, int N, int nz, const T *val,
const int *r, const int *c); int *r, int *c);
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
*/ */
template <class T> template <class T>
Sparse_Matrix_CompRow<T>::Sparse_Matrix_CompRow(int M, int N, int nz, Sparse_Matrix_CompRow<T>::Sparse_Matrix_CompRow(int M, int N, int nz,
const T *val, const int *r, const int *c) : val_(nz,val), const T *val, int *r, int *c) : val_(nz,val),
rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {} rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {}
......
...@@ -408,6 +408,7 @@ int lbfgs( ...@@ -408,6 +408,7 @@ int lbfgs(
pf = (lbfgsfloatval_t*)vecalloc(param.past * sizeof(lbfgsfloatval_t)); pf = (lbfgsfloatval_t*)vecalloc(param.past * sizeof(lbfgsfloatval_t));
} }
try {
/* Evaluate the function value and its gradient. */ /* Evaluate the function value and its gradient. */
fx = cd.proc_evaluate(cd.instance, x, g, cd.n, 0); fx = cd.proc_evaluate(cd.instance, x, g, cd.n, 0);
if (0. != param.orthantwise_c) { if (0. != param.orthantwise_c) {
...@@ -613,6 +614,26 @@ int lbfgs( ...@@ -613,6 +614,26 @@ int lbfgs(
*/ */
step = 1.0; step = 1.0;
} }
}
catch (...) {
vecfree(pf);
/* Free memory blocks used by this function. */
if (lm != NULL) {
for (i = 0;i < m;++i) {
vecfree(lm[i].s);
vecfree(lm[i].y);
}
vecfree(lm);
}
vecfree(pg);
vecfree(w);
vecfree(d);
vecfree(gp);
vecfree(g);
vecfree(xp);
throw;
}
lbfgs_exit: lbfgs_exit:
/* Return the final value of the objective function. */ /* Return the final value of the objective function. */
......
...@@ -555,7 +555,8 @@ public: ...@@ -555,7 +555,8 @@ public:
CutoffNonPeriodic = 1, CutoffNonPeriodic = 1,
CutoffPeriodic = 2, CutoffPeriodic = 2,
Ewald = 3, Ewald = 3,
PME = 4 PME = 4,
LJPME = 5
}; };
static std::string Name() { static std::string Name() {
return "CalcNonbondedForce"; return "CalcNonbondedForce";
...@@ -596,6 +597,15 @@ public: ...@@ -596,6 +597,15 @@ public:
* @param nz the number of grid points along the Z axis * @param nz the number of grid points along the Z axis
*/ */
virtual void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0; virtual void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0;
/**
* Get the parameters being used for the dispersion terms in LJPME.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
virtual void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0;
}; };
/** /**
...@@ -1335,6 +1345,57 @@ public: ...@@ -1335,6 +1345,57 @@ public:
}; };
/**
* This kernel performs the dispersion reciprocal space calculation for LJPME. In most cases, this
* calculation is done directly by CalcNonbondedForceKernel so this kernel is unneeded.
* In some cases it may want to outsource the work to a different kernel. In particular,
* GPU based platforms sometimes use a CPU based implementation provided by a separate
* plugin.
*/
class CalcDispersionPmeReciprocalForceKernel : public KernelImpl {
public:
class IO;
static std::string Name() {
return "CalcDispersionPmeReciprocalForce";
}
CalcDispersionPmeReciprocalForceKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
}
/**
* Initialize the kernel.
*
* @param gridx the x size of the PME grid
* @param gridy the y size of the PME grid
* @param gridz the z size of the PME grid
* @param numParticles the number of particles in the system
* @param alpha the Ewald blending parameter
*/
virtual void initialize(int gridx, int gridy, int gridz, int numParticles, double alpha) = 0;
/**
* Begin computing the force and energy.
*
* @param io an object that coordinates data transfer
* @param periodicBoxVectors the vectors defining the periodic box (measured in nm)
* @param includeEnergy true if potential energy should be computed
*/
virtual void beginComputation(IO& io, const Vec3* periodicBoxVectors, bool includeEnergy) = 0;
/**
* Finish computing the force and energy.
*
* @param io an object that coordinates data transfer
* @return the potential energy due to the PME reciprocal space interactions
*/
virtual double finishComputation(IO& io) = 0;
/**
* Get the parameters being used for PME.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
virtual void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0;
};
} // namespace OpenMM } // namespace OpenMM
#endif /*OPENMM_KERNELS_H_*/ #endif /*OPENMM_KERNELS_H_*/
...@@ -104,7 +104,7 @@ void Platform::setPropertyDefaultValue(const string& property, const string& val ...@@ -104,7 +104,7 @@ void Platform::setPropertyDefaultValue(const string& property, const string& val
propertyName = deprecatedPropertyReplacements.find(property)->second; propertyName = deprecatedPropertyReplacements.find(property)->second;
for (int i = 0; i < (int) platformProperties.size(); i++) for (int i = 0; i < (int) platformProperties.size(); i++)
if (platformProperties[i] == propertyName) { if (platformProperties[i] == propertyName) {
defaultProperties[property] = value; defaultProperties[propertyName] = value;
return; return;
} }
throw OpenMMException("setPropertyDefaultValue: Illegal property name"); throw OpenMMException("setPropertyDefaultValue: Illegal property name");
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2015 Stanford University and the Authors. * * Portions copyright (c) 2015-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -171,6 +171,16 @@ protected: ...@@ -171,6 +171,16 @@ protected:
* The implementation returns the union of all kernel names required by all Integrators that have been added. * The implementation returns the union of all kernel names required by all Integrators that have been added.
*/ */
std::vector<std::string> getKernelNames(); std::vector<std::string> getKernelNames();
/**
* This will be called by the Context when the user modifies aspects of the context state, such
* as positions, velocities, or parameters. This gives the Integrator a chance to discard cached
* information. This is <i>only</i> called when the user modifies information using methods of the Context
* object. It is <i>not</i> called when a ForceImpl object modifies state information in its updateContextState()
* method (unless the ForceImpl calls a Context method to perform the modification).
*
* @param changed this specifies what aspect of the Context was changed
*/
void stateChanged(State::DataType changed);
/** /**
* Compute the kinetic energy of the system at the current time. * Compute the kinetic energy of the system at the current time.
* *
......
...@@ -57,7 +57,7 @@ namespace OpenMM { ...@@ -57,7 +57,7 @@ namespace OpenMM {
* <li>distance(p1, p2): the distance between particles p1 and p2 (where "p1" and "p2" may be replaced by the names * <li>distance(p1, p2): the distance between particles p1 and p2 (where "p1" and "p2" may be replaced by the names
* of whichever particles you want to calculate the distance between).</li> * of whichever particles you want to calculate the distance between).</li>
* <li>angle(p1, p2, p3): the angle formed by the three specified particles.</li> * <li>angle(p1, p2, p3): the angle formed by the three specified particles.</li>
* <li>dihedral(p1, p2, p3, p4): the dihedral angle formed by the four specified particles.</li> * <li>dihedral(p1, p2, p3, p4): the dihedral angle formed by the four specified particles, guaranteed to be in the range [-pi,+pi].</li>
* </ul> * </ul>
* *
* The expression also may involve tabulated functions, and may depend on arbitrary * The expression also may involve tabulated functions, and may depend on arbitrary
......
...@@ -52,6 +52,7 @@ namespace OpenMM { ...@@ -52,6 +52,7 @@ namespace OpenMM {
* part of the system definition, while values of global parameters may be modified during a simulation by calling Context::setParameter(). * part of the system definition, while values of global parameters may be modified during a simulation by calling Context::setParameter().
* Finally, call addTorsion() once for each torsion. After an torsion has been added, you can modify its parameters by calling setTorsionParameters(). * Finally, call addTorsion() once for each torsion. After an torsion has been added, you can modify its parameters by calling setTorsionParameters().
* This will have no effect on Contexts that already exist unless you call updateParametersInContext(). * This will have no effect on Contexts that already exist unless you call updateParametersInContext().
* theta is guaranteed to be in the range [-pi,+pi]
* *
* As an example, the following code creates a CustomTorsionForce that implements a harmonic potential: * As an example, the following code creates a CustomTorsionForce that implements a harmonic potential:
* *
......
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
* @returns true if force uses PBC and false otherwise * @returns true if force uses PBC and false otherwise
*/ */
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return true; return false;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
......
...@@ -147,7 +147,7 @@ public: ...@@ -147,7 +147,7 @@ public:
* @returns true if force uses PBC and false otherwise * @returns true if force uses PBC and false otherwise
*/ */
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return true; return false;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
......
...@@ -244,7 +244,7 @@ public: ...@@ -244,7 +244,7 @@ public:
* @returns true if force uses PBC and false otherwise * @returns true if force uses PBC and false otherwise
*/ */
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return true; return false;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
......
...@@ -101,15 +101,20 @@ public: ...@@ -101,15 +101,20 @@ public:
*/ */
CutoffPeriodic = 2, CutoffPeriodic = 2,
/** /**
* Periodic boundary conditions are used, and Ewald summation is used to compute the interaction of each particle * Periodic boundary conditions are used, and Ewald summation is used to compute the Coulomb interaction of each particle
* with all periodic copies of every other particle. * with all periodic copies of every other particle.
*/ */
Ewald = 3, Ewald = 3,
/** /**
* Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the interaction of each particle * Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the Coulomb interaction of each particle
* with all periodic copies of every other particle. * with all periodic copies of every other particle.
*/ */
PME = 4 PME = 4,
/**
* Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the interaction of each particle
* with all periodic copies of every other particle for both Coulomb and Lennard-Jones. No switching is used for either interaction.
*/
LJPME = 5
}; };
/** /**
* Create a NonbondedForce. * Create a NonbondedForce.
...@@ -207,6 +212,16 @@ public: ...@@ -207,6 +212,16 @@ public:
* @param[out] nz the number of grid points along the Z axis * @param[out] nz the number of grid points along the Z axis
*/ */
void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const; void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/**
* Get the parameters to use for dispersion term in LJ-PME calculations. If alpha is 0 (the default),
* these parameters are ignored and instead their values are chosen based on the Ewald error tolerance.
*
* @param[out] alpha the separation parameter
* @param[out] nx the number of dispersion grid points along the X axis
* @param[out] ny the number of dispersion grid points along the Y axis
* @param[out] nz the number of dispersion grid points along the Z axis
*/
void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/** /**
* Set the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are * Set the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are
* ignored and instead their values are chosen based on the Ewald error tolerance. * ignored and instead their values are chosen based on the Ewald error tolerance.
...@@ -217,6 +232,16 @@ public: ...@@ -217,6 +232,16 @@ public:
* @param nz the number of grid points along the Z axis * @param nz the number of grid points along the Z axis
*/ */
void setPMEParameters(double alpha, int nx, int ny, int nz); void setPMEParameters(double alpha, int nx, int ny, int nz);
/**
* Set the parameters to use for the dispersion term in LJPME calculations. If alpha is 0 (the default),
* these parameters are ignored and instead their values are chosen based on the Ewald error tolerance.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
void setLJPMEParameters(double alpha, int nx, int ny, int nz);
/** /**
* Get the parameters being used for PME in a particular Context. Because some platforms have restrictions * Get the parameters being used for PME in a particular Context. Because some platforms have restrictions
* on the allowed grid sizes, the values that are actually used may be slightly different from those * on the allowed grid sizes, the values that are actually used may be slightly different from those
...@@ -230,6 +255,19 @@ public: ...@@ -230,6 +255,19 @@ public:
* @param[out] nz the number of grid points along the Z axis * @param[out] nz the number of grid points along the Z axis
*/ */
void getPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const; void getPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const;
/**
* Get the PME parameters being used for the dispersion term for LJPME in a particular Context. Because some
* platforms have restrictions on the allowed grid sizes, the values that are actually used may be slightly different
* from those specified with setPMEParameters(), or the standard values calculated based on the Ewald error tolerance.
* See the manual for details.
*
* @param context the Context for which to get the parameters
* @param[out] alpha the separation parameter
* @param[out] nx the number of grid points along the X axis
* @param[out] ny the number of grid points along the Y axis
* @param[out] nz the number of grid points along the Z axis
*/
void getLJPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const;
/** /**
* Add the nonbonded force parameters for a particle. This should be called once for each particle * Add the nonbonded force parameters for a particle. This should be called once for each particle
* in the System. When it is called for the i'th time, it specifies the parameters for the i'th particle. * in the System. When it is called for the i'th time, it specifies the parameters for the i'th particle.
...@@ -374,7 +412,8 @@ public: ...@@ -374,7 +412,8 @@ public:
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == NonbondedForce::CutoffPeriodic || return nonbondedMethod == NonbondedForce::CutoffPeriodic ||
nonbondedMethod == NonbondedForce::Ewald || nonbondedMethod == NonbondedForce::Ewald ||
nonbondedMethod == NonbondedForce::PME; nonbondedMethod == NonbondedForce::PME ||
nonbondedMethod == NonbondedForce::LJPME;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
...@@ -382,9 +421,9 @@ private: ...@@ -382,9 +421,9 @@ private:
class ParticleInfo; class ParticleInfo;
class ExceptionInfo; class ExceptionInfo;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
double cutoffDistance, switchingDistance, rfDielectric, ewaldErrorTol, alpha; double cutoffDistance, switchingDistance, rfDielectric, ewaldErrorTol, alpha, dalpha;
bool useSwitchingFunction, useDispersionCorrection; bool useSwitchingFunction, useDispersionCorrection;
int recipForceGroup, nx, ny, nz; int recipForceGroup, nx, ny, nz, dnx, dny, dnz;
void addExclusionsToSet(const std::vector<std::set<int> >& bonded12, std::set<int>& exclusions, int baseParticle, int fromParticle, int currentLevel) const; void addExclusionsToSet(const std::vector<std::set<int> >& bonded12, std::set<int>& exclusions, int baseParticle, int fromParticle, int currentLevel) const;
std::vector<ParticleInfo> particles; std::vector<ParticleInfo> particles;
std::vector<ExceptionInfo> exceptions; std::vector<ExceptionInfo> exceptions;
......
...@@ -59,6 +59,9 @@ class OPENMM_EXPORT TabulatedFunction { ...@@ -59,6 +59,9 @@ class OPENMM_EXPORT TabulatedFunction {
public: public:
virtual ~TabulatedFunction() { virtual ~TabulatedFunction() {
} }
/**
* @deprecated This will be removed in a future release.
*/
virtual TabulatedFunction* Copy() const = 0; virtual TabulatedFunction* Copy() const = 0;
}; };
...@@ -99,6 +102,8 @@ public: ...@@ -99,6 +102,8 @@ public:
void setFunctionParameters(const std::vector<double>& values, double min, double max); void setFunctionParameters(const std::vector<double>& values, double min, double max);
/** /**
* Create a deep copy of the tabulated function. * Create a deep copy of the tabulated function.
*
* @deprecated This will be removed in a future release.
*/ */
Continuous1DFunction* Copy() const; Continuous1DFunction* Copy() const;
private: private:
...@@ -158,6 +163,8 @@ public: ...@@ -158,6 +163,8 @@ public:
void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax); void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Continuous2DFunction* Copy() const; Continuous2DFunction* Copy() const;
private: private:
...@@ -233,6 +240,8 @@ public: ...@@ -233,6 +240,8 @@ public:
void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Continuous3DFunction* Copy() const; Continuous3DFunction* Copy() const;
private: private:
...@@ -268,6 +277,8 @@ public: ...@@ -268,6 +277,8 @@ public:
void setFunctionParameters(const std::vector<double>& values); void setFunctionParameters(const std::vector<double>& values);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Discrete1DFunction* Copy() const; Discrete1DFunction* Copy() const;
private: private:
...@@ -310,6 +321,8 @@ public: ...@@ -310,6 +321,8 @@ public:
void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values); void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Discrete2DFunction* Copy() const; Discrete2DFunction* Copy() const;
private: private:
...@@ -356,6 +369,8 @@ public: ...@@ -356,6 +369,8 @@ public:
void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values); void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Discrete3DFunction* Copy() const; Discrete3DFunction* Copy() const;
private: private:
......
...@@ -252,6 +252,10 @@ public: ...@@ -252,6 +252,10 @@ public:
void integratorDeleted() { void integratorDeleted() {
integratorIsDeleted = true; integratorIsDeleted = true;
} }
/**
* Notify the integrator that some aspect of the system has changed, and cached information should be discarded.
*/
void systemChanged();
/** /**
* This is the routine that actually computes the list of molecules returned by getMolecules(). Normally * This is the routine that actually computes the list of molecules returned by getMolecules(). Normally
* you should never call it. It is exposed here because the same logic is useful to other classes too. * you should never call it. It is exposed here because the same logic is useful to other classes too.
......
...@@ -65,6 +65,7 @@ public: ...@@ -65,6 +65,7 @@ public:
std::vector<std::string> getKernelNames(); std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context); void updateParametersInContext(ContextImpl& context);
void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const; void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/** /**
* This is a utility routine that calculates the values to use for alpha and kmax when using * This is a utility routine that calculates the values to use for alpha and kmax when using
* Ewald summation. * Ewald summation.
...@@ -74,7 +75,7 @@ public: ...@@ -74,7 +75,7 @@ public:
* This is a utility routine that calculates the values to use for alpha and grid size when using * This is a utility routine that calculates the values to use for alpha and grid size when using
* Particle Mesh Ewald. * Particle Mesh Ewald.
*/ */
static void calcPMEParameters(const System& system, const NonbondedForce& force, double& alpha, int& xsize, int& ysize, int& zsize); static void calcPMEParameters(const System& system, const NonbondedForce& force, double& alpha, int& xsize, int& ysize, int& zsize, bool lj);
/** /**
* Compute the coefficient which, when divided by the periodic box volume, gives the * Compute the coefficient which, when divided by the periodic box volume, gives the
* long range dispersion correction to the energy. * long range dispersion correction to the energy.
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2013 Stanford University and the Authors. * * Portions copyright (c) 2013-2017 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define NOMINMAX #define NOMINMAX
#include "windowsExport.h" #include "windowsExport.h"
#include <functional>
#include <pthread.h> #include <pthread.h>
#include <vector> #include <vector>
...@@ -69,6 +70,10 @@ public: ...@@ -69,6 +70,10 @@ public:
* Execute a Task in parallel on the worker threads. * Execute a Task in parallel on the worker threads.
*/ */
void execute(Task& task); void execute(Task& task);
/**
* Execute a function in parallel on the worker threads.
*/
void execute(std::function<void (ThreadPool&, int)> task);
/** /**
* This is called by the worker threads to block until all threads have reached the same point * This is called by the worker threads to block until all threads have reached the same point
* and the master thread instructs them to continue by calling resumeThreads(). * and the master thread instructs them to continue by calling resumeThreads().
...@@ -90,6 +95,8 @@ private: ...@@ -90,6 +95,8 @@ private:
std::vector<ThreadData*> threadData; std::vector<ThreadData*> threadData;
pthread_cond_t startCondition, endCondition; pthread_cond_t startCondition, endCondition;
pthread_mutex_t lock; pthread_mutex_t lock;
Task* currentTask;
std::function<void (ThreadPool& pool, int)> currentFunction;
}; };
/** /**
......
...@@ -158,4 +158,5 @@ void CMAPTorsionForceImpl::calcMapDerivatives(int size, const vector<double>& en ...@@ -158,4 +158,5 @@ void CMAPTorsionForceImpl::calcMapDerivatives(int size, const vector<double>& en
void CMAPTorsionForceImpl::updateParametersInContext(ContextImpl& context) { void CMAPTorsionForceImpl::updateParametersInContext(ContextImpl& context) {
kernel.getAs<CalcCMAPTorsionForceKernel>().copyParametersToContext(context, owner); kernel.getAs<CalcCMAPTorsionForceKernel>().copyParametersToContext(context, owner);
context.systemChanged();
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2015 Stanford University and the Authors. * * Portions copyright (c) 2015-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -120,6 +120,11 @@ vector<string> CompoundIntegrator::getKernelNames() { ...@@ -120,6 +120,11 @@ vector<string> CompoundIntegrator::getKernelNames() {
return kernels; return kernels;
} }
void CompoundIntegrator::stateChanged(State::DataType changed) {
for (int i = 0; i < integrators.size(); i++)
integrators[i]->stateChanged(changed);
}
double CompoundIntegrator::computeKineticEnergy() { double CompoundIntegrator::computeKineticEnergy() {
return integrators[currentIntegrator]->computeKineticEnergy(); return integrators[currentIntegrator]->computeKineticEnergy();
} }
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