Commit 8469621f authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1747 from peastman/realtype

Eliminated RealOpenMM
parents b84e22ba 6813ca57
...@@ -24,11 +24,12 @@ ...@@ -24,11 +24,12 @@
#include "AmoebaReferenceForce.h" #include "AmoebaReferenceForce.h"
#include "AmoebaReferenceAngleForce.h" #include "AmoebaReferenceAngleForce.h"
#include "SimTKOpenMMRealType.h"
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceAngleForce::setPeriodic(OpenMM::RealVec* vectors) { void AmoebaReferenceAngleForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true; usePeriodic = true;
boxVectors[0] = vectors[0]; boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1]; boxVectors[1] = vectors[1];
...@@ -53,49 +54,35 @@ void AmoebaReferenceAngleForce::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -53,49 +54,35 @@ void AmoebaReferenceAngleForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceAngleForce::getPrefactorsGivenAngleCosine(RealOpenMM cosine, double AmoebaReferenceAngleForce::getPrefactorsGivenAngleCosine(double cosine,
RealOpenMM idealAngle, RealOpenMM angleK, double idealAngle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
RealOpenMM* dEdR) const { double* dEdR) const {
// --------------------------------------------------------------------------------------- double angle;
if (cosine >= 1.0) {
static const RealOpenMM zero = 0.0; angle = 0.0;
static const RealOpenMM one = 1.0; } else if (cosine <= -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 = "AmoebaReferenceAngleForce::getPrefactorsGivenAngleCosine";
// ---------------------------------------------------------------------------------------
RealOpenMM angle;
if (cosine >= one) {
angle = zero;
} else if (cosine <= -one) {
angle = RADIAN*PI_M; angle = RADIAN*PI_M;
} else { } else {
angle = RADIAN*ACOS(cosine); angle = RADIAN*ACOS(cosine);
} }
RealOpenMM deltaIdeal = angle - idealAngle; double deltaIdeal = angle - idealAngle;
RealOpenMM deltaIdeal2 = deltaIdeal*deltaIdeal; double deltaIdeal2 = deltaIdeal*deltaIdeal;
RealOpenMM deltaIdeal3 = deltaIdeal*deltaIdeal2; double deltaIdeal3 = deltaIdeal*deltaIdeal2;
RealOpenMM deltaIdeal4 = deltaIdeal2*deltaIdeal2; double deltaIdeal4 = deltaIdeal2*deltaIdeal2;
*dEdR = (two + three*angleCubic*deltaIdeal + *dEdR = (2.0 + 3.0*angleCubic*deltaIdeal +
four*angleQuartic*deltaIdeal2 + 4.0*angleQuartic*deltaIdeal2 +
five*anglePentic*deltaIdeal3 + 5.0*anglePentic*deltaIdeal3 +
six*angleSextic*deltaIdeal4); 6.0*angleSextic*deltaIdeal4);
*dEdR *= RADIAN*angleK*deltaIdeal; *dEdR *= RADIAN*angleK*deltaIdeal;
RealOpenMM energy = 1.0f + angleCubic*deltaIdeal + angleQuartic*deltaIdeal2 + double energy = 1.0f + angleCubic*deltaIdeal + angleQuartic*deltaIdeal2 +
anglePentic*deltaIdeal3 + angleSextic*deltaIdeal4; anglePentic*deltaIdeal3 + angleSextic*deltaIdeal4;
energy *= angleK*deltaIdeal2; energy *= angleK*deltaIdeal2;
return energy; return energy;
...@@ -120,60 +107,49 @@ RealOpenMM AmoebaReferenceAngleForce::getPrefactorsGivenAngleCosine(RealOpenMM c ...@@ -120,60 +107,49 @@ RealOpenMM AmoebaReferenceAngleForce::getPrefactorsGivenAngleCosine(RealOpenMM c
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceAngleForce::calculateAngleIxn(const RealVec& positionAtomA, const RealVec& positionAtomB, double AmoebaReferenceAngleForce::calculateAngleIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const RealVec& positionAtomC, const Vec3& positionAtomC,
RealOpenMM angle, RealOpenMM angleK, double angle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
RealVec* forces) const { Vec3* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceAngleForce::calculateAngleIxn";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM onePt5 = 1.5;
static const RealOpenMM two = 2.0;
// ---------------------------------------------------------------------------------------
std::vector<RealOpenMM> deltaR[2]; std::vector<double> deltaR[2];
if (usePeriodic) if (usePeriodic)
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomA, positionAtomB, deltaR[0], boxVectors); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomA, positionAtomB, deltaR[0], boxVectors);
else else
AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomB, deltaR[0]); AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomB, deltaR[0]);
RealOpenMM rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[0]); double rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[0]);
RealOpenMM rAB = SQRT(rAB2); double rAB = SQRT(rAB2);
if (usePeriodic) if (usePeriodic)
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomB, deltaR[1], boxVectors); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomB, deltaR[1], boxVectors);
else else
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomB, deltaR[1]); AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomB, deltaR[1]);
RealOpenMM rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[1]); double rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[1]);
RealOpenMM rCB = SQRT(rCB2); double rCB = SQRT(rCB2);
if (rAB <= zero || rCB <= zero) { if (rAB <= 0.0 || rCB <= 0.0) {
return zero; return 0.0;
} }
std::vector<RealOpenMM> pVector(3); std::vector<double> pVector(3);
AmoebaReferenceForce::getCrossProduct(deltaR[0], deltaR[1], pVector); AmoebaReferenceForce::getCrossProduct(deltaR[0], deltaR[1], pVector);
RealOpenMM rp = AmoebaReferenceForce::getNorm3(pVector); double rp = AmoebaReferenceForce::getNorm3(pVector);
if (rp < 1.0e-06) { if (rp < 1.0e-06) {
rp = 1.0e-06; rp = 1.0e-06;
} }
RealOpenMM dot = AmoebaReferenceForce::getDotProduct3(deltaR[0], deltaR[1]); double dot = AmoebaReferenceForce::getDotProduct3(deltaR[0], deltaR[1]);
RealOpenMM cosine = dot/(rAB*rCB); double cosine = dot/(rAB*rCB);
RealOpenMM dEdR; double dEdR;
RealOpenMM energy = getPrefactorsGivenAngleCosine(cosine, angle, angleK, angleCubic, angleQuartic, double energy = getPrefactorsGivenAngleCosine(cosine, angle, angleK, angleCubic, angleQuartic,
anglePentic, angleSextic, &dEdR); anglePentic, angleSextic, &dEdR);
RealOpenMM termA = dEdR/(rAB2*rp); double termA = dEdR/(rAB2*rp);
RealOpenMM termC = -dEdR/(rCB2*rp); double termC = -dEdR/(rCB2*rp);
std::vector<RealOpenMM> deltaCrossP[3]; std::vector<double> deltaCrossP[3];
deltaCrossP[0].resize(3); deltaCrossP[0].resize(3);
deltaCrossP[1].resize(3); deltaCrossP[1].resize(3);
deltaCrossP[2].resize(3); deltaCrossP[2].resize(3);
...@@ -196,27 +172,27 @@ RealOpenMM AmoebaReferenceAngleForce::calculateAngleIxn(const RealVec& positionA ...@@ -196,27 +172,27 @@ RealOpenMM AmoebaReferenceAngleForce::calculateAngleIxn(const RealVec& positionA
return energy; return energy;
} }
RealOpenMM AmoebaReferenceAngleForce::calculateForceAndEnergy(int numAngles, vector<RealVec>& posData, double AmoebaReferenceAngleForce::calculateForceAndEnergy(int numAngles, vector<Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<RealOpenMM>& angle, const std::vector<double>& angle,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<double>& kQuadratic,
RealOpenMM angleCubic, double angleCubic,
RealOpenMM angleQuartic, double angleQuartic,
RealOpenMM anglePentic, double anglePentic,
RealOpenMM angleSextic, double angleSextic,
vector<RealVec>& forceData) const { vector<Vec3>& forceData) const {
RealOpenMM energy = 0.0; double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numAngles); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(numAngles); ii++) {
int particle1Index = particle1[ii]; int particle1Index = particle1[ii];
int particle2Index = particle2[ii]; int particle2Index = particle2[ii];
int particle3Index = particle3[ii]; int particle3Index = particle3[ii];
RealOpenMM idealAngle = angle[ii]; double idealAngle = angle[ii];
RealOpenMM angleK = kQuadratic[ii]; double angleK = kQuadratic[ii];
RealVec forces[3]; Vec3 forces[3];
energy += calculateAngleIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], energy += calculateAngleIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index],
idealAngle, angleK, angleCubic, angleQuartic, anglePentic, angleSextic, forces); idealAngle, angleK, angleCubic, angleQuartic, anglePentic, angleSextic, forces);
for (unsigned int jj = 0; jj < 3; jj++) { for (unsigned int jj = 0; jj < 3; jj++) {
forceData[particle1Index][jj] += forces[0][jj]; forceData[particle1Index][jj] += forces[0][jj];
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceAngleForce_H__ #ifndef __AmoebaReferenceAngleForce_H__
#define __AmoebaReferenceAngleForce_H__ #define __AmoebaReferenceAngleForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
namespace OpenMM { namespace OpenMM {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors); void setPeriodic(OpenMM::Vec3* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -82,22 +82,22 @@ public: ...@@ -82,22 +82,22 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numAngles, std::vector<OpenMM::RealVec>& posData, double calculateForceAndEnergy(int numAngles, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<RealOpenMM>& angle, const std::vector<double>& angle,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<double>& kQuadratic,
RealOpenMM globalAngleCubic, double globalAngleCubic,
RealOpenMM globalAngleQuartic, double globalAngleQuartic,
RealOpenMM globalAnglePentic, double globalAnglePentic,
RealOpenMM globalAngleSextic, double globalAngleSextic,
std::vector<OpenMM::RealVec>& forceData) const; std::vector<OpenMM::Vec3>& forceData) const;
private: private:
bool usePeriodic; bool usePeriodic;
RealVec boxVectors[3]; Vec3 boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -117,10 +117,10 @@ private: ...@@ -117,10 +117,10 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM getPrefactorsGivenAngleCosine(RealOpenMM cosine, RealOpenMM idealAngle, RealOpenMM angleK, double getPrefactorsGivenAngleCosine(double cosine, double idealAngle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
RealOpenMM* dEdR) const; double* dEdR) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -141,12 +141,12 @@ private: ...@@ -141,12 +141,12 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateAngleIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, double calculateAngleIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::Vec3& positionAtomC,
RealOpenMM angle, RealOpenMM angleK, double angle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
OpenMM::RealVec* forces) const; OpenMM::Vec3* forces) const;
}; };
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceBondForce::setPeriodic(OpenMM::RealVec* vectors) { void AmoebaReferenceBondForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true; usePeriodic = true;
boxVectors[0] = vectors[0]; boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1]; boxVectors[1] = vectors[1];
...@@ -51,73 +51,61 @@ void AmoebaReferenceBondForce::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -51,73 +51,61 @@ void AmoebaReferenceBondForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceBondForce::calculateBondIxn(const RealVec& positionAtomA, const RealVec& positionAtomB, double AmoebaReferenceBondForce::calculateBondIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
RealOpenMM bondLength, RealOpenMM bondK, double bondLength, double bondK,
RealOpenMM bondCubic, RealOpenMM bondQuartic, double bondCubic, double bondQuartic,
RealVec* forces) const { Vec3* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceBondForce::calculateBondIxn";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM onePt5 = 1.5;
static const RealOpenMM two = 2.0;
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms // get deltaR, R2, and R between 2 atoms
std::vector<RealOpenMM> deltaR; std::vector<double> deltaR;
if (usePeriodic) if (usePeriodic)
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomA, positionAtomB, deltaR, boxVectors); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomA, positionAtomB, deltaR, boxVectors);
else else
AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomB, deltaR); AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomB, deltaR);
RealOpenMM r = AmoebaReferenceForce::getNorm3(deltaR); double r = AmoebaReferenceForce::getNorm3(deltaR);
// deltaIdeal = r - r_0 // deltaIdeal = r - r_0
RealOpenMM deltaIdeal = r - bondLength; double deltaIdeal = r - bondLength;
RealOpenMM deltaIdeal2 = deltaIdeal*deltaIdeal; double deltaIdeal2 = deltaIdeal*deltaIdeal;
RealOpenMM dEdR = (one + onePt5*bondCubic*deltaIdeal + two*bondQuartic*deltaIdeal2); double dEdR = (1.0 + 1.5*bondCubic*deltaIdeal + 2.0*bondQuartic*deltaIdeal2);
dEdR *= two*bondK*deltaIdeal; dEdR *= 2.0*bondK*deltaIdeal;
dEdR = r > zero ? (dEdR/r) : zero; dEdR = r > 0.0 ? (dEdR/r) : 0.0;
forces[0][0] = dEdR*deltaR[0]; forces[0][0] = dEdR*deltaR[0];
forces[0][1] = dEdR*deltaR[1]; forces[0][1] = dEdR*deltaR[1];
forces[0][2] = dEdR*deltaR[2]; forces[0][2] = dEdR*deltaR[2];
dEdR *= -1.0; dEdR *= -1.0;
forces[1][0] = dEdR*deltaR[0]; forces[1][0] = dEdR*deltaR[0];
forces[1][1] = dEdR*deltaR[1]; forces[1][1] = dEdR*deltaR[1];
forces[1][2] = dEdR*deltaR[2]; forces[1][2] = dEdR*deltaR[2];
RealOpenMM energy = bondK*deltaIdeal2*(one + bondCubic*deltaIdeal + bondQuartic*deltaIdeal2); double energy = bondK*deltaIdeal2*(1.0 + bondCubic*deltaIdeal + bondQuartic*deltaIdeal2);
return energy; return energy;
} }
RealOpenMM AmoebaReferenceBondForce::calculateForceAndEnergy(int numBonds, double AmoebaReferenceBondForce::calculateForceAndEnergy(int numBonds,
vector<RealVec>& particlePositions, vector<Vec3>& particlePositions,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<RealOpenMM>& length, const std::vector<double>& length,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<double>& kQuadratic,
RealOpenMM globalBondCubic, double globalBondCubic,
RealOpenMM globalBondQuartic, double globalBondQuartic,
vector<RealVec>& forceData) const { vector<Vec3>& forceData) const {
RealOpenMM energy = 0.0; double energy = 0.0;
for (int ii = 0; ii < numBonds; ii++) { for (int ii = 0; ii < numBonds; ii++) {
int particle1Index = particle1[ii]; int particle1Index = particle1[ii];
int particle2Index = particle2[ii]; int particle2Index = particle2[ii];
RealOpenMM bondLength = length[ii]; double bondLength = length[ii];
RealOpenMM bondK = kQuadratic[ii]; double bondK = kQuadratic[ii];
RealVec forces[2]; Vec3 forces[2];
energy += calculateBondIxn(particlePositions[particle1Index], particlePositions[particle2Index], energy += calculateBondIxn(particlePositions[particle1Index], particlePositions[particle2Index],
bondLength, bondK, globalBondCubic, globalBondQuartic, bondLength, bondK, globalBondCubic, globalBondQuartic,
forces); forces);
for (int jj = 0; jj < 3; jj++) { for (int jj = 0; jj < 3; jj++) {
forceData[particle1Index][jj] += forces[0][jj]; forceData[particle1Index][jj] += forces[0][jj];
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceBondForce_H__ #ifndef __AmoebaReferenceBondForce_H__
#define __AmoebaReferenceBondForce_H__ #define __AmoebaReferenceBondForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
namespace OpenMM { namespace OpenMM {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors); void setPeriodic(OpenMM::Vec3* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -78,18 +78,18 @@ public: ...@@ -78,18 +78,18 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numBonds, std::vector<OpenMM::RealVec>& posData, double calculateForceAndEnergy(int numBonds, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<RealOpenMM>& bondLength, const std::vector<double>& bondLength,
const std::vector<RealOpenMM>& bondK, const std::vector<double>& bondK,
RealOpenMM bondCubic, RealOpenMM bondQuartic, double bondCubic, double bondQuartic,
std::vector<OpenMM::RealVec>& forceData) const; std::vector<OpenMM::Vec3>& forceData) const;
private: private:
bool usePeriodic; bool usePeriodic;
RealVec boxVectors[3]; Vec3 boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -107,10 +107,10 @@ private: ...@@ -107,10 +107,10 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateBondIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, double calculateBondIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
RealOpenMM bondLength, RealOpenMM bondK, double bondLength, double bondK,
RealOpenMM bondCubic, RealOpenMM bondQuartic, double bondCubic, double bondQuartic,
OpenMM::RealVec* forces) const; OpenMM::Vec3* forces) const;
}; };
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
#include "AmoebaReferenceForce.h" #include "AmoebaReferenceForce.h"
#include <cmath>
#include <vector> #include <vector>
using namespace OpenMM; using namespace OpenMM;
...@@ -37,8 +38,8 @@ using namespace OpenMM; ...@@ -37,8 +38,8 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::loadDeltaR(const RealVec& xVector, const RealVec& yVector, void AmoebaReferenceForce::loadDeltaR(const Vec3& xVector, const Vec3& yVector,
std::vector<RealOpenMM>& deltaR) { std::vector<double>& deltaR) {
deltaR.resize(0); deltaR.resize(0);
deltaR.push_back(yVector[0] - xVector[0]); deltaR.push_back(yVector[0] - xVector[0]);
deltaR.push_back(yVector[1] - xVector[1]); deltaR.push_back(yVector[1] - xVector[1]);
...@@ -56,9 +57,9 @@ void AmoebaReferenceForce::loadDeltaR(const RealVec& xVector, const RealVec& yVe ...@@ -56,9 +57,9 @@ void AmoebaReferenceForce::loadDeltaR(const RealVec& xVector, const RealVec& yVe
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::loadDeltaRPeriodic(const RealVec& xVector, const RealVec& yVector, void AmoebaReferenceForce::loadDeltaRPeriodic(const Vec3& xVector, const Vec3& yVector,
std::vector<RealOpenMM>& deltaR, const RealVec* boxVectors) { std::vector<double>& deltaR, const Vec3* boxVectors) {
RealVec diff = yVector-xVector; Vec3 diff = yVector-xVector;
diff -= boxVectors[2]*floor(diff[2]/boxVectors[2][2]+0.5); diff -= boxVectors[2]*floor(diff[2]/boxVectors[2][2]+0.5);
diff -= boxVectors[1]*floor(diff[1]/boxVectors[1][1]+0.5); diff -= boxVectors[1]*floor(diff[1]/boxVectors[1][1]+0.5);
diff -= boxVectors[0]*floor(diff[0]/boxVectors[0][0]+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 ...@@ -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 // get 3 norm
return (inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]); return (inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
...@@ -94,7 +95,7 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const std::vector<RealOpenMM>& ...@@ -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 // get 3 norm
return (inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]); return (inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
...@@ -110,25 +111,25 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const RealOpenMM* inputVector) ...@@ -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 // 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 // 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) { double AmoebaReferenceForce::normalizeVector3(double* inputVector) {
RealOpenMM norm = SQRT(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]); double norm = sqrt(inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2]);
if (norm > 0.0) { if (norm > 0.0) {
RealOpenMM normI = 1.0/norm; double normI = 1.0/norm;
inputVector[0] *= normI; inputVector[0] *= normI;
inputVector[1] *= normI; inputVector[1] *= normI;
inputVector[2] *= normI; inputVector[2] *= normI;
} }
return norm; return norm;
...@@ -145,7 +146,7 @@ RealOpenMM AmoebaReferenceForce::normalizeVector3(RealOpenMM* inputVector) { ...@@ -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 // get dot product
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2]; 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 ...@@ -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 // get dot product
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2]; 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 // get dot product
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2]; return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2];
...@@ -186,7 +187,7 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(const RealOpenMM* xVector, const ...@@ -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 // get dot product
return xVector[vectorOffset+0]*yVector[0] + xVector[vectorOffset+1]*yVector[1] + xVector[vectorOffset+2]*yVector[2]; 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 ...@@ -202,9 +203,9 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(unsigned int vectorOffset, const
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::getCrossProduct(const std::vector<RealOpenMM>& xVector, void AmoebaReferenceForce::getCrossProduct(const std::vector<double>& xVector,
const std::vector<RealOpenMM>& yVector, const std::vector<double>& yVector,
std::vector<RealOpenMM>& zVector) { std::vector<double>& zVector) {
zVector[0] = xVector[1]*yVector[2] - xVector[2]*yVector[1]; zVector[0] = xVector[1]*yVector[2] - xVector[2]*yVector[1];
zVector[1] = xVector[2]*yVector[0] - xVector[0]*yVector[2]; zVector[1] = xVector[2]*yVector[0] - xVector[0]*yVector[2];
zVector[2] = xVector[0]*yVector[1] - xVector[1]*yVector[0]; zVector[2] = xVector[0]*yVector[1] - xVector[1]*yVector[0];
...@@ -220,9 +221,9 @@ void AmoebaReferenceForce::getCrossProduct(const std::vector<RealOpenMM>& xVecto ...@@ -220,9 +221,9 @@ void AmoebaReferenceForce::getCrossProduct(const std::vector<RealOpenMM>& xVecto
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::getCrossProduct(const RealOpenMM* xVector, void AmoebaReferenceForce::getCrossProduct(const double* xVector,
const RealOpenMM* yVector, const double* yVector,
RealOpenMM* zVector) { double* zVector) {
zVector[0] = xVector[1]*yVector[2] - xVector[2]*yVector[1]; zVector[0] = xVector[1]*yVector[2] - xVector[2]*yVector[1];
zVector[1] = xVector[2]*yVector[0] - xVector[0]*yVector[2]; zVector[1] = xVector[2]*yVector[0] - xVector[0]*yVector[2];
zVector[2] = xVector[0]*yVector[1] - xVector[1]*yVector[0]; zVector[2] = xVector[0]*yVector[1] - xVector[1]*yVector[0];
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#ifndef __AmoebaReferenceForce_H__ #ifndef __AmoebaReferenceForce_H__
#define __AmoebaReferenceForce_H__ #define __AmoebaReferenceForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
...@@ -62,8 +61,8 @@ public: ...@@ -62,8 +61,8 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static void loadDeltaR(const OpenMM::RealVec& xVector, const OpenMM::RealVec& yVector, static void loadDeltaR(const OpenMM::Vec3& xVector, const OpenMM::Vec3& yVector,
std::vector<RealOpenMM>& deltaR); std::vector<double>& deltaR);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Load delta of two vectors, applying periodic boundary conditions Load delta of two vectors, applying periodic boundary conditions
...@@ -75,7 +74,7 @@ public: ...@@ -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: ...@@ -87,8 +86,8 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static RealOpenMM getNormSquared3(const std::vector<RealOpenMM>& inputVector); static double getNormSquared3(const std::vector<double>& inputVector);
static RealOpenMM getNormSquared3(const RealOpenMM* inputVector); static double getNormSquared3(const double* inputVector);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -100,8 +99,8 @@ public: ...@@ -100,8 +99,8 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static RealOpenMM getNorm3(const std::vector<RealOpenMM>& inputVector); static double getNorm3(const std::vector<double>& inputVector);
static RealOpenMM getNorm3(const RealOpenMM* inputVector); static double getNorm3(const double* inputVector);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -113,7 +112,7 @@ public: ...@@ -113,7 +112,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static RealOpenMM normalizeVector3(RealOpenMM* inputVector); static double normalizeVector3(double* inputVector);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -126,10 +125,10 @@ public: ...@@ -126,10 +125,10 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static RealOpenMM getDotProduct3(const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector); static double getDotProduct3(const std::vector<double>& xVector, const std::vector<double>& yVector);
static RealOpenMM getDotProduct3(const RealOpenMM* xVector, const RealOpenMM* yVector); static double getDotProduct3(const double* xVector, const double* yVector);
static RealOpenMM getDotProduct3(const RealOpenMM* xVector, const OpenMM::Vec3& yVector); static double getDotProduct3(const double* xVector, const OpenMM::Vec3& yVector);
static RealOpenMM getDotProduct3(unsigned int vectorOffset, const std::vector<RealOpenMM>& xVector, const RealOpenMM* yVector); static double getDotProduct3(unsigned int vectorOffset, const std::vector<double>& xVector, const double* yVector);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -141,10 +140,10 @@ public: ...@@ -141,10 +140,10 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static void getCrossProduct(const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector, static void getCrossProduct(const std::vector<double>& xVector, const std::vector<double>& yVector,
std::vector<RealOpenMM>& zVector); 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 @@ ...@@ -22,6 +22,7 @@
*/ */
#include "AmoebaReferenceGeneralizedKirkwoodForce.h" #include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include <cmath>
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
...@@ -61,120 +62,113 @@ int AmoebaReferenceGeneralizedKirkwoodForce::getDirectPolarization() const { ...@@ -61,120 +62,113 @@ int AmoebaReferenceGeneralizedKirkwoodForce::getDirectPolarization() const {
return _directPolarization; return _directPolarization;
} }
void AmoebaReferenceGeneralizedKirkwoodForce::setSoluteDielectric(RealOpenMM soluteDielectric) { void AmoebaReferenceGeneralizedKirkwoodForce::setSoluteDielectric(double soluteDielectric) {
_soluteDielectric = soluteDielectric; _soluteDielectric = soluteDielectric;
} }
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getSoluteDielectric() const { double AmoebaReferenceGeneralizedKirkwoodForce::getSoluteDielectric() const {
return _soluteDielectric; return _soluteDielectric;
} }
void AmoebaReferenceGeneralizedKirkwoodForce::setSolventDielectric(RealOpenMM solventDielectric) { void AmoebaReferenceGeneralizedKirkwoodForce::setSolventDielectric(double solventDielectric) {
_solventDielectric = solventDielectric; _solventDielectric = solventDielectric;
} }
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getSolventDielectric() const { double AmoebaReferenceGeneralizedKirkwoodForce::getSolventDielectric() const {
return _solventDielectric; return _solventDielectric;
} }
void AmoebaReferenceGeneralizedKirkwoodForce::setDielectricOffset(RealOpenMM dielectricOffset) { void AmoebaReferenceGeneralizedKirkwoodForce::setDielectricOffset(double dielectricOffset) {
_dielectricOffset = dielectricOffset; _dielectricOffset = dielectricOffset;
} }
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getDielectricOffset() const { double AmoebaReferenceGeneralizedKirkwoodForce::getDielectricOffset() const {
return _dielectricOffset; return _dielectricOffset;
} }
void AmoebaReferenceGeneralizedKirkwoodForce::setProbeRadius(RealOpenMM probeRadius) { void AmoebaReferenceGeneralizedKirkwoodForce::setProbeRadius(double probeRadius) {
_probeRadius = probeRadius; _probeRadius = probeRadius;
} }
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getProbeRadius() const { double AmoebaReferenceGeneralizedKirkwoodForce::getProbeRadius() const {
return _probeRadius; return _probeRadius;
} }
void AmoebaReferenceGeneralizedKirkwoodForce::setSurfaceAreaFactor(RealOpenMM surfaceAreaFactor) { void AmoebaReferenceGeneralizedKirkwoodForce::setSurfaceAreaFactor(double surfaceAreaFactor) {
_surfaceAreaFactor = surfaceAreaFactor; _surfaceAreaFactor = surfaceAreaFactor;
} }
RealOpenMM AmoebaReferenceGeneralizedKirkwoodForce::getSurfaceAreaFactor() const { double AmoebaReferenceGeneralizedKirkwoodForce::getSurfaceAreaFactor() const {
return _surfaceAreaFactor; return _surfaceAreaFactor;
} }
void AmoebaReferenceGeneralizedKirkwoodForce::setAtomicRadii(const vector<RealOpenMM>& atomicRadii) { void AmoebaReferenceGeneralizedKirkwoodForce::setAtomicRadii(const vector<double>& atomicRadii) {
_atomicRadii.resize(atomicRadii.size()); _atomicRadii.resize(atomicRadii.size());
copy(atomicRadii.begin(), atomicRadii.end(), _atomicRadii.begin()); 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()); atomicRadii.resize(_atomicRadii.size());
copy(_atomicRadii.begin(), _atomicRadii.end(), atomicRadii.begin()); 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()); _scaleFactors.resize(scaleFactors.size());
copy(scaleFactors.begin(), scaleFactors.end(), _scaleFactors.begin()); 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()); scaleFactors.resize(_scaleFactors.size());
copy(_scaleFactors.begin(), _scaleFactors.end(), scaleFactors.begin()); 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()); _charges.resize(charges.size());
copy(charges.begin(), charges.end(), _charges.begin()); 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()); bornRadii.resize(_bornRadii.size());
copy(_bornRadii.begin(), _bornRadii.end(), bornRadii.begin()); 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 double bigRadius = 1000.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;
_bornRadii.resize(_numParticles); _bornRadii.resize(_numParticles);
for (unsigned int ii = 0; ii < _numParticles; ii++) { for (unsigned int ii = 0; ii < _numParticles; ii++) {
if (_atomicRadii[ii] <= zero) { if (_atomicRadii[ii] <= 0.0) {
_bornRadii[ii] = bigRadius; _bornRadii[ii] = bigRadius;
continue; continue;
} }
RealOpenMM bornSum = zero; double bornSum = 0.0;
for (unsigned int jj = 0; jj < _numParticles; jj++) { 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]; double xr = particlePositions[jj][0] - particlePositions[ii][0];
RealOpenMM yr = particlePositions[jj][1] - particlePositions[ii][1]; double yr = particlePositions[jj][1] - particlePositions[ii][1];
RealOpenMM zr = particlePositions[jj][2] - particlePositions[ii][2]; double zr = particlePositions[jj][2] - particlePositions[ii][2];
RealOpenMM r2 = xr*xr + yr*yr + zr*zr; double r2 = xr*xr + yr*yr + zr*zr;
RealOpenMM r = SQRT(r2); double r = sqrt(r2);
RealOpenMM sk = _atomicRadii[jj]*_scaleFactors[jj]; double sk = _atomicRadii[jj]*_scaleFactors[jj];
RealOpenMM sk2 = sk*sk; double sk2 = sk*sk;
if ((_atomicRadii[ii] + r) < sk) { if ((_atomicRadii[ii] + r) < sk) {
RealOpenMM lik = _atomicRadii[ii]; double lik = _atomicRadii[ii];
RealOpenMM uik = sk - r; double uik = sk - r;
RealOpenMM lik3 = lik*lik*lik; double lik3 = lik*lik*lik;
RealOpenMM uik3 = uik*uik*uik; double uik3 = uik*uik*uik;
bornSum -= (one/uik3 - one/lik3); bornSum -= (1.0/uik3 - 1.0/lik3);
} }
RealOpenMM uik = r + sk; double uik = r + sk;
RealOpenMM lik; double lik;
if ((_atomicRadii[ii] + r) < sk) { if ((_atomicRadii[ii] + r) < sk) {
lik = sk - r; lik = sk - r;
} else if (r < (_atomicRadii[ii] + sk)) { } else if (r < (_atomicRadii[ii] + sk)) {
...@@ -183,22 +177,22 @@ void AmoebaReferenceGeneralizedKirkwoodForce::calculateGrycukBornRadii(const vec ...@@ -183,22 +177,22 @@ void AmoebaReferenceGeneralizedKirkwoodForce::calculateGrycukBornRadii(const vec
lik = r - sk; lik = r - sk;
} }
RealOpenMM l2 = lik*lik; double l2 = lik*lik;
RealOpenMM l4 = l2*l2; double l4 = l2*l2;
RealOpenMM lr = lik*r; double lr = lik*r;
RealOpenMM l4r = l4*r; double l4r = l4*r;
RealOpenMM u2 = uik*uik; double u2 = uik*uik;
RealOpenMM u4 = u2*u2; double u4 = u2*u2;
RealOpenMM ur = uik*r; double ur = uik*r;
RealOpenMM u4r = u4*r; double u4r = u4*r;
RealOpenMM term = (three*(r2-sk2) + six*u2 - eight*ur)/u4r - (three*(r2-sk2) + six*l2 - eight*lr)/l4r; 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/sixteen; bornSum += term/16.0;
} }
bornSum = one/(_atomicRadii[ii]*_atomicRadii[ii]*_atomicRadii[ii]) - bornSum; bornSum = 1.0/(_atomicRadii[ii]*_atomicRadii[ii]*_atomicRadii[ii]) - bornSum;
_bornRadii[ii] = (bornSum <= zero) ? bigRadius : POW(bornSum, -oneThird); _bornRadii[ii] = (bornSum <= 0.0) ? bigRadius : pow(bornSum, -1.0/3.0);
} }
return; return;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceGeneralizedKirkwoodForce_H__ #ifndef __AmoebaReferenceGeneralizedKirkwoodForce_H__
#define __AmoebaReferenceGeneralizedKirkwoodForce_H__ #define __AmoebaReferenceGeneralizedKirkwoodForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
using namespace OpenMM; using namespace OpenMM;
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
* *
* @return soluteDielectric * @return soluteDielectric
*/ */
RealOpenMM getSoluteDielectric() const; double getSoluteDielectric() const;
/** /**
* Set solute dielectric * Set solute dielectric
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
* @param soluteDielectric solute dielectric * @param soluteDielectric solute dielectric
* *
*/ */
void setSoluteDielectric(RealOpenMM soluteDielectric); void setSoluteDielectric(double soluteDielectric);
/** /**
* Get solvent dielectric * Get solvent dielectric
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
* @return solventDielectric * @return solventDielectric
* *
*/ */
RealOpenMM getSolventDielectric() const; double getSolventDielectric() const;
/** /**
* Set solvent dielectric * Set solvent dielectric
...@@ -125,7 +125,7 @@ public: ...@@ -125,7 +125,7 @@ public:
* @param solventDielectric solvent dielectric * @param solventDielectric solvent dielectric
* *
*/ */
void setSolventDielectric(RealOpenMM solventDielectric); void setSolventDielectric(double solventDielectric);
/** /**
* Get dielectric offset * Get dielectric offset
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
* @return dielectricOffset * @return dielectricOffset
* *
*/ */
RealOpenMM getDielectricOffset() const; double getDielectricOffset() const;
/** /**
* Set dielectric offset * Set dielectric offset
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
* @param dielectricOffset dielectric offset * @param dielectricOffset dielectric offset
* *
*/ */
void setDielectricOffset(RealOpenMM dielectricOffset); void setDielectricOffset(double dielectricOffset);
/** /**
* Get probeRadius * Get probeRadius
...@@ -149,7 +149,7 @@ public: ...@@ -149,7 +149,7 @@ public:
* @return probeRadius * @return probeRadius
* *
*/ */
RealOpenMM getProbeRadius() const; double getProbeRadius() const;
/** /**
* Set probe radius * Set probe radius
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
* @param probeRadius probe radiue * @param probeRadius probe radiue
* *
*/ */
void setProbeRadius(RealOpenMM probeRadius); void setProbeRadius(double probeRadius);
/** /**
* Get surfaceAreaFactor * Get surfaceAreaFactor
...@@ -165,7 +165,7 @@ public: ...@@ -165,7 +165,7 @@ public:
* @return surfaceAreaFactor * @return surfaceAreaFactor
* *
*/ */
RealOpenMM getSurfaceAreaFactor() const; double getSurfaceAreaFactor() const;
/** /**
* Set surface area factor * Set surface area factor
...@@ -173,7 +173,7 @@ public: ...@@ -173,7 +173,7 @@ public:
* @param surfaceAreaFactor surface area factor * @param surfaceAreaFactor surface area factor
* *
*/ */
void setSurfaceAreaFactor(RealOpenMM surfaceAreaFactor); void setSurfaceAreaFactor(double surfaceAreaFactor);
/** /**
* Set atomic radii * Set atomic radii
...@@ -181,7 +181,7 @@ public: ...@@ -181,7 +181,7 @@ public:
* @param atomicRadii input vector of atomic radii * @param atomicRadii input vector of atomic radii
* *
*/ */
void setAtomicRadii(const vector<RealOpenMM>& atomicRadii); void setAtomicRadii(const vector<double>& atomicRadii);
/** /**
* Get atomic radii * Get atomic radii
...@@ -189,7 +189,7 @@ public: ...@@ -189,7 +189,7 @@ public:
* @param atomicRadii output vector of atomic radii * @param atomicRadii output vector of atomic radii
* *
*/ */
void getAtomicRadii(vector<RealOpenMM>& atomicRadii) const; void getAtomicRadii(vector<double>& atomicRadii) const;
/** /**
* Set scale factors * Set scale factors
...@@ -197,7 +197,7 @@ public: ...@@ -197,7 +197,7 @@ public:
* @param scaleFactors input vector of scale factors * @param scaleFactors input vector of scale factors
* *
*/ */
void setScaleFactors(const vector<RealOpenMM>& scaleFactors); void setScaleFactors(const vector<double>& scaleFactors);
/** /**
* Get scale factors * Get scale factors
...@@ -205,7 +205,7 @@ public: ...@@ -205,7 +205,7 @@ public:
* @param scaleFactors output vector of scale factors * @param scaleFactors output vector of scale factors
* *
*/ */
void getScaleFactors(vector<RealOpenMM>& scaleFactors) const; void getScaleFactors(vector<double>& scaleFactors) const;
/** /**
* Set charges * Set charges
...@@ -213,7 +213,7 @@ public: ...@@ -213,7 +213,7 @@ public:
* @param charges input vector of charges * @param charges input vector of charges
* *
*/ */
void setCharges(const vector<RealOpenMM>& charges); void setCharges(const vector<double>& charges);
/** /**
* Calculate Grycuk Born radii * Calculate Grycuk Born radii
...@@ -221,7 +221,7 @@ public: ...@@ -221,7 +221,7 @@ public:
* @param particlePositions particle positions * @param particlePositions particle positions
* *
*/ */
void calculateGrycukBornRadii(const vector<RealVec>& particlePositions); void calculateGrycukBornRadii(const vector<Vec3>& particlePositions);
/** /**
* Get Grycik Born radii (must have called calculateGrycukBornRadii()) * Get Grycik Born radii (must have called calculateGrycukBornRadii())
...@@ -229,7 +229,7 @@ public: ...@@ -229,7 +229,7 @@ public:
* @param bornRadii vector of Born radii * @param bornRadii vector of Born radii
* *
*/ */
void getGrycukBornRadii(vector<RealOpenMM>& bornRadii) const; void getGrycukBornRadii(vector<double>& bornRadii) const;
private: private:
...@@ -237,17 +237,17 @@ private: ...@@ -237,17 +237,17 @@ private:
int _includeCavityTerm; int _includeCavityTerm;
int _directPolarization; int _directPolarization;
RealOpenMM _soluteDielectric; double _soluteDielectric;
RealOpenMM _solventDielectric; double _solventDielectric;
RealOpenMM _dielectricOffset; double _dielectricOffset;
RealOpenMM _probeRadius; double _probeRadius;
RealOpenMM _surfaceAreaFactor; double _surfaceAreaFactor;
std::vector<RealOpenMM> _atomicRadii; std::vector<double> _atomicRadii;
std::vector<RealOpenMM> _scaleFactors; std::vector<double> _scaleFactors;
std::vector<RealOpenMM> _charges; std::vector<double> _charges;
std::vector<RealOpenMM> _bornRadii; std::vector<double> _bornRadii;
}; };
......
...@@ -25,11 +25,12 @@ ...@@ -25,11 +25,12 @@
#include "AmoebaReferenceForce.h" #include "AmoebaReferenceForce.h"
#include "AmoebaReferenceInPlaneAngleForce.h" #include "AmoebaReferenceInPlaneAngleForce.h"
#include "ReferenceForce.h" #include "ReferenceForce.h"
#include "SimTKOpenMMRealType.h"
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::RealVec* vectors) { void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true; usePeriodic = true;
boxVectors[0] = vectors[0]; boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1]; boxVectors[1] = vectors[1];
...@@ -54,49 +55,34 @@ void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -54,49 +55,34 @@ void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(RealOpenMM cosine, double AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(double cosine,
RealOpenMM idealAngle, RealOpenMM angleK, double idealAngle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
RealOpenMM* dEdR) const { double* dEdR) const {
double angle;
// --------------------------------------------------------------------------------------- if (cosine >= 1.0) {
angle = 0.0;
static const RealOpenMM zero = 0.0; } else if (cosine <= -1.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) {
angle = RADIAN*PI_M; angle = RADIAN*PI_M;
} else { } else {
angle = RADIAN*ACOS(cosine); angle = RADIAN*ACOS(cosine);
} }
RealOpenMM deltaIdeal = angle - idealAngle; double deltaIdeal = angle - idealAngle;
RealOpenMM deltaIdeal2 = deltaIdeal*deltaIdeal; double deltaIdeal2 = deltaIdeal*deltaIdeal;
RealOpenMM deltaIdeal3 = deltaIdeal*deltaIdeal2; double deltaIdeal3 = deltaIdeal*deltaIdeal2;
RealOpenMM deltaIdeal4 = deltaIdeal2*deltaIdeal2; double deltaIdeal4 = deltaIdeal2*deltaIdeal2;
*dEdR = (two + three*angleCubic*deltaIdeal + *dEdR = (2.0 + 3.0*angleCubic*deltaIdeal +
four*angleQuartic*deltaIdeal2 + 4.0*angleQuartic*deltaIdeal2 +
five*anglePentic*deltaIdeal3 + 5.0*anglePentic*deltaIdeal3 +
six*angleSextic*deltaIdeal4); 6.0*angleSextic*deltaIdeal4);
*dEdR *= RADIAN*angleK*deltaIdeal; *dEdR *= RADIAN*angleK*deltaIdeal;
RealOpenMM energy = 1.0f + angleCubic*deltaIdeal + angleQuartic*deltaIdeal2 + double energy = 1.0f + angleCubic*deltaIdeal + angleQuartic*deltaIdeal2 +
anglePentic*deltaIdeal3 + angleSextic*deltaIdeal4; anglePentic*deltaIdeal3 + angleSextic*deltaIdeal4;
energy *= angleK*deltaIdeal2; energy *= angleK*deltaIdeal2;
return energy; return energy;
...@@ -122,12 +108,12 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(RealO ...@@ -122,12 +108,12 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(RealO
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& positionAtomA, const RealVec& positionAtomB, double AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD, const Vec3& positionAtomC, const Vec3& positionAtomD,
RealOpenMM angle, RealOpenMM angleK, double angle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
RealVec* forces) const { Vec3* forces) const {
// T = AD x CD // T = AD x CD
// P = B + T*delta // P = B + T*delta
// AP = A - P // AP = A - P
...@@ -136,7 +122,7 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po ...@@ -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 }; 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) { if (usePeriodic) {
deltaR[AD] = ReferenceForce::getDeltaRPeriodic(positionAtomD, positionAtomA, boxVectors); deltaR[AD] = ReferenceForce::getDeltaRPeriodic(positionAtomD, positionAtomA, boxVectors);
deltaR[BD] = ReferenceForce::getDeltaRPeriodic(positionAtomD, positionAtomB, boxVectors); deltaR[BD] = ReferenceForce::getDeltaRPeriodic(positionAtomD, positionAtomB, boxVectors);
...@@ -150,9 +136,8 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po ...@@ -150,9 +136,8 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
deltaR[T] = deltaR[AD].cross(deltaR[CD]); deltaR[T] = deltaR[AD].cross(deltaR[CD]);
RealOpenMM rT2 = deltaR[T].dot(deltaR[T]); double rT2 = deltaR[T].dot(deltaR[T]);
RealOpenMM delta = deltaR[T].dot(deltaR[BD])/rT2; double delta = -deltaR[T].dot(deltaR[BD])/rT2;
delta *= -1;
deltaR[P] = positionAtomB + deltaR[T]*delta; deltaR[P] = positionAtomB + deltaR[T]*delta;
if (usePeriodic) { if (usePeriodic) {
...@@ -164,28 +149,28 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po ...@@ -164,28 +149,28 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
deltaR[CP] = ReferenceForce::getDeltaR(deltaR[P], positionAtomC); deltaR[CP] = ReferenceForce::getDeltaR(deltaR[P], positionAtomC);
} }
RealOpenMM rAp2 = deltaR[AP].dot(deltaR[AP]); double rAp2 = deltaR[AP].dot(deltaR[AP]);
RealOpenMM rCp2 = deltaR[CP].dot(deltaR[CP]); double rCp2 = deltaR[CP].dot(deltaR[CP]);
if (rAp2 <= 0 && rCp2 <= 0) { if (rAp2 <= 0 && rCp2 <= 0) {
return 0; return 0;
} }
deltaR[M] = deltaR[CP].cross(deltaR[AP]); 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) { if (rm < 1.0e-06) {
rm = 1.0e-06; rm = 1.0e-06;
} }
RealOpenMM dot = deltaR[AP].dot(deltaR[CP]); double dot = deltaR[AP].dot(deltaR[CP]);
RealOpenMM cosine = dot/SQRT(rAp2*rCp2); double cosine = dot/SQRT(rAp2*rCp2);
RealOpenMM dEdR; double dEdR;
RealOpenMM energy = getPrefactorsGivenAngleCosine(cosine, angle, angleK, angleCubic, angleQuartic, double energy = getPrefactorsGivenAngleCosine(cosine, angle, angleK, angleCubic, angleQuartic,
anglePentic, angleSextic, &dEdR); anglePentic, angleSextic, &dEdR);
RealOpenMM termA = -dEdR/(rAp2*rm); double termA = -dEdR/(rAp2*rm);
RealOpenMM termC = dEdR/(rCp2*rm); double termC = dEdR/(rCp2*rm);
deltaR[APxM] = deltaR[AP].cross(deltaR[M]); deltaR[APxM] = deltaR[AP].cross(deltaR[M]);
deltaR[CPxM] = deltaR[CP].cross(deltaR[M]); deltaR[CPxM] = deltaR[CP].cross(deltaR[M]);
...@@ -193,27 +178,27 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po ...@@ -193,27 +178,27 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
// forces will be gathered here // forces will be gathered here
enum { dA, dB, dC, dD, LastDIndex }; enum { dA, dB, dC, dD, LastDIndex };
RealVec forceTerm[LastDIndex]; Vec3 forceTerm[LastDIndex];
forceTerm[dA] = deltaR[APxM]*termA; forceTerm[dA] = deltaR[APxM]*termA;
forceTerm[dC] = deltaR[CPxM]*termC; forceTerm[dC] = deltaR[CPxM]*termC;
forceTerm[dB] = -(forceTerm[dA] + forceTerm[dC]); forceTerm[dB] = -(forceTerm[dA] + forceTerm[dC]);
RealOpenMM pTrT2 = forceTerm[dB].dot(deltaR[T]); double pTrT2 = forceTerm[dB].dot(deltaR[T]);
pTrT2 /= rT2; pTrT2 /= rT2;
deltaR[CDxdB] = deltaR[CD].cross(forceTerm[dB]); deltaR[CDxdB] = deltaR[CD].cross(forceTerm[dB]);
deltaR[dBxAD] = forceTerm[dB].cross(deltaR[AD]); deltaR[dBxAD] = forceTerm[dB].cross(deltaR[AD]);
if (FABS(pTrT2) > 1.0e-08) { if (FABS(pTrT2) > 1.0e-08) {
RealOpenMM delta2 = delta*2; double delta2 = delta*2;
deltaR[BDxCD] = forceTerm[dB].cross(deltaR[CD]); deltaR[BDxCD] = forceTerm[dB].cross(deltaR[CD]);
deltaR[TxCD] = forceTerm[T].cross(deltaR[CD]); deltaR[TxCD] = forceTerm[T].cross(deltaR[CD]);
deltaR[ADxBD] = forceTerm[AD].cross(deltaR[BD]); deltaR[ADxBD] = forceTerm[AD].cross(deltaR[BD]);
deltaR[ADxT] = forceTerm[AD].cross(deltaR[T]); 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; forceTerm[dA] += deltaR[CDxdB]*delta + term*pTrT2;
term = deltaR[ADxBD] + deltaR[ADxT]*delta2; term = deltaR[ADxBD] + deltaR[ADxT]*delta2;
forceTerm[dC] += deltaR[dBxAD]*delta + term*pTrT2; forceTerm[dC] += deltaR[dBxAD]*delta + term*pTrT2;
...@@ -233,29 +218,29 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po ...@@ -233,29 +218,29 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
} }
RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateForceAndEnergy(int numAngles, vector<RealVec>& posData, double AmoebaReferenceInPlaneAngleForce::calculateForceAndEnergy(int numAngles, vector<Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<RealOpenMM>& angle, const std::vector<double>& angle,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<double>& kQuadratic,
RealOpenMM angleCubic, double angleCubic,
RealOpenMM angleQuartic, double angleQuartic,
RealOpenMM anglePentic, double anglePentic,
RealOpenMM angleSextic, double angleSextic,
vector<RealVec>& forceData) const { vector<Vec3>& forceData) const {
RealOpenMM energy = 0.0; double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numAngles); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(numAngles); ii++) {
int particle1Index = particle1[ii]; int particle1Index = particle1[ii];
int particle2Index = particle2[ii]; int particle2Index = particle2[ii];
int particle3Index = particle3[ii]; int particle3Index = particle3[ii];
int particle4Index = particle4[ii]; int particle4Index = particle4[ii];
RealOpenMM idealAngle = angle[ii]; double idealAngle = angle[ii];
RealOpenMM angleK = kQuadratic[ii]; double angleK = kQuadratic[ii];
RealVec forces[4]; Vec3 forces[4];
energy += calculateAngleIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], posData[particle4Index], energy += calculateAngleIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], posData[particle4Index],
idealAngle, angleK, angleCubic, angleQuartic, anglePentic, angleSextic, forces); idealAngle, angleK, angleCubic, angleQuartic, anglePentic, angleSextic, forces);
// accumulate forces // accumulate forces
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceInPlaneAngleForce_H__ #ifndef __AmoebaReferenceInPlaneAngleForce_H__
#define __AmoebaReferenceInPlaneAngleForce_H__ #define __AmoebaReferenceInPlaneAngleForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
namespace OpenMM { namespace OpenMM {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors); void setPeriodic(OpenMM::Vec3* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -83,23 +83,23 @@ public: ...@@ -83,23 +83,23 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numAngles, std::vector<OpenMM::RealVec>& posData, double calculateForceAndEnergy(int numAngles, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<RealOpenMM>& angle, const std::vector<double>& angle,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<double>& kQuadratic,
RealOpenMM globalAngleCubic, double globalAngleCubic,
RealOpenMM globalAngleQuartic, double globalAngleQuartic,
RealOpenMM globalAnglePentic, double globalAnglePentic,
RealOpenMM globalAngleSextic, double globalAngleSextic,
std::vector<OpenMM::RealVec>& forceData) const; std::vector<OpenMM::Vec3>& forceData) const;
private: private:
bool usePeriodic; bool usePeriodic;
RealVec boxVectors[3]; Vec3 boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -119,11 +119,11 @@ private: ...@@ -119,11 +119,11 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM getPrefactorsGivenAngleCosine(RealOpenMM cosine, RealOpenMM idealAngle, RealOpenMM angleK, double getPrefactorsGivenAngleCosine(double cosine, double idealAngle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
RealOpenMM* dEdR) const; double* dEdR) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba angle ixn (force and energy) Calculate Amoeba angle ixn (force and energy)
...@@ -144,12 +144,12 @@ private: ...@@ -144,12 +144,12 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateAngleIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, double calculateAngleIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD, const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
RealOpenMM angle, RealOpenMM angleK, double angle, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
OpenMM::RealVec* forces) const; 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 @@ ...@@ -24,8 +24,8 @@
#ifndef __AmoebaReferenceMultipoleForce_H__ #ifndef __AmoebaReferenceMultipoleForce_H__
#define __AmoebaReferenceMultipoleForce_H__ #define __AmoebaReferenceMultipoleForce_H__
#include "RealVec.h"
#include "openmm/AmoebaMultipoleForce.h" #include "openmm/AmoebaMultipoleForce.h"
#include "openmm/Vec3.h"
#include "AmoebaReferenceGeneralizedKirkwoodForce.h" #include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include <map> #include <map>
#include "fftpack.h" #include "fftpack.h"
...@@ -33,22 +33,22 @@ ...@@ -33,22 +33,22 @@
namespace OpenMM { namespace OpenMM {
typedef std::map< unsigned int, RealOpenMM> MapIntRealOpenMM; typedef std::map< unsigned int, double> MapIntRealOpenMM;
typedef MapIntRealOpenMM::iterator MapIntRealOpenMMI; typedef MapIntRealOpenMM::iterator MapIntRealOpenMMI;
typedef MapIntRealOpenMM::const_iterator MapIntRealOpenMMCI; typedef MapIntRealOpenMM::const_iterator MapIntRealOpenMMCI;
// A few useful constants for the spherical harmonic multipole code. // A few useful constants for the spherical harmonic multipole code.
const RealOpenMM oneThird = 1.0/3.0; const double oneThird = 1.0/3.0;
const RealOpenMM twoThirds = 2.0/3.0; const double twoThirds = 2.0/3.0;
const RealOpenMM fourThirds = 4.0/3.0; const double fourThirds = 4.0/3.0;
const RealOpenMM fourSqrtOneThird = 4.0/sqrt(3.0); const double fourSqrtOneThird = 4.0/sqrt(3.0);
const RealOpenMM sqrtFourThirds = 2.0/sqrt(3.0); const double sqrtFourThirds = 2.0/sqrt(3.0);
const RealOpenMM sqrtOneThird = 1.0/sqrt(3.0); const double sqrtOneThird = 1.0/sqrt(3.0);
const RealOpenMM sqrtThree = sqrt(3.0); const double sqrtThree = sqrt(3.0);
const RealOpenMM oneNinth = 1.0/9.0; const double oneNinth = 1.0/9.0;
const RealOpenMM fourOverFortyFive = 4.0/45.0; const double fourOverFortyFive = 4.0/45.0;
const RealOpenMM fourOverFifteen = 4.0/15.0; const double fourOverFifteen = 4.0/15.0;
/** /**
...@@ -167,30 +167,30 @@ private: ...@@ -167,30 +167,30 @@ private:
}; };
/** /**
* 4-dimensional RealOpenMM vector * 4-dimensional double vector
*/ */
class RealOpenMM4 { class double4 {
public: 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; 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[0] = x;
data[1] = y; data[1] = y;
data[2] = z; data[2] = z;
data[3] = w; data[3] = w;
} }
RealOpenMM operator[](int index) const { double operator[](int index) const {
assert(index >= 0 && index < 4); assert(index >= 0 && index < 4);
return data[index]; return data[index];
} }
RealOpenMM& operator[](int index) { double& operator[](int index) {
assert(index >= 0 && index < 4); assert(index >= 0 && index < 4);
return data[index]; return data[index];
} }
...@@ -198,17 +198,17 @@ public: ...@@ -198,17 +198,17 @@ public:
// Arithmetic operators // Arithmetic operators
// unary plus // unary plus
RealOpenMM4 operator+() const { double4 operator+() const {
return RealOpenMM4(*this); return double4(*this);
} }
// plus // plus
RealOpenMM4 operator+(const RealOpenMM4& rhs) const { double4 operator+(const double4& rhs) const {
const RealOpenMM4& lhs = *this; const double4& lhs = *this;
return RealOpenMM4(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2],lhs[3] + rhs[3]); 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[0] += rhs[0];
data[1] += rhs[1]; data[1] += rhs[1];
data[2] += rhs[2]; data[2] += rhs[2];
...@@ -216,7 +216,7 @@ public: ...@@ -216,7 +216,7 @@ public:
return *this; return *this;
} }
RealOpenMM4& operator-=(const RealOpenMM4& rhs) { double4& operator-=(const double4& rhs) {
data[0] -= rhs[0]; data[0] -= rhs[0];
data[1] -= rhs[1]; data[1] -= rhs[1];
data[2] -= rhs[2]; data[2] -= rhs[2];
...@@ -225,7 +225,7 @@ public: ...@@ -225,7 +225,7 @@ public:
} }
private: private:
RealOpenMM data[4]; double data[4];
}; };
using namespace OpenMM; using namespace OpenMM;
...@@ -425,7 +425,7 @@ public: ...@@ -425,7 +425,7 @@ public:
* @return epsilon * @return epsilon
* *
*/ */
RealOpenMM getMutualInducedDipoleEpsilon() const; double getMutualInducedDipoleEpsilon() const;
/** /**
* Set the coefficients for the µ_0, µ_1, µ_2, µ_n terms in the extrapolation * Set the coefficients for the µ_0, µ_1, µ_2, µ_n terms in the extrapolation
...@@ -434,7 +434,7 @@ public: ...@@ -434,7 +434,7 @@ public:
* @param optCoefficients a vector whose mth entry specifies the coefficient for µ_m * @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. * Set the target epsilon for converging mutual induced dipoles.
...@@ -442,7 +442,7 @@ public: ...@@ -442,7 +442,7 @@ public:
* @param targetEpsilon target epsilon for converging mutual induced dipoles * @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. * Get the target epsilon for converging mutual induced dipoles.
...@@ -450,7 +450,7 @@ public: ...@@ -450,7 +450,7 @@ public:
* @return target epsilon for converging mutual induced dipoles * @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. * Set the maximum number of iterations to be executed in converging mutual induced dipoles.
...@@ -487,19 +487,19 @@ public: ...@@ -487,19 +487,19 @@ public:
* *
* @return energy * @return energy
*/ */
RealOpenMM calculateForceAndEnergy(const std::vector<OpenMM::RealVec>& particlePositions, double calculateForceAndEnergy(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs, const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs, const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo, const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo,
std::vector<OpenMM::RealVec>& forces); std::vector<OpenMM::Vec3>& forces);
/** /**
* Calculate particle induced dipoles. * Calculate particle induced dipoles.
...@@ -519,19 +519,19 @@ public: ...@@ -519,19 +519,19 @@ public:
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors * @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param outputMultipoleMoments output multipole moments * @param outputMultipoleMoments output multipole moments
*/ */
void calculateInducedDipoles(const std::vector<OpenMM::RealVec>& particlePositions, void calculateInducedDipoles(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs, const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs, const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo, 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. * Calculate particle permanent dipoles rotated in the lab frame.
...@@ -552,19 +552,19 @@ public: ...@@ -552,19 +552,19 @@ public:
* @param outputMultipoleMoments output multipole moments * @param outputMultipoleMoments output multipole moments
*/ */
void calculateLabFramePermanentDipoles(const std::vector<RealVec>& particlePositions, void calculateLabFramePermanentDipoles(const std::vector<Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs, const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs, const std::vector<int>& multipoleAtomYs,
const std::vector< vector< vector<int> > >& multipoleAtomCovalentInfo, const std::vector< vector< vector<int> > >& multipoleAtomCovalentInfo,
std::vector<RealVec>& outputRotatedPermanentDipoles); std::vector<Vec3>& outputRotatedPermanentDipoles);
/** /**
* Calculate particle total dipoles. * Calculate particle total dipoles.
...@@ -586,19 +586,19 @@ public: ...@@ -586,19 +586,19 @@ public:
*/ */
void calculateTotalDipoles(const std::vector<RealVec>& particlePositions, void calculateTotalDipoles(const std::vector<Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs, const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs, const std::vector<int>& multipoleAtomYs,
const std::vector< vector< vector<int> > >& multipoleAtomCovalentInfo, const std::vector< vector< vector<int> > >& multipoleAtomCovalentInfo,
std::vector<RealVec>& outputRotatedPermanentDipoles); std::vector<Vec3>& outputRotatedPermanentDipoles);
...@@ -620,20 +620,20 @@ public: ...@@ -620,20 +620,20 @@ public:
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors * @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param outputMultipoleMoments output multipole moments * @param outputMultipoleMoments output multipole moments
*/ */
void calculateAmoebaSystemMultipoleMoments(const std::vector<RealOpenMM>& masses, void calculateAmoebaSystemMultipoleMoments(const std::vector<double>& masses,
const std::vector<OpenMM::RealVec>& particlePositions, const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs, const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs, const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo, 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. * Calculate electrostatic potential at a set of grid points.
...@@ -653,20 +653,20 @@ public: ...@@ -653,20 +653,20 @@ public:
* @param input grid input grid points to compute potential * @param input grid input grid points to compute potential
* @param outputPotential output electrostatic potential * @param outputPotential output electrostatic potential
*/ */
void calculateElectrostaticPotential(const std::vector<OpenMM::RealVec>& particlePositions, void calculateElectrostaticPotential(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs, const std::vector<int>& multipoleAtomXs,
const std::vector<int>& multipoleAtomYs, const std::vector<int>& multipoleAtomYs,
const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo, const std::vector< std::vector< std::vector<int> > >& multipoleAtomCovalentInfo,
const std::vector<RealVec>& inputGrid, const std::vector<Vec3>& inputGrid,
std::vector<RealOpenMM>& outputPotential); std::vector<double>& outputPotential);
protected: protected:
...@@ -682,15 +682,15 @@ protected: ...@@ -682,15 +682,15 @@ protected:
class MultipoleParticleData { class MultipoleParticleData {
public: public:
unsigned int particleIndex; unsigned int particleIndex;
RealVec position; Vec3 position;
RealOpenMM charge; double charge;
RealVec dipole; Vec3 dipole;
RealOpenMM quadrupole[6]; double quadrupole[6];
RealVec sphericalDipole; Vec3 sphericalDipole;
RealOpenMM sphericalQuadrupole[5]; double sphericalQuadrupole[5];
RealOpenMM thole; double thole;
RealOpenMM dampingFactor; double dampingFactor;
RealOpenMM polarity; double polarity;
}; };
/** /**
...@@ -698,22 +698,22 @@ protected: ...@@ -698,22 +698,22 @@ protected:
*/ */
class TransformedMultipole { class TransformedMultipole {
public: public:
RealOpenMM charge; double charge;
RealVec dipole; Vec3 dipole;
RealOpenMM quadrupole[6]; double quadrupole[6];
}; };
/* /*
* Helper class used in calculating induced dipoles * Helper class used in calculating induced dipoles
*/ */
struct UpdateInducedDipoleFieldStruct { 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); 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::RealVec>* fixedMultipoleField; std::vector<OpenMM::Vec3>* fixedMultipoleField;
std::vector<OpenMM::RealVec>* inducedDipoles; std::vector<OpenMM::Vec3>* inducedDipoles;
std::vector<std::vector<RealVec> >* extrapolatedDipoles; std::vector<std::vector<Vec3> >* extrapolatedDipoles;
std::vector<std::vector<RealOpenMM> >* extrapolatedDipoleFieldGradient; std::vector<std::vector<double> >* extrapolatedDipoleFieldGradient;
std::vector<OpenMM::RealVec> inducedDipoleField; std::vector<OpenMM::Vec3> inducedDipoleField;
std::vector<std::vector<RealOpenMM> > inducedDipoleFieldGradient; std::vector<std::vector<double> > inducedDipoleFieldGradient;
}; };
unsigned int _numParticles; unsigned int _numParticles;
...@@ -721,37 +721,37 @@ protected: ...@@ -721,37 +721,37 @@ protected:
NonbondedMethod _nonbondedMethod; NonbondedMethod _nonbondedMethod;
PolarizationType _polarizationType; PolarizationType _polarizationType;
RealOpenMM _electric; double _electric;
RealOpenMM _dielectric; double _dielectric;
enum ScaleType { D_SCALE, P_SCALE, M_SCALE, U_SCALE, LAST_SCALE_TYPE_INDEX }; enum ScaleType { D_SCALE, P_SCALE, M_SCALE, U_SCALE, LAST_SCALE_TYPE_INDEX };
std::vector< std::vector< MapIntRealOpenMM > > _scaleMaps; std::vector< std::vector< MapIntRealOpenMM > > _scaleMaps;
std::vector<unsigned int> _maxScaleIndex; std::vector<unsigned int> _maxScaleIndex;
RealOpenMM _dScale[5]; double _dScale[5];
RealOpenMM _pScale[5]; double _pScale[5];
RealOpenMM _mScale[5]; double _mScale[5];
RealOpenMM _uScale[5]; double _uScale[5];
std::vector<TransformedMultipole> _transformed; std::vector<TransformedMultipole> _transformed;
std::vector<RealVec> _fixedMultipoleField; std::vector<Vec3> _fixedMultipoleField;
std::vector<RealVec> _fixedMultipoleFieldPolar; std::vector<Vec3> _fixedMultipoleFieldPolar;
std::vector<RealVec> _inducedDipole; std::vector<Vec3> _inducedDipole;
std::vector<RealVec> _inducedDipolePolar; std::vector<Vec3> _inducedDipolePolar;
std::vector<std::vector<RealVec> > _ptDipoleP; std::vector<std::vector<Vec3> > _ptDipoleP;
std::vector<std::vector<RealVec> > _ptDipoleD; std::vector<std::vector<Vec3> > _ptDipoleD;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientP; std::vector<std::vector<double> > _ptDipoleFieldGradientP;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientD; std::vector<std::vector<double> > _ptDipoleFieldGradientD;
int _mutualInducedDipoleConverged; int _mutualInducedDipoleConverged;
int _mutualInducedDipoleIterations; int _mutualInducedDipoleIterations;
int _maximumMutualInducedDipoleIterations; int _maximumMutualInducedDipoleIterations;
int _maxPTOrder; int _maxPTOrder;
std::vector<RealOpenMM> _extrapolationCoefficients; std::vector<double> _extrapolationCoefficients;
std::vector<RealOpenMM> _extPartCoefficients; std::vector<double> _extPartCoefficients;
RealOpenMM _mutualInducedDipoleEpsilon; double _mutualInducedDipoleEpsilon;
RealOpenMM _mutualInducedDipoleTargetEpsilon; double _mutualInducedDipoleTargetEpsilon;
RealOpenMM _polarSOR; double _polarSOR;
RealOpenMM _debye; double _debye;
/** /**
* Helper constructor method to centralize initialization of objects. * Helper constructor method to centralize initialization of objects.
...@@ -772,13 +772,13 @@ protected: ...@@ -772,13 +772,13 @@ protected:
* @param particleData output data struct * @param particleData output data struct
* *
*/ */
void loadParticleData(const std::vector<OpenMM::RealVec>& particlePositions, void loadParticleData(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
std::vector<MultipoleParticleData>& particleData) const; std::vector<MultipoleParticleData>& particleData) const;
/** /**
...@@ -811,7 +811,7 @@ protected: ...@@ -811,7 +811,7 @@ protected:
* @param epsilon * @param epsilon
* *
*/ */
void setMutualInducedDipoleEpsilon(RealOpenMM epsilon); void setMutualInducedDipoleEpsilon(double epsilon);
/** /**
* Setup scale factors given covalent info. * Setup scale factors given covalent info.
...@@ -830,7 +830,7 @@ protected: ...@@ -830,7 +830,7 @@ protected:
* *
* @return scaleFactor * @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 * Get scale factor for particleI & particleJ
...@@ -841,7 +841,7 @@ protected: ...@@ -841,7 +841,7 @@ protected:
* *
* @return array of scaleFactors * @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 * Get p- and d-scale factors for particleI & particleJ ixn
...@@ -851,7 +851,7 @@ protected: ...@@ -851,7 +851,7 @@ protected:
* @param dScale output d-scale factor * @param dScale output d-scale factor
* @param pScale output p-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. * Calculate damped powers of 1/r.
...@@ -861,8 +861,8 @@ protected: ...@@ -861,8 +861,8 @@ protected:
* @param dScale output d-scale factor * @param dScale output d-scale factor
* @param pScale output p-scale factor * @param pScale output p-scale factor
*/ */
void getAndScaleInverseRs(RealOpenMM dampI, RealOpenMM dampJ, RealOpenMM tholeI, RealOpenMM tholeJ, void getAndScaleInverseRs(double dampI, double dampJ, double tholeI, double tholeJ,
RealOpenMM r, std::vector<RealOpenMM>& rrI) const; double r, std::vector<double>& rrI) const;
/** /**
* Check if multipoles at chiral site should be inverted. * Check if multipoles at chiral site should be inverted.
...@@ -915,11 +915,11 @@ protected: ...@@ -915,11 +915,11 @@ protected:
* @param r the bond length between atoms I and J * @param r the bond length between atoms I and J
* @param rotationmatrix the output rotation matrix for a 3-vector * @param rotationmatrix the output rotation matrix for a 3-vector
*/ */
void formQIRotationMatrix(const RealVec& iPosition, void formQIRotationMatrix(const Vec3& iPosition,
const RealVec& jPosition, const Vec3& jPosition,
const RealVec &deltaR, const Vec3 &deltaR,
RealOpenMM r, double r,
RealOpenMM (&rotationMatrix)[3][3]) const; double (&rotationMatrix)[3][3]) const;
/** /**
...@@ -928,7 +928,7 @@ protected: ...@@ -928,7 +928,7 @@ protected:
* @param D1 The input spherical harmonic dipole rotation matrix * @param D1 The input spherical harmonic dipole rotation matrix
* @param D2 The output spherical harmonic quadrupole 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. * Constructs a rotation matrix for spherical harmonic quadrupoles, using the dipole rotation matrix.
...@@ -937,7 +937,7 @@ protected: ...@@ -937,7 +937,7 @@ protected:
* @param D1 The input spherical harmonic dipole rotation matrix * @param D1 The input spherical harmonic dipole rotation matrix
* @param D2 The output spherical harmonic quadrupole 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. * Apply rotation matrix to molecular dipole/quadrupoles to get corresponding lab frame values.
...@@ -969,7 +969,7 @@ protected: ...@@ -969,7 +969,7 @@ protected:
* @param pScale p-scale value for i-j interaction * @param pScale p-scale value for i-j interaction
*/ */
virtual void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, virtual void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dScale, RealOpenMM pScale); double dScale, double pScale);
/** /**
* Initialize induced dipoles * Initialize induced dipoles
...@@ -991,9 +991,9 @@ protected: ...@@ -991,9 +991,9 @@ protected:
* @param field vector of induced dipole fields * @param field vector of induced dipole fields
*/ */
void calculateInducedDipolePairIxn(unsigned int particleI, unsigned int particleJ, void calculateInducedDipolePairIxn(unsigned int particleI, unsigned int particleJ,
RealOpenMM rr3, RealOpenMM rr5, const RealVec& delta, double rr3, double rr5, const Vec3& delta,
const std::vector<RealVec>& inducedDipole, const std::vector<Vec3>& inducedDipole,
std::vector<RealVec>& field) const; std::vector<Vec3>& field) const;
/** /**
* Calculate fields due induced dipoles at each site. * Calculate fields due induced dipoles at each site.
...@@ -1044,7 +1044,7 @@ protected: ...@@ -1044,7 +1044,7 @@ protected:
* @param prevErrors the vector of errors from previous iterations * @param prevErrors the vector of errors from previous iterations
* @param coefficients the coefficients will be stored into this * @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. * Update fields due to induced dipoles for each particle.
...@@ -1052,8 +1052,8 @@ protected: ...@@ -1052,8 +1052,8 @@ protected:
* @param particleData vector of particle positions and parameters (charge, labFrame dipoles, quadrupoles, ...) * @param particleData vector of particle positions and parameters (charge, labFrame dipoles, quadrupoles, ...)
* @param updateInducedDipoleFields vector of UpdateInducedDipoleFieldStruct containing input induced dipoles and output fields * @param updateInducedDipoleFields vector of UpdateInducedDipoleFieldStruct containing input induced dipoles and output fields
*/ */
RealOpenMM updateInducedDipoleFields(const std::vector<MultipoleParticleData>& particleData, double updateInducedDipoleFields(const std::vector<MultipoleParticleData>& particleData,
std::vector<UpdateInducedDipoleFieldStruct>& calculateInducedDipoleField); std::vector<UpdateInducedDipoleFieldStruct>& calculateInducedDipoleField);
/** /**
* Update induced dipole for a particle given updated induced dipole field at the site. * Update induced dipole for a particle given updated induced dipole field at the site.
...@@ -1063,10 +1063,10 @@ protected: ...@@ -1063,10 +1063,10 @@ protected:
* @param inducedDipoleField fields due induced dipoles at each site * @param inducedDipoleField fields due induced dipoles at each site
* @param inducedDipoles output vector of updated induced dipoles * @param inducedDipoles output vector of updated induced dipoles
*/ */
RealOpenMM updateInducedDipole(const std::vector<MultipoleParticleData>& particleI, double updateInducedDipole(const std::vector<MultipoleParticleData>& particleI,
const std::vector<RealVec>& fixedMultipoleField, const std::vector<Vec3>& fixedMultipoleField,
const std::vector<RealVec>& inducedDipoleField, const std::vector<Vec3>& inducedDipoleField,
std::vector<RealVec>& inducedDipoles); std::vector<Vec3>& inducedDipoles);
/** /**
* Calculate induced dipoles. * Calculate induced dipoles.
...@@ -1097,13 +1097,13 @@ protected: ...@@ -1097,13 +1097,13 @@ protected:
* @param particleData output vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles * @param particleData output vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
* *
*/ */
void setup(const std::vector<OpenMM::RealVec>& particlePositions, void setup(const std::vector<OpenMM::Vec3>& particlePositions,
const std::vector<RealOpenMM>& charges, const std::vector<double>& charges,
const std::vector<RealOpenMM>& dipoles, const std::vector<double>& dipoles,
const std::vector<RealOpenMM>& quadrupoles, const std::vector<double>& quadrupoles,
const std::vector<RealOpenMM>& tholes, const std::vector<double>& tholes,
const std::vector<RealOpenMM>& dampingFactors, const std::vector<double>& dampingFactors,
const std::vector<RealOpenMM>& polarity, const std::vector<double>& polarity,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& multipoleAtomXs, const std::vector<int>& multipoleAtomXs,
...@@ -1120,8 +1120,8 @@ protected: ...@@ -1120,8 +1120,8 @@ protected:
* @param forces vector of particle forces to be updated * @param forces vector of particle forces to be updated
* @param torque vector of particle torques to be updated * @param torque vector of particle torques to be updated
*/ */
RealOpenMM calculateElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleK, double calculateElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleK,
const std::vector<RealOpenMM>& scalingFactors, std::vector<OpenMM::RealVec>& forces, std::vector<RealVec>& torque) const; const std::vector<double>& scalingFactors, std::vector<OpenMM::Vec3>& forces, std::vector<Vec3>& torque) const;
/** /**
* Map particle torque to force. * Map particle torque to force.
...@@ -1138,7 +1138,7 @@ protected: ...@@ -1138,7 +1138,7 @@ protected:
const MultipoleParticleData& particleU, const MultipoleParticleData& particleU,
const MultipoleParticleData& particleV, const MultipoleParticleData& particleV,
MultipoleParticleData* particleW, 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. * Map torques to forces.
...@@ -1156,8 +1156,8 @@ protected: ...@@ -1156,8 +1156,8 @@ protected:
const std::vector<int>& multipoleAtomYs, const std::vector<int>& multipoleAtomYs,
const std::vector<int>& multipoleAtomZs, const std::vector<int>& multipoleAtomZs,
const std::vector<int>& axisTypes, const std::vector<int>& axisTypes,
std::vector<OpenMM::RealVec>& torques, std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::RealVec>& forces) const; std::vector<OpenMM::Vec3>& forces) const;
/** /**
* Calculate electrostatic forces * Calculate electrostatic forces
...@@ -1168,44 +1168,44 @@ protected: ...@@ -1168,44 +1168,44 @@ protected:
* *
* @return energy * @return energy
*/ */
virtual RealOpenMM calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData, virtual double calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::RealVec>& torques, std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::RealVec>& forces); std::vector<OpenMM::Vec3>& forces);
/** /**
* Normalize a RealVec * Normalize a Vec3
* *
* @param vectorToNormalize vector to normalize * @param vectorToNormalize vector to normalize
* *
* @return norm of vector on input * @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 * @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 * @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 inputVector vector to copy
* @param outputVector output vector * @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 * Calculate potential at grid point due to a particle
...@@ -1216,7 +1216,7 @@ protected: ...@@ -1216,7 +1216,7 @@ protected:
* @return potential at grid point * @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 * Apply periodic boundary conditions to difference in positions
...@@ -1224,7 +1224,7 @@ protected: ...@@ -1224,7 +1224,7 @@ protected:
* @param deltaR difference in particle positions; modified on output after applying PBC * @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 { class AmoebaReferenceGeneralizedKirkwoodMultipoleForce : public AmoebaReferenceMultipoleForce {
...@@ -1257,7 +1257,7 @@ public: ...@@ -1257,7 +1257,7 @@ public:
* @return probe radius * @return probe radius
* *
*/ */
RealOpenMM getProbeRadius() const; double getProbeRadius() const;
/** /**
* Get surface area factor. * Get surface area factor.
...@@ -1265,7 +1265,7 @@ public: ...@@ -1265,7 +1265,7 @@ public:
* @return surface area factor * @return surface area factor
* *
*/ */
RealOpenMM getSurfaceAreaFactor() const; double getSurfaceAreaFactor() const;
/** /**
* Get dielectric offset. * Get dielectric offset.
...@@ -1273,34 +1273,34 @@ public: ...@@ -1273,34 +1273,34 @@ public:
* @return dielectric offset * @return dielectric offset
* *
*/ */
RealOpenMM getDielectricOffset() const; double getDielectricOffset() const;
private: private:
AmoebaReferenceGeneralizedKirkwoodForce* _amoebaReferenceGeneralizedKirkwoodForce; AmoebaReferenceGeneralizedKirkwoodForce* _amoebaReferenceGeneralizedKirkwoodForce;
RealOpenMM _gkc; double _gkc;
RealOpenMM _fc; double _fc;
RealOpenMM _fd; double _fd;
RealOpenMM _fq; double _fq;
std::vector<RealOpenMM> _atomicRadii; std::vector<double> _atomicRadii;
std::vector<RealOpenMM> _scaledRadii; std::vector<double> _scaledRadii;
std::vector<RealOpenMM> _bornRadii; std::vector<double> _bornRadii;
std::vector<RealOpenMM> _bornForce; std::vector<double> _bornForce;
std::vector<RealVec> _gkField; std::vector<Vec3> _gkField;
std::vector<RealVec> _inducedDipoleS; std::vector<Vec3> _inducedDipoleS;
std::vector<RealVec> _inducedDipolePolarS; std::vector<Vec3> _inducedDipolePolarS;
std::vector<std::vector<RealVec> > _ptDipolePS; std::vector<std::vector<Vec3> > _ptDipolePS;
std::vector<std::vector<RealVec> > _ptDipoleDS; std::vector<std::vector<Vec3> > _ptDipoleDS;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientPS; std::vector<std::vector<double> > _ptDipoleFieldGradientPS;
std::vector<std::vector<RealOpenMM> > _ptDipoleFieldGradientDS; std::vector<std::vector<double> > _ptDipoleFieldGradientDS;
int _includeCavityTerm; int _includeCavityTerm;
RealOpenMM _probeRadius; double _probeRadius;
RealOpenMM _surfaceAreaFactor; double _surfaceAreaFactor;
RealOpenMM _dielectricOffset; double _dielectricOffset;
/** /**
* Zero fixed multipole fields. * Zero fixed multipole fields.
...@@ -1318,7 +1318,7 @@ private: ...@@ -1318,7 +1318,7 @@ private:
* @param pScale p-scale value for i-j interaction * @param pScale p-scale value for i-j interaction
*/ */
void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dScale, RealOpenMM pScale); double dScale, double pScale);
/** /**
* Calculate induced dipoles. * Calculate induced dipoles.
...@@ -1346,9 +1346,9 @@ private: ...@@ -1346,9 +1346,9 @@ private:
* *
* @return energy * @return energy
*/ */
RealOpenMM calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData, double calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::RealVec>& torques, std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::RealVec>& forces); std::vector<OpenMM::Vec3>& forces);
/** /**
* Calculate GK field at particle I due induced dipole at particle J and vice versa * Calculate GK field at particle I due induced dipole at particle J and vice versa
...@@ -1360,7 +1360,7 @@ private: ...@@ -1360,7 +1360,7 @@ private:
* @param fieldPolar vector of induced dipole polar fields * @param fieldPolar vector of induced dipole polar fields
*/ */
void calculateInducedDipolePairGkIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, 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. * Calculate Kirkwood interaction.
...@@ -1373,10 +1373,10 @@ private: ...@@ -1373,10 +1373,10 @@ private:
* *
* @return energy * @return energy
*/ */
RealOpenMM calculateKirkwoodPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, double calculateKirkwoodPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
std::vector<RealVec>& forces, std::vector<Vec3>& forces,
std::vector<RealVec>& torques, std::vector<Vec3>& torques,
std::vector<RealOpenMM>& dBorn) const; std::vector<double>& dBorn) const;
/** /**
* Calculate Grycuk 'chain-rule' force. * Calculate Grycuk 'chain-rule' force.
...@@ -1388,7 +1388,7 @@ private: ...@@ -1388,7 +1388,7 @@ private:
* *
*/ */
void calculateGrycukChainRulePairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, 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. * Calculate TINKER's ACE approximation to non-polar cavity term.
...@@ -1398,7 +1398,7 @@ private: ...@@ -1398,7 +1398,7 @@ private:
* @return ACE energy * @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()). * Correct vacuum to SCRF derivatives (TINKER's ediff1()).
...@@ -1412,9 +1412,9 @@ private: ...@@ -1412,9 +1412,9 @@ private:
* *
* @return energy * @return energy
*/ */
RealOpenMM calculateKirkwoodEDiffPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, double calculateKirkwoodEDiffPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM pscale, RealOpenMM dscale, double pscale, double dscale,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const; std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
}; };
...@@ -1440,7 +1440,7 @@ public: ...@@ -1440,7 +1440,7 @@ public:
* @return cutoff distance * @return cutoff distance
* *
*/ */
RealOpenMM getCutoffDistance() const; double getCutoffDistance() const;
/** /**
* Set cutoff distance. * Set cutoff distance.
...@@ -1448,7 +1448,7 @@ public: ...@@ -1448,7 +1448,7 @@ public:
* @return cutoff distance * @return cutoff distance
* *
*/ */
void setCutoffDistance(RealOpenMM cutoffDistance); void setCutoffDistance(double cutoffDistance);
/** /**
* Get alpha used in Ewald summation. * Get alpha used in Ewald summation.
...@@ -1456,7 +1456,7 @@ public: ...@@ -1456,7 +1456,7 @@ public:
* @return alpha * @return alpha
* *
*/ */
RealOpenMM getAlphaEwald() const; double getAlphaEwald() const;
/** /**
* Set alpha used in Ewald summation. * Set alpha used in Ewald summation.
...@@ -1464,7 +1464,7 @@ public: ...@@ -1464,7 +1464,7 @@ public:
* @return alpha * @return alpha
* *
*/ */
void setAlphaEwald(RealOpenMM alphaEwald); void setAlphaEwald(double alphaEwald);
/** /**
* Get PME grid dimensions. * Get PME grid dimensions.
...@@ -1488,19 +1488,19 @@ public: ...@@ -1488,19 +1488,19 @@ public:
* *
* @param vectors the vectors defining the periodic box * @param vectors the vectors defining the periodic box
*/ */
void setPeriodicBoxSize(OpenMM::RealVec* vectors); void setPeriodicBoxSize(OpenMM::Vec3* vectors);
private: private:
static const int AMOEBA_PME_ORDER; static const int AMOEBA_PME_ORDER;
static const RealOpenMM SQRT_PI; static const double SQRT_PI;
RealOpenMM _alphaEwald; double _alphaEwald;
RealOpenMM _cutoffDistance; double _cutoffDistance;
RealOpenMM _cutoffDistanceSquared; double _cutoffDistanceSquared;
RealVec _recipBoxVectors[3]; Vec3 _recipBoxVectors[3];
RealVec _periodicBoxVectors[3]; Vec3 _periodicBoxVectors[3];
int _totalGridSize; int _totalGridSize;
IntVec _pmeGridDimensions; IntVec _pmeGridDimensions;
...@@ -1510,15 +1510,15 @@ private: ...@@ -1510,15 +1510,15 @@ private:
unsigned int _pmeGridSize; unsigned int _pmeGridSize;
t_complex* _pmeGrid; t_complex* _pmeGrid;
std::vector<RealOpenMM> _pmeBsplineModuli[3]; std::vector<double> _pmeBsplineModuli[3];
std::vector<RealOpenMM4> _thetai[3]; std::vector<double4> _thetai[3];
std::vector<IntVec> _iGrid; std::vector<IntVec> _iGrid;
std::vector<RealOpenMM> _phi; std::vector<double> _phi;
std::vector<RealOpenMM> _phid; std::vector<double> _phid;
std::vector<RealOpenMM> _phip; std::vector<double> _phip;
std::vector<RealOpenMM> _phidp; std::vector<double> _phidp;
std::vector<RealOpenMM4> _pmeBsplineTheta; std::vector<double4> _pmeBsplineTheta;
std::vector<RealOpenMM4> _pmeBsplineDtheta; std::vector<double4> _pmeBsplineDtheta;
/** /**
* Resize PME arrays. * Resize PME arrays.
...@@ -1537,7 +1537,7 @@ private: ...@@ -1537,7 +1537,7 @@ private:
* @param delta input vector of difference in particle positions; on output adjusted for * @param delta input vector of difference in particle positions; on output adjusted for
* periodic boundary conditions * periodic boundary conditions
*/ */
void getPeriodicDelta(RealVec& deltaR) const; void getPeriodicDelta(Vec3& deltaR) const;
/** /**
* Calculate damped inverse distances. * Calculate damped inverse distances.
...@@ -1550,8 +1550,8 @@ private: ...@@ -1550,8 +1550,8 @@ private:
* @param dampedPInverseDistances damped inverse distances (prr3,prr5,prr7 in udirect2a() in TINKER) * @param dampedPInverseDistances damped inverse distances (prr3,prr5,prr7 in udirect2a() in TINKER)
*/ */
void getDampedInverseDistances(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, void getDampedInverseDistances(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dscale, RealOpenMM pscale, RealOpenMM r, double dscale, double pscale, double r,
RealVec& dampedDInverseDistances, RealVec& dampedPInverseDistances) const; Vec3& dampedDInverseDistances, Vec3& dampedPInverseDistances) const;
/** /**
* Initialize B-spline moduli. * Initialize B-spline moduli.
...@@ -1568,7 +1568,7 @@ private: ...@@ -1568,7 +1568,7 @@ private:
* @param pScale p-scale value for i-j interaction * @param pScale p-scale value for i-j interaction
*/ */
void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, void calculateFixedMultipoleFieldPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
RealOpenMM dscale, RealOpenMM pscale); double dscale, double pscale);
/** /**
* Calculate fixed multipole fields. * Calculate fixed multipole fields.
...@@ -1584,7 +1584,7 @@ private: ...@@ -1584,7 +1584,7 @@ private:
* @param thetai output spline coefficients * @param thetai output spline coefficients
* @param w offset from grid point * @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. * Compute bspline coefficients.
...@@ -1601,7 +1601,7 @@ private: ...@@ -1601,7 +1601,7 @@ private:
/** /**
* Transform potential from fractional coordinates to cartesian coordinates. * 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. * Spread fixed multipoles onto PME grid.
...@@ -1637,8 +1637,8 @@ private: ...@@ -1637,8 +1637,8 @@ private:
* *
* @return energy * @return energy
*/ */
RealOpenMM computeReciprocalSpaceFixedMultipoleForceAndEnergy(const std::vector<MultipoleParticleData>& particleData, double computeReciprocalSpaceFixedMultipoleForceAndEnergy(const std::vector<MultipoleParticleData>& particleData,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const; std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
/** /**
* Set reciprocal space fixed multipole fields. * Set reciprocal space fixed multipole fields.
...@@ -1665,9 +1665,9 @@ private: ...@@ -1665,9 +1665,9 @@ private:
* @param field vector of field at each particle due induced dipole of other particles * @param field vector of field at each particle due induced dipole of other particles
*/ */
void calculateDirectInducedDipolePairIxn(unsigned int iIndex, unsigned int jIndex, void calculateDirectInducedDipolePairIxn(unsigned int iIndex, unsigned int jIndex,
RealOpenMM preFactor1, RealOpenMM preFactor2, const RealVec& delta, double preFactor1, double preFactor2, const Vec3& delta,
const std::vector<RealVec>& inducedDipole, const std::vector<Vec3>& inducedDipole,
std::vector<RealVec>& field) const; std::vector<Vec3>& field) const;
/** /**
* Calculate direct space field at particleI due to induced dipole at particle J and vice versa for * Calculate direct space field at particleI due to induced dipole at particle J and vice versa for
...@@ -1694,8 +1694,8 @@ private: ...@@ -1694,8 +1694,8 @@ private:
* @param inputInducedDipole induced dipole value * @param inputInducedDipole induced dipole value
* @param inputInducedDipolePolar induced dipole polar value * @param inputInducedDipolePolar induced dipole polar value
*/ */
void spreadInducedDipolesOnGrid(const std::vector<RealVec>& inputInducedDipole, void spreadInducedDipolesOnGrid(const std::vector<Vec3>& inputInducedDipole,
const std::vector<RealVec>& inputInducedDipolePolar); const std::vector<Vec3>& inputInducedDipolePolar);
/** /**
* Calculate induced dipole fields. * Calculate induced dipole fields.
...@@ -1713,14 +1713,14 @@ private: ...@@ -1713,14 +1713,14 @@ private:
* @param fieldPolar reciprocal space output induced dipole polar field value at each site * @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. * Compute Pme self energy.
* *
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles * @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. * Compute the self torques.
...@@ -1728,7 +1728,7 @@ private: ...@@ -1728,7 +1728,7 @@ private:
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles * @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
* @param torques vector of torques * @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. * Calculate direct space electrostatic interaction between particles I and J.
...@@ -1739,9 +1739,9 @@ private: ...@@ -1739,9 +1739,9 @@ private:
* @param forces vector of particle forces to be updated * @param forces vector of particle forces to be updated
* @param torques vector of particle torques to be updated * @param torques vector of particle torques to be updated
*/ */
RealOpenMM calculatePmeDirectElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ, double calculatePmeDirectElectrostaticPairIxn(const MultipoleParticleData& particleI, const MultipoleParticleData& particleJ,
const std::vector<RealOpenMM>& scalingFactors, const std::vector<double>& scalingFactors,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const; std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
/** /**
* Calculate reciprocal space energy/force/torque for dipole interaction. * Calculate reciprocal space energy/force/torque for dipole interaction.
...@@ -1752,9 +1752,9 @@ private: ...@@ -1752,9 +1752,9 @@ private:
* @param forces vector of particle forces to be updated * @param forces vector of particle forces to be updated
* @param torques vector of particle torques to be updated * @param torques vector of particle torques to be updated
*/ */
RealOpenMM computeReciprocalSpaceInducedDipoleForceAndEnergy(AmoebaReferenceMultipoleForce::PolarizationType polarizationType, double computeReciprocalSpaceInducedDipoleForceAndEnergy(AmoebaReferenceMultipoleForce::PolarizationType polarizationType,
const std::vector<MultipoleParticleData>& particleData, const std::vector<MultipoleParticleData>& particleData,
std::vector<RealVec>& forces, std::vector<RealVec>& torques) const; std::vector<Vec3>& forces, std::vector<Vec3>& torques) const;
/** /**
* Calculate electrostatic forces. * Calculate electrostatic forces.
...@@ -1765,9 +1765,9 @@ private: ...@@ -1765,9 +1765,9 @@ private:
* *
* @return energy * @return energy
*/ */
RealOpenMM calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData, double calculateElectrostatic(const std::vector<MultipoleParticleData>& particleData,
std::vector<OpenMM::RealVec>& torques, std::vector<OpenMM::Vec3>& torques,
std::vector<OpenMM::RealVec>& forces); std::vector<OpenMM::Vec3>& forces);
}; };
......
...@@ -24,11 +24,12 @@ ...@@ -24,11 +24,12 @@
#include "AmoebaReferenceForce.h" #include "AmoebaReferenceForce.h"
#include "AmoebaReferenceOutOfPlaneBendForce.h" #include "AmoebaReferenceOutOfPlaneBendForce.h"
#include "SimTKOpenMMRealType.h"
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) { void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true; usePeriodic = true;
boxVectors[0] = vectors[0]; boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1]; boxVectors[1] = vectors[1];
...@@ -55,34 +56,20 @@ void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -55,34 +56,20 @@ void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const RealVec& positionAtomA, const RealVec& positionAtomB, double AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD, const Vec3& positionAtomC, const Vec3& positionAtomD,
RealOpenMM angleK, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
RealVec* forces) const { Vec3* 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;
enum { A, B, C, D, LastAtomIndex }; enum { A, B, C, D, LastAtomIndex };
enum { AB, CB, DB, AD, CD, LastDeltaIndex }; enum { AB, CB, DB, AD, CD, LastDeltaIndex };
// ---------------------------------------------------------------------------------------
// get deltaR between various combinations of the 4 atoms // get deltaR between various combinations of the 4 atoms
// and various intermediate terms // and various intermediate terms
std::vector<RealOpenMM> deltaR[LastDeltaIndex]; std::vector<double> deltaR[LastDeltaIndex];
for (int ii = 0; ii < LastDeltaIndex; ii++) { for (int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
...@@ -101,52 +88,52 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const ...@@ -101,52 +88,52 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomC, deltaR[CD]); AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomC, deltaR[CD]);
} }
RealOpenMM rDB2 = AmoebaReferenceForce::getNormSquared3(deltaR[DB]); double rDB2 = AmoebaReferenceForce::getNormSquared3(deltaR[DB]);
RealOpenMM rAD2 = AmoebaReferenceForce::getNormSquared3(deltaR[AD]); double rAD2 = AmoebaReferenceForce::getNormSquared3(deltaR[AD]);
RealOpenMM rCD2 = AmoebaReferenceForce::getNormSquared3(deltaR[CD]); double rCD2 = AmoebaReferenceForce::getNormSquared3(deltaR[CD]);
std::vector<RealOpenMM> tempVector(3); std::vector<double> tempVector(3);
AmoebaReferenceForce::getCrossProduct(deltaR[CB], deltaR[DB], tempVector); AmoebaReferenceForce::getCrossProduct(deltaR[CB], deltaR[DB], tempVector);
RealOpenMM eE = AmoebaReferenceForce::getDotProduct3(deltaR[AB], tempVector); double eE = AmoebaReferenceForce::getDotProduct3(deltaR[AB], tempVector);
RealOpenMM dot = AmoebaReferenceForce::getDotProduct3(deltaR[AD], deltaR[CD]); double dot = AmoebaReferenceForce::getDotProduct3(deltaR[AD], deltaR[CD]);
RealOpenMM cc = rAD2*rCD2 - dot*dot; double cc = rAD2*rCD2 - dot*dot;
if (rDB2 <= zero || cc == zero) { if (rDB2 <= 0.0 || cc == 0.0) {
return zero; return 0.0;
} }
RealOpenMM bkk2 = rDB2 - eE*eE/cc; double bkk2 = rDB2 - eE*eE/cc;
RealOpenMM cosine = SQRT(bkk2/rDB2); double cosine = sqrt(bkk2/rDB2);
RealOpenMM angle; double angle;
if (cosine >= one) { if (cosine >= 1.0) {
angle = zero; angle = 0.0;
} else if (cosine <= -one) { } else if (cosine <= -1.0) {
angle = PI_M; angle = M_PI;
} else { } else {
angle = RADIAN*ACOS(cosine); angle = RADIAN*acos(cosine);
} }
// chain rule // chain rule
RealOpenMM dt = angle; double dt = angle;
RealOpenMM dt2 = dt*dt; double dt2 = dt*dt;
RealOpenMM dt3 = dt2*dt; double dt3 = dt2*dt;
RealOpenMM dt4 = dt2*dt2; double dt4 = dt2*dt2;
RealOpenMM dEdDt = two + three*angleCubic*dt + four*angleQuartic*dt2 + double dEdDt = 2.0 + 3.0*angleCubic*dt + 4.0*angleQuartic*dt2 +
five*anglePentic*dt3 + six*angleSextic*dt4; 5.0*anglePentic*dt3 + 6.0*angleSextic*dt4;
dEdDt *= angleK*dt*RADIAN; dEdDt *= angleK*dt*RADIAN;
RealOpenMM dEdCos = dEdDt/SQRT(cc*bkk2); double dEdCos = dEdDt/sqrt(cc*bkk2);
if (eE > zero) { if (eE > 0.0) {
dEdCos *= -one; dEdCos *= -1.0;
} }
RealOpenMM term = eE/cc; double term = eE/cc;
std::vector<RealOpenMM> dccd[LastAtomIndex]; std::vector<double> dccd[LastAtomIndex];
std::vector<RealOpenMM> deed[LastAtomIndex]; std::vector<double> deed[LastAtomIndex];
std::vector<RealOpenMM> subForce[LastAtomIndex]; std::vector<double> subForce[LastAtomIndex];
for (int ii = 0; ii < LastAtomIndex; ii++) { for (int ii = 0; ii < LastAtomIndex; ii++) {
dccd[ii].resize(3); dccd[ii].resize(3);
deed[ii].resize(3); deed[ii].resize(3);
...@@ -155,7 +142,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const ...@@ -155,7 +142,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
for (int ii = 0; ii < 3; ii++) { for (int ii = 0; ii < 3; ii++) {
dccd[A][ii] = (deltaR[AD][ii]*rCD2 - deltaR[CD][ii]*dot)*term; 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[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]); AmoebaReferenceForce::getCrossProduct(deltaR[DB], deltaR[CB], deed[A]);
...@@ -189,7 +176,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const ...@@ -189,7 +176,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
if (jj == 3) { if (jj == 3) {
for (int ii = 0; ii < 3; ii++) { 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 ...@@ -206,31 +193,31 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
// calculate energy if 'energy' is set // calculate energy if 'energy' is set
RealOpenMM energy = one + angleCubic*dt + angleQuartic*dt2 + anglePentic*dt3 + angleSextic*dt4; double energy = 1.0 + angleCubic*dt + angleQuartic*dt2 + anglePentic*dt3 + angleSextic*dt4;
energy *= angleK*dt2; energy *= angleK*dt2;
return energy; return energy;
} }
RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateForceAndEnergy(int numOutOfPlaneBends, vector<RealVec>& posData, double AmoebaReferenceOutOfPlaneBendForce::calculateForceAndEnergy(int numOutOfPlaneBends, vector<Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<double>& kQuadratic,
RealOpenMM angleCubic, double angleCubic,
RealOpenMM angleQuartic, double angleQuartic,
RealOpenMM anglePentic, double anglePentic,
RealOpenMM angleSextic, double angleSextic,
vector<RealVec>& forceData) const { vector<Vec3>& forceData) const {
RealOpenMM energy = 0.0; double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numOutOfPlaneBends); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(numOutOfPlaneBends); ii++) {
int particle1Index = particle1[ii]; int particle1Index = particle1[ii];
int particle2Index = particle2[ii]; int particle2Index = particle2[ii];
int particle3Index = particle3[ii]; int particle3Index = particle3[ii];
int particle4Index = particle4[ii]; int particle4Index = particle4[ii];
RealOpenMM kAngle = kQuadratic[ii]; double kAngle = kQuadratic[ii];
RealVec forces[4]; Vec3 forces[4];
energy += calculateOutOfPlaneBendIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], posData[particle4Index], energy += calculateOutOfPlaneBendIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], posData[particle4Index],
kAngle, angleCubic, angleQuartic, anglePentic, angleSextic, forces); kAngle, angleCubic, angleQuartic, anglePentic, angleSextic, forces);
for (int jj = 0; jj < 3; jj++) { for (int jj = 0; jj < 3; jj++) {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceOutOfPlaneBendForce_H__ #ifndef __AmoebaReferenceOutOfPlaneBendForce_H__
#define __AmoebaReferenceOutOfPlaneBendForce_H__ #define __AmoebaReferenceOutOfPlaneBendForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
namespace OpenMM { namespace OpenMM {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors); void setPeriodic(OpenMM::Vec3* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -82,22 +82,22 @@ public: ...@@ -82,22 +82,22 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numOutOfPlaneBends, std::vector<OpenMM::RealVec>& posData, double calculateForceAndEnergy(int numOutOfPlaneBends, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<RealOpenMM>& kAngle, const std::vector<double>& kAngle,
RealOpenMM angleCubic, double angleCubic,
RealOpenMM angleQuartic, double angleQuartic,
RealOpenMM anglePentic, double anglePentic,
RealOpenMM angleSextic, double angleSextic,
std::vector<OpenMM::RealVec>& forceData) const; std::vector<OpenMM::Vec3>& forceData) const;
private: private:
bool usePeriodic; bool usePeriodic;
RealVec boxVectors[3]; Vec3 boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -118,13 +118,12 @@ private: ...@@ -118,13 +118,12 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateOutOfPlaneBendIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, double calculateOutOfPlaneBendIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD, const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
RealOpenMM angleK, double angleK,
RealOpenMM angleCubic, RealOpenMM angleQuartic, double angleCubic, double angleQuartic,
RealOpenMM anglePentic, RealOpenMM angleSextic, double anglePentic, double angleSextic,
OpenMM::RealVec* forces) const; OpenMM::Vec3* forces) const;
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -23,12 +23,13 @@ ...@@ -23,12 +23,13 @@
#include "AmoebaReferenceForce.h" #include "AmoebaReferenceForce.h"
#include "AmoebaReferencePiTorsionForce.h" #include "AmoebaReferencePiTorsionForce.h"
#include <cmath>
#include <vector> #include <vector>
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) { void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true; usePeriodic = true;
boxVectors[0] = vectors[0]; boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1]; boxVectors[1] = vectors[1];
...@@ -52,24 +53,14 @@ void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -52,24 +53,14 @@ void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& positionAtomA, const RealVec& positionAtomB, double AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD, const Vec3& positionAtomC, const Vec3& positionAtomD,
const RealVec& positionAtomE, const RealVec& positionAtomF, const Vec3& positionAtomE, const Vec3& positionAtomF,
RealOpenMM piTorsionK, RealVec* forces) const { double piTorsionK, Vec3* 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;
// ---------------------------------------------------------------------------------------
enum { AD, BD, EC, FC, P, Q, CP, DC, QD, T, U, TU, DP, QC, dT, dU, dP, dQ, dC1, dC2, dD1, dD2, LastDeltaIndex }; 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++) { for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
...@@ -87,7 +78,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p ...@@ -87,7 +78,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
} }
enum { A, B, C, D, E, F, LastAtomIndex }; 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++) { for (unsigned int ii = 0; ii < LastAtomIndex; ii++) {
d[ii].resize(3); d[ii].resize(3);
} }
...@@ -106,36 +97,36 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p ...@@ -106,36 +97,36 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
AmoebaReferenceForce::getCrossProduct(deltaR[DC], deltaR[QD], deltaR[U]); AmoebaReferenceForce::getCrossProduct(deltaR[DC], deltaR[QD], deltaR[U]);
AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[U], deltaR[TU]); AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[U], deltaR[TU]);
RealOpenMM rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]); double rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]);
RealOpenMM rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]); double rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]);
RealOpenMM rTrU = SQRT(rT2*rU2); double rTrU = sqrt(rT2*rU2);
if (rTrU <= zero) { if (rTrU <= 0.0) {
return zero; return 0.0;
} }
RealOpenMM rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]); double rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]);
RealOpenMM cosine = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]); double cosine = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]);
cosine /= rTrU; cosine /= rTrU;
RealOpenMM sine = AmoebaReferenceForce::getDotProduct3(deltaR[DC], deltaR[TU]); double sine = AmoebaReferenceForce::getDotProduct3(deltaR[DC], deltaR[TU]);
sine /= (rDC*rTrU); sine /= (rDC*rTrU);
RealOpenMM cosine2 = cosine*cosine - sine*sine; double cosine2 = cosine*cosine - sine*sine;
RealOpenMM sine2 = two*cosine*sine; double sine2 = 2.0*cosine*sine;
RealOpenMM phi2 = one - cosine2; double phi2 = 1.0 - cosine2;
RealOpenMM dphi2 = two*sine2; double dphi2 = 2.0*sine2;
RealOpenMM dedphi = piTorsionK*dphi2; double dedphi = piTorsionK*dphi2;
for (unsigned int ii = 0; ii < 3; ii++) { for (unsigned int ii = 0; ii < 3; ii++) {
deltaR[DP][ii] = positionAtomD[ii] - deltaR[P][ii]; deltaR[DP][ii] = positionAtomD[ii] - deltaR[P][ii];
deltaR[QC][ii] = deltaR[Q][ii] - positionAtomC[ii]; deltaR[QC][ii] = deltaR[Q][ii] - positionAtomC[ii];
} }
RealOpenMM factorT = dedphi/(rDC*rT2); double factorT = dedphi/(rDC*rT2);
RealOpenMM factorU = -dedphi/(rDC*rU2); double factorU = -dedphi/(rDC*rU2);
AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[DC], deltaR[dT]); AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[DC], deltaR[dT]);
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[DC], deltaR[dU]); AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[DC], deltaR[dU]);
...@@ -200,16 +191,16 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p ...@@ -200,16 +191,16 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
} }
RealOpenMM AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsions, vector<RealVec>& posData, double AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsions, vector<Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<int>& particle5, const std::vector<int>& particle5,
const std::vector<int>& particle6, const std::vector<int>& particle6,
const std::vector<RealOpenMM>& kTorsion, const std::vector<double>& kTorsion,
vector<RealVec>& forceData) const { vector<Vec3>& forceData) const {
RealOpenMM energy = 0.0; double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numPiTorsions); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(numPiTorsions); ii++) {
int particle1Index = particle1[ii]; int particle1Index = particle1[ii];
...@@ -219,7 +210,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsi ...@@ -219,7 +210,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsi
int particle5Index = particle5[ii]; int particle5Index = particle5[ii];
int particle6Index = particle6[ii]; int particle6Index = particle6[ii];
RealVec forces[6]; Vec3 forces[6];
energy += calculatePiTorsionIxn(posData[particle1Index], posData[particle2Index], energy += calculatePiTorsionIxn(posData[particle1Index], posData[particle2Index],
posData[particle3Index], posData[particle4Index], posData[particle3Index], posData[particle4Index],
posData[particle5Index], posData[particle6Index], posData[particle5Index], posData[particle6Index],
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferencePiTorsionForce_H__ #ifndef __AmoebaReferencePiTorsionForce_H__
#define __AmoebaReferencePiTorsionForce_H__ #define __AmoebaReferencePiTorsionForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
namespace OpenMM { namespace OpenMM {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors); void setPeriodic(OpenMM::Vec3* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -82,21 +82,21 @@ public: ...@@ -82,21 +82,21 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numPiTorsions, std::vector<OpenMM::RealVec>& posData, double calculateForceAndEnergy(int numPiTorsions, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<int>& particle5, const std::vector<int>& particle5,
const std::vector<int>& particle6, const std::vector<int>& particle6,
const std::vector<RealOpenMM>& kTorsion, const std::vector<double>& kTorsion,
std::vector<OpenMM::RealVec>& forceData) const; std::vector<OpenMM::Vec3>& forceData) const;
private: private:
bool usePeriodic; bool usePeriodic;
RealVec boxVectors[3]; Vec3 boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -115,10 +115,10 @@ private: ...@@ -115,10 +115,10 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculatePiTorsionIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, double calculatePiTorsionIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD, const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
const OpenMM::RealVec& positionAtomE, const OpenMM::RealVec& positionAtomF, const OpenMM::Vec3& positionAtomE, const OpenMM::Vec3& positionAtomF,
RealOpenMM kTorsion, OpenMM::RealVec* forces) const; double kTorsion, OpenMM::Vec3* forces) const;
}; };
......
...@@ -24,12 +24,13 @@ ...@@ -24,12 +24,13 @@
#include "AmoebaReferenceForce.h" #include "AmoebaReferenceForce.h"
#include "AmoebaReferenceStretchBendForce.h" #include "AmoebaReferenceStretchBendForce.h"
#include "SimTKOpenMMRealType.h"
#include <vector> #include <vector>
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) { void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true; usePeriodic = true;
boxVectors[0] = vectors[0]; boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1]; boxVectors[1] = vectors[1];
...@@ -56,20 +57,11 @@ void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -56,20 +57,11 @@ void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVec& positionAtomA, const RealVec& positionAtomB, double AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const RealVec& positionAtomC, const Vec3& positionAtomC,
RealOpenMM lengthAB, RealOpenMM lengthCB, double lengthAB, double lengthCB,
RealOpenMM idealAngle, RealOpenMM k1Parameter, double idealAngle, double k1Parameter,
RealOpenMM k2Parameter, RealVec* forces) const { double k2Parameter, Vec3* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceStretchBendForce::calculateStretchBendIxn";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
enum { A, B, C, LastAtomIndex }; enum { A, B, C, LastAtomIndex };
enum { AB, CB, CBxAB, ABxP, CBxP, LastDeltaIndex }; enum { AB, CB, CBxAB, ABxP, CBxP, LastDeltaIndex };
...@@ -79,7 +71,7 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe ...@@ -79,7 +71,7 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
// get deltaR between various combinations of the 3 atoms // get deltaR between various combinations of the 3 atoms
// and various intermediate terms // and various intermediate terms
std::vector<RealOpenMM> deltaR[LastDeltaIndex]; std::vector<double> deltaR[LastDeltaIndex];
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) { for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
...@@ -91,30 +83,30 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe ...@@ -91,30 +83,30 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomA, deltaR[AB]); AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomA, deltaR[AB]);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]); AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]);
} }
RealOpenMM rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[AB]); double rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[AB]);
RealOpenMM rAB = SQRT(rAB2); double rAB = sqrt(rAB2);
RealOpenMM rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[CB]); double rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[CB]);
RealOpenMM rCB = SQRT(rCB2); double rCB = sqrt(rCB2);
AmoebaReferenceForce::getCrossProduct(deltaR[CB], deltaR[AB], deltaR[CBxAB]); AmoebaReferenceForce::getCrossProduct(deltaR[CB], deltaR[AB], deltaR[CBxAB]);
RealOpenMM rP = AmoebaReferenceForce::getNorm3(deltaR[CBxAB]); double rP = AmoebaReferenceForce::getNorm3(deltaR[CBxAB]);
if (rP <= zero) { if (rP <= 0.0) {
return zero; return 0.0;
} }
RealOpenMM dot = AmoebaReferenceForce::getDotProduct3(deltaR[CB], deltaR[AB]); double dot = AmoebaReferenceForce::getDotProduct3(deltaR[CB], deltaR[AB]);
RealOpenMM cosine = dot/(rAB*rCB); double cosine = dot/(rAB*rCB);
RealOpenMM angle; double angle;
if (cosine >= one) { if (cosine >= 1.0) {
angle = zero; angle = 0.0;
} else if (cosine <= -one) { } else if (cosine <= -1.0) {
angle = PI_M; angle = M_PI;
} else { } else {
angle = RADIAN*ACOS(cosine); angle = RADIAN*acos(cosine);
} }
RealOpenMM termA = -RADIAN/(rAB2*rP); double termA = -RADIAN/(rAB2*rP);
RealOpenMM termC = RADIAN/(rCB2*rP); double termC = RADIAN/(rCB2*rP);
// P = CBxAB // P = CBxAB
...@@ -125,11 +117,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe ...@@ -125,11 +117,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
deltaR[CBxP][ii] *= termC; deltaR[CBxP][ii] *= termC;
} }
RealOpenMM dr1 = rAB - lengthAB; double dr1 = rAB - lengthAB;
RealOpenMM dr2 = rCB - lengthCB; double dr2 = rCB - lengthCB;
RealOpenMM drkk = dr1*k1Parameter + dr2*k2Parameter; double drkk = dr1*k1Parameter + dr2*k2Parameter;
termA = one/rAB; termA = 1.0/rAB;
termC = one/rCB; termC = 1.0/rCB;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -138,11 +130,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe ...@@ -138,11 +130,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
// calculate forces for atoms a, b, c // calculate forces for atoms a, b, c
// the force for b is then -(a + 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++) { for (int ii = 0; ii < LastAtomIndex; ii++) {
subForce[ii].resize(3); subForce[ii].resize(3);
} }
RealOpenMM dt = angle - idealAngle*RADIAN; double dt = angle - idealAngle*RADIAN;
for (int jj = 0; jj < 3; jj++) { for (int jj = 0; jj < 3; jj++) {
subForce[A][jj] = k1Parameter*dt*termA*deltaR[AB][jj] + drkk*deltaR[ABxP][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]; subForce[C][jj] = k2Parameter*dt*termC*deltaR[CB][jj] + drkk*deltaR[CBxP][jj];
...@@ -162,29 +154,29 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe ...@@ -162,29 +154,29 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
return dt*drkk; return dt*drkk;
} }
RealOpenMM AmoebaReferenceStretchBendForce::calculateForceAndEnergy(int numStretchBends, vector<RealVec>& posData, double AmoebaReferenceStretchBendForce::calculateForceAndEnergy(int numStretchBends, vector<Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<RealOpenMM>& lengthABParameters, const std::vector<double>& lengthABParameters,
const std::vector<RealOpenMM>& lengthCBParameters, const std::vector<double>& lengthCBParameters,
const std::vector<RealOpenMM>& angle, const std::vector<double>& angle,
const std::vector<RealOpenMM>& k1Quadratic, const std::vector<double>& k1Quadratic,
const std::vector<RealOpenMM>& k2Quadratic, const std::vector<double>& k2Quadratic,
vector<RealVec>& forceData) const { vector<Vec3>& forceData) const {
RealOpenMM energy = 0.0; double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numStretchBends); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(numStretchBends); ii++) {
int particle1Index = particle1[ii]; int particle1Index = particle1[ii];
int particle2Index = particle2[ii]; int particle2Index = particle2[ii];
int particle3Index = particle3[ii]; int particle3Index = particle3[ii];
RealOpenMM abLength = lengthABParameters[ii]; double abLength = lengthABParameters[ii];
RealOpenMM cbLength = lengthCBParameters[ii]; double cbLength = lengthCBParameters[ii];
RealOpenMM idealAngle = angle[ii]; double idealAngle = angle[ii];
RealOpenMM angleK1 = k1Quadratic[ii]; double angleK1 = k1Quadratic[ii];
RealOpenMM angleK2 = k2Quadratic[ii]; double angleK2 = k2Quadratic[ii];
RealVec forces[3]; Vec3 forces[3];
energy += calculateStretchBendIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index], energy += calculateStretchBendIxn(posData[particle1Index], posData[particle2Index], posData[particle3Index],
abLength, cbLength, idealAngle, angleK1, angleK2, forces); abLength, cbLength, idealAngle, angleK1, angleK2, forces);
// accumulate forces // accumulate forces
for (int jj = 0; jj < 3; jj++) { for (int jj = 0; jj < 3; jj++) {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceStretchBendForce_H__ #ifndef __AmoebaReferenceStretchBendForce_H__
#define __AmoebaReferenceStretchBendForce_H__ #define __AmoebaReferenceStretchBendForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
namespace OpenMM { namespace OpenMM {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors); void setPeriodic(OpenMM::Vec3* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -80,22 +80,22 @@ public: ...@@ -80,22 +80,22 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numAngles, std::vector<OpenMM::RealVec>& posData, double calculateForceAndEnergy(int numAngles, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<RealOpenMM>& lengthABParameters, const std::vector<double>& lengthABParameters,
const std::vector<RealOpenMM>& lengthCBParameters, const std::vector<double>& lengthCBParameters,
const std::vector<RealOpenMM>& angle, const std::vector<double>& angle,
const std::vector<RealOpenMM>& k1Quadratic, const std::vector<double>& k1Quadratic,
const std::vector<RealOpenMM>& k2Quadratic, const std::vector<double>& k2Quadratic,
std::vector<OpenMM::RealVec>& forceData) const; std::vector<OpenMM::Vec3>& forceData) const;
private: private:
bool usePeriodic; bool usePeriodic;
RealVec boxVectors[3]; Vec3 boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -115,11 +115,11 @@ private: ...@@ -115,11 +115,11 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateStretchBendIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, double calculateStretchBendIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::Vec3& positionAtomC,
RealOpenMM lengthAB, RealOpenMM lengthCB, double lengthAB, double lengthCB,
RealOpenMM idealAngle, RealOpenMM k1Parameter, double idealAngle, double k1Parameter,
RealOpenMM k2Parameter, OpenMM::RealVec* forces) const; double k2Parameter, OpenMM::Vec3* forces) const;
}; };
......
...@@ -23,11 +23,12 @@ ...@@ -23,11 +23,12 @@
#include "AmoebaReferenceForce.h" #include "AmoebaReferenceForce.h"
#include "AmoebaReferenceTorsionTorsionForce.h" #include "AmoebaReferenceTorsionTorsionForce.h"
#include "SimTKOpenMMRealType.h"
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) { void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::Vec3* vectors) {
usePeriodic = true; usePeriodic = true;
boxVectors[0] = vectors[0]; boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1]; boxVectors[1] = vectors[1];
...@@ -54,15 +55,9 @@ void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -54,15 +55,9 @@ void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle( void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle(
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid, const std::vector< std::vector< std::vector<double> > >& grid,
RealOpenMM angle1, RealOpenMM angle2, RealOpenMM corners[2][2], double angle1, double angle2, double corners[2][2],
RealOpenMM* fValues, RealOpenMM* fValues1, RealOpenMM* fValues2, RealOpenMM* fValues12) const { double* fValues, double* fValues1, double* fValues2, double* fValues12) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "loadGridValuesFromEnclosingRectangle";
// ---------------------------------------------------------------------------------------
// get 2 opposing grid indices for rectangle // get 2 opposing grid indices for rectangle
...@@ -123,50 +118,37 @@ void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle( ...@@ -123,50 +118,37 @@ void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle(
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealOpenMM* y, void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const double* y,
const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12, const RealOpenMM d1, const RealOpenMM d2, const double* y1, const double* y2, const double* y12, const double d1, const double d2,
RealOpenMM c[4][4]) const { double c[4][4]) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix";
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 // transpose of matrix in Tinker due to difference in C/Fotran row/column major
// change indices when multiplying by weightMatrix // change indices when multiplying by weightMatrix
static const RealOpenMM weightMatrix[16][16] = { static const double weightMatrix[16][16] = {
{ one, zero, -three, two, zero, zero, zero, zero, -three, zero, nine, -six, two, zero, -six, four }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, three, zero, -nine, six, -two, zero, six, -four }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, nine, -six, zero, zero, -six, four }, { 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 },
{ zero, zero, three, -two, zero, zero, zero, zero, zero, zero, -nine, six, zero, zero, six, -four }, { 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 },
{ zero, zero, zero, zero, one, zero, -three, two, -two, zero, six, -four, one, zero, -three, two }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, -one, zero, three, -two, one, zero, -three, two }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, -three, two, zero, zero, three, -two }, { 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 },
{ zero, zero, zero, zero, zero, zero, three, -two, zero, zero, -six, four, zero, zero, three, -two }, { 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 },
{ zero, one, -two, one, zero, zero, zero, zero, zero, -three, six, -three, zero, two, -four, two }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, three, -six, three, zero, -two, four, -two }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, -three, three, zero, zero, two, -two }, { 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 },
{ zero, zero, -one, one, zero, zero, zero, zero, zero, zero, three, -three, zero, zero, -two, two }, { 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 },
{ zero, zero, zero, zero, zero, one, -two, one, zero, -two, four, -two, zero, one, -two, one }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, -one, two, -one, zero, one, -two, one }, { 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 },
{ zero, zero, zero, zero, zero, zero, zero, zero, zero, zero, one, -one, zero, zero, -one, one }, { 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 },
{ zero, zero, zero, zero, zero, zero, -one, one, zero, zero, two, -two, zero, zero, -one, one } }; { 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 // pack y, y1, y2, y12 into single vector of dimension 16
std::vector<RealOpenMM> x(16); std::vector<double> x(16);
RealOpenMM d1d2 = d1*d2; double d1d2 = d1*d2;
for (int ii = 0; ii < 4; ii++) { for (int ii = 0; ii < 4; ii++) {
x[ii] = y[ii]; x[ii] = y[ii];
x[ii+4] = y1[ii]*d1; x[ii+4] = y1[ii]*d1;
...@@ -179,7 +161,7 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO ...@@ -179,7 +161,7 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
int rowIndex = 0; int rowIndex = 0;
int colIndex = 0; int colIndex = 0;
for (int ii = 0; ii < 16; ii++) { 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++) { for (int jj = 1; jj < 16; jj++) {
sum += weightMatrix[jj][ii]*x[jj]; sum += weightMatrix[jj][ii]*x[jj];
} }
...@@ -223,40 +205,30 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO ...@@ -223,40 +205,30 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void AmoebaReferenceTorsionTorsionForce::getBicubicValues( void AmoebaReferenceTorsionTorsionForce::getBicubicValues(
const RealOpenMM* y, const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12, const double* y, const double* y1, const double* y2, const double* y12,
const RealOpenMM x1Lower, const RealOpenMM x1Upper, const double x1Lower, const double x1Upper,
const RealOpenMM x2Lower, const RealOpenMM x2Upper, const double x2Lower, const double x2Upper,
const RealOpenMM gridValue1, const RealOpenMM gridValue2, const double gridValue1, const double gridValue2,
RealOpenMM* functionValue, RealOpenMM* functionValue1, RealOpenMM* functionValue2) const { double* functionValue, double* functionValue1, double* functionValue2) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "getBicubicValues";
static const RealOpenMM zero = 0.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
// ---------------------------------------------------------------------------------------
// get coefficent matrix // get coefficent matrix
RealOpenMM coefficientMatrix[4][4]; double coefficientMatrix[4][4];
getBicubicCoefficientMatrix(y, y1, y2, y12, x1Upper-x1Lower, x2Upper-x2Lower, coefficientMatrix); getBicubicCoefficientMatrix(y, y1, y2, y12, x1Upper-x1Lower, x2Upper-x2Lower, coefficientMatrix);
// apply coefficent matrix // apply coefficent matrix
RealOpenMM t = (gridValue1 - x1Lower)/(x1Upper - x1Lower); double t = (gridValue1 - x1Lower)/(x1Upper - x1Lower);
RealOpenMM u = (gridValue2 - x2Lower)/(x2Upper - x2Lower); double u = (gridValue2 - x2Lower)/(x2Upper - x2Lower);
*functionValue = zero; *functionValue = 0.0;
*functionValue1 = zero; *functionValue1 = 0.0;
*functionValue2 = zero; *functionValue2 = 0.0;
for (int ii = 3; ii >= 0; ii--) { 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]; *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]; *functionValue1 = u*(*functionValue1) + (3.0*coefficientMatrix[3][ii]*t + 2.0*coefficientMatrix[2][ii])*t + coefficientMatrix[1][ii];
*functionValue2 = t*(*functionValue2) + (three*coefficientMatrix[ii][3]*u + two*coefficientMatrix[ii][2])*u + coefficientMatrix[ii][1]; *functionValue2 = t*(*functionValue2) + (3.0*coefficientMatrix[ii][3]*u + 2.0*coefficientMatrix[ii][2])*u + coefficientMatrix[ii][1];
} }
*functionValue1 /= (x1Upper - x1Lower); *functionValue1 /= (x1Upper - x1Lower);
...@@ -280,22 +252,13 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicValues( ...@@ -280,22 +252,13 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicValues(
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int AmoebaReferenceTorsionTorsionForce::checkTorsionSign( int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
const RealVec& positionAtomA, const RealVec& positionAtomB, const Vec3& positionAtomA, const Vec3& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD) const { const Vec3& positionAtomC, const Vec3& positionAtomD) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::checkTorsionSign";
static const RealOpenMM zero = 0.0;
static const int one = 1;
// ---------------------------------------------------------------------------------------
// compute parallelpiped volume at atomC and return sign based on sign of volume // compute parallelpiped volume at atomC and return sign based on sign of volume
enum { CA, CB, CD, LastDeltaIndex }; enum { CA, CB, CD, LastDeltaIndex };
std::vector<RealOpenMM> deltaR[LastDeltaIndex]; std::vector<double> deltaR[LastDeltaIndex];
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) { for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
...@@ -311,11 +274,11 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign( ...@@ -311,11 +274,11 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomD, deltaR[CD]); AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomD, deltaR[CD]);
} }
RealOpenMM volume = deltaR[CA][0]*(deltaR[CB][1]*deltaR[CD][2] - deltaR[CB][2]*deltaR[CD][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[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]); 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( ...@@ -337,21 +300,12 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const RealVec& positionAtomA, const RealVec& positionAtomB, double AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const Vec3& positionAtomA, const Vec3& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomD, const Vec3& positionAtomC, const Vec3& positionAtomD,
const RealVec& positionAtomE, const RealVec* positionChiralCheckAtom, const Vec3& positionAtomE, const Vec3* positionChiralCheckAtom,
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid, const std::vector< std::vector< std::vector<double> > >& grid,
RealVec* forces) const { Vec3* forces) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
enum { A, B, C, D, E, LastAtomIndex }; enum { A, B, C, D, E, LastAtomIndex };
// get deltaR between various combinations of the 4 atoms // get deltaR between various combinations of the 4 atoms
...@@ -359,7 +313,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -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 }; 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++) { for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
...@@ -383,7 +337,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -383,7 +337,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomE, deltaR[EC]); AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomE, deltaR[EC]);
} }
std::vector<RealOpenMM> d[LastAtomIndex]; std::vector<double> d[LastAtomIndex];
for (unsigned int ii = 0; ii < LastAtomIndex; ii++) { for (unsigned int ii = 0; ii < LastAtomIndex; ii++) {
d[ii].resize(3); d[ii].resize(3);
} }
...@@ -394,51 +348,51 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -394,51 +348,51 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[V], deltaR[UxV]); AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[V], deltaR[UxV]);
RealOpenMM rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]); double rT2 = AmoebaReferenceForce::getNormSquared3(deltaR[T]);
RealOpenMM rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]); double rU2 = AmoebaReferenceForce::getNormSquared3(deltaR[U]);
RealOpenMM rV2 = AmoebaReferenceForce::getNormSquared3(deltaR[V]); double rV2 = AmoebaReferenceForce::getNormSquared3(deltaR[V]);
RealOpenMM rUrV = SQRT(rU2*rV2); double rUrV = sqrt(rU2*rV2);
RealOpenMM rTrU = SQRT(rT2*rU2); double rTrU = sqrt(rT2*rU2);
if (rTrU <= zero || rUrV <= zero) { if (rTrU <= 0.0 || rUrV <= 0.0) {
return zero; return 0.0;
} }
RealOpenMM rCB = AmoebaReferenceForce::getNorm3(deltaR[CB]); double rCB = AmoebaReferenceForce::getNorm3(deltaR[CB]);
RealOpenMM cosine1 = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]); double cosine1 = AmoebaReferenceForce::getDotProduct3(deltaR[T], deltaR[U]);
cosine1 /= rTrU; cosine1 /= rTrU;
RealOpenMM angle1; double angle1;
if (cosine1 <= -one) { if (cosine1 <= -1.0) {
angle1 = PI_M*RADIAN; angle1 = M_PI*RADIAN;
} else if (cosine1 >= one) { } else if (cosine1 >= 1.0) {
angle1 = zero; angle1 = 0.0;
} else { } else {
angle1 = RADIAN*ACOS(cosine1); angle1 = RADIAN*acos(cosine1);
} }
RealOpenMM sign = AmoebaReferenceForce::getDotProduct3(deltaR[BA], deltaR[U]); double sign = AmoebaReferenceForce::getDotProduct3(deltaR[BA], deltaR[U]);
if (sign < zero) { if (sign < 0.0) {
angle1 = -angle1; angle1 = -angle1;
} }
// value1 = angle1; // value1 = angle1;
RealOpenMM rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]); double rDC = AmoebaReferenceForce::getNorm3(deltaR[DC]);
RealOpenMM cosine2 = AmoebaReferenceForce::getDotProduct3(deltaR[U], deltaR[V]); double cosine2 = AmoebaReferenceForce::getDotProduct3(deltaR[U], deltaR[V]);
cosine2 /= rUrV; cosine2 /= rUrV;
RealOpenMM angle2; double angle2;
if (cosine2 <= -one) { if (cosine2 <= -1.0) {
angle2 = PI_M*RADIAN; angle2 = M_PI*RADIAN;
} else if (cosine1 >= one) { } else if (cosine1 >= 1.0) {
angle2 = zero; angle2 = 0.0;
} else { } else {
angle2 = RADIAN*ACOS(cosine2); angle2 = RADIAN*acos(cosine2);
} }
sign = AmoebaReferenceForce::getDotProduct3(deltaR[CB], deltaR[V]); sign = AmoebaReferenceForce::getDotProduct3(deltaR[CB], deltaR[V]);
if (sign < zero) { if (sign < 0.0) {
angle2 = -angle2; angle2 = -angle2;
} }
...@@ -447,18 +401,18 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -447,18 +401,18 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
if (positionChiralCheckAtom) { if (positionChiralCheckAtom) {
sign = checkTorsionSign(*positionChiralCheckAtom, positionAtomB, positionAtomC, positionAtomD); sign = checkTorsionSign(*positionChiralCheckAtom, positionAtomB, positionAtomC, positionAtomD);
if (sign < zero) { if (sign < 0.0) {
angle1 = -angle1; angle1 = -angle1;
angle2 = -angle2; angle2 = -angle2;
} }
} else { } else {
sign = one; sign = 1.0;
} }
// bicubic interpolation // bicubic interpolation
RealOpenMM corners[2][2]; double corners[2][2];
RealOpenMM eValues[4][4]; double eValues[4][4];
enum { E0, E1, E2, E12, LastEIndex }; enum { E0, E1, E2, E12, LastEIndex };
loadGridValuesFromEnclosingRectangle(grid, angle1, angle2, corners, eValues[E0], eValues[E1], eValues[E2], eValues[E12]); loadGridValuesFromEnclosingRectangle(grid, angle1, angle2, corners, eValues[E0], eValues[E1], eValues[E2], eValues[E12]);
...@@ -467,9 +421,9 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -467,9 +421,9 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
// get corners of grid encompassing point // get corners of grid encompassing point
// get width/height of encompassing rectangle // get width/height of encompassing rectangle
RealOpenMM gridEnergy; double gridEnergy;
RealOpenMM dEdAngle1; double dEdAngle1;
RealOpenMM dEdAngle2; double dEdAngle2;
AmoebaReferenceTorsionTorsionForce::getBicubicValues( AmoebaReferenceTorsionTorsionForce::getBicubicValues(
eValues[E0], eValues[E1], eValues[E2], eValues[E12], eValues[E0], eValues[E1], eValues[E2], eValues[E12],
corners[0][0], corners[0][1], corners[1][0], corners[1][1], corners[0][0], corners[0][1], corners[1][0], corners[1][1],
...@@ -481,8 +435,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -481,8 +435,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[CB], deltaR[dT]); AmoebaReferenceForce::getCrossProduct(deltaR[T], deltaR[CB], deltaR[dT]);
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[CB], deltaR[dU]); AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[CB], deltaR[dU]);
RealOpenMM factorT = dEdAngle1/(rCB*rT2); double factorT = dEdAngle1/(rCB*rT2);
RealOpenMM factorU = -dEdAngle1/(rCB*rU2); double factorU = -dEdAngle1/(rCB*rU2);
deltaR[dT][0] *= factorT; deltaR[dT][0] *= factorT;
deltaR[dT][1] *= factorT; deltaR[dT][1] *= factorT;
...@@ -495,7 +449,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -495,7 +449,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[dT], deltaR[CB], d[A]); AmoebaReferenceForce::getCrossProduct(deltaR[dT], deltaR[CB], d[A]);
AmoebaReferenceForce::getCrossProduct(deltaR[dU], deltaR[CB], d[D]); 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++) { for (unsigned int ii = 0; ii < 3; ii++) {
tmp[ii].resize(3); tmp[ii].resize(3);
} }
...@@ -518,8 +472,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -518,8 +472,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[DC], deltaR[dU2]); AmoebaReferenceForce::getCrossProduct(deltaR[U], deltaR[DC], deltaR[dU2]);
AmoebaReferenceForce::getCrossProduct(deltaR[V], deltaR[DC], deltaR[dV2]); AmoebaReferenceForce::getCrossProduct(deltaR[V], deltaR[DC], deltaR[dV2]);
RealOpenMM factorU2 = dEdAngle2/(rDC*rU2); double factorU2 = dEdAngle2/(rDC*rU2);
RealOpenMM factorV2 = -dEdAngle2/(rDC*rV2); double factorV2 = -dEdAngle2/(rDC*rV2);
deltaR[dU2][0] *= factorU2; deltaR[dU2][0] *= factorU2;
deltaR[dU2][1] *= factorU2; deltaR[dU2][1] *= factorU2;
...@@ -574,17 +528,17 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -574,17 +528,17 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
return gridEnergy; return gridEnergy;
} }
RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTorsionTorsions, vector<RealVec>& posData, double AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTorsionTorsions, vector<Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<int>& particle5, const std::vector<int>& particle5,
const std::vector<int>& chiralCheckAtom, const std::vector<int>& chiralCheckAtom,
const std::vector<int>& gridIndices, const std::vector<int>& gridIndices,
const std::vector< std::vector< std::vector< std::vector<RealOpenMM> > > >& torsionTorsionGrids, const std::vector< std::vector< std::vector< std::vector<double> > > >& torsionTorsionGrids,
vector<RealVec>& forceData) const { vector<Vec3>& forceData) const {
RealOpenMM energy = 0.0; double energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numTorsionTorsions); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(numTorsionTorsions); ii++) {
int particle1Index = particle1[ii]; int particle1Index = particle1[ii];
...@@ -597,8 +551,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTo ...@@ -597,8 +551,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTo
int gridIndex = gridIndices[ii]; int gridIndex = gridIndices[ii];
RealVec forces[5]; Vec3 forces[5];
RealVec* chiralCheckAtom; Vec3* chiralCheckAtom;
if (chiralCheckAtomIndex > -1) { if (chiralCheckAtomIndex > -1) {
chiralCheckAtom = &posData[chiralCheckAtomIndex]; chiralCheckAtom = &posData[chiralCheckAtomIndex];
} else { } else {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceTorsionTorsionForce_H__ #ifndef __AmoebaReferenceTorsionTorsionForce_H__
#define __AmoebaReferenceTorsionTorsionForce_H__ #define __AmoebaReferenceTorsionTorsionForce_H__
#include "RealVec.h" #include "openmm/Vec3.h"
#include <vector> #include <vector>
namespace OpenMM { namespace OpenMM {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors); void setPeriodic(OpenMM::Vec3* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -81,21 +81,21 @@ public: ...@@ -81,21 +81,21 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateForceAndEnergy(int numTorsionTorsions, std::vector<OpenMM::RealVec>& posData, double calculateForceAndEnergy(int numTorsionTorsions, std::vector<OpenMM::Vec3>& posData,
const std::vector<int>& particle1, const std::vector<int>& particle1,
const std::vector<int>& particle2, const std::vector<int>& particle2,
const std::vector<int>& particle3, const std::vector<int>& particle3,
const std::vector<int>& particle4, const std::vector<int>& particle4,
const std::vector<int>& particle5, const std::vector<int>& particle5,
const std::vector<int>& chiralCheckAtom, const std::vector<int>& chiralCheckAtom,
const std::vector<int>& gridIndices, const std::vector<int>& gridIndices,
const std::vector< std::vector< std::vector< std::vector<RealOpenMM> > > >& torsionTorsionGrids, const std::vector< std::vector< std::vector< std::vector<double> > > >& torsionTorsionGrids,
std::vector<OpenMM::RealVec>& forceData) const; std::vector<OpenMM::Vec3>& forceData) const;
private: private:
bool usePeriodic; bool usePeriodic;
RealVec boxVectors[3]; Vec3 boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -116,9 +116,9 @@ private: ...@@ -116,9 +116,9 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void loadGridValuesFromEnclosingRectangle( void loadGridValuesFromEnclosingRectangle(
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid, const std::vector< std::vector< std::vector<double> > >& grid,
RealOpenMM angle1, RealOpenMM angle2, RealOpenMM corners[2][2], double angle1, double angle2, double corners[2][2],
RealOpenMM* fValues, RealOpenMM* fValues1, RealOpenMM* fValues2, RealOpenMM* fValues12) const; double* fValues, double* fValues1, double* fValues2, double* fValues12) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -141,8 +141,8 @@ private: ...@@ -141,8 +141,8 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void getBicubicCoefficientMatrix(const RealOpenMM* y, const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12, void getBicubicCoefficientMatrix(const double* y, const double* y1, const double* y2, const double* y12,
const RealOpenMM d1, const RealOpenMM d2, RealOpenMM c[4][4]) const; const double d1, const double d2, double c[4][4]) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -176,11 +176,11 @@ private: ...@@ -176,11 +176,11 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void getBicubicValues( void getBicubicValues(
const RealOpenMM* y, const RealOpenMM* y1, const RealOpenMM* y2, const RealOpenMM* y12, const double* y, const double* y1, const double* y2, const double* y12,
const RealOpenMM x1Lower, const RealOpenMM x1Upper, const double x1Lower, const double x1Upper,
const RealOpenMM x2Lower, const RealOpenMM x2Upper, const double x2Lower, const double x2Upper,
const RealOpenMM gridValue1, const RealOpenMM gridValue2, const double gridValue1, const double gridValue2,
RealOpenMM* functionValue, RealOpenMM* functionValue1, RealOpenMM* functionValue2) const; double* functionValue, double* functionValue1, double* functionValue2) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -196,8 +196,8 @@ private: ...@@ -196,8 +196,8 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int checkTorsionSign(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, int checkTorsionSign(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD) const; const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -217,11 +217,11 @@ private: ...@@ -217,11 +217,11 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM calculateTorsionTorsionIxn(const OpenMM::RealVec& positionAtomA, const OpenMM::RealVec& positionAtomB, double calculateTorsionTorsionIxn(const OpenMM::Vec3& positionAtomA, const OpenMM::Vec3& positionAtomB,
const OpenMM::RealVec& positionAtomC, const OpenMM::RealVec& positionAtomD, const OpenMM::Vec3& positionAtomC, const OpenMM::Vec3& positionAtomD,
const OpenMM::RealVec& positionAtomE, const OpenMM::RealVec* chiralCheckAtom, const OpenMM::Vec3& positionAtomE, const OpenMM::Vec3* chiralCheckAtom,
const std::vector< std::vector< std::vector<RealOpenMM> > >& grid, const std::vector< std::vector< std::vector<double> > >& grid,
OpenMM::RealVec* forces) const; OpenMM::Vec3* forces) const;
}; };
......
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