Commit c44c956d authored by peastman's avatar peastman
Browse files

Deleted lots of debugging code

parent 41cd79a5
......@@ -157,7 +157,7 @@ public:
*
* @return number of bonds
*/
int getNumBonds( void ) const;
int getNumBonds() const;
/**
* Get the dielectric constant for the solvent.
......@@ -208,7 +208,7 @@ public:
/**
* Get Born radius scaling method
*/
BornRadiusScalingMethod getBornRadiusScalingMethod( void ) const;
BornRadiusScalingMethod getBornRadiusScalingMethod() const;
/**
* Set Born radius scaling method
*/
......@@ -216,7 +216,7 @@ public:
/**
* Get the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8)
*/
double getQuinticLowerLimitFactor( void ) const;
double getQuinticLowerLimitFactor() const;
/**
* Set the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8)
*/
......@@ -224,7 +224,7 @@ public:
/**
* Get the upper limit used in the quintic spline scaling method, measured in nm (~5.0)
*/
double getQuinticUpperBornRadiusLimit( void ) const;
double getQuinticUpperBornRadiusLimit() const;
/**
* Set the upper limit used in the quintic spline scaling method, measured in nm (~5.0)
*/
......
......@@ -77,7 +77,7 @@ void GBVIForce::setCutoffDistance(double distance) {
cutoffDistance = distance;
}
GBVIForce::BornRadiusScalingMethod GBVIForce::getBornRadiusScalingMethod( void ) const {
GBVIForce::BornRadiusScalingMethod GBVIForce::getBornRadiusScalingMethod() const {
return scalingMethod;
}
......@@ -85,7 +85,7 @@ void GBVIForce::setBornRadiusScalingMethod(BornRadiusScalingMethod method) {
scalingMethod = method;
}
double GBVIForce::getQuinticLowerLimitFactor( void ) const {
double GBVIForce::getQuinticLowerLimitFactor() const {
return quinticLowerLimitFactor;
}
......@@ -93,7 +93,7 @@ void GBVIForce::setQuinticLowerLimitFactor(double inputQuinticLowerLimitFactor )
quinticLowerLimitFactor = inputQuinticLowerLimitFactor;
}
double GBVIForce::getQuinticUpperBornRadiusLimit( void ) const {
double GBVIForce::getQuinticUpperBornRadiusLimit() const {
return quinticUpperBornRadiusLimit;
}
......@@ -113,7 +113,7 @@ void GBVIForce::setBondParameters( int index, int particle1, int particle2, doub
bonds[index].bondLength = bondLength;
}
int GBVIForce::getNumBonds( void ) const {
int GBVIForce::getNumBonds() const {
return (int) bonds.size();
}
......
......@@ -145,8 +145,6 @@ int GBVIForceImpl::getBondsFromForces(ContextImpl& context) {
}
*/
#define GBVIDebug 0
void GBVIForceImpl::findScaledRadii( int numberOfParticles, const std::vector<std::vector<int> >& bondIndices,
const std::vector<double> & bondLengths, std::vector<double> & scaledRadii) const {
......@@ -219,26 +217,6 @@ void GBVIForceImpl::findScaledRadii( int numberOfParticles, const std::vector<st
if( errors ){
throw OpenMMException("GBVIForceImpl::findScaledRadii errors -- aborting");
}
#if GBVIDebug
(void) fprintf( stderr, " R q gamma scaled radii no. bnds\n" );
double totalQ = 0.0;
for( int i = 0; i < (int) scaledRadii.size(); i++ ){
double charge;
double gamma;
double radiusI;
owner.getParticleParameters(i, charge, radiusI, gamma);
totalQ += charge;
(void) fprintf( stderr, "%4d %14.5e %14.5e %14.5e %14.5e %d\n", i, radiusI, charge, gamma, scaledRadii[i], (int) bonded12[i].size() );
}
(void) fprintf( stderr, "Total charge=%e\n", totalQ );
(void) fflush( stderr );
#endif
#undef GBVIDebug
}
double GBVIForceImpl::calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) {
......
......@@ -77,7 +77,7 @@ public:
*
* @return global cubicK term
*/
double getAmoebaGlobalAngleCubic( void ) const;
double getAmoebaGlobalAngleCubic() const;
/**
* Set the global quartic term
......@@ -91,7 +91,7 @@ public:
*
* @return global quartic term
*/
double getAmoebaGlobalAngleQuartic( void ) const;
double getAmoebaGlobalAngleQuartic() const;
/**
* Set the global pentic term
......@@ -105,7 +105,7 @@ public:
*
* @return global penticK term
*/
double getAmoebaGlobalAnglePentic( void ) const;
double getAmoebaGlobalAnglePentic() const;
/**
* Set the global sextic term
......@@ -119,7 +119,7 @@ public:
*
* @return global sextic term
*/
double getAmoebaGlobalAngleSextic( void ) const;
double getAmoebaGlobalAngleSextic() const;
/**
* Add an angle term to the force field.
......
......@@ -78,7 +78,7 @@ public:
*
* @return global cubicK term
*/
double getAmoebaGlobalBondCubic( void ) const;
double getAmoebaGlobalBondCubic() const;
/**
* Set the global quartic term
......@@ -92,7 +92,7 @@ public:
*
* @return global quartic term
*/
double getAmoebaGlobalBondQuartic( void ) const;
double getAmoebaGlobalBondQuartic() const;
/**
* Add a bond term to the force field.
......
......@@ -127,7 +127,7 @@ public:
/**
* Get the flag signaling whether the cavity term should be included
*/
int getIncludeCavityTerm( ) const;
int getIncludeCavityTerm() const;
/**
* Set the flag signaling whether the cavity term should be included
......
......@@ -77,7 +77,7 @@ public:
*
* @return global cubicK term
*/
double getAmoebaGlobalInPlaneAngleCubic( void ) const;
double getAmoebaGlobalInPlaneAngleCubic() const;
/**
* Set the global quartic term
......@@ -91,7 +91,7 @@ public:
*
* @return global quartic term
*/
double getAmoebaGlobalInPlaneAngleQuartic( void ) const;
double getAmoebaGlobalInPlaneAngleQuartic() const;
/**
* Set the global pentic term
......@@ -105,7 +105,7 @@ public:
*
* @return global penticK term
*/
double getAmoebaGlobalInPlaneAnglePentic( void ) const;
double getAmoebaGlobalInPlaneAnglePentic() const;
/**
* Set the global sextic term
......@@ -119,7 +119,7 @@ public:
*
* @return global sextic term
*/
double getAmoebaGlobalInPlaneAngleSextic( void ) const;
double getAmoebaGlobalInPlaneAngleSextic() const;
/**
* Add an angle term to the force field.
......
......@@ -97,7 +97,7 @@ private:
static int CovalentDegrees[AmoebaMultipoleForce::CovalentEnd];
static bool initializedCovalentDegrees;
static const int* getCovalentDegrees( void );
static const int* getCovalentDegrees();
};
} // namespace OpenMM
......
......@@ -63,7 +63,7 @@ void AmoebaAngleForce::setAngleParameters(int index, int particle1, int particle
angles[index].quadraticK = quadraticK;
}
double AmoebaAngleForce::getAmoebaGlobalAngleCubic( void ) const {
double AmoebaAngleForce::getAmoebaGlobalAngleCubic() const {
return _globalCubicK;
}
......@@ -71,7 +71,7 @@ void AmoebaAngleForce::setAmoebaGlobalAngleCubic(double cubicK ) {
_globalCubicK = cubicK;
}
double AmoebaAngleForce::getAmoebaGlobalAngleQuartic( void ) const {
double AmoebaAngleForce::getAmoebaGlobalAngleQuartic() const {
return _globalQuarticK;
}
......@@ -79,7 +79,7 @@ void AmoebaAngleForce::setAmoebaGlobalAngleQuartic(double quarticK ) {
_globalQuarticK = quarticK;
}
double AmoebaAngleForce::getAmoebaGlobalAnglePentic( void ) const {
double AmoebaAngleForce::getAmoebaGlobalAnglePentic() const {
return _globalPenticK;
}
......@@ -87,7 +87,7 @@ void AmoebaAngleForce::setAmoebaGlobalAnglePentic(double penticK ) {
_globalPenticK = penticK;
}
double AmoebaAngleForce::getAmoebaGlobalAngleSextic( void ) const {
double AmoebaAngleForce::getAmoebaGlobalAngleSextic() const {
return _globalSexticK;
}
......
......@@ -67,11 +67,11 @@ void AmoebaBondForce::setAmoebaGlobalBondQuartic(double quarticK ) {
_globalQuarticK = quarticK;
}
double AmoebaBondForce::getAmoebaGlobalBondCubic( void ) const {
double AmoebaBondForce::getAmoebaGlobalBondCubic() const {
return _globalCubicK;
}
double AmoebaBondForce::getAmoebaGlobalBondQuartic( void ) const {
double AmoebaBondForce::getAmoebaGlobalBondQuartic() const {
return _globalQuarticK;
}
......
......@@ -73,11 +73,11 @@ void AmoebaInPlaneAngleForce::setAmoebaGlobalInPlaneAngleQuartic(double quarticK
_globalQuarticK = quarticK;
}
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAngleCubic( void ) const {
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAngleCubic() const {
return _globalCubicK;
}
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAngleQuartic( void ) const {
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAngleQuartic() const {
return _globalQuarticK;
}
......@@ -89,11 +89,11 @@ void AmoebaInPlaneAngleForce::setAmoebaGlobalInPlaneAngleSextic(double quarticK
_globalSexticK = quarticK;
}
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAnglePentic( void ) const {
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAnglePentic() const {
return _globalPenticK;
}
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAngleSextic( void ) const {
double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAngleSextic() const {
return _globalSexticK;
}
......
......@@ -45,7 +45,7 @@ AmoebaMultipoleForce::AmoebaMultipoleForce() : nonbondedMethod(NoCutoff), polari
pmeGridDimension[0] = pmeGridDimension[1] = pmeGridDimension[2];
}
AmoebaMultipoleForce::NonbondedMethod AmoebaMultipoleForce::getNonbondedMethod( void ) const {
AmoebaMultipoleForce::NonbondedMethod AmoebaMultipoleForce::getNonbondedMethod() const {
return nonbondedMethod;
}
......@@ -53,7 +53,7 @@ void AmoebaMultipoleForce::setNonbondedMethod( AmoebaMultipoleForce::NonbondedMe
nonbondedMethod = method;
}
AmoebaMultipoleForce::PolarizationType AmoebaMultipoleForce::getPolarizationType( void ) const {
AmoebaMultipoleForce::PolarizationType AmoebaMultipoleForce::getPolarizationType() const {
return polarizationType;
}
......@@ -77,7 +77,7 @@ void AmoebaMultipoleForce::setAEwald(double inputAewald ) {
aewald = inputAewald;
}
int AmoebaMultipoleForce::getPmeBSplineOrder( void ) const {
int AmoebaMultipoleForce::getPmeBSplineOrder() const {
return pmeBSplineOrder;
}
......@@ -103,7 +103,7 @@ void AmoebaMultipoleForce::setPmeGridDimensions( const std::vector<int>& gridDim
return;
}
int AmoebaMultipoleForce::getMutualInducedMaxIterations( void ) const {
int AmoebaMultipoleForce::getMutualInducedMaxIterations() const {
return mutualInducedMaxIterations;
}
......@@ -111,7 +111,7 @@ void AmoebaMultipoleForce::setMutualInducedMaxIterations( int inputMutualInduced
mutualInducedMaxIterations = inputMutualInducedMaxIterations;
}
double AmoebaMultipoleForce::getMutualInducedTargetEpsilon( void ) const {
double AmoebaMultipoleForce::getMutualInducedTargetEpsilon() const {
return mutualInducedTargetEpsilon;
}
......
......@@ -138,7 +138,7 @@ std::vector<std::string> AmoebaMultipoleForceImpl::getKernelNames() {
return names;
}
const int* AmoebaMultipoleForceImpl::getCovalentDegrees( void ) {
const int* AmoebaMultipoleForceImpl::getCovalentDegrees() {
if( !initializedCovalentDegrees ){
initializedCovalentDegrees = true;
CovalentDegrees[AmoebaMultipoleForce::Covalent12] = 1;
......
......@@ -44,7 +44,7 @@ AmoebaOutOfPlaneBendForce::AmoebaOutOfPlaneBendForce() {
}
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendCubic( void ) const {
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendCubic() const {
return _globalCubicK;
}
......@@ -52,7 +52,7 @@ void AmoebaOutOfPlaneBendForce::setAmoebaGlobalOutOfPlaneBendCubic(double cubicK
_globalCubicK = cubicK;
}
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendQuartic( void ) const {
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendQuartic() const {
return _globalQuarticK;
}
......@@ -60,7 +60,7 @@ void AmoebaOutOfPlaneBendForce::setAmoebaGlobalOutOfPlaneBendQuartic(double quar
_globalQuarticK = quarticK;
}
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendPentic( void ) const {
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendPentic() const {
return _globalPenticK;
}
......@@ -68,7 +68,7 @@ void AmoebaOutOfPlaneBendForce::setAmoebaGlobalOutOfPlaneBendPentic(double penti
_globalPenticK = penticK;
}
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendSextic( void ) const {
double AmoebaOutOfPlaneBendForce::getAmoebaGlobalOutOfPlaneBendSextic() const {
return _globalSexticK;
}
......
......@@ -66,7 +66,7 @@ void AmoebaVdwForce::setSigmaCombiningRule( const std::string& inputSigmaCombini
sigmaCombiningRule = inputSigmaCombiningRule;
}
const std::string& AmoebaVdwForce::getSigmaCombiningRule( void ) const {
const std::string& AmoebaVdwForce::getSigmaCombiningRule() const {
return sigmaCombiningRule;
}
......@@ -74,7 +74,7 @@ void AmoebaVdwForce::setEpsilonCombiningRule( const std::string& inputEpsilonCom
epsilonCombiningRule = inputEpsilonCombiningRule;
}
const std::string& AmoebaVdwForce::getEpsilonCombiningRule( void ) const {
const std::string& AmoebaVdwForce::getEpsilonCombiningRule() const {
return epsilonCombiningRule;
}
......
......@@ -63,35 +63,35 @@ void AmoebaWcaDispersionForce::setParticleParameters(int particleIndex, double r
parameters[particleIndex].epsilon = epsilon;
}
double AmoebaWcaDispersionForce::getEpso( void ) const {
double AmoebaWcaDispersionForce::getEpso() const {
return epso;
}
double AmoebaWcaDispersionForce::getEpsh( void ) const {
double AmoebaWcaDispersionForce::getEpsh() const {
return epsh;
}
double AmoebaWcaDispersionForce::getRmino( void ) const {
double AmoebaWcaDispersionForce::getRmino() const {
return rmino;
}
double AmoebaWcaDispersionForce::getRminh( void ) const {
double AmoebaWcaDispersionForce::getRminh() const {
return rminh;
}
double AmoebaWcaDispersionForce::getAwater( void ) const {
double AmoebaWcaDispersionForce::getAwater() const {
return awater;
}
double AmoebaWcaDispersionForce::getShctd( void ) const {
double AmoebaWcaDispersionForce::getShctd() const {
return shctd;
}
double AmoebaWcaDispersionForce::getDispoff( void ) const {
double AmoebaWcaDispersionForce::getDispoff() const {
return dispoff;
}
double AmoebaWcaDispersionForce::getSlevy( void ) const {
double AmoebaWcaDispersionForce::getSlevy() const {
return slevy;
}
......
......@@ -33,8 +33,6 @@
using std::vector;
using namespace OpenMM;
#undef AMOEBA_DEBUG
AmoebaReferenceMultipoleForce::AmoebaReferenceMultipoleForce() :
_nonbondedMethod(NoCutoff),
_numParticles(0),
......@@ -233,33 +231,6 @@ void AmoebaReferenceMultipoleForce::setupScaleMaps(const vector< vector< vector<
}
}
}
//showScaleMapForParticle(2, stderr);
//showScaleMapForParticle(10, stderr);
return;
}
void AmoebaReferenceMultipoleForce::showScaleMapForParticle(unsigned int particleI, FILE* log) const
{
#ifdef AMOEBA_DEBUG
(void) fprintf(log, "Scale map particle %5u maxIndex=%u\n", particleI, _maxScaleIndex[particleI]);
std::string scaleNames[LAST_SCALE_TYPE_INDEX] = { "D", "P", "M" };
for (unsigned int ii = 0; ii < _scaleMaps[particleI].size(); ii++) {
MapIntRealOpenMM scaleMap = _scaleMaps[particleI][ii];
(void) fprintf(log, " %s scale ", scaleNames[ii].c_str());
for (MapIntRealOpenMMCI jj = scaleMap.begin(); jj != scaleMap.end(); jj++) {
//if (jj->first > particleI && jj->second < 1.0)
if (jj->second < 1.0)
(void) fprintf(log, "%4d=%5.2f ", jj->first, jj->second);
}
(void) fprintf(log, "\n");
}
(void) fprintf(log, "\n");
(void) fflush(log);
#endif
}
RealOpenMM AmoebaReferenceMultipoleForce::getMultipoleScaleFactor(unsigned int particleI, unsigned int particleJ, ScaleType scaleType) const
......
......@@ -712,15 +712,6 @@ protected:
*/
void setupScaleMaps(const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo);
/**
* Show scaling factor map
*
* @param particleI index of particle whose scale map is to be shown
* @param log output destination
*
*/
void showScaleMapForParticle(unsigned int particleI, FILE* log) const;
/**
* Get multipole scale factor for particleI & particleJ
*
......
......@@ -77,7 +77,7 @@ static void crossProductVector3(double* vectorX, double* vectorY, double* vector
static void getPrefactorsGivenAngleCosine(double cosine, double idealAngle, double quadraticK, double cubicK,
double quarticK, double penticK, double sexticK,
double* dEdR, double* energyTerm, FILE* log) {
double* dEdR, double* energyTerm) {
double angle;
if (cosine >= 1.0) {
......@@ -89,12 +89,6 @@ static void getPrefactorsGivenAngleCosine(double cosine, double idealAngle, doub
else {
angle = RADIAN*acos(cosine);
}
#ifdef AMOEBA_DEBUG
if (log) {
(void) fprintf(log, "getPrefactorsGivenAngleCosine: cosine=%10.3e angle=%10.3e ideal=%10.3e\n", cosine, angle, idealAngle);
(void) fflush(log);
}
#endif
double deltaIdeal = angle - idealAngle;
double deltaIdeal2 = deltaIdeal*deltaIdeal;
......@@ -122,7 +116,7 @@ static void getPrefactorsGivenAngleCosine(double cosine, double idealAngle, doub
}
static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions, AmoebaAngleForce& AmoebaAngleForce,
std::vector<Vec3>& forces, double* energy, FILE* log) {
std::vector<Vec3>& forces, double* energy) {
int particle1, particle2, particle3;
double idealAngle;
......@@ -133,13 +127,6 @@ static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions
double quarticK = AmoebaAngleForce.getAmoebaGlobalAngleQuartic();
double penticK = AmoebaAngleForce.getAmoebaGlobalAnglePentic();
double sexticK = AmoebaAngleForce.getAmoebaGlobalAngleSextic();
#ifdef AMOEBA_DEBUG
if (log) {
(void) fprintf(log, "computeAmoebaAngleForce: bond %d [%d %d %d] ang=%10.3f k=%10.3f [%10.3e %10.3e %10.3e %10.3e]\n",
bondIndex, particle1, particle2, particle3, idealAngle, quadraticK, cubicK, quarticK, penticK, sexticK);
(void) fflush(log);
}
#endif
double deltaR[2][3];
double r2_0 = 0.0;
......@@ -163,17 +150,10 @@ static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions
double dot = deltaR[0][0]*deltaR[1][0] + deltaR[0][1]*deltaR[1][1] + deltaR[0][2]*deltaR[1][2];
double cosine = dot/sqrt(r2_0*r2_1);
#ifdef AMOEBA_DEBUG
if (log) {
(void) fprintf(log, "dot=%10.3e r2_0=%10.3e r2_1=%10.3e\n", dot, r2_0, r2_1);
(void) fflush(log);
}
#endif
double dEdR;
double energyTerm;
getPrefactorsGivenAngleCosine(cosine, idealAngle, quadraticK, cubicK,
quarticK, penticK, sexticK, &dEdR, &energyTerm, log);
quarticK, penticK, sexticK, &dEdR, &energyTerm);
double termA = -dEdR/(r2_0*rp);
double termC = dEdR/(r2_1*rp);
......@@ -203,7 +183,7 @@ static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions
}
static void computeAmoebaAngleForces(Context& context, AmoebaAngleForce& AmoebaAngleForce,
std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log) {
std::vector<Vec3>& expectedForces, double* expectedEnergy) {
// get positions and zero forces
......@@ -219,50 +199,27 @@ static void computeAmoebaAngleForces(Context& context, AmoebaAngleForce& AmoebaA
*expectedEnergy = 0.0;
for (int ii = 0; ii < AmoebaAngleForce.getNumAngles(); ii++) {
computeAmoebaAngleForce(ii, positions, AmoebaAngleForce, expectedForces, expectedEnergy, log);
}
#ifdef AMOEBA_DEBUG
if (log) {
(void) fprintf(log, "computeAmoebaAngleForces: expected energy=%14.7e\n", *expectedEnergy);
for (unsigned int ii = 0; ii < positions.size(); ii++) {
(void) fprintf(log, "%6u [%14.7e %14.7e %14.7e]\n", ii, expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2]);
}
(void) fflush(log);
computeAmoebaAngleForce(ii, positions, AmoebaAngleForce, expectedForces, expectedEnergy);
}
#endif
return;
}
void compareWithExpectedForceAndEnergy(Context& context, AmoebaAngleForce& AmoebaAngleForce,
double tolerance, const std::string& idString, FILE* log) {
double tolerance, const std::string& idString) {
std::vector<Vec3> expectedForces;
double expectedEnergy;
computeAmoebaAngleForces(context, AmoebaAngleForce, expectedForces, &expectedEnergy, log);
computeAmoebaAngleForces(context, AmoebaAngleForce, expectedForces, &expectedEnergy);
State state = context.getState(State::Forces | State::Energy);
const std::vector<Vec3> forces = state.getForces();
#ifdef AMOEBA_DEBUG
if (log) {
(void) fprintf(log, "computeAmoebaAngleForces: expected energy=%14.7e %14.7e\n", expectedEnergy, state.getPotentialEnergy());
for (unsigned int ii = 0; ii < forces.size(); ii++) {
(void) fprintf(log, "%6u [%14.7e %14.7e %14.7e] [%14.7e %14.7e %14.7e]\n", ii,
expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2], forces[ii][0], forces[ii][1], forces[ii][2]);
}
(void) fflush(log);
}
#endif
for (unsigned int ii = 0; ii < forces.size(); ii++) {
ASSERT_EQUAL_VEC(expectedForces[ii], forces[ii], tolerance);
}
ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance);
}
void testOneAngle(FILE* log) {
void testOneAngle() {
System system;
int numberOfParticles = 3;
......@@ -299,7 +256,7 @@ void testOneAngle(FILE* log) {
positions[2] = Vec3(0, 0, 1);
context.setPositions(positions);
compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle", log);
compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle");
// Try changing the angle parameters and make sure it's still correct.
......@@ -307,14 +264,14 @@ void testOneAngle(FILE* log) {
bool exceptionThrown = false;
try {
// This should throw an exception.
compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle", log);
compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle");
}
catch (std::exception ex) {
exceptionThrown = true;
}
ASSERT(exceptionThrown);
amoebaAngleForce->updateParametersInContext(context);
compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle", log);
compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle");
}
int main(int numberOfArguments, char* argv[]) {
......@@ -322,16 +279,7 @@ int main(int numberOfArguments, char* argv[]) {
try {
std::cout << "TestCudaAmoebaAngleForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories();
//FILE* log = fopen("AmoebaAngleForce.log", "w");;
FILE* log = NULL;
//FILE* log = stderr;
testOneAngle(log);
#ifdef AMOEBA_DEBUG
if (log && log != stderr)
(void) fclose(log);
#endif
testOneAngle();
}
catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
......
......@@ -85,7 +85,7 @@ static void computeAmoebaBondForce(int bondIndex, std::vector<Vec3>& positions,
}
static void computeAmoebaBondForces(Context& context, AmoebaBondForce& AmoebaBondForce,
std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log) {
std::vector<Vec3>& expectedForces, double* expectedEnergy) {
// get positions and zero forces
......@@ -103,37 +103,16 @@ static void computeAmoebaBondForces(Context& context, AmoebaBondForce& AmoebaBon
for (int ii = 0; ii < AmoebaBondForce.getNumBonds(); ii++) {
computeAmoebaBondForce(ii, positions, AmoebaBondForce, expectedForces, expectedEnergy);
}
#ifdef AMOEBA_DEBUG
if (log) {
(void) fprintf(log, "computeAmoebaBondForces: expected energy=%15.7e\n", *expectedEnergy);
for (unsigned int ii = 0; ii < positions.size(); ii++) {
(void) fprintf(log, "%6u [%15.7e %15.7e %15.7e]\n", ii, expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2]);
}
(void) fflush(log);
}
#endif
return;
}
void compareWithExpectedForceAndEnergy(Context& context, AmoebaBondForce& AmoebaBondForce, double tolerance, const std::string& idString, FILE* log) {
void compareWithExpectedForceAndEnergy(Context& context, AmoebaBondForce& AmoebaBondForce, double tolerance, const std::string& idString) {
std::vector<Vec3> expectedForces;
double expectedEnergy;
computeAmoebaBondForces(context, AmoebaBondForce, expectedForces, &expectedEnergy, NULL);
computeAmoebaBondForces(context, AmoebaBondForce, expectedForces, &expectedEnergy);
State state = context.getState(State::Forces | State::Energy);
const std::vector<Vec3> forces = state.getForces();
#ifdef AMOEBA_DEBUG
if (log) {
(void) fprintf(log, "computeAmoebaBondForces: expected energy=%15.7e %15.7e\n", expectedEnergy, state.getPotentialEnergy());
for (unsigned int ii = 0; ii < forces.size(); ii++) {
(void) fprintf(log, "%6u [%15.7e %15.7e %15.7e] [%15.7e %15.7e %15.7e]\n", ii,
expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2], forces[ii][0], forces[ii][1], forces[ii][2]);
}
(void) fflush(log);
}
#endif
for (unsigned int ii = 0; ii < forces.size(); ii++) {
ASSERT_EQUAL_VEC(expectedForces[ii], forces[ii], tolerance);
......@@ -141,7 +120,7 @@ void compareWithExpectedForceAndEnergy(Context& context, AmoebaBondForce& Amoeba
ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance);
}
void testOneBond(FILE* log) {
void testOneBond() {
System system;
......@@ -168,10 +147,10 @@ void testOneBond(FILE* log) {
positions[1] = Vec3(0, 0, 0);
context.setPositions(positions);
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testOneBond", log);
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testOneBond");
}
void testTwoBond(FILE* log) {
void testTwoBond() {
System system;
......@@ -203,7 +182,7 @@ void testTwoBond(FILE* log) {
positions[2] = Vec3(1, 0, 1);
context.setPositions(positions);
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond", log);
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond");
// Try changing the bond parameters and make sure it's still correct.
......@@ -212,14 +191,14 @@ void testTwoBond(FILE* log) {
bool exceptionThrown = false;
try {
// This should throw an exception.
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond", log);
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond");
}
catch (std::exception ex) {
exceptionThrown = true;
}
ASSERT(exceptionThrown);
amoebaBondForce->updateParametersInContext(context);
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond", log);
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond");
}
int main(int numberOfArguments, char* argv[]) {
......@@ -227,16 +206,8 @@ int main(int numberOfArguments, char* argv[]) {
try {
std::cout << "TestReferenceAmoebaBondForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories();
FILE* log = NULL;
//FILE* log = stderr;
//testOneBond(log);
testTwoBond(log);
#ifdef AMOEBA_DEBUG
if (log && log != stderr)
(void) fclose(log);
#endif
//testOneBond();
testTwoBond();
}
catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
......
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