Commit 480c695c authored by Jason Swails's avatar Jason Swails
Browse files

A few fixes.

parent 99628218
...@@ -94,6 +94,24 @@ public: ...@@ -94,6 +94,24 @@ public:
void getStretchBendParameters(int index, int& particle1, int& particle2, int& particle3, double& lengthAB, void getStretchBendParameters(int index, int& particle1, int& particle2, int& particle3, double& lengthAB,
double& lengthCB, double& angle, double& k1, double& k2) const; double& lengthCB, double& angle, double& k1, double& k2) const;
/**
* Get the force field parameters for a stretch-bend term, provided for
* backwards-compatibility. Since the two force constants may be different,
* you are recommended to call the other version of getStretchBendParameters
* with both a k1 and k2
*
* @param index the index of the stretch-bend for which to get parameters
* @param particle1 the index of the first particle connected by the stretch-bend
* @param particle2 the index of the second particle connected by the stretch-bend
* @param particle3 the index of the third particle connected by the stretch-bend
* @param lengthAB the equilibrium length of the stretch-bend in bond ab [particle1, particle2], measured in nm
* @param lengthCB the equilibrium length of the stretch-bend in bond cb [particle3, particle2], measured in nm
* @param angle the equilibrium angle in radians
* @param k1 the force constant
*/
void getStretchBendParameters(int index, int& particle1, int& particle2, int& particle3, double& lengthAB,
double& lengthCB, double& angle, double& k1) const;
/** /**
* Set the force field parameters for a stretch-bend term. * Set the force field parameters for a stretch-bend term.
* *
......
...@@ -483,7 +483,7 @@ private: ...@@ -483,7 +483,7 @@ private:
}; };
CudaCalcAmoebaStretchBendForceKernel::CudaCalcAmoebaStretchBendForceKernel(std::string name, const Platform& platform, CudaContext& cu, const System& system) : CudaCalcAmoebaStretchBendForceKernel::CudaCalcAmoebaStretchBendForceKernel(std::string name, const Platform& platform, CudaContext& cu, const System& system) :
CalcAmoebaStretchBendForceKernel(name, platform), cu(cu), system(system), params(NULL) { CalcAmoebaStretchBendForceKernel(name, platform), cu(cu), system(system), params1(NULL), params2(NULL) {
} }
CudaCalcAmoebaStretchBendForceKernel::~CudaCalcAmoebaStretchBendForceKernel() { CudaCalcAmoebaStretchBendForceKernel::~CudaCalcAmoebaStretchBendForceKernel() {
...@@ -539,14 +539,17 @@ void CudaCalcAmoebaStretchBendForceKernel::copyParametersToContext(ContextImpl& ...@@ -539,14 +539,17 @@ void CudaCalcAmoebaStretchBendForceKernel::copyParametersToContext(ContextImpl&
// Record the per-stretch-bend parameters. // Record the per-stretch-bend parameters.
vector<float4> paramVector(numStretchBends); vector<float3> paramVector(numStretchBends);
vector<float2> paramVector1(numStretchBends);
for (int i = 0; i < numStretchBends; i++) { for (int i = 0; i < numStretchBends; i++) {
int atom1, atom2, atom3; int atom1, atom2, atom3;
double lengthAB, lengthCB, angle, k; double lengthAB, lengthCB, angle, k1, k2;
force.getStretchBendParameters(startIndex+i, atom1, atom2, atom3, lengthAB, lengthCB, angle, k); force.getStretchBendParameters(startIndex+i, atom1, atom2, atom3, lengthAB, lengthCB, angle, k1, k2);
paramVector[i] = make_float4((float) lengthAB, (float) lengthCB, (float) angle, (float) k); paramVector[i] = make_float3((float) lengthAB, (float) lengthCB, (float) angle);
paramVector1[i] = make_flaot2((float) k1, (float) k2);
} }
params->upload(paramVector); params1->upload(paramVector);
params2->upload(paramVector1);
// Mark that the current reordering may be invalid. // Mark that the current reordering may be invalid.
......
...@@ -52,7 +52,7 @@ using OpenMM::RealVec; ...@@ -52,7 +52,7 @@ using OpenMM::RealVec;
RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn( const RealVec& positionAtomA, const RealVec& positionAtomB, RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn( const RealVec& positionAtomA, const RealVec& positionAtomB,
const RealVec& positionAtomC, const RealVec& positionAtomC,
RealOpenMM lengthAB, RealOpenMM lengthCB, RealOpenMM lengthAB, RealOpenMM lengthCB,
RealOpenMM idealAngle, RealOpenMM kParameter, RealOpenMM idealAngle, RealOpenMM k1Parameter,
RealOpenMM k2Parameter, RealVec* forces ) const { RealOpenMM k2Parameter, RealVec* forces ) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -156,7 +156,8 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateForceAndEnergy( int numStre ...@@ -156,7 +156,8 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateForceAndEnergy( int numStre
const std::vector<RealOpenMM>& lengthABParameters, const std::vector<RealOpenMM>& lengthABParameters,
const std::vector<RealOpenMM>& lengthCBParameters, const std::vector<RealOpenMM>& lengthCBParameters,
const std::vector<RealOpenMM>& angle, const std::vector<RealOpenMM>& angle,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<RealOpenMM>& k1Quadratic,
const std::vector<RealOpenMM>& k2Quadratic,
vector<RealVec>& forceData) const { vector<RealVec>& forceData) const {
RealOpenMM energy = 0.0; RealOpenMM energy = 0.0;
for (unsigned int ii = 0; ii < static_cast<unsigned int>(numStretchBends); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(numStretchBends); ii++) {
...@@ -166,10 +167,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateForceAndEnergy( int numStre ...@@ -166,10 +167,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateForceAndEnergy( int numStre
RealOpenMM abLength = lengthABParameters[ii]; RealOpenMM abLength = lengthABParameters[ii];
RealOpenMM cbLength = lengthCBParameters[ii]; RealOpenMM cbLength = lengthCBParameters[ii];
RealOpenMM idealAngle = angle[ii]; RealOpenMM idealAngle = angle[ii];
RealOpenMM angleK = kQuadratic[ii]; RealOpenMM angleK1 = k1Quadratic[ii];
RealOpenMM angleK2 = k2Quadratic[ii];
RealVec forces[3]; RealVec forces[3];
energy += calculateStretchBendIxn( posData[particle1Index], posData[particle2Index], posData[particle3Index], energy += calculateStretchBendIxn( posData[particle1Index], posData[particle2Index], posData[particle3Index],
abLength, cbLength, idealAngle, angleK, forces ); abLength, cbLength, idealAngle, angleK1, anglek2, forces );
// accumulate forces // accumulate forces
for( int jj = 0; jj < 3; jj++ ){ for( int jj = 0; jj < 3; jj++ ){
......
...@@ -77,7 +77,8 @@ public: ...@@ -77,7 +77,8 @@ public:
const std::vector<RealOpenMM>& lengthABParameters, const std::vector<RealOpenMM>& lengthABParameters,
const std::vector<RealOpenMM>& lengthCBParameters, const std::vector<RealOpenMM>& lengthCBParameters,
const std::vector<RealOpenMM>& angle, const std::vector<RealOpenMM>& angle,
const std::vector<RealOpenMM>& kQuadratic, const std::vector<RealOpenMM>& k1Quadratic,
const std::vector<RealOpenMM>& k2Quadratic,
std::vector<OpenMM::RealVec>& forceData ) const; std::vector<OpenMM::RealVec>& forceData ) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment