Commit 41cd79a5 authored by peastman's avatar peastman
Browse files

Cleaned up formatting of AMOEBA reference code

parent 25a308e6
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferenceTorsionTorsionForce( ){}; AmoebaReferenceTorsionTorsionForce() {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
~AmoebaReferenceTorsionTorsionForce( ){}; ~AmoebaReferenceTorsionTorsionForce() {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy( int numTorsionTorsions, std::vector<OpenMM::RealVec>& posData, RealOpenMM calculateForceAndEnergy(int numTorsionTorsions, std::vector<OpenMM::RealVec>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
const std::vector<int>& chiralCheckAtom, const std::vector<int>& chiralCheckAtom,
const std::vector<int>& gridIndices, const std::vector<int>& gridIndices,
const std::vector< std::vector< std::vector< std::vector<RealOpenMM> > > >& torsionTorsionGrids, const std::vector< std::vector< std::vector< std::vector<RealOpenMM> > > >& torsionTorsionGrids,
std::vector<OpenMM::RealVec>& forceData ) const; std::vector<OpenMM::RealVec>& forceData) const;
private: private:
...@@ -105,7 +105,7 @@ private: ...@@ -105,7 +105,7 @@ private:
void loadGridValuesFromEnclosingRectangle( void loadGridValuesFromEnclosingRectangle(
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid, const std::vector< std::vector< std::vector<RealOpenMM> > >& grid,
RealOpenMM angle1, RealOpenMM angle2, RealOpenMM corners[2][2], RealOpenMM angle1, RealOpenMM angle2, RealOpenMM corners[2][2],
RealOpenMM* fValues, RealOpenMM* fValues1, RealOpenMM* fValues2, RealOpenMM* fValues12 ) const; RealOpenMM* fValues, RealOpenMM* fValues1, RealOpenMM* fValues2, RealOpenMM* fValues12) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -128,8 +128,8 @@ private: ...@@ -128,8 +128,8 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void getBicubicCoefficientMatrix( const RealOpenMM* y, const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12, void getBicubicCoefficientMatrix(const RealOpenMM* y, const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12,
const RealOpenMM d1, const RealOpenMM d2, RealOpenMM c[4][4] ) const; const RealOpenMM d1, const RealOpenMM d2, RealOpenMM c[4][4]) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -167,7 +167,7 @@ private: ...@@ -167,7 +167,7 @@ private:
const RealOpenMM x1Lower, const RealOpenMM x1Upper, const RealOpenMM x1Lower, const RealOpenMM x1Upper,
const RealOpenMM x2Lower, const RealOpenMM x2Upper, const RealOpenMM x2Lower, const RealOpenMM x2Upper,
const RealOpenMM gridValue1, const RealOpenMM gridValue2, const RealOpenMM gridValue1, const RealOpenMM gridValue2,
RealOpenMM* functionValue, RealOpenMM* functionValue1, RealOpenMM* functionValue2 ) const; RealOpenMM* functionValue, RealOpenMM* functionValue1, RealOpenMM* functionValue2) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -183,8 +183,8 @@ private: ...@@ -183,8 +183,8 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int checkTorsionSign( const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, int checkTorsionSign(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD ) const; const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -204,11 +204,11 @@ private: ...@@ -204,11 +204,11 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateTorsionTorsionIxn( const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, RealOpenMM calculateTorsionTorsionIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD, const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD,
const OpenMM::RealVec& positionAtomE, const OpenMM::RealVec* chiralCheckAtom, const OpenMM::RealVec& positionAtomE, const OpenMM::RealVec* chiralCheckAtom,
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid, const std::vector< std::vector< std::vector<RealOpenMM> > >& grid,
OpenMM::RealVec* forces ) const; OpenMM::RealVec* forces) const;
}; };
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
namespace OpenMM { namespace OpenMM {
class AmoebaReferenceVdwForce; class AmoebaReferenceVdwForce;
typedef RealOpenMM (AmoebaReferenceVdwForce::*CombiningFunction)( RealOpenMM x, RealOpenMM y) const; typedef RealOpenMM (AmoebaReferenceVdwForce::*CombiningFunction)(RealOpenMM x, RealOpenMM y) const;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferenceVdwForce( ); AmoebaReferenceVdwForce();
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -79,8 +79,8 @@ public: ...@@ -79,8 +79,8 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferenceVdwForce( const std::string& sigmaCombiningRule, AmoebaReferenceVdwForce(const std::string& sigmaCombiningRule,
const std::string& epsilonCombiningRule ); const std::string& epsilonCombiningRule);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
~AmoebaReferenceVdwForce( ){}; ~AmoebaReferenceVdwForce() {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -98,7 +98,7 @@ public: ...@@ -98,7 +98,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
NonbondedMethod getNonbondedMethod( void ) const; NonbondedMethod getNonbondedMethod() const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -108,7 +108,7 @@ public: ...@@ -108,7 +108,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setNonbondedMethod( NonbondedMethod nonbondedMethod ); void setNonbondedMethod(NonbondedMethod nonbondedMethod);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -118,7 +118,7 @@ public: ...@@ -118,7 +118,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
double getCutoff( void ) const; double getCutoff() const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -128,7 +128,7 @@ public: ...@@ -128,7 +128,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setCutoff( double cutoff ); void setCutoff(double cutoff);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -138,7 +138,7 @@ public: ...@@ -138,7 +138,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setSigmaCombiningRule( const std::string& sigmaCombiningRule ); void setSigmaCombiningRule(const std::string& sigmaCombiningRule);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -148,7 +148,7 @@ public: ...@@ -148,7 +148,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
std::string getSigmaCombiningRule( void ) const; std::string getSigmaCombiningRule() const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -158,7 +158,7 @@ public: ...@@ -158,7 +158,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setEpsilonCombiningRule( const std::string& epsilonCombiningRule ); void setEpsilonCombiningRule(const std::string& epsilonCombiningRule);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -168,7 +168,7 @@ public: ...@@ -168,7 +168,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
std::string getEpsilonCombiningRule( void ) const; std::string getEpsilonCombiningRule() const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -197,12 +197,12 @@ public: ...@@ -197,12 +197,12 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy( int numParticles, const std::vector<OpenMM::RealVec>& particlePositions, RealOpenMM calculateForceAndEnergy(int numParticles, const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<int>& indexIVs, const std::vector<int>& indexIVs,
const std::vector<RealOpenMM>& sigmas, const std::vector<RealOpenMM>& epsilons, const std::vector<RealOpenMM>& sigmas, const std::vector<RealOpenMM>& epsilons,
const std::vector<RealOpenMM>& reductions, const std::vector<RealOpenMM>& reductions,
const std::vector< std::set<int> >& vdwExclusions, const std::vector< std::set<int> >& vdwExclusions,
std::vector<OpenMM::RealVec>& forces ) const; std::vector<OpenMM::RealVec>& forces) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -221,12 +221,12 @@ public: ...@@ -221,12 +221,12 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy( int numParticles, const std::vector<OpenMM::RealVec>& particlePositions, RealOpenMM calculateForceAndEnergy(int numParticles, const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<int>& indexIVs, const std::vector<int>& indexIVs,
const std::vector<RealOpenMM>& sigmas, const std::vector<RealOpenMM>& epsilons, const std::vector<RealOpenMM>& sigmas, const std::vector<RealOpenMM>& epsilons,
const std::vector<RealOpenMM>& reductions, const std::vector<RealOpenMM>& reductions,
const NeighborList& neighborList, const NeighborList& neighborList,
std::vector<OpenMM::RealVec>& forces ) const; std::vector<OpenMM::RealVec>& forces) const;
private: private:
...@@ -245,15 +245,15 @@ private: ...@@ -245,15 +245,15 @@ private:
RealOpenMM _taperCoefficients[3]; RealOpenMM _taperCoefficients[3];
RealVec _periodicBoxVectors[3]; RealVec _periodicBoxVectors[3];
CombiningFunction _combineSigmas; CombiningFunction _combineSigmas;
RealOpenMM arithmeticSigmaCombiningRule( RealOpenMM sigmaI, RealOpenMM sigmaJ ) const; RealOpenMM arithmeticSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const;
RealOpenMM geometricSigmaCombiningRule( RealOpenMM sigmaI, RealOpenMM sigmaJ ) const; RealOpenMM geometricSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const;
RealOpenMM cubicMeanSigmaCombiningRule( RealOpenMM sigmaI, RealOpenMM sigmaJ ) const; RealOpenMM cubicMeanSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const;
CombiningFunction _combineEpsilons; CombiningFunction _combineEpsilons;
RealOpenMM arithmeticEpsilonCombiningRule( RealOpenMM epsilonI, RealOpenMM epsilonJ ) const; RealOpenMM arithmeticEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
RealOpenMM geometricEpsilonCombiningRule( RealOpenMM epsilonI, RealOpenMM epsilonJ ) const; RealOpenMM geometricEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
RealOpenMM harmonicEpsilonCombiningRule( RealOpenMM epsilonI, RealOpenMM epsilonJ ) const; RealOpenMM harmonicEpsilonCombiningRule( RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
RealOpenMM hhgEpsilonCombiningRule( RealOpenMM epsilonI, RealOpenMM epsilonJ ) const; RealOpenMM hhgEpsilonCombiningRule( RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -272,9 +272,9 @@ private: ...@@ -272,9 +272,9 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setReducedPositions( int numParticles, const std::vector<RealVec>& particlePositions, void setReducedPositions(int numParticles, const std::vector<RealVec>& particlePositions,
const std::vector<int>& indexIVs, const std::vector<RealOpenMM>& reductions, const std::vector<int>& indexIVs, const std::vector<RealOpenMM>& reductions,
std::vector<Vec3>& reducedPositions ) const; std::vector<Vec3>& reducedPositions) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -289,9 +289,9 @@ private: ...@@ -289,9 +289,9 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void addReducedForce( unsigned int particleI, unsigned int particleIV, void addReducedForce(unsigned int particleI, unsigned int particleIV,
RealOpenMM reduction, RealOpenMM sign, RealOpenMM reduction, RealOpenMM sign,
Vec3& force, std::vector<OpenMM::RealVec>& forces ) const; Vec3& force, std::vector<OpenMM::RealVec>& forces) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -301,7 +301,7 @@ private: ...@@ -301,7 +301,7 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setTaperCoefficients( double cutoff ); void setTaperCoefficients(double cutoff);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -317,9 +317,9 @@ private: ...@@ -317,9 +317,9 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculatePairIxn( RealOpenMM combindedSigma, RealOpenMM combindedEpsilon, RealOpenMM calculatePairIxn(RealOpenMM combindedSigma, RealOpenMM combindedEpsilon,
const Vec3& particleIPosition, const Vec3& particleJPosition, const Vec3& particleIPosition, const Vec3& particleJPosition,
Vec3& force ) const; Vec3& force) const;
}; };
......
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
AmoebaReferenceWcaDispersionForce::AmoebaReferenceWcaDispersionForce( RealOpenMM epso, RealOpenMM epsh, RealOpenMM rmino, RealOpenMM rminh, AmoebaReferenceWcaDispersionForce::AmoebaReferenceWcaDispersionForce(RealOpenMM epso, RealOpenMM epsh, RealOpenMM rmino, RealOpenMM rminh,
RealOpenMM awater, RealOpenMM shctd, RealOpenMM dispoff, RealOpenMM slevy ) : RealOpenMM awater, RealOpenMM shctd, RealOpenMM dispoff, RealOpenMM slevy) :
_epso(epso), _epsh(epsh), _rmino(rmino), _rminh(rminh), _awater(awater), _shctd(shctd), _dispoff(dispoff), _slevy(slevy) { _epso(epso), _epsh(epsh), _rmino(rmino), _rminh(rminh), _awater(awater), _shctd(shctd), _dispoff(dispoff), _slevy(slevy) {
} }
RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiusI, RealOpenMM radiusK, RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn(RealOpenMM radiusI, RealOpenMM radiusK,
const RealVec& particleIPosition, const RealVec& particleIPosition,
const RealVec& particleJPosition, const RealVec& particleJPosition,
const RealOpenMM* const intermediateValues, const RealOpenMM* const intermediateValues,
Vec3& force ) const { Vec3& force) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -62,7 +62,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -62,7 +62,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM zr = particleIPosition[2] - particleJPosition[2]; RealOpenMM zr = particleIPosition[2] - particleJPosition[2];
RealOpenMM r2 = xr*xr + yr*yr + zr*zr; RealOpenMM r2 = xr*xr + yr*yr + zr*zr;
RealOpenMM r = SQRT( r2 ); RealOpenMM r = SQRT(r2);
RealOpenMM r3 = r2*r; RealOpenMM r3 = r2*r;
RealOpenMM sK = radiusK*_shctd; RealOpenMM sK = radiusK*_shctd;
...@@ -84,7 +84,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -84,7 +84,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM sum = zero; RealOpenMM sum = zero;
RealOpenMM de = zero; RealOpenMM de = zero;
if( radiusI < (r + sK) ){ if (radiusI < (r + sK)) {
RealOpenMM rmax = (radiusI > (r - sK)) ? radiusI : (r - sK); RealOpenMM rmax = (radiusI > (r - sK)) ? radiusI : (r - sK);
...@@ -93,7 +93,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -93,7 +93,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM lik3 = lik2*lik; RealOpenMM lik3 = lik2*lik;
RealOpenMM lik4 = lik2*lik2; RealOpenMM lik4 = lik2*lik2;
if( lik < rmixo ){ if (lik < rmixo) {
RealOpenMM uik = (r + sK) < rmixo ? (r + sK) : rmixo; RealOpenMM uik = (r + sK) < rmixo ? (r + sK) : rmixo;
RealOpenMM uik2 = uik*uik; RealOpenMM uik2 = uik*uik;
...@@ -103,7 +103,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -103,7 +103,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM term = four*PI/(fortyEight*r)* (three*(lik4-uik4) - eight*r*(lik3-uik3) + six*(r2-sK2)*(lik2-uik2)); RealOpenMM term = four*PI/(fortyEight*r)* (three*(lik4-uik4) - eight*r*(lik3-uik3) + six*(r2-sK2)*(lik2-uik2));
RealOpenMM dl; RealOpenMM dl;
if( radiusI > (r - sK) ){ if (radiusI > (r - sK)) {
dl = -lik2 + two*(r2 + sK2); dl = -lik2 + two*(r2 + sK2);
dl *= lik2; dl *= lik2;
} else { } else {
...@@ -112,7 +112,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -112,7 +112,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
} }
RealOpenMM du; RealOpenMM du;
if( (r+sK) > rmixo ){ if ((r+sK) > rmixo) {
du = -uik2 + two*(r2 + sK2); du = -uik2 + two*(r2 + sK2);
du *= -uik2; du *= -uik2;
} else { } else {
...@@ -123,7 +123,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -123,7 +123,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
sum += -emixo*term; sum += -emixo*term;
} }
if( lik < rmixh ){ if (lik < rmixh) {
RealOpenMM uik = (r + sK) < rmixh ? (r + sK) : rmixh; RealOpenMM uik = (r + sK) < rmixh ? (r + sK) : rmixh;
RealOpenMM uik2 = uik*uik; RealOpenMM uik2 = uik*uik;
...@@ -131,7 +131,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -131,7 +131,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM uik4 = uik2*uik2; RealOpenMM uik4 = uik2*uik2;
RealOpenMM term = four*PI / (fortyEight*r)*(three*(lik4-uik4) - eight*r*(lik3-uik3) + six*(r2-sK2)*(lik2-uik2)); RealOpenMM term = four*PI / (fortyEight*r)*(three*(lik4-uik4) - eight*r*(lik3-uik3) + six*(r2-sK2)*(lik2-uik2));
RealOpenMM dl; RealOpenMM dl;
if( radiusI > (r-sK) ){ if (radiusI > (r-sK)) {
dl = -lik2 + two*(r2 + sK2); dl = -lik2 + two*(r2 + sK2);
dl *= lik2; dl *= lik2;
} else { } else {
...@@ -140,7 +140,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -140,7 +140,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
} }
RealOpenMM du; RealOpenMM du;
if (r+sK > rmixh){ if (r+sK > rmixh) {
du = -uik2 + two*(r2 + sK2); du = -uik2 + two*(r2 + sK2);
du *= -uik2; du *= -uik2;
} else { } else {
...@@ -162,7 +162,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -162,7 +162,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM uik12 = uik6 * uik6; RealOpenMM uik12 = uik6 * uik6;
RealOpenMM uik13 = uik10 * uik3; RealOpenMM uik13 = uik10 * uik3;
if( uik > rmixo ){ if (uik > rmixo) {
RealOpenMM lik = rmax > rmixo ? rmax : rmixo; RealOpenMM lik = rmax > rmixo ? rmax : rmixo;
RealOpenMM lik2 = lik * lik; RealOpenMM lik2 = lik * lik;
...@@ -177,7 +177,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -177,7 +177,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM term = four*PI/(120.0*r*lik5*uik5)*(15.0*uik*lik*r*(uik4-lik4) - ten*uik2*lik2*(uik3-lik3) + six*(sK2-r2)*(uik5-lik5)); RealOpenMM term = four*PI/(120.0*r*lik5*uik5)*(15.0*uik*lik*r*(uik4-lik4) - ten*uik2*lik2*(uik3-lik3) + six*(sK2-r2)*(uik5-lik5));
RealOpenMM dl; RealOpenMM dl;
if( radiusI > (r-sK) || rmax < rmixo ){ if (radiusI > (r-sK) || rmax < rmixo) {
dl = -five*lik2 + three*(r2 + sK2); dl = -five*lik2 + three*(r2 + sK2);
dl /= -lik5; dl /= -lik5;
} else { } else {
...@@ -189,7 +189,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -189,7 +189,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM idisp = -two*ao*term; RealOpenMM idisp = -two*ao*term;
de -= two*ao*PI*(dl + du)/(15.0*r2); de -= two*ao*PI*(dl + du)/(15.0*r2);
term = four*PI/(2640.0*r*lik12*uik12) * (120.0*uik*lik*r*(uik11-lik11) - 66.0*uik2*lik2*(uik10-lik10) + 55.0*(sK2-r2)*(uik12-lik12)); term = four*PI/(2640.0*r*lik12*uik12) * (120.0*uik*lik*r*(uik11-lik11) - 66.0*uik2*lik2*(uik10-lik10) + 55.0*(sK2-r2)*(uik12-lik12));
if( radiusI > (r-sK) || rmax < rmixo ){ if (radiusI > (r-sK) || rmax < rmixo) {
dl = -six*lik2 + five*r2 + five*sK2; dl = -six*lik2 + five*r2 + five*sK2;
dl /= -lik12; dl /= -lik12;
} else { } else {
...@@ -201,7 +201,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -201,7 +201,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
de += ao*rmixo7*PI*(dl + du)/(60.0*r2); de += ao*rmixo7*PI*(dl + du)/(60.0*r2);
sum += ao*rmixo7*term + idisp; sum += ao*rmixo7*term + idisp;
} }
if (uik > rmixh){ if (uik > rmixh) {
lik = rmax > rmixh ? rmax : rmixh; lik = rmax > rmixh ? rmax : rmixh;
lik2 = lik * lik; lik2 = lik * lik;
lik3 = lik2 * lik; lik3 = lik2 * lik;
...@@ -215,7 +215,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -215,7 +215,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM term = four*PI / (120.0*r*lik5*uik5)*(15.0*uik*lik*r*(uik4-lik4) - ten*uik2*lik2*(uik3-lik3) + six*(sK2-r2)*(uik5-lik5)); RealOpenMM term = four*PI / (120.0*r*lik5*uik5)*(15.0*uik*lik*r*(uik4-lik4) - ten*uik2*lik2*(uik3-lik3) + six*(sK2-r2)*(uik5-lik5));
RealOpenMM dl; RealOpenMM dl;
if( radiusI > (r-sK) || rmax < rmixh ){ if (radiusI > (r-sK) || rmax < rmixh) {
dl = -five*lik2 + three*(r2 + sK2); dl = -five*lik2 + three*(r2 + sK2);
dl /= -lik5; dl /= -lik5;
} else { } else {
...@@ -227,7 +227,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -227,7 +227,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
RealOpenMM idisp = -four*ah*term; RealOpenMM idisp = -four*ah*term;
de = de - four*ah*PI*(dl + du)/(15.0*r2); de = de - four*ah*PI*(dl + du)/(15.0*r2);
term = four*PI / (2640.0*r*lik12*uik12)* (120.0*uik*lik*r*(uik11-lik11)- 66.0*uik2*lik2*(uik10-lik10)+ 55.0*(sK2-r2)*(uik12-lik12)); term = four*PI / (2640.0*r*lik12*uik12)* (120.0*uik*lik*r*(uik11-lik11)- 66.0*uik2*lik2*(uik10-lik10)+ 55.0*(sK2-r2)*(uik12-lik12));
if( radiusI > (r-sK) || rmax < rmixh){ if (radiusI > (r-sK) || rmax < rmixh) {
dl = -six*lik2 + five*r2 + five*sK2; dl = -six*lik2 + five*r2 + five*sK2;
dl = -dl / lik12; dl = -dl / lik12;
} else {; } else {;
...@@ -254,12 +254,12 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu ...@@ -254,12 +254,12 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn( RealOpenMM radiu
} }
RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy( int numParticles, RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy(int numParticles,
const vector<RealVec>& particlePositions, const vector<RealVec>& particlePositions,
const std::vector<RealOpenMM>& radii, const std::vector<RealOpenMM>& radii,
const std::vector<RealOpenMM>& epsilons, const std::vector<RealOpenMM>& epsilons,
RealOpenMM totalMaximumDispersionEnergy, RealOpenMM totalMaximumDispersionEnergy,
vector<RealVec>& forces ) const { vector<RealVec>& forces) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -284,7 +284,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy( int numPa ...@@ -284,7 +284,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy( int numPa
RealOpenMM intermediateValues[LastIntermediateValueIndex]; RealOpenMM intermediateValues[LastIntermediateValueIndex];
for( unsigned int ii = 0; ii < static_cast<unsigned int>(numParticles); ii++ ){ for (unsigned int ii = 0; ii < static_cast<unsigned int>(numParticles); ii++) {
RealOpenMM epsi = epsilons[ii]; RealOpenMM epsi = epsilons[ii];
RealOpenMM rmini = radii[ii]; RealOpenMM rmini = radii[ii];
...@@ -296,7 +296,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy( int numPa ...@@ -296,7 +296,7 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy( int numPa
RealOpenMM rminI2 = rmini*rmini; RealOpenMM rminI2 = rmini*rmini;
RealOpenMM rminI3 = rminI2*rmini; RealOpenMM rminI3 = rminI2*rmini;
RealOpenMM rmixo = two*(rmino3 + rminI3 ) / (rmino2 + rminI2); RealOpenMM rmixo = two*(rmino3 + rminI3) / (rmino2 + rminI2);
intermediateValues[RMIXO] = rmixo; intermediateValues[RMIXO] = rmixo;
RealOpenMM rmixo7 = rmixo*rmixo*rmixo; RealOpenMM rmixo7 = rmixo*rmixo*rmixo;
...@@ -319,14 +319,14 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy( int numPa ...@@ -319,14 +319,14 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy( int numPa
intermediateValues[AH] = emixh*rmixh7; intermediateValues[AH] = emixh*rmixh7;
for( unsigned int jj = 0; jj < static_cast<unsigned int>(numParticles); jj++ ){ for (unsigned int jj = 0; jj < static_cast<unsigned int>(numParticles); jj++) {
if( ii == jj )continue; if (ii == jj)continue;
Vec3 force; Vec3 force;
energy += calculatePairIxn( rmini, radii[jj], energy += calculatePairIxn(rmini, radii[jj],
particlePositions[ii], particlePositions[jj], particlePositions[ii], particlePositions[jj],
intermediateValues, force ); intermediateValues, force);
forces[ii][0] += force[0]; forces[ii][0] += force[0];
forces[ii][1] += force[1]; forces[ii][1] += force[1];
......
...@@ -51,8 +51,8 @@ public: ...@@ -51,8 +51,8 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferenceWcaDispersionForce( RealOpenMM epso, RealOpenMM epsh, RealOpenMM rmino, RealOpenMM rminh, AmoebaReferenceWcaDispersionForce(RealOpenMM epso, RealOpenMM epsh, RealOpenMM rmino, RealOpenMM rminh,
RealOpenMM awater, RealOpenMM shctd, RealOpenMM dispoff, RealOpenMM slevy ); RealOpenMM awater, RealOpenMM shctd, RealOpenMM dispoff, RealOpenMM slevy);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
~AmoebaReferenceWcaDispersionForce( ){}; ~AmoebaReferenceWcaDispersionForce() {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -77,10 +77,10 @@ public: ...@@ -77,10 +77,10 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy( int numParticles, const std::vector<OpenMM::RealVec>& particlePositions, RealOpenMM calculateForceAndEnergy(int numParticles, const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<RealOpenMM>& radii, const std::vector<RealOpenMM>& radii,
const std::vector<RealOpenMM>& epsilons, const std::vector<RealOpenMM>& epsilons,
RealOpenMM totalMaximumDispersionEnergy, std::vector<OpenMM::RealVec>& forces ) const; RealOpenMM totalMaximumDispersionEnergy, std::vector<OpenMM::RealVec>& forces) const;
private: private:
RealOpenMM _epso; RealOpenMM _epso;
...@@ -109,10 +109,10 @@ private: ...@@ -109,10 +109,10 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculatePairIxn( RealOpenMM radiusI, RealOpenMM radiusJ, RealOpenMM calculatePairIxn(RealOpenMM radiusI, RealOpenMM radiusJ,
const OpenMM::RealVec& particleIPosition, const OpenMM::RealVec& particleJPosition, const OpenMM::RealVec& particleIPosition, const OpenMM::RealVec& particleJPosition,
const RealOpenMM* const intermediateValues, const RealOpenMM* const intermediateValues,
Vec3& force ) const; Vec3& force) const;
}; };
......
...@@ -66,7 +66,7 @@ const double TOL = 1e-5; ...@@ -66,7 +66,7 @@ const double TOL = 1e-5;
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static void crossProductVector3( double* vectorX, double* vectorY, double* vectorZ ){ static void crossProductVector3(double* vectorX, double* vectorY, double* vectorZ) {
vectorZ[0] = vectorX[1]*vectorY[2] - vectorX[2]*vectorY[1]; vectorZ[0] = vectorX[1]*vectorY[2] - vectorX[2]*vectorY[1];
vectorZ[1] = vectorX[2]*vectorY[0] - vectorX[0]*vectorY[2]; vectorZ[1] = vectorX[2]*vectorY[0] - vectorX[0]*vectorY[2];
...@@ -75,24 +75,24 @@ static void crossProductVector3( double* vectorX, double* vectorY, double* vecto ...@@ -75,24 +75,24 @@ static void crossProductVector3( double* vectorX, double* vectorY, double* vecto
return; return;
} }
static void getPrefactorsGivenAngleCosine( double cosine, double idealAngle, double quadraticK, double cubicK, static void getPrefactorsGivenAngleCosine(double cosine, double idealAngle, double quadraticK, double cubicK,
double quarticK, double penticK, double sexticK, double quarticK, double penticK, double sexticK,
double* dEdR, double* energyTerm, FILE* log ) { double* dEdR, double* energyTerm, FILE* log) {
double angle; double angle;
if( cosine >= 1.0 ){ if (cosine >= 1.0) {
angle = 0.0f; angle = 0.0f;
} }
else if( cosine <= -1.0 ){ else if (cosine <= -1.0) {
angle = RADIAN*PI_M; angle = RADIAN*PI_M;
} }
else { else {
angle = RADIAN*acos(cosine); angle = RADIAN*acos(cosine);
} }
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "getPrefactorsGivenAngleCosine: cosine=%10.3e angle=%10.3e ideal=%10.3e\n", cosine, angle, idealAngle ); (void) fprintf(log, "getPrefactorsGivenAngleCosine: cosine=%10.3e angle=%10.3e ideal=%10.3e\n", cosine, angle, idealAngle);
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
...@@ -103,7 +103,7 @@ static void getPrefactorsGivenAngleCosine( double cosine, double idealAngle, dou ...@@ -103,7 +103,7 @@ static void getPrefactorsGivenAngleCosine( double cosine, double idealAngle, dou
// deltaIdeal = r - r_0 // deltaIdeal = r - r_0
*dEdR = ( 2.0 + *dEdR = (2.0 +
3.0*cubicK* deltaIdeal + 3.0*cubicK* deltaIdeal +
4.0*quarticK*deltaIdeal2 + 4.0*quarticK*deltaIdeal2 +
5.0*penticK* deltaIdeal3 + 5.0*penticK* deltaIdeal3 +
...@@ -122,29 +122,29 @@ static void getPrefactorsGivenAngleCosine( double cosine, double idealAngle, dou ...@@ -122,29 +122,29 @@ static void getPrefactorsGivenAngleCosine( double cosine, double idealAngle, dou
} }
static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions, AmoebaAngleForce& AmoebaAngleForce, 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, FILE* log) {
int particle1, particle2, particle3; int particle1, particle2, particle3;
double idealAngle; double idealAngle;
double quadraticK; double quadraticK;
AmoebaAngleForce.getAngleParameters(bondIndex, particle1, particle2, particle3, idealAngle, quadraticK ); AmoebaAngleForce.getAngleParameters(bondIndex, particle1, particle2, particle3, idealAngle, quadraticK);
double cubicK = AmoebaAngleForce.getAmoebaGlobalAngleCubic(); double cubicK = AmoebaAngleForce.getAmoebaGlobalAngleCubic();
double quarticK = AmoebaAngleForce.getAmoebaGlobalAngleQuartic(); double quarticK = AmoebaAngleForce.getAmoebaGlobalAngleQuartic();
double penticK = AmoebaAngleForce.getAmoebaGlobalAnglePentic(); double penticK = AmoebaAngleForce.getAmoebaGlobalAnglePentic();
double sexticK = AmoebaAngleForce.getAmoebaGlobalAngleSextic(); double sexticK = AmoebaAngleForce.getAmoebaGlobalAngleSextic();
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ 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", (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 ); bondIndex, particle1, particle2, particle3, idealAngle, quadraticK, cubicK, quarticK, penticK, sexticK);
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
double deltaR[2][3]; double deltaR[2][3];
double r2_0 = 0.0; double r2_0 = 0.0;
double r2_1 = 0.0; double r2_1 = 0.0;
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
deltaR[0][ii] = positions[particle1][ii] - positions[particle2][ii]; deltaR[0][ii] = positions[particle1][ii] - positions[particle2][ii];
r2_0 += deltaR[0][ii]*deltaR[0][ii]; r2_0 += deltaR[0][ii]*deltaR[0][ii];
...@@ -155,33 +155,33 @@ static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions ...@@ -155,33 +155,33 @@ static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions
} }
double pVector[3]; double pVector[3];
crossProductVector3( deltaR[0], deltaR[1], pVector ); crossProductVector3(deltaR[0], deltaR[1], pVector);
double rp = sqrt( pVector[0]*pVector[0] + pVector[1]*pVector[1] + pVector[2]*pVector[2] ); double rp = sqrt(pVector[0]*pVector[0] + pVector[1]*pVector[1] + pVector[2]*pVector[2]);
if( rp < 1.0e-06 ){ if (rp < 1.0e-06) {
rp = 1.0e-06; rp = 1.0e-06;
} }
double dot = deltaR[0][0]*deltaR[1][0] + deltaR[0][1]*deltaR[1][1] + deltaR[0][2]*deltaR[1][2]; 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); double cosine = dot/sqrt(r2_0*r2_1);
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "dot=%10.3e r2_0=%10.3e r2_1=%10.3e\n", dot, r2_0, r2_1 ); (void) fprintf(log, "dot=%10.3e r2_0=%10.3e r2_1=%10.3e\n", dot, r2_0, r2_1);
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
double dEdR; double dEdR;
double energyTerm; double energyTerm;
getPrefactorsGivenAngleCosine( cosine, idealAngle, quadraticK, cubicK, getPrefactorsGivenAngleCosine(cosine, idealAngle, quadraticK, cubicK,
quarticK, penticK, sexticK, &dEdR, &energyTerm, log ); quarticK, penticK, sexticK, &dEdR, &energyTerm, log);
double termA = -dEdR/(r2_0*rp); double termA = -dEdR/(r2_0*rp);
double termC = dEdR/(r2_1*rp); double termC = dEdR/(r2_1*rp);
double deltaCrossP[3][3]; double deltaCrossP[3][3];
crossProductVector3( deltaR[0], pVector, deltaCrossP[0] ); crossProductVector3(deltaR[0], pVector, deltaCrossP[0]);
crossProductVector3( deltaR[1], pVector, deltaCrossP[2] ); crossProductVector3(deltaR[1], pVector, deltaCrossP[2]);
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
deltaCrossP[0][ii] *= termA; deltaCrossP[0][ii] *= termA;
deltaCrossP[2][ii] *= termC; deltaCrossP[2][ii] *= termC;
deltaCrossP[1][ii] = -1.0*(deltaCrossP[0][ii] + deltaCrossP[2][ii]); deltaCrossP[1][ii] = -1.0*(deltaCrossP[0][ii] + deltaCrossP[2][ii]);
...@@ -202,71 +202,71 @@ static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions ...@@ -202,71 +202,71 @@ static void computeAmoebaAngleForce(int bondIndex, std::vector<Vec3>& positions
*energy += energyTerm; *energy += energyTerm;
} }
static void computeAmoebaAngleForces( Context& context, AmoebaAngleForce& AmoebaAngleForce, static void computeAmoebaAngleForces(Context& context, AmoebaAngleForce& AmoebaAngleForce,
std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log ) { std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log) {
// get positions and zero forces // get positions and zero forces
State state = context.getState(State::Positions); State state = context.getState(State::Positions);
std::vector<Vec3> positions = state.getPositions(); std::vector<Vec3> positions = state.getPositions();
expectedForces.resize( positions.size() ); expectedForces.resize(positions.size());
for( unsigned int ii = 0; ii < expectedForces.size(); ii++ ){ for (unsigned int ii = 0; ii < expectedForces.size(); ii++) {
expectedForces[ii][0] = expectedForces[ii][1] = expectedForces[ii][2] = 0.0; expectedForces[ii][0] = expectedForces[ii][1] = expectedForces[ii][2] = 0.0;
} }
// calculates forces/energy // calculates forces/energy
*expectedEnergy = 0.0; *expectedEnergy = 0.0;
for( int ii = 0; ii < AmoebaAngleForce.getNumAngles(); ii++ ){ for (int ii = 0; ii < AmoebaAngleForce.getNumAngles(); ii++) {
computeAmoebaAngleForce(ii, positions, AmoebaAngleForce, expectedForces, expectedEnergy, log ); computeAmoebaAngleForce(ii, positions, AmoebaAngleForce, expectedForces, expectedEnergy, log);
} }
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaAngleForces: expected energy=%14.7e\n", *expectedEnergy ); (void) fprintf(log, "computeAmoebaAngleForces: expected energy=%14.7e\n", *expectedEnergy);
for( unsigned int ii = 0; ii < positions.size(); ii++ ){ 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) fprintf(log, "%6u [%14.7e %14.7e %14.7e]\n", ii, expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2]);
} }
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
return; return;
} }
void compareWithExpectedForceAndEnergy( Context& context, AmoebaAngleForce& AmoebaAngleForce, void compareWithExpectedForceAndEnergy(Context& context, AmoebaAngleForce& AmoebaAngleForce,
double tolerance, const std::string& idString, FILE* log) { double tolerance, const std::string& idString, FILE* log) {
std::vector<Vec3> expectedForces; std::vector<Vec3> expectedForces;
double expectedEnergy; double expectedEnergy;
computeAmoebaAngleForces( context, AmoebaAngleForce, expectedForces, &expectedEnergy, log ); computeAmoebaAngleForces(context, AmoebaAngleForce, expectedForces, &expectedEnergy, log);
State state = context.getState(State::Forces | State::Energy); State state = context.getState(State::Forces | State::Energy);
const std::vector<Vec3> forces = state.getForces(); const std::vector<Vec3> forces = state.getForces();
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaAngleForces: expected energy=%14.7e %14.7e\n", expectedEnergy, state.getPotentialEnergy() ); (void) fprintf(log, "computeAmoebaAngleForces: expected energy=%14.7e %14.7e\n", expectedEnergy, state.getPotentialEnergy());
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ 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, (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] ); expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2], forces[ii][0], forces[ii][1], forces[ii][2]);
} }
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ for (unsigned int ii = 0; ii < forces.size(); ii++) {
ASSERT_EQUAL_VEC( expectedForces[ii], forces[ii], tolerance ); ASSERT_EQUAL_VEC(expectedForces[ii], forces[ii], tolerance);
} }
ASSERT_EQUAL_TOL( expectedEnergy, state.getPotentialEnergy(), tolerance ); ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance);
} }
void testOneAngle( FILE* log ) { void testOneAngle(FILE* log) {
System system; System system;
int numberOfParticles = 3; int numberOfParticles = 3;
for( int ii = 0; ii < numberOfParticles; ii++ ){ for (int ii = 0; ii < numberOfParticles; ii++) {
system.addParticle(1.0); system.addParticle(1.0);
} }
...@@ -290,7 +290,7 @@ void testOneAngle( FILE* log ) { ...@@ -290,7 +290,7 @@ void testOneAngle( FILE* log ) {
system.addForce(amoebaAngleForce); system.addForce(amoebaAngleForce);
ASSERT(!amoebaAngleForce->usesPeriodicBoundaryConditions()); ASSERT(!amoebaAngleForce->usesPeriodicBoundaryConditions());
ASSERT(!system.usesPeriodicBoundaryConditions()); ASSERT(!system.usesPeriodicBoundaryConditions());
Context context(system, integrator, Platform::getPlatformByName( "Reference")); Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numberOfParticles); std::vector<Vec3> positions(numberOfParticles);
...@@ -299,7 +299,7 @@ void testOneAngle( FILE* log ) { ...@@ -299,7 +299,7 @@ void testOneAngle( FILE* log ) {
positions[2] = Vec3(0, 0, 1); positions[2] = Vec3(0, 0, 1);
context.setPositions(positions); context.setPositions(positions);
compareWithExpectedForceAndEnergy( context, *amoebaAngleForce, TOL, "testOneAngle", log ); compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle", log);
// Try changing the angle parameters and make sure it's still correct. // Try changing the angle parameters and make sure it's still correct.
...@@ -307,29 +307,29 @@ void testOneAngle( FILE* log ) { ...@@ -307,29 +307,29 @@ void testOneAngle( FILE* log ) {
bool exceptionThrown = false; bool exceptionThrown = false;
try { try {
// This should throw an exception. // This should throw an exception.
compareWithExpectedForceAndEnergy( context, *amoebaAngleForce, TOL, "testOneAngle", log ); compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle", log);
} }
catch (std::exception ex) { catch (std::exception ex) {
exceptionThrown = true; exceptionThrown = true;
} }
ASSERT(exceptionThrown); ASSERT(exceptionThrown);
amoebaAngleForce->updateParametersInContext(context); amoebaAngleForce->updateParametersInContext(context);
compareWithExpectedForceAndEnergy( context, *amoebaAngleForce, TOL, "testOneAngle", log ); compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle", log);
} }
int main( int numberOfArguments, char* argv[] ) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestCudaAmoebaAngleForce running test..." << std::endl; std::cout << "TestCudaAmoebaAngleForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
//FILE* log = fopen( "AmoebaAngleForce.log", "w" );; //FILE* log = fopen("AmoebaAngleForce.log", "w");;
FILE* log = NULL; FILE* log = NULL;
//FILE* log = stderr; //FILE* log = stderr;
testOneAngle( log ); testOneAngle(log);
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log && log != stderr ) if (log && log != stderr)
(void) fclose( log ); (void) fclose(log);
#endif #endif
} }
......
...@@ -49,22 +49,22 @@ extern "C" OPENMM_EXPORT void registerAmoebaReferenceKernelFactories(); ...@@ -49,22 +49,22 @@ extern "C" OPENMM_EXPORT void registerAmoebaReferenceKernelFactories();
const double TOL = 1e-5; const double TOL = 1e-5;
static void computeAmoebaBondForce(int bondIndex, std::vector<Vec3>& positions, AmoebaBondForce& AmoebaBondForce, static void computeAmoebaBondForce(int bondIndex, std::vector<Vec3>& positions, AmoebaBondForce& AmoebaBondForce,
std::vector<Vec3>& forces, double* energy ) { std::vector<Vec3>& forces, double* energy) {
int particle1, particle2; int particle1, particle2;
double bondLength; double bondLength;
double quadraticK; double quadraticK;
double cubicK = AmoebaBondForce.getAmoebaGlobalBondCubic(); double cubicK = AmoebaBondForce.getAmoebaGlobalBondCubic();
double quarticK = AmoebaBondForce.getAmoebaGlobalBondQuartic(); double quarticK = AmoebaBondForce.getAmoebaGlobalBondQuartic();
AmoebaBondForce.getBondParameters(bondIndex, particle1, particle2, bondLength, quadraticK ); AmoebaBondForce.getBondParameters(bondIndex, particle1, particle2, bondLength, quadraticK);
double deltaR[3]; double deltaR[3];
double r2 = 0.0; double r2 = 0.0;
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
deltaR[ii] = positions[particle2][ii] - positions[particle1][ii]; deltaR[ii] = positions[particle2][ii] - positions[particle1][ii];
r2 += deltaR[ii]*deltaR[ii]; r2 += deltaR[ii]*deltaR[ii];
} }
double r = sqrt( r2 ); double r = sqrt(r2);
double bondDelta = (r - bondLength); double bondDelta = (r - bondLength);
double bondDelta2 = bondDelta*bondDelta; double bondDelta2 = bondDelta*bondDelta;
...@@ -84,64 +84,64 @@ static void computeAmoebaBondForce(int bondIndex, std::vector<Vec3>& positions, ...@@ -84,64 +84,64 @@ static void computeAmoebaBondForce(int bondIndex, std::vector<Vec3>& positions,
} }
static void computeAmoebaBondForces( Context& context, AmoebaBondForce& AmoebaBondForce, static void computeAmoebaBondForces(Context& context, AmoebaBondForce& AmoebaBondForce,
std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log ) { std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log) {
// get positions and zero forces // get positions and zero forces
State state = context.getState(State::Positions); State state = context.getState(State::Positions);
std::vector<Vec3> positions = state.getPositions(); std::vector<Vec3> positions = state.getPositions();
expectedForces.resize( positions.size() ); expectedForces.resize(positions.size());
for( unsigned int ii = 0; ii < expectedForces.size(); ii++ ){ for (unsigned int ii = 0; ii < expectedForces.size(); ii++) {
expectedForces[ii][0] = expectedForces[ii][1] = expectedForces[ii][2] = 0.0; expectedForces[ii][0] = expectedForces[ii][1] = expectedForces[ii][2] = 0.0;
} }
// calculates forces/energy // calculates forces/energy
*expectedEnergy = 0.0; *expectedEnergy = 0.0;
for( int ii = 0; ii < AmoebaBondForce.getNumBonds(); ii++ ){ for (int ii = 0; ii < AmoebaBondForce.getNumBonds(); ii++) {
computeAmoebaBondForce(ii, positions, AmoebaBondForce, expectedForces, expectedEnergy ); computeAmoebaBondForce(ii, positions, AmoebaBondForce, expectedForces, expectedEnergy);
} }
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaBondForces: expected energy=%15.7e\n", *expectedEnergy ); (void) fprintf(log, "computeAmoebaBondForces: expected energy=%15.7e\n", *expectedEnergy);
for( unsigned int ii = 0; ii < positions.size(); ii++ ){ 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) fprintf(log, "%6u [%15.7e %15.7e %15.7e]\n", ii, expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2]);
} }
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
return; 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, FILE* log) {
std::vector<Vec3> expectedForces; std::vector<Vec3> expectedForces;
double expectedEnergy; double expectedEnergy;
computeAmoebaBondForces( context, AmoebaBondForce, expectedForces, &expectedEnergy, NULL ); computeAmoebaBondForces(context, AmoebaBondForce, expectedForces, &expectedEnergy, NULL);
State state = context.getState(State::Forces | State::Energy); State state = context.getState(State::Forces | State::Energy);
const std::vector<Vec3> forces = state.getForces(); const std::vector<Vec3> forces = state.getForces();
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaBondForces: expected energy=%15.7e %15.7e\n", expectedEnergy, state.getPotentialEnergy() ); (void) fprintf(log, "computeAmoebaBondForces: expected energy=%15.7e %15.7e\n", expectedEnergy, state.getPotentialEnergy());
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ 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, (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] ); expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2], forces[ii][0], forces[ii][1], forces[ii][2]);
} }
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ for (unsigned int ii = 0; ii < forces.size(); ii++) {
ASSERT_EQUAL_VEC( expectedForces[ii], forces[ii], tolerance ); ASSERT_EQUAL_VEC(expectedForces[ii], forces[ii], tolerance);
} }
ASSERT_EQUAL_TOL( expectedEnergy, state.getPotentialEnergy(), tolerance ); ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance);
} }
void testOneBond( FILE* log ) { void testOneBond(FILE* log) {
System system; System system;
...@@ -156,22 +156,22 @@ void testOneBond( FILE* log ) { ...@@ -156,22 +156,22 @@ void testOneBond( FILE* log ) {
double quadraticK = 1.0; double quadraticK = 1.0;
double cubicK = 2.0; double cubicK = 2.0;
double quarticicK = 3.0; double quarticicK = 3.0;
amoebaBondForce->setAmoebaGlobalBondCubic( cubicK ); amoebaBondForce->setAmoebaGlobalBondCubic(cubicK);
amoebaBondForce->setAmoebaGlobalBondQuartic( quarticicK ); amoebaBondForce->setAmoebaGlobalBondQuartic(quarticicK);
amoebaBondForce->addBond(0, 1, bondLength, quadraticK); amoebaBondForce->addBond(0, 1, bondLength, quadraticK);
system.addForce(amoebaBondForce); system.addForce(amoebaBondForce);
Context context(system, integrator, Platform::getPlatformByName( "Reference")); Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(2); std::vector<Vec3> positions(2);
positions[0] = Vec3(0, 1, 0); positions[0] = Vec3(0, 1, 0);
positions[1] = Vec3(0, 0, 0); positions[1] = Vec3(0, 0, 0);
context.setPositions(positions); context.setPositions(positions);
compareWithExpectedForceAndEnergy( context, *amoebaBondForce, TOL, "testOneBond", log ); compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testOneBond", log);
} }
void testTwoBond( FILE* log ) { void testTwoBond(FILE* log) {
System system; System system;
...@@ -187,15 +187,15 @@ void testTwoBond( FILE* log ) { ...@@ -187,15 +187,15 @@ void testTwoBond( FILE* log ) {
double quadraticK = 1.0; double quadraticK = 1.0;
double cubicK = 2.0; double cubicK = 2.0;
double quarticicK = 3.0; double quarticicK = 3.0;
amoebaBondForce->setAmoebaGlobalBondCubic( cubicK ); amoebaBondForce->setAmoebaGlobalBondCubic(cubicK);
amoebaBondForce->setAmoebaGlobalBondQuartic( quarticicK ); amoebaBondForce->setAmoebaGlobalBondQuartic(quarticicK);
amoebaBondForce->addBond(0, 1, bondLength, quadraticK); amoebaBondForce->addBond(0, 1, bondLength, quadraticK);
amoebaBondForce->addBond(1, 2, bondLength, quadraticK); amoebaBondForce->addBond(1, 2, bondLength, quadraticK);
system.addForce(amoebaBondForce); system.addForce(amoebaBondForce);
ASSERT(!amoebaBondForce->usesPeriodicBoundaryConditions()); ASSERT(!amoebaBondForce->usesPeriodicBoundaryConditions());
ASSERT(!system.usesPeriodicBoundaryConditions()); ASSERT(!system.usesPeriodicBoundaryConditions());
Context context(system, integrator, Platform::getPlatformByName( "Reference")); Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(3); std::vector<Vec3> positions(3);
positions[0] = Vec3(0, 1, 0); positions[0] = Vec3(0, 1, 0);
...@@ -203,7 +203,7 @@ void testTwoBond( FILE* log ) { ...@@ -203,7 +203,7 @@ void testTwoBond( FILE* log ) {
positions[2] = Vec3(1, 0, 1); positions[2] = Vec3(1, 0, 1);
context.setPositions(positions); context.setPositions(positions);
compareWithExpectedForceAndEnergy( context, *amoebaBondForce, TOL, "testTwoBond", log ); compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond", log);
// Try changing the bond parameters and make sure it's still correct. // Try changing the bond parameters and make sure it's still correct.
...@@ -212,17 +212,17 @@ void testTwoBond( FILE* log ) { ...@@ -212,17 +212,17 @@ void testTwoBond( FILE* log ) {
bool exceptionThrown = false; bool exceptionThrown = false;
try { try {
// This should throw an exception. // This should throw an exception.
compareWithExpectedForceAndEnergy( context, *amoebaBondForce, TOL, "testTwoBond", log ); compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond", log);
} }
catch (std::exception ex) { catch (std::exception ex) {
exceptionThrown = true; exceptionThrown = true;
} }
ASSERT(exceptionThrown); ASSERT(exceptionThrown);
amoebaBondForce->updateParametersInContext(context); amoebaBondForce->updateParametersInContext(context);
compareWithExpectedForceAndEnergy( context, *amoebaBondForce, TOL, "testTwoBond", log ); compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond", log);
} }
int main( int numberOfArguments, char* argv[] ) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestReferenceAmoebaBondForce running test..." << std::endl; std::cout << "TestReferenceAmoebaBondForce running test..." << std::endl;
...@@ -230,11 +230,11 @@ int main( int numberOfArguments, char* argv[] ) { ...@@ -230,11 +230,11 @@ int main( int numberOfArguments, char* argv[] ) {
FILE* log = NULL; FILE* log = NULL;
//FILE* log = stderr; //FILE* log = stderr;
//testOneBond( log ); //testOneBond(log);
testTwoBond( log ); testTwoBond(log);
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log && log != stderr ) if (log && log != stderr)
(void) fclose( log ); (void) fclose(log);
#endif #endif
} }
......
...@@ -64,7 +64,7 @@ const double TOL = 1e-5; ...@@ -64,7 +64,7 @@ const double TOL = 1e-5;
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static void crossProductVector3( double* vectorX, double* vectorY, double* vectorZ ){ static void crossProductVector3(double* vectorX, double* vectorY, double* vectorZ) {
vectorZ[0] = vectorX[1]*vectorY[2] - vectorX[2]*vectorY[1]; vectorZ[0] = vectorX[1]*vectorY[2] - vectorX[2]*vectorY[1];
vectorZ[1] = vectorX[2]*vectorY[0] - vectorX[0]*vectorY[2]; vectorZ[1] = vectorX[2]*vectorY[0] - vectorX[0]*vectorY[2];
...@@ -73,28 +73,28 @@ static void crossProductVector3( double* vectorX, double* vectorY, double* vecto ...@@ -73,28 +73,28 @@ static void crossProductVector3( double* vectorX, double* vectorY, double* vecto
return; return;
} }
static double dotVector3( double* vectorX, double* vectorY ){ static double dotVector3(double* vectorX, double* vectorY) {
return vectorX[0]*vectorY[0] + vectorX[1]*vectorY[1] + vectorX[2]*vectorY[2]; return vectorX[0]*vectorY[0] + vectorX[1]*vectorY[1] + vectorX[2]*vectorY[2];
} }
static void getPrefactorsGivenInPlaneAngleCosine( double cosine, double idealInPlaneAngle, double quadraticK, double cubicK, static void getPrefactorsGivenInPlaneAngleCosine(double cosine, double idealInPlaneAngle, double quadraticK, double cubicK,
double quarticK, double penticK, double sexticK, double quarticK, double penticK, double sexticK,
double* dEdR, double* energyTerm, FILE* log ) { double* dEdR, double* energyTerm, FILE* log) {
double angle; double angle;
if( cosine >= 1.0 ){ if (cosine >= 1.0) {
angle = 0.0f; angle = 0.0f;
} }
else if( cosine <= -1.0 ){ else if (cosine <= -1.0) {
angle = RADIAN*PI_M; angle = RADIAN*PI_M;
} }
else { else {
angle = RADIAN*acos(cosine); angle = RADIAN*acos(cosine);
} }
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "getPrefactorsGivenInPlaneAngleCosine: cosine=%10.3e angle=%10.3e ideal=%10.3e\n", cosine, angle, idealInPlaneAngle ); (void) fprintf(log, "getPrefactorsGivenInPlaneAngleCosine: cosine=%10.3e angle=%10.3e ideal=%10.3e\n", cosine, angle, idealInPlaneAngle);
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
...@@ -105,7 +105,7 @@ static void getPrefactorsGivenInPlaneAngleCosine( double cosine, double idealInP ...@@ -105,7 +105,7 @@ static void getPrefactorsGivenInPlaneAngleCosine( double cosine, double idealInP
// deltaIdeal = r - r_0 // deltaIdeal = r - r_0
*dEdR = ( 2.0 + *dEdR = (2.0 +
3.0*cubicK* deltaIdeal + 3.0*cubicK* deltaIdeal +
4.0*quarticK*deltaIdeal2 + 4.0*quarticK*deltaIdeal2 +
5.0*penticK* deltaIdeal3 + 5.0*penticK* deltaIdeal3 +
...@@ -124,22 +124,22 @@ static void getPrefactorsGivenInPlaneAngleCosine( double cosine, double idealInP ...@@ -124,22 +124,22 @@ static void getPrefactorsGivenInPlaneAngleCosine( double cosine, double idealInP
} }
static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& positions, AmoebaInPlaneAngleForce& AmoebaInPlaneAngleForce, static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& positions, AmoebaInPlaneAngleForce& AmoebaInPlaneAngleForce,
std::vector<Vec3>& forces, double* energy, FILE* log ) { std::vector<Vec3>& forces, double* energy, FILE* log) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
double idealInPlaneAngle; double idealInPlaneAngle;
double quadraticK; double quadraticK;
AmoebaInPlaneAngleForce.getAngleParameters(bondIndex, particle1, particle2, particle3, particle4, idealInPlaneAngle, quadraticK ); AmoebaInPlaneAngleForce.getAngleParameters(bondIndex, particle1, particle2, particle3, particle4, idealInPlaneAngle, quadraticK);
double cubicK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAngleCubic(); double cubicK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAngleCubic();
double quarticK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAngleQuartic(); double quarticK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAngleQuartic();
double penticK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAnglePentic(); double penticK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAnglePentic();
double sexticK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAngleSextic(); double sexticK = AmoebaInPlaneAngleForce.getAmoebaGlobalInPlaneAngleSextic();
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaInPlaneAngleForce: bond %d [%d %d %d %d] ang=%10.3f k=%10.3f [%10.3e %10.3e %10.3e %10.3e]\n", (void) fprintf(log, "computeAmoebaInPlaneAngleForce: bond %d [%d %d %d %d] ang=%10.3f k=%10.3f [%10.3e %10.3e %10.3e %10.3e]\n",
bondIndex, particle1, particle2, particle3, particle4, idealInPlaneAngle, quadraticK, cubicK, quarticK, penticK, sexticK ); bondIndex, particle1, particle2, particle3, particle4, idealInPlaneAngle, quadraticK, cubicK, quarticK, penticK, sexticK);
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
...@@ -162,82 +162,82 @@ static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& po ...@@ -162,82 +162,82 @@ static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& po
// APxM, CPxM, ADxBD, BDxCD, TxCD, ADxT, dBxAD, CDxdB, LastDeltaAtomIndex // APxM, CPxM, ADxBD, BDxCD, TxCD, ADxT, dBxAD, CDxdB, LastDeltaAtomIndex
double deltaR[LastDeltaAtomIndex][3]; double deltaR[LastDeltaAtomIndex][3];
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
deltaR[AD][ii] = positions[particle1][ii] - positions[particle4][ii]; deltaR[AD][ii] = positions[particle1][ii] - positions[particle4][ii];
deltaR[BD][ii] = positions[particle2][ii] - positions[particle4][ii]; deltaR[BD][ii] = positions[particle2][ii] - positions[particle4][ii];
deltaR[CD][ii] = positions[particle3][ii] - positions[particle4][ii]; deltaR[CD][ii] = positions[particle3][ii] - positions[particle4][ii];
} }
crossProductVector3( deltaR[AD], deltaR[CD], deltaR[T] ); crossProductVector3(deltaR[AD], deltaR[CD], deltaR[T]);
double rT2 = dotVector3( deltaR[T], deltaR[T] ); double rT2 = dotVector3(deltaR[T], deltaR[T]);
double delta = dotVector3( deltaR[T], deltaR[BD] ); double delta = dotVector3(deltaR[T], deltaR[BD]);
delta *= -1.0/rT2; delta *= -1.0/rT2;
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
deltaR[P][ii] = positions[particle2][ii] + deltaR[T][ii]*delta; deltaR[P][ii] = positions[particle2][ii] + deltaR[T][ii]*delta;
deltaR[AP][ii] = positions[particle1][ii] - deltaR[P][ii]; deltaR[AP][ii] = positions[particle1][ii] - deltaR[P][ii];
deltaR[CP][ii] = positions[particle3][ii] - deltaR[P][ii]; deltaR[CP][ii] = positions[particle3][ii] - deltaR[P][ii];
} }
double rAp2 = dotVector3( deltaR[AP], deltaR[AP] ); double rAp2 = dotVector3(deltaR[AP], deltaR[AP]);
double rCp2 = dotVector3( deltaR[CP], deltaR[CP] ); double rCp2 = dotVector3(deltaR[CP], deltaR[CP]);
if( rAp2 <= 0.0 && rCp2 <= 0.0 ){ if (rAp2 <= 0.0 && rCp2 <= 0.0) {
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaInPlaneAngleForce: rAp2 or rCp2 <= 0.0\n" ); (void) fprintf(log, "computeAmoebaInPlaneAngleForce: rAp2 or rCp2 <= 0.0\n");
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
return; return;
} }
crossProductVector3( deltaR[CP], deltaR[AP], deltaR[M] ); crossProductVector3(deltaR[CP], deltaR[AP], deltaR[M]);
double rm = dotVector3( deltaR[M], deltaR[M] ); double rm = dotVector3(deltaR[M], deltaR[M]);
rm = sqrt( rm ); rm = sqrt(rm);
if( rm < 0.000001 ){ if (rm < 0.000001) {
rm = 0.000001; rm = 0.000001;
} }
double dot = dotVector3( deltaR[AP], deltaR[CP] ); double dot = dotVector3(deltaR[AP], deltaR[CP]);
double cosine = dot/sqrt( rAp2*rCp2 ); double cosine = dot/sqrt(rAp2*rCp2);
double dEdR; double dEdR;
double energyTerm; double energyTerm;
getPrefactorsGivenInPlaneAngleCosine( cosine, idealInPlaneAngle, quadraticK, cubicK, getPrefactorsGivenInPlaneAngleCosine(cosine, idealInPlaneAngle, quadraticK, cubicK,
quarticK, penticK, sexticK, &dEdR, &energyTerm, log ); quarticK, penticK, sexticK, &dEdR, &energyTerm, log);
double termA = -dEdR/(rAp2*rm); double termA = -dEdR/(rAp2*rm);
double termC = dEdR/(rCp2*rm); double termC = dEdR/(rCp2*rm);
crossProductVector3( deltaR[AP], deltaR[M], deltaR[APxM] ); crossProductVector3(deltaR[AP], deltaR[M], deltaR[APxM]);
crossProductVector3( deltaR[CP], deltaR[M], deltaR[CPxM] ); crossProductVector3(deltaR[CP], deltaR[M], deltaR[CPxM]);
// forces will be gathered here // forces will be gathered here
enum { dA, dB, dC, dD, LastDIndex }; enum { dA, dB, dC, dD, LastDIndex };
double forceTerm[LastDIndex][3]; double forceTerm[LastDIndex][3];
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
forceTerm[dA][ii] = deltaR[APxM][ii]*termA; forceTerm[dA][ii] = deltaR[APxM][ii]*termA;
forceTerm[dC][ii] = deltaR[CPxM][ii]*termC; forceTerm[dC][ii] = deltaR[CPxM][ii]*termC;
forceTerm[dB][ii] = -1.0*( forceTerm[dA][ii] + forceTerm[dC][ii] ); forceTerm[dB][ii] = -1.0*(forceTerm[dA][ii] + forceTerm[dC][ii]);
} }
double pTrT2 = dotVector3( forceTerm[dB], deltaR[T] ); double pTrT2 = dotVector3(forceTerm[dB], deltaR[T]);
pTrT2 /= rT2; pTrT2 /= rT2;
crossProductVector3( deltaR[CD], forceTerm[dB], deltaR[CDxdB] ); crossProductVector3(deltaR[CD], forceTerm[dB], deltaR[CDxdB]);
crossProductVector3( forceTerm[dB], deltaR[AD], deltaR[dBxAD] ); crossProductVector3(forceTerm[dB], deltaR[AD], deltaR[dBxAD]);
if( fabs( pTrT2 ) > 1.0e-08 ){ if (fabs(pTrT2) > 1.0e-08) {
double delta2 = delta*2.0; double delta2 = delta*2.0;
crossProductVector3( deltaR[BD], deltaR[CD], deltaR[BDxCD] ); crossProductVector3(deltaR[BD], deltaR[CD], deltaR[BDxCD]);
crossProductVector3( deltaR[T], deltaR[CD], deltaR[TxCD] ); crossProductVector3(deltaR[T], deltaR[CD], deltaR[TxCD] );
crossProductVector3( deltaR[AD], deltaR[BD], deltaR[ADxBD] ); crossProductVector3(deltaR[AD], deltaR[BD], deltaR[ADxBD]);
crossProductVector3( deltaR[AD], deltaR[T], deltaR[ADxT] ); crossProductVector3(deltaR[AD], deltaR[T], deltaR[ADxT] );
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
double term = deltaR[BDxCD][ii] + delta2*deltaR[TxCD][ii]; double term = deltaR[BDxCD][ii] + delta2*deltaR[TxCD][ii];
forceTerm[dA][ii] += delta*deltaR[CDxdB][ii] + term*pTrT2; forceTerm[dA][ii] += delta*deltaR[CDxdB][ii] + term*pTrT2;
...@@ -245,16 +245,16 @@ static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& po ...@@ -245,16 +245,16 @@ static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& po
term = deltaR[ADxBD][ii] + delta2*deltaR[ADxT][ii]; term = deltaR[ADxBD][ii] + delta2*deltaR[ADxT][ii];
forceTerm[dC][ii] += delta*deltaR[dBxAD][ii] + term*pTrT2; forceTerm[dC][ii] += delta*deltaR[dBxAD][ii] + term*pTrT2;
forceTerm[dD][ii] = -( forceTerm[dA][ii] + forceTerm[dB][ii] + forceTerm[dC][ii] ); forceTerm[dD][ii] = -(forceTerm[dA][ii] + forceTerm[dB][ii] + forceTerm[dC][ii]);
} }
} }
else { else {
for( int ii = 0; ii < 3; ii++ ){ for (int ii = 0; ii < 3; ii++) {
forceTerm[dA][ii] += delta*deltaR[CDxdB][ii]; forceTerm[dA][ii] += delta*deltaR[CDxdB][ii];
forceTerm[dC][ii] += delta*deltaR[dBxAD][ii]; forceTerm[dC][ii] += delta*deltaR[dBxAD][ii];
forceTerm[dD][ii] = -( forceTerm[dA][ii] + forceTerm[dB][ii] + forceTerm[dC][ii] ); forceTerm[dD][ii] = -(forceTerm[dA][ii] + forceTerm[dB][ii] + forceTerm[dC][ii]);
} }
} }
...@@ -280,69 +280,69 @@ static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& po ...@@ -280,69 +280,69 @@ static void computeAmoebaInPlaneAngleForce(int bondIndex, std::vector<Vec3>& po
} }
static void computeAmoebaInPlaneAngleForces( Context& context, AmoebaInPlaneAngleForce& AmoebaInPlaneAngleForce, static void computeAmoebaInPlaneAngleForces(Context& context, AmoebaInPlaneAngleForce& AmoebaInPlaneAngleForce,
std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log ) { std::vector<Vec3>& expectedForces, double* expectedEnergy, FILE* log) {
// get positions and zero forces // get positions and zero forces
State state = context.getState(State::Positions); State state = context.getState(State::Positions);
std::vector<Vec3> positions = state.getPositions(); std::vector<Vec3> positions = state.getPositions();
expectedForces.resize( positions.size() ); expectedForces.resize(positions.size());
for( unsigned int ii = 0; ii < expectedForces.size(); ii++ ){ for (unsigned int ii = 0; ii < expectedForces.size(); ii++) {
expectedForces[ii][0] = expectedForces[ii][1] = expectedForces[ii][2] = 0.0; expectedForces[ii][0] = expectedForces[ii][1] = expectedForces[ii][2] = 0.0;
} }
// calculates forces/energy // calculates forces/energy
*expectedEnergy = 0.0; *expectedEnergy = 0.0;
for( int ii = 0; ii < AmoebaInPlaneAngleForce.getNumAngles(); ii++ ){ for (int ii = 0; ii < AmoebaInPlaneAngleForce.getNumAngles(); ii++) {
computeAmoebaInPlaneAngleForce(ii, positions, AmoebaInPlaneAngleForce, expectedForces, expectedEnergy, log ); computeAmoebaInPlaneAngleForce(ii, positions, AmoebaInPlaneAngleForce, expectedForces, expectedEnergy, log);
} }
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaInPlaneAngleForces: expected energy=%14.7e\n", *expectedEnergy ); (void) fprintf(log, "computeAmoebaInPlaneAngleForces: expected energy=%14.7e\n", *expectedEnergy);
for( unsigned int ii = 0; ii < positions.size(); ii++ ){ 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) fprintf(log, "%6u [%14.7e %14.7e %14.7e]\n", ii, expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2]);
} }
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
return; return;
} }
void compareWithExpectedForceAndEnergy( Context& context, AmoebaInPlaneAngleForce& AmoebaInPlaneAngleForce, void compareWithExpectedForceAndEnergy(Context& context, AmoebaInPlaneAngleForce& AmoebaInPlaneAngleForce,
double tolerance, const std::string& idString, FILE* log) { double tolerance, const std::string& idString, FILE* log) {
std::vector<Vec3> expectedForces; std::vector<Vec3> expectedForces;
double expectedEnergy; double expectedEnergy;
computeAmoebaInPlaneAngleForces( context, AmoebaInPlaneAngleForce, expectedForces, &expectedEnergy, log ); computeAmoebaInPlaneAngleForces(context, AmoebaInPlaneAngleForce, expectedForces, &expectedEnergy, log);
State state = context.getState(State::Forces | State::Energy); State state = context.getState(State::Forces | State::Energy);
const std::vector<Vec3> forces = state.getForces(); const std::vector<Vec3> forces = state.getForces();
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log ){ if (log) {
(void) fprintf( log, "computeAmoebaInPlaneAngleForces: expected energy=%14.7e %14.7e\n", expectedEnergy, state.getPotentialEnergy() ); (void) fprintf(log, "computeAmoebaInPlaneAngleForces: expected energy=%14.7e %14.7e\n", expectedEnergy, state.getPotentialEnergy());
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ 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, (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] ); expectedForces[ii][0], expectedForces[ii][1], expectedForces[ii][2], forces[ii][0], forces[ii][1], forces[ii][2]);
} }
(void) fflush( log ); (void) fflush(log);
} }
#endif #endif
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ for (unsigned int ii = 0; ii < forces.size(); ii++) {
ASSERT_EQUAL_VEC( expectedForces[ii], forces[ii], tolerance ); ASSERT_EQUAL_VEC(expectedForces[ii], forces[ii], tolerance);
} }
ASSERT_EQUAL_TOL( expectedEnergy, state.getPotentialEnergy(), tolerance ); ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance);
} }
void testOneAngle( FILE* log ) { void testOneAngle(FILE* log) {
System system; System system;
int numberOfParticles = 4; int numberOfParticles = 4;
for( int ii = 0; ii < numberOfParticles; ii++ ){ for (int ii = 0; ii < numberOfParticles; ii++) {
system.addParticle(1.0); system.addParticle(1.0);
} }
...@@ -366,7 +366,7 @@ void testOneAngle( FILE* log ) { ...@@ -366,7 +366,7 @@ void testOneAngle( FILE* log ) {
system.addForce(amoebaInPlaneAngleForce); system.addForce(amoebaInPlaneAngleForce);
ASSERT(!amoebaInPlaneAngleForce->usesPeriodicBoundaryConditions()); ASSERT(!amoebaInPlaneAngleForce->usesPeriodicBoundaryConditions());
ASSERT(!system.usesPeriodicBoundaryConditions()); ASSERT(!system.usesPeriodicBoundaryConditions());
Context context(system, integrator, Platform::getPlatformByName( "Reference")); Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numberOfParticles); std::vector<Vec3> positions(numberOfParticles);
...@@ -376,7 +376,7 @@ void testOneAngle( FILE* log ) { ...@@ -376,7 +376,7 @@ void testOneAngle( FILE* log ) {
positions[3] = Vec3(1, 1, 1); positions[3] = Vec3(1, 1, 1);
context.setPositions(positions); context.setPositions(positions);
compareWithExpectedForceAndEnergy( context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle", log ); compareWithExpectedForceAndEnergy(context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle", log);
// Try changing the angle parameters and make sure it's still correct. // Try changing the angle parameters and make sure it's still correct.
...@@ -384,29 +384,29 @@ void testOneAngle( FILE* log ) { ...@@ -384,29 +384,29 @@ void testOneAngle( FILE* log ) {
bool exceptionThrown = false; bool exceptionThrown = false;
try { try {
// This should throw an exception. // This should throw an exception.
compareWithExpectedForceAndEnergy( context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle", log ); compareWithExpectedForceAndEnergy(context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle", log);
} }
catch (std::exception ex) { catch (std::exception ex) {
exceptionThrown = true; exceptionThrown = true;
} }
ASSERT(exceptionThrown); ASSERT(exceptionThrown);
amoebaInPlaneAngleForce->updateParametersInContext(context); amoebaInPlaneAngleForce->updateParametersInContext(context);
compareWithExpectedForceAndEnergy( context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle", log ); compareWithExpectedForceAndEnergy(context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle", log);
} }
int main( int numberOfArguments, char* argv[] ) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestReferenceAmoebaInPlaneAngleForce running test..." << std::endl; std::cout << "TestReferenceAmoebaInPlaneAngleForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
FILE* log = NULL; FILE* log = NULL;
//FILE* log = stderr; //FILE* log = stderr;
//FILE* log = fopen( "AmoebaInPlaneAngleForce.log", "w" );; //FILE* log = fopen("AmoebaInPlaneAngleForce.log", "w");;
testOneAngle( NULL ); testOneAngle(NULL);
#ifdef AMOEBA_DEBUG #ifdef AMOEBA_DEBUG
if( log && log != stderr ) if (log && log != stderr)
(void) fclose( log ); (void) fclose(log);
#endif #endif
} }
......
...@@ -2559,20 +2559,20 @@ static double grid[4][625][6] = { ...@@ -2559,20 +2559,20 @@ static double grid[4][625][6] = {
int elementCount = (includeDerivs ? 6 : 3); int elementCount = (includeDerivs ? 6 : 3);
std::vector<TorsionTorsionGrid> grids(4); std::vector<TorsionTorsionGrid> grids(4);
for( int ii = 0; ii < 4; ii++ ){ for (int ii = 0; ii < 4; ii++) {
grids[ii].resize( 25 ); grids[ii].resize(25);
for( int jj = 0; jj < 25; jj++ ){ for (int jj = 0; jj < 25; jj++) {
grids[ii][jj].resize(25); grids[ii][jj].resize(25);
for( int kk = 0; kk < 25; kk++ ){ for (int kk = 0; kk < 25; kk++) {
grids[ii][jj][kk].resize(elementCount); grids[ii][jj][kk].resize(elementCount);
} }
} }
int index = 0; int index = 0;
for( int jj = 0; jj < 25; jj++ ){ for (int jj = 0; jj < 25; jj++) {
for( int kk = 0; kk < 25; kk++ ){ for (int kk = 0; kk < 25; kk++) {
int jjIndex = static_cast<int>(((grid[ii][index][0] + 180.0)/15.0)+1.0e-05); int jjIndex = static_cast<int>(((grid[ii][index][0] + 180.0)/15.0)+1.0e-05);
int kkIndex = static_cast<int>(((grid[ii][index][1] + 180.0)/15.0)+1.0e-05); int kkIndex = static_cast<int>(((grid[ii][index][1] + 180.0)/15.0)+1.0e-05);
for( int ll = 0; ll < elementCount; ll++ ){ for (int ll = 0; ll < elementCount; ll++) {
grids[ii][kk][jj][ll] = grid[ii][index][ll]; grids[ii][kk][jj][ll] = grid[ii][index][ll];
} }
index++; index++;
...@@ -2586,7 +2586,7 @@ void testTorsionTorsion(int systemId, bool includeDerivs) { ...@@ -2586,7 +2586,7 @@ void testTorsionTorsion(int systemId, bool includeDerivs) {
System system; System system;
int numberOfParticles = 6; int numberOfParticles = 6;
for( int ii = 0; ii < numberOfParticles; ii++ ){ for (int ii = 0; ii < numberOfParticles; ii++) {
system.addParticle(1.0); system.addParticle(1.0);
} }
LangevinIntegrator integrator(0.0, 0.1, 0.01); LangevinIntegrator integrator(0.0, 0.1, 0.01);
...@@ -2598,48 +2598,48 @@ void testTorsionTorsion(int systemId, bool includeDerivs) { ...@@ -2598,48 +2598,48 @@ void testTorsionTorsion(int systemId, bool includeDerivs) {
std::vector<Vec3> positions(numberOfParticles); std::vector<Vec3> positions(numberOfParticles);
std::vector<Vec3> expectedForces(numberOfParticles); std::vector<Vec3> expectedForces(numberOfParticles);
double expectedEnergy; double expectedEnergy;
if( systemId == 0 ){ if (systemId == 0) {
// villin: 2 19 20 21 38 25 grid=2 // villin: 2 19 20 21 38 25 grid=2
chiralCheckAtomIndex = 5; chiralCheckAtomIndex = 5;
gridIndex = 2; gridIndex = 2;
positions[0] = Vec3( -0.422792800E+01, -0.110605910E+02, -0.508156700E+01 ); positions[0] = Vec3(-0.422792800E+01, -0.110605910E+02, -0.508156700E+01);
positions[1] = Vec3( -0.447153100E+01, -0.978627900E+01, -0.466405800E+01 ); positions[1] = Vec3(-0.447153100E+01, -0.978627900E+01, -0.466405800E+01);
positions[2] = Vec3( -0.531878400E+01, -0.940508600E+01, -0.352283100E+01 ); positions[2] = Vec3(-0.531878400E+01, -0.940508600E+01, -0.352283100E+01);
positions[3] = Vec3( -0.679606000E+01, -0.974353100E+01, -0.382975700E+01 ); positions[3] = Vec3(-0.679606000E+01, -0.974353100E+01, -0.382975700E+01);
positions[4] = Vec3( -0.760612300E+01, -0.992590200E+01, -0.275088400E+01 ); positions[4] = Vec3(-0.760612300E+01, -0.992590200E+01, -0.275088400E+01);
positions[5] = Vec3( -0.516893900E+01, -0.788347000E+01, -0.316943000E+01 ); positions[5] = Vec3(-0.516893900E+01, -0.788347000E+01, -0.316943000E+01);
expectedForces[0] = Vec3( 0.906091624E+00, -0.529814945E-01, 0.690384140E+00 ); expectedForces[0] = Vec3( 0.906091624E+00, -0.529814945E-01, 0.690384140E+00);
expectedForces[1] = Vec3( -0.124550232E+01, -0.999341692E+00, -0.590867130E+00 ); expectedForces[1] = Vec3(-0.124550232E+01, -0.999341692E+00, -0.590867130E+00);
expectedForces[2] = Vec3( 0.534419689E+00, 0.612404926E-01, 0.547380310E-01 ); expectedForces[2] = Vec3( 0.534419689E+00, 0.612404926E-01, 0.547380310E-01);
expectedForces[3] = Vec3( -5.732010432E-01, 2.645718463E+00, -1.585204274E-01 ); expectedForces[3] = Vec3(-5.732010432E-01, 2.645718463E+00, -1.585204274E-01);
expectedForces[4] = Vec3( 3.781920539E-01, -1.654635768E+00, 4.265386268E-03 ); expectedForces[4] = Vec3( 3.781920539E-01, -1.654635768E+00, 4.265386268E-03);
expectedForces[5] = Vec3( 0.0, 0.0, 0.0 ); expectedForces[5] = Vec3( 0.0, 0.0, 0.0);
expectedEnergy = -2.699654759E+00; expectedEnergy = -2.699654759E+00;
} }
else if( systemId == 1 ){ else if (systemId == 1) {
// villin: 158 176 177 178 183 -1 0 // villin: 158 176 177 178 183 -1 0
chiralCheckAtomIndex = -1; chiralCheckAtomIndex = -1;
gridIndex = 0; gridIndex = 0;
positions[0] = Vec3( -0.105946640E+02, -0.917797000E+00, 0.105486310E+02 ); positions[0] = Vec3(-0.105946640E+02, -0.917797000E+00, 0.105486310E+02);
positions[1] = Vec3( -0.115059090E+02, -0.141876700E+01, 0.966933200E+01 ); positions[1] = Vec3(-0.115059090E+02, -0.141876700E+01, 0.966933200E+01);
positions[2] = Vec3( -0.128314660E+02, -0.876338000E+00, 0.942959800E+01 ); positions[2] = Vec3(-0.128314660E+02, -0.876338000E+00, 0.942959800E+01);
positions[3] = Vec3( -0.130879850E+02, -0.760280000E-01, 0.814732200E+01 ); positions[3] = Vec3(-0.130879850E+02, -0.760280000E-01, 0.814732200E+01);
positions[4] = Vec3( -0.120888080E+02, 0.112050000E-01, 0.722704500E+01 ); positions[4] = Vec3(-0.120888080E+02, 0.112050000E-01, 0.722704500E+01);
positions[5] = Vec3( 0.0, 0.0, 0.0 ); positions[5] = Vec3( 0.0, 0.0, 0.0);
expectedForces[0] = Vec3( 4.165851130E-01, 6.608242922E-01, -8.082168261E-01 ); expectedForces[0] = Vec3( 4.165851130E-01, 6.608242922E-01, -8.082168261E-01);
expectedForces[1] = Vec3( -6.024659721E-01, -8.878744406E-01, 1.322274444E+00 ); expectedForces[1] = Vec3(-6.024659721E-01, -8.878744406E-01, 1.322274444E+00);
expectedForces[2] = Vec3( 3.196925118E-02, -3.137497848E-01, -8.207984001E-01 ); expectedForces[2] = Vec3( 3.196925118E-02, -3.137497848E-01, -8.207984001E-01);
expectedForces[3] = Vec3( 3.842205941E-02, 2.602732089E-01, 1.547586195E-01 ); expectedForces[3] = Vec3( 3.842205941E-02, 2.602732089E-01, 1.547586195E-01);
expectedForces[4] = Vec3( 1.154895485E-01, 2.805267242E-01, 1.519821623E-01 ); expectedForces[4] = Vec3( 1.154895485E-01, 2.805267242E-01, 1.519821623E-01);
expectedForces[5] = Vec3( 0.0, 0.0, 0.0 ); expectedForces[5] = Vec3( 0.0, 0.0, 0.0);
expectedEnergy = -3.372536909E+00; expectedEnergy = -3.372536909E+00;
} }
...@@ -2656,21 +2656,21 @@ void testTorsionTorsion(int systemId, bool includeDerivs) { ...@@ -2656,21 +2656,21 @@ void testTorsionTorsion(int systemId, bool includeDerivs) {
std::vector<Vec3> forces = state.getForces(); std::vector<Vec3> forces = state.getForces();
const double conversion = -1.0; const double conversion = -1.0;
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ for (unsigned int ii = 0; ii < forces.size(); ii++) {
forces[ii][0] *= conversion; forces[ii][0] *= conversion;
forces[ii][1] *= conversion; forces[ii][1] *= conversion;
forces[ii][2] *= conversion; forces[ii][2] *= conversion;
} }
double tolerance = 1.0e-03; double tolerance = 1.0e-03;
for( unsigned int ii = 0; ii < forces.size(); ii++ ){ for (unsigned int ii = 0; ii < forces.size(); ii++) {
ASSERT_EQUAL_VEC( expectedForces[ii], forces[ii], tolerance ); ASSERT_EQUAL_VEC(expectedForces[ii], forces[ii], tolerance);
} }
ASSERT_EQUAL_TOL( expectedEnergy, state.getPotentialEnergy(), tolerance ); ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance);
} }
int main( int numberOfArguments, char* argv[] ) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestReferenceAmoebaTorsionTorsionForce running test..." << std::endl; std::cout << "TestReferenceAmoebaTorsionTorsionForce running test..." << 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