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
...@@ -1834,32 +1834,19 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb ...@@ -1834,32 +1834,19 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
sc += bsplines_data[j]*cos(arg); sc += bsplines_data[j]*cos(arg);
ss += bsplines_data[j]*sin(arg); ss += bsplines_data[j]*sin(arg);
} }
moduli[i] = (float) (sc*sc+ss*ss); moduli[i] = sc*sc+ss*ss;
} }
for (int i = 0; i < ndata; i++) for (int i = 0; i < ndata; i++)
{ {
if (moduli[i] < 1.0e-7) if (moduli[i] < 1.0e-7)
moduli[i] = (moduli[i-1]+moduli[i+1])*0.5f; moduli[i] = (moduli[i-1]+moduli[i+1])*0.5f;
} }
if (cl.getUseDoublePrecision()) { if (dim == 0)
if (dim == 0) xmoduli->upload(moduli, true, true);
xmoduli->upload(moduli); else if (dim == 1)
else if (dim == 1) ymoduli->upload(moduli, true, true);
ymoduli->upload(moduli); else
else zmoduli->upload(moduli, true, true);
zmoduli->upload(moduli);
}
else {
vector<float> modulif(ndata);
for (int i = 0; i < ndata; i++)
modulif[i] = (float) moduli[i];
if (dim == 0)
xmoduli->upload(modulif);
else if (dim == 1)
ymoduli->upload(modulif);
else
zmoduli->upload(modulif);
}
} }
} }
} }
...@@ -2153,14 +2140,7 @@ double OpenCLCalcNonbondedForceKernel::execute(ContextImpl& context, bool includ ...@@ -2153,14 +2140,7 @@ double OpenCLCalcNonbondedForceKernel::execute(ContextImpl& context, bool includ
} }
if (paramChanged) { if (paramChanged) {
recomputeParams = true; recomputeParams = true;
if (cl.getUseDoublePrecision()) globalParams.upload(paramValues, true, true);
globalParams.upload(paramValues);
else {
vector<float> v(paramValues.size());
for (int i = 0; i < v.size(); i++)
v[i] = paramValues[i];
globalParams.upload(v);
}
} }
double energy = (includeReciprocal ? ewaldSelfEnergy : 0.0); double energy = (includeReciprocal ? ewaldSelfEnergy : 0.0);
if (recomputeParams || hasOffsets) { if (recomputeParams || hasOffsets) {
...@@ -3133,14 +3113,7 @@ void OpenCLCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOB ...@@ -3133,14 +3113,7 @@ void OpenCLCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOB
chargeVec[i] = charge; chargeVec[i] = charge;
paramsVector[i] = mm_float2((float) radius, (float) (scalingFactor*radius)); paramsVector[i] = mm_float2((float) radius, (float) (scalingFactor*radius));
} }
if (cl.getUseDoublePrecision()) charges.upload(chargeVec, true, true);
charges.upload(chargeVec);
else {
vector<float> c(charges.getSize());
for (int i = 0; i < c.size(); i++)
c[i] = (float) chargeVec[i];
charges.upload(c);
}
params.upload(paramsVector); params.upload(paramsVector);
prefactor = -ONE_4PI_EPS0*((1.0/force.getSoluteDielectric())-(1.0/force.getSolventDielectric())); prefactor = -ONE_4PI_EPS0*((1.0/force.getSoluteDielectric())-(1.0/force.getSolventDielectric()));
surfaceAreaFactor = -6.0*4*M_PI*force.getSurfaceAreaEnergy(); surfaceAreaFactor = -6.0*4*M_PI*force.getSurfaceAreaEnergy();
...@@ -3307,14 +3280,7 @@ void OpenCLCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, ...@@ -3307,14 +3280,7 @@ void OpenCLCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context,
} }
for (int i = numParticles; i < cl.getPaddedNumAtoms(); i++) for (int i = numParticles; i < cl.getPaddedNumAtoms(); i++)
paramsVector[i] = mm_float2(1,1); paramsVector[i] = mm_float2(1,1);
if (cl.getUseDoublePrecision()) charges.upload(chargeVector, true, true);
charges.upload(chargeVector);
else {
vector<float> c(charges.getSize());
for (int i = 0; i < c.size(); i++)
c[i] = (float) chargeVector[i];
charges.upload(c);
}
params.upload(paramsVector); params.upload(paramsVector);
// Mark that the current reordering may be invalid. // Mark that the current reordering may be invalid.
...@@ -5162,8 +5128,7 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c ...@@ -5162,8 +5128,7 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
numGroups = force.getNumGroups(); numGroups = force.getNumGroups();
vector<cl_int> groupParticleVec; vector<cl_int> groupParticleVec;
vector<cl_float> groupWeightVecFloat; vector<cl_double> groupWeightVec;
vector<cl_double> groupWeightVecDouble;
vector<cl_int> groupOffsetVec; vector<cl_int> groupOffsetVec;
groupOffsetVec.push_back(0); groupOffsetVec.push_back(0);
for (int i = 0; i < numGroups; i++) { for (int i = 0; i < numGroups; i++) {
...@@ -5175,27 +5140,19 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c ...@@ -5175,27 +5140,19 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
} }
vector<vector<double> > normalizedWeights; vector<vector<double> > normalizedWeights;
CustomCentroidBondForceImpl::computeNormalizedWeights(force, system, normalizedWeights); CustomCentroidBondForceImpl::computeNormalizedWeights(force, system, normalizedWeights);
if (cl.getUseDoublePrecision()) { for (int i = 0; i < numGroups; i++)
for (int i = 0; i < numGroups; i++) groupWeightVec.insert(groupWeightVec.end(), normalizedWeights[i].begin(), normalizedWeights[i].end());
groupWeightVecDouble.insert(groupWeightVecDouble.end(), normalizedWeights[i].begin(), normalizedWeights[i].end());
}
else {
for (int i = 0; i < numGroups; i++)
for (int j = 0; j < normalizedWeights[i].size(); j++)
groupWeightVecFloat.push_back((float) normalizedWeights[i][j]);
}
groupParticles.initialize<int>(cl, groupParticleVec.size(), "groupParticles"); groupParticles.initialize<int>(cl, groupParticleVec.size(), "groupParticles");
groupParticles.upload(groupParticleVec); groupParticles.upload(groupParticleVec);
if (cl.getUseDoublePrecision()) { if (cl.getUseDoublePrecision()) {
groupWeights.initialize<double>(cl, groupParticleVec.size(), "groupWeights"); groupWeights.initialize<double>(cl, groupParticleVec.size(), "groupWeights");
groupWeights.upload(groupWeightVecDouble);
centerPositions.initialize<mm_double4>(cl, numGroups, "centerPositions"); centerPositions.initialize<mm_double4>(cl, numGroups, "centerPositions");
} }
else { else {
groupWeights.initialize<float>(cl, groupParticleVec.size(), "groupWeights"); groupWeights.initialize<float>(cl, groupParticleVec.size(), "groupWeights");
groupWeights.upload(groupWeightVecFloat);
centerPositions.initialize<mm_float4>(cl, numGroups, "centerPositions"); centerPositions.initialize<mm_float4>(cl, numGroups, "centerPositions");
} }
groupWeights.upload(groupWeightVec, true, true);
groupOffsets.initialize<int>(cl, groupOffsetVec.size(), "groupOffsets"); groupOffsets.initialize<int>(cl, groupOffsetVec.size(), "groupOffsets");
groupOffsets.upload(groupOffsetVec); groupOffsets.upload(groupOffsetVec);
groupForces.initialize<long long>(cl, numGroups*3, "groupForces"); groupForces.initialize<long long>(cl, numGroups*3, "groupForces");
...@@ -7122,18 +7079,10 @@ void OpenCLCalcRMSDForceKernel::recordParameters(const RMSDForce& force) { ...@@ -7122,18 +7079,10 @@ void OpenCLCalcRMSDForceKernel::recordParameters(const RMSDForce& force) {
// Upload them to the device. // Upload them to the device.
particles.upload(particleVec); particles.upload(particleVec);
if (cl.getUseDoublePrecision()) { vector<mm_double4> pos;
vector<mm_double4> pos; for (Vec3 p : centeredPositions)
for (Vec3 p : centeredPositions) pos.push_back(mm_double4(p[0], p[1], p[2], 0));
pos.push_back(mm_double4(p[0], p[1], p[2], 0)); referencePos.upload(pos, true, true);
referencePos.upload(pos);
}
else {
vector<mm_float4> pos;
for (Vec3 p : centeredPositions)
pos.push_back(mm_float4(p[0], p[1], p[2], 0));
referencePos.upload(pos);
}
// Record the sum of the norms of the reference positions. // Record the sum of the norms of the reference positions.
...@@ -7352,20 +7301,11 @@ void OpenCLIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang ...@@ -7352,20 +7301,11 @@ void OpenCLIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang
double vscale = exp(-stepSize*friction); double vscale = exp(-stepSize*friction);
double fscale = (friction == 0 ? stepSize : (1-vscale)/friction); double fscale = (friction == 0 ? stepSize : (1-vscale)/friction);
double noisescale = sqrt(kT*(1-vscale*vscale)); double noisescale = sqrt(kT*(1-vscale*vscale));
if (cl.getUseDoublePrecision() || cl.getUseMixedPrecision()) { vector<cl_double> p(params.getSize());
vector<cl_double> p(params.getSize()); p[0] = vscale;
p[0] = vscale; p[1] = fscale;
p[1] = fscale; p[2] = noisescale;
p[2] = noisescale; params.upload(p, true, true);
params.upload(p);
}
else {
vector<cl_float> p(params.getSize());
p[0] = (cl_float) vscale;
p[1] = (cl_float) fscale;
p[2] = (cl_float) noisescale;
params.upload(p);
}
prevTemp = temperature; prevTemp = temperature;
prevFriction = friction; prevFriction = friction;
prevStepSize = stepSize; prevStepSize = stepSize;
...@@ -7929,22 +7869,20 @@ void OpenCLIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context ...@@ -7929,22 +7869,20 @@ void OpenCLIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
// Allocate space for storing global values, both on the host and the device. // Allocate space for storing global values, both on the host and the device.
globalValuesFloat.resize(expressionSet.getNumVariables()); localGlobalValues.resize(expressionSet.getNumVariables());
globalValuesDouble.resize(expressionSet.getNumVariables());
int elementSize = (cl.getUseDoublePrecision() || cl.getUseMixedPrecision() ? sizeof(double) : sizeof(float)); int elementSize = (cl.getUseDoublePrecision() || cl.getUseMixedPrecision() ? sizeof(double) : sizeof(float));
globalValues.initialize(cl, expressionSet.getNumVariables(), elementSize, "globalValues"); globalValues.initialize(cl, expressionSet.getNumVariables(), elementSize, "globalValues");
for (int i = 0; i < integrator.getNumGlobalVariables(); i++) { for (int i = 0; i < integrator.getNumGlobalVariables(); i++) {
globalValuesDouble[globalVariableIndex[i]] = initialGlobalVariables[i]; localGlobalValues[globalVariableIndex[i]] = initialGlobalVariables[i];
expressionSet.setVariable(globalVariableIndex[i], initialGlobalVariables[i]); expressionSet.setVariable(globalVariableIndex[i], initialGlobalVariables[i]);
} }
for (int i = 0; i < (int) parameterVariableIndex.size(); i++) { for (int i = 0; i < (int) parameterVariableIndex.size(); i++) {
double value = context.getParameter(parameterNames[i]); double value = context.getParameter(parameterNames[i]);
globalValuesDouble[parameterVariableIndex[i]] = value; localGlobalValues[parameterVariableIndex[i]] = value;
expressionSet.setVariable(parameterVariableIndex[i], value); expressionSet.setVariable(parameterVariableIndex[i], value);
} }
int numContextParams = context.getParameters().size(); int numContextParams = context.getParameters().size();
localPerDofEnergyParamDerivsFloat.resize(numContextParams); localPerDofEnergyParamDerivs.resize(numContextParams);
localPerDofEnergyParamDerivsDouble.resize(numContextParams);
perDofEnergyParamDerivs.initialize(cl, max(1, numContextParams), elementSize, "perDofEnergyParamDerivs"); perDofEnergyParamDerivs.initialize(cl, max(1, numContextParams), elementSize, "perDofEnergyParamDerivs");
// Record information about the targets of steps that will be stored in global variables. // Record information about the targets of steps that will be stored in global variables.
...@@ -8219,8 +8157,8 @@ void OpenCLIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context ...@@ -8219,8 +8157,8 @@ void OpenCLIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
recordGlobalValue(stepSize, GlobalTarget(DT, dtVariableIndex), integrator); recordGlobalValue(stepSize, GlobalTarget(DT, dtVariableIndex), integrator);
for (int i = 0; i < (int) parameterNames.size(); i++) { for (int i = 0; i < (int) parameterNames.size(); i++) {
double value = context.getParameter(parameterNames[i]); double value = context.getParameter(parameterNames[i]);
if (value != globalValuesDouble[parameterVariableIndex[i]]) { if (value != localGlobalValues[parameterVariableIndex[i]]) {
globalValuesDouble[parameterVariableIndex[i]] = value; localGlobalValues[parameterVariableIndex[i]] = value;
deviceGlobalsAreCurrent = false; deviceGlobalsAreCurrent = false;
} }
} }
...@@ -8314,16 +8252,9 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr ...@@ -8314,16 +8252,9 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
if (needsEnergyParamDerivs) { if (needsEnergyParamDerivs) {
context.getEnergyParameterDerivatives(energyParamDerivs); context.getEnergyParameterDerivatives(energyParamDerivs);
if (perDofEnergyParamDerivNames.size() > 0) { if (perDofEnergyParamDerivNames.size() > 0) {
if (cl.getUseDoublePrecision() || cl.getUseMixedPrecision()) { for (int i = 0; i < perDofEnergyParamDerivNames.size(); i++)
for (int i = 0; i < perDofEnergyParamDerivNames.size(); i++) localPerDofEnergyParamDerivs[i] = energyParamDerivs[perDofEnergyParamDerivNames[i]];
localPerDofEnergyParamDerivsDouble[i] = energyParamDerivs[perDofEnergyParamDerivNames[i]]; perDofEnergyParamDerivs.upload(localPerDofEnergyParamDerivs, true, true);
perDofEnergyParamDerivs.upload(localPerDofEnergyParamDerivsDouble);
}
else {
for (int i = 0; i < perDofEnergyParamDerivNames.size(); i++)
localPerDofEnergyParamDerivsFloat[i] = (float) energyParamDerivs[perDofEnergyParamDerivNames[i]];
perDofEnergyParamDerivs.upload(localPerDofEnergyParamDerivsFloat);
}
} }
} }
forcesAreValid = true; forcesAreValid = true;
...@@ -8334,13 +8265,7 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr ...@@ -8334,13 +8265,7 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
if (needsGlobals[step] && !deviceGlobalsAreCurrent) { if (needsGlobals[step] && !deviceGlobalsAreCurrent) {
// Upload the global values to the device. // Upload the global values to the device.
if (cl.getUseDoublePrecision() || cl.getUseMixedPrecision()) globalValues.upload(localGlobalValues, true, true);
globalValues.upload(globalValuesDouble);
else {
for (int j = 0; j < (int) globalValuesDouble.size(); j++)
globalValuesFloat[j] = (float) globalValuesDouble[j];
globalValues.upload(globalValuesFloat);
}
} }
bool stepInvalidatesForces = invalidatesForces[step]; bool stepInvalidatesForces = invalidatesForces[step];
if (stepType[step] == CustomIntegrator::ComputePerDof && !merged[step]) { if (stepType[step] == CustomIntegrator::ComputePerDof && !merged[step]) {
...@@ -8491,17 +8416,17 @@ double OpenCLIntegrateCustomStepKernel::computeKineticEnergy(ContextImpl& contex ...@@ -8491,17 +8416,17 @@ double OpenCLIntegrateCustomStepKernel::computeKineticEnergy(ContextImpl& contex
void OpenCLIntegrateCustomStepKernel::recordGlobalValue(double value, GlobalTarget target, CustomIntegrator& integrator) { void OpenCLIntegrateCustomStepKernel::recordGlobalValue(double value, GlobalTarget target, CustomIntegrator& integrator) {
switch (target.type) { switch (target.type) {
case DT: case DT:
if (value != globalValuesDouble[dtVariableIndex]) if (value != localGlobalValues[dtVariableIndex])
deviceGlobalsAreCurrent = false; deviceGlobalsAreCurrent = false;
expressionSet.setVariable(dtVariableIndex, value); expressionSet.setVariable(dtVariableIndex, value);
globalValuesDouble[dtVariableIndex] = value; localGlobalValues[dtVariableIndex] = value;
cl.getIntegrationUtilities().setNextStepSize(value); cl.getIntegrationUtilities().setNextStepSize(value);
integrator.setStepSize(value); integrator.setStepSize(value);
break; break;
case VARIABLE: case VARIABLE:
case PARAMETER: case PARAMETER:
expressionSet.setVariable(target.variableIndex, value); expressionSet.setVariable(target.variableIndex, value);
globalValuesDouble[target.variableIndex] = value; localGlobalValues[target.variableIndex] = value;
deviceGlobalsAreCurrent = false; deviceGlobalsAreCurrent = false;
break; break;
} }
...@@ -8512,8 +8437,8 @@ void OpenCLIntegrateCustomStepKernel::recordChangedParameters(ContextImpl& conte ...@@ -8512,8 +8437,8 @@ void OpenCLIntegrateCustomStepKernel::recordChangedParameters(ContextImpl& conte
return; return;
for (int i = 0; i < (int) parameterNames.size(); i++) { for (int i = 0; i < (int) parameterNames.size(); i++) {
double value = context.getParameter(parameterNames[i]); double value = context.getParameter(parameterNames[i]);
if (value != globalValuesDouble[parameterVariableIndex[i]]) if (value != localGlobalValues[parameterVariableIndex[i]])
context.setParameter(parameterNames[i], globalValuesDouble[parameterVariableIndex[i]]); context.setParameter(parameterNames[i], localGlobalValues[parameterVariableIndex[i]]);
} }
} }
...@@ -8526,7 +8451,7 @@ void OpenCLIntegrateCustomStepKernel::getGlobalVariables(ContextImpl& context, v ...@@ -8526,7 +8451,7 @@ void OpenCLIntegrateCustomStepKernel::getGlobalVariables(ContextImpl& context, v
} }
values.resize(numGlobalVariables); values.resize(numGlobalVariables);
for (int i = 0; i < numGlobalVariables; i++) for (int i = 0; i < numGlobalVariables; i++)
values[i] = globalValuesDouble[globalVariableIndex[i]]; values[i] = localGlobalValues[globalVariableIndex[i]];
} }
void OpenCLIntegrateCustomStepKernel::setGlobalVariables(ContextImpl& context, const vector<double>& values) { void OpenCLIntegrateCustomStepKernel::setGlobalVariables(ContextImpl& context, const vector<double>& values) {
...@@ -8539,7 +8464,7 @@ void OpenCLIntegrateCustomStepKernel::setGlobalVariables(ContextImpl& context, c ...@@ -8539,7 +8464,7 @@ void OpenCLIntegrateCustomStepKernel::setGlobalVariables(ContextImpl& context, c
return; return;
} }
for (int i = 0; i < numGlobalVariables; i++) { for (int i = 0; i < numGlobalVariables; i++) {
globalValuesDouble[globalVariableIndex[i]] = values[i]; localGlobalValues[globalVariableIndex[i]] = values[i];
expressionSet.setVariable(globalVariableIndex[i], values[i]); expressionSet.setVariable(globalVariableIndex[i], values[i]);
} }
deviceGlobalsAreCurrent = false; deviceGlobalsAreCurrent = false;
......
...@@ -77,7 +77,7 @@ class OPENMM_EXPORT ReferenceAngleBondIxn : public ReferenceBondIxn { ...@@ -77,7 +77,7 @@ class OPENMM_EXPORT ReferenceAngleBondIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void getPrefactorsGivenAngleCosine(double cosine, double* angleParameters, void getPrefactorsGivenAngleCosine(double cosine, std::vector<double>& angleParameters,
double* dEdR, double* energyTerm) const; double* dEdR, double* energyTerm) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -93,8 +93,8 @@ class OPENMM_EXPORT ReferenceAngleBondIxn : public ReferenceBondIxn { ...@@ -93,8 +93,8 @@ class OPENMM_EXPORT ReferenceAngleBondIxn : 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);
......
...@@ -67,9 +67,9 @@ class OPENMM_EXPORT ReferenceBondForce : public ReferenceForce { ...@@ -67,9 +67,9 @@ class OPENMM_EXPORT ReferenceBondForce : public ReferenceForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateForce(int numberOfBonds, int** atomIndices, void calculateForce(int numberOfBonds, std::vector<std::vector<int> >& atomIndices,
std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& atomCoordinates,
double** parameters, std::vector<OpenMM::Vec3>& forces, std::vector<std::vector<double> >& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, ReferenceBondIxn& referenceBondIxn); double* totalEnergy, ReferenceBondIxn& referenceBondIxn);
}; };
......
...@@ -65,8 +65,8 @@ class OPENMM_EXPORT ReferenceBondIxn { ...@@ -65,8 +65,8 @@ class OPENMM_EXPORT ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
virtual void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates, virtual 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);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
......
...@@ -95,8 +95,8 @@ public: ...@@ -95,8 +95,8 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
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);
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
...@@ -84,8 +84,8 @@ class ReferenceCustomAngleIxn : public ReferenceBondIxn { ...@@ -84,8 +84,8 @@ class ReferenceCustomAngleIxn : 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);
......
...@@ -85,8 +85,8 @@ class ReferenceCustomBondIxn : public ReferenceBondIxn { ...@@ -85,8 +85,8 @@ class ReferenceCustomBondIxn : 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);
......
/* 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
...@@ -130,7 +130,7 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn { ...@@ -130,7 +130,7 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, double** bondParameters, void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& bondParameters,
const std::map<std::string, double>& globalParameters, const std::map<std::string, double>& globalParameters,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs); std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs);
......
...@@ -127,7 +127,7 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn { ...@@ -127,7 +127,7 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, double** bondParameters, void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& bondParameters,
const std::map<std::string, double>& globalParameters, const std::map<std::string, double>& globalParameters,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs); std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs);
......
/* 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
...@@ -81,7 +81,7 @@ class ReferenceCustomExternalIxn { ...@@ -81,7 +81,7 @@ class ReferenceCustomExternalIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateForce(int atomIndex, std::vector<OpenMM::Vec3>& atomCoordinates, void calculateForce(int atomIndex, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces, double* energy) const; std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces, 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
...@@ -73,7 +73,7 @@ class ReferenceCustomGBIxn { ...@@ -73,7 +73,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateSingleParticleValue(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters); void calculateSingleParticleValue(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -88,7 +88,7 @@ class ReferenceCustomGBIxn { ...@@ -88,7 +88,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateParticlePairValue(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters, void calculateParticlePairValue(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters,
const std::vector<std::set<int> >& exclusions, bool useExclusions); const std::vector<std::set<int> >& exclusions, bool useExclusions);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -103,7 +103,7 @@ class ReferenceCustomGBIxn { ...@@ -103,7 +103,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateOnePairValue(int index, int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters); void calculateOnePairValue(int index, int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -119,7 +119,7 @@ class ReferenceCustomGBIxn { ...@@ -119,7 +119,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateSingleParticleEnergyTerm(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, void calculateSingleParticleEnergyTerm(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs); std::vector<std::vector<double> >& atomParameters, std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -136,7 +136,7 @@ class ReferenceCustomGBIxn { ...@@ -136,7 +136,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateParticlePairEnergyTerm(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters, void calculateParticlePairEnergyTerm(int index, int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters,
const std::vector<std::set<int> >& exclusions, bool useExclusions, const std::vector<std::set<int> >& exclusions, bool useExclusions,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs); std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs);
...@@ -154,7 +154,7 @@ class ReferenceCustomGBIxn { ...@@ -154,7 +154,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateOnePairEnergyTerm(int index, int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters, void calculateOnePairEnergyTerm(int index, int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs); std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -169,7 +169,7 @@ class ReferenceCustomGBIxn { ...@@ -169,7 +169,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateChainRuleForces(int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters, void calculateChainRuleForces(int numAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters,
const std::vector<std::set<int> >& exclusions, std::vector<OpenMM::Vec3>& forces, double* energyParamDerivs); const std::vector<std::set<int> >& exclusions, std::vector<OpenMM::Vec3>& forces, double* energyParamDerivs);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -185,7 +185,7 @@ class ReferenceCustomGBIxn { ...@@ -185,7 +185,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateOnePairChainRule(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters, void calculateOnePairChainRule(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters,
std::vector<OpenMM::Vec3>& forces, bool isExcluded); std::vector<OpenMM::Vec3>& forces, bool isExcluded);
public: public:
...@@ -254,7 +254,7 @@ class ReferenceCustomGBIxn { ...@@ -254,7 +254,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters, const std::vector<std::set<int> >& exclusions, void calculateIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& atomParameters, const std::vector<std::set<int> >& exclusions,
std::map<std::string, double>& globalParameters, std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs); std::map<std::string, double>& globalParameters, std::vector<OpenMM::Vec3>& forces, double* totalEnergy, double* energyParamDerivs);
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
...@@ -152,7 +152,7 @@ class ReferenceCustomHbondIxn : public ReferenceBondIxn { ...@@ -152,7 +152,7 @@ class ReferenceCustomHbondIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, double** donorParameters, double** acceptorParameters, void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& donorParameters, std::vector<std::vector<double> >& acceptorParameters,
std::vector<std::set<int> >& exclusions, const std::map<std::string, double>& globalParameters, std::vector<std::set<int> >& exclusions, const std::map<std::string, double>& globalParameters,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const; std::vector<OpenMM::Vec3>& forces, 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
...@@ -59,8 +59,8 @@ class ReferenceCustomManyParticleIxn { ...@@ -59,8 +59,8 @@ class ReferenceCustomManyParticleIxn {
std::vector<DihedralTermInfo> dihedralTerms; std::vector<DihedralTermInfo> dihedralTerms;
void loopOverInteractions(std::vector<int>& particles, int loopIndex, std::vector<OpenMM::Vec3>& atomCoordinates, void loopOverInteractions(std::vector<int>& particles, int loopIndex, std::vector<OpenMM::Vec3>& atomCoordinates,
double** particleParameters, std::map<std::string, double>& variables, std::vector<OpenMM::Vec3>& forces, std::vector<std::vector<double> >& particleParameters, std::map<std::string, double>& variables,
double* totalEnergy) const; std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -76,8 +76,8 @@ class ReferenceCustomManyParticleIxn { ...@@ -76,8 +76,8 @@ class ReferenceCustomManyParticleIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateOneIxn(const std::vector<int>& particles, std::vector<OpenMM::Vec3>& atomCoordinates, void calculateOneIxn(const std::vector<int>& particles, std::vector<OpenMM::Vec3>& atomCoordinates,
double** particleParameters, std::map<std::string, double>& variables, std::vector<OpenMM::Vec3>& forces, std::vector<std::vector<double> >& particleParameters, std::map<std::string, double>& variables,
double* totalEnergy) const; std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const;
void computeDelta(int atom1, int atom2, double* delta, std::vector<OpenMM::Vec3>& atomCoordinates) const; void computeDelta(int atom1, int atom2, double* delta, std::vector<OpenMM::Vec3>& atomCoordinates) const;
...@@ -136,7 +136,7 @@ class ReferenceCustomManyParticleIxn { ...@@ -136,7 +136,7 @@ class ReferenceCustomManyParticleIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateIxn(std::vector<OpenMM::Vec3>& atomCoordinates, double** particleParameters, void calculateIxn(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& particleParameters,
const std::map<std::string, double>& globalParameters, const std::map<std::string, double>& globalParameters,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const; std::vector<OpenMM::Vec3>& forces, double* totalEnergy) 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
...@@ -61,15 +61,13 @@ class ReferenceCustomNonbondedIxn { ...@@ -61,15 +61,13 @@ class ReferenceCustomNonbondedIxn {
@param atom1 the index of the first atom @param atom1 the index of the first atom
@param atom2 the index of the second atom @param atom2 the index of the second atom
@param atomCoordinates atom coordinates @param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][parameterIndex]
@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 calculateOneIxn(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& forces, void calculateOneIxn(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& forces,
double* energyByAtom, double* totalEnergy, double* energyParamDerivs); double* totalEnergy, double* energyParamDerivs);
public: public:
...@@ -144,19 +142,16 @@ class ReferenceCustomNonbondedIxn { ...@@ -144,19 +142,16 @@ class ReferenceCustomNonbondedIxn {
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex] @param atomParameters atom parameters (charges, c6, c12, ...) 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 calculatePairIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, void calculatePairIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<std::set<int> >& exclusions, std::vector<std::vector<double> >& atomParameters, std::vector<std::set<int> >& exclusions,
double* fixedParameters, const std::map<std::string, double>& globalParameters, const std::map<std::string, double>& globalParameters, std::vector<OpenMM::Vec3>& forces,
std::vector<OpenMM::Vec3>& forces, double* energyByAtom, double* totalEnergy, double* totalEnergy, double* energyParamDerivs);
double* energyParamDerivs);
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
...@@ -84,8 +84,8 @@ class ReferenceCustomTorsionIxn : public ReferenceBondIxn { ...@@ -84,8 +84,8 @@ class ReferenceCustomTorsionIxn : 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);
......
...@@ -77,8 +77,8 @@ class ReferenceHarmonicBondIxn : public ReferenceBondIxn { ...@@ -77,8 +77,8 @@ class ReferenceHarmonicBondIxn : 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);
}; };
......
...@@ -261,7 +261,6 @@ class ReferenceCalcHarmonicBondForceKernel : public CalcHarmonicBondForceKernel ...@@ -261,7 +261,6 @@ class ReferenceCalcHarmonicBondForceKernel : public CalcHarmonicBondForceKernel
public: public:
ReferenceCalcHarmonicBondForceKernel(std::string name, const Platform& platform) : CalcHarmonicBondForceKernel(name, platform) { ReferenceCalcHarmonicBondForceKernel(std::string name, const Platform& platform) : CalcHarmonicBondForceKernel(name, platform) {
} }
~ReferenceCalcHarmonicBondForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -287,8 +286,8 @@ public: ...@@ -287,8 +286,8 @@ public:
void copyParametersToContext(ContextImpl& context, const HarmonicBondForce& force); void copyParametersToContext(ContextImpl& context, const HarmonicBondForce& force);
private: private:
int numBonds; int numBonds;
int **bondIndexArray; std::vector<std::vector<int> >bondIndexArray;
double **bondParamArray; std::vector<std::vector<double> >bondParamArray;
bool usePeriodic; bool usePeriodic;
}; };
...@@ -299,7 +298,6 @@ class ReferenceCalcCustomBondForceKernel : public CalcCustomBondForceKernel { ...@@ -299,7 +298,6 @@ class ReferenceCalcCustomBondForceKernel : public CalcCustomBondForceKernel {
public: public:
ReferenceCalcCustomBondForceKernel(std::string name, const Platform& platform) : CalcCustomBondForceKernel(name, platform) { ReferenceCalcCustomBondForceKernel(std::string name, const Platform& platform) : CalcCustomBondForceKernel(name, platform) {
} }
~ReferenceCalcCustomBondForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -325,8 +323,8 @@ public: ...@@ -325,8 +323,8 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomBondForce& force); void copyParametersToContext(ContextImpl& context, const CustomBondForce& force);
private: private:
int numBonds; int numBonds;
int **bondIndexArray; std::vector<std::vector<int> >bondIndexArray;
double **bondParamArray; std::vector<std::vector<double> >bondParamArray;
Lepton::CompiledExpression energyExpression, forceExpression; Lepton::CompiledExpression energyExpression, forceExpression;
std::vector<Lepton::CompiledExpression> energyParamDerivExpressions; std::vector<Lepton::CompiledExpression> energyParamDerivExpressions;
std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames; std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames;
...@@ -340,7 +338,6 @@ class ReferenceCalcHarmonicAngleForceKernel : public CalcHarmonicAngleForceKerne ...@@ -340,7 +338,6 @@ class ReferenceCalcHarmonicAngleForceKernel : public CalcHarmonicAngleForceKerne
public: public:
ReferenceCalcHarmonicAngleForceKernel(std::string name, const Platform& platform) : CalcHarmonicAngleForceKernel(name, platform) { ReferenceCalcHarmonicAngleForceKernel(std::string name, const Platform& platform) : CalcHarmonicAngleForceKernel(name, platform) {
} }
~ReferenceCalcHarmonicAngleForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -366,8 +363,8 @@ public: ...@@ -366,8 +363,8 @@ public:
void copyParametersToContext(ContextImpl& context, const HarmonicAngleForce& force); void copyParametersToContext(ContextImpl& context, const HarmonicAngleForce& force);
private: private:
int numAngles; int numAngles;
int **angleIndexArray; std::vector<std::vector<int> >angleIndexArray;
double **angleParamArray; std::vector<std::vector<double> >angleParamArray;
bool usePeriodic; bool usePeriodic;
}; };
...@@ -378,7 +375,6 @@ class ReferenceCalcCustomAngleForceKernel : public CalcCustomAngleForceKernel { ...@@ -378,7 +375,6 @@ class ReferenceCalcCustomAngleForceKernel : public CalcCustomAngleForceKernel {
public: public:
ReferenceCalcCustomAngleForceKernel(std::string name, const Platform& platform) : CalcCustomAngleForceKernel(name, platform) { ReferenceCalcCustomAngleForceKernel(std::string name, const Platform& platform) : CalcCustomAngleForceKernel(name, platform) {
} }
~ReferenceCalcCustomAngleForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -404,8 +400,8 @@ public: ...@@ -404,8 +400,8 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomAngleForce& force); void copyParametersToContext(ContextImpl& context, const CustomAngleForce& force);
private: private:
int numAngles; int numAngles;
int **angleIndexArray; std::vector<std::vector<int> >angleIndexArray;
double **angleParamArray; std::vector<std::vector<double> >angleParamArray;
Lepton::CompiledExpression energyExpression, forceExpression; Lepton::CompiledExpression energyExpression, forceExpression;
std::vector<Lepton::CompiledExpression> energyParamDerivExpressions; std::vector<Lepton::CompiledExpression> energyParamDerivExpressions;
std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames; std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames;
...@@ -419,7 +415,6 @@ class ReferenceCalcPeriodicTorsionForceKernel : public CalcPeriodicTorsionForceK ...@@ -419,7 +415,6 @@ class ReferenceCalcPeriodicTorsionForceKernel : public CalcPeriodicTorsionForceK
public: public:
ReferenceCalcPeriodicTorsionForceKernel(std::string name, const Platform& platform) : CalcPeriodicTorsionForceKernel(name, platform) { ReferenceCalcPeriodicTorsionForceKernel(std::string name, const Platform& platform) : CalcPeriodicTorsionForceKernel(name, platform) {
} }
~ReferenceCalcPeriodicTorsionForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -445,8 +440,8 @@ public: ...@@ -445,8 +440,8 @@ public:
void copyParametersToContext(ContextImpl& context, const PeriodicTorsionForce& force); void copyParametersToContext(ContextImpl& context, const PeriodicTorsionForce& force);
private: private:
int numTorsions; int numTorsions;
int **torsionIndexArray; std::vector<std::vector<int> >torsionIndexArray;
double **torsionParamArray; std::vector<std::vector<double> >torsionParamArray;
bool usePeriodic; bool usePeriodic;
}; };
...@@ -457,7 +452,6 @@ class ReferenceCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel { ...@@ -457,7 +452,6 @@ class ReferenceCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
public: public:
ReferenceCalcRBTorsionForceKernel(std::string name, const Platform& platform) : CalcRBTorsionForceKernel(name, platform) { ReferenceCalcRBTorsionForceKernel(std::string name, const Platform& platform) : CalcRBTorsionForceKernel(name, platform) {
} }
~ReferenceCalcRBTorsionForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -483,8 +477,8 @@ public: ...@@ -483,8 +477,8 @@ public:
void copyParametersToContext(ContextImpl& context, const RBTorsionForce& force); void copyParametersToContext(ContextImpl& context, const RBTorsionForce& force);
private: private:
int numTorsions; int numTorsions;
int **torsionIndexArray; std::vector<std::vector<int> >torsionIndexArray;
double **torsionParamArray; std::vector<std::vector<double> >torsionParamArray;
bool usePeriodic; bool usePeriodic;
}; };
...@@ -532,7 +526,6 @@ class ReferenceCalcCustomTorsionForceKernel : public CalcCustomTorsionForceKerne ...@@ -532,7 +526,6 @@ class ReferenceCalcCustomTorsionForceKernel : public CalcCustomTorsionForceKerne
public: public:
ReferenceCalcCustomTorsionForceKernel(std::string name, const Platform& platform) : CalcCustomTorsionForceKernel(name, platform) { ReferenceCalcCustomTorsionForceKernel(std::string name, const Platform& platform) : CalcCustomTorsionForceKernel(name, platform) {
} }
~ReferenceCalcCustomTorsionForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -558,8 +551,8 @@ public: ...@@ -558,8 +551,8 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomTorsionForce& force); void copyParametersToContext(ContextImpl& context, const CustomTorsionForce& force);
private: private:
int numTorsions; int numTorsions;
int **torsionIndexArray; std::vector<std::vector<int> >torsionIndexArray;
double **torsionParamArray; std::vector<std::vector<double> >torsionParamArray;
Lepton::CompiledExpression energyExpression, forceExpression; Lepton::CompiledExpression energyExpression, forceExpression;
std::vector<Lepton::CompiledExpression> energyParamDerivExpressions; std::vector<Lepton::CompiledExpression> energyParamDerivExpressions;
std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames; std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames;
...@@ -619,8 +612,8 @@ public: ...@@ -619,8 +612,8 @@ public:
private: private:
void computeParameters(ContextImpl& context); void computeParameters(ContextImpl& context);
int numParticles, num14; int numParticles, num14;
int **bonded14IndexArray; std::vector<std::vector<int> >bonded14IndexArray;
double **particleParamArray, **bonded14ParamArray; std::vector<std::vector<double> > particleParamArray, bonded14ParamArray;
std::vector<std::array<double, 3> > baseParticleParams, baseExceptionParams; std::vector<std::array<double, 3> > baseParticleParams, baseExceptionParams;
std::map<std::pair<std::string, int>, std::array<double, 3> > particleParamOffsets, exceptionParamOffsets; std::map<std::pair<std::string, int>, std::array<double, 3> > particleParamOffsets, exceptionParamOffsets;
double nonbondedCutoff, switchingDistance, rfDielectric, ewaldAlpha, ewaldDispersionAlpha, dispersionCoefficient; double nonbondedCutoff, switchingDistance, rfDielectric, ewaldAlpha, ewaldDispersionAlpha, dispersionCoefficient;
...@@ -664,7 +657,7 @@ public: ...@@ -664,7 +657,7 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomNonbondedForce& force); void copyParametersToContext(ContextImpl& context, const CustomNonbondedForce& force);
private: private:
int numParticles; int numParticles;
double **particleParamArray; std::vector<std::vector<double> > particleParamArray;
double nonbondedCutoff, switchingDistance, periodicBoxSize[3], longRangeCoefficient; double nonbondedCutoff, switchingDistance, periodicBoxSize[3], longRangeCoefficient;
bool useSwitchingFunction, hasInitializedLongRangeCorrection; bool useSwitchingFunction, hasInitializedLongRangeCorrection;
CustomNonbondedForce* forceCopy; CustomNonbondedForce* forceCopy;
...@@ -750,7 +743,7 @@ public: ...@@ -750,7 +743,7 @@ public:
private: private:
int numParticles; int numParticles;
bool isPeriodic; bool isPeriodic;
double **particleParamArray; std::vector<std::vector<double> > particleParamArray;
double nonbondedCutoff; double nonbondedCutoff;
std::vector<std::set<int> > exclusions; std::vector<std::set<int> > exclusions;
std::vector<std::string> particleParameterNames, globalParameterNames, energyParamDerivNames, valueNames; std::vector<std::string> particleParameterNames, globalParameterNames, energyParamDerivNames, valueNames;
...@@ -775,7 +768,6 @@ class ReferenceCalcCustomExternalForceKernel : public CalcCustomExternalForceKer ...@@ -775,7 +768,6 @@ class ReferenceCalcCustomExternalForceKernel : public CalcCustomExternalForceKer
public: public:
ReferenceCalcCustomExternalForceKernel(std::string name, const Platform& platform) : CalcCustomExternalForceKernel(name, platform) { ReferenceCalcCustomExternalForceKernel(std::string name, const Platform& platform) : CalcCustomExternalForceKernel(name, platform) {
} }
~ReferenceCalcCustomExternalForceKernel();
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
...@@ -803,7 +795,7 @@ private: ...@@ -803,7 +795,7 @@ private:
class PeriodicDistanceFunction; class PeriodicDistanceFunction;
int numParticles; int numParticles;
std::vector<int> particles; std::vector<int> particles;
double **particleParamArray; std::vector<std::vector<double> > particleParamArray;
Lepton::CompiledExpression energyExpression, forceExpressionX, forceExpressionY, forceExpressionZ; Lepton::CompiledExpression energyExpression, forceExpressionX, forceExpressionY, forceExpressionZ;
std::vector<std::string> parameterNames, globalParameterNames; std::vector<std::string> parameterNames, globalParameterNames;
Vec3* boxVectors; Vec3* boxVectors;
...@@ -853,7 +845,7 @@ public: ...@@ -853,7 +845,7 @@ public:
private: private:
int numDonors, numAcceptors, numParticles; int numDonors, numAcceptors, numParticles;
bool isPeriodic; bool isPeriodic;
double **donorParamArray, **acceptorParamArray; std::vector<std::vector<double> > donorParamArray, acceptorParamArray;
double nonbondedCutoff; double nonbondedCutoff;
ReferenceCustomHbondIxn* ixn; ReferenceCustomHbondIxn* ixn;
std::vector<std::set<int> > exclusions; std::vector<std::set<int> > exclusions;
...@@ -893,7 +885,7 @@ public: ...@@ -893,7 +885,7 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomCentroidBondForce& force); void copyParametersToContext(ContextImpl& context, const CustomCentroidBondForce& force);
private: private:
int numBonds, numParticles; int numBonds, numParticles;
double **bondParamArray; std::vector<std::vector<double> > bondParamArray;
ReferenceCustomCentroidBondIxn* ixn; ReferenceCustomCentroidBondIxn* ixn;
std::vector<std::string> globalParameterNames, energyParamDerivNames; std::vector<std::string> globalParameterNames, energyParamDerivNames;
bool usePeriodic; bool usePeriodic;
...@@ -932,7 +924,7 @@ public: ...@@ -932,7 +924,7 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomCompoundBondForce& force); void copyParametersToContext(ContextImpl& context, const CustomCompoundBondForce& force);
private: private:
int numBonds; int numBonds;
double **bondParamArray; std::vector<std::vector<double> > bondParamArray;
ReferenceCustomCompoundBondIxn* ixn; ReferenceCustomCompoundBondIxn* ixn;
std::vector<std::string> globalParameterNames, energyParamDerivNames; std::vector<std::string> globalParameterNames, energyParamDerivNames;
bool usePeriodic; bool usePeriodic;
...@@ -972,7 +964,7 @@ public: ...@@ -972,7 +964,7 @@ public:
private: private:
int numParticles; int numParticles;
double cutoffDistance; double cutoffDistance;
double **particleParamArray; std::vector<std::vector<double> > particleParamArray;
ReferenceCustomManyParticleIxn* ixn; ReferenceCustomManyParticleIxn* ixn;
std::vector<std::string> globalParameterNames; std::vector<std::string> globalParameterNames;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
......
...@@ -62,8 +62,8 @@ class OPENMM_EXPORT ReferenceLJCoulomb14 : public ReferenceBondIxn { ...@@ -62,8 +62,8 @@ class OPENMM_EXPORT ReferenceLJCoulomb14 : 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);
}; };
......
/* 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
...@@ -62,14 +62,13 @@ class ReferenceLJCoulombIxn { ...@@ -62,14 +62,13 @@ class ReferenceLJCoulombIxn {
@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 calculateOneIxn(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, void calculateOneIxn(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<OpenMM::Vec3>& forces, std::vector<std::vector<double> >& atomParameters, std::vector<OpenMM::Vec3>& forces,
double* energyByAtom, double* totalEnergy) const; double* totalEnergy) const;
public: public:
...@@ -169,9 +168,7 @@ class ReferenceLJCoulombIxn { ...@@ -169,9 +168,7 @@ class ReferenceLJCoulombIxn {
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex] @param atomParameters atom parameters (charges, c6, c12, ...) 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
...@@ -179,9 +176,8 @@ class ReferenceLJCoulombIxn { ...@@ -179,9 +176,8 @@ class ReferenceLJCoulombIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculatePairIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, void calculatePairIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<std::set<int> >& exclusions, std::vector<std::vector<double> >& atomParameters, std::vector<std::set<int> >& exclusions,
double* fixedParameters, std::vector<OpenMM::Vec3>& forces, std::vector<OpenMM::Vec3>& forces, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
double* energyByAtom, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
private: private:
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -193,9 +189,7 @@ private: ...@@ -193,9 +189,7 @@ private:
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex] @param atomParameters atom parameters (charges, c6, c12, ...) 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
...@@ -203,9 +197,8 @@ private: ...@@ -203,9 +197,8 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateEwaldIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, void calculateEwaldIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<std::set<int> >& exclusions, std::vector<std::vector<double> >& atomParameters, std::vector<std::set<int> >& exclusions,
double* fixedParameters, std::vector<OpenMM::Vec3>& forces, std::vector<OpenMM::Vec3>& forces, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
double* energyByAtom, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -78,8 +78,8 @@ class OPENMM_EXPORT ReferenceProperDihedralBond : public ReferenceBondIxn { ...@@ -78,8 +78,8 @@ class OPENMM_EXPORT ReferenceProperDihedralBond : 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);
}; };
......
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