Commit a783b996 authored by peastman's avatar peastman
Browse files

Eliminated RealOpenMM type

parent 9500f3af
......@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceBondForce_H__
#define __AmoebaReferenceBondForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
namespace OpenMM {
......@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
void setPeriodic(OpenMM::Vec3* vectors);
/**---------------------------------------------------------------------------------------
......@@ -78,18 +78,18 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numBonds, std::vector<OpenMM::RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<RealOpenMM>& bondLength,
const std::vector<RealOpenMM>& bondK,
RealOpenMM bondCubic, RealOpenMM bondQuartic,
std::vector<OpenMM::RealVec>& forceData) const;
double calculateForceAndEnergy(int numBonds, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<double>& bondLength,
const std::vector<double>& bondK,
double bondCubic, double bondQuartic,
std::vector<OpenMM::Vec3>& forceData) const;
private:
bool usePeriodic;
RealVec boxVectors[3];
Vec3 boxVectors[3];
/**---------------------------------------------------------------------------------------
......@@ -107,10 +107,10 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateBondIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
RealOpenMM bondLength, RealOpenMM bondK,
RealOpenMM bondCubic, RealOpenMM bondQuartic,
OpenMM::RealVec* forces) const;
double calculateBondIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
double bondLength, double bondK,
double bondCubic, double bondQuartic,
OpenMM::Vec3* forces) const;
};
......
......@@ -23,6 +23,7 @@
*/
#include "AmoebaReferenceForce.h"
#include <cmath>
#include <vector>
using namespace OpenMM;
......@@ -37,8 +38,8 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::loadDeltaR(const RealVec& xVector, const RealVec& yVector,
std::vector<RealOpenMM>& deltaR) {
void AmoebaReferenceForce::loadDeltaR(const Vec3& xVector, const Vec3& yVector,
std::vector<double>& deltaR) {
deltaR.resize(0);
deltaR.push_back(yVector[0] - xVector[0]);
deltaR.push_back(yVector[1] - xVector[1]);
......@@ -56,9 +57,9 @@ void AmoebaReferenceForce::loadDeltaR(const RealVec& xVector, const RealVec& yVe
--------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::loadDeltaRPeriodic(const RealVec& xVector, const RealVec& yVector,
std::vector<RealOpenMM>& deltaR, const RealVec* boxVectors) {
RealVec diff = yVector-xVector;
void AmoebaReferenceForce::loadDeltaRPeriodic(const Vec3& xVector, const Vec3& yVector,
std::vector<double>& deltaR, const Vec3* boxVectors) {
Vec3 diff = yVector-xVector;
diff -= boxVectors[2]*floor(diff[2]/boxVectors[2][2]+0.5);
diff -= boxVectors[1]*floor(diff[1]/boxVectors[1][1]+0.5);
diff -= boxVectors[0]*floor(diff[0]/boxVectors[0][0]+0.5);
......@@ -78,7 +79,7 @@ void AmoebaReferenceForce::loadDeltaRPeriodic(const RealVec& xVector, const Real
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getNormSquared3(const std::vector<RealOpenMM>& inputVector) {
double AmoebaReferenceForce::getNormSquared3(const std::vector<double>& inputVector) {
// get 3 norm
return (inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
......@@ -94,7 +95,7 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const std::vector<RealOpenMM>&
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getNormSquared3(const RealOpenMM* inputVector) {
double AmoebaReferenceForce::getNormSquared3(const double* inputVector) {
// get 3 norm
return (inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
......@@ -110,25 +111,25 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const RealOpenMM* inputVector)
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getNorm3(const std::vector<RealOpenMM>& inputVector) {
double AmoebaReferenceForce::getNorm3(const std::vector<double>& inputVector) {
// get 3 norm
return SQRT(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
return sqrt(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
}
RealOpenMM AmoebaReferenceForce::getNorm3(const RealOpenMM* inputVector) {
double AmoebaReferenceForce::getNorm3(const double* inputVector) {
// get 3 norm
return SQRT(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
return sqrt(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
}
RealOpenMM AmoebaReferenceForce::normalizeVector3(RealOpenMM* inputVector) {
RealOpenMM norm = SQRT(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
double AmoebaReferenceForce::normalizeVector3(double* inputVector) {
double norm = sqrt(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
if (norm > 0.0) {
RealOpenMM normI = 1.0/norm;
inputVector[0] *= normI;
inputVector[1] *= normI;
inputVector[2] *= normI;
double normI = 1.0/norm;
inputVector[0] *= normI;
inputVector[1] *= normI;
inputVector[2] *= normI;
}
return norm;
......@@ -145,7 +146,7 @@ RealOpenMM AmoebaReferenceForce::normalizeVector3(RealOpenMM* inputVector) {
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getDotProduct3(const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector) {
double AmoebaReferenceForce::getDotProduct3(const std::vector<double>& xVector, const std::vector<double>& yVector) {
// get dot product
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2];
......@@ -162,13 +163,13 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(const std::vector<RealOpenMM>& x
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getDotProduct3(const RealOpenMM* xVector, const RealOpenMM* yVector) {
double AmoebaReferenceForce::getDotProduct3(const double* xVector, const double* yVector) {
// get dot product
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2];
}
RealOpenMM AmoebaReferenceForce::getDotProduct3(const RealOpenMM* xVector, const OpenMM::Vec3& yVector) {
double AmoebaReferenceForce::getDotProduct3(const double* xVector, const OpenMM::Vec3& yVector) {
// get dot product
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2];
......@@ -186,7 +187,7 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(const RealOpenMM* xVector, const
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getDotProduct3(unsigned int vectorOffset, const std::vector<RealOpenMM>& xVector, const RealOpenMM* yVector) {
double AmoebaReferenceForce::getDotProduct3(unsigned int vectorOffset, const std::vector<double>& xVector, const double* yVector) {
// get dot product
return xVector[vectorOffset+0]*yVector[0] + xVector[vectorOffset+1]*yVector[1] + xVector[vectorOffset+2]*yVector[2];
......@@ -202,9 +203,9 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(unsigned int vectorOffset, const
--------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::getCrossProduct(const std::vector<RealOpenMM>& xVector,
const std::vector<RealOpenMM>& yVector,
std::vector<RealOpenMM>& zVector) {
void AmoebaReferenceForce::getCrossProduct(const std::vector<double>& xVector,
const std::vector<double>& yVector,
std::vector<double>& zVector) {
zVector[0] = xVector[1]*yVector[2] - xVector[2]*yVector[1];
zVector[1] = xVector[2]*yVector[0] - xVector[0]*yVector[2];
zVector[2] = xVector[0]*yVector[1] - xVector[1]*yVector[0];
......@@ -220,9 +221,9 @@ void AmoebaReferenceForce::getCrossProduct(const std::vector<RealOpenMM>& xVecto
--------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::getCrossProduct(const RealOpenMM* xVector,
const RealOpenMM* yVector,
RealOpenMM* zVector) {
void AmoebaReferenceForce::getCrossProduct(const double* xVector,
const double* yVector,
double* zVector) {
zVector[0] = xVector[1]*yVector[2] - xVector[2]*yVector[1];
zVector[1] = xVector[2]*yVector[0] - xVector[0]*yVector[2];
zVector[2] = xVector[0]*yVector[1] - xVector[1]*yVector[0];
......
......@@ -25,7 +25,6 @@
#ifndef __AmoebaReferenceForce_H__
#define __AmoebaReferenceForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
......@@ -62,8 +61,8 @@ public:
--------------------------------------------------------------------------------------- */
static void loadDeltaR(const OpenMM::RealVec& xVector, const OpenMM::RealVec& yVector,
std::vector<RealOpenMM>& deltaR);
static void loadDeltaR(const OpenMM::Vec3& xVector, const OpenMM::Vec3& yVector,
std::vector<double>& deltaR);
/**---------------------------------------------------------------------------------------
Load delta of two vectors, applying periodic boundary conditions
......@@ -75,7 +74,7 @@ public:
--------------------------------------------------------------------------------------- */
static void loadDeltaRPeriodic(const RealVec& xVector, const RealVec& yVector, std::vector<RealOpenMM>& deltaR, const RealVec* boxVectors);
static void loadDeltaRPeriodic(const Vec3& xVector, const Vec3& yVector, std::vector<double>& deltaR, const Vec3* boxVectors);
/**---------------------------------------------------------------------------------------
......@@ -87,8 +86,8 @@ public:
--------------------------------------------------------------------------------------- */
static RealOpenMM getNormSquared3(const std::vector<RealOpenMM>& inputVector);
static RealOpenMM getNormSquared3(const RealOpenMM* inputVector);
static double getNormSquared3(const std::vector<double>& inputVector);
static double getNormSquared3(const double* inputVector);
/**---------------------------------------------------------------------------------------
......@@ -100,8 +99,8 @@ public:
--------------------------------------------------------------------------------------- */
static RealOpenMM getNorm3(const std::vector<RealOpenMM>& inputVector);
static RealOpenMM getNorm3(const RealOpenMM* inputVector);
static double getNorm3(const std::vector<double>& inputVector);
static double getNorm3(const double* inputVector);
/**---------------------------------------------------------------------------------------
......@@ -113,7 +112,7 @@ public:
--------------------------------------------------------------------------------------- */
static RealOpenMM normalizeVector3(RealOpenMM* inputVector);
static double normalizeVector3(double* inputVector);
/**---------------------------------------------------------------------------------------
......@@ -126,10 +125,10 @@ public:
--------------------------------------------------------------------------------------- */
static RealOpenMM getDotProduct3(const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector);
static RealOpenMM getDotProduct3(const RealOpenMM* xVector, const RealOpenMM* yVector);
static RealOpenMM getDotProduct3(const RealOpenMM* xVector, const OpenMM::Vec3& yVector);
static RealOpenMM getDotProduct3(unsigned int vectorOffset, const std::vector<RealOpenMM>& xVector, const RealOpenMM* yVector);
static double getDotProduct3(const std::vector<double>& xVector, const std::vector<double>& yVector);
static double getDotProduct3(const double* xVector, const double* yVector);
static double getDotProduct3(const double* xVector, const OpenMM::Vec3& yVector);
static double getDotProduct3(unsigned int vectorOffset, const std::vector<double>& xVector, const double* yVector);
/**---------------------------------------------------------------------------------------
......@@ -141,10 +140,10 @@ public:
--------------------------------------------------------------------------------------- */
static void getCrossProduct(const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector,
std::vector<RealOpenMM>& zVector);
static void getCrossProduct(const std::vector<double>& xVector, const std::vector<double>& yVector,
std::vector<double>& zVector);
static void getCrossProduct(const RealOpenMM* xVector, const RealOpenMM* yVector, RealOpenMM* zVector);
static void getCrossProduct(const double* xVector, const double* yVector, double* zVector);
};
......
......@@ -22,6 +22,7 @@
*/
#include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include <cmath>
using std::vector;
using namespace OpenMM;
......@@ -61,120 +62,113 @@ int AmoebaReferenceGeneralizedKirkwoodForce::getDirectPolarization() const {
return _directPolarization;
}
void AmoebaReferenceGeneralizedKirkwoodForce::setSoluteDielectric(RealOpenMM soluteDielectric) {
void AmoebaReferenceGeneralizedKirkwoodForce::setSoluteDielectric(double soluteDielectric) {
_soluteDielectric = soluteDielectric;
}
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getSoluteDielectric() const {
double AmoebaReferenceGeneralizedKirkwoodForce::getSoluteDielectric() const {
return _soluteDielectric;
}
void AmoebaReferenceGeneralizedKirkwoodForce::setSolventDielectric(RealOpenMM solventDielectric) {
void AmoebaReferenceGeneralizedKirkwoodForce::setSolventDielectric(double solventDielectric) {
_solventDielectric = solventDielectric;
}
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getSolventDielectric() const {
double AmoebaReferenceGeneralizedKirkwoodForce::getSolventDielectric() const {
return _solventDielectric;
}
void AmoebaReferenceGeneralizedKirkwoodForce::setDielectricOffset(RealOpenMM dielectricOffset) {
void AmoebaReferenceGeneralizedKirkwoodForce::setDielectricOffset(double dielectricOffset) {
_dielectricOffset = dielectricOffset;
}
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getDielectricOffset() const {
double AmoebaReferenceGeneralizedKirkwoodForce::getDielectricOffset() const {
return _dielectricOffset;
}
void AmoebaReferenceGeneralizedKirkwoodForce::setProbeRadius(RealOpenMM probeRadius) {
void AmoebaReferenceGeneralizedKirkwoodForce::setProbeRadius(double probeRadius) {
_probeRadius = probeRadius;
}
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getProbeRadius() const {
double AmoebaReferenceGeneralizedKirkwoodForce::getProbeRadius() const {
return _probeRadius;
}
void AmoebaReferenceGeneralizedKirkwoodForce::setSurfaceAreaFactor(RealOpenMM surfaceAreaFactor) {
void AmoebaReferenceGeneralizedKirkwoodForce::setSurfaceAreaFactor(double surfaceAreaFactor) {
_surfaceAreaFactor = surfaceAreaFactor;
}
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getSurfaceAreaFactor() const {
double AmoebaReferenceGeneralizedKirkwoodForce::getSurfaceAreaFactor() const {
return _surfaceAreaFactor;
}
void AmoebaReferenceGeneralizedKirkwoodForce::setAtomicRadii(const vector<RealOpenMM>& atomicRadii) {
void AmoebaReferenceGeneralizedKirkwoodForce::setAtomicRadii(const vector<double>& atomicRadii) {
_atomicRadii.resize(atomicRadii.size());
copy(atomicRadii.begin(), atomicRadii.end(), _atomicRadii.begin());
}
void AmoebaReferenceGeneralizedKirkwoodForce::getAtomicRadii(vector<RealOpenMM>& atomicRadii) const {
void AmoebaReferenceGeneralizedKirkwoodForce::getAtomicRadii(vector<double>& atomicRadii) const {
atomicRadii.resize(_atomicRadii.size());
copy(_atomicRadii.begin(), _atomicRadii.end(), atomicRadii.begin());
}
void AmoebaReferenceGeneralizedKirkwoodForce::setScaleFactors(const vector<RealOpenMM>& scaleFactors) {
void AmoebaReferenceGeneralizedKirkwoodForce::setScaleFactors(const vector<double>& scaleFactors) {
_scaleFactors.resize(scaleFactors.size());
copy(scaleFactors.begin(), scaleFactors.end(), _scaleFactors.begin());
}
void AmoebaReferenceGeneralizedKirkwoodForce::getScaleFactors(vector<RealOpenMM>& scaleFactors) const {
void AmoebaReferenceGeneralizedKirkwoodForce::getScaleFactors(vector<double>& scaleFactors) const {
scaleFactors.resize(_scaleFactors.size());
copy(_scaleFactors.begin(), _scaleFactors.end(), scaleFactors.begin());
}
void AmoebaReferenceGeneralizedKirkwoodForce::setCharges(const vector<RealOpenMM>& charges) {
void AmoebaReferenceGeneralizedKirkwoodForce::setCharges(const vector<double>& charges) {
_charges.resize(charges.size());
copy(charges.begin(), charges.end(), _charges.begin());
}
void AmoebaReferenceGeneralizedKirkwoodForce::getGrycukBornRadii(vector<RealOpenMM>& bornRadii) const {
void AmoebaReferenceGeneralizedKirkwoodForce::getGrycukBornRadii(vector<double>& bornRadii) const {
bornRadii.resize(_bornRadii.size());
copy(_bornRadii.begin(), _bornRadii.end(), bornRadii.begin());
}
void AmoebaReferenceGeneralizedKirkwoodForce::calculateGrycukBornRadii(const vector<RealVec>& particlePositions) {
void AmoebaReferenceGeneralizedKirkwoodForce::calculateGrycukBornRadii(const vector<Vec3>& particlePositions) {
const RealOpenMM zero = 0.0;
const RealOpenMM one = 1.0;
const RealOpenMM three = 3.0;
const RealOpenMM six = 6.0;
const RealOpenMM eight = 8.0;
const RealOpenMM sixteen = 16.0;
const RealOpenMM oneThird = 1.0/3.0;
const RealOpenMM bigRadius = 1000.0;
const double bigRadius = 1000.0;
_bornRadii.resize(_numParticles);
for (unsigned int ii = 0; ii < _numParticles; ii++) {
if (_atomicRadii[ii] <= zero) {
if (_atomicRadii[ii] <= 0.0) {
_bornRadii[ii] = bigRadius;
continue;
}
RealOpenMM bornSum = zero;
double bornSum = 0.0;
for (unsigned int jj = 0; jj < _numParticles; jj++) {
if (ii == jj || _atomicRadii[jj] < zero)continue;
if (ii == jj || _atomicRadii[jj] < 0.0)continue;
RealOpenMM xr = particlePositions[jj][0] - particlePositions[ii][0];
RealOpenMM yr = particlePositions[jj][1] - particlePositions[ii][1];
RealOpenMM zr = particlePositions[jj][2] - particlePositions[ii][2];
double xr = particlePositions[jj][0] - particlePositions[ii][0];
double yr = particlePositions[jj][1] - particlePositions[ii][1];
double zr = particlePositions[jj][2] - particlePositions[ii][2];
RealOpenMM r2 = xr*xr + yr*yr + zr*zr;
RealOpenMM r = SQRT(r2);
double r2 = xr*xr + yr*yr + zr*zr;
double r = sqrt(r2);
RealOpenMM sk = _atomicRadii[jj]*_scaleFactors[jj];
RealOpenMM sk2 = sk*sk;
double sk = _atomicRadii[jj]*_scaleFactors[jj];
double sk2 = sk*sk;
if ((_atomicRadii[ii] + r) < sk) {
RealOpenMM lik = _atomicRadii[ii];
RealOpenMM uik = sk - r;
RealOpenMM lik3 = lik*lik*lik;
RealOpenMM uik3 = uik*uik*uik;
bornSum -= (one/uik3 - one/lik3);
double lik = _atomicRadii[ii];
double uik = sk - r;
double lik3 = lik*lik*lik;
double uik3 = uik*uik*uik;
bornSum -= (1.0/uik3 - 1.0/lik3);
}
RealOpenMM uik = r + sk;
RealOpenMM lik;
double uik = r + sk;
double lik;
if ((_atomicRadii[ii] + r) < sk) {
lik = sk - r;
} else if (r < (_atomicRadii[ii] + sk)) {
......@@ -183,22 +177,22 @@ void AmoebaReferenceGeneralizedKirkwoodForce::calculateGrycukBornRadii(const vec
lik = r - sk;
}
RealOpenMM l2 = lik*lik;
RealOpenMM l4 = l2*l2;
RealOpenMM lr = lik*r;
RealOpenMM l4r = l4*r;
double l2 = lik*lik;
double l4 = l2*l2;
double lr = lik*r;
double l4r = l4*r;
RealOpenMM u2 = uik*uik;
RealOpenMM u4 = u2*u2;
RealOpenMM ur = uik*r;
RealOpenMM u4r = u4*r;
double u2 = uik*uik;
double u4 = u2*u2;
double ur = uik*r;
double u4r = u4*r;
RealOpenMM term = (three*(r2-sk2) + six*u2 - eight*ur)/u4r - (three*(r2-sk2) + six*l2 - eight*lr)/l4r;
bornSum += term/sixteen;
double term = (3.0*(r2-sk2) + 6.0*u2 - 8.0*ur)/u4r - (3.0*(r2-sk2) + 6.0*l2 - 8.0*lr)/l4r;
bornSum += term/16.0;
}
bornSum = one/(_atomicRadii[ii]*_atomicRadii[ii]*_atomicRadii[ii]) - bornSum;
_bornRadii[ii] = (bornSum <= zero) ? bigRadius : POW(bornSum, -oneThird);
bornSum = 1.0/(_atomicRadii[ii]*_atomicRadii[ii]*_atomicRadii[ii]) - bornSum;
_bornRadii[ii] = (bornSum <= 0.0) ? bigRadius : pow(bornSum, -1.0/3.0);
}
return;
......
......@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceGeneralizedKirkwoodForce_H__
#define __AmoebaReferenceGeneralizedKirkwoodForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
using namespace OpenMM;
......@@ -101,7 +101,7 @@ public:
*
* @return soluteDielectric
*/
RealOpenMM getSoluteDielectric() const;
double getSoluteDielectric() const;
/**
* Set solute dielectric
......@@ -109,7 +109,7 @@ public:
* @param soluteDielectric solute dielectric
*
*/
void setSoluteDielectric(RealOpenMM soluteDielectric);
void setSoluteDielectric(double soluteDielectric);
/**
* Get solvent dielectric
......@@ -117,7 +117,7 @@ public:
* @return solventDielectric
*
*/
RealOpenMM getSolventDielectric() const;
double getSolventDielectric() const;
/**
* Set solvent dielectric
......@@ -125,7 +125,7 @@ public:
* @param solventDielectric solvent dielectric
*
*/
void setSolventDielectric(RealOpenMM solventDielectric);
void setSolventDielectric(double solventDielectric);
/**
* Get dielectric offset
......@@ -133,7 +133,7 @@ public:
* @return dielectricOffset
*
*/
RealOpenMM getDielectricOffset() const;
double getDielectricOffset() const;
/**
* Set dielectric offset
......@@ -141,7 +141,7 @@ public:
* @param dielectricOffset dielectric offset
*
*/
void setDielectricOffset(RealOpenMM dielectricOffset);
void setDielectricOffset(double dielectricOffset);
/**
* Get probeRadius
......@@ -149,7 +149,7 @@ public:
* @return probeRadius
*
*/
RealOpenMM getProbeRadius() const;
double getProbeRadius() const;
/**
* Set probe radius
......@@ -157,7 +157,7 @@ public:
* @param probeRadius probe radiue
*
*/
void setProbeRadius(RealOpenMM probeRadius);
void setProbeRadius(double probeRadius);
/**
* Get surfaceAreaFactor
......@@ -165,7 +165,7 @@ public:
* @return surfaceAreaFactor
*
*/
RealOpenMM getSurfaceAreaFactor() const;
double getSurfaceAreaFactor() const;
/**
* Set surface area factor
......@@ -173,7 +173,7 @@ public:
* @param surfaceAreaFactor surface area factor
*
*/
void setSurfaceAreaFactor(RealOpenMM surfaceAreaFactor);
void setSurfaceAreaFactor(double surfaceAreaFactor);
/**
* Set atomic radii
......@@ -181,7 +181,7 @@ public:
* @param atomicRadii input vector of atomic radii
*
*/
void setAtomicRadii(const vector<RealOpenMM>& atomicRadii);
void setAtomicRadii(const vector<double>& atomicRadii);
/**
* Get atomic radii
......@@ -189,7 +189,7 @@ public:
* @param atomicRadii output vector of atomic radii
*
*/
void getAtomicRadii(vector<RealOpenMM>& atomicRadii) const;
void getAtomicRadii(vector<double>& atomicRadii) const;
/**
* Set scale factors
......@@ -197,7 +197,7 @@ public:
* @param scaleFactors input vector of scale factors
*
*/
void setScaleFactors(const vector<RealOpenMM>& scaleFactors);
void setScaleFactors(const vector<double>& scaleFactors);
/**
* Get scale factors
......@@ -205,7 +205,7 @@ public:
* @param scaleFactors output vector of scale factors
*
*/
void getScaleFactors(vector<RealOpenMM>& scaleFactors) const;
void getScaleFactors(vector<double>& scaleFactors) const;
/**
* Set charges
......@@ -213,7 +213,7 @@ public:
* @param charges input vector of charges
*
*/
void setCharges(const vector<RealOpenMM>& charges);
void setCharges(const vector<double>& charges);
/**
* Calculate Grycuk Born radii
......@@ -221,7 +221,7 @@ public:
* @param particlePositions particle positions
*
*/
void calculateGrycukBornRadii(const vector<RealVec>& particlePositions);
void calculateGrycukBornRadii(const vector<Vec3>& particlePositions);
/**
* Get Grycik Born radii (must have called calculateGrycukBornRadii())
......@@ -229,7 +229,7 @@ public:
* @param bornRadii vector of Born radii
*
*/
void getGrycukBornRadii(vector<RealOpenMM>& bornRadii) const;
void getGrycukBornRadii(vector<double>& bornRadii) const;
private:
......@@ -237,17 +237,17 @@ private:
int _includeCavityTerm;
int _directPolarization;
RealOpenMM _soluteDielectric;
RealOpenMM _solventDielectric;
RealOpenMM _dielectricOffset;
RealOpenMM _probeRadius;
RealOpenMM _surfaceAreaFactor;
double _soluteDielectric;
double _solventDielectric;
double _dielectricOffset;
double _probeRadius;
double _surfaceAreaFactor;
std::vector<RealOpenMM> _atomicRadii;
std::vector<RealOpenMM> _scaleFactors;
std::vector<RealOpenMM> _charges;
std::vector<double> _atomicRadii;
std::vector<double> _scaleFactors;
std::vector<double> _charges;
std::vector<RealOpenMM> _bornRadii;
std::vector<double> _bornRadii;
};
......
......@@ -25,11 +25,12 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceInPlaneAngleForce.h"
#include "ReferenceForce.h"
#include "SimTKOpenMMRealType.h"
using std::vector;
using namespace OpenMM;
void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::RealVec* vectors) {
void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
......@@ -54,49 +55,34 @@ void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(RealOpenMM cosine,
RealOpenMM idealAngle, RealOpenMM angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic,
RealOpenMM* dEdR) const {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
static const RealOpenMM four = 4.0;
static const RealOpenMM five = 5.0;
static const RealOpenMM six = 6.0;
// static const std::string methodName = "AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine";
// ---------------------------------------------------------------------------------------
RealOpenMM angle;
if (cosine >= one) {
angle = zero;
} else if (cosine <= -one) {
double AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(double cosine,
double idealAngle, double angleK,
double angleCubic, double angleQuartic,
double anglePentic, double angleSextic,
double* dEdR) const {
double angle;
if (cosine >= 1.0) {
angle = 0.0;
} else if (cosine <= -1.0) {
angle = RADIAN*PI_M;
} else {
angle = RADIAN*ACOS(cosine);
}
RealOpenMM deltaIdeal = angle - idealAngle;
RealOpenMM deltaIdeal2 = deltaIdeal*deltaIdeal;
RealOpenMM deltaIdeal3 = deltaIdeal*deltaIdeal2;
RealOpenMM deltaIdeal4 = deltaIdeal2*deltaIdeal2;
double deltaIdeal = angle - idealAngle;
double deltaIdeal2 = deltaIdeal*deltaIdeal;
double deltaIdeal3 = deltaIdeal*deltaIdeal2;
double deltaIdeal4 = deltaIdeal2*deltaIdeal2;
*dEdR = (two + three*angleCubic*deltaIdeal +
four*angleQuartic*deltaIdeal2 +
five*anglePentic*deltaIdeal3 +
six*angleSextic*deltaIdeal4);
*dEdR = (2.0 + 3.0*angleCubic*deltaIdeal +
4.0*angleQuartic*deltaIdeal2 +
5.0*anglePentic*deltaIdeal3 +
6.0*angleSextic*deltaIdeal4);
*dEdR *= RADIAN*angleK*deltaIdeal;
*dEdR *= RADIAN*angleK*deltaIdeal;
RealOpenMM energy = 1.0f + angleCubic*deltaIdeal + angleQuartic*deltaIdeal2 +
anglePentic*deltaIdeal3 + angleSextic*deltaIdeal4;
energy *= angleK*deltaIdeal2;
double energy = 1.0f + angleCubic*deltaIdeal + angleQuartic*deltaIdeal2 +
anglePentic*deltaIdeal3 + angleSextic*deltaIdeal4;
energy *= angleK*deltaIdeal2;
return energy;
......@@ -122,12 +108,12 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(RealO
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& positionAtomA, const RealVec& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD,
RealOpenMM angle, RealOpenMM angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic,
RealVec* forces) const {
double AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const Vec3& positionAtomC, const Vec3& positionAtomD,
double angle, double angleK,
double angleCubic, double angleQuartic,
double anglePentic, double angleSextic,
Vec3* forces) const {
// T = AD x CD
// P = B + T*delta
// AP = A - P
......@@ -136,7 +122,7 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
enum { AD, BD, CD, T, AP, P, CP, M, APxM, CPxM, ADxBD, BDxCD, TxCD, ADxT, dBxAD, CDxdB, LastDeltaAtomIndex };
RealVec deltaR[LastDeltaAtomIndex];
Vec3 deltaR[LastDeltaAtomIndex];
if (usePeriodic) {
deltaR[AD] = ReferenceForce::getDeltaRPeriodic(positionAtomD, positionAtomA, boxVectors);
deltaR[BD] = ReferenceForce::getDeltaRPeriodic(positionAtomD, positionAtomB, boxVectors);
......@@ -150,9 +136,8 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
deltaR[T] = deltaR[AD].cross(deltaR[CD]);
RealOpenMM rT2 = deltaR[T].dot(deltaR[T]);
RealOpenMM delta = deltaR[T].dot(deltaR[BD])/rT2;
delta *= -1;
double rT2 = deltaR[T].dot(deltaR[T]);
double delta = -deltaR[T].dot(deltaR[BD])/rT2;
deltaR[P] = positionAtomB + deltaR[T]*delta;
if (usePeriodic) {
......@@ -164,28 +149,28 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
deltaR[CP] = ReferenceForce::getDeltaR(deltaR[P], positionAtomC);
}
RealOpenMM rAp2 = deltaR[AP].dot(deltaR[AP]);
RealOpenMM rCp2 = deltaR[CP].dot(deltaR[CP]);
double rAp2 = deltaR[AP].dot(deltaR[AP]);
double rCp2 = deltaR[CP].dot(deltaR[CP]);
if (rAp2 <= 0 && rCp2 <= 0) {
return 0;
}
deltaR[M] = deltaR[CP].cross(deltaR[AP]);
RealOpenMM rm = SQRT(deltaR[M].dot(deltaR[M]));
double rm = sqrt(deltaR[M].dot(deltaR[M]));
if (rm < 1.0e-06) {
rm = 1.0e-06;
}
RealOpenMM dot = deltaR[AP].dot(deltaR[CP]);
RealOpenMM cosine = dot/SQRT(rAp2*rCp2);
double dot = deltaR[AP].dot(deltaR[CP]);
double cosine = dot/SQRT(rAp2*rCp2);
RealOpenMM dEdR;
RealOpenMM energy = getPrefactorsGivenAngleCosine(cosine, angle, angleK, angleCubic, angleQuartic,
double dEdR;
double energy = getPrefactorsGivenAngleCosine(cosine, angle, angleK, angleCubic, angleQuartic,
anglePentic, angleSextic, &dEdR);
RealOpenMM termA = -dEdR/(rAp2*rm);
RealOpenMM termC = dEdR/(rCp2*rm);
double termA = -dEdR/(rAp2*rm);
double termC = dEdR/(rCp2*rm);
deltaR[APxM] = deltaR[AP].cross(deltaR[M]);
deltaR[CPxM] = deltaR[CP].cross(deltaR[M]);
......@@ -193,27 +178,27 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
// forces will be gathered here
enum { dA, dB, dC, dD, LastDIndex };
RealVec forceTerm[LastDIndex];
Vec3 forceTerm[LastDIndex];
forceTerm[dA] = deltaR[APxM]*termA;
forceTerm[dC] = deltaR[CPxM]*termC;
forceTerm[dB] = -(forceTerm[dA] + forceTerm[dC]);
RealOpenMM pTrT2 = forceTerm[dB].dot(deltaR[T]);
pTrT2 /= rT2;
double pTrT2 = forceTerm[dB].dot(deltaR[T]);
pTrT2 /= rT2;
deltaR[CDxdB] = deltaR[CD].cross(forceTerm[dB]);
deltaR[dBxAD] = forceTerm[dB].cross(deltaR[AD]);
if (FABS(pTrT2) > 1.0e-08) {
RealOpenMM delta2 = delta*2;
double delta2 = delta*2;
deltaR[BDxCD] = forceTerm[dB].cross(deltaR[CD]);
deltaR[TxCD] = forceTerm[T].cross(deltaR[CD]);
deltaR[ADxBD] = forceTerm[AD].cross(deltaR[BD]);
deltaR[ADxT] = forceTerm[AD].cross(deltaR[T]);
RealVec term = deltaR[BDxCD] + deltaR[TxCD]*delta2;
Vec3 term = deltaR[BDxCD] + deltaR[TxCD]*delta2;
forceTerm[dA] += deltaR[CDxdB]*delta + term*pTrT2;
term = deltaR[ADxBD] + deltaR[ADxT]*delta2;
forceTerm[dC] += deltaR[dBxAD]*delta + term*pTrT2;
......@@ -233,29 +218,29 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
}
RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateForceAndEnergy(int numAngles, vector<RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<RealOpenMM>& angle,
const std::vector<RealOpenMM>& kQuadratic,
RealOpenMM angleCubic,
RealOpenMM angleQuartic,
RealOpenMM anglePentic,
RealOpenMM angleSextic,
vector<RealVec>& forceData) const {
RealOpenMM energy = 0.0;
double AmoebaReferenceInPlaneAngleForce::calculateForceAndEnergy(int numAngles, vector<Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<double>& angle,
const std::vector<double>& kQuadratic,
double angleCubic,
double angleQuartic,
double anglePentic,
double angleSextic,
vector<Vec3>& forceData) const {
double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numAngles); ii++) {
int particle1Index = particle1[ii];
int particle2Index = particle2[ii];
int particle3Index = particle3[ii];
int particle4Index = particle4[ii];
RealOpenMM idealAngle = angle[ii];
RealOpenMM angleK = kQuadratic[ii];
RealVec forces[4];
energy += calculateAngleIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], posData[particle4Index],
idealAngle, angleK, angleCubic, angleQuartic, anglePentic, angleSextic, forces);
int particle1Index = particle1[ii];
int particle2Index = particle2[ii];
int particle3Index = particle3[ii];
int particle4Index = particle4[ii];
double idealAngle = angle[ii];
double angleK = kQuadratic[ii];
Vec3 forces[4];
energy += calculateAngleIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], posData[particle4Index],
idealAngle, angleK, angleCubic, angleQuartic, anglePentic, angleSextic, forces);
// accumulate forces
......
......@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceInPlaneAngleForce_H__
#define __AmoebaReferenceInPlaneAngleForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
namespace OpenMM {
......@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
void setPeriodic(OpenMM::Vec3* vectors);
/**---------------------------------------------------------------------------------------
......@@ -83,23 +83,23 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numAngles, std::vector<OpenMM::RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<RealOpenMM>& angle,
const std::vector<RealOpenMM>& kQuadratic,
RealOpenMM globalAngleCubic,
RealOpenMM globalAngleQuartic,
RealOpenMM globalAnglePentic,
RealOpenMM globalAngleSextic,
std::vector<OpenMM::RealVec>& forceData) const;
double calculateForceAndEnergy(int numAngles, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<double>& angle,
const std::vector<double>& kQuadratic,
double globalAngleCubic,
double globalAngleQuartic,
double globalAnglePentic,
double globalAngleSextic,
std::vector<OpenMM::Vec3>& forceData) const;
private:
bool usePeriodic;
RealVec boxVectors[3];
Vec3 boxVectors[3];
/**---------------------------------------------------------------------------------------
......@@ -119,11 +119,11 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM getPrefactorsGivenAngleCosine(RealOpenMM cosine, RealOpenMM idealAngle, RealOpenMM angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic,
RealOpenMM* dEdR) const;
double getPrefactorsGivenAngleCosine(double cosine, double idealAngle, double angleK,
double angleCubic, double angleQuartic,
double anglePentic, double angleSextic,
double* dEdR) const;
/**---------------------------------------------------------------------------------------
Calculate Amoeba angle ixn (force and energy)
......@@ -144,12 +144,12 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateAngleIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD,
RealOpenMM angle, RealOpenMM angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic,
OpenMM::RealVec* forces) const;
double calculateAngleIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
double angle, double angleK,
double angleCubic, double angleQuartic,
double anglePentic, double angleSextic,
OpenMM::Vec3* forces) const;
};
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -24,8 +24,8 @@
#ifndef __AmoebaReferenceMultipoleForce_H__
#define __AmoebaReferenceMultipoleForce_H__
#include "RealVec.h"
#include "openmm/AmoebaMultipoleForce.h"
#include "openmm/Vec3.h"
#include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include <map>
#include "fftpack.h"
......@@ -33,22 +33,22 @@
namespace OpenMM {
typedef std::map< unsigned int, RealOpenMM> MapIntRealOpenMM;
typedef std::map< unsigned int, double> MapIntRealOpenMM;
typedef MapIntRealOpenMM::iterator MapIntRealOpenMMI;
typedef MapIntRealOpenMM::const_iterator MapIntRealOpenMMCI;
// A few useful constants for the spherical harmonic multipole code.
const RealOpenMM oneThird = 1.0/3.0;
const RealOpenMM twoThirds = 2.0/3.0;
const RealOpenMM fourThirds = 4.0/3.0;
const RealOpenMM fourSqrtOneThird = 4.0/sqrt(3.0);
const RealOpenMM sqrtFourThirds = 2.0/sqrt(3.0);
const RealOpenMM sqrtOneThird = 1.0/sqrt(3.0);
const RealOpenMM sqrtThree = sqrt(3.0);
const RealOpenMM oneNinth = 1.0/9.0;
const RealOpenMM fourOverFortyFive = 4.0/45.0;
const RealOpenMM fourOverFifteen = 4.0/15.0;
const double oneThird = 1.0/3.0;
const double twoThirds = 2.0/3.0;
const double fourThirds = 4.0/3.0;
const double fourSqrtOneThird = 4.0/sqrt(3.0);
const double sqrtFourThirds = 2.0/sqrt(3.0);
const double sqrtOneThird = 1.0/sqrt(3.0);
const double sqrtThree = sqrt(3.0);
const double oneNinth = 1.0/9.0;
const double fourOverFortyFive = 4.0/45.0;
const double fourOverFifteen = 4.0/15.0;
/**
......@@ -167,30 +167,30 @@ private:
};
/**
* 4-dimensional RealOpenMM vector
* 4-dimensional double vector
*/
class RealOpenMM4 {
class double4 {
public:
/**
* Create a RealOpenMM4 whose elements are all 0.
* Create a double4 whose elements are all 0.
*/
RealOpenMM4() {
double4() {
data[0] = data[1] = data[2] = data[3] = 0.0;
}
/**
* Create a RealOpenMM4 with specified x, y, z, w components.
* Create a double4 with specified x, y, z, w components.
*/
RealOpenMM4(RealOpenMM x, RealOpenMM y, RealOpenMM z, RealOpenMM w) {
double4(double x, double y, double z, double w) {
data[0] = x;
data[1] = y;
data[2] = z;
data[3] = w;
}
RealOpenMM operator[](int index) const {
double operator[](int index) const {
assert(index >= 0 && index < 4);
return data[index];
}
RealOpenMM& operator[](int index) {
double& operator[](int index) {
assert(index >= 0 && index < 4);
return data[index];
}
......@@ -198,17 +198,17 @@ public:
// Arithmetic operators
// unary plus
RealOpenMM4 operator+() const {
return RealOpenMM4(*this);
double4 operator+() const {
return double4(*this);
}
// plus
RealOpenMM4 operator+(const RealOpenMM4& rhs) const {
const RealOpenMM4& lhs = *this;
return RealOpenMM4(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2],lhs[3] + rhs[3]);
double4 operator+(const double4& rhs) const {
const double4& lhs = *this;
return double4(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2],lhs[3] + rhs[3]);
}
RealOpenMM4& operator+=(const RealOpenMM4& rhs) {
double4& operator+=(const double4& rhs) {
data[0] += rhs[0];
data[1] += rhs[1];
data[2] += rhs[2];
......@@ -216,7 +216,7 @@ public:
return *this;
}
RealOpenMM4& operator-=(const RealOpenMM4& rhs) {
double4& operator-=(const double4& rhs) {
data[0] -= rhs[0];
data[1] -= rhs[1];
data[2] -= rhs[2];
......@@ -225,7 +225,7 @@ public:
}
private:
RealOpenMM data[4];
double data[4];
};
using namespace OpenMM;
......@@ -425,7 +425,7 @@ public:
* @return epsilon
*
*/
RealOpenMM getMutualInducedDipoleEpsilon() const;
double getMutualInducedDipoleEpsilon() const;
/**
* Set the coefficients for the µ_0, µ_1, µ_2, µ_n terms in the extrapolation
......@@ -434,7 +434,7 @@ public:
* @param optCoefficients a vector whose mth entry specifies the coefficient for µ_m
*
*/
void setExtrapolationCoefficients(const std::vector<RealOpenMM> &coefficients);
void setExtrapolationCoefficients(const std::vector<double> &coefficients);
/**
* Set the target epsilon for converging mutual induced dipoles.
......@@ -442,7 +442,7 @@ public:
* @param targetEpsilon target epsilon for converging mutual induced dipoles
*
*/
void setMutualInducedDipoleTargetEpsilon(RealOpenMM targetEpsilon);
void setMutualInducedDipoleTargetEpsilon(double targetEpsilon);
/**
* Get the target epsilon for converging mutual induced dipoles.
......@@ -450,7 +450,7 @@ public:
* @return target epsilon for converging mutual induced dipoles
*
*/
RealOpenMM getMutualInducedDipoleTargetEpsilon() const;
double getMutualInducedDipoleTargetEpsilon() const;
/**
* Set the maximum number of iterations to be executed in converging mutual induced dipoles.
......@@ -487,19 +487,19 @@ public:
*
* @return energy
*/
RealOpenMM calculateForceAndEnergy(const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo,
std::vector<OpenMM::RealVec>& forces);
double calculateForceAndEnergy(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo,
std::vector<OpenMM::Vec3>& forces);
/**
* Calculate particle induced dipoles.
......@@ -519,19 +519,19 @@ public:
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param outputMultipoleMoments output multipole moments
*/
void calculateInducedDipoles(const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
void calculateInducedDipoles(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo,
std::vector<RealVec>& outputInducedDipoles);
std::vector<Vec3>& outputInducedDipoles);
/**
* Calculate particle permanent dipoles rotated in the lab frame.
......@@ -552,19 +552,19 @@ public:
* @param outputMultipoleMoments output multipole moments
*/
void calculateLabFramePermanentDipoles(const std::vector<RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
void calculateLabFramePermanentDipoles(const std::vector<Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< vector< vector<int> > >& multipoleAtomCovalentInfo,
std::vector<RealVec>& outputRotatedPermanentDipoles);
std::vector<Vec3>& outputRotatedPermanentDipoles);
/**
* Calculate particle total dipoles.
......@@ -586,19 +586,19 @@ public:
*/
void calculateTotalDipoles(const std::vector<RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< vector< vector<int> > >& multipoleAtomCovalentInfo,
std::vector<RealVec>& outputRotatedPermanentDipoles);
void calculateTotalDipoles(const std::vector<Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< vector< vector<int> > >& multipoleAtomCovalentInfo,
std::vector<Vec3>& outputRotatedPermanentDipoles);
......@@ -620,20 +620,20 @@ public:
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param outputMultipoleMoments output multipole moments
*/
void calculateAmoebaSystemMultipoleMoments(const std::vector<RealOpenMM>& masses,
const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
void calculateAmoebaSystemMultipoleMoments(const std::vector<double>& masses,
const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo,
std::vector<RealOpenMM>& outputMultipoleMoments);
std::vector<double>& outputMultipoleMoments);
/**
* Calculate electrostatic potential at a set of grid points.
......@@ -653,20 +653,20 @@ public:
* @param input grid input grid points to compute potential
* @param outputPotential output electrostatic potential
*/
void calculateElectrostaticPotential(const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
void calculateElectrostaticPotential(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo,
const std::vector<RealVec>& inputGrid,
std::vector<RealOpenMM>& outputPotential);
const std::vector<Vec3>& inputGrid,
std::vector<double>& outputPotential);
protected:
......@@ -682,15 +682,15 @@ protected:
class MultipoleParticleData {
public:
unsigned int particleIndex;
RealVec position;
RealOpenMM charge;
RealVec dipole;
RealOpenMM quadrupole[6];
RealVec sphericalDipole;
RealOpenMM sphericalQuadrupole[5];
RealOpenMM thole;
RealOpenMM dampingFactor;
RealOpenMM polarity;
Vec3 position;
double charge;
Vec3 dipole;
double quadrupole[6];
Vec3 sphericalDipole;
double sphericalQuadrupole[5];
double thole;
double dampingFactor;
double polarity;
};
/**
......@@ -698,22 +698,22 @@ protected:
*/
class TransformedMultipole {
public:
RealOpenMM charge;
RealVec dipole;
RealOpenMM quadrupole[6];
double charge;
Vec3 dipole;
double quadrupole[6];
};
/*
* Helper class used in calculating induced dipoles
*/
struct UpdateInducedDipoleFieldStruct {
UpdateInducedDipoleFieldStruct(std::vector<OpenMM::RealVec>& inputFixed_E_Field, std::vector<OpenMM::RealVec>& inputInducedDipoles, std::vector<std::vector<RealVec> >& extrapolatedDipoles, std::vector<std::vector<RealOpenMM> >& extrapolatedDipoleFieldGradient);
std::vector<OpenMM::RealVec>* fixedMultipoleField;
std::vector<OpenMM::RealVec>* inducedDipoles;
std::vector<std::vector<RealVec> >* extrapolatedDipoles;
std::vector<std::vector<RealOpenMM> >* extrapolatedDipoleFieldGradient;
std::vector<OpenMM::RealVec> inducedDipoleField;
std::vector<std::vector<RealOpenMM> > inducedDipoleFieldGradient;
UpdateInducedDipoleFieldStruct(std::vector<OpenMM::Vec3>& inputFixed_E_Field, std::vector<OpenMM::Vec3>& inputInducedDipoles, std::vector<std::vector<Vec3> >& extrapolatedDipoles, std::vector<std::vector<double> >& extrapolatedDipoleFieldGradient);
std::vector<OpenMM::Vec3>* fixedMultipoleField;
std::vector<OpenMM::Vec3>* inducedDipoles;
std::vector<std::vector<Vec3> >* extrapolatedDipoles;
std::vector<std::vector<double> >* extrapolatedDipoleFieldGradient;
std::vector<OpenMM::Vec3> inducedDipoleField;
std::vector<std::vector<double> > inducedDipoleFieldGradient;
};
unsigned int _numParticles;
......@@ -721,37 +721,37 @@ protected:
NonbondedMethod _nonbondedMethod;
PolarizationType _polarizationType;
RealOpenMM _electric;
RealOpenMM _dielectric;
double _electric;
double _dielectric;
enum ScaleType { D_SCALE, P_SCALE, M_SCALE, U_SCALE, LAST_SCALE_TYPE_INDEX };
std::vector< std::vector< MapIntRealOpenMM > > _scaleMaps;
std::vector<unsigned int> _maxScaleIndex;
RealOpenMM _dScale[5];
RealOpenMM _pScale[5];
RealOpenMM _mScale[5];
RealOpenMM _uScale[5];
double _dScale[5];
double _pScale[5];
double _mScale[5];
double _uScale[5];
std::vector<TransformedMultipole> _transformed;
std::vector<RealVec> _fixedMultipoleField;
std::vector<RealVec> _fixedMultipoleFieldPolar;
std::vector<RealVec> _inducedDipole;
std::vector<RealVec> _inducedDipolePolar;
std::vector<std::vector<RealVec> > _ptDipoleP;
std::vector<std::vector<RealVec> > _ptDipoleD;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientP;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientD;
std::vector<Vec3> _fixedMultipoleField;
std::vector<Vec3> _fixedMultipoleFieldPolar;
std::vector<Vec3> _inducedDipole;
std::vector<Vec3> _inducedDipolePolar;
std::vector<std::vector<Vec3> > _ptDipoleP;
std::vector<std::vector<Vec3> > _ptDipoleD;
std::vector<std::vector<double> > _ptDipoleFieldGradientP;
std::vector<std::vector<double> > _ptDipoleFieldGradientD;
int _mutualInducedDipoleConverged;
int _mutualInducedDipoleIterations;
int _maximumMutualInducedDipoleIterations;
int _maxPTOrder;
std::vector<RealOpenMM> _extrapolationCoefficients;
std::vector<RealOpenMM> _extPartCoefficients;
RealOpenMM _mutualInducedDipoleEpsilon;
RealOpenMM _mutualInducedDipoleTargetEpsilon;
RealOpenMM _polarSOR;
RealOpenMM _debye;
std::vector<double> _extrapolationCoefficients;
std::vector<double> _extPartCoefficients;
double _mutualInducedDipoleEpsilon;
double _mutualInducedDipoleTargetEpsilon;
double _polarSOR;
double _debye;
/**
* Helper constructor method to centralize initialization of objects.
......@@ -772,13 +772,13 @@ protected:
* @param particleData output data struct
*
*/
void loadParticleData(const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
void loadParticleData(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
std::vector<MultipoleParticleData>& particleData) const;
/**
......@@ -811,7 +811,7 @@ protected:
* @param epsilon
*
*/
void setMutualInducedDipoleEpsilon(RealOpenMM epsilon);
void setMutualInducedDipoleEpsilon(double epsilon);
/**
* Setup scale factors given covalent info.
......@@ -830,7 +830,7 @@ protected:
*
* @return scaleFactor
*/
RealOpenMM getMultipoleScaleFactor(unsigned int particleI, unsigned int particleJ, ScaleType scaleType) const;
double getMultipoleScaleFactor(unsigned int particleI, unsigned int particleJ, ScaleType scaleType) const;
/**
* Get scale factor for particleI & particleJ
......@@ -841,7 +841,7 @@ protected:
*
* @return array of scaleFactors
*/
void getMultipoleScaleFactors(unsigned int particleI, unsigned int particleJ, std::vector<RealOpenMM>& scaleFactors) const;
void getMultipoleScaleFactors(unsigned int particleI, unsigned int particleJ, std::vector<double>& scaleFactors) const;
/**
* Get p- and d-scale factors for particleI & particleJ ixn
......@@ -851,7 +851,7 @@ protected:
* @param dScale output d-scale factor
* @param pScale output p-scale factor
*/
void getDScaleAndPScale(unsigned int particleI, unsigned int particleJ, RealOpenMM& dScale, RealOpenMM& pScale) const;
void getDScaleAndPScale(unsigned int particleI, unsigned int particleJ, double& dScale, double& pScale) const;
/**
* Calculate damped powers of 1/r.
......@@ -861,8 +861,8 @@ protected:
* @param dScale output d-scale factor
* @param pScale output p-scale factor
*/
void getAndScaleInverseRs(RealOpenMM dampI, RealOpenMM dampJ, RealOpenMM tholeI, RealOpenMM tholeJ,
RealOpenMM r, std::vector<RealOpenMM>& rrI) const;
void getAndScaleInverseRs(double dampI, double dampJ, double tholeI, double tholeJ,
double r, std::vector<double>& rrI) const;
/**
* Check if multipoles at chiral site should be inverted.
......@@ -915,11 +915,11 @@ protected:
* @param r the bond length between atoms I and J
* @param rotationmatrix the output rotation matrix for a 3-vector
*/
void formQIRotationMatrix(const RealVec& iPosition,
const RealVec& jPosition,
const RealVec &deltaR,
RealOpenMM r,
RealOpenMM (&rotationMatrix)[3][3]) const;
void formQIRotationMatrix(const Vec3& iPosition,
const Vec3& jPosition,
const Vec3 &deltaR,
double r,
double (&rotationMatrix)[3][3]) const;
/**
......@@ -928,7 +928,7 @@ protected:
* @param D1 The input spherical harmonic dipole rotation matrix
* @param D2 The output spherical harmonic quadrupole rotation matrix
*/
void buildSphericalQuadrupoleRotationMatrix(const RealOpenMM (&D1)[3][3], RealOpenMM (&D2)[5][5]) const;
void buildSphericalQuadrupoleRotationMatrix(const double (&D1)[3][3], double (&D2)[5][5]) const;
/**
* Constructs a rotation matrix for spherical harmonic quadrupoles, using the dipole rotation matrix.
......@@ -937,7 +937,7 @@ protected:
* @param D1 The input spherical harmonic dipole rotation matrix
* @param D2 The output spherical harmonic quadrupole rotation matrix
*/
void buildPartialSphericalQuadrupoleRotationMatrix(const RealOpenMM (&D1)[3][3], RealOpenMM (&D2)[3][5]) const;
void buildPartialSphericalQuadrupoleRotationMatrix(const double (&D1)[3][3], double (&D2)[3][5]) const;
/**
* Apply rotation matrix to molecular dipole/quadrupoles to get corresponding lab frame values.
......@@ -969,7 +969,7 @@ protected:
* @param pScale p-scale value for i-j interaction
*/
virtual void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dScale, RealOpenMM pScale);
double dScale, double pScale);
/**
* Initialize induced dipoles
......@@ -991,9 +991,9 @@ protected:
* @param field vector of induced dipole fields
*/
void calculateInducedDipolePairIxn(unsigned int particleI, unsigned int particleJ,
RealOpenMM rr3, RealOpenMM rr5, const RealVec& delta,
const std::vector<RealVec>& inducedDipole,
std::vector<RealVec>& field) const;
double rr3, double rr5, const Vec3& delta,
const std::vector<Vec3>& inducedDipole,
std::vector<Vec3>& field) const;
/**
* Calculate fields due induced dipoles at each site.
......@@ -1044,7 +1044,7 @@ protected:
* @param prevErrors the vector of errors from previous iterations
* @param coefficients the coefficients will be stored into this
*/
void computeDIISCoefficients(const std::vector<std::vector<RealVec> >& prevErrors, std::vector<RealOpenMM>& coefficients) const;
void computeDIISCoefficients(const std::vector<std::vector<Vec3> >& prevErrors, std::vector<double>& coefficients) const;
/**
* Update fields due to induced dipoles for each particle.
......@@ -1052,8 +1052,8 @@ protected:
* @param particleData vector of particle positions and parameters (charge, labFrame dipoles, quadrupoles, ...)
* @param updateInducedDipoleFields vector of UpdateInducedDipoleFieldStruct containing input induced dipoles and output fields
*/
RealOpenMM updateInducedDipoleFields(const std::vector<MultipoleParticleData>& particleData,
std::vector<UpdateInducedDipoleFieldStruct>& calculateInducedDipoleField);
double updateInducedDipoleFields(const std::vector<MultipoleParticleData>& particleData,
std::vector<UpdateInducedDipoleFieldStruct>& calculateInducedDipoleField);
/**
* Update induced dipole for a particle given updated induced dipole field at the site.
......@@ -1063,10 +1063,10 @@ protected:
* @param inducedDipoleField fields due induced dipoles at each site
* @param inducedDipoles output vector of updated induced dipoles
*/
RealOpenMM updateInducedDipole(const std::vector<MultipoleParticleData>& particleI,
const std::vector<RealVec>& fixedMultipoleField,
const std::vector<RealVec>& inducedDipoleField,
std::vector<RealVec>& inducedDipoles);
double updateInducedDipole(const std::vector<MultipoleParticleData>& particleI,
const std::vector<Vec3>& fixedMultipoleField,
const std::vector<Vec3>& inducedDipoleField,
std::vector<Vec3>& inducedDipoles);
/**
* Calculate induced dipoles.
......@@ -1097,13 +1097,13 @@ protected:
* @param particleData output vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
*
*/
void setup(const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<RealOpenMM>& charges,
const std::vector<RealOpenMM>& dipoles,
const std::vector<RealOpenMM>& quadrupoles,
const std::vector<RealOpenMM>& tholes,
const std::vector<RealOpenMM>& dampingFactors,
const std::vector<RealOpenMM>& polarity,
void setup(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<double>& charges,
const std::vector<double>& dipoles,
const std::vector<double>& quadrupoles,
const std::vector<double>& tholes,
const std::vector<double>& dampingFactors,
const std::vector<double>& polarity,
const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs,
......@@ -1120,8 +1120,8 @@ protected:
* @param forces vector of particle forces to be updated
* @param torque vector of particle torques to be updated
*/
RealOpenMM calculateElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleK,
const std::vector<RealOpenMM>& scalingFactors, std::vector<OpenMM::RealVec>& forces, std::vector<RealVec>& torque) const;
double calculateElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleK,
const std::vector<double>& scalingFactors, std::vector<OpenMM::Vec3>& forces, std::vector<Vec3>& torque) const;
/**
* Map particle torque to force.
......@@ -1138,7 +1138,7 @@ protected:
const MultipoleParticleData& particleU,
const MultipoleParticleData& particleV,
MultipoleParticleData* particleW,
int axisType, const Vec3& torque, std::vector<OpenMM::RealVec>& forces) const;
int axisType, const Vec3& torque, std::vector<OpenMM::Vec3>& forces) const;
/**
* Map torques to forces.
......@@ -1156,8 +1156,8 @@ protected:
const std::vector<int>& multipoleAtomYs,
const std::vector<int>& multipoleAtomZs,
const std::vector<int>& axisTypes,
std::vector<OpenMM::RealVec>& torques,
std::vector<OpenMM::RealVec>& forces) const;
std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::Vec3>& forces) const;
/**
* Calculate electrostatic forces
......@@ -1168,44 +1168,44 @@ protected:
*
* @return energy
*/
virtual RealOpenMM calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::RealVec>& torques,
std::vector<OpenMM::RealVec>& forces);
virtual double calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::Vec3>& forces);
/**
* Normalize a RealVec
* Normalize a Vec3
*
* @param vectorToNormalize vector to normalize
*
* @return norm of vector on input
*
*/
RealOpenMM normalizeRealVec(RealVec& vectorToNormalize) const;
double normalizeVec3(Vec3& vectorToNormalize) const;
/**
* Initialize vector of RealOpenMM (size=numParticles)
* Initialize vector of double (size=numParticles)
*
* @param vectorToInitialize vector to initialize
*
*/
void initializeRealOpenMMVector(vector<RealOpenMM>& vectorToInitialize) const;
void initializeRealOpenMMVector(vector<double>& vectorToInitialize) const;
/**
* Initialize vector of RealVec (size=numParticles)
* Initialize vector of Vec3 (size=numParticles)
*
* @param vectorToInitialize vector to initialize
*
*/
void initializeRealVecVector(vector<RealVec>& vectorToInitialize) const;
void initializeVec3Vector(vector<Vec3>& vectorToInitialize) const;
/**
* Copy vector of RealVec
* Copy vector of Vec3
*
* @param inputVector vector to copy
* @param outputVector output vector
*
*/
void copyRealVecVector(const std::vector<OpenMM::RealVec>& inputVector, std::vector<OpenMM::RealVec>& outputVector) const;
void copyVec3Vector(const std::vector<OpenMM::Vec3>& inputVector, std::vector<OpenMM::Vec3>& outputVector) const;
/**
* Calculate potential at grid point due to a particle
......@@ -1216,7 +1216,7 @@ protected:
* @return potential at grid point
*
*/
RealOpenMM calculateElectrostaticPotentialForParticleGridPoint(const MultipoleParticleData& particleI, const RealVec& gridPoint) const;
double calculateElectrostaticPotentialForParticleGridPoint(const MultipoleParticleData& particleI, const Vec3& gridPoint) const;
/**
* Apply periodic boundary conditions to difference in positions
......@@ -1224,7 +1224,7 @@ protected:
* @param deltaR difference in particle positions; modified on output after applying PBC
*
*/
virtual void getPeriodicDelta(RealVec& deltaR) const {};
virtual void getPeriodicDelta(Vec3& deltaR) const {};
};
class AmoebaReferenceGeneralizedKirkwoodMultipoleForce : public AmoebaReferenceMultipoleForce {
......@@ -1257,7 +1257,7 @@ public:
* @return probe radius
*
*/
RealOpenMM getProbeRadius() const;
double getProbeRadius() const;
/**
* Get surface area factor.
......@@ -1265,7 +1265,7 @@ public:
* @return surface area factor
*
*/
RealOpenMM getSurfaceAreaFactor() const;
double getSurfaceAreaFactor() const;
/**
* Get dielectric offset.
......@@ -1273,34 +1273,34 @@ public:
* @return dielectric offset
*
*/
RealOpenMM getDielectricOffset() const;
double getDielectricOffset() const;
private:
AmoebaReferenceGeneralizedKirkwoodForce* _amoebaReferenceGeneralizedKirkwoodForce;
RealOpenMM _gkc;
RealOpenMM _fc;
RealOpenMM _fd;
RealOpenMM _fq;
double _gkc;
double _fc;
double _fd;
double _fq;
std::vector<RealOpenMM> _atomicRadii;
std::vector<RealOpenMM> _scaledRadii;
std::vector<RealOpenMM> _bornRadii;
std::vector<RealOpenMM> _bornForce;
std::vector<double> _atomicRadii;
std::vector<double> _scaledRadii;
std::vector<double> _bornRadii;
std::vector<double> _bornForce;
std::vector<RealVec> _gkField;
std::vector<RealVec> _inducedDipoleS;
std::vector<RealVec> _inducedDipolePolarS;
std::vector<std::vector<RealVec> > _ptDipolePS;
std::vector<std::vector<RealVec> > _ptDipoleDS;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientPS;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientDS;
std::vector<Vec3> _gkField;
std::vector<Vec3> _inducedDipoleS;
std::vector<Vec3> _inducedDipolePolarS;
std::vector<std::vector<Vec3> > _ptDipolePS;
std::vector<std::vector<Vec3> > _ptDipoleDS;
std::vector<std::vector<double> > _ptDipoleFieldGradientPS;
std::vector<std::vector<double> > _ptDipoleFieldGradientDS;
int _includeCavityTerm;
RealOpenMM _probeRadius;
RealOpenMM _surfaceAreaFactor;
RealOpenMM _dielectricOffset;
double _probeRadius;
double _surfaceAreaFactor;
double _dielectricOffset;
/**
* Zero fixed multipole fields.
......@@ -1318,7 +1318,7 @@ private:
* @param pScale p-scale value for i-j interaction
*/
void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dScale, RealOpenMM pScale);
double dScale, double pScale);
/**
* Calculate induced dipoles.
......@@ -1346,9 +1346,9 @@ private:
*
* @return energy
*/
RealOpenMM calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::RealVec>& torques,
std::vector<OpenMM::RealVec>& forces);
double calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::Vec3>& forces);
/**
* Calculate GK field at particle I due induced dipole at particle J and vice versa
......@@ -1360,7 +1360,7 @@ private:
* @param fieldPolar vector of induced dipole polar fields
*/
void calculateInducedDipolePairGkIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
const std::vector<RealVec>& field, std::vector<RealVec>& fieldPolar) const;
const std::vector<Vec3>& field, std::vector<Vec3>& fieldPolar) const;
/**
* Calculate Kirkwood interaction.
......@@ -1373,10 +1373,10 @@ private:
*
* @return energy
*/
RealOpenMM calculateKirkwoodPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
std::vector<RealVec>& forces,
std::vector<RealVec>& torques,
std::vector<RealOpenMM>& dBorn) const;
double calculateKirkwoodPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
std::vector<Vec3>& forces,
std::vector<Vec3>& torques,
std::vector<double>& dBorn) const;
/**
* Calculate Grycuk 'chain-rule' force.
......@@ -1388,7 +1388,7 @@ private:
*
*/
void calculateGrycukChainRulePairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
const std::vector<RealOpenMM>& dBorn, std::vector<RealVec>& forces) const;
const std::vector<double>& dBorn, std::vector<Vec3>& forces) const;
/**
* Calculate TINKER's ACE approximation to non-polar cavity term.
......@@ -1398,7 +1398,7 @@ private:
* @return ACE energy
*
*/
RealOpenMM calculateCavityTermEnergyAndForces(std::vector<RealOpenMM>& dBorn) const;
double calculateCavityTermEnergyAndForces(std::vector<double>& dBorn) const;
/**
* Correct vacuum to SCRF derivatives (TINKER's ediff1()).
......@@ -1412,9 +1412,9 @@ private:
*
* @return energy
*/
RealOpenMM calculateKirkwoodEDiffPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM pscale, RealOpenMM dscale,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const;
double calculateKirkwoodEDiffPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
double pscale, double dscale,
std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
};
......@@ -1440,7 +1440,7 @@ public:
* @return cutoff distance
*
*/
RealOpenMM getCutoffDistance() const;
double getCutoffDistance() const;
/**
* Set cutoff distance.
......@@ -1448,7 +1448,7 @@ public:
* @return cutoff distance
*
*/
void setCutoffDistance(RealOpenMM cutoffDistance);
void setCutoffDistance(double cutoffDistance);
/**
* Get alpha used in Ewald summation.
......@@ -1456,7 +1456,7 @@ public:
* @return alpha
*
*/
RealOpenMM getAlphaEwald() const;
double getAlphaEwald() const;
/**
* Set alpha used in Ewald summation.
......@@ -1464,7 +1464,7 @@ public:
* @return alpha
*
*/
void setAlphaEwald(RealOpenMM alphaEwald);
void setAlphaEwald(double alphaEwald);
/**
* Get PME grid dimensions.
......@@ -1488,19 +1488,19 @@ public:
*
* @param vectors the vectors defining the periodic box
*/
void setPeriodicBoxSize(OpenMM::RealVec* vectors);
void setPeriodicBoxSize(OpenMM::Vec3* vectors);
private:
static const int AMOEBA_PME_ORDER;
static const RealOpenMM SQRT_PI;
static const double SQRT_PI;
RealOpenMM _alphaEwald;
RealOpenMM _cutoffDistance;
RealOpenMM _cutoffDistanceSquared;
double _alphaEwald;
double _cutoffDistance;
double _cutoffDistanceSquared;
RealVec _recipBoxVectors[3];
RealVec _periodicBoxVectors[3];
Vec3 _recipBoxVectors[3];
Vec3 _periodicBoxVectors[3];
int _totalGridSize;
IntVec _pmeGridDimensions;
......@@ -1510,15 +1510,15 @@ private:
unsigned int _pmeGridSize;
t_complex* _pmeGrid;
std::vector<RealOpenMM> _pmeBsplineModuli[3];
std::vector<RealOpenMM4> _thetai[3];
std::vector<double> _pmeBsplineModuli[3];
std::vector<double4> _thetai[3];
std::vector<IntVec> _iGrid;
std::vector<RealOpenMM> _phi;
std::vector<RealOpenMM> _phid;
std::vector<RealOpenMM> _phip;
std::vector<RealOpenMM> _phidp;
std::vector<RealOpenMM4> _pmeBsplineTheta;
std::vector<RealOpenMM4> _pmeBsplineDtheta;
std::vector<double> _phi;
std::vector<double> _phid;
std::vector<double> _phip;
std::vector<double> _phidp;
std::vector<double4> _pmeBsplineTheta;
std::vector<double4> _pmeBsplineDtheta;
/**
* Resize PME arrays.
......@@ -1537,7 +1537,7 @@ private:
* @param delta input vector of difference in particle positions; on output adjusted for
* periodic boundary conditions
*/
void getPeriodicDelta(RealVec& deltaR) const;
void getPeriodicDelta(Vec3& deltaR) const;
/**
* Calculate damped inverse distances.
......@@ -1550,8 +1550,8 @@ private:
* @param dampedPInverseDistances damped inverse distances (prr3,prr5,prr7 in udirect2a() in TINKER)
*/
void getDampedInverseDistances(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dscale, RealOpenMM pscale, RealOpenMM r,
RealVec& dampedDInverseDistances, RealVec& dampedPInverseDistances) const;
double dscale, double pscale, double r,
Vec3& dampedDInverseDistances, Vec3& dampedPInverseDistances) const;
/**
* Initialize B-spline moduli.
......@@ -1568,7 +1568,7 @@ private:
* @param pScale p-scale value for i-j interaction
*/
void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dscale, RealOpenMM pscale);
double dscale, double pscale);
/**
* Calculate fixed multipole fields.
......@@ -1584,7 +1584,7 @@ private:
* @param thetai output spline coefficients
* @param w offset from grid point
*/
void computeBSplinePoint(std::vector<RealOpenMM4>& thetai, RealOpenMM w);
void computeBSplinePoint(std::vector<double4>& thetai, double w);
/**
* Compute bspline coefficients.
......@@ -1601,7 +1601,7 @@ private:
/**
* Transform potential from fractional coordinates to cartesian coordinates.
*/
void transformPotentialToCartesianCoordinates(const std::vector<RealOpenMM>& fphi, std::vector<RealOpenMM>& cphi) const;
void transformPotentialToCartesianCoordinates(const std::vector<double>& fphi, std::vector<double>& cphi) const;
/**
* Spread fixed multipoles onto PME grid.
......@@ -1637,8 +1637,8 @@ private:
*
* @return energy
*/
RealOpenMM computeReciprocalSpaceFixedMultipoleForceAndEnergy(const std::vector<MultipoleParticleData>& particleData,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const;
double computeReciprocalSpaceFixedMultipoleForceAndEnergy(const std::vector<MultipoleParticleData>& particleData,
std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
/**
* Set reciprocal space fixed multipole fields.
......@@ -1665,9 +1665,9 @@ private:
* @param field vector of field at each particle due induced dipole of other particles
*/
void calculateDirectInducedDipolePairIxn(unsigned int iIndex, unsigned int jIndex,
RealOpenMM preFactor1, RealOpenMM preFactor2, const RealVec& delta,
const std::vector<RealVec>& inducedDipole,
std::vector<RealVec>& field) const;
double preFactor1, double preFactor2, const Vec3& delta,
const std::vector<Vec3>& inducedDipole,
std::vector<Vec3>& field) const;
/**
* Calculate direct space field at particleI due to induced dipole at particle J and vice versa for
......@@ -1694,8 +1694,8 @@ private:
* @param inputInducedDipole induced dipole value
* @param inputInducedDipolePolar induced dipole polar value
*/
void spreadInducedDipolesOnGrid(const std::vector<RealVec>& inputInducedDipole,
const std::vector<RealVec>& inputInducedDipolePolar);
void spreadInducedDipolesOnGrid(const std::vector<Vec3>& inputInducedDipole,
const std::vector<Vec3>& inputInducedDipolePolar);
/**
* Calculate induced dipole fields.
......@@ -1713,14 +1713,14 @@ private:
* @param fieldPolar reciprocal space output induced dipole polar field value at each site
*
*/
void recordInducedDipoleField(vector<RealVec>& field, vector<RealVec>& fieldPolar);
void recordInducedDipoleField(vector<Vec3>& field, vector<Vec3>& fieldPolar);
/**
* Compute Pme self energy.
*
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
*/
RealOpenMM calculatePmeSelfEnergy(const std::vector<MultipoleParticleData>& particleData) const;
double calculatePmeSelfEnergy(const std::vector<MultipoleParticleData>& particleData) const;
/**
* Compute the self torques.
......@@ -1728,7 +1728,7 @@ private:
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
* @param torques vector of torques
*/
void calculatePmeSelfTorque(const std::vector<MultipoleParticleData>& particleData, std::vector<RealVec>& torques) const;
void calculatePmeSelfTorque(const std::vector<MultipoleParticleData>& particleData, std::vector<Vec3>& torques) const;
/**
* Calculate direct space electrostatic interaction between particles I and J.
......@@ -1739,9 +1739,9 @@ private:
* @param forces vector of particle forces to be updated
* @param torques vector of particle torques to be updated
*/
RealOpenMM calculatePmeDirectElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
const std::vector<RealOpenMM>& scalingFactors,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const;
double calculatePmeDirectElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
const std::vector<double>& scalingFactors,
std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
/**
* Calculate reciprocal space energy/force/torque for dipole interaction.
......@@ -1752,9 +1752,9 @@ private:
* @param forces vector of particle forces to be updated
* @param torques vector of particle torques to be updated
*/
RealOpenMM computeReciprocalSpaceInducedDipoleForceAndEnergy(AmoebaReferenceMultipoleForce::PolarizationType polarizationType,
const std::vector<MultipoleParticleData>& particleData,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const;
double computeReciprocalSpaceInducedDipoleForceAndEnergy(AmoebaReferenceMultipoleForce::PolarizationType polarizationType,
const std::vector<MultipoleParticleData>& particleData,
std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
/**
* Calculate electrostatic forces.
......@@ -1765,9 +1765,9 @@ private:
*
* @return energy
*/
RealOpenMM calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::RealVec>& torques,
std::vector<OpenMM::RealVec>& forces);
double calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::Vec3>& forces);
};
......
......@@ -24,11 +24,12 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceOutOfPlaneBendForce.h"
#include "SimTKOpenMMRealType.h"
using std::vector;
using namespace OpenMM;
void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) {
void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
......@@ -55,34 +56,20 @@ void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const RealVec& positionAtomA, const RealVec& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD,
RealOpenMM angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic,
RealVec* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
static const RealOpenMM four = 4.0;
static const RealOpenMM five = 5.0;
static const RealOpenMM six = 6.0;
double AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const Vec3& positionAtomC, const Vec3& positionAtomD,
double angleK,
double angleCubic, double angleQuartic,
double anglePentic, double angleSextic,
Vec3* forces) const {
enum { A, B, C, D, LastAtomIndex };
enum { AB, CB, DB, AD, CD, LastDeltaIndex };
// ---------------------------------------------------------------------------------------
// get deltaR between various combinations of the 4 atoms
// and various intermediate terms
std::vector<RealOpenMM> deltaR[LastDeltaIndex];
std::vector<double> deltaR[LastDeltaIndex];
for (int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3);
}
......@@ -101,52 +88,52 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomC, deltaR[CD]);
}
RealOpenMM rDB2 = AmoebaReferenceForce::getNormSquared3(deltaR[DB]);
RealOpenMM rAD2 = AmoebaReferenceForce::getNormSquared3(deltaR[AD]);
RealOpenMM rCD2 = AmoebaReferenceForce::getNormSquared3(deltaR[CD]);
double rDB2 = AmoebaReferenceForce::getNormSquared3(deltaR[DB]);
double rAD2 = AmoebaReferenceForce::getNormSquared3(deltaR[AD]);
double rCD2 = AmoebaReferenceForce::getNormSquared3(deltaR[CD]);
std::vector<RealOpenMM> tempVector(3);
std::vector<double> tempVector(3);
AmoebaReferenceForce::getCrossProduct(deltaR[CB], deltaR[DB], tempVector);
RealOpenMM eE = AmoebaReferenceForce::getDotProduct3(deltaR[AB], tempVector);
RealOpenMM dot = AmoebaReferenceForce::getDotProduct3(deltaR[AD], deltaR[CD]);
RealOpenMM cc = rAD2*rCD2 - dot*dot;
double eE = AmoebaReferenceForce::getDotProduct3(deltaR[AB], tempVector);
double dot = AmoebaReferenceForce::getDotProduct3(deltaR[AD], deltaR[CD]);
double cc = rAD2*rCD2 - dot*dot;
if (rDB2 <= zero || cc == zero) {
return zero;
if (rDB2 <= 0.0 || cc == 0.0) {
return 0.0;
}
RealOpenMM bkk2 = rDB2 - eE*eE/cc;
RealOpenMM cosine = SQRT(bkk2/rDB2);
RealOpenMM angle;
if (cosine >= one) {
angle = zero;
} else if (cosine <= -one) {
angle = PI_M;
double bkk2 = rDB2 - eE*eE/cc;
double cosine = sqrt(bkk2/rDB2);
double angle;
if (cosine >= 1.0) {
angle = 0.0;
} else if (cosine <= -1.0) {
angle = M_PI;
} else {
angle = RADIAN*ACOS(cosine);
angle = RADIAN*acos(cosine);
}
// chain rule
RealOpenMM dt = angle;
RealOpenMM dt2 = dt*dt;
RealOpenMM dt3 = dt2*dt;
RealOpenMM dt4 = dt2*dt2;
double dt = angle;
double dt2 = dt*dt;
double dt3 = dt2*dt;
double dt4 = dt2*dt2;
RealOpenMM dEdDt = two + three*angleCubic*dt + four*angleQuartic*dt2 +
five*anglePentic*dt3 + six*angleSextic*dt4;
double dEdDt = 2.0 + 3.0*angleCubic*dt + 4.0*angleQuartic*dt2 +
5.0*anglePentic*dt3 + 6.0*angleSextic*dt4;
dEdDt *= angleK*dt*RADIAN;
RealOpenMM dEdCos = dEdDt/SQRT(cc*bkk2);
if (eE > zero) {
dEdCos *= -one;
double dEdCos = dEdDt/sqrt(cc*bkk2);
if (eE > 0.0) {
dEdCos *= -1.0;
}
RealOpenMM term = eE/cc;
double term = eE/cc;
std::vector<RealOpenMM> dccd[LastAtomIndex];
std::vector<RealOpenMM> deed[LastAtomIndex];
std::vector<RealOpenMM> subForce[LastAtomIndex];
std::vector<double> dccd[LastAtomIndex];
std::vector<double> deed[LastAtomIndex];
std::vector<double> subForce[LastAtomIndex];
for (int ii = 0; ii < LastAtomIndex; ii++) {
dccd[ii].resize(3);
deed[ii].resize(3);
......@@ -155,7 +142,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
for (int ii = 0; ii < 3; ii++) {
dccd[A][ii] = (deltaR[AD][ii]*rCD2 - deltaR[CD][ii]*dot)*term;
dccd[C][ii] = (deltaR[CD][ii]*rAD2 - deltaR[AD][ii]*dot)*term;
dccd[D][ii] = -one*(dccd[A][ii] + dccd[C][ii]);
dccd[D][ii] = -1.0*(dccd[A][ii] + dccd[C][ii]);
}
AmoebaReferenceForce::getCrossProduct(deltaR[DB], deltaR[CB], deed[A]);
......@@ -189,7 +176,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
if (jj == 3) {
for (int ii = 0; ii < 3; ii++) {
subForce[1][ii] = -one*(subForce[0][ii] + subForce[2][ii] + subForce[3][ii]);
subForce[1][ii] = -1.0*(subForce[0][ii] + subForce[2][ii] + subForce[3][ii]);
}
}
}
......@@ -206,31 +193,31 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
// calculate energy if 'energy' is set
RealOpenMM energy = one + angleCubic*dt + angleQuartic*dt2 + anglePentic*dt3 + angleSextic*dt4;
energy *= angleK*dt2;
double energy = 1.0 + angleCubic*dt + angleQuartic*dt2 + anglePentic*dt3 + angleSextic*dt4;
energy *= angleK*dt2;
return energy;
}
RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateForceAndEnergy(int numOutOfPlaneBends, vector<RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<RealOpenMM>& kQuadratic,
RealOpenMM angleCubic,
RealOpenMM angleQuartic,
RealOpenMM anglePentic,
RealOpenMM angleSextic,
vector<RealVec>& forceData) const {
RealOpenMM energy = 0.0;
double AmoebaReferenceOutOfPlaneBendForce::calculateForceAndEnergy(int numOutOfPlaneBends, vector<Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<double>& kQuadratic,
double angleCubic,
double angleQuartic,
double anglePentic,
double angleSextic,
vector<Vec3>& forceData) const {
double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numOutOfPlaneBends); ii++) {
int particle1Index = particle1[ii];
int particle2Index = particle2[ii];
int particle3Index = particle3[ii];
int particle4Index = particle4[ii];
RealOpenMM kAngle = kQuadratic[ii];
RealVec forces[4];
double kAngle = kQuadratic[ii];
Vec3 forces[4];
energy += calculateOutOfPlaneBendIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], posData[particle4Index],
kAngle, angleCubic, angleQuartic, anglePentic, angleSextic, forces);
for (int jj = 0; jj < 3; jj++) {
......
......@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceOutOfPlaneBendForce_H__
#define __AmoebaReferenceOutOfPlaneBendForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
namespace OpenMM {
......@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
void setPeriodic(OpenMM::Vec3* vectors);
/**---------------------------------------------------------------------------------------
......@@ -82,22 +82,22 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numOutOfPlaneBends, std::vector<OpenMM::RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<RealOpenMM>& kAngle,
RealOpenMM angleCubic,
RealOpenMM angleQuartic,
RealOpenMM anglePentic,
RealOpenMM angleSextic,
std::vector<OpenMM::RealVec>& forceData) const;
double calculateForceAndEnergy(int numOutOfPlaneBends, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<double>& kAngle,
double angleCubic,
double angleQuartic,
double anglePentic,
double angleSextic,
std::vector<OpenMM::Vec3>& forceData) const;
private:
bool usePeriodic;
RealVec boxVectors[3];
Vec3 boxVectors[3];
/**---------------------------------------------------------------------------------------
......@@ -118,13 +118,12 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateOutOfPlaneBendIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD,
RealOpenMM angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic,
OpenMM::RealVec* forces) const;
double calculateOutOfPlaneBendIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
double angleK,
double angleCubic, double angleQuartic,
double anglePentic, double angleSextic,
OpenMM::Vec3* forces) const;
};
} // namespace OpenMM
......
......@@ -23,12 +23,13 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferencePiTorsionForce.h"
#include <cmath>
#include <vector>
using std::vector;
using namespace OpenMM;
void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
......@@ -52,24 +53,14 @@ void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& positionAtomA, const RealVec& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD,
const RealVec& positionAtomE, const RealVec& positionAtomF,
RealOpenMM piTorsionK, RealVec* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferencePiTorsionForce::calculatePiTorsionIxn";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
// ---------------------------------------------------------------------------------------
double AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const Vec3& positionAtomC, const Vec3& positionAtomD,
const Vec3& positionAtomE, const Vec3& positionAtomF,
double piTorsionK, Vec3* forces) const {
enum { AD, BD, EC, FC, P, Q, CP, DC, QD, T, U, TU, DP, QC, dT, dU, dP, dQ, dC1, dC2, dD1, dD2, LastDeltaIndex };
std::vector<RealOpenMM> deltaR[LastDeltaIndex];
std::vector<double> deltaR[LastDeltaIndex];
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3);
}
......@@ -87,7 +78,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
}
enum { A, B, C, D, E, F, LastAtomIndex };
std::vector<RealOpenMM> d[LastAtomIndex];
std::vector<double> d[LastAtomIndex];
for (unsigned int ii = 0; ii < LastAtomIndex; ii++) {
d[ii].resize(3);
}
......@@ -106,36 +97,36 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
AmoebaReferenceForce::getCrossProduct(deltaR[DC], deltaR[QD], deltaR[U]);
AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[U], deltaR[TU]);
RealOpenMM rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]);
RealOpenMM rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]);
RealOpenMM rTrU = SQRT(rT2*rU2);
if (rTrU <= zero) {
return zero;
double rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]);
double rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]);
double rTrU = sqrt(rT2*rU2);
if (rTrU <= 0.0) {
return 0.0;
}
RealOpenMM rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]);
double rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]);
RealOpenMM cosine = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]);
cosine /= rTrU;
double cosine = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]);
cosine /= rTrU;
RealOpenMM sine = AmoebaReferenceForce::getDotProduct3(deltaR[DC], deltaR[TU]);
sine /= (rDC*rTrU);
double sine = AmoebaReferenceForce::getDotProduct3(deltaR[DC], deltaR[TU]);
sine /= (rDC*rTrU);
RealOpenMM cosine2 = cosine*cosine - sine*sine;
RealOpenMM sine2 = two*cosine*sine;
double cosine2 = cosine*cosine - sine*sine;
double sine2 = 2.0*cosine*sine;
RealOpenMM phi2 = one - cosine2;
RealOpenMM dphi2 = two*sine2;
double phi2 = 1.0 - cosine2;
double dphi2 = 2.0*sine2;
RealOpenMM dedphi = piTorsionK*dphi2;
double dedphi = piTorsionK*dphi2;
for (unsigned int ii = 0; ii < 3; ii++) {
deltaR[DP][ii] = positionAtomD[ii] - deltaR[P][ii];
deltaR[QC][ii] = deltaR[Q][ii] - positionAtomC[ii];
}
RealOpenMM factorT = dedphi/(rDC*rT2);
RealOpenMM factorU = -dedphi/(rDC*rU2);
double factorT = dedphi/(rDC*rT2);
double factorU = -dedphi/(rDC*rU2);
AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[DC], deltaR[dT]);
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[DC], deltaR[dU]);
......@@ -200,16 +191,16 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
}
RealOpenMM AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsions, vector<RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& particle6,
const std::vector<RealOpenMM>& kTorsion,
vector<RealVec>& forceData) const {
RealOpenMM energy = 0.0;
double AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsions, vector<Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& particle6,
const std::vector<double>& kTorsion,
vector<Vec3>& forceData) const {
double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numPiTorsions); ii++) {
int particle1Index = particle1[ii];
......@@ -219,7 +210,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsi
int particle5Index = particle5[ii];
int particle6Index = particle6[ii];
RealVec forces[6];
Vec3 forces[6];
energy += calculatePiTorsionIxn(posData[particle1Index], posData[particle2Index],
posData[particle3Index], posData[particle4Index],
posData[particle5Index], posData[particle6Index],
......
......@@ -25,7 +25,7 @@
#ifndef __AmoebaReferencePiTorsionForce_H__
#define __AmoebaReferencePiTorsionForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
namespace OpenMM {
......@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
void setPeriodic(OpenMM::Vec3* vectors);
/**---------------------------------------------------------------------------------------
......@@ -82,21 +82,21 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numPiTorsions, std::vector<OpenMM::RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& particle6,
const std::vector<RealOpenMM>& kTorsion,
std::vector<OpenMM::RealVec>& forceData) const;
double calculateForceAndEnergy(int numPiTorsions, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& particle6,
const std::vector<double>& kTorsion,
std::vector<OpenMM::Vec3>& forceData) const;
private:
bool usePeriodic;
RealVec boxVectors[3];
Vec3 boxVectors[3];
/**---------------------------------------------------------------------------------------
......@@ -115,10 +115,10 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM calculatePiTorsionIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD,
const OpenMM::RealVec& positionAtomE, const OpenMM::RealVec& positionAtomF,
RealOpenMM kTorsion, OpenMM::RealVec* forces) const;
double calculatePiTorsionIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
const OpenMM::Vec3& positionAtomE, const OpenMM::Vec3& positionAtomF,
double kTorsion, OpenMM::Vec3* forces) const;
};
......
......@@ -24,12 +24,13 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceStretchBendForce.h"
#include "SimTKOpenMMRealType.h"
#include <vector>
using std::vector;
using namespace OpenMM;
void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) {
void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
......@@ -56,20 +57,11 @@ void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVec& positionAtomA, const RealVec& positionAtomB,
const RealVec& positionAtomC,
RealOpenMM lengthAB, RealOpenMM lengthCB,
RealOpenMM idealAngle, RealOpenMM k1Parameter,
RealOpenMM k2Parameter, RealVec* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceStretchBendForce::calculateStretchBendIxn";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
double AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const Vec3& positionAtomC,
double lengthAB, double lengthCB,
double idealAngle, double k1Parameter,
double k2Parameter, Vec3* forces) const {
enum { A, B, C, LastAtomIndex };
enum { AB, CB, CBxAB, ABxP, CBxP, LastDeltaIndex };
......@@ -79,7 +71,7 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
// get deltaR between various combinations of the 3 atoms
// and various intermediate terms
std::vector<RealOpenMM> deltaR[LastDeltaIndex];
std::vector<double> deltaR[LastDeltaIndex];
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3);
}
......@@ -91,30 +83,30 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomA, deltaR[AB]);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]);
}
RealOpenMM rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[AB]);
RealOpenMM rAB = SQRT(rAB2);
RealOpenMM rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[CB]);
RealOpenMM rCB = SQRT(rCB2);
double rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[AB]);
double rAB = sqrt(rAB2);
double rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[CB]);
double rCB = sqrt(rCB2);
AmoebaReferenceForce::getCrossProduct(deltaR[CB], deltaR[AB], deltaR[CBxAB]);
RealOpenMM rP = AmoebaReferenceForce::getNorm3(deltaR[CBxAB]);
if (rP <= zero) {
return zero;
double rP = AmoebaReferenceForce::getNorm3(deltaR[CBxAB]);
if (rP <= 0.0) {
return 0.0;
}
RealOpenMM dot = AmoebaReferenceForce::getDotProduct3(deltaR[CB], deltaR[AB]);
RealOpenMM cosine = dot/(rAB*rCB);
double dot = AmoebaReferenceForce::getDotProduct3(deltaR[CB], deltaR[AB]);
double cosine = dot/(rAB*rCB);
RealOpenMM angle;
if (cosine >= one) {
angle = zero;
} else if (cosine <= -one) {
angle = PI_M;
double angle;
if (cosine >= 1.0) {
angle = 0.0;
} else if (cosine <= -1.0) {
angle = M_PI;
} else {
angle = RADIAN*ACOS(cosine);
angle = RADIAN*acos(cosine);
}
RealOpenMM termA = -RADIAN/(rAB2*rP);
RealOpenMM termC = RADIAN/(rCB2*rP);
double termA = -RADIAN/(rAB2*rP);
double termC = RADIAN/(rCB2*rP);
// P = CBxAB
......@@ -125,11 +117,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
deltaR[CBxP][ii] *= termC;
}
RealOpenMM dr1 = rAB - lengthAB;
RealOpenMM dr2 = rCB - lengthCB;
RealOpenMM drkk = dr1*k1Parameter + dr2*k2Parameter;
termA = one/rAB;
termC = one/rCB;
double dr1 = rAB - lengthAB;
double dr2 = rCB - lengthCB;
double drkk = dr1*k1Parameter + dr2*k2Parameter;
termA = 1.0/rAB;
termC = 1.0/rCB;
// ---------------------------------------------------------------------------------------
......@@ -138,11 +130,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
// calculate forces for atoms a, b, c
// the force for b is then -(a + c)
std::vector<RealOpenMM> subForce[LastAtomIndex];
std::vector<double> subForce[LastAtomIndex];
for (int ii = 0; ii < LastAtomIndex; ii++) {
subForce[ii].resize(3);
}
RealOpenMM dt = angle - idealAngle*RADIAN;
double dt = angle - idealAngle*RADIAN;
for (int jj = 0; jj < 3; jj++) {
subForce[A][jj] = k1Parameter*dt*termA*deltaR[AB][jj] + drkk*deltaR[ABxP][jj];
subForce[C][jj] = k2Parameter*dt*termC*deltaR[CB][jj] + drkk*deltaR[CBxP][jj];
......@@ -162,29 +154,29 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
return dt*drkk;
}
RealOpenMM AmoebaReferenceStretchBendForce::calculateForceAndEnergy(int numStretchBends, vector<RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<RealOpenMM>& lengthABParameters,
const std::vector<RealOpenMM>& lengthCBParameters,
const std::vector<RealOpenMM>& angle,
const std::vector<RealOpenMM>& k1Quadratic,
const std::vector<RealOpenMM>& k2Quadratic,
vector<RealVec>& forceData) const {
RealOpenMM energy = 0.0;
double AmoebaReferenceStretchBendForce::calculateForceAndEnergy(int numStretchBends, vector<Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<double>& lengthABParameters,
const std::vector<double>& lengthCBParameters,
const std::vector<double>& angle,
const std::vector<double>& k1Quadratic,
const std::vector<double>& k2Quadratic,
vector<Vec3>& forceData) const {
double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numStretchBends); ii++) {
int particle1Index = particle1[ii];
int particle2Index = particle2[ii];
int particle3Index = particle3[ii];
RealOpenMM abLength = lengthABParameters[ii];
RealOpenMM cbLength = lengthCBParameters[ii];
RealOpenMM idealAngle = angle[ii];
RealOpenMM angleK1 = k1Quadratic[ii];
RealOpenMM angleK2 = k2Quadratic[ii];
RealVec forces[3];
energy += calculateStretchBendIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index],
abLength, cbLength, idealAngle, angleK1, angleK2, forces);
int particle1Index = particle1[ii];
int particle2Index = particle2[ii];
int particle3Index = particle3[ii];
double abLength = lengthABParameters[ii];
double cbLength = lengthCBParameters[ii];
double idealAngle = angle[ii];
double angleK1 = k1Quadratic[ii];
double angleK2 = k2Quadratic[ii];
Vec3 forces[3];
energy += calculateStretchBendIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index],
abLength, cbLength, idealAngle, angleK1, angleK2, forces);
// accumulate forces
for (int jj = 0; jj < 3; jj++) {
......
......@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceStretchBendForce_H__
#define __AmoebaReferenceStretchBendForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
namespace OpenMM {
......@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
void setPeriodic(OpenMM::Vec3* vectors);
/**---------------------------------------------------------------------------------------
......@@ -80,22 +80,22 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numAngles, std::vector<OpenMM::RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<RealOpenMM>& lengthABParameters,
const std::vector<RealOpenMM>& lengthCBParameters,
const std::vector<RealOpenMM>& angle,
const std::vector<RealOpenMM>& k1Quadratic,
const std::vector<RealOpenMM>& k2Quadratic,
std::vector<OpenMM::RealVec>& forceData) const;
double calculateForceAndEnergy(int numAngles, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<double>& lengthABParameters,
const std::vector<double>& lengthCBParameters,
const std::vector<double>& angle,
const std::vector<double>& k1Quadratic,
const std::vector<double>& k2Quadratic,
std::vector<OpenMM::Vec3>& forceData) const;
private:
bool usePeriodic;
RealVec boxVectors[3];
Vec3 boxVectors[3];
/**---------------------------------------------------------------------------------------
......@@ -115,11 +115,11 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateStretchBendIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC,
RealOpenMM lengthAB, RealOpenMM lengthCB,
RealOpenMM idealAngle, RealOpenMM k1Parameter,
RealOpenMM k2Parameter, OpenMM::RealVec* forces) const;
double calculateStretchBendIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::Vec3& positionAtomC,
double lengthAB, double lengthCB,
double idealAngle, double k1Parameter,
double k2Parameter, OpenMM::Vec3* forces) const;
};
......
......@@ -23,11 +23,12 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceTorsionTorsionForce.h"
#include "SimTKOpenMMRealType.h"
using std::vector;
using namespace OpenMM;
void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
......@@ -54,15 +55,9 @@ void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle(
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid,
RealOpenMM angle1, RealOpenMM angle2, RealOpenMM corners[2][2],
RealOpenMM* fValues, RealOpenMM* fValues1, RealOpenMM* fValues2, RealOpenMM* fValues12) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "loadGridValuesFromEnclosingRectangle";
// ---------------------------------------------------------------------------------------
const std::vector< std::vector< std::vector<double> > >& grid,
double angle1, double angle2, double corners[2][2],
double* fValues, double* fValues1, double* fValues2, double* fValues12) const {
// get 2 opposing grid indices for rectangle
......@@ -123,50 +118,37 @@ void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle(
--------------------------------------------------------------------------------------- */
void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealOpenMM* y,
const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12, const RealOpenMM d1, const RealOpenMM d2,
RealOpenMM c[4][4]) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix";
void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const double* y,
const double* y1, const double* y2, const double* y12, const double d1, const double d2,
double c[4][4]) const {
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
static const RealOpenMM four = 4.0;
static const RealOpenMM five = 5.0;
static const RealOpenMM six = 6.0;
static const RealOpenMM nine = 9.0;
// transpose of matrix in Tinker due to difference in C/Fotran row/column major
// change indices when multiplying by weightMatrix
static const RealOpenMM weightMatrix[16][16] = {
{ one, zero, -three, two, zero, zero, zero, zero, -three, zero, nine, -six, two, zero, -six, four },
{ zero, zero, zero, zero, zero, zero, zero, zero, three, zero, -nine, six, -two, zero, six, -four },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, nine, -six, zero, zero, -six, four },
{ zero, zero, three, -two, zero, zero, zero, zero, zero, zero, -nine, six, zero, zero, six, -four },
{ zero, zero, zero, zero, one, zero, -three, two, -two, zero, six, -four, one, zero, -three, two },
{ zero, zero, zero, zero, zero, zero, zero, zero, -one, zero, three, -two, one, zero, -three, two },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, -three, two, zero, zero, three, -two },
{ zero, zero, zero, zero, zero, zero, three, -two, zero, zero, -six, four, zero, zero, three, -two },
{ zero, one, -two, one, zero, zero, zero, zero, zero, -three, six, -three, zero, two, -four, two },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, three, -six, three, zero, -two, four, -two },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, -three, three, zero, zero, two, -two },
{ zero, zero, -one, one, zero, zero, zero, zero, zero, zero, three, -three, zero, zero, -two, two },
{ zero, zero, zero, zero, zero, one, -two, one, zero, -two, four, -two, zero, one, -two, one },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, -one, two, -one, zero, one, -two, one },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, one, -one, zero, zero, -one, one },
{ zero, zero, zero, zero, zero, zero, -one, one, zero, zero, two, -two, zero, zero, -one, one } };
static const double weightMatrix[16][16] = {
{ 1.0, 0.0, -3.0, 2.0, 0.0, 0.0, 0.0, 0.0, -3.0, 0.0, 9.0, -6.0, 2.0, 0.0, -6.0, 4.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, -9.0, 6.0, -2.0, 0.0, 6.0, -4.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 9.0, -6.0, 0.0, 0.0, -6.0, 4.0 },
{ 0.0, 0.0, 3.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -9.0, 6.0, 0.0, 0.0, 6.0, -4.0 },
{ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -3.0, 2.0, -2.0, 0.0, 6.0, -4.0, 1.0, 0.0, -3.0, 2.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, -2.0, 1.0, 0.0, -3.0, 2.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -3.0, 2.0, 0.0, 0.0, 3.0, -2.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, -2.0, 0.0, 0.0, -6.0, 4.0, 0.0, 0.0, 3.0, -2.0 },
{ 0.0, 1.0, -2.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -3.0, 6.0, -3.0, 0.0, 2.0, -4.0, 2.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, -6.0, 3.0, 0.0, -2.0, 4.0, -2.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -3.0, 3.0, 0.0, 0.0, 2.0, -2.0 },
{ 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, -3.0, 0.0, 0.0, -2.0, 2.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, -2.0, 1.0, 0.0, -2.0, 4.0, -2.0, 0.0, 1.0, -2.0, 1.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 2.0, -1.0, 0.0, 1.0, -2.0, 1.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, -1.0, 1.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 2.0, -2.0, 0.0, 0.0, -1.0, 1.0 } };
// ---------------------------------------------------------------------------------------
// pack y, y1, y2, y12 into single vector of dimension 16
std::vector<RealOpenMM> x(16);
RealOpenMM d1d2 = d1*d2;
std::vector<double> x(16);
double d1d2 = d1*d2;
for (int ii = 0; ii < 4; ii++) {
x[ii] = y[ii];
x[ii+4] = y1[ii]*d1;
......@@ -179,7 +161,7 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
int rowIndex = 0;
int colIndex = 0;
for (int ii = 0; ii < 16; ii++) {
RealOpenMM sum = weightMatrix[0][ii]*x[0];
double sum = weightMatrix[0][ii]*x[0];
for (int jj = 1; jj < 16; jj++) {
sum += weightMatrix[jj][ii]*x[jj];
}
......@@ -223,40 +205,30 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
--------------------------------------------------------------------------------------- */
void AmoebaReferenceTorsionTorsionForce::getBicubicValues(
const RealOpenMM* y, const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12,
const RealOpenMM x1Lower, const RealOpenMM x1Upper,
const RealOpenMM x2Lower, const RealOpenMM x2Upper,
const RealOpenMM gridValue1, const RealOpenMM gridValue2,
RealOpenMM* functionValue, RealOpenMM* functionValue1, RealOpenMM* functionValue2) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "getBicubicValues";
const double* y, const double* y1, const double* y2, const double* y12,
const double x1Lower, const double x1Upper,
const double x2Lower, const double x2Upper,
const double gridValue1, const double gridValue2,
double* functionValue, double* functionValue1, double* functionValue2) const {
static const RealOpenMM zero = 0.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
// ---------------------------------------------------------------------------------------
// get coefficent matrix
RealOpenMM coefficientMatrix[4][4];
double coefficientMatrix[4][4];
getBicubicCoefficientMatrix(y, y1, y2, y12, x1Upper-x1Lower, x2Upper-x2Lower, coefficientMatrix);
// apply coefficent matrix
RealOpenMM t = (gridValue1 - x1Lower)/(x1Upper - x1Lower);
RealOpenMM u = (gridValue2 - x2Lower)/(x2Upper - x2Lower);
double t = (gridValue1 - x1Lower)/(x1Upper - x1Lower);
double u = (gridValue2 - x2Lower)/(x2Upper - x2Lower);
*functionValue = zero;
*functionValue1 = zero;
*functionValue2 = zero;
*functionValue = 0.0;
*functionValue1 = 0.0;
*functionValue2 = 0.0;
for (int ii = 3; ii >= 0; ii--) {
*functionValue = t*(*functionValue) + ( (coefficientMatrix[ii][3]*u + coefficientMatrix[ii][2])*u + coefficientMatrix[ii][1])*u + coefficientMatrix[ii][0];
*functionValue1 = u*(*functionValue1) + (three*coefficientMatrix[3][ii]*t + two*coefficientMatrix[2][ii])*t + coefficientMatrix[1][ii];
*functionValue2 = t*(*functionValue2) + (three*coefficientMatrix[ii][3]*u + two*coefficientMatrix[ii][2])*u + coefficientMatrix[ii][1];
*functionValue = t*(*functionValue) + ( (coefficientMatrix[ii][3]*u + coefficientMatrix[ii][2])*u + coefficientMatrix[ii][1])*u + coefficientMatrix[ii][0];
*functionValue1 = u*(*functionValue1) + (3.0*coefficientMatrix[3][ii]*t + 2.0*coefficientMatrix[2][ii])*t + coefficientMatrix[1][ii];
*functionValue2 = t*(*functionValue2) + (3.0*coefficientMatrix[ii][3]*u + 2.0*coefficientMatrix[ii][2])*u + coefficientMatrix[ii][1];
}
*functionValue1 /= (x1Upper - x1Lower);
......@@ -280,22 +252,13 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicValues(
--------------------------------------------------------------------------------------- */
int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
const RealVec& positionAtomA, const RealVec& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::checkTorsionSign";
static const RealOpenMM zero = 0.0;
static const int one = 1;
// ---------------------------------------------------------------------------------------
const Vec3& positionAtomA, const Vec3& positionAtomB,
const Vec3& positionAtomC, const Vec3& positionAtomD) const {
// compute parallelpiped volume at atomC and return sign based on sign of volume
enum { CA, CB, CD, LastDeltaIndex };
std::vector<RealOpenMM> deltaR[LastDeltaIndex];
std::vector<double> deltaR[LastDeltaIndex];
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3);
}
......@@ -311,11 +274,11 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomD, deltaR[CD]);
}
RealOpenMM volume = deltaR[CA][0]*(deltaR[CB][1]*deltaR[CD][2] - deltaR[CB][2]*deltaR[CD][1]) +
deltaR[CB][0]*(deltaR[CD][1]*deltaR[CA][2] - deltaR[CD][2]*deltaR[CA][1]) +
deltaR[CD][0]*(deltaR[CA][1]*deltaR[CB][2] - deltaR[CA][2]*deltaR[CB][1]);
double volume = deltaR[CA][0]*(deltaR[CB][1]*deltaR[CD][2] - deltaR[CB][2]*deltaR[CD][1]) +
deltaR[CB][0]*(deltaR[CD][1]*deltaR[CA][2] - deltaR[CD][2]*deltaR[CA][1]) +
deltaR[CD][0]*(deltaR[CA][1]*deltaR[CB][2] - deltaR[CA][2]*deltaR[CB][1]);
return (volume >= zero ? one : -one);
return (volume >= 0.0 ? 1.0 : -1.0);
}
......@@ -337,21 +300,12 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const RealVec& positionAtomA, const RealVec& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD,
const RealVec& positionAtomE, const RealVec* positionChiralCheckAtom,
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid,
RealVec* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
double AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const Vec3& positionAtomC, const Vec3& positionAtomD,
const Vec3& positionAtomE, const Vec3* positionChiralCheckAtom,
const std::vector< std::vector< std::vector<double> > >& grid,
Vec3* forces) const {
// ---------------------------------------------------------------------------------------
enum { A, B, C, D, E, LastAtomIndex };
// get deltaR between various combinations of the 4 atoms
......@@ -359,7 +313,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
enum { BA, CB, DC, ED, T, U, V, UxV, CA, DB, EC, dT, dU, dU2, dV2, LastDeltaIndex };
std::vector<RealOpenMM> deltaR[LastDeltaIndex];
std::vector<double> deltaR[LastDeltaIndex];
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3);
}
......@@ -383,7 +337,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomE, deltaR[EC]);
}
std::vector<RealOpenMM> d[LastAtomIndex];
std::vector<double> d[LastAtomIndex];
for (unsigned int ii = 0; ii < LastAtomIndex; ii++) {
d[ii].resize(3);
}
......@@ -394,51 +348,51 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[V], deltaR[UxV]);
RealOpenMM rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]);
RealOpenMM rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]);
RealOpenMM rV2 = AmoebaReferenceForce::getNormSquared3(deltaR[V]);
RealOpenMM rUrV = SQRT(rU2*rV2);
double rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]);
double rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]);
double rV2 = AmoebaReferenceForce::getNormSquared3(deltaR[V]);
double rUrV = sqrt(rU2*rV2);
RealOpenMM rTrU = SQRT(rT2*rU2);
double rTrU = sqrt(rT2*rU2);
if (rTrU <= zero || rUrV <= zero) {
return zero;
if (rTrU <= 0.0 || rUrV <= 0.0) {
return 0.0;
}
RealOpenMM rCB = AmoebaReferenceForce::getNorm3(deltaR[CB]);
RealOpenMM cosine1 = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]);
cosine1 /= rTrU;
RealOpenMM angle1;
if (cosine1 <= -one) {
angle1 = PI_M*RADIAN;
} else if (cosine1 >= one) {
angle1 = zero;
double rCB = AmoebaReferenceForce::getNorm3(deltaR[CB]);
double cosine1 = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]);
cosine1 /= rTrU;
double angle1;
if (cosine1 <= -1.0) {
angle1 = M_PI*RADIAN;
} else if (cosine1 >= 1.0) {
angle1 = 0.0;
} else {
angle1 = RADIAN*ACOS(cosine1);
angle1 = RADIAN*acos(cosine1);
}
RealOpenMM sign = AmoebaReferenceForce::getDotProduct3(deltaR[BA], deltaR[U]);
if (sign < zero) {
double sign = AmoebaReferenceForce::getDotProduct3(deltaR[BA], deltaR[U]);
if (sign < 0.0) {
angle1 = -angle1;
}
// value1 = angle1;
RealOpenMM rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]);
RealOpenMM cosine2 = AmoebaReferenceForce::getDotProduct3(deltaR[U], deltaR[V]);
cosine2 /= rUrV;
double rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]);
double cosine2 = AmoebaReferenceForce::getDotProduct3(deltaR[U], deltaR[V]);
cosine2 /= rUrV;
RealOpenMM angle2;
if (cosine2 <= -one) {
angle2 = PI_M*RADIAN;
} else if (cosine1 >= one) {
angle2 = zero;
double angle2;
if (cosine2 <= -1.0) {
angle2 = M_PI*RADIAN;
} else if (cosine1 >= 1.0) {
angle2 = 0.0;
} else {
angle2 = RADIAN*ACOS(cosine2);
angle2 = RADIAN*acos(cosine2);
}
sign = AmoebaReferenceForce::getDotProduct3(deltaR[CB], deltaR[V]);
if (sign < zero) {
if (sign < 0.0) {
angle2 = -angle2;
}
......@@ -447,18 +401,18 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
if (positionChiralCheckAtom) {
sign = checkTorsionSign(*positionChiralCheckAtom, positionAtomB, positionAtomC, positionAtomD);
if (sign < zero) {
if (sign < 0.0) {
angle1 = -angle1;
angle2 = -angle2;
}
} else {
sign = one;
sign = 1.0;
}
// bicubic interpolation
RealOpenMM corners[2][2];
RealOpenMM eValues[4][4];
double corners[2][2];
double eValues[4][4];
enum { E0, E1, E2, E12, LastEIndex };
loadGridValuesFromEnclosingRectangle(grid, angle1, angle2, corners, eValues[E0], eValues[E1], eValues[E2], eValues[E12]);
......@@ -467,9 +421,9 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
// get corners of grid encompassing point
// get width/height of encompassing rectangle
RealOpenMM gridEnergy;
RealOpenMM dEdAngle1;
RealOpenMM dEdAngle2;
double gridEnergy;
double dEdAngle1;
double dEdAngle2;
AmoebaReferenceTorsionTorsionForce::getBicubicValues(
eValues[E0], eValues[E1], eValues[E2], eValues[E12],
corners[0][0], corners[0][1], corners[1][0], corners[1][1],
......@@ -481,8 +435,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[CB], deltaR[dT]);
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[CB], deltaR[dU]);
RealOpenMM factorT = dEdAngle1/(rCB*rT2);
RealOpenMM factorU = -dEdAngle1/(rCB*rU2);
double factorT = dEdAngle1/(rCB*rT2);
double factorU = -dEdAngle1/(rCB*rU2);
deltaR[dT][0] *= factorT;
deltaR[dT][1] *= factorT;
......@@ -495,7 +449,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[dT], deltaR[CB], d[A]);
AmoebaReferenceForce::getCrossProduct(deltaR[dU], deltaR[CB], d[D]);
std::vector<RealOpenMM> tmp[3];
std::vector<double> tmp[3];
for (unsigned int ii = 0; ii < 3; ii++) {
tmp[ii].resize(3);
}
......@@ -518,8 +472,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[DC], deltaR[dU2]);
AmoebaReferenceForce::getCrossProduct(deltaR[V], deltaR[DC], deltaR[dV2]);
RealOpenMM factorU2 = dEdAngle2/(rDC*rU2);
RealOpenMM factorV2 = -dEdAngle2/(rDC*rV2);
double factorU2 = dEdAngle2/(rDC*rU2);
double factorV2 = -dEdAngle2/(rDC*rV2);
deltaR[dU2][0] *= factorU2;
deltaR[dU2][1] *= factorU2;
......@@ -574,17 +528,17 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
return gridEnergy;
}
RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTorsionTorsions, vector<RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& chiralCheckAtom,
const std::vector<int>& gridIndices,
const std::vector< std::vector< std::vector< std::vector<RealOpenMM> > > >& torsionTorsionGrids,
vector<RealVec>& forceData) const {
RealOpenMM energy = 0.0;
double AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTorsionTorsions, vector<Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& chiralCheckAtom,
const std::vector<int>& gridIndices,
const std::vector< std::vector< std::vector< std::vector<double> > > >& torsionTorsionGrids,
vector<Vec3>& forceData) const {
double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numTorsionTorsions); ii++) {
int particle1Index = particle1[ii];
......@@ -597,8 +551,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTo
int gridIndex = gridIndices[ii];
RealVec forces[5];
RealVec* chiralCheckAtom;
Vec3 forces[5];
Vec3* chiralCheckAtom;
if (chiralCheckAtomIndex > -1) {
chiralCheckAtom = &posData[chiralCheckAtomIndex];
} else {
......
......@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceTorsionTorsionForce_H__
#define __AmoebaReferenceTorsionTorsionForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include <vector>
namespace OpenMM {
......@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
void setPeriodic(OpenMM::Vec3* vectors);
/**---------------------------------------------------------------------------------------
......@@ -81,21 +81,21 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numTorsionTorsions, std::vector<OpenMM::RealVec>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& chiralCheckAtom,
const std::vector<int>& gridIndices,
const std::vector< std::vector< std::vector< std::vector<RealOpenMM> > > >& torsionTorsionGrids,
std::vector<OpenMM::RealVec>& forceData) const;
double calculateForceAndEnergy(int numTorsionTorsions, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1,
const std::vector<int>& particle2,
const std::vector<int>& particle3,
const std::vector<int>& particle4,
const std::vector<int>& particle5,
const std::vector<int>& chiralCheckAtom,
const std::vector<int>& gridIndices,
const std::vector< std::vector< std::vector< std::vector<double> > > >& torsionTorsionGrids,
std::vector<OpenMM::Vec3>& forceData) const;
private:
bool usePeriodic;
RealVec boxVectors[3];
Vec3 boxVectors[3];
/**---------------------------------------------------------------------------------------
......@@ -116,9 +116,9 @@ private:
--------------------------------------------------------------------------------------- */
void loadGridValuesFromEnclosingRectangle(
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid,
RealOpenMM angle1, RealOpenMM angle2, RealOpenMM corners[2][2],
RealOpenMM* fValues, RealOpenMM* fValues1, RealOpenMM* fValues2, RealOpenMM* fValues12) const;
const std::vector< std::vector< std::vector<double> > >& grid,
double angle1, double angle2, double corners[2][2],
double* fValues, double* fValues1, double* fValues2, double* fValues12) const;
/**---------------------------------------------------------------------------------------
......@@ -141,8 +141,8 @@ private:
--------------------------------------------------------------------------------------- */
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;
void getBicubicCoefficientMatrix(const double* y, const double* y1, const double* y2, const double* y12,
const double d1, const double d2, double c[4][4]) const;
/**---------------------------------------------------------------------------------------
......@@ -176,11 +176,11 @@ private:
--------------------------------------------------------------------------------------- */
void getBicubicValues(
const RealOpenMM* y, const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12,
const RealOpenMM x1Lower, const RealOpenMM x1Upper,
const RealOpenMM x2Lower, const RealOpenMM x2Upper,
const RealOpenMM gridValue1, const RealOpenMM gridValue2,
RealOpenMM* functionValue, RealOpenMM* functionValue1, RealOpenMM* functionValue2) const;
const double* y, const double* y1, const double* y2, const double* y12,
const double x1Lower, const double x1Upper,
const double x2Lower, const double x2Upper,
const double gridValue1, const double gridValue2,
double* functionValue, double* functionValue1, double* functionValue2) const;
/**---------------------------------------------------------------------------------------
......@@ -196,8 +196,8 @@ private:
--------------------------------------------------------------------------------------- */
int checkTorsionSign(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD) const;
int checkTorsionSign(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD) const;
/**---------------------------------------------------------------------------------------
......@@ -217,11 +217,11 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateTorsionTorsionIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD,
const OpenMM::RealVec& positionAtomE, const OpenMM::RealVec* chiralCheckAtom,
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid,
OpenMM::RealVec* forces) const;
double calculateTorsionTorsionIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
const OpenMM::Vec3& positionAtomE, const OpenMM::Vec3* chiralCheckAtom,
const std::vector< std::vector< std::vector<double> > >& grid,
OpenMM::Vec3* forces) const;
};
......
......@@ -27,6 +27,7 @@
#include "ReferenceForce.h"
#include <algorithm>
#include <cctype>
#include <cmath>
using std::vector;
using namespace OpenMM;
......@@ -76,7 +77,7 @@ double AmoebaReferenceVdwForce::getCutoff() const {
return _cutoff;
}
void AmoebaReferenceVdwForce::setPeriodicBox(OpenMM::RealVec* vectors) {
void AmoebaReferenceVdwForce::setPeriodicBox(OpenMM::Vec3* vectors) {
_periodicBoxVectors[0] = vectors[0];
_periodicBoxVectors[1] = vectors[1];
_periodicBoxVectors[2] = vectors[2];
......@@ -102,22 +103,19 @@ std::string AmoebaReferenceVdwForce::getSigmaCombiningRule() const {
return _sigmaCombiningRule;
}
RealOpenMM AmoebaReferenceVdwForce::arithmeticSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const {
double AmoebaReferenceVdwForce::arithmeticSigmaCombiningRule(double sigmaI, double sigmaJ) const {
return (sigmaI + sigmaJ);
}
RealOpenMM AmoebaReferenceVdwForce::geometricSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const {
return 2.0*SQRT(sigmaI*sigmaJ);
double AmoebaReferenceVdwForce::geometricSigmaCombiningRule(double sigmaI, double sigmaJ) const {
return 2.0*sqrt(sigmaI*sigmaJ);
}
RealOpenMM AmoebaReferenceVdwForce::cubicMeanSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const {
double AmoebaReferenceVdwForce::cubicMeanSigmaCombiningRule(double sigmaI, double sigmaJ) const {
double sigmaI2 = sigmaI*sigmaI;
double sigmaJ2 = sigmaJ*sigmaJ;
const RealOpenMM zero = 0.0;
RealOpenMM sigmaI2 = sigmaI*sigmaI;
RealOpenMM sigmaJ2 = sigmaJ*sigmaJ;
return sigmaI != zero && sigmaJ != 0.0 ? 2.0*(sigmaI2*sigmaI + sigmaJ2*sigmaJ)/(sigmaI2 + sigmaJ2) : zero;
return sigmaI != 0.0 && sigmaJ != 0.0 ? 2.0*(sigmaI2*sigmaI + sigmaJ2*sigmaJ)/(sigmaI2 + sigmaJ2) : 0.0;
}
void AmoebaReferenceVdwForce::setEpsilonCombiningRule(const std::string& epsilonCombiningRule) {
......@@ -142,97 +140,83 @@ std::string AmoebaReferenceVdwForce::getEpsilonCombiningRule() const {
return _epsilonCombiningRule;
}
RealOpenMM AmoebaReferenceVdwForce::arithmeticEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const {
double AmoebaReferenceVdwForce::arithmeticEpsilonCombiningRule(double epsilonI, double epsilonJ) const {
return 0.5*(epsilonI + epsilonJ);
}
RealOpenMM AmoebaReferenceVdwForce::geometricEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const {
return SQRT(epsilonI*epsilonJ);
double AmoebaReferenceVdwForce::geometricEpsilonCombiningRule(double epsilonI, double epsilonJ) const {
return sqrt(epsilonI*epsilonJ);
}
RealOpenMM AmoebaReferenceVdwForce::harmonicEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const {
double AmoebaReferenceVdwForce::harmonicEpsilonCombiningRule(double epsilonI, double epsilonJ) const {
return (epsilonI != 0.0 && epsilonJ != 0.0) ? 2.0*(epsilonI*epsilonJ)/(epsilonI + epsilonJ) : 0.0;
}
RealOpenMM AmoebaReferenceVdwForce::hhgEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const {
RealOpenMM denominator = SQRT(epsilonI) + SQRT(epsilonJ);
double AmoebaReferenceVdwForce::hhgEpsilonCombiningRule(double epsilonI, double epsilonJ) const {
double denominator = sqrt(epsilonI) + sqrt(epsilonJ);
return (epsilonI != 0.0 && epsilonJ != 0.0) ? 4.0*(epsilonI*epsilonJ)/(denominator*denominator) : 0.0;
}
void AmoebaReferenceVdwForce::addReducedForce(unsigned int particleI, unsigned int particleIV,
RealOpenMM reduction, RealOpenMM sign,
Vec3& force, vector<RealVec>& forces) const {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
double reduction, double sign,
Vec3& force, vector<Vec3>& forces) const {
forces[particleI][0] += sign*force[0]*reduction;
forces[particleI][1] += sign*force[1]*reduction;
forces[particleI][2] += sign*force[2]*reduction;
forces[particleIV][0] += sign*force[0]*(one - reduction);
forces[particleIV][1] += sign*force[1]*(one - reduction);
forces[particleIV][2] += sign*force[2]*(one - reduction);
forces[particleIV][0] += sign*force[0]*(1.0 - reduction);
forces[particleIV][1] += sign*force[1]*(1.0 - reduction);
forces[particleIV][2] += sign*force[2]*(1.0 - reduction);
}
RealOpenMM AmoebaReferenceVdwForce::calculatePairIxn(RealOpenMM combinedSigma, RealOpenMM combinedEpsilon,
const Vec3& particleIPosition,
const Vec3& particleJPosition,
Vec3& force) const {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM seven = 7.0;
static const RealOpenMM dhal = 0.07;
static const RealOpenMM ghal = 0.12;
// ---------------------------------------------------------------------------------------
double AmoebaReferenceVdwForce::calculatePairIxn(double combinedSigma, double combinedEpsilon,
const Vec3& particleIPosition,
const Vec3& particleJPosition,
Vec3& force) const {
static const double dhal = 0.07;
static const double ghal = 0.12;
// get deltaR, R2, and R between 2 atoms
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
double deltaR[ReferenceForce::LastDeltaRIndex];
if (_nonbondedMethod == CutoffPeriodic)
ReferenceForce::getDeltaRPeriodic(particleJPosition, particleIPosition, _periodicBoxVectors, deltaR);
else
ReferenceForce::getDeltaR(particleJPosition, particleIPosition, deltaR);
RealOpenMM r_ij_2 = deltaR[ReferenceForce::R2Index];
RealOpenMM r_ij = deltaR[ReferenceForce::RIndex];
RealOpenMM sigma_7 = combinedSigma*combinedSigma*combinedSigma;
sigma_7 = sigma_7*sigma_7*combinedSigma;
double r_ij_2 = deltaR[ReferenceForce::R2Index];
double r_ij = deltaR[ReferenceForce::RIndex];
double sigma_7 = combinedSigma*combinedSigma*combinedSigma;
sigma_7 = sigma_7*sigma_7*combinedSigma;
RealOpenMM r_ij_6 = r_ij_2*r_ij_2*r_ij_2;
RealOpenMM r_ij_7 = r_ij_6*r_ij;
double r_ij_6 = r_ij_2*r_ij_2*r_ij_2;
double r_ij_7 = r_ij_6*r_ij;
RealOpenMM rho = r_ij_7 + ghal*sigma_7;
double rho = r_ij_7 + ghal*sigma_7;
RealOpenMM tau = (dhal + one)/(r_ij + dhal*combinedSigma);
RealOpenMM tau_7 = tau*tau*tau;
tau_7 = tau_7*tau_7*tau;
double tau = (dhal + 1.0)/(r_ij + dhal*combinedSigma);
double tau_7 = tau*tau*tau;
tau_7 = tau_7*tau_7*tau;
RealOpenMM dtau = tau/(dhal + one);
double dtau = tau/(dhal + 1.0);
RealOpenMM ratio = (sigma_7/rho);
RealOpenMM gtau = combinedEpsilon*tau_7*r_ij_6*(ghal+one)*ratio*ratio;
double ratio = (sigma_7/rho);
double gtau = combinedEpsilon*tau_7*r_ij_6*(ghal+1.0)*ratio*ratio;
RealOpenMM energy = combinedEpsilon*tau_7*sigma_7*((ghal+one)*sigma_7/rho - two);
double energy = combinedEpsilon*tau_7*sigma_7*((ghal+1.0)*sigma_7/rho - 2.0);
RealOpenMM dEdR = -seven*(dtau*energy + gtau);
double dEdR = -7.0*(dtau*energy + gtau);
// tapering
if ((_nonbondedMethod == CutoffNonPeriodic || _nonbondedMethod == CutoffPeriodic) && r_ij > _taperCutoff) {
RealOpenMM delta = r_ij - _taperCutoff;
RealOpenMM taper = 1.0 + delta*delta*delta*(_taperCoefficients[C3] + delta*(_taperCoefficients[C4] + delta*_taperCoefficients[C5]));
RealOpenMM dtaper = delta*delta*(3.0*_taperCoefficients[C3] + delta*(4.0*_taperCoefficients[C4] + delta*5.0*_taperCoefficients[C5]));
dEdR = energy*dtaper + dEdR*taper;
energy *= taper;
double delta = r_ij - _taperCutoff;
double taper = 1.0 + delta*delta*delta*(_taperCoefficients[C3] + delta*(_taperCoefficients[C4] + delta*_taperCoefficients[C5]));
double dtaper = delta*delta*(3.0*_taperCoefficients[C3] + delta*(4.0*_taperCoefficients[C4] + delta*5.0*_taperCoefficients[C5]));
dEdR = energy*dtaper + dEdR*taper;
energy *= taper;
}
dEdR /= r_ij;
......@@ -246,16 +230,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculatePairIxn(RealOpenMM combinedSigma, R
}
void AmoebaReferenceVdwForce::setReducedPositions(int numParticles,
const vector<RealVec>& particlePositions,
const vector<Vec3>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<RealOpenMM>& reductions,
const std::vector<double>& reductions,
std::vector<Vec3>& reducedPositions) const {
static const RealOpenMM zero = 0.0;
reducedPositions.resize(numParticles);
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numParticles); ii++) {
if (reductions[ii] != zero) {
if (reductions[ii] != 0.0) {
int reductionIndex = indexIVs[ii];
reducedPositions[ii] = Vec3(reductions[ii]*(particlePositions[ii][0] - particlePositions[reductionIndex][0]) + particlePositions[reductionIndex][0],
reductions[ii]*(particlePositions[ii][1] - particlePositions[reductionIndex][1]) + particlePositions[reductionIndex][1],
......@@ -266,22 +248,14 @@ void AmoebaReferenceVdwForce::setReducedPositions(int numParticles,
}
}
RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
const vector<RealVec>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<RealOpenMM>& sigmas,
const std::vector<RealOpenMM>& epsilons,
const std::vector<RealOpenMM>& reductions,
const std::vector< std::set<int> >& allExclusions,
vector<RealVec>& forces) const {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
// ---------------------------------------------------------------------------------------
double AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
const vector<Vec3>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<double>& sigmas,
const std::vector<double>& epsilons,
const std::vector<double>& reductions,
const std::vector< std::set<int> >& allExclusions,
vector<Vec3>& forces) const {
// set reduced coordinates
......@@ -297,12 +271,12 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
// based on reduction factor
// (4) reset exclusion vector
RealOpenMM energy = zero;
double energy = 0.0;
std::vector<unsigned int> exclusions(numParticles, 0);
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numParticles); ii++) {
RealOpenMM sigmaI = sigmas[ii];
RealOpenMM epsilonI = epsilons[ii];
double sigmaI = sigmas[ii];
double epsilonI = epsilons[ii];
for (std::set<int>::const_iterator jj = allExclusions[ii].begin(); jj != allExclusions[ii].end(); jj++) {
exclusions[*jj] = 1;
}
......@@ -310,8 +284,8 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
for (unsigned int jj = ii+1; jj < static_cast<unsigned int>(numParticles); jj++) {
if (exclusions[jj] == 0) {
RealOpenMM combinedSigma = (this->*_combineSigmas)(sigmaI, sigmas[jj]);
RealOpenMM combinedEpsilon = (this->*_combineEpsilons)(epsilonI, epsilons[jj]);
double combinedSigma = (this->*_combineSigmas)(sigmaI, sigmas[jj]);
double combinedEpsilon = (this->*_combineEpsilons)(epsilonI, epsilons[jj]);
Vec3 force;
energy += calculatePairIxn(combinedSigma, combinedEpsilon,
......@@ -323,14 +297,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
forces[ii][1] -= force[1];
forces[ii][2] -= force[2];
} else {
addReducedForce(ii, indexIVs[ii], reductions[ii], -one, force, forces);
addReducedForce(ii, indexIVs[ii], reductions[ii], -1.0, force, forces);
}
if (indexIVs[jj] == jj) {
forces[jj][0] += force[0];
forces[jj][1] += force[1];
forces[jj][2] += force[2];
} else {
addReducedForce(jj, indexIVs[jj], reductions[jj], one, force, forces);
addReducedForce(jj, indexIVs[jj], reductions[jj], 1.0, force, forces);
}
}
......@@ -344,22 +318,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
return energy;
}
RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
const vector<RealVec>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<RealOpenMM>& sigmas,
const std::vector<RealOpenMM>& epsilons,
const std::vector<RealOpenMM>& reductions,
const NeighborList& neighborList,
vector<RealVec>& forces) const {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
// ---------------------------------------------------------------------------------------
double AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
const vector<Vec3>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<double>& sigmas,
const std::vector<double>& epsilons,
const std::vector<double>& reductions,
const NeighborList& neighborList,
vector<Vec3>& forces) const {
// set reduced coordinates
......@@ -372,15 +338,15 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
// then call addReducedForce() to apportion force to particle and its covalent partner
// based on reduction factor
RealOpenMM energy = zero;
double energy = 0.0;
for (unsigned int ii = 0; ii < neighborList.size(); ii++) {
OpenMM::AtomPair pair = neighborList[ii];
int siteI = pair.first;
int siteJ = pair.second;
RealOpenMM combinedSigma = (this->*_combineSigmas)(sigmas[siteI], sigmas[siteJ]);
RealOpenMM combinedEpsilon = (this->*_combineEpsilons)(epsilons[siteI], epsilons[siteJ]);
double combinedSigma = (this->*_combineSigmas)(sigmas[siteI], sigmas[siteJ]);
double combinedEpsilon = (this->*_combineEpsilons)(epsilons[siteI], epsilons[siteJ]);
Vec3 force;
energy += calculatePairIxn(combinedSigma, combinedEpsilon,
......@@ -391,14 +357,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
forces[siteI][1] -= force[1];
forces[siteI][2] -= force[2];
} else {
addReducedForce(siteI, indexIVs[siteI], reductions[siteI], -one, force, forces);
addReducedForce(siteI, indexIVs[siteI], reductions[siteI], -1.0, force, forces);
}
if (indexIVs[siteJ] == siteJ) {
forces[siteJ][0] += force[0];
forces[siteJ][1] += force[1];
forces[siteJ][2] += force[2];
} else {
addReducedForce(siteJ, indexIVs[siteJ], reductions[siteJ], one, force, forces);
addReducedForce(siteJ, indexIVs[siteJ], reductions[siteJ], 1.0, force, forces);
}
}
......
......@@ -25,7 +25,6 @@
#ifndef __AmoebaReferenceVdwForce_H__
#define __AmoebaReferenceVdwForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include "ReferenceNeighborList.h"
#include <string>
......@@ -34,7 +33,7 @@
namespace OpenMM {
class AmoebaReferenceVdwForce;
typedef RealOpenMM (AmoebaReferenceVdwForce::*CombiningFunction)(RealOpenMM x, RealOpenMM y) const;
typedef double (AmoebaReferenceVdwForce::*CombiningFunction)(double x, double y) const;
// ---------------------------------------------------------------------------------------
......@@ -178,7 +177,7 @@ public:
--------------------------------------------------------------------------------------- */
void setPeriodicBox(OpenMM::RealVec* vectors);
void setPeriodicBox(OpenMM::Vec3* vectors);
/**---------------------------------------------------------------------------------------
......@@ -197,12 +196,12 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numParticles, const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<RealOpenMM>& sigmas, const std::vector<RealOpenMM>& epsilons,
const std::vector<RealOpenMM>& reductions,
const std::vector< std::set<int> >& vdwExclusions,
std::vector<OpenMM::RealVec>& forces) const;
double calculateForceAndEnergy(int numParticles, const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<double>& sigmas, const std::vector<double>& epsilons,
const std::vector<double>& reductions,
const std::vector< std::set<int> >& vdwExclusions,
std::vector<OpenMM::Vec3>& forces) const;
/**---------------------------------------------------------------------------------------
......@@ -221,12 +220,12 @@ public:
--------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numParticles, const std::vector<OpenMM::RealVec>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<RealOpenMM>& sigmas, const std::vector<RealOpenMM>& epsilons,
const std::vector<RealOpenMM>& reductions,
const NeighborList& neighborList,
std::vector<OpenMM::RealVec>& forces) const;
double calculateForceAndEnergy(int numParticles, const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<int>& indexIVs,
const std::vector<double>& sigmas, const std::vector<double>& epsilons,
const std::vector<double>& reductions,
const NeighborList& neighborList,
std::vector<OpenMM::Vec3>& forces) const;
private:
......@@ -242,18 +241,18 @@ private:
double _cutoff;
double _taperCutoffFactor;
double _taperCutoff;
RealOpenMM _taperCoefficients[3];
RealVec _periodicBoxVectors[3];
double _taperCoefficients[3];
Vec3 _periodicBoxVectors[3];
CombiningFunction _combineSigmas;
RealOpenMM arithmeticSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const;
RealOpenMM geometricSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const;
RealOpenMM cubicMeanSigmaCombiningRule(RealOpenMM sigmaI, RealOpenMM sigmaJ) const;
double arithmeticSigmaCombiningRule(double sigmaI, double sigmaJ) const;
double geometricSigmaCombiningRule(double sigmaI, double sigmaJ) const;
double cubicMeanSigmaCombiningRule(double sigmaI, double sigmaJ) const;
CombiningFunction _combineEpsilons;
RealOpenMM arithmeticEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
RealOpenMM geometricEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
RealOpenMM harmonicEpsilonCombiningRule(RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
RealOpenMM hhgEpsilonCombiningRule( RealOpenMM epsilonI, RealOpenMM epsilonJ) const;
double arithmeticEpsilonCombiningRule(double epsilonI, double epsilonJ) const;
double geometricEpsilonCombiningRule(double epsilonI, double epsilonJ) const;
double harmonicEpsilonCombiningRule(double epsilonI, double epsilonJ) const;
double hhgEpsilonCombiningRule(double epsilonI, double epsilonJ) const;
/**---------------------------------------------------------------------------------------
......@@ -272,8 +271,8 @@ private:
--------------------------------------------------------------------------------------- */
void setReducedPositions(int numParticles, const std::vector<RealVec>& particlePositions,
const std::vector<int>& indexIVs, const std::vector<RealOpenMM>& reductions,
void setReducedPositions(int numParticles, const std::vector<Vec3>& particlePositions,
const std::vector<int>& indexIVs, const std::vector<double>& reductions,
std::vector<Vec3>& reducedPositions) const;
/**---------------------------------------------------------------------------------------
......@@ -290,8 +289,8 @@ private:
--------------------------------------------------------------------------------------- */
void addReducedForce(unsigned int particleI, unsigned int particleIV,
RealOpenMM reduction, RealOpenMM sign,
Vec3& force, std::vector<OpenMM::RealVec>& forces) const;
double reduction, double sign,
Vec3& force, std::vector<OpenMM::Vec3>& forces) const;
/**---------------------------------------------------------------------------------------
......@@ -317,9 +316,9 @@ private:
--------------------------------------------------------------------------------------- */
RealOpenMM calculatePairIxn(RealOpenMM combindedSigma, RealOpenMM combindedEpsilon,
const Vec3& particleIPosition, const Vec3& particleJPosition,
Vec3& force) const;
double calculatePairIxn(double combindedSigma, double combindedEpsilon,
const Vec3& particleIPosition, const Vec3& particleJPosition,
Vec3& force) const;
};
......
......@@ -24,221 +24,207 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceWcaDispersionForce.h"
#include <cmath>
using std::vector;
using namespace OpenMM;
AmoebaReferenceWcaDispersionForce::AmoebaReferenceWcaDispersionForce(RealOpenMM epso, RealOpenMM epsh, RealOpenMM rmino, RealOpenMM rminh,
RealOpenMM awater, RealOpenMM shctd, RealOpenMM dispoff, RealOpenMM slevy) :
AmoebaReferenceWcaDispersionForce::AmoebaReferenceWcaDispersionForce(double epso, double epsh, double rmino, double rminh,
double awater, double shctd, double dispoff, double slevy) :
_epso(epso), _epsh(epsh), _rmino(rmino), _rminh(rminh), _awater(awater), _shctd(shctd), _dispoff(dispoff), _slevy(slevy) {
}
RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn(RealOpenMM radiusI, RealOpenMM radiusK,
const RealVec& particleIPosition,
const RealVec& particleJPosition,
const RealOpenMM* const intermediateValues,
Vec3& force) const {
double AmoebaReferenceWcaDispersionForce::calculatePairIxn(double radiusI, double radiusK,
const Vec3& particleIPosition,
const Vec3& particleJPosition,
const double* const intermediateValues,
Vec3& force) const {
// ---------------------------------------------------------------------------------------
static const double PI = M_PI;
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
static const RealOpenMM four = 4.0;
static const RealOpenMM five = 5.0;
static const RealOpenMM six = 6.0;
static const RealOpenMM seven = 7.0;
static const RealOpenMM eight = 8.0;
static const RealOpenMM ten = 10.0;
static const RealOpenMM fortyEight = 48.0;
static const RealOpenMM PI = 3.1415926535897932384;
double xr = particleIPosition[0] - particleJPosition[0];
double yr = particleIPosition[1] - particleJPosition[1];
double zr = particleIPosition[2] - particleJPosition[2];
// ---------------------------------------------------------------------------------------
double r2 = xr*xr + yr*yr + zr*zr;
double r = sqrt(r2);
double r3 = r2*r;
RealOpenMM xr = particleIPosition[0] - particleJPosition[0];
RealOpenMM yr = particleIPosition[1] - particleJPosition[1];
RealOpenMM zr = particleIPosition[2] - particleJPosition[2];
double sK = radiusK*_shctd;
double sK2 = sK*sK;
RealOpenMM r2 = xr*xr + yr*yr + zr*zr;
RealOpenMM r = SQRT(r2);
RealOpenMM r3 = r2*r;
double rmixo = intermediateValues[RMIXO];
double rmixo7 = intermediateValues[RMIXO7];
RealOpenMM sK = radiusK*_shctd;
RealOpenMM sK2 = sK*sK;
double emixo = intermediateValues[EMIXO];
RealOpenMM rmixo = intermediateValues[RMIXO];
RealOpenMM rmixo7 = intermediateValues[RMIXO7];
double rmixh = intermediateValues[RMIXH];
double rmixh7 = intermediateValues[RMIXH7];
RealOpenMM emixo = intermediateValues[EMIXO];
double emixh = intermediateValues[EMIXH];
RealOpenMM rmixh = intermediateValues[RMIXH];
RealOpenMM rmixh7 = intermediateValues[RMIXH7];
double ao = intermediateValues[AO];
double ah = intermediateValues[AH];
RealOpenMM emixh = intermediateValues[EMIXH];
RealOpenMM ao = intermediateValues[AO];
RealOpenMM ah = intermediateValues[AH];
RealOpenMM sum = zero;
RealOpenMM de = zero;
double sum = 0.0;
double de = 0.0;
if (radiusI < (r + sK)) {
RealOpenMM rmax = (radiusI > (r - sK)) ? radiusI : (r - sK);
double rmax = (radiusI > (r - sK)) ? radiusI : (r - sK);
RealOpenMM lik = rmax;
RealOpenMM lik2 = lik*lik;
RealOpenMM lik3 = lik2*lik;
RealOpenMM lik4 = lik2*lik2;
double lik = rmax;
double lik2 = lik*lik;
double lik3 = lik2*lik;
double lik4 = lik2*lik2;
if (lik < rmixo) {
RealOpenMM uik = (r + sK) < rmixo ? (r + sK) : rmixo;
RealOpenMM uik2 = uik*uik;
RealOpenMM uik3 = uik2*uik;
RealOpenMM uik4 = uik2*uik2;
double uik = (r + sK) < rmixo ? (r + sK) : rmixo;
double uik2 = uik*uik;
double uik3 = uik2*uik;
double uik4 = uik2*uik2;
RealOpenMM term = four*PI/(fortyEight*r)* (three*(lik4-uik4) - eight*r*(lik3-uik3) + six*(r2-sK2)*(lik2-uik2));
double term = 4.0*PI/(48.0*r)* (3.0*(lik4-uik4) - 8.0*r*(lik3-uik3) + 6.0*(r2-sK2)*(lik2-uik2));
RealOpenMM dl;
double dl;
if (radiusI > (r - sK)) {
dl = -lik2 + two*(r2 + sK2);
dl = -lik2 + 2.0*(r2 + sK2);
dl *= lik2;
} else {
dl = -lik3 + four*lik2*r - six*lik*r2 + two*lik*sK2 + four*r*(r2 - sK2);
dl = -lik3 + 4.0*lik2*r - 6.0*lik*r2 + 2.0*lik*sK2 + 4.0*r*(r2 - sK2);
dl *= lik;
}
RealOpenMM du;
double du;
if ((r+sK) > rmixo) {
du = -uik2 + two*(r2 + sK2);
du = -uik2 + 2.0*(r2 + sK2);
du *= -uik2;
} else {
du = -uik3 + four*uik2*r - six*uik*r2 + two*uik*sK2 + four*r*(r2 - sK2);
du = -uik3 + 4.0*uik2*r - 6.0*uik*r2 + 2.0*uik*sK2 + 4.0*r*(r2 - sK2);
du *= -uik;
}
de = -emixo*PI*(dl+du)/(four*r2);
de = -emixo*PI*(dl+du)/(4.0*r2);
sum += -emixo*term;
}
if (lik < rmixh) {
RealOpenMM uik = (r + sK) < rmixh ? (r + sK) : rmixh;
RealOpenMM uik2 = uik*uik;
RealOpenMM uik3 = uik2*uik;
RealOpenMM uik4 = uik2*uik2;
RealOpenMM term = four*PI / (fortyEight*r)*(three*(lik4-uik4) - eight*r*(lik3-uik3) + six*(r2-sK2)*(lik2-uik2));
RealOpenMM dl;
double uik = (r + sK) < rmixh ? (r + sK) : rmixh;
double uik2 = uik*uik;
double uik3 = uik2*uik;
double uik4 = uik2*uik2;
double term = 4.0*PI / (48.0*r)*(3.0*(lik4-uik4) - 8.0*r*(lik3-uik3) + 6.0*(r2-sK2)*(lik2-uik2));
double dl;
if (radiusI > (r-sK)) {
dl = -lik2 + two*(r2 + sK2);
dl = -lik2 + 2.0*(r2 + sK2);
dl *= lik2;
} else {
dl = -lik3 + four*lik2*r - six*lik*r2 + two*lik*sK2 + four*r*(r2 -sK2);
dl = -lik3 + 4.0*lik2*r - 6.0*lik*r2 + 2.0*lik*sK2 + 4.0*r*(r2 -sK2);
dl *= lik;
}
RealOpenMM du;
double du;
if (r+sK > rmixh) {
du = -uik2 + two*(r2 + sK2);
du = -uik2 + 2.0*(r2 + sK2);
du *= -uik2;
} else {
du = -uik3 +four*uik2*r - six*uik*r2 + two*uik*sK2 +four*r*(r2 - sK2);
du = -uik3 +4.0*uik2*r - 6.0*uik*r2 + 2.0*uik*sK2 +4.0*r*(r2 - sK2);
du *= -uik;
}
de -= two*emixh*PI*(dl+du)/(four*r2);
sum -= two*emixh*term;
de -= 2.0*emixh*PI*(dl+du)/(4.0*r2);
sum -= 2.0*emixh*term;
}
RealOpenMM uik = r + sK;
RealOpenMM uik2 = uik * uik;
RealOpenMM uik3 = uik2 * uik;
RealOpenMM uik4 = uik2 * uik2;
RealOpenMM uik5 = uik3 * uik2;
RealOpenMM uik6 = uik3 * uik3;
RealOpenMM uik10 = uik5 * uik5;
RealOpenMM uik11 = uik5 * uik6;
RealOpenMM uik12 = uik6 * uik6;
RealOpenMM uik13 = uik10 * uik3;
double uik = r + sK;
double uik2 = uik * uik;
double uik3 = uik2 * uik;
double uik4 = uik2 * uik2;
double uik5 = uik3 * uik2;
double uik6 = uik3 * uik3;
double uik10 = uik5 * uik5;
double uik11 = uik5 * uik6;
double uik12 = uik6 * uik6;
double uik13 = uik10 * uik3;
if (uik > rmixo) {
RealOpenMM lik = rmax > rmixo ? rmax : rmixo;
RealOpenMM lik2 = lik * lik;
RealOpenMM lik3 = lik2 * lik;
RealOpenMM lik4 = lik2 * lik2;
RealOpenMM lik5 = lik2 * lik3;
RealOpenMM lik6 = lik3 * lik3;
RealOpenMM lik10 = lik5 * lik5;
RealOpenMM lik11 = lik5 * lik6;
RealOpenMM lik12 = lik6 * lik6;
RealOpenMM lik13 = lik10 * lik3;
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;
double lik = rmax > rmixo ? rmax : rmixo;
double lik2 = lik * lik;
double lik3 = lik2 * lik;
double lik4 = lik2 * lik2;
double lik5 = lik2 * lik3;
double lik6 = lik3 * lik3;
double lik10 = lik5 * lik5;
double lik11 = lik5 * lik6;
double lik12 = lik6 * lik6;
double lik13 = lik10 * lik3;
double term = 4.0*PI/(120.0*r*lik5*uik5)*(15.0*uik*lik*r*(uik4-lik4) - 10.0*uik2*lik2*(uik3-lik3) + 6.0*(sK2-r2)*(uik5-lik5));
double dl;
if (radiusI > (r-sK) || rmax < rmixo) {
dl = -five*lik2 + three*(r2 + sK2);
dl = -5.0*lik2 + 3.0*(r2 + sK2);
dl /= -lik5;
} else {
dl = five*lik3 - 33.0*lik*r2 - three*lik*sK2 + 15.0*(lik2*r+r3-r*sK2);
dl = 5.0*lik3 - 33.0*lik*r2 - 3.0*lik*sK2 + 15.0*(lik2*r+r3-r*sK2);
dl /= lik6;
}
RealOpenMM du = five*uik3 - 33.0*uik*r2 - three*uik*sK2 + 15.0*(uik2*r+r3-r*sK2);
du /= -uik6;
RealOpenMM idisp = -two*ao*term;
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));
double du = 5.0*uik3 - 33.0*uik*r2 - 3.0*uik*sK2 + 15.0*(uik2*r+r3-r*sK2);
du /= -uik6;
double idisp = -2.0*ao*term;
de -= 2.0*ao*PI*(dl + du)/(15.0*r2);
term = 4.0*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) {
dl = -six*lik2 + five*r2 + five*sK2;
dl = -6.0*lik2 + 5.0*r2 + 5.0*sK2;
dl /= -lik12;
} else {
dl = six*lik3 - 125.0*lik*r2 - five*lik*sK2 + 60.0*(lik2*r+r3-r*sK2);
dl = 6.0*lik3 - 125.0*lik*r2 - 5.0*lik*sK2 + 60.0*(lik2*r+r3-r*sK2);
dl /= lik13;
}
du = six*uik3 - 125.0*uik*r2 - five*uik*sK2 + 60.0*(uik2*r+r3-r*sK2);
du = 6.0*uik3 - 125.0*uik*r2 - 5.0*uik*sK2 + 60.0*(uik2*r+r3-r*sK2);
du /= -uik13;
de += ao*rmixo7*PI*(dl + du)/(60.0*r2);
sum += ao*rmixo7*term + idisp;
}
if (uik > rmixh) {
lik = rmax > rmixh ? rmax : rmixh;
lik2 = lik * lik;
lik3 = lik2 * lik;
lik4 = lik2 * lik2;
RealOpenMM lik5 = lik2 * lik3;
RealOpenMM lik6 = lik3 * lik3;
RealOpenMM lik10 = lik5 * lik5;
RealOpenMM lik11 = lik5 * lik6;
RealOpenMM lik12 = lik6 * lik6;
RealOpenMM lik13 = lik3 * lik10;
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;
lik = rmax > rmixh ? rmax : rmixh;
lik2 = lik * lik;
lik3 = lik2 * lik;
lik4 = lik2 * lik2;
double lik5 = lik2 * lik3;
double lik6 = lik3 * lik3;
double lik10 = lik5 * lik5;
double lik11 = lik5 * lik6;
double lik12 = lik6 * lik6;
double lik13 = lik3 * lik10;
double term = 4.0*PI / (120.0*r*lik5*uik5)*(15.0*uik*lik*r*(uik4-lik4) - 10.0*uik2*lik2*(uik3-lik3) + 6.0*(sK2-r2)*(uik5-lik5));
double dl;
if (radiusI > (r-sK) || rmax < rmixh) {
dl = -five*lik2 + three*(r2 + sK2);
dl = -5.0*lik2 + 3.0*(r2 + sK2);
dl /= -lik5;
} else {
dl = five*lik3 - 33.0*lik*r2 - three*lik*sK2 + 15.0*(lik2*r+r3-r*sK2);
dl = 5.0*lik3 - 33.0*lik*r2 - 3.0*lik*sK2 + 15.0*(lik2*r+r3-r*sK2);
dl /= lik6;
}
RealOpenMM du = five*uik3 - 33.0*uik*r2 - 3.0*uik*sK2 + 15.0*(uik2*r+r3-r*sK2);
du /= -uik6;
RealOpenMM idisp = -four*ah*term;
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));
double du = 5.0*uik3 - 33.0*uik*r2 - 3.0*uik*sK2 + 15.0*(uik2*r+r3-r*sK2);
du /= -uik6;
double idisp = -4.0*ah*term;
de = de - 4.0*ah*PI*(dl + du)/(15.0*r2);
term = 4.0*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) {
dl = -six*lik2 + five*r2 + five*sK2;
dl = -6.0*lik2 + 5.0*r2 + 5.0*sK2;
dl = -dl / lik12;
} else {;
dl = six*lik3 - 125.0*lik*r2 - five*lik*sK2 + 60.0*(lik2*r+r3-r*sK2);
dl = 6.0*lik3 - 125.0*lik*r2 - 5.0*lik*sK2 + 60.0*(lik2*r+r3-r*sK2);
dl = dl / lik13;
}
du = six*uik3 - 125.0*uik*r2 - five*uik*sK2 + 60.0*(uik2*r+r3-r*sK2);
du /= -uik13;
RealOpenMM irep = two*ah*rmixh7*term;
de += ah*rmixh7*PI*(dl+du)/(30.0*r2);
sum += irep + idisp;
du = 6.0*uik3 - 125.0*uik*r2 - 5.0*uik*sK2 + 60.0*(uik2*r+r3-r*sK2);
du /= -uik13;
double irep = 2.0*ah*rmixh7*term;
de += ah*rmixh7*PI*(dl+du)/(30.0*r2);
sum += irep + idisp;
}
}
......@@ -254,70 +240,59 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn(RealOpenMM radius
}
RealOpenMM AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy(int numParticles,
const vector<RealVec>& particlePositions,
const std::vector<RealOpenMM>& radii,
const std::vector<RealOpenMM>& epsilons,
RealOpenMM totalMaximumDispersionEnergy,
vector<RealVec>& forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM four = 4.0;
// ---------------------------------------------------------------------------------------
double AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy(int numParticles,
const vector<Vec3>& particlePositions,
const std::vector<double>& radii,
const std::vector<double>& epsilons,
double totalMaximumDispersionEnergy,
vector<Vec3>& forces) const {
// loop over all ixns
RealOpenMM energy = zero;
double energy = 0.0;
RealOpenMM rmino2 = _rmino*_rmino;
RealOpenMM rmino3 = rmino2*_rmino;
double rmino2 = _rmino*_rmino;
double rmino3 = rmino2*_rmino;
RealOpenMM rminh2 = _rminh*_rminh;
RealOpenMM rminh3 = rminh2*_rminh;
double rminh2 = _rminh*_rminh;
double rminh3 = rminh2*_rminh;
RealOpenMM intermediateValues[LastIntermediateValueIndex];
double intermediateValues[LastIntermediateValueIndex];
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numParticles); ii++) {
RealOpenMM epsi = epsilons[ii];
RealOpenMM rmini = radii[ii];
double epsi = epsilons[ii];
double rmini = radii[ii];
RealOpenMM denominator = SQRT(_epso) + SQRT(epsi);
RealOpenMM emixo = four*_epso*epsi/(denominator*denominator);
double denominator = sqrt(_epso) + sqrt(epsi);
double emixo = 4.0*_epso*epsi/(denominator*denominator);
intermediateValues[EMIXO] = emixo;
RealOpenMM rminI2 = rmini*rmini;
RealOpenMM rminI3 = rminI2*rmini;
double rminI2 = rmini*rmini;
double rminI3 = rminI2*rmini;
RealOpenMM rmixo = two*(rmino3 + rminI3) / (rmino2 + rminI2);
intermediateValues[RMIXO] = rmixo;
double rmixo = 2.0*(rmino3 + rminI3) / (rmino2 + rminI2);
intermediateValues[RMIXO] = rmixo;
RealOpenMM rmixo7 = rmixo*rmixo*rmixo;
rmixo7 = rmixo7*rmixo7*rmixo;
intermediateValues[RMIXO7] = rmixo7;
double rmixo7 = rmixo*rmixo*rmixo;
rmixo7 = rmixo7*rmixo7*rmixo;
intermediateValues[RMIXO7] = rmixo7;
intermediateValues[AO] = emixo*rmixo7;
intermediateValues[AO] = emixo*rmixo7;
denominator = SQRT(_epsh) + SQRT(epsi);
denominator = sqrt(_epsh) + sqrt(epsi);
RealOpenMM emixh = four*_epsh*epsi/ (denominator*denominator);
intermediateValues[EMIXH] = emixh;
double emixh = 4.0*_epsh*epsi/ (denominator*denominator);
intermediateValues[EMIXH] = emixh;
RealOpenMM rmixh = two * (rminh3 + rminI3) / (rminh2 + rminI2);
intermediateValues[RMIXH] = rmixh;
double rmixh = 2.0 * (rminh3 + rminI3) / (rminh2 + rminI2);
intermediateValues[RMIXH] = rmixh;
RealOpenMM rmixh7 = rmixh*rmixh*rmixh;
rmixh7 = rmixh7*rmixh7*rmixh;
intermediateValues[RMIXH7] = rmixh7;
double rmixh7 = rmixh*rmixh*rmixh;
rmixh7 = rmixh7*rmixh7*rmixh;
intermediateValues[RMIXH7] = rmixh7;
intermediateValues[AH] = emixh*rmixh7;
intermediateValues[AH] = emixh*rmixh7;
for (unsigned int jj = 0; jj < static_cast<unsigned int>(numParticles); jj++) {
......
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