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