Commit 5b5e2cb6 authored by Peter Eastman's avatar Peter Eastman
Browse files

Reciprocal space force group defaults to "same as direct space force group"

parent 33badc47
...@@ -267,16 +267,17 @@ public: ...@@ -267,16 +267,17 @@ public:
* Get the force group that reciprocal space interactions for Ewald or PME are included in. This allows multiple * Get the force group that reciprocal space interactions for Ewald or PME are included in. This allows multiple
* time step integrators to evaluate direct and reciprocal space interactions at different intervals: getForceGroup() * time step integrators to evaluate direct and reciprocal space interactions at different intervals: getForceGroup()
* specifies the group for direct space, and getReciprocalSpaceForceGroup() specifies the group for reciprocal space. * specifies the group for direct space, and getReciprocalSpaceForceGroup() specifies the group for reciprocal space.
* The default value is 0. * If this is -1 (the default value), the same force group is used for reciprocal space as for direct space.
*/ */
int getReciprocalSpaceForceGroup() const; int getReciprocalSpaceForceGroup() const;
/** /**
* Set the force group that reciprocal space interactions for Ewald or PME are included in. This allows multiple * Set the force group that reciprocal space interactions for Ewald or PME are included in. This allows multiple
* time step integrators to evaluate direct and reciprocal space interactions at different intervals: setForceGroup() * time step integrators to evaluate direct and reciprocal space interactions at different intervals: setForceGroup()
* specifies the group for direct space, and setReciprocalSpaceForceGroup() specifies the group for reciprocal space. * specifies the group for direct space, and setReciprocalSpaceForceGroup() specifies the group for reciprocal space.
* The default value is 0. * If this is -1 (the default value), the same force group is used for reciprocal space as for direct space.
* *
* @param group the group index. Legal values are between 0 and 31 (inclusive). * @param group the group index. Legal values are between 0 and 31 (inclusive), or -1 to use the same force group
* that is specified for direct space.
*/ */
void setReciprocalSpaceForceGroup(int group); void setReciprocalSpaceForceGroup(int group);
protected: protected:
......
...@@ -47,7 +47,7 @@ using std::string; ...@@ -47,7 +47,7 @@ using std::string;
using std::stringstream; using std::stringstream;
using std::vector; using std::vector;
NonbondedForce::NonbondedForce() : nonbondedMethod(NoCutoff), cutoffDistance(1.0), rfDielectric(78.3), ewaldErrorTol(5e-4), useDispersionCorrection(true), recipForceGroup(0) { NonbondedForce::NonbondedForce() : nonbondedMethod(NoCutoff), cutoffDistance(1.0), rfDielectric(78.3), ewaldErrorTol(5e-4), useDispersionCorrection(true), recipForceGroup(-1) {
} }
NonbondedForce::NonbondedMethod NonbondedForce::getNonbondedMethod() const { NonbondedForce::NonbondedMethod NonbondedForce::getNonbondedMethod() const {
...@@ -202,7 +202,7 @@ int NonbondedForce::getReciprocalSpaceForceGroup() const { ...@@ -202,7 +202,7 @@ int NonbondedForce::getReciprocalSpaceForceGroup() const {
} }
void NonbondedForce::setReciprocalSpaceForceGroup(int group) { void NonbondedForce::setReciprocalSpaceForceGroup(int group) {
if (group < 0 || group > 31) if (group < -1 || group > 31)
throw OpenMMException("Force group must be between 0 and 31"); throw OpenMMException("Force group must be between -1 and 31");
recipForceGroup = group; recipForceGroup = group;
} }
...@@ -100,7 +100,9 @@ void NonbondedForceImpl::initialize(ContextImpl& context) { ...@@ -100,7 +100,9 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
double NonbondedForceImpl::calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) { double NonbondedForceImpl::calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) {
bool includeDirect = ((groups&(1<<owner.getForceGroup())) != 0); bool includeDirect = ((groups&(1<<owner.getForceGroup())) != 0);
bool includeReciprocal = ((groups&(1<<owner.getReciprocalSpaceForceGroup())) != 0); bool includeReciprocal = includeDirect;
if (owner.getReciprocalSpaceForceGroup() >= 0)
includeReciprocal = ((groups&(1<<owner.getReciprocalSpaceForceGroup())) != 0);
return dynamic_cast<CalcNonbondedForceKernel&>(kernel.getImpl()).execute(context, includeForces, includeEnergy, includeDirect, includeReciprocal); return dynamic_cast<CalcNonbondedForceKernel&>(kernel.getImpl()).execute(context, includeForces, includeEnergy, includeDirect, includeReciprocal);
} }
......
...@@ -822,7 +822,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon ...@@ -822,7 +822,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
method = PERIODIC; method = PERIODIC;
} }
if (force.getNonbondedMethod() == NonbondedForce::Ewald || force.getNonbondedMethod() == NonbondedForce::PME) { if (force.getNonbondedMethod() == NonbondedForce::Ewald || force.getNonbondedMethod() == NonbondedForce::PME) {
if (force.getReciprocalSpaceForceGroup() != 0) if (force.getReciprocalSpaceForceGroup() > 0)
throw OpenMMException("CudaPlatform does not support force groups"); throw OpenMMException("CudaPlatform does not support force groups");
if (force.getNonbondedMethod() == NonbondedForce::Ewald) { if (force.getNonbondedMethod() == NonbondedForce::Ewald) {
double alpha; double alpha;
......
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