Commit ddbd992b authored by Jason Swails's avatar Jason Swails
Browse files

Add a usesPeriodicBoundaryConditions() method to all of the Force classes and

the System. The System inspects all of its forces and calls
usePeriodicBoundaryConditions -- it reports 'true' if at least one of its Forces
returns 'true' for usesPeriodicBoundaryConditions.

The default Force implementation is to raise an exception (NotImplementedError).
The System implementation will return true if at least one of its Forces returns
'true' for usesPeriodicBoundaryConditions, _regardless_ of whether or not one or
more of the forces does not implement the method. If at least one of the forces
does not implement usesPeriodicBoundaryConditions and all forces return false,
an OpenMMException is thrown.
parent 67ad6557
......@@ -148,6 +148,13 @@ public:
* @param b4 the index of the fourth particle forming the second torsion
*/
void setTorsionParameters(int index, int map, int a1, int a2, int a3, int a4, int b1, int b2, int b3, int b4);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns false
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -202,6 +202,13 @@ public:
* the Context. The set of particles involved in a angle cannot be changed, nor can new angles be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns false
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -199,6 +199,13 @@ public:
* the Context. The set of particles involved in a bond cannot be changed, nor can new bonds be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns false
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -297,6 +297,13 @@ public:
* the Context. The set of particles involved in a bond cannot be changed, nor can new bonds be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns false
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -199,6 +199,13 @@ public:
* the Context. Also, this method cannot be used to add new particles, only to change the parameters of existing ones.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns false
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -523,6 +523,15 @@ public:
* the Context. Also, this method cannot be used to add new particles, only to change the parameters of existing ones.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == CustomGBForce::CutoffPeriodic;
}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -443,6 +443,15 @@ public:
* new donors or acceptors be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == CustomHbondForce::CutoffPeriodic;
}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -461,6 +461,15 @@ public:
* the parameters of existing ones.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == CustomManyParticleForce::CutoffPeriodic;
}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -464,6 +464,15 @@ public:
* the parameters of existing ones.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == CustomNonbondedForce::CutoffPeriodic;
}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -205,6 +205,13 @@ public:
* the Context. The set of particles involved in a torsion cannot be changed, nor can new torsions be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -78,6 +78,14 @@ public:
* @param group the group index. Legal values are between 0 and 31 (inclusive).
*/
void setForceGroup(int group);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions. This method should be overridden for all Force subclasses, or
* a OpenMM::NotImplementedError will be thrown
*
* @return true if Force uses periodic boundaries or false if it does not
*/
virtual bool usesPeriodicBoundaryConditions() const;
protected:
friend class ContextImpl;
/**
......
......@@ -184,6 +184,15 @@ public:
* change the parameters of existing ones.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == GBSAOBCForce::CutoffPeriodic;
}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -229,6 +229,15 @@ public:
* Set the upper limit used in the quintic spline scaling method, measured in nm (~5.0)
*/
void setQuinticUpperBornRadiusLimit(double quinticUpperBornRadiusLimit);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == GBVIForce::CutoffPeriodic;
}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -102,6 +102,13 @@ public:
* in a angle cannot be changed, nor can new angles be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -99,6 +99,13 @@ public:
* in a bond cannot be changed, nor can new bonds be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -352,6 +352,17 @@ public:
* to add new particles or exceptions, only to change the parameters of existing ones.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == NonbondedForce::CutoffPeriodic ||
nonbondedMethod == NonbondedForce::Ewald ||
nonbondedMethod == NonbondedForce::PME;
}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -54,6 +54,17 @@ private:
std::string message;
};
class NotImplementedError : public std::exception {
public:
explicit NotImplementedError(const std::string& message) : message(message) {
}
~NotImplementedError() throw() {
}
const char* what() const throw() {
return message.c_str();
}
};
} // namespace OpenMM
#endif /*OPENMM_OPENMMEXCEPTION_H_*/
......@@ -108,6 +108,13 @@ public:
* in a torsion cannot be changed, nor can new torsions be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
......@@ -117,6 +117,13 @@ public:
* in a torsion cannot be changed, nor can new torsions be added.
*/
void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if nonbondedMethod uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {return false;}
protected:
ForceImpl* createImpl() const;
private:
......
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