Commit 9f37b18b authored by peastman's avatar peastman
Browse files

Code cleanup to reference and CPU platforms

parent f9106ddb
...@@ -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);
}; };
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. * * Portions copyright (c) 2008-2018 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -259,7 +259,6 @@ class ReferenceCalcHarmonicBondForceKernel : public CalcHarmonicBondForceKernel ...@@ -259,7 +259,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.
* *
...@@ -285,8 +284,8 @@ public: ...@@ -285,8 +284,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;
}; };
...@@ -297,7 +296,6 @@ class ReferenceCalcCustomBondForceKernel : public CalcCustomBondForceKernel { ...@@ -297,7 +296,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.
* *
...@@ -323,8 +321,8 @@ public: ...@@ -323,8 +321,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;
...@@ -338,7 +336,6 @@ class ReferenceCalcHarmonicAngleForceKernel : public CalcHarmonicAngleForceKerne ...@@ -338,7 +336,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.
* *
...@@ -364,8 +361,8 @@ public: ...@@ -364,8 +361,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;
}; };
...@@ -376,7 +373,6 @@ class ReferenceCalcCustomAngleForceKernel : public CalcCustomAngleForceKernel { ...@@ -376,7 +373,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.
* *
...@@ -402,8 +398,8 @@ public: ...@@ -402,8 +398,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;
...@@ -417,7 +413,6 @@ class ReferenceCalcPeriodicTorsionForceKernel : public CalcPeriodicTorsionForceK ...@@ -417,7 +413,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.
* *
...@@ -443,8 +438,8 @@ public: ...@@ -443,8 +438,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;
}; };
...@@ -455,7 +450,6 @@ class ReferenceCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel { ...@@ -455,7 +450,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.
* *
...@@ -481,8 +475,8 @@ public: ...@@ -481,8 +475,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;
}; };
...@@ -530,7 +524,6 @@ class ReferenceCalcCustomTorsionForceKernel : public CalcCustomTorsionForceKerne ...@@ -530,7 +524,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.
* *
...@@ -556,8 +549,8 @@ public: ...@@ -556,8 +549,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;
...@@ -616,8 +609,8 @@ public: ...@@ -616,8 +609,8 @@ public:
void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const; void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
private: private:
int numParticles, num14; int numParticles, num14;
int **bonded14IndexArray; std::vector<std::vector<int> >bonded14IndexArray;
double **particleParamArray, **bonded14ParamArray; std::vector<std::vector<double> > particleParamArray, bonded14ParamArray;
double nonbondedCutoff, switchingDistance, rfDielectric, ewaldAlpha, ewaldDispersionAlpha, dispersionCoefficient; double nonbondedCutoff, switchingDistance, rfDielectric, ewaldAlpha, ewaldDispersionAlpha, dispersionCoefficient;
int kmax[3], gridSize[3], dispersionGridSize[3]; int kmax[3], gridSize[3], dispersionGridSize[3];
bool useSwitchingFunction; bool useSwitchingFunction;
...@@ -659,7 +652,7 @@ public: ...@@ -659,7 +652,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;
...@@ -745,7 +738,7 @@ public: ...@@ -745,7 +738,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;
...@@ -770,7 +763,6 @@ class ReferenceCalcCustomExternalForceKernel : public CalcCustomExternalForceKer ...@@ -770,7 +763,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.
* *
...@@ -798,7 +790,7 @@ private: ...@@ -798,7 +790,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;
...@@ -848,7 +840,7 @@ public: ...@@ -848,7 +840,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;
...@@ -888,7 +880,7 @@ public: ...@@ -888,7 +880,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;
...@@ -927,7 +919,7 @@ public: ...@@ -927,7 +919,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;
...@@ -967,7 +959,7 @@ public: ...@@ -967,7 +959,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);
}; };
......
...@@ -76,8 +76,8 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn { ...@@ -76,8 +76,8 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates, void calculateBondIxn(std::vector<int>& atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces, std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs); double* totalEnergy, double* energyParamDerivs);
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. * * Portions copyright (c) 2008-2018 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -89,36 +89,6 @@ ...@@ -89,36 +89,6 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
static int** allocateIntArray(int length, int width) {
int** array = new int*[length];
for (int i = 0; i < length; ++i)
array[i] = new int[width];
return array;
}
static double** allocateRealArray(int length, int width) {
double** array = new double*[length];
for (int i = 0; i < length; ++i)
array[i] = new double[width];
return array;
}
static void disposeIntArray(int** array, int size) {
if (array) {
for (int i = 0; i < size; ++i)
delete[] array[i];
delete[] array;
}
}
static void disposeRealArray(double** array, int size) {
if (array) {
for (int i = 0; i < size; ++i)
delete[] array[i];
delete[] array;
}
}
static vector<Vec3>& extractPositions(ContextImpl& context) { static vector<Vec3>& extractPositions(ContextImpl& context) {
ReferencePlatform::PlatformData* data = reinterpret_cast<ReferencePlatform::PlatformData*>(context.getPlatformData()); ReferencePlatform::PlatformData* data = reinterpret_cast<ReferencePlatform::PlatformData*>(context.getPlatformData());
return *((vector<Vec3>*) data->positions); return *((vector<Vec3>*) data->positions);
...@@ -366,15 +336,10 @@ void ReferenceVirtualSitesKernel::computePositions(ContextImpl& context) { ...@@ -366,15 +336,10 @@ void ReferenceVirtualSitesKernel::computePositions(ContextImpl& context) {
ReferenceVirtualSites::computePositions(context.getSystem(), positions); ReferenceVirtualSites::computePositions(context.getSystem(), positions);
} }
ReferenceCalcHarmonicBondForceKernel::~ReferenceCalcHarmonicBondForceKernel() {
disposeIntArray(bondIndexArray, numBonds);
disposeRealArray(bondParamArray, numBonds);
}
void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, const HarmonicBondForce& force) { void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, const HarmonicBondForce& force) {
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
bondIndexArray = allocateIntArray(numBonds, 2); bondIndexArray.resize(numBonds, vector<int>(2));
bondParamArray = allocateRealArray(numBonds, 2); bondParamArray.resize(numBonds, vector<double>(2));
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i) {
int particle1, particle2; int particle1, particle2;
double length, k; double length, k;
...@@ -418,11 +383,6 @@ void ReferenceCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl& ...@@ -418,11 +383,6 @@ void ReferenceCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl&
} }
} }
ReferenceCalcCustomBondForceKernel::~ReferenceCalcCustomBondForceKernel() {
disposeIntArray(bondIndexArray, numBonds);
disposeRealArray(bondParamArray, numBonds);
}
void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const CustomBondForce& force) { void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const CustomBondForce& force) {
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
int numParameters = force.getNumPerBondParameters(); int numParameters = force.getNumPerBondParameters();
...@@ -430,8 +390,8 @@ void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const ...@@ -430,8 +390,8 @@ void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const
// Build the arrays. // Build the arrays.
bondIndexArray = allocateIntArray(numBonds, 2); bondIndexArray.resize(numBonds, vector<int>(2));
bondParamArray = allocateRealArray(numBonds, numParameters); bondParamArray.resize(numBonds, vector<double>(numParameters));
vector<double> params; vector<double> params;
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i) {
int particle1, particle2; int particle1, particle2;
...@@ -500,15 +460,10 @@ void ReferenceCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& co ...@@ -500,15 +460,10 @@ void ReferenceCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& co
} }
} }
ReferenceCalcHarmonicAngleForceKernel::~ReferenceCalcHarmonicAngleForceKernel() {
disposeIntArray(angleIndexArray, numAngles);
disposeRealArray(angleParamArray, numAngles);
}
void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, const HarmonicAngleForce& force) { void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, const HarmonicAngleForce& force) {
numAngles = force.getNumAngles(); numAngles = force.getNumAngles();
angleIndexArray = allocateIntArray(numAngles, 3); angleIndexArray.resize(numAngles, vector<int>(3));
angleParamArray = allocateRealArray(numAngles, 2); angleParamArray.resize(numAngles, vector<double>(2));
for (int i = 0; i < numAngles; ++i) { for (int i = 0; i < numAngles; ++i) {
int particle1, particle2, particle3; int particle1, particle2, particle3;
double angle, k; double angle, k;
...@@ -551,11 +506,6 @@ void ReferenceCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl& ...@@ -551,11 +506,6 @@ void ReferenceCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl&
} }
} }
ReferenceCalcCustomAngleForceKernel::~ReferenceCalcCustomAngleForceKernel() {
disposeIntArray(angleIndexArray, numAngles);
disposeRealArray(angleParamArray, numAngles);
}
void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const CustomAngleForce& force) { void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const CustomAngleForce& force) {
numAngles = force.getNumAngles(); numAngles = force.getNumAngles();
int numParameters = force.getNumPerAngleParameters(); int numParameters = force.getNumPerAngleParameters();
...@@ -563,8 +513,8 @@ void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const ...@@ -563,8 +513,8 @@ void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const
// Build the arrays. // Build the arrays.
angleIndexArray = allocateIntArray(numAngles, 3); angleIndexArray.resize(numAngles, vector<int>(3));
angleParamArray = allocateRealArray(numAngles, numParameters); angleParamArray.resize(numAngles, vector<double>(numParameters));
vector<double> params; vector<double> params;
for (int i = 0; i < numAngles; ++i) { for (int i = 0; i < numAngles; ++i) {
int particle1, particle2, particle3; int particle1, particle2, particle3;
...@@ -634,15 +584,10 @@ void ReferenceCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& c ...@@ -634,15 +584,10 @@ void ReferenceCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& c
} }
} }
ReferenceCalcPeriodicTorsionForceKernel::~ReferenceCalcPeriodicTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, const PeriodicTorsionForce& force) { void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, const PeriodicTorsionForce& force) {
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray = allocateRealArray(numTorsions, 3); torsionParamArray.resize(numTorsions, vector<double>(3));
for (int i = 0; i < numTorsions; ++i) { for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4, periodicity; int particle1, particle2, particle3, particle4, periodicity;
double phase, k; double phase, k;
...@@ -688,15 +633,10 @@ void ReferenceCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImp ...@@ -688,15 +633,10 @@ void ReferenceCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImp
} }
} }
ReferenceCalcRBTorsionForceKernel::~ReferenceCalcRBTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const RBTorsionForce& force) { void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const RBTorsionForce& force) {
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray = allocateRealArray(numTorsions, 6); torsionParamArray.resize(numTorsions, vector<double>(6));
for (int i = 0; i < numTorsions; ++i) { for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
double c0, c1, c2, c3, c4, c5; double c0, c1, c2, c3, c4, c5;
...@@ -820,11 +760,6 @@ void ReferenceCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& c ...@@ -820,11 +760,6 @@ void ReferenceCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& c
} }
} }
ReferenceCalcCustomTorsionForceKernel::~ReferenceCalcCustomTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, const CustomTorsionForce& force) { void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, const CustomTorsionForce& force) {
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
int numParameters = force.getNumPerTorsionParameters(); int numParameters = force.getNumPerTorsionParameters();
...@@ -832,8 +767,8 @@ void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, con ...@@ -832,8 +767,8 @@ void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, con
// Build the arrays. // Build the arrays.
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray = allocateRealArray(numTorsions, numParameters); torsionParamArray.resize(numTorsions, vector<double>(numParameters));
vector<double> params; vector<double> params;
for (int i = 0; i < numTorsions; ++i) { for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
...@@ -905,9 +840,6 @@ void ReferenceCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl& ...@@ -905,9 +840,6 @@ void ReferenceCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl&
} }
ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() { ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() {
disposeRealArray(particleParamArray, numParticles);
disposeIntArray(bonded14IndexArray, num14);
disposeRealArray(bonded14ParamArray, num14);
if (neighborList != NULL) if (neighborList != NULL)
delete neighborList; delete neighborList;
} }
...@@ -932,9 +864,9 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N ...@@ -932,9 +864,9 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
// Build the arrays. // Build the arrays.
num14 = nb14s.size(); num14 = nb14s.size();
bonded14IndexArray = allocateIntArray(num14, 2); bonded14IndexArray.resize(num14, vector<int>(2));
bonded14ParamArray = allocateRealArray(num14, 3); bonded14ParamArray.resize(num14, vector<double>(3));
particleParamArray = allocateRealArray(numParticles, 3); particleParamArray.resize(numParticles, vector<double>(3));
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i) {
double charge, radius, depth; double charge, radius, depth;
force.getParticleParameters(i, charge, radius, depth); force.getParticleParameters(i, charge, radius, depth);
...@@ -1019,7 +951,7 @@ double ReferenceCalcNonbondedForceKernel::execute(ContextImpl& context, bool inc ...@@ -1019,7 +951,7 @@ double ReferenceCalcNonbondedForceKernel::execute(ContextImpl& context, bool inc
} }
if (useSwitchingFunction) if (useSwitchingFunction)
clj.setUseSwitchingFunction(switchingDistance); clj.setUseSwitchingFunction(switchingDistance);
clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, 0, forceData, 0, includeEnergy ? &energy : NULL, includeDirect, includeReciprocal); clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, forceData, includeEnergy ? &energy : NULL, includeDirect, includeReciprocal);
if (includeDirect) { if (includeDirect) {
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
ReferenceLJCoulomb14 nonbonded14; ReferenceLJCoulomb14 nonbonded14;
...@@ -1092,7 +1024,6 @@ void ReferenceCalcNonbondedForceKernel::getLJPMEParameters(double& alpha, int& n ...@@ -1092,7 +1024,6 @@ void ReferenceCalcNonbondedForceKernel::getLJPMEParameters(double& alpha, int& n
} }
ReferenceCalcCustomNonbondedForceKernel::~ReferenceCalcCustomNonbondedForceKernel() { ReferenceCalcCustomNonbondedForceKernel::~ReferenceCalcCustomNonbondedForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (neighborList != NULL) if (neighborList != NULL)
delete neighborList; delete neighborList;
if (forceCopy != NULL) if (forceCopy != NULL)
...@@ -1115,13 +1046,9 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, c ...@@ -1115,13 +1046,9 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, c
// Build the arrays. // Build the arrays.
int numParameters = force.getNumPerParticleParameters(); int numParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numParameters); particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i)
vector<double> parameters; force.getParticleParameters(i, particleParamArray[i]);
force.getParticleParameters(i, parameters);
for (int j = 0; j < numParameters; j++)
particleParamArray[i][j] = parameters[j];
}
nonbondedMethod = CalcCustomNonbondedForceKernel::NonbondedMethod(force.getNonbondedMethod()); nonbondedMethod = CalcCustomNonbondedForceKernel::NonbondedMethod(force.getNonbondedMethod());
nonbondedCutoff = force.getCutoffDistance(); nonbondedCutoff = force.getCutoffDistance();
if (nonbondedMethod == NoCutoff) { if (nonbondedMethod == NoCutoff) {
...@@ -1219,7 +1146,7 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo ...@@ -1219,7 +1146,7 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo
if (useSwitchingFunction) if (useSwitchingFunction)
ixn.setUseSwitchingFunction(switchingDistance); ixn.setUseSwitchingFunction(switchingDistance);
vector<double> energyParamDerivValues(energyParamDerivNames.size()+1, 0.0); vector<double> energyParamDerivValues(energyParamDerivNames.size()+1, 0.0);
ixn.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, 0, globalParamValues, forceData, 0, includeEnergy ? &energy : NULL, &energyParamDerivValues[0]); ixn.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, globalParamValues, forceData, includeEnergy ? &energy : NULL, &energyParamDerivValues[0]);
map<string, double>& energyParamDerivs = extractEnergyParameterDerivatives(context); map<string, double>& energyParamDerivs = extractEnergyParameterDerivatives(context);
for (int i = 0; i < energyParamDerivNames.size(); i++) for (int i = 0; i < energyParamDerivNames.size(); i++)
energyParamDerivs[energyParamDerivNames[i]] += energyParamDerivValues[i]; energyParamDerivs[energyParamDerivNames[i]] += energyParamDerivValues[i];
...@@ -1323,7 +1250,6 @@ void ReferenceCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& conte ...@@ -1323,7 +1250,6 @@ void ReferenceCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& conte
} }
ReferenceCalcCustomGBForceKernel::~ReferenceCalcCustomGBForceKernel() { ReferenceCalcCustomGBForceKernel::~ReferenceCalcCustomGBForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (neighborList != NULL) if (neighborList != NULL)
delete neighborList; delete neighborList;
} }
...@@ -1356,13 +1282,9 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu ...@@ -1356,13 +1282,9 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu
// Build the arrays. // Build the arrays.
int numPerParticleParameters = force.getNumPerParticleParameters(); int numPerParticleParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numPerParticleParameters); particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i)
vector<double> parameters; force.getParticleParameters(i, particleParamArray[i]);
force.getParticleParameters(i, parameters);
for (int j = 0; j < numPerParticleParameters; j++)
particleParamArray[i][j] = parameters[j];
}
for (int i = 0; i < numPerParticleParameters; i++) for (int i = 0; i < numPerParticleParameters; i++)
particleParameterNames.push_back(force.getPerParticleParameterName(i)); particleParameterNames.push_back(force.getPerParticleParameterName(i));
for (int i = 0; i < force.getNumGlobalParameters(); i++) for (int i = 0; i < force.getNumGlobalParameters(); i++)
...@@ -1548,10 +1470,6 @@ Lepton::CustomFunction* ReferenceCalcCustomExternalForceKernel::PeriodicDistance ...@@ -1548,10 +1470,6 @@ Lepton::CustomFunction* ReferenceCalcCustomExternalForceKernel::PeriodicDistance
return new PeriodicDistanceFunction(boxVectorHandle); return new PeriodicDistanceFunction(boxVectorHandle);
} }
ReferenceCalcCustomExternalForceKernel::~ReferenceCalcCustomExternalForceKernel() {
disposeRealArray(particleParamArray, numParticles);
}
void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, const CustomExternalForce& force) { void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, const CustomExternalForce& force) {
numParticles = force.getNumParticles(); numParticles = force.getNumParticles();
int numParameters = force.getNumPerParticleParameters(); int numParameters = force.getNumPerParticleParameters();
...@@ -1559,13 +1477,9 @@ void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, co ...@@ -1559,13 +1477,9 @@ void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, co
// Build the arrays. // Build the arrays.
particles.resize(numParticles); particles.resize(numParticles);
particleParamArray = allocateRealArray(numParticles, numParameters); particleParamArray.resize(numParticles);
vector<double> params; for (int i = 0; i < numParticles; ++i)
for (int i = 0; i < numParticles; ++i) { force.getParticleParameters(i, particles[i], particleParamArray[i]);
force.getParticleParameters(i, particles[i], params);
for (int j = 0; j < numParameters; j++)
particleParamArray[i][j] = params[j];
}
// Parse the expression used to calculate the force. // Parse the expression used to calculate the force.
...@@ -1624,8 +1538,6 @@ void ReferenceCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl ...@@ -1624,8 +1538,6 @@ void ReferenceCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl
} }
ReferenceCalcCustomHbondForceKernel::~ReferenceCalcCustomHbondForceKernel() { ReferenceCalcCustomHbondForceKernel::~ReferenceCalcCustomHbondForceKernel() {
disposeRealArray(donorParamArray, numDonors);
disposeRealArray(acceptorParamArray, numAcceptors);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1648,29 +1560,23 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const ...@@ -1648,29 +1560,23 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const
vector<vector<int> > donorParticles(numDonors); vector<vector<int> > donorParticles(numDonors);
int numDonorParameters = force.getNumPerDonorParameters(); int numDonorParameters = force.getNumPerDonorParameters();
donorParamArray = allocateRealArray(numDonors, numDonorParameters); donorParamArray.resize(numDonors);
for (int i = 0; i < numDonors; ++i) { for (int i = 0; i < numDonors; ++i) {
vector<double> parameters;
int d1, d2, d3; int d1, d2, d3;
force.getDonorParameters(i, d1, d2, d3, parameters); force.getDonorParameters(i, d1, d2, d3, donorParamArray[i]);
donorParticles[i].push_back(d1); donorParticles[i].push_back(d1);
donorParticles[i].push_back(d2); donorParticles[i].push_back(d2);
donorParticles[i].push_back(d3); donorParticles[i].push_back(d3);
for (int j = 0; j < numDonorParameters; j++)
donorParamArray[i][j] = parameters[j];
} }
vector<vector<int> > acceptorParticles(numAcceptors); vector<vector<int> > acceptorParticles(numAcceptors);
int numAcceptorParameters = force.getNumPerAcceptorParameters(); int numAcceptorParameters = force.getNumPerAcceptorParameters();
acceptorParamArray = allocateRealArray(numAcceptors, numAcceptorParameters); acceptorParamArray.resize(numAcceptors);
for (int i = 0; i < numAcceptors; ++i) { for (int i = 0; i < numAcceptors; ++i) {
vector<double> parameters;
int a1, a2, a3; int a1, a2, a3;
force.getAcceptorParameters(i, a1, a2, a3, parameters); force.getAcceptorParameters(i, a1, a2, a3, acceptorParamArray[i]);
acceptorParticles[i].push_back(a1); acceptorParticles[i].push_back(a1);
acceptorParticles[i].push_back(a2); acceptorParticles[i].push_back(a2);
acceptorParticles[i].push_back(a3); acceptorParticles[i].push_back(a3);
for (int j = 0; j < numAcceptorParameters; j++)
acceptorParamArray[i][j] = parameters[j];
} }
NonbondedMethod nonbondedMethod = CalcCustomHbondForceKernel::NonbondedMethod(force.getNonbondedMethod()); NonbondedMethod nonbondedMethod = CalcCustomHbondForceKernel::NonbondedMethod(force.getNonbondedMethod());
nonbondedCutoff = force.getCutoffDistance(); nonbondedCutoff = force.getCutoffDistance();
...@@ -1751,7 +1657,6 @@ void ReferenceCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& c ...@@ -1751,7 +1657,6 @@ void ReferenceCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& c
} }
ReferenceCalcCustomCentroidBondForceKernel::~ReferenceCalcCustomCentroidBondForceKernel() { ReferenceCalcCustomCentroidBondForceKernel::~ReferenceCalcCustomCentroidBondForceKernel() {
disposeRealArray(bondParamArray, numBonds);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1771,13 +1676,9 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system ...@@ -1771,13 +1676,9 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
vector<vector<int> > bondGroups(numBonds); vector<vector<int> > bondGroups(numBonds);
int numBondParameters = force.getNumPerBondParameters(); int numBondParameters = force.getNumPerBondParameters();
bondParamArray = allocateRealArray(numBonds, numBondParameters); bondParamArray.resize(numBonds);
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i)
vector<double> parameters; force.getBondParameters(i, bondGroups[i], bondParamArray[i]);
force.getBondParameters(i, bondGroups[i], parameters);
for (int j = 0; j < numBondParameters; j++)
bondParamArray[i][j] = parameters[j];
}
// Create custom functions for the tabulated functions. // Create custom functions for the tabulated functions.
...@@ -1848,7 +1749,6 @@ void ReferenceCalcCustomCentroidBondForceKernel::copyParametersToContext(Context ...@@ -1848,7 +1749,6 @@ void ReferenceCalcCustomCentroidBondForceKernel::copyParametersToContext(Context
} }
ReferenceCalcCustomCompoundBondForceKernel::~ReferenceCalcCustomCompoundBondForceKernel() { ReferenceCalcCustomCompoundBondForceKernel::~ReferenceCalcCustomCompoundBondForceKernel() {
disposeRealArray(bondParamArray, numBonds);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1861,13 +1761,9 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system ...@@ -1861,13 +1761,9 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
vector<vector<int> > bondParticles(numBonds); vector<vector<int> > bondParticles(numBonds);
int numBondParameters = force.getNumPerBondParameters(); int numBondParameters = force.getNumPerBondParameters();
bondParamArray = allocateRealArray(numBonds, numBondParameters); bondParamArray.resize(numBonds);
for (int i = 0; i < numBonds; ++i) { for (int i = 0; i < numBonds; ++i)
vector<double> parameters; force.getBondParameters(i, bondParticles[i], bondParamArray[i]);
force.getBondParameters(i, bondParticles[i], parameters);
for (int j = 0; j < numBondParameters; j++)
bondParamArray[i][j] = parameters[j];
}
// Create custom functions for the tabulated functions. // Create custom functions for the tabulated functions.
...@@ -1938,7 +1834,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context ...@@ -1938,7 +1834,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context
} }
ReferenceCalcCustomManyParticleForceKernel::~ReferenceCalcCustomManyParticleForceKernel() { ReferenceCalcCustomManyParticleForceKernel::~ReferenceCalcCustomManyParticleForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (ixn != NULL) if (ixn != NULL)
delete ixn; delete ixn;
} }
...@@ -1949,13 +1844,10 @@ void ReferenceCalcCustomManyParticleForceKernel::initialize(const System& system ...@@ -1949,13 +1844,10 @@ void ReferenceCalcCustomManyParticleForceKernel::initialize(const System& system
numParticles = system.getNumParticles(); numParticles = system.getNumParticles();
int numParticleParameters = force.getNumPerParticleParameters(); int numParticleParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numParticleParameters); particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i) {
vector<double> parameters;
int type; int type;
force.getParticleParameters(i, parameters, type); force.getParticleParameters(i, particleParamArray[i], type);
for (int j = 0; j < numParticleParameters; j++)
particleParamArray[i][j] = parameters[j];
} }
for (int i = 0; i < force.getNumGlobalParameters(); i++) for (int i = 0; i < force.getNumGlobalParameters(); i++)
globalParameterNames.push_back(force.getGlobalParameterName(i)); globalParameterNames.push_back(force.getGlobalParameterName(i));
......
...@@ -69,7 +69,7 @@ void ReferenceAngleBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -69,7 +69,7 @@ void ReferenceAngleBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double* angleParameters, void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, vector<double>& angleParameters,
double* dEdR, double* energyTerm) const { double* dEdR, double* energyTerm) const {
double angle; double angle;
...@@ -101,9 +101,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double* ...@@ -101,9 +101,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double*
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::calculateBondIxn(int* atomIndices, void ReferenceAngleBondIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
......
...@@ -64,9 +64,9 @@ ReferenceBondForce::~ReferenceBondForce() { ...@@ -64,9 +64,9 @@ ReferenceBondForce::~ReferenceBondForce() {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceBondForce::calculateForce(int numberOfBonds, int** atomIndices, void ReferenceBondForce::calculateForce(int numberOfBonds, vector<vector<int> >& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double** parameters, vector<vector<double> >& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double *totalEnergy, double *totalEnergy,
ReferenceBondIxn& referenceBondIxn) { ReferenceBondIxn& referenceBondIxn) {
......
...@@ -62,8 +62,8 @@ ReferenceBondIxn::~ReferenceBondIxn() { ...@@ -62,8 +62,8 @@ ReferenceBondIxn::~ReferenceBondIxn() {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceBondIxn::calculateBondIxn(int* atomIndices, vector<Vec3>& atomCoordinates, void ReferenceBondIxn::calculateBondIxn(vector<int>& atomIndices, vector<Vec3>& atomCoordinates,
double* parameters, vector<Vec3>& forces, vector<double>& parameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
} }
......
...@@ -206,6 +206,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<Vec3>& atomCoord ...@@ -206,6 +206,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<Vec3>& atomCoord
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCMAPTorsionIxn::calculateBondIxn(int* atomIndices, vector<Vec3>& atomCoordinates, void ReferenceCMAPTorsionIxn::calculateBondIxn(vector<int>& atomIndices, vector<Vec3>& atomCoordinates,
double* parameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) { vector<double>& parameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) {
} }
...@@ -81,9 +81,9 @@ void ReferenceCustomAngleIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -81,9 +81,9 @@ void ReferenceCustomAngleIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomAngleIxn::calculateBondIxn(int* atomIndices, void ReferenceCustomAngleIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[2][ReferenceForce::LastDeltaRIndex]; double deltaR[2][ReferenceForce::LastDeltaRIndex];
......
...@@ -82,9 +82,9 @@ void ReferenceCustomBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -82,9 +82,9 @@ void ReferenceCustomBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomBondIxn::calculateBondIxn(int* atomIndices, void ReferenceCustomBondIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
double deltaR[ReferenceForce::LastDeltaRIndex]; double deltaR[ReferenceForce::LastDeltaRIndex];
......
/* Portions copyright (c) 2009-2016 Stanford University and Simbios. /* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -93,7 +93,7 @@ void ReferenceCustomCentroidBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -93,7 +93,7 @@ void ReferenceCustomCentroidBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
boxVectors[2] = vectors[2]; boxVectors[2] = vectors[2];
} }
void ReferenceCustomCentroidBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, double** bondParameters, void ReferenceCustomCentroidBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& bondParameters,
const map<string, double>& globalParameters, vector<Vec3>& forces, const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
......
...@@ -116,7 +116,7 @@ void ReferenceCustomCompoundBondIxn::setPeriodic(OpenMM::Vec3* vectors) { ...@@ -116,7 +116,7 @@ void ReferenceCustomCompoundBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, double** bondParameters, void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& bondParameters,
const map<string, double>& globalParameters, vector<Vec3>& forces, const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) { double* totalEnergy, double* energyParamDerivs) {
for (auto& param : globalParameters) for (auto& param : globalParameters)
......
/* Portions copyright (c) 2009-2013 Stanford University and Simbios. /* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -94,7 +94,7 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn() { ...@@ -94,7 +94,7 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn() {
void ReferenceCustomExternalIxn::calculateForce(int atomIndex, void ReferenceCustomExternalIxn::calculateForce(int atomIndex,
vector<Vec3>& atomCoordinates, vector<Vec3>& atomCoordinates,
double* parameters, vector<double>& parameters,
vector<Vec3>& forces, vector<Vec3>& forces,
double* energy) const { double* energy) const {
......
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