Commit 8469621f authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1747 from peastman/realtype

Eliminated RealOpenMM
parents b84e22ba 6813ca57
...@@ -231,7 +231,7 @@ IF (NOT (ANDROID OR PNACL OR (WIN32 AND OPENMM_BUILD_STATIC_LIB))) ...@@ -231,7 +231,7 @@ IF (NOT (ANDROID OR PNACL OR (WIN32 AND OPENMM_BUILD_STATIC_LIB)))
SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files}) SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files})
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit") INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit")
SET(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DLEPTON_USE_JIT") SET(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DLEPTON_USE_JIT")
ENDIF (NOT (ANDROID OR PNACL)) ENDIF (NOT (ANDROID OR PNACL OR (WIN32 AND OPENMM_BUILD_STATIC_LIB)))
# If API wrappers are being generated, and add them to the build. # If API wrappers are being generated, and add them to the build.
SET(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS ON CACHE BOOL "Build wrappers for C and Fortran") SET(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS ON CACHE BOOL "Build wrappers for C and Fortran")
......
...@@ -317,16 +317,6 @@ that is the goal.) When implementing a new feature, it is recommended to create ...@@ -317,16 +317,6 @@ that is the goal.) When implementing a new feature, it is recommended to create
the reference implementation first, then use that as a model for the versions in the reference implementation first, then use that as a model for the versions in
other Platforms. other Platforms.
The reference Platform represents all floating point numbers with the type
RealOpenMM, which is defined in SimTKOpenMMRealType.h. This allows the entire
platform to be compiled in either single or double precision. By default it is
double precision, but it can be changed by modifying one flag at the top of that
file. The same file also defines lots of numerical constants and mathematical
functions, so the correct precision version will always be used. Vector
quantities (positions, velocities, etc.) are represented by RealVec objects.
This class is identical to Vec3, except that its components are of type
RealOpenMM instead of double.
When using the reference Platform, the “platform-specific data” stored in When using the reference Platform, the “platform-specific data” stored in
ContextImpl is of type ReferencePlatform::PlatformData, which is declared in ContextImpl is of type ReferencePlatform::PlatformData, which is declared in
ReferencePlatform.h. Several of the fields in this class are declared as void* ReferencePlatform.h. Several of the fields in this class are declared as void*
......
...@@ -54,13 +54,13 @@ public: ...@@ -54,13 +54,13 @@ public:
/** /**
* Compute the forces from all bonds. * Compute the forces from all bonds.
*/ */
void calculateForce(std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMM** parameters, std::vector<OpenMM::RealVec>& forces, void calculateForce(std::vector<OpenMM::Vec3>& atomCoordinates, double** parameters, std::vector<OpenMM::Vec3>& forces,
RealOpenMM* totalEnergy, ReferenceBondIxn& referenceBondIxn); double* totalEnergy, ReferenceBondIxn& referenceBondIxn);
/** /**
* This routine contains the code executed by each thread. * This routine contains the code executed by each thread.
*/ */
void threadComputeForce(ThreadPool& threads, int threadIndex, std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMM** parameters, void threadComputeForce(ThreadPool& threads, int threadIndex, std::vector<OpenMM::Vec3>& atomCoordinates, double** parameters,
std::vector<OpenMM::RealVec>& forces, RealOpenMM* totalEnergy, ReferenceBondIxn& referenceBondIxn); std::vector<OpenMM::Vec3>& forces, double* totalEnergy, ReferenceBondIxn& referenceBondIxn);
private: private:
bool canAssignBond(int bond, int thread, std::vector<int>& atomThread); bool canAssignBond(int bond, int thread, std::vector<int>& atomThread);
void assignBond(int bond, int thread, std::vector<int>& atomThread, std::vector<int>& bondThread, std::vector<std::set<int> >& atomBonds, std::list<int>& candidateBonds); void assignBond(int bond, int thread, std::vector<int>& atomThread, std::vector<int>& bondThread, std::vector<std::set<int> >& atomBonds, std::list<int>& candidateBonds);
......
...@@ -59,7 +59,7 @@ private: ...@@ -59,7 +59,7 @@ private:
// The following variables are used to make information accessible to the individual threads. // The following variables are used to make information accessible to the individual threads.
int numberOfAtoms; int numberOfAtoms;
float* posq; float* posq;
RealOpenMM** atomParameters; double** atomParameters;
const std::map<std::string, double>* globalParameters; const std::map<std::string, double>* globalParameters;
std::vector<AlignedArray<float> >* threadForce; std::vector<AlignedArray<float> >* threadForce;
bool includeForce, includeEnergy; bool includeForce, includeEnergy;
...@@ -81,7 +81,7 @@ private: ...@@ -81,7 +81,7 @@ private:
* @param useExclusions specifies whether to use exclusions * @param useExclusions specifies whether to use exclusions
*/ */
void calculateParticlePairValue(int index, ThreadData& data, int numAtoms, float* posq, RealOpenMM** atomParameters, void calculateParticlePairValue(int index, ThreadData& data, int numAtoms, float* posq, double** atomParameters,
bool useExclusions, const fvec4& boxSize, const fvec4& invBoxSize); bool useExclusions, const fvec4& boxSize, const fvec4& invBoxSize);
/** /**
...@@ -95,7 +95,7 @@ private: ...@@ -95,7 +95,7 @@ private:
* @param atomParameters atomParameters[atomIndex][paramterIndex] * @param atomParameters atomParameters[atomIndex][paramterIndex]
*/ */
void calculateOnePairValue(int index, int atom1, int atom2, ThreadData& data, float* posq, RealOpenMM** atomParameters, void calculateOnePairValue(int index, int atom1, int atom2, ThreadData& data, float* posq, double** atomParameters,
std::vector<float>& valueArray, const fvec4& boxSize, const fvec4& invBoxSize); std::vector<float>& valueArray, const fvec4& boxSize, const fvec4& invBoxSize);
/** /**
...@@ -110,7 +110,7 @@ private: ...@@ -110,7 +110,7 @@ private:
* @param totalEnergy the energy contribution is added to this * @param totalEnergy the energy contribution is added to this
*/ */
void calculateSingleParticleEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq, RealOpenMM** atomParameters, float* forces, double& totalEnergy); void calculateSingleParticleEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq, double** atomParameters, float* forces, double& totalEnergy);
/** /**
* Calculate an energy term that is based on particle pairs * Calculate an energy term that is based on particle pairs
...@@ -125,7 +125,7 @@ private: ...@@ -125,7 +125,7 @@ private:
* @param totalEnergy the energy contribution is added to this * @param totalEnergy the energy contribution is added to this
*/ */
void calculateParticlePairEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq, RealOpenMM** atomParameters, void calculateParticlePairEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq, double** atomParameters,
bool useExclusions, float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize); bool useExclusions, float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize);
/** /**
...@@ -141,7 +141,7 @@ private: ...@@ -141,7 +141,7 @@ private:
* @param totalEnergy the energy contribution is added to this * @param totalEnergy the energy contribution is added to this
*/ */
void calculateOnePairEnergyTerm(int index, int atom1, int atom2, ThreadData& data, float* posq, RealOpenMM** atomParameters, void calculateOnePairEnergyTerm(int index, int atom1, int atom2, ThreadData& data, float* posq, double** atomParameters,
float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize); float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize);
/** /**
...@@ -154,7 +154,7 @@ private: ...@@ -154,7 +154,7 @@ private:
* @param forces forces on atoms are added to this * @param forces forces on atoms are added to this
*/ */
void calculateChainRuleForces(ThreadData& data, int numAtoms, float* posq, RealOpenMM** atomParameters, void calculateChainRuleForces(ThreadData& data, int numAtoms, float* posq, double** atomParameters,
float* forces, const fvec4& boxSize, const fvec4& invBoxSize); float* forces, const fvec4& boxSize, const fvec4& invBoxSize);
/** /**
...@@ -169,7 +169,7 @@ private: ...@@ -169,7 +169,7 @@ private:
* @param isExcluded specifies whether this is an excluded pair * @param isExcluded specifies whether this is an excluded pair
*/ */
void calculateOnePairChainRule(int atom1, int atom2, ThreadData& data, float* posq, RealOpenMM** atomParameters, void calculateOnePairChainRule(int atom1, int atom2, ThreadData& data, float* posq, double** atomParameters,
float* forces, bool isExcluded, const fvec4& boxSize, const fvec4& invBoxSize); float* forces, bool isExcluded, const fvec4& boxSize, const fvec4& invBoxSize);
/** /**
...@@ -217,7 +217,7 @@ public: ...@@ -217,7 +217,7 @@ public:
* @param boxSize the X, Y, and Z widths of the periodic box * @param boxSize the X, Y, and Z widths of the periodic box
*/ */
void setPeriodic(RealVec& boxSize); void setPeriodic(Vec3& boxSize);
/** /**
* Calculate custom GB ixn * Calculate custom GB ixn
...@@ -231,7 +231,7 @@ public: ...@@ -231,7 +231,7 @@ public:
* @param energyParamDerivs derivatives of the energy with respect to global parameters * @param energyParamDerivs derivatives of the energy with respect to global parameters
*/ */
void calculateIxn(int numberOfAtoms, float* posq, RealOpenMM** atomParameters, std::map<std::string, double>& globalParameters, void calculateIxn(int numberOfAtoms, float* posq, double** atomParameters, std::map<std::string, double>& globalParameters,
std::vector<AlignedArray<float> >& threadForce, bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs); std::vector<AlignedArray<float> >& threadForce, bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs);
}; };
......
...@@ -51,9 +51,9 @@ private: ...@@ -51,9 +51,9 @@ private:
class ThreadData; class ThreadData;
int numParticles, numParticlesPerSet, numPerParticleParameters, numTypes; int numParticles, numParticlesPerSet, numPerParticleParameters, numTypes;
bool useCutoff, usePeriodic, triclinic, centralParticleMode; bool useCutoff, usePeriodic, triclinic, centralParticleMode;
RealOpenMM cutoffDistance; double cutoffDistance;
float recipBoxSize[3]; float recipBoxSize[3];
RealVec periodicBoxVectors[3]; Vec3 periodicBoxVectors[3];
AlignedArray<fvec4> periodicBoxVec4; AlignedArray<fvec4> periodicBoxVec4;
CpuNeighborList* neighborList; CpuNeighborList* neighborList;
ThreadPool& threads; ThreadPool& threads;
...@@ -65,7 +65,7 @@ private: ...@@ -65,7 +65,7 @@ private:
std::vector<ThreadData*> threadData; std::vector<ThreadData*> threadData;
// The following variables are used to make information accessible to the individual threads. // The following variables are used to make information accessible to the individual threads.
float* posq; float* posq;
RealOpenMM** particleParameters; double** particleParameters;
const std::map<std::string, double>* globalParameters; const std::map<std::string, double>* globalParameters;
std::vector<AlignedArray<float> >* threadForce; std::vector<AlignedArray<float> >* threadForce;
bool includeForces, includeEnergy; bool includeForces, includeEnergy;
...@@ -81,7 +81,7 @@ private: ...@@ -81,7 +81,7 @@ private:
* interaction for each one. * interaction for each one.
*/ */
void loopOverInteractions(std::vector<int>& availableParticles, std::vector<int>& particleSet, int loopIndex, int startIndex, void loopOverInteractions(std::vector<int>& availableParticles, std::vector<int>& particleSet, int loopIndex, int startIndex,
RealOpenMM** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize); double** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -104,7 +104,7 @@ private: ...@@ -104,7 +104,7 @@ private:
* @param boxSize the size of the periodic box * @param boxSize the size of the periodic box
* @param invBoxSize the inverse size of the periodic box * @param invBoxSize the inverse size of the periodic box
*/ */
void calculateOneIxn(std::vector<int>& particleSet, RealOpenMM** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize); void calculateOneIxn(std::vector<int>& particleSet, double** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize);
/** /**
* Compute the displacement and squared distance between two points, optionally using * Compute the displacement and squared distance between two points, optionally using
...@@ -132,7 +132,7 @@ public: ...@@ -132,7 +132,7 @@ public:
* *
* @param distance the cutoff distance * @param distance the cutoff distance
*/ */
void setUseCutoff(RealOpenMM distance); void setUseCutoff(double distance);
/** /**
* Set the force to use periodic boundary conditions. This requires that a cutoff has * Set the force to use periodic boundary conditions. This requires that a cutoff has
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
* *
* @param periodicBoxVectors the vectors defining the periodic box * @param periodicBoxVectors the vectors defining the periodic box
*/ */
void setPeriodic(RealVec* periodicBoxVectors); void setPeriodic(Vec3* periodicBoxVectors);
/** /**
* Calculate the interaction. * Calculate the interaction.
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
* @param includeEnergy whether to compute energy * @param includeEnergy whether to compute energy
* @param energy the total energy is added to this * @param energy the total energy is added to this
*/ */
void calculateIxn(AlignedArray<float>& posq, RealOpenMM** particleParameters, const std::map<std::string, double>& globalParameters, void calculateIxn(AlignedArray<float>& posq, double** particleParameters, const std::map<std::string, double>& globalParameters,
std::vector<AlignedArray<float> >& threadForce, bool includeForces, bool includeEnergy, double& energy); std::vector<AlignedArray<float> >& threadForce, bool includeForces, bool includeEnergy, double& energy);
}; };
......
...@@ -67,7 +67,7 @@ class CpuCustomNonbondedForce { ...@@ -67,7 +67,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setUseCutoff(RealOpenMM distance, const CpuNeighborList& neighbors); void setUseCutoff(double distance, const CpuNeighborList& neighbors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -88,7 +88,7 @@ class CpuCustomNonbondedForce { ...@@ -88,7 +88,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setUseSwitchingFunction(RealOpenMM distance); void setUseSwitchingFunction(double distance);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -100,7 +100,7 @@ class CpuCustomNonbondedForce { ...@@ -100,7 +100,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(RealVec* periodicBoxVectors); void setPeriodic(Vec3* periodicBoxVectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -118,8 +118,8 @@ class CpuCustomNonbondedForce { ...@@ -118,8 +118,8 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculatePairIxn(int numberOfAtoms, float* posq, std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMM** atomParameters, void calculatePairIxn(int numberOfAtoms, float* posq, std::vector<OpenMM::Vec3>& atomCoordinates, double** atomParameters,
RealOpenMM* fixedParameters, const std::map<std::string, double>& globalParameters, double* fixedParameters, const std::map<std::string, double>& globalParameters,
std::vector<AlignedArray<float> >& threadForce, bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs); std::vector<AlignedArray<float> >& threadForce, bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs);
private: private:
class ThreadData; class ThreadData;
...@@ -131,9 +131,9 @@ private: ...@@ -131,9 +131,9 @@ private:
bool useInteractionGroups; bool useInteractionGroups;
const CpuNeighborList* neighborList; const CpuNeighborList* neighborList;
float recipBoxSize[3]; float recipBoxSize[3];
RealVec periodicBoxVectors[3]; Vec3 periodicBoxVectors[3];
AlignedArray<fvec4> periodicBoxVec4; AlignedArray<fvec4> periodicBoxVec4;
RealOpenMM cutoffDistance, switchingDistance; double cutoffDistance, switchingDistance;
ThreadPool& threads; ThreadPool& threads;
const std::vector<std::set<int> > exclusions; const std::vector<std::set<int> > exclusions;
std::vector<ThreadData*> threadData; std::vector<ThreadData*> threadData;
...@@ -143,8 +143,8 @@ private: ...@@ -143,8 +143,8 @@ private:
// The following variables are used to make information accessible to the individual threads. // The following variables are used to make information accessible to the individual threads.
int numberOfAtoms; int numberOfAtoms;
float* posq; float* posq;
RealVec const* atomCoordinates; Vec3 const* atomCoordinates;
RealOpenMM** atomParameters; double** atomParameters;
const std::map<std::string, double>* globalParameters; const std::map<std::string, double>* globalParameters;
std::vector<AlignedArray<float> >* threadForce; std::vector<AlignedArray<float> >* threadForce;
bool includeForce, includeEnergy; bool includeForce, includeEnergy;
...@@ -185,7 +185,7 @@ public: ...@@ -185,7 +185,7 @@ public:
CompiledExpressionSet expressionSet; CompiledExpressionSet expressionSet;
std::vector<double> particleParam; std::vector<double> particleParam;
double r; double r;
std::vector<RealOpenMM> energyParamDerivs; std::vector<double> energyParamDerivs;
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "openmm/internal/ThreadPool.h" #include "openmm/internal/ThreadPool.h"
#include "CpuNeighborList.h" #include "CpuNeighborList.h"
#include "CpuPlatform.h" #include "CpuPlatform.h"
#include "RealVec.h" #include "openmm/Vec3.h"
#include <set> #include <set>
#include <utility> #include <utility>
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
* @param data the platform data for the current context * @param data the platform data for the current context
* @return the energy of the interaction * @return the energy of the interaction
*/ */
RealOpenMM calculateForce(const std::vector<RealVec>& positions, std::vector<RealVec>& forces, std::vector<AlignedArray<float> >& threadForce, RealVec* boxVectors, CpuPlatform::PlatformData& data); double calculateForce(const std::vector<Vec3>& positions, std::vector<Vec3>& forces, std::vector<AlignedArray<float> >& threadForce, Vec3* boxVectors, CpuPlatform::PlatformData& data);
/** /**
* This routine contains the code executed by each thread. * This routine contains the code executed by each thread.
...@@ -81,41 +81,41 @@ private: ...@@ -81,41 +81,41 @@ private:
std::set<std::pair<int, int> > exclusions; std::set<std::pair<int, int> > exclusions;
std::vector<std::set<int> > particleExclusions; std::vector<std::set<int> > particleExclusions;
GayBerneForce::NonbondedMethod nonbondedMethod; GayBerneForce::NonbondedMethod nonbondedMethod;
RealOpenMM cutoffDistance, switchingDistance; double cutoffDistance, switchingDistance;
bool useSwitchingFunction; bool useSwitchingFunction;
std::vector<RealOpenMM> s; std::vector<double> s;
std::vector<Matrix> A, B, G; std::vector<Matrix> A, B, G;
std::vector<double> threadEnergy; std::vector<double> threadEnergy;
std::vector<std::vector<RealVec> > threadTorque; std::vector<std::vector<Vec3> > threadTorque;
// The following variables are used to make information accessible to the individual threads. // The following variables are used to make information accessible to the individual threads.
RealVec const* positions; Vec3 const* positions;
std::vector<AlignedArray<float> >* threadForce; std::vector<AlignedArray<float> >* threadForce;
RealVec* boxVectors; Vec3* boxVectors;
void* atomicCounter; void* atomicCounter;
void computeEllipsoidFrames(const std::vector<RealVec>& positions); void computeEllipsoidFrames(const std::vector<Vec3>& positions);
void applyTorques(const std::vector<RealVec>& positions, std::vector<RealVec>& forces); void applyTorques(const std::vector<Vec3>& positions, std::vector<Vec3>& forces);
RealOpenMM computeOneInteraction(int particle1, int particle2, RealOpenMM sigma, RealOpenMM epsilon, const RealVec* positions, double computeOneInteraction(int particle1, int particle2, double sigma, double epsilon, const Vec3* positions,
float* forces, std::vector<RealVec>& torques, const RealVec* boxVectors); float* forces, std::vector<Vec3>& torques, const Vec3* boxVectors);
}; };
struct CpuGayBerneForce::ParticleInfo { struct CpuGayBerneForce::ParticleInfo {
int xparticle, yparticle; int xparticle, yparticle;
RealOpenMM sigmaOver2, sqrtEpsilon, rx, ry, rz, ex, ey, ez; double sigmaOver2, sqrtEpsilon, rx, ry, rz, ex, ey, ez;
bool isPointParticle; bool isPointParticle;
}; };
struct CpuGayBerneForce::ExceptionInfo { struct CpuGayBerneForce::ExceptionInfo {
int particle1, particle2; int particle1, particle2;
RealOpenMM sigma, epsilon; double sigma, epsilon;
}; };
struct CpuGayBerneForce::Matrix { struct CpuGayBerneForce::Matrix {
RealOpenMM v[3][3]; double v[3][3];
RealVec operator*(const RealVec& r) { Vec3 operator*(const Vec3& r) {
return RealVec(v[0][0]*r[0] + v[0][1]*r[1] + v[0][2]*r[2], return Vec3(v[0][0]*r[0] + v[0][1]*r[1] + v[0][2]*r[2],
v[1][0]*r[0] + v[1][1]*r[1] + v[1][2]*r[2], v[1][0]*r[0] + v[1][1]*r[1] + v[1][2]*r[2],
v[2][0]*r[0] + v[2][1]*r[1] + v[2][2]*r[2]); v[2][0]*r[0] + v[2][1]*r[1] + v[2][2]*r[2]);
} }
...@@ -128,13 +128,13 @@ struct CpuGayBerneForce::Matrix { ...@@ -128,13 +128,13 @@ struct CpuGayBerneForce::Matrix {
return result; return result;
} }
RealOpenMM determinant() { double determinant() {
return (v[0][0]*v[1][1]*v[2][2] + v[0][1]*v[1][2]*v[2][0] + v[0][2]*v[1][0]*v[2][1] - return (v[0][0]*v[1][1]*v[2][2] + v[0][1]*v[1][2]*v[2][0] + v[0][2]*v[1][0]*v[2][1] -
v[0][0]*v[1][2]*v[2][1] - v[0][1]*v[1][0]*v[2][2] - v[0][2]*v[1][1]*v[2][0]); v[0][0]*v[1][2]*v[2][1] - v[0][1]*v[1][0]*v[2][2] - v[0][2]*v[1][1]*v[2][0]);
} }
Matrix inverse() { Matrix inverse() {
RealOpenMM invDet = 1/determinant(); double invDet = 1/determinant();
Matrix result; Matrix result;
result.v[0][0] = invDet*(v[1][1]*v[2][2] - v[1][2]*v[2][1]); result.v[0][0] = invDet*(v[1][1]*v[2][2] - v[1][2]*v[2][1]);
result.v[1][0] = -invDet*(v[1][0]*v[2][2] - v[1][2]*v[2][0]); result.v[1][0] = -invDet*(v[1][0]*v[2][2] - v[1][2]*v[2][0]);
...@@ -149,8 +149,8 @@ struct CpuGayBerneForce::Matrix { ...@@ -149,8 +149,8 @@ struct CpuGayBerneForce::Matrix {
} }
}; };
static RealVec operator*(const RealVec& r, CpuGayBerneForce::Matrix& m) { static Vec3 operator*(const Vec3& r, CpuGayBerneForce::Matrix& m) {
return RealVec(m.v[0][0]*r[0] + m.v[1][0]*r[1] + m.v[2][0]*r[2], return Vec3(m.v[0][0]*r[0] + m.v[1][0]*r[1] + m.v[2][0]*r[2],
m.v[0][1]*r[0] + m.v[1][1]*r[1] + m.v[2][1]*r[2], m.v[0][1]*r[0] + m.v[1][1]*r[1] + m.v[2][1]*r[2],
m.v[0][2]*r[0] + m.v[1][2]*r[1] + m.v[2][2]*r[2]); m.v[0][2]*r[0] + m.v[1][2]*r[1] + m.v[2][2]*r[2]);
} }
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
private: private:
CpuPlatform::PlatformData& data; CpuPlatform::PlatformData& data;
Kernel referenceKernel; Kernel referenceKernel;
std::vector<RealVec> lastPositions; std::vector<Vec3> lastPositions;
}; };
/** /**
...@@ -128,7 +128,7 @@ private: ...@@ -128,7 +128,7 @@ private:
CpuPlatform::PlatformData& data; CpuPlatform::PlatformData& data;
int numAngles; int numAngles;
int **angleIndexArray; int **angleIndexArray;
RealOpenMM **angleParamArray; double **angleParamArray;
CpuBondForce bondForce; CpuBondForce bondForce;
bool usePeriodic; bool usePeriodic;
}; };
...@@ -169,7 +169,7 @@ private: ...@@ -169,7 +169,7 @@ private:
CpuPlatform::PlatformData& data; CpuPlatform::PlatformData& data;
int numTorsions; int numTorsions;
int **torsionIndexArray; int **torsionIndexArray;
RealOpenMM **torsionParamArray; double **torsionParamArray;
CpuBondForce bondForce; CpuBondForce bondForce;
bool usePeriodic; bool usePeriodic;
}; };
...@@ -210,7 +210,7 @@ private: ...@@ -210,7 +210,7 @@ private:
CpuPlatform::PlatformData& data; CpuPlatform::PlatformData& data;
int numTorsions; int numTorsions;
int **torsionIndexArray; int **torsionIndexArray;
RealOpenMM **torsionParamArray; double **torsionParamArray;
CpuBondForce bondForce; CpuBondForce bondForce;
bool usePeriodic; bool usePeriodic;
}; };
...@@ -403,8 +403,8 @@ private: ...@@ -403,8 +403,8 @@ private:
CpuPlatform::PlatformData& data; CpuPlatform::PlatformData& data;
int numParticles; int numParticles;
bool isPeriodic; bool isPeriodic;
RealOpenMM **particleParamArray; double **particleParamArray;
RealOpenMM nonbondedCutoff; double nonbondedCutoff;
CpuCustomGBForce* ixn; CpuCustomGBForce* ixn;
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;
...@@ -448,8 +448,8 @@ public: ...@@ -448,8 +448,8 @@ public:
private: private:
CpuPlatform::PlatformData& data; CpuPlatform::PlatformData& data;
int numParticles; int numParticles;
RealOpenMM cutoffDistance; double cutoffDistance;
RealOpenMM **particleParamArray; double **particleParamArray;
CpuCustomManyParticleForce* ixn; CpuCustomManyParticleForce* ixn;
std::vector<std::string> globalParameterNames; std::vector<std::string> globalParameterNames;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
...@@ -524,7 +524,7 @@ public: ...@@ -524,7 +524,7 @@ public:
private: private:
CpuPlatform::PlatformData& data; CpuPlatform::PlatformData& data;
CpuLangevinDynamics* dynamics; CpuLangevinDynamics* dynamics;
std::vector<RealOpenMM> masses; std::vector<double> masses;
double prevTemp, prevFriction, prevStepSize; double prevTemp, prevFriction, prevStepSize;
}; };
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
* @param threads thread pool for parallelizing computation * @param threads thread pool for parallelizing computation
* @param random random number generator * @param random random number generator
*/ */
CpuLangevinDynamics(int numberOfAtoms, RealOpenMM deltaT, RealOpenMM friction, RealOpenMM temperature, OpenMM::ThreadPool& threads, OpenMM::CpuRandom& random); CpuLangevinDynamics(int numberOfAtoms, double deltaT, double friction, double temperature, OpenMM::ThreadPool& threads, OpenMM::CpuRandom& random);
/** /**
* Destructor. * Destructor.
...@@ -62,8 +62,8 @@ public: ...@@ -62,8 +62,8 @@ public:
* @param inverseMasses inverse atom masses * @param inverseMasses inverse atom masses
* @param xPrime xPrime * @param xPrime xPrime
*/ */
void updatePart1(int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<OpenMM::RealVec>& velocities, void updatePart1(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& velocities,
std::vector<OpenMM::RealVec>& forces, std::vector<RealOpenMM>& inverseMasses, std::vector<OpenMM::RealVec>& xPrime); std::vector<OpenMM::Vec3>& forces, std::vector<double>& inverseMasses, std::vector<OpenMM::Vec3>& xPrime);
/** /**
* Second update step. * Second update step.
...@@ -75,8 +75,8 @@ public: ...@@ -75,8 +75,8 @@ public:
* @param inverseMasses inverse atom masses * @param inverseMasses inverse atom masses
* @param xPrime xPrime * @param xPrime xPrime
*/ */
void updatePart2(int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<OpenMM::RealVec>& velocities, void updatePart2(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& velocities,
std::vector<OpenMM::RealVec>& forces, std::vector<RealOpenMM>& inverseMasses, std::vector<OpenMM::RealVec>& xPrime); std::vector<OpenMM::Vec3>& forces, std::vector<double>& inverseMasses, std::vector<OpenMM::Vec3>& xPrime);
/** /**
* Third update * Third update
...@@ -86,8 +86,8 @@ public: ...@@ -86,8 +86,8 @@ public:
* @param velocities velocities * @param velocities velocities
* @param inverseMasses inverse atom masses * @param inverseMasses inverse atom masses
*/ */
void updatePart3(int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<OpenMM::RealVec>& velocities, void updatePart3(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& velocities,
std::vector<RealOpenMM>& inverseMasses, std::vector<OpenMM::RealVec>& xPrime); std::vector<double>& inverseMasses, std::vector<OpenMM::Vec3>& xPrime);
private: private:
void threadUpdate1(int threadIndex); void threadUpdate1(int threadIndex);
...@@ -98,11 +98,11 @@ private: ...@@ -98,11 +98,11 @@ private:
std::vector<OpenMM_SFMT::SFMT> threadRandom; std::vector<OpenMM_SFMT::SFMT> threadRandom;
// The following variables are used to make information accessible to the individual threads. // The following variables are used to make information accessible to the individual threads.
int numberOfAtoms; int numberOfAtoms;
OpenMM::RealVec* atomCoordinates; OpenMM::Vec3* atomCoordinates;
OpenMM::RealVec* velocities; OpenMM::Vec3* velocities;
OpenMM::RealVec* forces; OpenMM::Vec3* forces;
RealOpenMM* inverseMasses; double* inverseMasses;
OpenMM::RealVec* xPrime; OpenMM::Vec3* xPrime;
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include "AlignedArray.h" #include "AlignedArray.h"
#include "RealVec.h" #include "openmm/Vec3.h"
#include "windowsExportCpu.h" #include "windowsExportCpu.h"
#include "openmm/internal/gmx_atomic.h" #include "openmm/internal/gmx_atomic.h"
#include "openmm/internal/ThreadPool.h" #include "openmm/internal/ThreadPool.h"
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
class Voxels; class Voxels;
CpuNeighborList(int blockSize); CpuNeighborList(int blockSize);
void computeNeighborList(int numAtoms, const AlignedArray<float>& atomLocations, const std::vector<std::set<int> >& exclusions, void computeNeighborList(int numAtoms, const AlignedArray<float>& atomLocations, const std::vector<std::set<int> >& exclusions,
const RealVec* periodicBoxVectors, bool usePeriodic, float maxDistance, ThreadPool& threads); const Vec3* periodicBoxVectors, bool usePeriodic, float maxDistance, ThreadPool& threads);
int getNumBlocks() const; int getNumBlocks() const;
int getBlockSize() const; int getBlockSize() const;
const std::vector<int>& getSortedAtoms() const; const std::vector<int>& getSortedAtoms() const;
...@@ -71,7 +71,7 @@ private: ...@@ -71,7 +71,7 @@ private:
Voxels* voxels; Voxels* voxels;
const std::vector<std::set<int> >* exclusions; const std::vector<std::set<int> >* exclusions;
const float* atomLocations; const float* atomLocations;
RealVec periodicBoxVectors[3]; Vec3 periodicBoxVectors[3];
int numAtoms; int numAtoms;
bool usePeriodic; bool usePeriodic;
float maxDistance; float maxDistance;
......
...@@ -86,7 +86,7 @@ class CpuNonbondedForce { ...@@ -86,7 +86,7 @@ class CpuNonbondedForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setPeriodic(RealVec* periodicBoxVectors); void setPeriodic(Vec3* periodicBoxVectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -140,9 +140,9 @@ class CpuNonbondedForce { ...@@ -140,9 +140,9 @@ class CpuNonbondedForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateReciprocalIxn(int numberOfAtoms, float* posq, const std::vector<RealVec>& atomCoordinates, void calculateReciprocalIxn(int numberOfAtoms, float* posq, const std::vector<Vec3>& atomCoordinates,
const std::vector<std::pair<float, float> >& atomParameters, const std::vector<float> &C6params, const std::vector<std::pair<float, float> >& atomParameters, const std::vector<float> &C6params,
const std::vector<std::set<int> >& exclusions, std::vector<RealVec>& forces, double* totalEnergy) const; const std::vector<std::set<int> >& exclusions, std::vector<Vec3>& forces, double* totalEnergy) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -160,7 +160,7 @@ class CpuNonbondedForce { ...@@ -160,7 +160,7 @@ class CpuNonbondedForce {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void calculateDirectIxn(int numberOfAtoms, float* posq, const std::vector<RealVec>& atomCoordinates, const std::vector<std::pair<float, float> >& atomParameters, void calculateDirectIxn(int numberOfAtoms, float* posq, const std::vector<Vec3>& atomCoordinates, const std::vector<std::pair<float, float> >& atomParameters,
const std::vector<float>& C6params, const std::vector<std::set<int> >& exclusions, std::vector<AlignedArray<float> >& threadForce, double* totalEnergy, ThreadPool& threads); const std::vector<float>& C6params, const std::vector<std::set<int> >& exclusions, std::vector<AlignedArray<float> >& threadForce, double* totalEnergy, ThreadPool& threads);
/** /**
...@@ -178,7 +178,7 @@ protected: ...@@ -178,7 +178,7 @@ protected:
bool tableIsValid, expTableIsValid; bool tableIsValid, expTableIsValid;
const CpuNeighborList* neighborList; const CpuNeighborList* neighborList;
float recipBoxSize[3]; float recipBoxSize[3];
RealVec periodicBoxVectors[3]; Vec3 periodicBoxVectors[3];
AlignedArray<fvec4> periodicBoxVec4; AlignedArray<fvec4> periodicBoxVec4;
float cutoffDistance, switchingDistance; float cutoffDistance, switchingDistance;
float krf, crf; float krf, crf;
...@@ -192,7 +192,7 @@ protected: ...@@ -192,7 +192,7 @@ protected:
// The following variables are used to make information accessible to the individual threads. // The following variables are used to make information accessible to the individual threads.
int numberOfAtoms; int numberOfAtoms;
float* posq; float* posq;
RealVec const* atomCoordinates; Vec3 const* atomCoordinates;
std::pair<float, float> const* atomParameters; std::pair<float, float> const* atomParameters;
float const *C6params; float const *C6params;
std::set<int> const* exclusions; std::set<int> const* exclusions;
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
* @param inverseMasses 1/mass * @param inverseMasses 1/mass
* @param tolerance the constraint tolerance * @param tolerance the constraint tolerance
*/ */
void apply(std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<OpenMM::RealVec>& atomCoordinatesP, std::vector<RealOpenMM>& inverseMasses, RealOpenMM tolerance); void apply(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& atomCoordinatesP, std::vector<double>& inverseMasses, double tolerance);
/** /**
* Apply the constraint algorithm to velocities. * Apply the constraint algorithm to velocities.
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
* @param inverseMasses 1/mass * @param inverseMasses 1/mass
* @param tolerance the constraint tolerance * @param tolerance the constraint tolerance
*/ */
void applyToVelocities(std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<OpenMM::RealVec>& velocities, std::vector<RealOpenMM>& inverseMasses, RealOpenMM tolerance); void applyToVelocities(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& velocities, std::vector<double>& inverseMasses, double tolerance);
private: private:
std::vector<ReferenceSETTLEAlgorithm*> threadSettle; std::vector<ReferenceSETTLEAlgorithm*> threadSettle;
ThreadPool& threads; ThreadPool& threads;
......
...@@ -164,13 +164,13 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec ...@@ -164,13 +164,13 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec
} }
} }
void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM** parameters, vector<RealVec>& forces, void CpuBondForce::calculateForce(vector<Vec3>& atomCoordinates, double** parameters, vector<Vec3>& forces,
RealOpenMM* totalEnergy, ReferenceBondIxn& referenceBondIxn) { double* totalEnergy, ReferenceBondIxn& referenceBondIxn) {
// Have the worker threads compute their forces. // Have the worker threads compute their forces.
vector<RealOpenMM> threadEnergy(threads->getNumThreads(), 0); vector<double> threadEnergy(threads->getNumThreads(), 0);
threads->execute([&] (ThreadPool& threads, int threadIndex) { threads->execute([&] (ThreadPool& threads, int threadIndex) {
RealOpenMM* energy = (totalEnergy == NULL ? NULL : &threadEnergy[threadIndex]); double* energy = (totalEnergy == NULL ? NULL : &threadEnergy[threadIndex]);
threadComputeForce(threads, threadIndex, atomCoordinates, parameters, forces, energy, referenceBondIxn); threadComputeForce(threads, threadIndex, atomCoordinates, parameters, forces, energy, referenceBondIxn);
}); });
threads->waitForThreads(); threads->waitForThreads();
...@@ -189,8 +189,8 @@ void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM** ...@@ -189,8 +189,8 @@ void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM**
*totalEnergy += threadEnergy[i]; *totalEnergy += threadEnergy[i];
} }
void CpuBondForce::threadComputeForce(ThreadPool& threads, int threadIndex, vector<RealVec>& atomCoordinates, RealOpenMM** parameters, vector<RealVec>& forces, void CpuBondForce::threadComputeForce(ThreadPool& threads, int threadIndex, vector<Vec3>& atomCoordinates, double** parameters, vector<Vec3>& forces,
RealOpenMM* totalEnergy, ReferenceBondIxn& referenceBondIxn) { double* totalEnergy, ReferenceBondIxn& referenceBondIxn) {
vector<int>& bonds = threadBonds[threadIndex]; vector<int>& bonds = threadBonds[threadIndex];
int numBonds = bonds.size(); int numBonds = bonds.size();
for (int i = 0; i < numBonds; i++) { for (int i = 0; i < numBonds; i++) {
......
...@@ -166,7 +166,7 @@ void CpuCustomGBForce::setUseCutoff(float distance, const CpuNeighborList& neigh ...@@ -166,7 +166,7 @@ void CpuCustomGBForce::setUseCutoff(float distance, const CpuNeighborList& neigh
neighborList = &neighbors; neighborList = &neighbors;
} }
void CpuCustomGBForce::setPeriodic(RealVec& boxSize) { void CpuCustomGBForce::setPeriodic(Vec3& boxSize) {
if (cutoff) { if (cutoff) {
assert(boxSize[0] >= 2.0*cutoffDistance); assert(boxSize[0] >= 2.0*cutoffDistance);
assert(boxSize[1] >= 2.0*cutoffDistance); assert(boxSize[1] >= 2.0*cutoffDistance);
...@@ -178,7 +178,7 @@ void CpuCustomGBForce::setPeriodic(RealVec& boxSize) { ...@@ -178,7 +178,7 @@ void CpuCustomGBForce::setPeriodic(RealVec& boxSize) {
periodicBoxSize[2] = boxSize[2]; periodicBoxSize[2] = boxSize[2];
} }
void CpuCustomGBForce::calculateIxn(int numberOfAtoms, float* posq, RealOpenMM** atomParameters, void CpuCustomGBForce::calculateIxn(int numberOfAtoms, float* posq, double** atomParameters,
map<string, double>& globalParameters, vector<AlignedArray<float> >& threadForce, map<string, double>& globalParameters, vector<AlignedArray<float> >& threadForce,
bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs) { bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs) {
// Record the parameters for the threads. // Record the parameters for the threads.
...@@ -352,7 +352,7 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex) ...@@ -352,7 +352,7 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
calculateChainRuleForces(data, numberOfAtoms, posq, atomParameters, forces, boxSize, invBoxSize); calculateChainRuleForces(data, numberOfAtoms, posq, atomParameters, forces, boxSize, invBoxSize);
} }
void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, int numAtoms, float* posq, RealOpenMM** atomParameters, void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, int numAtoms, float* posq, double** atomParameters,
bool useExclusions, const fvec4& boxSize, const fvec4& invBoxSize) { bool useExclusions, const fvec4& boxSize, const fvec4& invBoxSize) {
for (int i = 0; i < numAtoms; i++) for (int i = 0; i < numAtoms; i++)
values[index][i] = 0.0f; values[index][i] = 0.0f;
...@@ -399,7 +399,7 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i ...@@ -399,7 +399,7 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i
} }
} }
void CpuCustomGBForce::calculateOnePairValue(int index, int atom1, int atom2, ThreadData& data, float* posq, RealOpenMM** atomParameters, void CpuCustomGBForce::calculateOnePairValue(int index, int atom1, int atom2, ThreadData& data, float* posq, double** atomParameters,
vector<float>& valueArray, const fvec4& boxSize, const fvec4& invBoxSize) { vector<float>& valueArray, const fvec4& boxSize, const fvec4& invBoxSize) {
fvec4 deltaR; fvec4 deltaR;
fvec4 pos1(posq+4*atom1); fvec4 pos1(posq+4*atom1);
...@@ -426,7 +426,7 @@ void CpuCustomGBForce::calculateOnePairValue(int index, int atom1, int atom2, Th ...@@ -426,7 +426,7 @@ void CpuCustomGBForce::calculateOnePairValue(int index, int atom1, int atom2, Th
} }
void CpuCustomGBForce::calculateSingleParticleEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq, void CpuCustomGBForce::calculateSingleParticleEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq,
RealOpenMM** atomParameters, float* forces, double& totalEnergy) { double** atomParameters, float* forces, double& totalEnergy) {
for (int i = data.firstAtom; i < data.lastAtom; i++) { for (int i = data.firstAtom; i < data.lastAtom; i++) {
data.x = posq[4*i]; data.x = posq[4*i];
data.y = posq[4*i+1]; data.y = posq[4*i+1];
...@@ -450,7 +450,7 @@ void CpuCustomGBForce::calculateSingleParticleEnergyTerm(int index, ThreadData& ...@@ -450,7 +450,7 @@ void CpuCustomGBForce::calculateSingleParticleEnergyTerm(int index, ThreadData&
} }
} }
void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq, RealOpenMM** atomParameters, void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& data, int numAtoms, float* posq, double** atomParameters,
bool useExclusions, float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize) { bool useExclusions, float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize) {
if (cutoff) { if (cutoff) {
// Loop over all pairs in the neighbor list. // Loop over all pairs in the neighbor list.
...@@ -492,7 +492,7 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da ...@@ -492,7 +492,7 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da
} }
} }
void CpuCustomGBForce::calculateOnePairEnergyTerm(int index, int atom1, int atom2, ThreadData& data, float* posq, RealOpenMM** atomParameters, void CpuCustomGBForce::calculateOnePairEnergyTerm(int index, int atom1, int atom2, ThreadData& data, float* posq, double** atomParameters,
float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize) { float* forces, double& totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize) {
// Compute the displacement. // Compute the displacement.
...@@ -537,7 +537,7 @@ void CpuCustomGBForce::calculateOnePairEnergyTerm(int index, int atom1, int atom ...@@ -537,7 +537,7 @@ void CpuCustomGBForce::calculateOnePairEnergyTerm(int index, int atom1, int atom
data.energyParamDerivs[i] += data.energyParamDerivExpressions[index][i].evaluate(); data.energyParamDerivs[i] += data.energyParamDerivExpressions[index][i].evaluate();
} }
void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms, float* posq, RealOpenMM** atomParameters, void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms, float* posq, double** atomParameters,
float* forces, const fvec4& boxSize, const fvec4& invBoxSize) { float* forces, const fvec4& boxSize, const fvec4& invBoxSize) {
if (cutoff) { if (cutoff) {
// Loop over all pairs in the neighbor list. // Loop over all pairs in the neighbor list.
...@@ -614,7 +614,7 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms, ...@@ -614,7 +614,7 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms,
data.energyParamDerivs[k] += dEdV[j][i]*dValuedParam[j][k][i]; data.energyParamDerivs[k] += dEdV[j][i]*dValuedParam[j][k][i];
} }
void CpuCustomGBForce::calculateOnePairChainRule(int atom1, int atom2, ThreadData& data, float* posq, RealOpenMM** atomParameters, void CpuCustomGBForce::calculateOnePairChainRule(int atom1, int atom2, ThreadData& data, float* posq, double** atomParameters,
float* forces, bool isExcluded, const fvec4& boxSize, const fvec4& invBoxSize) { float* forces, bool isExcluded, const fvec4& boxSize, const fvec4& invBoxSize) {
// Compute the displacement. // Compute the displacement.
......
...@@ -88,7 +88,7 @@ CpuCustomManyParticleForce::~CpuCustomManyParticleForce() { ...@@ -88,7 +88,7 @@ CpuCustomManyParticleForce::~CpuCustomManyParticleForce() {
delete threadData[i]; delete threadData[i];
} }
void CpuCustomManyParticleForce::calculateIxn(AlignedArray<float>& posq, RealOpenMM** particleParameters, void CpuCustomManyParticleForce::calculateIxn(AlignedArray<float>& posq, double** particleParameters,
const map<string, double>& globalParameters, vector<AlignedArray<float> >& threadForce, const map<string, double>& globalParameters, vector<AlignedArray<float> >& threadForce,
bool includeForces, bool includeEnergy, double& energy) { bool includeForces, bool includeEnergy, double& energy) {
// Record the parameters for the threads. // Record the parameters for the threads.
...@@ -180,14 +180,14 @@ void CpuCustomManyParticleForce::threadComputeForce(ThreadPool& threads, int thr ...@@ -180,14 +180,14 @@ void CpuCustomManyParticleForce::threadComputeForce(ThreadPool& threads, int thr
} }
} }
void CpuCustomManyParticleForce::setUseCutoff(RealOpenMM distance) { void CpuCustomManyParticleForce::setUseCutoff(double distance) {
useCutoff = true; useCutoff = true;
cutoffDistance = distance; cutoffDistance = distance;
if (neighborList == NULL) if (neighborList == NULL)
neighborList = new CpuNeighborList(4); neighborList = new CpuNeighborList(4);
} }
void CpuCustomManyParticleForce::setPeriodic(RealVec* periodicBoxVectors) { void CpuCustomManyParticleForce::setPeriodic(Vec3* periodicBoxVectors) {
assert(useCutoff); assert(useCutoff);
assert(periodicBoxVectors[0][0] >= 2.0*cutoffDistance); assert(periodicBoxVectors[0][0] >= 2.0*cutoffDistance);
assert(periodicBoxVectors[1][1] >= 2.0*cutoffDistance); assert(periodicBoxVectors[1][1] >= 2.0*cutoffDistance);
...@@ -209,7 +209,7 @@ void CpuCustomManyParticleForce::setPeriodic(RealVec* periodicBoxVectors) { ...@@ -209,7 +209,7 @@ void CpuCustomManyParticleForce::setPeriodic(RealVec* periodicBoxVectors) {
} }
void CpuCustomManyParticleForce::loopOverInteractions(vector<int>& availableParticles, vector<int>& particleSet, int loopIndex, int startIndex, void CpuCustomManyParticleForce::loopOverInteractions(vector<int>& availableParticles, vector<int>& particleSet, int loopIndex, int startIndex,
RealOpenMM** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize) { double** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize) {
int numParticles = availableParticles.size(); int numParticles = availableParticles.size();
double cutoff2 = cutoffDistance*cutoffDistance; double cutoff2 = cutoffDistance*cutoffDistance;
int checkRange = (centralParticleMode ? 1 : loopIndex); int checkRange = (centralParticleMode ? 1 : loopIndex);
...@@ -243,7 +243,7 @@ void CpuCustomManyParticleForce::loopOverInteractions(vector<int>& availablePart ...@@ -243,7 +243,7 @@ void CpuCustomManyParticleForce::loopOverInteractions(vector<int>& availablePart
} }
} }
void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, RealOpenMM** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize) { void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, double** particleParameters, float* forces, ThreadData& data, const fvec4& boxSize, const fvec4& invBoxSize) {
// Select the ordering to use for the particles. // Select the ordering to use for the particles.
vector<int>& permutedParticles = data.permutedParticles; vector<int>& permutedParticles = data.permutedParticles;
......
...@@ -70,7 +70,7 @@ CpuCustomNonbondedForce::~CpuCustomNonbondedForce() { ...@@ -70,7 +70,7 @@ CpuCustomNonbondedForce::~CpuCustomNonbondedForce() {
delete threadData[i]; delete threadData[i];
} }
void CpuCustomNonbondedForce::setUseCutoff(RealOpenMM distance, const CpuNeighborList& neighbors) { void CpuCustomNonbondedForce::setUseCutoff(double distance, const CpuNeighborList& neighbors) {
cutoff = true; cutoff = true;
cutoffDistance = distance; cutoffDistance = distance;
neighborList = &neighbors; neighborList = &neighbors;
...@@ -93,12 +93,12 @@ void CpuCustomNonbondedForce::setInteractionGroups(const vector<pair<set<int>, s ...@@ -93,12 +93,12 @@ void CpuCustomNonbondedForce::setInteractionGroups(const vector<pair<set<int>, s
} }
} }
void CpuCustomNonbondedForce::setUseSwitchingFunction(RealOpenMM distance) { void CpuCustomNonbondedForce::setUseSwitchingFunction(double distance) {
useSwitch = true; useSwitch = true;
switchingDistance = distance; switchingDistance = distance;
} }
void CpuCustomNonbondedForce::setPeriodic(RealVec* periodicBoxVectors) { void CpuCustomNonbondedForce::setPeriodic(Vec3* periodicBoxVectors) {
assert(cutoff); assert(cutoff);
assert(periodicBoxVectors[0][0] >= 2.0*cutoffDistance); assert(periodicBoxVectors[0][0] >= 2.0*cutoffDistance);
assert(periodicBoxVectors[1][1] >= 2.0*cutoffDistance); assert(periodicBoxVectors[1][1] >= 2.0*cutoffDistance);
...@@ -120,8 +120,8 @@ void CpuCustomNonbondedForce::setPeriodic(RealVec* periodicBoxVectors) { ...@@ -120,8 +120,8 @@ void CpuCustomNonbondedForce::setPeriodic(RealVec* periodicBoxVectors) {
} }
void CpuCustomNonbondedForce::calculatePairIxn(int numberOfAtoms, float* posq, vector<RealVec>& atomCoordinates, RealOpenMM** atomParameters, void CpuCustomNonbondedForce::calculatePairIxn(int numberOfAtoms, float* posq, vector<Vec3>& atomCoordinates, double** atomParameters,
RealOpenMM* fixedParameters, const map<string, double>& globalParameters, double* fixedParameters, const map<string, double>& globalParameters,
vector<AlignedArray<float> >& threadForce, bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs) { vector<AlignedArray<float> >& threadForce, bool includeForce, bool includeEnergy, double& totalEnergy, double* energyParamDerivs) {
// Record the parameters for the threads. // Record the parameters for the threads.
......
...@@ -100,7 +100,7 @@ const vector<set<int> >& CpuGayBerneForce::getExclusions() const { ...@@ -100,7 +100,7 @@ const vector<set<int> >& CpuGayBerneForce::getExclusions() const {
return particleExclusions; return particleExclusions;
} }
RealOpenMM CpuGayBerneForce::calculateForce(const vector<RealVec>& positions, std::vector<RealVec>& forces, std::vector<AlignedArray<float> >& threadForce, RealVec* boxVectors, CpuPlatform::PlatformData& data) { double CpuGayBerneForce::calculateForce(const vector<Vec3>& positions, std::vector<Vec3>& forces, std::vector<AlignedArray<float> >& threadForce, Vec3* boxVectors, CpuPlatform::PlatformData& data) {
if (nonbondedMethod == GayBerneForce::CutoffPeriodic) { if (nonbondedMethod == GayBerneForce::CutoffPeriodic) {
double minAllowedSize = 1.999999*cutoffDistance; double minAllowedSize = 1.999999*cutoffDistance;
if (boxVectors[0][0] < minAllowedSize || boxVectors[1][1] < minAllowedSize || boxVectors[2][2] < minAllowedSize) if (boxVectors[0][0] < minAllowedSize || boxVectors[1][1] < minAllowedSize || boxVectors[2][2] < minAllowedSize)
...@@ -152,10 +152,10 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex, ...@@ -152,10 +152,10 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
int numThreads = threads.getNumThreads(); int numThreads = threads.getNumThreads();
threadEnergy[threadIndex] = 0; threadEnergy[threadIndex] = 0;
float* forces = &(*threadForce)[threadIndex][0]; float* forces = &(*threadForce)[threadIndex][0];
vector<RealVec>& torques = threadTorque[threadIndex]; vector<Vec3>& torques = threadTorque[threadIndex];
torques.resize(numParticles); torques.resize(numParticles);
for (int i = 0; i < numParticles; i++) for (int i = 0; i < numParticles; i++)
torques[i] = RealVec(); torques[i] = Vec3();
double energy = 0.0; double energy = 0.0;
// Compute this thread's subset of interactions. // Compute this thread's subset of interactions.
...@@ -172,8 +172,8 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex, ...@@ -172,8 +172,8 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
continue; continue;
if (particleExclusions[i].find(j) != particleExclusions[i].end()) if (particleExclusions[i].find(j) != particleExclusions[i].end())
continue; // This interaction will be handled by an exception. continue; // This interaction will be handled by an exception.
RealOpenMM sigma = particles[i].sigmaOver2+particles[j].sigmaOver2; double sigma = particles[i].sigmaOver2+particles[j].sigmaOver2;
RealOpenMM epsilon = particles[i].sqrtEpsilon*particles[j].sqrtEpsilon; double epsilon = particles[i].sqrtEpsilon*particles[j].sqrtEpsilon;
energy += computeOneInteraction(i, j, sigma, epsilon, positions, forces, torques, boxVectors); energy += computeOneInteraction(i, j, sigma, epsilon, positions, forces, torques, boxVectors);
} }
} }
...@@ -196,8 +196,8 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex, ...@@ -196,8 +196,8 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
int second = blockAtom[k]; int second = blockAtom[k];
if (particles[second].sqrtEpsilon == 0.0f) if (particles[second].sqrtEpsilon == 0.0f)
continue; continue;
RealOpenMM sigma = particles[first].sigmaOver2+particles[second].sigmaOver2; double sigma = particles[first].sigmaOver2+particles[second].sigmaOver2;
RealOpenMM epsilon = particles[first].sqrtEpsilon*particles[second].sqrtEpsilon; double epsilon = particles[first].sqrtEpsilon*particles[second].sqrtEpsilon;
energy += computeOneInteraction(first, second, sigma, epsilon, positions, forces, torques, boxVectors); energy += computeOneInteraction(first, second, sigma, epsilon, positions, forces, torques, boxVectors);
} }
} }
...@@ -223,39 +223,39 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex, ...@@ -223,39 +223,39 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
threadEnergy[threadIndex] = energy; threadEnergy[threadIndex] = energy;
} }
void CpuGayBerneForce::computeEllipsoidFrames(const vector<RealVec>& positions) { void CpuGayBerneForce::computeEllipsoidFrames(const vector<Vec3>& positions) {
int numParticles = particles.size(); int numParticles = particles.size();
for (int particle = 0; particle < numParticles; particle++) { for (int particle = 0; particle < numParticles; particle++) {
ParticleInfo& p = particles[particle]; ParticleInfo& p = particles[particle];
// Compute the local coordinate system of the ellipsoid; // Compute the local coordinate system of the ellipsoid;
RealVec xdir, ydir, zdir; Vec3 xdir, ydir, zdir;
if (p.xparticle == -1) { if (p.xparticle == -1) {
xdir = RealVec(1, 0, 0); xdir = Vec3(1, 0, 0);
ydir = RealVec(0, 1, 0); ydir = Vec3(0, 1, 0);
} }
else { else {
xdir = positions[particle]-positions[p.xparticle]; xdir = positions[particle]-positions[p.xparticle];
xdir /= SQRT(xdir.dot(xdir)); xdir /= sqrt(xdir.dot(xdir));
if (p.yparticle == -1) { if (p.yparticle == -1) {
if (xdir[1] > -0.5 && xdir[1] < 0.5) if (xdir[1] > -0.5 && xdir[1] < 0.5)
ydir = RealVec(0, 1, 0); ydir = Vec3(0, 1, 0);
else else
ydir = RealVec(1, 0, 0); ydir = Vec3(1, 0, 0);
} }
else else
ydir = positions[particle]-positions[p.yparticle]; ydir = positions[particle]-positions[p.yparticle];
ydir -= xdir*(xdir.dot(ydir)); ydir -= xdir*(xdir.dot(ydir));
ydir /= SQRT(ydir.dot(ydir)); ydir /= sqrt(ydir.dot(ydir));
} }
zdir = xdir.cross(ydir); zdir = xdir.cross(ydir);
// Compute matrices we will need later. // Compute matrices we will need later.
RealOpenMM (&a)[3][3] = A[particle].v; double (&a)[3][3] = A[particle].v;
RealOpenMM (&b)[3][3] = B[particle].v; double (&b)[3][3] = B[particle].v;
RealOpenMM (&g)[3][3] = G[particle].v; double (&g)[3][3] = G[particle].v;
a[0][0] = xdir[0]; a[0][0] = xdir[0];
a[0][1] = xdir[1]; a[0][1] = xdir[1];
a[0][2] = xdir[2]; a[0][2] = xdir[2];
...@@ -265,8 +265,8 @@ void CpuGayBerneForce::computeEllipsoidFrames(const vector<RealVec>& positions) ...@@ -265,8 +265,8 @@ void CpuGayBerneForce::computeEllipsoidFrames(const vector<RealVec>& positions)
a[2][0] = zdir[0]; a[2][0] = zdir[0];
a[2][1] = zdir[1]; a[2][1] = zdir[1];
a[2][2] = zdir[2]; a[2][2] = zdir[2];
RealVec r2(p.rx*p.rx, p.ry*p.ry, p.rz*p.rz); Vec3 r2(p.rx*p.rx, p.ry*p.ry, p.rz*p.rz);
RealVec e2(1/sqrt(p.ex), 1/sqrt(p.ey), 1/sqrt(p.ez)); Vec3 e2(1/sqrt(p.ex), 1/sqrt(p.ey), 1/sqrt(p.ez));
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
b[i][j] = 0; b[i][j] = 0;
...@@ -279,33 +279,33 @@ void CpuGayBerneForce::computeEllipsoidFrames(const vector<RealVec>& positions) ...@@ -279,33 +279,33 @@ void CpuGayBerneForce::computeEllipsoidFrames(const vector<RealVec>& positions)
} }
} }
void CpuGayBerneForce::applyTorques(const vector<RealVec>& positions, vector<RealVec>& forces) { void CpuGayBerneForce::applyTorques(const vector<Vec3>& positions, vector<Vec3>& forces) {
int numParticles = particles.size(); int numParticles = particles.size();
int numThreads = threadTorque.size(); int numThreads = threadTorque.size();
for (int particle = 0; particle < numParticles; particle++) { for (int particle = 0; particle < numParticles; particle++) {
ParticleInfo& p = particles[particle]; ParticleInfo& p = particles[particle];
RealVec pos = positions[particle]; Vec3 pos = positions[particle];
if (p.xparticle != -1) { if (p.xparticle != -1) {
// Add up the torques from the individual threads. // Add up the torques from the individual threads.
RealVec torque; Vec3 torque;
for (int i = 0; i < numThreads; i++) for (int i = 0; i < numThreads; i++)
torque += threadTorque[i][particle]; torque += threadTorque[i][particle];
// Apply a force to the x particle. // Apply a force to the x particle.
RealVec dx = positions[p.xparticle]-pos; Vec3 dx = positions[p.xparticle]-pos;
double dx2 = dx.dot(dx); double dx2 = dx.dot(dx);
RealVec f = torque.cross(dx)/dx2; Vec3 f = torque.cross(dx)/dx2;
forces[p.xparticle] += f; forces[p.xparticle] += f;
forces[particle] -= f; forces[particle] -= f;
if (p.yparticle != -1) { if (p.yparticle != -1) {
// Apply a force to the y particle. This is based on the component of the torque // Apply a force to the y particle. This is based on the component of the torque
// that was not already applied to the x particle. // that was not already applied to the x particle.
RealVec dy = positions[p.yparticle]-pos; Vec3 dy = positions[p.yparticle]-pos;
double dy2 = dy.dot(dy); double dy2 = dy.dot(dy);
RealVec torque2 = dx*(torque.dot(dx)/dx2); Vec3 torque2 = dx*(torque.dot(dx)/dx2);
f = torque2.cross(dy)/dy2; f = torque2.cross(dy)/dy2;
forces[p.yparticle] += f; forces[p.yparticle] += f;
forces[particle] -= f; forces[particle] -= f;
...@@ -314,27 +314,27 @@ void CpuGayBerneForce::applyTorques(const vector<RealVec>& positions, vector<Rea ...@@ -314,27 +314,27 @@ void CpuGayBerneForce::applyTorques(const vector<RealVec>& positions, vector<Rea
} }
} }
RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2, RealOpenMM sigma, RealOpenMM epsilon, const RealVec* positions, double CpuGayBerneForce::computeOneInteraction(int particle1, int particle2, double sigma, double epsilon, const Vec3* positions,
float* forces, vector<RealVec>& torques, const RealVec* boxVectors) { float* forces, vector<Vec3>& torques, const Vec3* boxVectors) {
// Compute the displacement and check against the cutoff. // Compute the displacement and check against the cutoff.
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex]; double deltaR[ReferenceForce::LastDeltaRIndex];
if (nonbondedMethod == GayBerneForce::CutoffPeriodic) if (nonbondedMethod == GayBerneForce::CutoffPeriodic)
ReferenceForce::getDeltaRPeriodic(positions[particle2], positions[particle1], boxVectors, deltaR); ReferenceForce::getDeltaRPeriodic(positions[particle2], positions[particle1], boxVectors, deltaR);
else else
ReferenceForce::getDeltaR(positions[particle2], positions[particle1], deltaR); ReferenceForce::getDeltaR(positions[particle2], positions[particle1], deltaR);
RealOpenMM r = deltaR[ReferenceForce::RIndex]; double r = deltaR[ReferenceForce::RIndex];
if (nonbondedMethod != GayBerneForce::NoCutoff && r >= cutoffDistance) if (nonbondedMethod != GayBerneForce::NoCutoff && r >= cutoffDistance)
return 0; return 0;
RealOpenMM rInv = 1/r; double rInv = 1/r;
RealVec dr(deltaR[ReferenceForce::XIndex], deltaR[ReferenceForce::YIndex], deltaR[ReferenceForce::ZIndex]); Vec3 dr(deltaR[ReferenceForce::XIndex], deltaR[ReferenceForce::YIndex], deltaR[ReferenceForce::ZIndex]);
RealVec drUnit = dr*rInv; Vec3 drUnit = dr*rInv;
// Compute the switching function. // Compute the switching function.
RealOpenMM switchValue = 1, switchDeriv = 0; double switchValue = 1, switchDeriv = 0;
if (useSwitchingFunction && r > switchingDistance) { if (useSwitchingFunction && r > switchingDistance) {
RealOpenMM t = (r-switchingDistance)/(cutoffDistance-switchingDistance); double t = (r-switchingDistance)/(cutoffDistance-switchingDistance);
switchValue = 1+t*t*t*(-10+t*(15-t*6)); switchValue = 1+t*t*t*(-10+t*(15-t*6));
switchDeriv = t*t*(-30+t*(60-t*30))/(cutoffDistance-switchingDistance); switchDeriv = t*t*(-30+t*(60-t*30))/(cutoffDistance-switchingDistance);
} }
...@@ -342,11 +342,11 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2, ...@@ -342,11 +342,11 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
// Interactions between two point particles can be computed more easily. // Interactions between two point particles can be computed more easily.
if (particles[particle1].isPointParticle && particles[particle2].isPointParticle) { if (particles[particle1].isPointParticle && particles[particle2].isPointParticle) {
RealOpenMM sig = sigma*rInv; double sig = sigma*rInv;
RealOpenMM sig2 = sig*sig; double sig2 = sig*sig;
RealOpenMM sig6 = sig2*sig2*sig2; double sig6 = sig2*sig2*sig2;
RealOpenMM energy = 4*epsilon*(sig6-1)*sig6; double energy = 4*epsilon*(sig6-1)*sig6;
RealVec force = drUnit*(switchValue*4*epsilon*(12*sig6 - 6)*sig6*rInv - energy*switchDeriv); Vec3 force = drUnit*(switchValue*4*epsilon*(12*sig6 - 6)*sig6*rInv - energy*switchDeriv);
forces[4*particle1] += force[0]; forces[4*particle1] += force[0];
forces[4*particle1+1] += force[1]; forces[4*particle1+1] += force[1];
forces[4*particle1+2] += force[2]; forces[4*particle1+2] += force[2];
...@@ -362,31 +362,31 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2, ...@@ -362,31 +362,31 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
Matrix G12 = G[particle1]+G[particle2]; Matrix G12 = G[particle1]+G[particle2];
Matrix B12inv = B12.inverse(); Matrix B12inv = B12.inverse();
Matrix G12inv = G12.inverse(); Matrix G12inv = G12.inverse();
RealOpenMM detG12 = G12.determinant(); double detG12 = G12.determinant();
// Estimate the distance between the ellipsoids and compute the first terms needed for the energy. // Estimate the distance between the ellipsoids and compute the first terms needed for the energy.
RealOpenMM sigma12 = 1/SQRT(0.5*drUnit.dot(G12inv*drUnit)); double sigma12 = 1/sqrt(0.5*drUnit.dot(G12inv*drUnit));
RealOpenMM h12 = r - sigma12; double h12 = r - sigma12;
RealOpenMM rho = sigma/(h12+sigma); double rho = sigma/(h12+sigma);
RealOpenMM rho2 = rho*rho; double rho2 = rho*rho;
RealOpenMM rho6 = rho2*rho2*rho2; double rho6 = rho2*rho2*rho2;
RealOpenMM u = 4*epsilon*(rho6*rho6-rho6); double u = 4*epsilon*(rho6*rho6-rho6);
RealOpenMM eta = SQRT(2*s[particle1]*s[particle2]/detG12); double eta = sqrt(2*s[particle1]*s[particle2]/detG12);
RealOpenMM chi = 2*drUnit.dot(B12inv*drUnit); double chi = 2*drUnit.dot(B12inv*drUnit);
chi *= chi; chi *= chi;
RealOpenMM energy = u*eta*chi; double energy = u*eta*chi;
// Compute the terms needed for the force. // Compute the terms needed for the force.
RealVec kappa = G12inv*dr; Vec3 kappa = G12inv*dr;
RealVec iota = B12inv*dr; Vec3 iota = B12inv*dr;
RealOpenMM rInv2 = rInv*rInv; double rInv2 = rInv*rInv;
RealOpenMM dUSLJdr = 24*epsilon*(2*rho6-1)*rho6*rho/sigma; double dUSLJdr = 24*epsilon*(2*rho6-1)*rho6*rho/sigma;
RealOpenMM temp = 0.5*sigma12*sigma12*sigma12*rInv2; double temp = 0.5*sigma12*sigma12*sigma12*rInv2;
RealVec dudr = (drUnit + (kappa-drUnit*kappa.dot(drUnit))*temp)*dUSLJdr; Vec3 dudr = (drUnit + (kappa-drUnit*kappa.dot(drUnit))*temp)*dUSLJdr;
RealVec dchidr = (iota-drUnit*iota.dot(drUnit))*(-8*rInv2*SQRT(chi)); Vec3 dchidr = (iota-drUnit*iota.dot(drUnit))*(-8*rInv2*sqrt(chi));
RealVec force = (dchidr*u + dudr*chi)*(eta*switchValue) - drUnit*(energy*switchDeriv); Vec3 force = (dchidr*u + dudr*chi)*(eta*switchValue) - drUnit*(energy*switchDeriv);
forces[4*particle1] += force[0]; forces[4*particle1] += force[0];
forces[4*particle1+1] += force[1]; forces[4*particle1+1] += force[1];
forces[4*particle1+2] += force[2]; forces[4*particle1+2] += force[2];
...@@ -401,13 +401,13 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2, ...@@ -401,13 +401,13 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
ParticleInfo& p = particles[particle]; ParticleInfo& p = particles[particle];
if (p.isPointParticle) if (p.isPointParticle)
continue; continue;
RealVec dudq = (kappa*G[particle]).cross(kappa*(temp*dUSLJdr)); Vec3 dudq = (kappa*G[particle]).cross(kappa*(temp*dUSLJdr));
RealVec dchidq = (iota*B[particle]).cross(iota)*(-4*rInv2); Vec3 dchidq = (iota*B[particle]).cross(iota)*(-4*rInv2);
RealOpenMM (&g12)[3][3] = G12.v; double (&g12)[3][3] = G12.v;
RealOpenMM (&a)[3][3] = A[particle].v; double (&a)[3][3] = A[particle].v;
RealVec scale = RealVec(p.rx*p.rx, p.ry*p.ry, p.rz*p.rz)*(-0.5*eta/detG12); Vec3 scale = Vec3(p.rx*p.rx, p.ry*p.ry, p.rz*p.rz)*(-0.5*eta/detG12);
Matrix D; Matrix D;
RealOpenMM (&d)[3][3] = D.v; double (&d)[3][3] = D.v;
d[0][0] = scale[0]*(2*a[0][0]*(g12[1][1]*g12[2][2] - g12[1][2]*g12[2][1]) + d[0][0] = scale[0]*(2*a[0][0]*(g12[1][1]*g12[2][2] - g12[1][2]*g12[2][1]) +
a[0][2]*(g12[1][2]*g12[0][1] + g12[1][0]*g12[2][1] - g12[1][1]*(g12[0][2] + g12[2][0])) + a[0][2]*(g12[1][2]*g12[0][1] + g12[1][0]*g12[2][1] - g12[1][1]*(g12[0][2] + g12[2][0])) +
a[0][1]*(g12[0][2]*g12[2][1] + g12[2][0]*g12[1][2] - g12[2][2]*(g12[0][1] + g12[1][0]))); a[0][1]*(g12[0][2]*g12[2][1] + g12[2][0]*g12[1][2] - g12[2][2]*(g12[0][1] + g12[1][0])));
...@@ -435,10 +435,10 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2, ...@@ -435,10 +435,10 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
d[2][2] = scale[2]*( a[2][0]*(g12[0][1]*g12[1][2] + g12[2][1]*g12[1][0] - g12[1][1]*(g12[0][2] + g12[2][0])) + d[2][2] = scale[2]*( a[2][0]*(g12[0][1]*g12[1][2] + g12[2][1]*g12[1][0] - g12[1][1]*(g12[0][2] + g12[2][0])) +
a[2][1]*(g12[1][0]*g12[0][2] + g12[2][0]*g12[0][1] - g12[0][0]*(g12[1][2] + g12[2][1])) + a[2][1]*(g12[1][0]*g12[0][2] + g12[2][0]*g12[0][1] - g12[0][0]*(g12[1][2] + g12[2][1])) +
2*a[2][2]*(g12[1][1]*g12[0][0] - g12[1][0]*g12[0][1])); 2*a[2][2]*(g12[1][1]*g12[0][0] - g12[1][0]*g12[0][1]));
RealVec detadq; Vec3 detadq;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
detadq += RealVec(a[i][0], a[i][1], a[i][2]).cross(RealVec(d[i][0], d[i][1], d[i][2])); detadq += Vec3(a[i][0], a[i][1], a[i][2]).cross(Vec3(d[i][0], d[i][1], d[i][2]));
RealVec torque = (dchidq*(u*eta) + detadq*(u*chi) + dudq*(eta*chi))*switchValue; Vec3 torque = (dchidq*(u*eta) + detadq*(u*chi) + dudq*(eta*chi))*switchValue;
torques[particle] -= torque; torques[particle] -= torque;
} }
return switchValue*energy; return switchValue*energy;
......
This diff is collapsed.
...@@ -29,15 +29,15 @@ ...@@ -29,15 +29,15 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
CpuLangevinDynamics::CpuLangevinDynamics(int numberOfAtoms, RealOpenMM deltaT, RealOpenMM friction, RealOpenMM temperature, ThreadPool& threads, CpuRandom& random) : CpuLangevinDynamics::CpuLangevinDynamics(int numberOfAtoms, double deltaT, double friction, double temperature, ThreadPool& threads, CpuRandom& random) :
ReferenceStochasticDynamics(numberOfAtoms, deltaT, friction, temperature), threads(threads), random(random) { ReferenceStochasticDynamics(numberOfAtoms, deltaT, friction, temperature), threads(threads), random(random) {
} }
CpuLangevinDynamics::~CpuLangevinDynamics() { CpuLangevinDynamics::~CpuLangevinDynamics() {
} }
void CpuLangevinDynamics::updatePart1(int numberOfAtoms, vector<RealVec>& atomCoordinates, vector<RealVec>& velocities, void CpuLangevinDynamics::updatePart1(int numberOfAtoms, vector<Vec3>& atomCoordinates, vector<Vec3>& velocities,
vector<RealVec>& forces, vector<RealOpenMM>& inverseMasses, vector<RealVec>& xPrime) { vector<Vec3>& forces, vector<double>& inverseMasses, vector<Vec3>& xPrime) {
// Record the parameters for the threads. // Record the parameters for the threads.
this->numberOfAtoms = numberOfAtoms; this->numberOfAtoms = numberOfAtoms;
...@@ -53,8 +53,8 @@ void CpuLangevinDynamics::updatePart1(int numberOfAtoms, vector<RealVec>& atomCo ...@@ -53,8 +53,8 @@ void CpuLangevinDynamics::updatePart1(int numberOfAtoms, vector<RealVec>& atomCo
threads.waitForThreads(); threads.waitForThreads();
} }
void CpuLangevinDynamics::updatePart2(int numberOfAtoms, vector<RealVec>& atomCoordinates, vector<RealVec>& velocities, void CpuLangevinDynamics::updatePart2(int numberOfAtoms, vector<Vec3>& atomCoordinates, vector<Vec3>& velocities,
vector<RealVec>& forces, vector<RealOpenMM>& inverseMasses, vector<RealVec>& xPrime) { vector<Vec3>& forces, vector<double>& inverseMasses, vector<Vec3>& xPrime) {
// Record the parameters for the threads. // Record the parameters for the threads.
this->numberOfAtoms = numberOfAtoms; this->numberOfAtoms = numberOfAtoms;
...@@ -70,8 +70,8 @@ void CpuLangevinDynamics::updatePart2(int numberOfAtoms, vector<RealVec>& atomCo ...@@ -70,8 +70,8 @@ void CpuLangevinDynamics::updatePart2(int numberOfAtoms, vector<RealVec>& atomCo
threads.waitForThreads(); threads.waitForThreads();
} }
void CpuLangevinDynamics::updatePart3(int numberOfAtoms, vector<RealVec>& atomCoordinates, vector<RealVec>& velocities, void CpuLangevinDynamics::updatePart3(int numberOfAtoms, vector<Vec3>& atomCoordinates, vector<Vec3>& velocities,
vector<RealOpenMM>& inverseMasses, vector<RealVec>& xPrime) { vector<double>& inverseMasses, vector<Vec3>& xPrime) {
// Record the parameters for the threads. // Record the parameters for the threads.
this->numberOfAtoms = numberOfAtoms; this->numberOfAtoms = numberOfAtoms;
...@@ -87,39 +87,39 @@ void CpuLangevinDynamics::updatePart3(int numberOfAtoms, vector<RealVec>& atomCo ...@@ -87,39 +87,39 @@ void CpuLangevinDynamics::updatePart3(int numberOfAtoms, vector<RealVec>& atomCo
} }
void CpuLangevinDynamics::threadUpdate1(int threadIndex) { void CpuLangevinDynamics::threadUpdate1(int threadIndex) {
RealOpenMM dt = getDeltaT(); double dt = getDeltaT();
RealOpenMM friction = getFriction(); double friction = getFriction();
const RealOpenMM vscale = EXP(-dt*friction); const double vscale = exp(-dt*friction);
const RealOpenMM fscale = (friction == 0 ? dt : (1-vscale)/friction); const double fscale = (friction == 0 ? dt : (1-vscale)/friction);
const RealOpenMM kT = BOLTZ*getTemperature(); const double kT = BOLTZ*getTemperature();
const RealOpenMM noisescale = SQRT(kT*(1-vscale*vscale)); const double noisescale = sqrt(kT*(1-vscale*vscale));
int start = threadIndex*numberOfAtoms/threads.getNumThreads(); int start = threadIndex*numberOfAtoms/threads.getNumThreads();
int end = (threadIndex+1)*numberOfAtoms/threads.getNumThreads(); int end = (threadIndex+1)*numberOfAtoms/threads.getNumThreads();
for (int i = start; i < end; i++) { for (int i = start; i < end; i++) {
if (inverseMasses[i] != 0.0) { if (inverseMasses[i] != 0.0) {
RealOpenMM sqrtInvMass = SQRT(inverseMasses[i]); double sqrtInvMass = sqrt(inverseMasses[i]);
RealVec noise(random.getGaussianRandom(threadIndex), random.getGaussianRandom(threadIndex), random.getGaussianRandom(threadIndex)); Vec3 noise(random.getGaussianRandom(threadIndex), random.getGaussianRandom(threadIndex), random.getGaussianRandom(threadIndex));
velocities[i] = velocities[i]*vscale + forces[i]*(fscale*inverseMasses[i]) + noise*(noisescale*sqrtInvMass); velocities[i] = velocities[i]*vscale + forces[i]*(fscale*inverseMasses[i]) + noise*(noisescale*sqrtInvMass);
} }
} }
} }
void CpuLangevinDynamics::threadUpdate2(int threadIndex) { void CpuLangevinDynamics::threadUpdate2(int threadIndex) {
const RealOpenMM dt = getDeltaT(); const double dt = getDeltaT();
int start = threadIndex*numberOfAtoms/threads.getNumThreads(); int start = threadIndex*numberOfAtoms/threads.getNumThreads();
int end = (threadIndex+1)*numberOfAtoms/threads.getNumThreads(); int end = (threadIndex+1)*numberOfAtoms/threads.getNumThreads();
for (int i = start; i < end; i++) { for (int i = start; i < end; i++) {
if (inverseMasses[i] != 0.0) { if (inverseMasses[i] != 0.0) {
RealOpenMM sqrtInvMass = SQRT(inverseMasses[i]); double sqrtInvMass = sqrt(inverseMasses[i]);
xPrime[i] = atomCoordinates[i]+velocities[i]*dt; xPrime[i] = atomCoordinates[i]+velocities[i]*dt;
} }
} }
} }
void CpuLangevinDynamics::threadUpdate3(int threadIndex) { void CpuLangevinDynamics::threadUpdate3(int threadIndex) {
const RealOpenMM invStepSize = 1.0/getDeltaT(); const double invStepSize = 1.0/getDeltaT();
int start = threadIndex*numberOfAtoms/threads.getNumThreads(); int start = threadIndex*numberOfAtoms/threads.getNumThreads();
int end = (threadIndex+1)*numberOfAtoms/threads.getNumThreads(); int end = (threadIndex+1)*numberOfAtoms/threads.getNumThreads();
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
*/ */
class CpuNeighborList::Voxels { class CpuNeighborList::Voxels {
public: public:
Voxels(int blockSize, float vsy, float vsz, float miny, float maxy, float minz, float maxz, const RealVec* boxVectors, bool usePeriodic) : Voxels(int blockSize, float vsy, float vsz, float miny, float maxy, float minz, float maxz, const Vec3* boxVectors, bool usePeriodic) :
blockSize(blockSize), voxelSizeY(vsy), voxelSizeZ(vsz), miny(miny), maxy(maxy), minz(minz), maxz(maxz), usePeriodic(usePeriodic) { blockSize(blockSize), voxelSizeY(vsy), voxelSizeZ(vsz), miny(miny), maxy(maxy), minz(minz), maxz(maxz), usePeriodic(usePeriodic) {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
...@@ -413,7 +413,7 @@ CpuNeighborList::CpuNeighborList(int blockSize) : blockSize(blockSize) { ...@@ -413,7 +413,7 @@ CpuNeighborList::CpuNeighborList(int blockSize) : blockSize(blockSize) {
} }
void CpuNeighborList::computeNeighborList(int numAtoms, const AlignedArray<float>& atomLocations, const vector<set<int> >& exclusions, void CpuNeighborList::computeNeighborList(int numAtoms, const AlignedArray<float>& atomLocations, const vector<set<int> >& exclusions,
const RealVec* periodicBoxVectors, bool usePeriodic, float maxDistance, ThreadPool& threads) { const Vec3* periodicBoxVectors, bool usePeriodic, float maxDistance, ThreadPool& threads) {
int numBlocks = (numAtoms+blockSize-1)/blockSize; int numBlocks = (numAtoms+blockSize-1)/blockSize;
blockNeighbors.resize(numBlocks); blockNeighbors.resize(numBlocks);
blockExclusions.resize(numBlocks); blockExclusions.resize(numBlocks);
......
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