"openmmapi/src/RGForce.cpp" did not exist on "d28df82861324d57f2329ddce588e33b79151cf0"
Commit 04ea8ce9 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed lots of errors and warnings compiling under Windows

parent a01da386
...@@ -41,11 +41,11 @@ SET(OPENMM_SOURCE_SUBDIRS . openmmapi olla platforms/reference) ...@@ -41,11 +41,11 @@ SET(OPENMM_SOURCE_SUBDIRS . openmmapi olla platforms/reference)
# SET(LIB64) # nothing # SET(LIB64) # nothing
#ENDIF (ARCH64) #ENDIF (ARCH64)
IF( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 ) IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
SET( LIB64 64 ) SET( LIB64 64 )
ELSE( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 ) ELSE( CMAKE_SIZEOF_VOID_P EQUAL 8 )
SET( LIB64 ) SET( LIB64 )
ENDIF( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 ) ENDIF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
IF(UNIX AND NOT CMAKE_BUILD_TYPE) IF(UNIX AND NOT CMAKE_BUILD_TYPE)
......
...@@ -68,7 +68,7 @@ class OPENMM_EXPORT StreamImpl; ...@@ -68,7 +68,7 @@ class OPENMM_EXPORT StreamImpl;
* may choose to implement it internally with single precision values. * may choose to implement it internally with single precision values.
*/ */
class Stream { class OPENMM_EXPORT Stream {
public: public:
Stream(); Stream();
Stream(const Stream& copy); Stream(const Stream& copy);
......
...@@ -43,7 +43,7 @@ namespace OpenMM { ...@@ -43,7 +43,7 @@ namespace OpenMM {
* A StreamImpl defines the internal implementation of a Stream object. * A StreamImpl defines the internal implementation of a Stream object.
*/ */
class StreamImpl { class OPENMM_EXPORT StreamImpl {
public: public:
/** /**
* Create a StreamImpl. * Create a StreamImpl.
......
...@@ -49,7 +49,7 @@ class System; ...@@ -49,7 +49,7 @@ class System;
* This is the internal implementation of an OpenMMContext. * This is the internal implementation of an OpenMMContext.
*/ */
class OpenMMContextImpl { class OPENMM_EXPORT OpenMMContextImpl {
public: public:
/** /**
* Create an OpenMMContextImpl for an OpenMMContext; * Create an OpenMMContextImpl for an OpenMMContext;
......
...@@ -41,7 +41,7 @@ namespace OpenMM { ...@@ -41,7 +41,7 @@ namespace OpenMM {
* This Platform subclass uses CUDA implementations of the OpenMM kernels to run on NVidia GPUs. * This Platform subclass uses CUDA implementations of the OpenMM kernels to run on NVidia GPUs.
*/ */
class CudaPlatform : public Platform { class OPENMM_EXPORT CudaPlatform : public Platform {
public: public:
CudaPlatform(); CudaPlatform();
std::string getName() const { std::string getName() const {
......
...@@ -40,7 +40,7 @@ namespace OpenMM { ...@@ -40,7 +40,7 @@ namespace OpenMM {
* This StreamFactory creates all streams for CudaPlatform. * This StreamFactory creates all streams for CudaPlatform.
*/ */
class CudaStreamFactory : public StreamFactory { class OPENMM_EXPORT CudaStreamFactory : public StreamFactory {
public: public:
StreamImpl* createStreamImpl(std::string name, int size, Stream::DataType type, const Platform& platform, OpenMMContextImpl& context) const; StreamImpl* createStreamImpl(std::string name, int size, Stream::DataType type, const Platform& platform, OpenMMContextImpl& context) const;
}; };
......
...@@ -70,8 +70,8 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >& ...@@ -70,8 +70,8 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >&
psBondID->_pSysStream[0][i].y = bondIndices[i][1]; psBondID->_pSysStream[0][i].y = bondIndices[i][1];
psBondID->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psBondID->_pSysStream[0][i].x]++; psBondID->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psBondID->_pSysStream[0][i].x]++;
psBondID->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psBondID->_pSysStream[0][i].y]++; psBondID->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psBondID->_pSysStream[0][i].y]++;
psBondParameter->_pSysStream[0][i].x = bondParameters[i][0]; psBondParameter->_pSysStream[0][i].x = (float) bondParameters[i][0];
psBondParameter->_pSysStream[0][i].y = bondParameters[i][1]; psBondParameter->_pSysStream[0][i].y = (float) bondParameters[i][1];
} }
psBondID->Upload(); psBondID->Upload();
psBondParameter->Upload(); psBondParameter->Upload();
...@@ -95,8 +95,8 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >& ...@@ -95,8 +95,8 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >&
psBondAngleID1->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psBondAngleID1->_pSysStream[0][i].x]++; psBondAngleID1->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psBondAngleID1->_pSysStream[0][i].x]++;
psBondAngleID2->_pSysStream[0][i].x = gpu->pOutputBufferCounter[psBondAngleID1->_pSysStream[0][i].y]++; psBondAngleID2->_pSysStream[0][i].x = gpu->pOutputBufferCounter[psBondAngleID1->_pSysStream[0][i].y]++;
psBondAngleID2->_pSysStream[0][i].y = gpu->pOutputBufferCounter[psBondAngleID1->_pSysStream[0][i].z]++; psBondAngleID2->_pSysStream[0][i].y = gpu->pOutputBufferCounter[psBondAngleID1->_pSysStream[0][i].z]++;
psBondAngleParameter->_pSysStream[0][i].x = angleParameters[i][0]*180.0/M_PI; psBondAngleParameter->_pSysStream[0][i].x = (float) (angleParameters[i][0]*180.0/3.14159265);
psBondAngleParameter->_pSysStream[0][i].y = angleParameters[i][1]; psBondAngleParameter->_pSysStream[0][i].y = (float) angleParameters[i][1];
} }
psBondAngleID1->Upload(); psBondAngleID1->Upload();
psBondAngleID2->Upload(); psBondAngleID2->Upload();
...@@ -123,9 +123,9 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >& ...@@ -123,9 +123,9 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >&
psDihedralID2->_pSysStream[0][i].y = gpu->pOutputBufferCounter[psDihedralID1->_pSysStream[0][i].y]++; psDihedralID2->_pSysStream[0][i].y = gpu->pOutputBufferCounter[psDihedralID1->_pSysStream[0][i].y]++;
psDihedralID2->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psDihedralID1->_pSysStream[0][i].z]++; psDihedralID2->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psDihedralID1->_pSysStream[0][i].z]++;
psDihedralID2->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psDihedralID1->_pSysStream[0][i].w]++; psDihedralID2->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psDihedralID1->_pSysStream[0][i].w]++;
psDihedralParameter->_pSysStream[0][i].x = periodicTorsionParameters[i][0]; psDihedralParameter->_pSysStream[0][i].x = (float) periodicTorsionParameters[i][0];
psDihedralParameter->_pSysStream[0][i].y = periodicTorsionParameters[i][1]; psDihedralParameter->_pSysStream[0][i].y = (float) periodicTorsionParameters[i][1];
psDihedralParameter->_pSysStream[0][i].z = periodicTorsionParameters[i][2]; psDihedralParameter->_pSysStream[0][i].z = (float) periodicTorsionParameters[i][2];
psDihedralParameter->_pSysStream[0][i].w = 0.0f; psDihedralParameter->_pSysStream[0][i].w = 0.0f;
} }
psDihedralID1->Upload(); psDihedralID1->Upload();
...@@ -156,12 +156,12 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >& ...@@ -156,12 +156,12 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >&
psRbDihedralID2->_pSysStream[0][i].y = gpu->pOutputBufferCounter[psRbDihedralID1->_pSysStream[0][i].y]++; psRbDihedralID2->_pSysStream[0][i].y = gpu->pOutputBufferCounter[psRbDihedralID1->_pSysStream[0][i].y]++;
psRbDihedralID2->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psRbDihedralID1->_pSysStream[0][i].z]++; psRbDihedralID2->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psRbDihedralID1->_pSysStream[0][i].z]++;
psRbDihedralID2->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psRbDihedralID1->_pSysStream[0][i].w]++; psRbDihedralID2->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psRbDihedralID1->_pSysStream[0][i].w]++;
psRbDihedralParameter1->_pSysStream[0][i].x = rbTorsionParameters[i][0]; psRbDihedralParameter1->_pSysStream[0][i].x = (float) rbTorsionParameters[i][0];
psRbDihedralParameter1->_pSysStream[0][i].y = rbTorsionParameters[i][1]; psRbDihedralParameter1->_pSysStream[0][i].y = (float) rbTorsionParameters[i][1];
psRbDihedralParameter1->_pSysStream[0][i].z = rbTorsionParameters[i][2]; psRbDihedralParameter1->_pSysStream[0][i].z = (float) rbTorsionParameters[i][2];
psRbDihedralParameter1->_pSysStream[0][i].w = rbTorsionParameters[i][3]; psRbDihedralParameter1->_pSysStream[0][i].w = (float) rbTorsionParameters[i][3];
psRbDihedralParameter2->_pSysStream[0][i].x = rbTorsionParameters[i][4]; psRbDihedralParameter2->_pSysStream[0][i].x = (float) rbTorsionParameters[i][4];
psRbDihedralParameter2->_pSysStream[0][i].y = rbTorsionParameters[i][5]; psRbDihedralParameter2->_pSysStream[0][i].y = (float) rbTorsionParameters[i][5];
} }
psRbDihedralID1->Upload(); psRbDihedralID1->Upload();
psRbDihedralID2->Upload(); psRbDihedralID2->Upload();
...@@ -171,9 +171,9 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >& ...@@ -171,9 +171,9 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >&
// Initialize nonbonded interactions. // Initialize nonbonded interactions.
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numAtoms; i++) {
gpu->psPosq4->_pSysStream[0][i].w = nonbondedParameters[i][0]; gpu->psPosq4->_pSysStream[0][i].w = (float) nonbondedParameters[i][0];
gpu->psSigEps2->_pSysStream[0][i].x = nonbondedParameters[i][1]; gpu->psSigEps2->_pSysStream[0][i].x = (float) nonbondedParameters[i][1];
gpu->psSigEps2->_pSysStream[0][i].y = nonbondedParameters[i][2]; gpu->psSigEps2->_pSysStream[0][i].y = (float) nonbondedParameters[i][2];
} }
gpu->psPosq4->Upload(); gpu->psPosq4->Upload();
gpu->psSigEps2->Upload(); gpu->psSigEps2->Upload();
...@@ -197,9 +197,9 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >& ...@@ -197,9 +197,9 @@ void CudaCalcStandardMMForceFieldKernel::initialize(const vector<vector<int> >&
psLJ14ID->_pSysStream[0][i].y = atom2; psLJ14ID->_pSysStream[0][i].y = atom2;
psLJ14ID->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psLJ14ID->_pSysStream[0][i].x]++; psLJ14ID->_pSysStream[0][i].z = gpu->pOutputBufferCounter[psLJ14ID->_pSysStream[0][i].x]++;
psLJ14ID->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psLJ14ID->_pSysStream[0][i].y]++; psLJ14ID->_pSysStream[0][i].w = gpu->pOutputBufferCounter[psLJ14ID->_pSysStream[0][i].y]++;
psLJ14Parameter->_pSysStream[0][i].x = atom1params[0]+atom2params[0]; psLJ14Parameter->_pSysStream[0][i].x = (float) (atom1params[0]+atom2params[0]);
psLJ14Parameter->_pSysStream[0][i].y = lj14Scale*(atom1params[1]*atom2params[1]); psLJ14Parameter->_pSysStream[0][i].y = (float) (lj14Scale*(atom1params[1]*atom2params[1]));
psLJ14Parameter->_pSysStream[0][i].z = coulomb14Scale*(atom1params[2]*atom2params[2]); psLJ14Parameter->_pSysStream[0][i].z = (float) (coulomb14Scale*(atom1params[2]*atom2params[2]));
} }
psLJ14ID->Upload(); psLJ14ID->Upload();
psLJ14Parameter->Upload(); psLJ14Parameter->Upload();
...@@ -217,6 +217,7 @@ void CudaCalcStandardMMForceFieldKernel::executeForces(const Stream& positions, ...@@ -217,6 +217,7 @@ void CudaCalcStandardMMForceFieldKernel::executeForces(const Stream& positions,
} }
double CudaCalcStandardMMForceFieldKernel::executeEnergy(const Stream& positions) { double CudaCalcStandardMMForceFieldKernel::executeEnergy(const Stream& positions) {
return 0.0;
} }
//CudaCalcGBSAOBCForceFieldKernel::~CudaCalcGBSAOBCForceFieldKernel() { //CudaCalcGBSAOBCForceFieldKernel::~CudaCalcGBSAOBCForceFieldKernel() {
......
...@@ -141,15 +141,15 @@ void CudaStreamImpl<T>::loadFromArray(const void* array) { ...@@ -141,15 +141,15 @@ void CudaStreamImpl<T>::loadFromArray(const void* array) {
double* arrayData = (double*) array; double* arrayData = (double*) array;
for (int i = 0; i < getSize(); ++i) for (int i = 0; i < getSize(); ++i)
for (int j = 0; j < width; ++j) for (int j = 0; j < width; ++j)
data[i*rowOffset+j] = arrayData[i*width+j]; data[i*rowOffset+j] = (float) arrayData[i*width+j];
} }
else { else {
int* arrayData = (int*) array; int* arrayData = (int*) array;
for (int i = 0; i < getSize(); ++i) for (int i = 0; i < getSize(); ++i)
for (int j = 0; j < width; ++j) for (int j = 0; j < width; ++j)
data[i*rowOffset+j] = arrayData[i*width+j]; data[i*rowOffset+j] = (float) arrayData[i*width+j];
} }
for (int i = getSize(); i < stream->_length; ++i) for (int i = getSize(); i < (int) stream->_length; ++i)
for (int j = 0; j < rowOffset; ++j) for (int j = 0; j < rowOffset; ++j)
data[i*rowOffset+j] = paddingValues[j]; data[i*rowOffset+j] = paddingValues[j];
stream->Upload(); stream->Upload();
...@@ -174,7 +174,7 @@ void CudaStreamImpl<T>::saveToArray(void* array) { ...@@ -174,7 +174,7 @@ void CudaStreamImpl<T>::saveToArray(void* array) {
int* arrayData = (int*) array; int* arrayData = (int*) array;
for (int i = 0; i < getSize(); ++i) for (int i = 0; i < getSize(); ++i)
for (int j = 0; j < width; ++j) for (int j = 0; j < width; ++j)
arrayData[i*width+j] = data[i*rowOffset+j]; arrayData[i*width+j] = (int) data[i*rowOffset+j];
} }
stream->Download(); stream->Download();
} }
...@@ -192,15 +192,15 @@ void CudaStreamImpl<T>::fillWithValue(void* value) { ...@@ -192,15 +192,15 @@ void CudaStreamImpl<T>::fillWithValue(void* value) {
double valueData = *((double*) value); double valueData = *((double*) value);
for (int i = 0; i < getSize(); ++i) for (int i = 0; i < getSize(); ++i)
for (int j = 0; j < width; ++j) for (int j = 0; j < width; ++j)
data[i*rowOffset+j] = valueData; data[i*rowOffset+j] = (float) valueData;
} }
else { else {
int valueData = *((int*) value); int valueData = *((int*) value);
for (int i = 0; i < getSize(); ++i) for (int i = 0; i < getSize(); ++i)
for (int j = 0; j < width; ++j) for (int j = 0; j < width; ++j)
data[i*rowOffset+j] = valueData; data[i*rowOffset+j] = (float) valueData;
} }
for (int i = getSize(); i < stream->_length; ++i) for (int i = getSize(); i < (int) stream->_length; ++i)
for (int j = 0; j < rowOffset; ++j) for (int j = 0; j < rowOffset; ++j)
data[i*rowOffset+j] = paddingValues[j]; data[i*rowOffset+j] = paddingValues[j];
stream->Upload(); stream->Upload();
......
...@@ -71,16 +71,16 @@ void testStream(Stream::DataType type, T scale) { ...@@ -71,16 +71,16 @@ void testStream(Stream::DataType type, T scale) {
array[i] = 0; array[i] = 0;
stream.saveToArray(array); stream.saveToArray(array);
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
ASSERT_EQUAL_TOL((i*scale), array[i], TOL); ASSERT_EQUAL_TOL((double) (i*scale), array[i], TOL);
ASSERT_EQUAL_TOL(0, array[length], TOL); ASSERT_EQUAL_TOL(0.0, (double) array[length], TOL);
} }
int main() { int main() {
try { try {
testStream<float, 1>(Stream::Float, 0.1); testStream<float, 1>(Stream::Float, 0.1f);
testStream<float, 2>(Stream::Float2, 0.1); testStream<float, 2>(Stream::Float2, 0.1f);
testStream<float, 3>(Stream::Float3, 0.1); testStream<float, 3>(Stream::Float3, 0.1f);
testStream<float, 4>(Stream::Float4, 0.1); testStream<float, 4>(Stream::Float4, 0.1f);
testStream<double, 1>(Stream::Double, 0.1); testStream<double, 1>(Stream::Double, 0.1);
testStream<double, 2>(Stream::Double2, 0.1); testStream<double, 2>(Stream::Double2, 0.1);
testStream<double, 3>(Stream::Double3, 0.1); testStream<double, 3>(Stream::Double3, 0.1);
......
...@@ -164,10 +164,10 @@ void ReferenceCalcStandardMMForceFieldKernel::initialize(const vector<vector<int ...@@ -164,10 +164,10 @@ void ReferenceCalcStandardMMForceFieldKernel::initialize(const vector<vector<int
bonded14ParamArray[i][2] = static_cast<RealOpenMM>( coulomb14Scale*(atomParamArray[atom1][2]*atomParamArray[atom2][2]) ); bonded14ParamArray[i][2] = static_cast<RealOpenMM>( coulomb14Scale*(atomParamArray[atom1][2]*atomParamArray[atom2][2]) );
} }
this->nonbondedMethod = nonbondedMethod; this->nonbondedMethod = nonbondedMethod;
this->nonbondedCutoff = nonbondedCutoff; this->nonbondedCutoff = (RealOpenMM) nonbondedCutoff;
this->periodicBoxSize[0] = periodicBoxSize[0]; this->periodicBoxSize[0] = (RealOpenMM) periodicBoxSize[0];
this->periodicBoxSize[1] = periodicBoxSize[1]; this->periodicBoxSize[1] = (RealOpenMM) periodicBoxSize[1];
this->periodicBoxSize[2] = periodicBoxSize[2]; this->periodicBoxSize[2] = (RealOpenMM) periodicBoxSize[2];
if (nonbondedMethod == NoCutoff) if (nonbondedMethod == NoCutoff)
neighborList = NULL; neighborList = NULL;
else else
...@@ -191,14 +191,14 @@ void ReferenceCalcStandardMMForceFieldKernel::executeForces(const Stream& positi ...@@ -191,14 +191,14 @@ void ReferenceCalcStandardMMForceFieldKernel::executeForces(const Stream& positi
bool periodic = (nonbondedMethod == CutoffPeriodic); bool periodic = (nonbondedMethod == CutoffPeriodic);
if (nonbondedMethod != NoCutoff) { if (nonbondedMethod != NoCutoff) {
computeNeighborListVoxelHash(*neighborList, numAtoms, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0); computeNeighborListVoxelHash(*neighborList, numAtoms, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0);
clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3); clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3f);
} }
if (periodic) if (periodic)
clj.setPeriodic(periodicBoxSize); clj.setPeriodic(periodicBoxSize);
clj.calculatePairIxn(numAtoms, posData, atomParamArray, exclusionArray, 0, forceData, 0, 0); clj.calculatePairIxn(numAtoms, posData, atomParamArray, exclusionArray, 0, forceData, 0, 0);
ReferenceLJCoulomb14 nonbonded14; ReferenceLJCoulomb14 nonbonded14;
if (nonbondedMethod != NoCutoff) if (nonbondedMethod != NoCutoff)
nonbonded14.setUseCutoff(nonbondedCutoff, 78.3); nonbonded14.setUseCutoff(nonbondedCutoff, 78.3f);
refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, 0, 0, 0, nonbonded14); refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, 0, 0, 0, nonbonded14);
} }
...@@ -229,14 +229,14 @@ double ReferenceCalcStandardMMForceFieldKernel::executeEnergy(const Stream& posi ...@@ -229,14 +229,14 @@ double ReferenceCalcStandardMMForceFieldKernel::executeEnergy(const Stream& posi
bool periodic = (nonbondedMethod == CutoffPeriodic); bool periodic = (nonbondedMethod == CutoffPeriodic);
if (nonbondedMethod != NoCutoff) { if (nonbondedMethod != NoCutoff) {
computeNeighborListVoxelHash(*neighborList, numAtoms, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0); computeNeighborListVoxelHash(*neighborList, numAtoms, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0);
clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3); clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3f);
} }
if (periodic) if (periodic)
clj.setPeriodic(periodicBoxSize); clj.setPeriodic(periodicBoxSize);
clj.calculatePairIxn(numAtoms, posData, atomParamArray, exclusionArray, 0, forceData, 0, &energy); clj.calculatePairIxn(numAtoms, posData, atomParamArray, exclusionArray, 0, forceData, 0, &energy);
ReferenceLJCoulomb14 nonbonded14; ReferenceLJCoulomb14 nonbonded14;
if (nonbondedMethod != NoCutoff) if (nonbondedMethod != NoCutoff)
nonbonded14.setUseCutoff(nonbondedCutoff, 78.3); nonbonded14.setUseCutoff(nonbondedCutoff, 78.3f);
for (int i = 0; i < arraySize; ++i) for (int i = 0; i < arraySize; ++i)
energyArray[i] = 0; energyArray[i] = 0;
refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, energyArray, 0, &energy, nonbonded14); refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, energyArray, 0, &energy, nonbonded14);
......
...@@ -70,7 +70,7 @@ ReferenceForce::~ReferenceForce( ){ ...@@ -70,7 +70,7 @@ ReferenceForce::~ReferenceForce( ){
RealOpenMM ReferenceForce::periodicDifference(RealOpenMM val1, RealOpenMM val2, RealOpenMM period) { RealOpenMM ReferenceForce::periodicDifference(RealOpenMM val1, RealOpenMM val2, RealOpenMM period) {
RealOpenMM diff = val1-val2; RealOpenMM diff = val1-val2;
RealOpenMM base = floor(diff/period+0.5)*period; RealOpenMM base = (RealOpenMM) (floor(diff/period+0.5)*period);
return diff-base; return diff-base;
} }
......
...@@ -78,8 +78,8 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){ ...@@ -78,8 +78,8 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){
cutoff = true; cutoff = true;
cutoffDistance = distance; cutoffDistance = distance;
krf = pow(cutoffDistance, -3.0)*(solventDielectric-1.0)/(2.0*solventDielectric+1.0); krf = pow(cutoffDistance, -3.0f)*(solventDielectric-1.0f)/(2.0f*solventDielectric+1.0f);
crf = (1.0/cutoffDistance)*(3.0*solventDielectric)/(2.0*solventDielectric+1.0); crf = (1.0f/cutoffDistance)*(3.0f*solventDielectric)/(2.0f*solventDielectric+1.0f);
return ReferenceForce::DefaultReturn; return ReferenceForce::DefaultReturn;
} }
...@@ -202,7 +202,7 @@ int ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, RealOpenMM** atomC ...@@ -202,7 +202,7 @@ int ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, RealOpenMM** atomC
RealOpenMM dEdR = parameters[1]*( twelve*sig6 - six )*sig6; RealOpenMM dEdR = parameters[1]*( twelve*sig6 - six )*sig6;
if (cutoff) if (cutoff)
dEdR += parameters[2]*(inverseR-2.0*krf*r2); dEdR += parameters[2]*(inverseR-2.0f*krf*r2);
else else
dEdR += parameters[2]*inverseR; dEdR += parameters[2]*inverseR;
dEdR *= inverseR*inverseR; dEdR *= inverseR*inverseR;
......
...@@ -80,8 +80,8 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){ ...@@ -80,8 +80,8 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
cutoff = true; cutoff = true;
cutoffDistance = distance; cutoffDistance = distance;
neighborList = &neighbors; neighborList = &neighbors;
krf = pow(cutoffDistance, -3.0)*(solventDielectric-1.0)/(2.0*solventDielectric+1.0); krf = pow(cutoffDistance, -3.0f)*(solventDielectric-1.0f)/(2.0f*solventDielectric+1.0f);
crf = (1.0/cutoffDistance)*(3.0*solventDielectric)/(2.0*solventDielectric+1.0); crf = (1.0f/cutoffDistance)*(3.0f*solventDielectric)/(2.0f*solventDielectric+1.0f);
return ReferenceForce::DefaultReturn; return ReferenceForce::DefaultReturn;
} }
...@@ -190,7 +190,7 @@ int ReferenceLJCoulombIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** ato ...@@ -190,7 +190,7 @@ int ReferenceLJCoulombIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** ato
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const { RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const {
if (cutoff) { if (cutoff) {
for (int i = 0; i < neighborList->size(); i++) { for (int i = 0; i < (int) neighborList->size(); i++) {
OpenMM::AtomPair pair = (*neighborList)[i]; OpenMM::AtomPair pair = (*neighborList)[i];
calculateOneIxn(pair.first, pair.second, atomCoordinates, atomParameters, forces, energyByAtom, totalEnergy); calculateOneIxn(pair.first, pair.second, atomCoordinates, atomParameters, forces, energyByAtom, totalEnergy);
} }
...@@ -290,7 +290,7 @@ int ReferenceLJCoulombIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** ato ...@@ -290,7 +290,7 @@ int ReferenceLJCoulombIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** ato
RealOpenMM eps = atomParameters[ii][EpsIndex]*atomParameters[jj][EpsIndex]; RealOpenMM eps = atomParameters[ii][EpsIndex]*atomParameters[jj][EpsIndex];
RealOpenMM dEdR = eps*( twelve*sig6 - six )*sig6; RealOpenMM dEdR = eps*( twelve*sig6 - six )*sig6;
if (cutoff) if (cutoff)
dEdR += atomParameters[ii][QIndex]*atomParameters[jj][QIndex]*(inverseR-2.0*krf*r2); dEdR += atomParameters[ii][QIndex]*atomParameters[jj][QIndex]*(inverseR-2.0f*krf*r2);
else else
dEdR += atomParameters[ii][QIndex]*atomParameters[jj][QIndex]*inverseR; dEdR += atomParameters[ii][QIndex]*atomParameters[jj][QIndex]*inverseR;
dEdR *= inverseR*inverseR; dEdR *= inverseR*inverseR;
...@@ -373,5 +373,6 @@ int ReferenceLJCoulombIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** ato ...@@ -373,5 +373,6 @@ int ReferenceLJCoulombIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** ato
SimTKOpenMMLog::printMessage( message ); SimTKOpenMMLog::printMessage( message );
} }
return ReferenceForce::DefaultReturn;
} }
#ifndef OPENMM_REFERENCE_NEIGHBORLIST_H_
#define OPENMM_REFERENCE_NEIGHBORLIST_H_
#include "../SimTKUtilities/SimTKOpenMMRealType.h"
#include "internal/windowsExport.h"
#include <set>
#include <vector>
namespace OpenMM {
typedef RealOpenMM** AtomLocationList;
typedef unsigned int AtomIndex;
typedef std::pair<AtomIndex, AtomIndex> AtomPair;
typedef std::vector<AtomPair> NeighborList;
// Ridiculous O(n^2) version of neighbor list
// for pedagogical purposes and simplicity
// parameter neighborList is automatically clear()ed before
// neighbors are added
void OPENMM_EXPORT computeNeighborListNaive(
NeighborList& neighborList,
int nAtoms,
const AtomLocationList& atomLocations,
const std::vector<std::set<int> >& exclusions,
const RealOpenMM* periodicBoxSize,
double maxDistance,
double minDistance = 0.0,
bool reportSymmetricPairs = false
);
// O(n) neighbor list method using voxel hash data structure
// parameter neighborList is automatically clear()ed before
// neighbors are added
void OPENMM_EXPORT computeNeighborListVoxelHash(
NeighborList& neighborList,
int nAtoms,
const AtomLocationList& atomLocations,
const std::vector<std::set<int> >& exclusions,
const RealOpenMM* periodicBoxSize,
double maxDistance,
double minDistance = 0.0,
bool reportSymmetricPairs = false
);
} // namespace OpenMM
#endif // OPENMM_REFERENCE_NEIGHBORLIST_H_
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <map> #include <map>
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
#include <cassert>
using namespace std; using namespace std;
...@@ -34,7 +35,7 @@ static double compPairDistanceSquared(const RealOpenMM* pos1, const RealOpenMM* ...@@ -34,7 +35,7 @@ static double compPairDistanceSquared(const RealOpenMM* pos1, const RealOpenMM*
// Ridiculous O(n^2) version of neighbor list // Ridiculous O(n^2) version of neighbor list
// for pedagogical purposes and simplicity // for pedagogical purposes and simplicity
void computeNeighborListNaive( void OPENMM_EXPORT computeNeighborListNaive(
NeighborList& neighborList, NeighborList& neighborList,
int nAtoms, int nAtoms,
const AtomLocationList& atomLocations, const AtomLocationList& atomLocations,
...@@ -50,9 +51,9 @@ void computeNeighborListNaive( ...@@ -50,9 +51,9 @@ void computeNeighborListNaive(
double maxDistanceSquared = maxDistance * maxDistance; double maxDistanceSquared = maxDistance * maxDistance;
double minDistanceSquared = minDistance * minDistance; double minDistanceSquared = minDistance * minDistance;
for (AtomIndex atomI = 0; atomI < (nAtoms - 1); ++atomI) for (AtomIndex atomI = 0; atomI < (AtomIndex) (nAtoms - 1); ++atomI)
{ {
for (AtomIndex atomJ = atomI + 1; atomJ < nAtoms; ++atomJ) for (AtomIndex atomJ = atomI + 1; atomJ < (AtomIndex) nAtoms; ++atomJ)
{ {
double pairDistanceSquared = compPairDistanceSquared(atomLocations[atomI], atomLocations[atomJ], periodicBoxSize); double pairDistanceSquared = compPairDistanceSquared(atomLocations[atomI], atomLocations[atomJ], periodicBoxSize);
if ( (pairDistanceSquared <= maxDistanceSquared) && (pairDistanceSquared >= minDistanceSquared)) if ( (pairDistanceSquared <= maxDistanceSquared) && (pairDistanceSquared >= minDistanceSquared))
...@@ -97,9 +98,9 @@ public: ...@@ -97,9 +98,9 @@ public:
VoxelHash(double vsx, double vsy, double vsz, const RealOpenMM* periodicBoxSize) : VoxelHash(double vsx, double vsy, double vsz, const RealOpenMM* periodicBoxSize) :
voxelSizeX(vsx), voxelSizeY(vsy), voxelSizeZ(vsz), periodicBoxSize(periodicBoxSize) { voxelSizeX(vsx), voxelSizeY(vsy), voxelSizeZ(vsz), periodicBoxSize(periodicBoxSize) {
if (periodicBoxSize != NULL) { if (periodicBoxSize != NULL) {
nx = floor(periodicBoxSize[0]/voxelSizeX+0.5); nx = (int) floor(periodicBoxSize[0]/voxelSizeX+0.5);
ny = floor(periodicBoxSize[1]/voxelSizeY+0.5); ny = (int) floor(periodicBoxSize[1]/voxelSizeY+0.5);
nz = floor(periodicBoxSize[2]/voxelSizeZ+0.5); nz = (int) floor(periodicBoxSize[2]/voxelSizeZ+0.5);
} }
} }
...@@ -213,7 +214,7 @@ private: ...@@ -213,7 +214,7 @@ private:
// O(n) neighbor list method using voxel hash data structure // O(n) neighbor list method using voxel hash data structure
void computeNeighborListVoxelHash( void OPENMM_EXPORT computeNeighborListVoxelHash(
NeighborList& neighborList, NeighborList& neighborList,
int nAtoms, int nAtoms,
const AtomLocationList& atomLocations, const AtomLocationList& atomLocations,
...@@ -235,7 +236,7 @@ void computeNeighborListVoxelHash( ...@@ -235,7 +236,7 @@ void computeNeighborListVoxelHash(
edgeSizeZ = periodicBoxSize[2]/floor(periodicBoxSize[2]/maxDistance); edgeSizeZ = periodicBoxSize[2]/floor(periodicBoxSize[2]/maxDistance);
} }
VoxelHash voxelHash(edgeSizeX, edgeSizeY, edgeSizeZ, periodicBoxSize); VoxelHash voxelHash(edgeSizeX, edgeSizeY, edgeSizeZ, periodicBoxSize);
for (AtomIndex atomJ = 0; atomJ < nAtoms; ++atomJ) // use "j", because j > i for pairs for (AtomIndex atomJ = 0; atomJ < (AtomIndex) nAtoms; ++atomJ) // use "j", because j > i for pairs
{ {
// 1) Find other atoms that are close to this one // 1) Find other atoms that are close to this one
const RealOpenMM* location = atomLocations[atomJ]; const RealOpenMM* location = atomLocations[atomJ];
......
This diff is collapsed.
...@@ -13,7 +13,7 @@ void testNeighborList() ...@@ -13,7 +13,7 @@ void testNeighborList()
atomList[0] = new RealOpenMM[3]; atomList[0] = new RealOpenMM[3];
atomList[1] = new RealOpenMM[3]; atomList[1] = new RealOpenMM[3];
atomList[2] = new RealOpenMM[3]; atomList[2] = new RealOpenMM[3];
atomList[0][0] = 13.6; atomList[0][0] = 13.6f;
atomList[0][1] = 0; atomList[0][1] = 0;
atomList[0][2] = 0; atomList[0][2] = 0;
atomList[1][0] = 0; atomList[1][0] = 0;
...@@ -54,7 +54,7 @@ double distance2(RealOpenMM* pos1, RealOpenMM* pos2, const RealOpenMM* periodicB ...@@ -54,7 +54,7 @@ double distance2(RealOpenMM* pos1, RealOpenMM* pos2, const RealOpenMM* periodicB
} }
void verifyNeighborList(NeighborList& list, int numAtoms, RealOpenMM** positions, const RealOpenMM* periodicBoxSize, double cutoff) { void verifyNeighborList(NeighborList& list, int numAtoms, RealOpenMM** positions, const RealOpenMM* periodicBoxSize, double cutoff) {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < (int) list.size(); i++) {
int atom1 = list[i].first; int atom1 = list[i].first;
int atom2 = list[i].second; int atom2 = list[i].second;
ASSERT(distance2(positions[atom1], positions[atom2], periodicBoxSize) <= cutoff*cutoff); ASSERT(distance2(positions[atom1], positions[atom2], periodicBoxSize) <= cutoff*cutoff);
...@@ -75,9 +75,9 @@ void testPeriodic() { ...@@ -75,9 +75,9 @@ void testPeriodic() {
init_gen_rand(0); init_gen_rand(0);
for (int i = 0; i <numAtoms; i++) { for (int i = 0; i <numAtoms; i++) {
atomList[i] = new RealOpenMM[3]; atomList[i] = new RealOpenMM[3];
atomList[i][0] = genrand_real2()*periodicBoxSize[0]*3; atomList[i][0] = (RealOpenMM) (genrand_real2()*periodicBoxSize[0]*3);
atomList[i][1] = genrand_real2()*periodicBoxSize[1]*3; atomList[i][1] = (RealOpenMM) (genrand_real2()*periodicBoxSize[1]*3);
atomList[i][2] = genrand_real2()*periodicBoxSize[2]*3; atomList[i][2] = (RealOpenMM) (genrand_real2()*periodicBoxSize[2]*3);
} }
vector<set<int> > exclusions(numAtoms); vector<set<int> > exclusions(numAtoms);
NeighborList neighborList; NeighborList neighborList;
......
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