Unverified Commit 8f8aa247 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2112 from peastman/cleanup

Code cleanup
parents 0d13f9cd c0e862f6
...@@ -76,8 +76,8 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn { ...@@ -76,8 +76,8 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates, void calculateBondIxn(std::vector<int>& atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces, std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs); double* totalEnergy, double* energyParamDerivs);
}; };
......
...@@ -89,36 +89,6 @@ ...@@ -89,36 +89,6 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
static int** allocateIntArray(int length, int width) {
int** array = new int*[length];
for (int i = 0; i < length; ++i)
array[i] = new int[width];
return array;
}
static double** allocateRealArray(int length, int width) {
double** array = new double*[length];
for (int i = 0; i < length; ++i)
array[i] = new double[width];
return array;
}
static void disposeIntArray(int** array, int size) {
if (array) {
for (int i = 0; i < size; ++i)
delete[] array[i];
delete[] array;
}
}
static void disposeRealArray(double** array, int size) {
if (array) {
for (int i = 0; i < size; ++i)
delete[] array[i];
delete[] array;
}
}
static vector<Vec3>& extractPositions(ContextImpl& context) { static vector<Vec3>& extractPositions(ContextImpl& context) {
ReferencePlatform::PlatformData* data = reinterpret_cast<ReferencePlatform::PlatformData*>(context.getPlatformData()); ReferencePlatform::PlatformData* data = reinterpret_cast<ReferencePlatform::PlatformData*>(context.getPlatformData());
return *((vector<Vec3>*) data->positions); return *((vector<Vec3>*) data->positions);
...@@ -366,15 +336,10 @@ void ReferenceVirtualSitesKernel::computePositions(ContextImpl& context) { ...@@ -366,15 +336,10 @@ void ReferenceVirtualSitesKernel::computePositions(ContextImpl& context) {
ReferenceVirtualSites::computePositions(context.getSystem(), positions); ReferenceVirtualSites::computePositions(context.getSystem(), positions);
} }
ReferenceCalcHarmonicBondForceKernel::~ReferenceCalcHarmonicBondForceKernel() {
disposeIntArray(bondIndexArray, numBonds);
disposeRealArray(bondParamArray, numBonds);
}
void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, const HarmonicBondForce& force) { void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, const HarmonicBondForce& force) {
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
bondIndexArray = allocateIntArray(numBonds, 2); bondIndexArray.resize(numBonds, vector<int>(2));
bondParamArray = allocateRealArray(numBonds, 2); bondParamArray.resize(numBonds, vector<double>(2));
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i) {
int particle1, particle2; int particle1, particle2;
double length, k; double length, k;
...@@ -418,11 +383,6 @@ void ReferenceCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl& ...@@ -418,11 +383,6 @@ void ReferenceCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl&
} }
} }
ReferenceCalcCustomBondForceKernel::~ReferenceCalcCustomBondForceKernel() {
disposeIntArray(bondIndexArray, numBonds);
disposeRealArray(bondParamArray, numBonds);
}
void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const CustomBondForce& force) { void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const CustomBondForce& force) {
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
int numParameters = force.getNumPerBondParameters(); int numParameters = force.getNumPerBondParameters();
...@@ -430,8 +390,8 @@ void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const ...@@ -430,8 +390,8 @@ void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const
// Build the arrays. // Build the arrays.
bondIndexArray = allocateIntArray(numBonds, 2); bondIndexArray.resize(numBonds, vector<int>(2));
bondParamArray = allocateRealArray(numBonds, numParameters); bondParamArray.resize(numBonds, vector<double>(numParameters));
vector<double> params; vector<double> params;
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i) {
int particle1, particle2; int particle1, particle2;
...@@ -500,15 +460,10 @@ void ReferenceCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& co ...@@ -500,15 +460,10 @@ void ReferenceCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& co
} }
} }
ReferenceCalcHarmonicAngleForceKernel::~ReferenceCalcHarmonicAngleForceKernel() {
disposeIntArray(angleIndexArray, numAngles);
disposeRealArray(angleParamArray, numAngles);
}
void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, const HarmonicAngleForce& force) { void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, const HarmonicAngleForce& force) {
numAngles = force.getNumAngles(); numAngles = force.getNumAngles();
angleIndexArray = allocateIntArray(numAngles, 3); angleIndexArray.resize(numAngles, vector<int>(3));
angleParamArray = allocateRealArray(numAngles, 2); angleParamArray.resize(numAngles, vector<double>(2));
for (int i = 0; i < numAngles; ++i) { for (int i = 0; i < numAngles; ++i) {
int particle1, particle2, particle3; int particle1, particle2, particle3;
double angle, k; double angle, k;
...@@ -551,11 +506,6 @@ void ReferenceCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl& ...@@ -551,11 +506,6 @@ void ReferenceCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl&
} }
} }
ReferenceCalcCustomAngleForceKernel::~ReferenceCalcCustomAngleForceKernel() {
disposeIntArray(angleIndexArray, numAngles);
disposeRealArray(angleParamArray, numAngles);
}
void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const CustomAngleForce& force) { void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const CustomAngleForce& force) {
numAngles = force.getNumAngles(); numAngles = force.getNumAngles();
int numParameters = force.getNumPerAngleParameters(); int numParameters = force.getNumPerAngleParameters();
...@@ -563,8 +513,8 @@ void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const ...@@ -563,8 +513,8 @@ void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const
// Build the arrays. // Build the arrays.
angleIndexArray = allocateIntArray(numAngles, 3); angleIndexArray.resize(numAngles, vector<int>(3));
angleParamArray = allocateRealArray(numAngles, numParameters); angleParamArray.resize(numAngles, vector<double>(numParameters));
vector<double> params; vector<double> params;
for (int i = 0; i < numAngles; ++i) { for (int i = 0; i < numAngles; ++i) {
int particle1, particle2, particle3; int particle1, particle2, particle3;
...@@ -634,15 +584,10 @@ void ReferenceCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& c ...@@ -634,15 +584,10 @@ void ReferenceCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& c
} }
} }
ReferenceCalcPeriodicTorsionForceKernel::~ReferenceCalcPeriodicTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, const PeriodicTorsionForce& force) { void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, const PeriodicTorsionForce& force) {
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray = allocateRealArray(numTorsions, 3); torsionParamArray.resize(numTorsions, vector<double>(3));
for (int i = 0; i < numTorsions; ++i) { for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4, periodicity; int particle1, particle2, particle3, particle4, periodicity;
double phase, k; double phase, k;
...@@ -688,15 +633,10 @@ void ReferenceCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImp ...@@ -688,15 +633,10 @@ void ReferenceCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImp
} }
} }
ReferenceCalcRBTorsionForceKernel::~ReferenceCalcRBTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const RBTorsionForce& force) { void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const RBTorsionForce& force) {
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray = allocateRealArray(numTorsions, 6); torsionParamArray.resize(numTorsions, vector<double>(6));
for (int i = 0; i < numTorsions; ++i) { for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
double c0, c1, c2, c3, c4, c5; double c0, c1, c2, c3, c4, c5;
...@@ -820,11 +760,6 @@ void ReferenceCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& c ...@@ -820,11 +760,6 @@ void ReferenceCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& c
} }
} }
ReferenceCalcCustomTorsionForceKernel::~ReferenceCalcCustomTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, const CustomTorsionForce& force) { void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, const CustomTorsionForce& force) {
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
int numParameters = force.getNumPerTorsionParameters(); int numParameters = force.getNumPerTorsionParameters();
...@@ -832,8 +767,8 @@ void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, con ...@@ -832,8 +767,8 @@ void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, con
// Build the arrays. // Build the arrays.
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray = allocateRealArray(numTorsions, numParameters); torsionParamArray.resize(numTorsions, vector<double>(numParameters));
vector<double> params; vector<double> params;
for (int i = 0; i < numTorsions; ++i) { for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
...@@ -905,9 +840,6 @@ void ReferenceCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl& ...@@ -905,9 +840,6 @@ void ReferenceCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl&
} }
ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() { ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() {
disposeRealArray(particleParamArray, numParticles);
disposeIntArray(bonded14IndexArray, num14);
disposeRealArray(bonded14ParamArray, num14);
if (neighborList != NULL) if (neighborList != NULL)
delete neighborList; delete neighborList;
} }
...@@ -932,9 +864,9 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N ...@@ -932,9 +864,9 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
// Build the arrays. // Build the arrays.
num14 = nb14s.size(); num14 = nb14s.size();
bonded14IndexArray = allocateIntArray(num14, 2); bonded14IndexArray.resize(num14, vector<int>(2));
bonded14ParamArray = allocateRealArray(num14, 3); bonded14ParamArray.resize(num14, vector<double>(3));
particleParamArray = allocateRealArray(numParticles, 3); particleParamArray.resize(numParticles, vector<double>(3));
baseParticleParams.resize(numParticles); baseParticleParams.resize(numParticles);
baseExceptionParams.resize(num14); baseExceptionParams.resize(num14);
for (int i = 0; i < numParticles; ++i) for (int i = 0; i < numParticles; ++i)
...@@ -1027,7 +959,7 @@ double ReferenceCalcNonbondedForceKernel::execute(ContextImpl& context, bool inc ...@@ -1027,7 +959,7 @@ double ReferenceCalcNonbondedForceKernel::execute(ContextImpl& context, bool inc
} }
if (useSwitchingFunction) if (useSwitchingFunction)
clj.setUseSwitchingFunction(switchingDistance); clj.setUseSwitchingFunction(switchingDistance);
clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, 0, forceData, 0, includeEnergy ? &energy : NULL, includeDirect, includeReciprocal); clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, forceData, includeEnergy ? &energy : NULL, includeDirect, includeReciprocal);
if (includeDirect) { if (includeDirect) {
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
ReferenceLJCoulomb14 nonbonded14; ReferenceLJCoulomb14 nonbonded14;
...@@ -1137,7 +1069,6 @@ void ReferenceCalcNonbondedForceKernel::computeParameters(ContextImpl& context) ...@@ -1137,7 +1069,6 @@ void ReferenceCalcNonbondedForceKernel::computeParameters(ContextImpl& context)
} }
ReferenceCalcCustomNonbondedForceKernel::~ReferenceCalcCustomNonbondedForceKernel() { ReferenceCalcCustomNonbondedForceKernel::~ReferenceCalcCustomNonbondedForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (neighborList != NULL) if (neighborList != NULL)
delete neighborList; delete neighborList;
if (forceCopy != NULL) if (forceCopy != NULL)
...@@ -1160,13 +1091,9 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, c ...@@ -1160,13 +1091,9 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, c
// Build the arrays. // Build the arrays.
int numParameters = force.getNumPerParticleParameters(); int numParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numParameters); particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i)
vector<double> parameters; force.getParticleParameters(i, particleParamArray[i]);
force.getParticleParameters(i, parameters);
for (int j = 0; j < numParameters; j++)
particleParamArray[i][j] = parameters[j];
}
nonbondedMethod = CalcCustomNonbondedForceKernel::NonbondedMethod(force.getNonbondedMethod()); nonbondedMethod = CalcCustomNonbondedForceKernel::NonbondedMethod(force.getNonbondedMethod());
nonbondedCutoff = force.getCutoffDistance(); nonbondedCutoff = force.getCutoffDistance();
if (nonbondedMethod == NoCutoff) { if (nonbondedMethod == NoCutoff) {
...@@ -1264,7 +1191,7 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo ...@@ -1264,7 +1191,7 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo
if (useSwitchingFunction) if (useSwitchingFunction)
ixn.setUseSwitchingFunction(switchingDistance); ixn.setUseSwitchingFunction(switchingDistance);
vector<double> energyParamDerivValues(energyParamDerivNames.size()+1, 0.0); vector<double> energyParamDerivValues(energyParamDerivNames.size()+1, 0.0);
ixn.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, 0, globalParamValues, forceData, 0, includeEnergy ? &energy : NULL, &energyParamDerivValues[0]); ixn.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, globalParamValues, forceData, includeEnergy ? &energy : NULL, &energyParamDerivValues[0]);
map<string, double>& energyParamDerivs = extractEnergyParameterDerivatives(context); map<string, double>& energyParamDerivs = extractEnergyParameterDerivatives(context);
for (int i = 0; i < energyParamDerivNames.size(); i++) for (int i = 0; i < energyParamDerivNames.size(); i++)
energyParamDerivs[energyParamDerivNames[i]] += energyParamDerivValues[i]; energyParamDerivs[energyParamDerivNames[i]] += energyParamDerivValues[i];
...@@ -1368,7 +1295,6 @@ void ReferenceCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& conte ...@@ -1368,7 +1295,6 @@ void ReferenceCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& conte
} }
ReferenceCalcCustomGBForceKernel::~ReferenceCalcCustomGBForceKernel() { ReferenceCalcCustomGBForceKernel::~ReferenceCalcCustomGBForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (neighborList != NULL) if (neighborList != NULL)
delete neighborList; delete neighborList;
} }
...@@ -1401,13 +1327,9 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu ...@@ -1401,13 +1327,9 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu
// Build the arrays. // Build the arrays.
int numPerParticleParameters = force.getNumPerParticleParameters(); int numPerParticleParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numPerParticleParameters); particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i)
vector<double> parameters; force.getParticleParameters(i, particleParamArray[i]);
force.getParticleParameters(i, parameters);
for (int j = 0; j < numPerParticleParameters; j++)
particleParamArray[i][j] = parameters[j];
}
for (int i = 0; i < numPerParticleParameters; i++) for (int i = 0; i < numPerParticleParameters; i++)
particleParameterNames.push_back(force.getPerParticleParameterName(i)); particleParameterNames.push_back(force.getPerParticleParameterName(i));
for (int i = 0; i < force.getNumGlobalParameters(); i++) for (int i = 0; i < force.getNumGlobalParameters(); i++)
...@@ -1593,10 +1515,6 @@ Lepton::CustomFunction* ReferenceCalcCustomExternalForceKernel::PeriodicDistance ...@@ -1593,10 +1515,6 @@ Lepton::CustomFunction* ReferenceCalcCustomExternalForceKernel::PeriodicDistance
return new PeriodicDistanceFunction(boxVectorHandle); return new PeriodicDistanceFunction(boxVectorHandle);
} }
ReferenceCalcCustomExternalForceKernel::~ReferenceCalcCustomExternalForceKernel() {
disposeRealArray(particleParamArray, numParticles);
}
void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, const CustomExternalForce& force) { void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, const CustomExternalForce& force) {
numParticles = force.getNumParticles(); numParticles = force.getNumParticles();
int numParameters = force.getNumPerParticleParameters(); int numParameters = force.getNumPerParticleParameters();
...@@ -1604,13 +1522,9 @@ void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, co ...@@ -1604,13 +1522,9 @@ void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, co
// Build the arrays. // Build the arrays.
particles.resize(numParticles); particles.resize(numParticles);
particleParamArray = allocateRealArray(numParticles, numParameters); particleParamArray.resize(numParticles);
vector<double> params; for (int i = 0; i < numParticles; ++i)
for (int i = 0; i < numParticles; ++i) { force.getParticleParameters(i, particles[i], particleParamArray[i]);
force.getParticleParameters(i, particles[i], params);
for (int j = 0; j < numParameters; j++)
particleParamArray[i][j] = params[j];
}
// Parse the expression used to calculate the force. // Parse the expression used to calculate the force.
...@@ -1669,8 +1583,6 @@ void ReferenceCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl ...@@ -1669,8 +1583,6 @@ void ReferenceCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl
} }
ReferenceCalcCustomHbondForceKernel::~ReferenceCalcCustomHbondForceKernel() { ReferenceCalcCustomHbondForceKernel::~ReferenceCalcCustomHbondForceKernel() {
disposeRealArray(donorParamArray, numDonors);
disposeRealArray(acceptorParamArray, numAcceptors);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1693,29 +1605,23 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const ...@@ -1693,29 +1605,23 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const
vector<vector<int> > donorParticles(numDonors); vector<vector<int> > donorParticles(numDonors);
int numDonorParameters = force.getNumPerDonorParameters(); int numDonorParameters = force.getNumPerDonorParameters();
donorParamArray = allocateRealArray(numDonors, numDonorParameters); donorParamArray.resize(numDonors);
for (int i = 0; i < numDonors; ++i) { for (int i = 0; i < numDonors; ++i) {
vector<double> parameters;
int d1, d2, d3; int d1, d2, d3;
force.getDonorParameters(i, d1, d2, d3, parameters); force.getDonorParameters(i, d1, d2, d3, donorParamArray[i]);
donorParticles[i].push_back(d1); donorParticles[i].push_back(d1);
donorParticles[i].push_back(d2); donorParticles[i].push_back(d2);
donorParticles[i].push_back(d3); donorParticles[i].push_back(d3);
for (int j = 0; j < numDonorParameters; j++)
donorParamArray[i][j] = parameters[j];
} }
vector<vector<int> > acceptorParticles(numAcceptors); vector<vector<int> > acceptorParticles(numAcceptors);
int numAcceptorParameters = force.getNumPerAcceptorParameters(); int numAcceptorParameters = force.getNumPerAcceptorParameters();
acceptorParamArray = allocateRealArray(numAcceptors, numAcceptorParameters); acceptorParamArray.resize(numAcceptors);
for (int i = 0; i < numAcceptors; ++i) { for (int i = 0; i < numAcceptors; ++i) {
vector<double> parameters;
int a1, a2, a3; int a1, a2, a3;
force.getAcceptorParameters(i, a1, a2, a3, parameters); force.getAcceptorParameters(i, a1, a2, a3, acceptorParamArray[i]);
acceptorParticles[i].push_back(a1); acceptorParticles[i].push_back(a1);
acceptorParticles[i].push_back(a2); acceptorParticles[i].push_back(a2);
acceptorParticles[i].push_back(a3); acceptorParticles[i].push_back(a3);
for (int j = 0; j < numAcceptorParameters; j++)
acceptorParamArray[i][j] = parameters[j];
} }
NonbondedMethod nonbondedMethod = CalcCustomHbondForceKernel::NonbondedMethod(force.getNonbondedMethod()); NonbondedMethod nonbondedMethod = CalcCustomHbondForceKernel::NonbondedMethod(force.getNonbondedMethod());
nonbondedCutoff = force.getCutoffDistance(); nonbondedCutoff = force.getCutoffDistance();
...@@ -1796,7 +1702,6 @@ void ReferenceCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& c ...@@ -1796,7 +1702,6 @@ void ReferenceCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& c
} }
ReferenceCalcCustomCentroidBondForceKernel::~ReferenceCalcCustomCentroidBondForceKernel() { ReferenceCalcCustomCentroidBondForceKernel::~ReferenceCalcCustomCentroidBondForceKernel() {
disposeRealArray(bondParamArray, numBonds);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1816,13 +1721,9 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system ...@@ -1816,13 +1721,9 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
vector<vector<int> > bondGroups(numBonds); vector<vector<int> > bondGroups(numBonds);
int numBondParameters = force.getNumPerBondParameters(); int numBondParameters = force.getNumPerBondParameters();
bondParamArray = allocateRealArray(numBonds, numBondParameters); bondParamArray.resize(numBonds);
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i)
vector<double> parameters; force.getBondParameters(i, bondGroups[i], bondParamArray[i]);
force.getBondParameters(i, bondGroups[i], parameters);
for (int j = 0; j < numBondParameters; j++)
bondParamArray[i][j] = parameters[j];
}
// Create custom functions for the tabulated functions. // Create custom functions for the tabulated functions.
...@@ -1893,7 +1794,6 @@ void ReferenceCalcCustomCentroidBondForceKernel::copyParametersToContext(Context ...@@ -1893,7 +1794,6 @@ void ReferenceCalcCustomCentroidBondForceKernel::copyParametersToContext(Context
} }
ReferenceCalcCustomCompoundBondForceKernel::~ReferenceCalcCustomCompoundBondForceKernel() { ReferenceCalcCustomCompoundBondForceKernel::~ReferenceCalcCustomCompoundBondForceKernel() {
disposeRealArray(bondParamArray, numBonds);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1906,13 +1806,9 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system ...@@ -1906,13 +1806,9 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
vector<vector<int> > bondParticles(numBonds); vector<vector<int> > bondParticles(numBonds);
int numBondParameters = force.getNumPerBondParameters(); int numBondParameters = force.getNumPerBondParameters();
bondParamArray = allocateRealArray(numBonds, numBondParameters); bondParamArray.resize(numBonds);
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i)
vector<double> parameters; force.getBondParameters(i, bondParticles[i], bondParamArray[i]);
force.getBondParameters(i, bondParticles[i], parameters);
for (int j = 0; j < numBondParameters; j++)
bondParamArray[i][j] = parameters[j];
}
// Create custom functions for the tabulated functions. // Create custom functions for the tabulated functions.
...@@ -1983,7 +1879,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context ...@@ -1983,7 +1879,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context
} }
ReferenceCalcCustomManyParticleForceKernel::~ReferenceCalcCustomManyParticleForceKernel() { ReferenceCalcCustomManyParticleForceKernel::~ReferenceCalcCustomManyParticleForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1994,13 +1889,10 @@ void ReferenceCalcCustomManyParticleForceKernel::initialize(const System& system ...@@ -1994,13 +1889,10 @@ void ReferenceCalcCustomManyParticleForceKernel::initialize(const System& system
numParticles = system.getNumParticles(); numParticles = system.getNumParticles();
int numParticleParameters = force.getNumPerParticleParameters(); int numParticleParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numParticleParameters); particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i) {
vector<double> parameters;
int type; int type;
force.getParticleParameters(i, parameters, type); force.getParticleParameters(i, particleParamArray[i], type);
for (int j = 0; j < numParticleParameters; j++)
particleParamArray[i][j] = parameters[j];
} }
for (int i = 0; i < force.getNumGlobalParameters(); i++) for (int i = 0; i < force.getNumGlobalParameters(); i++)
globalParameterNames.push_back(force.getGlobalParameterName(i)); globalParameterNames.push_back(force.getGlobalParameterName(i));
......
...@@ -69,7 +69,7 @@ void ReferenceAngleBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -69,7 +69,7 @@ void ReferenceAngleBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double* angleParameters, void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, vector<double>& angleParameters,
double* dEdR, double* energyTerm) const { double* dEdR, double* energyTerm) const {
double angle; double angle;
...@@ -101,9 +101,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double* ...@@ -101,9 +101,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double*
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::calculateBondIxn(int* atomIndices, void ReferenceAngleBondIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
......
...@@ -64,9 +64,9 @@ ReferenceBondForce::~ReferenceBondForce() { ...@@ -64,9 +64,9 @@ ReferenceBondForce::~ReferenceBondForce() {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceBondForce::calculateForce(int numberOfBonds, int** atomIndices, void ReferenceBondForce::calculateForce(int numberOfBonds, vector<vector<int> >& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double** parameters, vector<vector<double> >& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double *totalEnergy, double *totalEnergy,
ReferenceBondIxn& referenceBondIxn) { ReferenceBondIxn& referenceBondIxn) {
......
...@@ -62,8 +62,8 @@ ReferenceBondIxn::~ReferenceBondIxn() { ...@@ -62,8 +62,8 @@ ReferenceBondIxn::~ReferenceBondIxn() {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceBondIxn::calculateBondIxn(int* atomIndices, vector<Vec3>& atomCoordinates, void ReferenceBondIxn::calculateBondIxn(vector<int>& atomIndices, vector<Vec3>& atomCoordinates,
double* parameters, vector<Vec3>& forces, vector<double>& parameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
} }
......
...@@ -206,6 +206,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<Vec3>& atomCoord ...@@ -206,6 +206,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<Vec3>& atomCoord
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCMAPTorsionIxn::calculateBondIxn(int* atomIndices, vector<Vec3>& atomCoordinates, void ReferenceCMAPTorsionIxn::calculateBondIxn(vector<int>& atomIndices, vector<Vec3>& atomCoordinates,
double* parameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) { vector<double>& parameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) {
} }
...@@ -81,9 +81,9 @@ void ReferenceCustomAngleIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -81,9 +81,9 @@ void ReferenceCustomAngleIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomAngleIxn::calculateBondIxn(int* atomIndices, void ReferenceCustomAngleIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[2][ReferenceForce::LastDeltaRIndex]; double deltaR[2][ReferenceForce::LastDeltaRIndex];
......
...@@ -82,9 +82,9 @@ void ReferenceCustomBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -82,9 +82,9 @@ void ReferenceCustomBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomBondIxn::calculateBondIxn(int* atomIndices, void ReferenceCustomBondIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[ReferenceForce::LastDeltaRIndex]; double deltaR[ReferenceForce::LastDeltaRIndex];
......
/* Portions copyright (c) 2009-2016 Stanford University and Simbios. /* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -93,7 +93,7 @@ void ReferenceCustomCentroidBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -93,7 +93,7 @@ void ReferenceCustomCentroidBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
boxVectors[2] = vectors[2]; boxVectors[2] = vectors[2];
} }
void ReferenceCustomCentroidBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, double** bondParameters, void ReferenceCustomCentroidBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& bondParameters,
const map<string, double>& globalParameters, vector<Vec3>& forces, const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
......
...@@ -116,7 +116,7 @@ void ReferenceCustomCompoundBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -116,7 +116,7 @@ void ReferenceCustomCompoundBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, double** bondParameters, void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& bondParameters,
const map<string, double>& globalParameters, vector<Vec3>& forces, const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
for (auto& param : globalParameters) for (auto& param : globalParameters)
......
/* Portions copyright (c) 2009-2013 Stanford University and Simbios. /* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -94,7 +94,7 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn() { ...@@ -94,7 +94,7 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn() {
void ReferenceCustomExternalIxn::calculateForce(int atomIndex, void ReferenceCustomExternalIxn::calculateForce(int atomIndex,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* energy) const { double* energy) const {
......
/* Portions copyright (c) 2009-2016 Stanford University and Simbios. /* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -150,7 +150,7 @@ ReferenceCustomGBIxn::~ReferenceCustomGBIxn() { ...@@ -150,7 +150,7 @@ ReferenceCustomGBIxn::~ReferenceCustomGBIxn() {
periodicBoxVectors[2] = vectors[2]; periodicBoxVectors[2] = vectors[2];
} }
void ReferenceCustomGBIxn::calculateIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates, double** atomParameters, void ReferenceCustomGBIxn::calculateIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters,
const vector<set<int> >& exclusions, map<string, double>& globalParameters, vector<Vec3>& forces, const vector<set<int> >& exclusions, map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
for (auto& param : globalParameters) for (auto& param : globalParameters)
...@@ -193,7 +193,7 @@ void ReferenceCustomGBIxn::calculateIxn(int numberOfAtoms, vector<Vec3>& atomCoo ...@@ -193,7 +193,7 @@ void ReferenceCustomGBIxn::calculateIxn(int numberOfAtoms, vector<Vec3>& atomCoo
calculateChainRuleForces(numberOfAtoms, atomCoordinates, atomParameters, exclusions, forces, energyParamDerivs); calculateChainRuleForces(numberOfAtoms, atomCoordinates, atomParameters, exclusions, forces, energyParamDerivs);
} }
void ReferenceCustomGBIxn::calculateSingleParticleValue(int index, int numAtoms, vector<Vec3>& atomCoordinates, double** atomParameters) { void ReferenceCustomGBIxn::calculateSingleParticleValue(int index, int numAtoms, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters) {
values[index].resize(numAtoms); values[index].resize(numAtoms);
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numAtoms; i++) {
expressionSet.setVariable(xIndex, atomCoordinates[i][0]); expressionSet.setVariable(xIndex, atomCoordinates[i][0]);
...@@ -217,7 +217,7 @@ void ReferenceCustomGBIxn::calculateSingleParticleValue(int index, int numAtoms, ...@@ -217,7 +217,7 @@ void ReferenceCustomGBIxn::calculateSingleParticleValue(int index, int numAtoms,
} }
} }
void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, vector<Vec3>& atomCoordinates, double** atomParameters, void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters,
const vector<set<int> >& exclusions, bool useExclusions) { const vector<set<int> >& exclusions, bool useExclusions) {
values[index].resize(numAtoms); values[index].resize(numAtoms);
for (int i = 0; i < numAtoms; i++) for (int i = 0; i < numAtoms; i++)
...@@ -246,7 +246,7 @@ void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, v ...@@ -246,7 +246,7 @@ void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, v
} }
} }
void ReferenceCustomGBIxn::calculateOnePairValue(int index, int atom1, int atom2, vector<Vec3>& atomCoordinates, double** atomParameters) { void ReferenceCustomGBIxn::calculateOnePairValue(int index, int atom1, int atom2, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters) {
double deltaR[ReferenceForce::LastDeltaRIndex]; double deltaR[ReferenceForce::LastDeltaRIndex];
if (periodic) if (periodic)
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atom2], atomCoordinates[atom1], periodicBoxVectors, deltaR); ReferenceForce::getDeltaRPeriodic(atomCoordinates[atom2], atomCoordinates[atom1], periodicBoxVectors, deltaR);
...@@ -273,7 +273,7 @@ void ReferenceCustomGBIxn::calculateOnePairValue(int index, int atom1, int atom2 ...@@ -273,7 +273,7 @@ void ReferenceCustomGBIxn::calculateOnePairValue(int index, int atom1, int atom2
} }
void ReferenceCustomGBIxn::calculateSingleParticleEnergyTerm(int index, int numAtoms, vector<Vec3>& atomCoordinates, void ReferenceCustomGBIxn::calculateSingleParticleEnergyTerm(int index, int numAtoms, vector<Vec3>& atomCoordinates,
double** atomParameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) { vector<vector<double> >& atomParameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) {
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numAtoms; i++) {
expressionSet.setVariable(xIndex, atomCoordinates[i][0]); expressionSet.setVariable(xIndex, atomCoordinates[i][0]);
expressionSet.setVariable(yIndex, atomCoordinates[i][1]); expressionSet.setVariable(yIndex, atomCoordinates[i][1]);
...@@ -300,7 +300,7 @@ void ReferenceCustomGBIxn::calculateSingleParticleEnergyTerm(int index, int numA ...@@ -300,7 +300,7 @@ void ReferenceCustomGBIxn::calculateSingleParticleEnergyTerm(int index, int numA
} }
} }
void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAtoms, vector<Vec3>& atomCoordinates, double** atomParameters, void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAtoms, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters,
const vector<set<int> >& exclusions, bool useExclusions, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) { const vector<set<int> >& exclusions, bool useExclusions, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) {
if (cutoff) { if (cutoff) {
// Loop over all pairs in the neighbor list. // Loop over all pairs in the neighbor list.
...@@ -324,7 +324,7 @@ void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAto ...@@ -324,7 +324,7 @@ void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAto
} }
} }
void ReferenceCustomGBIxn::calculateOnePairEnergyTerm(int index, int atom1, int atom2, vector<Vec3>& atomCoordinates, double** atomParameters, void ReferenceCustomGBIxn::calculateOnePairEnergyTerm(int index, int atom1, int atom2, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters,
vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) { vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) {
// Compute the displacement. // Compute the displacement.
...@@ -370,7 +370,7 @@ void ReferenceCustomGBIxn::calculateOnePairEnergyTerm(int index, int atom1, int ...@@ -370,7 +370,7 @@ void ReferenceCustomGBIxn::calculateOnePairEnergyTerm(int index, int atom1, int
energyParamDerivs[i] += energyParamDerivExpressions[index][i].evaluate(); energyParamDerivs[i] += energyParamDerivExpressions[index][i].evaluate();
} }
void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<Vec3>& atomCoordinates, double** atomParameters, void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters,
const vector<set<int> >& exclusions, vector<Vec3>& forces, double* energyParamDerivs) { const vector<set<int> >& exclusions, vector<Vec3>& forces, double* energyParamDerivs) {
if (cutoff) { if (cutoff) {
// Loop over all pairs in the neighbor list. // Loop over all pairs in the neighbor list.
...@@ -429,7 +429,7 @@ void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<Vec3>& ...@@ -429,7 +429,7 @@ void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<Vec3>&
energyParamDerivs[k] += dEdV[j][i]*dValuedParam[j][k][i]; energyParamDerivs[k] += dEdV[j][i]*dValuedParam[j][k][i];
} }
void ReferenceCustomGBIxn::calculateOnePairChainRule(int atom1, int atom2, vector<Vec3>& atomCoordinates, double** atomParameters, void ReferenceCustomGBIxn::calculateOnePairChainRule(int atom1, int atom2, vector<Vec3>& atomCoordinates, vector<vector<double> >& atomParameters,
vector<Vec3>& forces, bool isExcluded) { vector<Vec3>& forces, bool isExcluded) {
// Compute the displacement. // Compute the displacement.
......
...@@ -116,7 +116,7 @@ void ReferenceCustomHbondIxn::setPeriodic(Vec3* vectors) { ...@@ -116,7 +116,7 @@ void ReferenceCustomHbondIxn::setPeriodic(Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomHbondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, double** donorParameters, double** acceptorParameters, void ReferenceCustomHbondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& donorParameters, vector<vector<double> >& acceptorParameters,
vector<set<int> >& exclusions, const map<string, double>& globalParameters, vector<Vec3>& forces, vector<set<int> >& exclusions, const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy) const { double* totalEnergy) const {
......
/* Portions copyright (c) 2009-2014 Stanford University and Simbios. /* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -105,7 +105,7 @@ ReferenceCustomManyParticleIxn::ReferenceCustomManyParticleIxn(const CustomManyP ...@@ -105,7 +105,7 @@ ReferenceCustomManyParticleIxn::ReferenceCustomManyParticleIxn(const CustomManyP
ReferenceCustomManyParticleIxn::~ReferenceCustomManyParticleIxn() { ReferenceCustomManyParticleIxn::~ReferenceCustomManyParticleIxn() {
} }
void ReferenceCustomManyParticleIxn::calculateIxn(vector<Vec3>& atomCoordinates, double** particleParameters, void ReferenceCustomManyParticleIxn::calculateIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& particleParameters,
const map<string, double>& globalParameters, vector<Vec3>& forces, const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy) const { double* totalEnergy) const {
map<string, double> variables = globalParameters; map<string, double> variables = globalParameters;
...@@ -130,7 +130,7 @@ void ReferenceCustomManyParticleIxn::setPeriodic(Vec3* vectors) { ...@@ -130,7 +130,7 @@ void ReferenceCustomManyParticleIxn::setPeriodic(Vec3* vectors) {
} }
void ReferenceCustomManyParticleIxn::loopOverInteractions(vector<int>& particles, int loopIndex, vector<OpenMM::Vec3>& atomCoordinates, void ReferenceCustomManyParticleIxn::loopOverInteractions(vector<int>& particles, int loopIndex, vector<OpenMM::Vec3>& atomCoordinates,
double** particleParameters, map<string, double>& variables, vector<OpenMM::Vec3>& forces, vector<vector<double> >& particleParameters, map<string, double>& variables, vector<OpenMM::Vec3>& forces,
double* totalEnergy) const { double* totalEnergy) const {
int numParticles = atomCoordinates.size(); int numParticles = atomCoordinates.size();
int firstPartialLoop = (centralParticleMode ? 2 : 1); int firstPartialLoop = (centralParticleMode ? 2 : 1);
...@@ -147,7 +147,7 @@ void ReferenceCustomManyParticleIxn::loopOverInteractions(vector<int>& particles ...@@ -147,7 +147,7 @@ void ReferenceCustomManyParticleIxn::loopOverInteractions(vector<int>& particles
} }
void ReferenceCustomManyParticleIxn::calculateOneIxn(const vector<int>& particles, vector<Vec3>& atomCoordinates, void ReferenceCustomManyParticleIxn::calculateOneIxn(const vector<int>& particles, vector<Vec3>& atomCoordinates,
double** particleParameters, map<string, double>& variables, vector<Vec3>& forces, double* totalEnergy) const { vector<vector<double> >& particleParameters, map<string, double>& variables, vector<Vec3>& forces, double* totalEnergy) const {
// Select the ordering to use for the particles. // Select the ordering to use for the particles.
vector<int> permutedParticles(numParticlesPerSet); vector<int> permutedParticles(numParticlesPerSet);
......
/* Portions copyright (c) 2009-2016 Stanford University and Simbios. /* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -146,18 +146,16 @@ void ReferenceCustomNonbondedIxn::setUseSwitchingFunction(double distance) { ...@@ -146,18 +146,16 @@ void ReferenceCustomNonbondedIxn::setUseSwitchingFunction(double distance) {
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex] @param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices @param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param globalParameters the values of global parameters @param globalParameters the values of global parameters
@param forces force array (forces added) @param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy @param totalEnergy total energy
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates, void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates,
double** atomParameters, vector<set<int> >& exclusions, vector<vector<double> >& atomParameters, vector<set<int> >& exclusions,
double* fixedParameters, const map<string, double>& globalParameters, vector<Vec3>& forces, const map<string, double>& globalParameters, vector<Vec3>& forces,
double* energyByAtom, double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
for (auto& param : globalParameters) for (auto& param : globalParameters)
expressionSet.setVariable(expressionSet.getVariableIndex(param.first), param.second); expressionSet.setVariable(expressionSet.getVariableIndex(param.first), param.second);
...@@ -177,7 +175,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec ...@@ -177,7 +175,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
expressionSet.setVariable(particleParamIndex[j*2], atomParameters[*atom1][j]); expressionSet.setVariable(particleParamIndex[j*2], atomParameters[*atom1][j]);
expressionSet.setVariable(particleParamIndex[j*2+1], atomParameters[*atom2][j]); expressionSet.setVariable(particleParamIndex[j*2+1], atomParameters[*atom2][j]);
} }
calculateOneIxn(*atom1, *atom2, atomCoordinates, forces, energyByAtom, totalEnergy, energyParamDerivs); calculateOneIxn(*atom1, *atom2, atomCoordinates, forces, totalEnergy, energyParamDerivs);
} }
} }
} }
...@@ -190,7 +188,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec ...@@ -190,7 +188,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
expressionSet.setVariable(particleParamIndex[j*2], atomParameters[pair.first][j]); expressionSet.setVariable(particleParamIndex[j*2], atomParameters[pair.first][j]);
expressionSet.setVariable(particleParamIndex[j*2+1], atomParameters[pair.second][j]); expressionSet.setVariable(particleParamIndex[j*2+1], atomParameters[pair.second][j]);
} }
calculateOneIxn(pair.first, pair.second, atomCoordinates, forces, energyByAtom, totalEnergy, energyParamDerivs); calculateOneIxn(pair.first, pair.second, atomCoordinates, forces, totalEnergy, energyParamDerivs);
} }
} }
else { else {
...@@ -203,7 +201,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec ...@@ -203,7 +201,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
expressionSet.setVariable(particleParamIndex[j*2], atomParameters[ii][j]); expressionSet.setVariable(particleParamIndex[j*2], atomParameters[ii][j]);
expressionSet.setVariable(particleParamIndex[j*2+1], atomParameters[jj][j]); expressionSet.setVariable(particleParamIndex[j*2+1], atomParameters[jj][j]);
} }
calculateOneIxn(ii, jj, atomCoordinates, forces, energyByAtom, totalEnergy, energyParamDerivs); calculateOneIxn(ii, jj, atomCoordinates, forces, totalEnergy, energyParamDerivs);
} }
} }
} }
...@@ -217,15 +215,13 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec ...@@ -217,15 +215,13 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
@param ii the index of the first atom @param ii the index of the first atom
@param jj the index of the second atom @param jj the index of the second atom
@param atomCoordinates atom coordinates @param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param forces force array (forces added) @param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy @param totalEnergy total energy
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomNonbondedIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& atomCoordinates, vector<Vec3>& forces, void ReferenceCustomNonbondedIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& atomCoordinates, vector<Vec3>& forces,
double* energyByAtom, double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
// get deltaR, R2, and R between 2 atoms // get deltaR, R2, and R between 2 atoms
double deltaR[ReferenceForce::LastDeltaRIndex]; double deltaR[ReferenceForce::LastDeltaRIndex];
...@@ -262,14 +258,8 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& ...@@ -262,14 +258,8 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn(int ii, int jj, vector<Vec3>&
// accumulate energies // accumulate energies
if (totalEnergy || energyByAtom) {
if (totalEnergy) if (totalEnergy)
*totalEnergy += energy; *totalEnergy += energy;
if (energyByAtom) {
energyByAtom[ii] += energy;
energyByAtom[jj] += energy;
}
}
} }
...@@ -81,9 +81,9 @@ void ReferenceCustomTorsionIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -81,9 +81,9 @@ void ReferenceCustomTorsionIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomTorsionIxn::calculateBondIxn(int* atomIndices, void ReferenceCustomTorsionIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[3][ReferenceForce::LastDeltaRIndex]; double deltaR[3][ReferenceForce::LastDeltaRIndex];
......
...@@ -70,9 +70,9 @@ void ReferenceHarmonicBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -70,9 +70,9 @@ void ReferenceHarmonicBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceHarmonicBondIxn::calculateBondIxn(int* atomIndices, void ReferenceHarmonicBondIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[ReferenceForce::LastDeltaRIndex]; double deltaR[ReferenceForce::LastDeltaRIndex];
......
...@@ -65,8 +65,8 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14() { ...@@ -65,8 +65,8 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14() {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceLJCoulomb14::calculateBondIxn(int* atomIndices, vector<Vec3>& atomCoordinates, void ReferenceLJCoulomb14::calculateBondIxn(vector<int>& atomIndices, vector<Vec3>& atomCoordinates,
double* parameters, vector<Vec3>& forces, vector<double>& parameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[2][ReferenceForce::LastDeltaRIndex]; double deltaR[2][ReferenceForce::LastDeltaRIndex];
......
/* Portions copyright (c) 2006-2013 Stanford University and Simbios. /* Portions copyright (c) 2006-2018 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -176,9 +176,7 @@ void ReferenceLJCoulombIxn::setUseLJPME(double alpha, int meshSize[3]) { ...@@ -176,9 +176,7 @@ void ReferenceLJCoulombIxn::setUseLJPME(double alpha, int meshSize[3]) {
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex] @param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices @param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added) @param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy @param totalEnergy total energy
@param includeDirect true if direct space interactions should be included @param includeDirect true if direct space interactions should be included
@param includeReciprocal true if reciprocal space interactions should be included @param includeReciprocal true if reciprocal space interactions should be included
...@@ -186,9 +184,8 @@ void ReferenceLJCoulombIxn::setUseLJPME(double alpha, int meshSize[3]) { ...@@ -186,9 +184,8 @@ void ReferenceLJCoulombIxn::setUseLJPME(double alpha, int meshSize[3]) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates, void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates,
double** atomParameters, vector<set<int> >& exclusions, vector<vector<double> >& atomParameters, vector<set<int> >& exclusions,
double* fixedParameters, vector<Vec3>& forces, vector<Vec3>& forces, double* totalEnergy, bool includeDirect, bool includeReciprocal) const {
double* energyByAtom, double* totalEnergy, bool includeDirect, bool includeReciprocal) const {
typedef std::complex<double> d_complex; typedef std::complex<double> d_complex;
static const double epsilon = 1.0; static const double epsilon = 1.0;
...@@ -224,9 +221,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -224,9 +221,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
selfEwaldEnergy -= pow(alphaDispersionEwald, 6.0) * 64.0*pow(atomParameters[atomID][SigIndex], 6.0) * pow(atomParameters[atomID][EpsIndex], 2.0) / 12.0; selfEwaldEnergy -= pow(alphaDispersionEwald, 6.0) * 64.0*pow(atomParameters[atomID][SigIndex], 6.0) * pow(atomParameters[atomID][EpsIndex], 2.0) / 12.0;
} }
totalSelfEwaldEnergy -= selfEwaldEnergy; totalSelfEwaldEnergy -= selfEwaldEnergy;
if (energyByAtom) {
energyByAtom[atomID] -= selfEwaldEnergy;
}
} }
} }
...@@ -252,10 +246,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -252,10 +246,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
if (totalEnergy) if (totalEnergy)
*totalEnergy += recipEnergy; *totalEnergy += recipEnergy;
if (energyByAtom)
for (int n = 0; n < numberOfAtoms; n++)
energyByAtom[n] += recipEnergy;
pme_destroy(pmedata); pme_destroy(pmedata);
if (ljpme) { if (ljpme) {
...@@ -275,10 +265,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -275,10 +265,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
} }
if (totalEnergy) if (totalEnergy)
*totalEnergy += recipDispersionEnergy; *totalEnergy += recipDispersionEnergy;
if (energyByAtom)
for (int n = 0; n < numberOfAtoms; n++)
energyByAtom[n] += recipDispersionEnergy;
pme_destroy(pmedata); pme_destroy(pmedata);
} }
} }
...@@ -374,10 +360,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -374,10 +360,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
if (totalEnergy) if (totalEnergy)
*totalEnergy += recipEnergy; *totalEnergy += recipEnergy;
if (energyByAtom)
for (int n = 0; n < numberOfAtoms; n++)
energyByAtom[n] += recipEnergy;
lowrz = 1 - numRz; lowrz = 1 - numRz;
} }
lowry = 1 - numRy; lowry = 1 - numRy;
...@@ -473,11 +455,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -473,11 +455,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
totalVdwEnergy += vdwEnergy; totalVdwEnergy += vdwEnergy;
totalRealSpaceEwaldEnergy += realSpaceEwaldEnergy; totalRealSpaceEwaldEnergy += realSpaceEwaldEnergy;
if (energyByAtom) {
energyByAtom[ii] += realSpaceEwaldEnergy + vdwEnergy;
energyByAtom[jj] += realSpaceEwaldEnergy + vdwEnergy;
}
} }
if (totalEnergy) if (totalEnergy)
...@@ -537,10 +514,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -537,10 +514,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
} }
totalExclusionEnergy += realSpaceEwaldEnergy; totalExclusionEnergy += realSpaceEwaldEnergy;
if (energyByAtom) {
energyByAtom[ii] -= realSpaceEwaldEnergy;
energyByAtom[jj] -= realSpaceEwaldEnergy;
}
} }
} }
...@@ -558,9 +531,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -558,9 +531,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex] @param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices @param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added) @param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy @param totalEnergy total energy
@param includeDirect true if direct space interactions should be included @param includeDirect true if direct space interactions should be included
@param includeReciprocal true if reciprocal space interactions should be included @param includeReciprocal true if reciprocal space interactions should be included
...@@ -568,12 +539,11 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a ...@@ -568,12 +539,11 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates, void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& atomCoordinates,
double** atomParameters, vector<set<int> >& exclusions, vector<vector<double> >& atomParameters, vector<set<int> >& exclusions,
double* fixedParameters, vector<Vec3>& forces, vector<Vec3>& forces, double* totalEnergy, bool includeDirect, bool includeReciprocal) const {
double* energyByAtom, double* totalEnergy, bool includeDirect, bool includeReciprocal) const {
if (ewald || pme || ljpme) { if (ewald || pme || ljpme) {
calculateEwaldIxn(numberOfAtoms, atomCoordinates, atomParameters, exclusions, fixedParameters, forces, energyByAtom, calculateEwaldIxn(numberOfAtoms, atomCoordinates, atomParameters, exclusions, forces,
totalEnergy, includeDirect, includeReciprocal); totalEnergy, includeDirect, includeReciprocal);
return; return;
} }
...@@ -581,7 +551,7 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at ...@@ -581,7 +551,7 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at
return; return;
if (cutoff) { if (cutoff) {
for (auto& pair : *neighborList) for (auto& pair : *neighborList)
calculateOneIxn(pair.first, pair.second, atomCoordinates, atomParameters, forces, energyByAtom, totalEnergy); calculateOneIxn(pair.first, pair.second, atomCoordinates, atomParameters, forces, totalEnergy);
} }
else { else {
for (int ii = 0; ii < numberOfAtoms; ii++) { for (int ii = 0; ii < numberOfAtoms; ii++) {
...@@ -589,7 +559,7 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at ...@@ -589,7 +559,7 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at
for (int jj = ii+1; jj < numberOfAtoms; jj++) for (int jj = ii+1; jj < numberOfAtoms; jj++)
if (exclusions[jj].find(ii) == exclusions[jj].end()) if (exclusions[jj].find(ii) == exclusions[jj].end())
calculateOneIxn(ii, jj, atomCoordinates, atomParameters, forces, energyByAtom, totalEnergy); calculateOneIxn(ii, jj, atomCoordinates, atomParameters, forces, totalEnergy);
} }
} }
} }
...@@ -603,14 +573,13 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at ...@@ -603,14 +573,13 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at
@param atomCoordinates atom coordinates @param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex] @param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param forces force array (forces added) @param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy @param totalEnergy total energy
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceLJCoulombIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& atomCoordinates, void ReferenceLJCoulombIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& atomCoordinates,
double** atomParameters, vector<Vec3>& forces, vector<vector<double> >& atomParameters, vector<Vec3>& forces,
double* energyByAtom, double* totalEnergy) const { double* totalEnergy) const {
double deltaR[2][ReferenceForce::LastDeltaRIndex]; double deltaR[2][ReferenceForce::LastDeltaRIndex];
// get deltaR, R2, and R between 2 atoms // get deltaR, R2, and R between 2 atoms
...@@ -665,9 +634,5 @@ void ReferenceLJCoulombIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& atomCo ...@@ -665,9 +634,5 @@ void ReferenceLJCoulombIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& atomCo
if (totalEnergy) if (totalEnergy)
*totalEnergy += energy; *totalEnergy += energy;
if (energyByAtom) {
energyByAtom[ii] += energy;
energyByAtom[jj] += energy;
}
} }
...@@ -71,9 +71,9 @@ void ReferenceProperDihedralBond::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -71,9 +71,9 @@ void ReferenceProperDihedralBond::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceProperDihedralBond::calculateBondIxn(int* atomIndices, void ReferenceProperDihedralBond::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[3][ReferenceForce::LastDeltaRIndex]; double deltaR[3][ReferenceForce::LastDeltaRIndex];
......
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