Commit 162d69a2 authored by peastman's avatar peastman
Browse files

Merge pull request #827 from peastman/reference

Lots of cleanup to reference platform
parents 2379b982 c44c956d
......@@ -25,14 +25,12 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceAngleBondIxn.h"
#include "ReferenceForce.h"
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn::ReferenceAngleBondIxn( ){
ReferenceAngleBondIxn::ReferenceAngleBondIxn() {
// ---------------------------------------------------------------------------------------
......@@ -56,7 +54,7 @@ ReferenceAngleBondIxn::ReferenceAngleBondIxn( ){
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn::~ReferenceAngleBondIxn( ){
ReferenceAngleBondIxn::~ReferenceAngleBondIxn() {
// ---------------------------------------------------------------------------------------
......@@ -78,8 +76,8 @@ ReferenceAngleBondIxn::~ReferenceAngleBondIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, RealOpenMM* angleParameters,
RealOpenMM* dEdR, RealOpenMM* energyTerm ) const {
void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(RealOpenMM cosine, RealOpenMM* angleParameters,
RealOpenMM* dEdR, RealOpenMM* energyTerm) const {
// ---------------------------------------------------------------------------------------
......@@ -92,9 +90,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Re
// ---------------------------------------------------------------------------------------
RealOpenMM angle;
if( cosine >= one ){
if (cosine >= one) {
angle = zero;
} else if( cosine <= -one ){
} else if (cosine <= -one) {
angle = PI_M;
} else {
angle = ACOS(cosine);
......@@ -120,11 +118,11 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Re
--------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
void ReferenceAngleBondIxn::calculateBondIxn(int* atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* totalEnergy ) const {
RealOpenMM* totalEnergy) const {
// constants -- reduce Visual Studio warnings regarding conversions between float & double
......@@ -147,31 +145,31 @@ void ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
int atomAIndex = atomIndices[0];
int atomBIndex = atomIndices[1];
int atomCIndex = atomIndices[2];
ReferenceForce::getDeltaR( atomCoordinates[atomAIndex], atomCoordinates[atomBIndex], deltaR[0] );
ReferenceForce::getDeltaR( atomCoordinates[atomCIndex], atomCoordinates[atomBIndex], deltaR[1] );
ReferenceForce::getDeltaR(atomCoordinates[atomAIndex], atomCoordinates[atomBIndex], deltaR[0]);
ReferenceForce::getDeltaR(atomCoordinates[atomCIndex], atomCoordinates[atomBIndex], deltaR[1]);
RealOpenMM pVector[threeI];
SimTKOpenMMUtilities::crossProductVector3( deltaR[0], deltaR[1], pVector );
RealOpenMM rp = DOT3( pVector, pVector );
rp = SQRT( rp );
if( rp < 1.0e-06 ){
SimTKOpenMMUtilities::crossProductVector3(deltaR[0], deltaR[1], pVector);
RealOpenMM rp = DOT3(pVector, pVector);
rp = SQRT(rp);
if (rp < 1.0e-06) {
rp = (RealOpenMM) 1.0e-06;
}
RealOpenMM dot = DOT3( deltaR[0], deltaR[1] );
RealOpenMM cosine = dot/SQRT( (deltaR[0][ReferenceForce::R2Index]*deltaR[1][ReferenceForce::R2Index]) );
RealOpenMM dot = DOT3(deltaR[0], deltaR[1]);
RealOpenMM cosine = dot/SQRT((deltaR[0][ReferenceForce::R2Index]*deltaR[1][ReferenceForce::R2Index]));
RealOpenMM dEdR;
RealOpenMM energy;
getPrefactorsGivenAngleCosine( cosine, parameters, &dEdR, &energy );
getPrefactorsGivenAngleCosine(cosine, parameters, &dEdR, &energy);
RealOpenMM termA = dEdR/(deltaR[0][ReferenceForce::R2Index]*rp);
RealOpenMM termC = -dEdR/(deltaR[1][ReferenceForce::R2Index]*rp);
RealOpenMM deltaCrossP[LastAtomIndex][threeI];
SimTKOpenMMUtilities::crossProductVector3( deltaR[0], pVector, deltaCrossP[0] );
SimTKOpenMMUtilities::crossProductVector3( deltaR[1], pVector, deltaCrossP[2] );
SimTKOpenMMUtilities::crossProductVector3(deltaR[0], pVector, deltaCrossP[0]);
SimTKOpenMMUtilities::crossProductVector3(deltaR[1], pVector, deltaCrossP[2]);
for( int ii = 0; ii < threeI; ii++ ){
for (int ii = 0; ii < threeI; ii++) {
deltaCrossP[0][ii] *= termA;
deltaCrossP[2][ii] *= termC;
deltaCrossP[1][ii] = oneM*(deltaCrossP[0][ii] + deltaCrossP[2][ii]);
......@@ -179,8 +177,8 @@ void ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
// accumulate forces
for( int jj = 0; jj < LastAtomIndex; jj++ ){
for( int ii = 0; ii < threeI; ii++ ){
for (int jj = 0; jj < LastAtomIndex; jj++) {
for (int ii = 0; ii < threeI; ii++) {
forces[atomIndices[jj]][ii] += deltaCrossP[jj][ii];
}
}
......
......@@ -25,13 +25,11 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceBondForce.h"
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -39,7 +37,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceBondForce::ReferenceBondForce( ){
ReferenceBondForce::ReferenceBondForce() {
// ---------------------------------------------------------------------------------------
......@@ -55,7 +53,7 @@ ReferenceBondForce::ReferenceBondForce( ){
--------------------------------------------------------------------------------------- */
ReferenceBondForce::~ReferenceBondForce( ){
ReferenceBondForce::~ReferenceBondForce() {
// ---------------------------------------------------------------------------------------
......@@ -80,12 +78,12 @@ ReferenceBondForce::~ReferenceBondForce( ){
--------------------------------------------------------------------------------------- */
void ReferenceBondForce::calculateForce( int numberOfBonds, int** atomIndices,
void ReferenceBondForce::calculateForce(int numberOfBonds, int** atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM** parameters,
vector<RealVec>& forces,
RealOpenMM *totalEnergy,
ReferenceBondIxn& referenceBondIxn ){
ReferenceBondIxn& referenceBondIxn) {
// ---------------------------------------------------------------------------------------
......@@ -94,12 +92,12 @@ void ReferenceBondForce::calculateForce( int numberOfBonds, int** atomIndices,
// ---------------------------------------------------------------------------------------
for( int ii = 0; ii < numberOfBonds; ii++ ){
for (int ii = 0; ii < numberOfBonds; ii++) {
// calculate bond ixn
referenceBondIxn.calculateBondIxn( atomIndices[ii], atomCoordinates, parameters[ii],
forces, totalEnergy );
referenceBondIxn.calculateBondIxn(atomIndices[ii], atomCoordinates, parameters[ii],
forces, totalEnergy);
}
}
......@@ -25,14 +25,12 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceBondIxn.h"
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceBondIxn::ReferenceBondIxn( ){
ReferenceBondIxn::ReferenceBondIxn() {
// ---------------------------------------------------------------------------------------
......@@ -56,7 +54,7 @@ ReferenceBondIxn::ReferenceBondIxn( ){
--------------------------------------------------------------------------------------- */
ReferenceBondIxn::~ReferenceBondIxn( ){
ReferenceBondIxn::~ReferenceBondIxn() {
// ---------------------------------------------------------------------------------------
......@@ -78,9 +76,9 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceBondIxn::calculateBondIxn( int* atomIndices, vector<RealVec>& atomCoordinates,
void ReferenceBondIxn::calculateBondIxn(int* atomIndices, vector<RealVec>& atomCoordinates,
RealOpenMM* parameters, vector<RealVec>& forces,
RealOpenMM* totalEnergy ) const {
RealOpenMM* totalEnergy) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::calculateBondIxn";
......@@ -104,8 +102,8 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenMM* vector2,
int hasREntry = 0 ) {
RealOpenMM ReferenceBondIxn::getNormedDotProduct(RealOpenMM* vector1, RealOpenMM* vector2,
int hasREntry = 0) {
// ---------------------------------------------------------------------------------------
......@@ -124,35 +122,35 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
#if defined USE_DOUBLE_FOR_NORMED_DOT_PRODUCT
double v1D[3];
double v2D[3];
v1D[0] = static_cast<double>( vector1[0] );
v1D[1] = static_cast<double>( vector1[1] );
v1D[2] = static_cast<double>( vector1[2] );
v2D[0] = static_cast<double>( vector2[0] );
v2D[1] = static_cast<double>( vector2[1] );
v2D[2] = static_cast<double>( vector2[2] );
double dotProductD = DOT3( v1D, v2D );
if( dotProductD != 0.0 ){
if( hasREntry ){
dotProductD /= ( static_cast<double>(vector1[ReferenceForce::RIndex])*static_cast<double>(vector2[ReferenceForce::RIndex]) );
v1D[0] = static_cast<double>(vector1[0]);
v1D[1] = static_cast<double>(vector1[1]);
v1D[2] = static_cast<double>(vector1[2]);
v2D[0] = static_cast<double>(vector2[0]);
v2D[1] = static_cast<double>(vector2[1]);
v2D[2] = static_cast<double>(vector2[2]);
double dotProductD = DOT3(v1D, v2D);
if (dotProductD != 0.0) {
if (hasREntry) {
dotProductD /= (static_cast<double>(vector1[ReferenceForce::RIndex])*static_cast<double>(vector2[ReferenceForce::RIndex]));
} else {
double norm1 = DOT3( v1D, v1D );
double norm2 = DOT3( v2D, v2D);
dotProductD /= sqrt( norm1*norm2 );
double norm1 = DOT3(v1D, v1D);
double norm2 = DOT3(v2D, v2D);
dotProductD /= sqrt(norm1*norm2);
}
}
RealOpenMM dotProduct = static_cast<RealOpenMM>(dotProductD);
#else
RealOpenMM dotProduct = DOT3( vector1, vector2 );
if( dotProduct != zero ){
if( hasREntry ){
dotProduct /= ( vector1[ReferenceForce::RIndex]*vector2[ReferenceForce::RIndex] );
RealOpenMM dotProduct = DOT3(vector1, vector2);
if (dotProduct != zero) {
if (hasREntry) {
dotProduct /= (vector1[ReferenceForce::RIndex]*vector2[ReferenceForce::RIndex]);
} else {
RealOpenMM norm1 = DOT3( vector1, vector1 );
RealOpenMM norm2 = DOT3( vector2, vector2 );
dotProduct /= SQRT( norm1*norm2 );
RealOpenMM norm1 = DOT3(vector1, vector1);
RealOpenMM norm2 = DOT3(vector2, vector2);
dotProduct /= SQRT(norm1*norm2);
}
}
......@@ -161,9 +159,9 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
// clamp dot product to [-1,1]
if( dotProduct > one ){
if (dotProduct > one) {
dotProduct = one;
} else if( dotProduct < -one ){
} else if (dotProduct < -one) {
dotProduct = -one;
}
......@@ -185,9 +183,9 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, RealOpenMM* vector2,
RealOpenMM* outputDotProduct = NULL,
int hasREntry = 0 ) {
RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors(RealOpenMM* vector1, RealOpenMM* vector2,
RealOpenMM* outputDotProduct = NULL,
int hasREntry = 0) {
// ---------------------------------------------------------------------------------------
......@@ -200,7 +198,7 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
// get dot product betweenn vectors and then angle
RealOpenMM dotProduct = getNormedDotProduct( vector1, vector2, hasREntry );
RealOpenMM dotProduct = getNormedDotProduct(vector1, vector2, hasREntry);
RealOpenMM angle;
if (dotProduct > (RealOpenMM) 0.99 || dotProduct < (RealOpenMM) -0.99) {
......@@ -216,7 +214,7 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
angle = ACOS(dotProduct);
}
if( outputDotProduct ){
if (outputDotProduct) {
*outputDotProduct = dotProduct;
}
......@@ -242,14 +240,14 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* vector1,
RealOpenMM* vector2,
RealOpenMM* vector3,
RealOpenMM** outputCrossProduct = NULL,
RealOpenMM* cosineOfAngle = NULL,
RealOpenMM* signVector = NULL,
RealOpenMM* signOfAngle = NULL,
int hasREntry = 0 ) {
RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors(RealOpenMM* vector1,
RealOpenMM* vector2,
RealOpenMM* vector3,
RealOpenMM** outputCrossProduct = NULL,
RealOpenMM* cosineOfAngle = NULL,
RealOpenMM* signVector = NULL,
RealOpenMM* signOfAngle = NULL,
int hasREntry = 0) {
// ---------------------------------------------------------------------------------------
......@@ -265,7 +263,7 @@ RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* v
// get cross products between vectors and then angle between cross product vectors
RealOpenMM* crossProduct[2];
if( outputCrossProduct ){
if (outputCrossProduct) {
crossProduct[0] = outputCrossProduct[0];
crossProduct[1] = outputCrossProduct[1];
} else {
......@@ -273,17 +271,17 @@ RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* v
crossProduct[1] = tempVectors + 3;
}
SimTKOpenMMUtilities::crossProductVector3( vector1, vector2, crossProduct[0] );
SimTKOpenMMUtilities::crossProductVector3( vector2, vector3, crossProduct[1] );
SimTKOpenMMUtilities::crossProductVector3(vector1, vector2, crossProduct[0]);
SimTKOpenMMUtilities::crossProductVector3(vector2, vector3, crossProduct[1]);
RealOpenMM angle = getAngleBetweenTwoVectors( crossProduct[0], crossProduct[1], cosineOfAngle, 0 );
RealOpenMM angle = getAngleBetweenTwoVectors(crossProduct[0], crossProduct[1], cosineOfAngle, 0);
// take care of sign of angle
if( signVector ){
RealOpenMM dotProduct = DOT3( signVector, crossProduct[1] );
if (signVector) {
RealOpenMM dotProduct = DOT3(signVector, crossProduct[1]);
RealOpenMM sign = dotProduct < zero ? -one : one;
if( signOfAngle ){
if (signOfAngle) {
*signOfAngle = sign;
}
angle *= sign;
......
......@@ -25,16 +25,15 @@
#include <cstring>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceBrownianDynamics.h"
#include "ReferenceVirtualSites.h"
#include "openmm/OpenMMException.h"
#include <cstdio>
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -47,29 +46,15 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceBrownianDynamics::ReferenceBrownianDynamics( int numberOfAtoms,
ReferenceBrownianDynamics::ReferenceBrownianDynamics(int numberOfAtoms,
RealOpenMM deltaT, RealOpenMM friction,
RealOpenMM temperature ) :
ReferenceDynamics( numberOfAtoms, deltaT, temperature ), friction( friction ) {
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nReferenceBrownianDynamics::ReferenceBrownianDynamics";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
if( friction <= zero ){
RealOpenMM temperature) :
ReferenceDynamics(numberOfAtoms, deltaT, temperature), friction(friction) {
if (friction <= 0) {
std::stringstream message;
message << methodName;
message << " input frction value=" << friction << " is invalid -- setting to 1.";
SimTKOpenMMLog::printError( message );
this->friction = one;
message << "illegal friction value: " << friction;
throw OpenMMException(message.str());
}
xPrime.resize(numberOfAtoms);
inverseMasses.resize(numberOfAtoms);
......@@ -81,7 +66,7 @@ ReferenceBrownianDynamics::ReferenceBrownianDynamics( int numberOfAtoms,
--------------------------------------------------------------------------------------- */
ReferenceBrownianDynamics::~ReferenceBrownianDynamics( ){
ReferenceBrownianDynamics::~ReferenceBrownianDynamics() {
// ---------------------------------------------------------------------------------------
......@@ -99,7 +84,7 @@ ReferenceBrownianDynamics::~ReferenceBrownianDynamics( ){
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceBrownianDynamics::getFriction( void ) const {
RealOpenMM ReferenceBrownianDynamics::getFriction() const {
// ---------------------------------------------------------------------------------------
......@@ -139,10 +124,10 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
// first-time-through initialization
int numberOfAtoms = system.getNumParticles();
if( getTimeStep() == 0 ){
if (getTimeStep() == 0) {
// invert masses
for( int ii = 0; ii < numberOfAtoms; ii++ ){
for (int ii = 0; ii < numberOfAtoms; ii++) {
if (masses[ii] == zero)
inverseMasses[ii] = zero;
else
......@@ -152,7 +137,7 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
// Perform the integration.
const RealOpenMM noiseAmplitude = static_cast<RealOpenMM>( sqrt(2.0*BOLTZ*getTemperature()*getDeltaT()/getFriction()) );
const RealOpenMM noiseAmplitude = static_cast<RealOpenMM>(sqrt(2.0*BOLTZ*getTemperature()*getDeltaT()/getFriction()));
const RealOpenMM forceScale = getDeltaT()/getFriction();
for (int i = 0; i < numberOfAtoms; ++i) {
if (masses[i] != zero)
......@@ -166,7 +151,7 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
// Update the positions and velocities.
RealOpenMM velocityScale = static_cast<RealOpenMM>( 1.0/getDeltaT() );
RealOpenMM velocityScale = static_cast<RealOpenMM>(1.0/getDeltaT());
for (int i = 0; i < numberOfAtoms; ++i) {
if (masses[i] != zero)
for (int j = 0; j < 3; ++j) {
......
......@@ -25,9 +25,7 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMLog.h"
#include "ReferenceCCMAAlgorithm.h"
#include "ReferenceDynamics.h"
#include "quern.h"
......@@ -39,9 +37,7 @@ using std::map;
using std::pair;
using std::vector;
using std::set;
using OpenMM::OpenMMException;
using OpenMM::Vec3;
using OpenMM::RealVec;
using namespace OpenMM;
ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
int numberOfConstraints,
......
......@@ -26,7 +26,7 @@
#include "ReferenceForce.h"
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......
......@@ -24,8 +24,6 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomAngleIxn.h"
#include "ReferenceForce.h"
......@@ -62,7 +60,7 @@ ReferenceCustomAngleIxn::ReferenceCustomAngleIxn(const Lepton::CompiledExpressio
--------------------------------------------------------------------------------------- */
ReferenceCustomAngleIxn::~ReferenceCustomAngleIxn( ){
ReferenceCustomAngleIxn::~ReferenceCustomAngleIxn() {
// ---------------------------------------------------------------------------------------
......@@ -84,11 +82,11 @@ ReferenceCustomAngleIxn::~ReferenceCustomAngleIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceCustomAngleIxn::calculateBondIxn( int* atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* totalEnergy ) const {
void ReferenceCustomAngleIxn::calculateBondIxn(int* atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* totalEnergy) const {
static const std::string methodName = "\nReferenceCustomAngleIxn::calculateAngleIxn";
......
......@@ -25,8 +25,6 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomBondIxn.h"
#include "ReferenceForce.h"
......@@ -62,7 +60,7 @@ ReferenceCustomBondIxn::ReferenceCustomBondIxn(const Lepton::CompiledExpression&
--------------------------------------------------------------------------------------- */
ReferenceCustomBondIxn::~ReferenceCustomBondIxn( ){
ReferenceCustomBondIxn::~ReferenceCustomBondIxn() {
// ---------------------------------------------------------------------------------------
......@@ -84,11 +82,11 @@ ReferenceCustomBondIxn::~ReferenceCustomBondIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceCustomBondIxn::calculateBondIxn( int* atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* totalEnergy ) const {
void ReferenceCustomBondIxn::calculateBondIxn(int* atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* totalEnergy) const {
static const std::string methodName = "\nReferenceCustomBondIxn::calculateBondIxn";
......@@ -110,7 +108,7 @@ void ReferenceCustomBondIxn::calculateBondIxn( int* atomIndices,
int atomAIndex = atomIndices[0];
int atomBIndex = atomIndices[1];
ReferenceForce::getDeltaR( atomCoordinates[atomAIndex], atomCoordinates[atomBIndex], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomAIndex], atomCoordinates[atomBIndex], deltaR);
ReferenceForce::setVariable(energyR, deltaR[ReferenceForce::RIndex]);
ReferenceForce::setVariable(forceR, deltaR[ReferenceForce::RIndex]);
......
......@@ -26,8 +26,6 @@
#include <sstream>
#include <utility>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceCustomCompoundBondIxn.h"
......@@ -37,7 +35,7 @@ using std::pair;
using std::string;
using std::stringstream;
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -72,7 +70,7 @@ ReferenceCustomCompoundBondIxn::ReferenceCustomCompoundBondIxn(int numParticlesP
--------------------------------------------------------------------------------------- */
ReferenceCustomCompoundBondIxn::~ReferenceCustomCompoundBondIxn( ){
ReferenceCustomCompoundBondIxn::~ReferenceCustomCompoundBondIxn() {
}
/**---------------------------------------------------------------------------------------
......@@ -93,7 +91,7 @@ void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<RealVec>& atomCoord
map<string, double> variables = globalParameters;
int numBonds = bondAtoms.size();
for (int bond = 0; bond < numBonds; bond++){
for (int bond = 0; bond < numBonds; bond++) {
for (int j = 0; j < (int) bondParamNames.size(); j++)
variables[bondParamNames[j]] = bondParameters[bond][j];
calculateOneIxn(bond, atomCoordinates, variables, forces, totalEnergy);
......
......@@ -22,8 +22,6 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceVirtualSites.h"
#include "ReferenceCustomDynamics.h"
......@@ -97,7 +95,7 @@ ReferenceCustomDynamics::~ReferenceCustomDynamics() {
void ReferenceCustomDynamics::update(ContextImpl& context, int numberOfAtoms, vector<RealVec>& atomCoordinates,
vector<RealVec>& velocities, vector<RealVec>& forces, vector<RealOpenMM>& masses,
map<string, RealOpenMM>& globals, vector<vector<RealVec> >& perDof, bool& forcesAreValid, RealOpenMM tolerance){
map<string, RealOpenMM>& globals, vector<vector<RealVec> >& perDof, bool& forcesAreValid, RealOpenMM tolerance) {
int numSteps = stepType.size();
globals.insert(context.getParameters().begin(), context.getParameters().end());
oldPos = atomCoordinates;
......
......@@ -25,8 +25,6 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomExternalIxn.h"
#include "ReferenceForce.h"
......@@ -79,7 +77,7 @@ ReferenceCustomExternalIxn::ReferenceCustomExternalIxn(const Lepton::CompiledExp
--------------------------------------------------------------------------------------- */
ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn( ){
ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn() {
// ---------------------------------------------------------------------------------------
......@@ -101,11 +99,11 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceCustomExternalIxn::calculateForce( int atomIndex,
void ReferenceCustomExternalIxn::calculateForce(int atomIndex,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* energy ) const {
RealOpenMM* energy) const {
static const std::string methodName = "\nReferenceCustomExternalIxn::calculateBondIxn";
......
......@@ -25,8 +25,6 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceCustomGBIxn.h"
......@@ -36,7 +34,7 @@ using std::set;
using std::string;
using std::stringstream;
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -86,7 +84,7 @@ ReferenceCustomGBIxn::ReferenceCustomGBIxn(const vector<Lepton::ExpressionProgra
--------------------------------------------------------------------------------------- */
ReferenceCustomGBIxn::~ReferenceCustomGBIxn( ){
ReferenceCustomGBIxn::~ReferenceCustomGBIxn() {
// ---------------------------------------------------------------------------------------
......@@ -105,7 +103,7 @@ ReferenceCustomGBIxn::~ReferenceCustomGBIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceCustomGBIxn::setUseCutoff( RealOpenMM distance, const OpenMM::NeighborList& neighbors ) {
void ReferenceCustomGBIxn::setUseCutoff(RealOpenMM distance, const OpenMM::NeighborList& neighbors) {
cutoff = true;
cutoffDistance = distance;
......@@ -203,8 +201,8 @@ void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, v
else {
// Perform an O(N^2) loop over all atom pairs.
for (int i = 0; i < numAtoms; i++){
for (int j = i+1; j < numAtoms; j++ ){
for (int i = 0; i < numAtoms; i++) {
for (int j = i+1; j < numAtoms; j++) {
if (useExclusions && exclusions[i].find(j) != exclusions[i].end())
continue;
calculateOnePairValue(index, i, j, atomCoordinates, atomParameters, globalParameters, values);
......@@ -275,8 +273,8 @@ void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAto
else {
// Perform an O(N^2) loop over all atom pairs.
for (int i = 0; i < numAtoms; i++){
for (int j = i+1; j < numAtoms; j++ ){
for (int i = 0; i < numAtoms; i++) {
for (int j = i+1; j < numAtoms; j++) {
if (useExclusions && exclusions[i].find(j) != exclusions[i].end())
continue;
calculateOnePairEnergyTerm(index, i, j, atomCoordinates, atomParameters, globalParameters, values, forces, totalEnergy, dEdV);
......@@ -344,8 +342,8 @@ void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<RealVec
else {
// Perform an O(N^2) loop over all atom pairs.
for (int i = 0; i < numAtoms; i++){
for (int j = i+1; j < numAtoms; j++ ){
for (int i = 0; i < numAtoms; i++) {
for (int j = i+1; j < numAtoms; j++) {
bool isExcluded = (exclusions[i].find(j) != exclusions[i].end());
calculateOnePairChainRule(i, j, atomCoordinates, atomParameters, globalParameters, values, forces, dEdV, isExcluded);
calculateOnePairChainRule(j, i, atomCoordinates, atomParameters, globalParameters, values, forces, dEdV, isExcluded);
......
......@@ -26,8 +26,6 @@
#include <sstream>
#include <utility>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceCustomHbondIxn.h"
......@@ -38,7 +36,7 @@ using std::set;
using std::string;
using std::stringstream;
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -65,7 +63,7 @@ ReferenceCustomHbondIxn::ReferenceCustomHbondIxn(const vector<vector<int> >& don
--------------------------------------------------------------------------------------- */
ReferenceCustomHbondIxn::~ReferenceCustomHbondIxn( ){
ReferenceCustomHbondIxn::~ReferenceCustomHbondIxn() {
}
/**---------------------------------------------------------------------------------------
......@@ -129,7 +127,7 @@ void ReferenceCustomHbondIxn::calculatePairIxn(vector<RealVec>& atomCoordinates,
int numDonors = donorAtoms.size();
int numAcceptors = acceptorAtoms.size();
for( int donor = 0; donor < numDonors; donor++ ){
for (int donor = 0; donor < numDonors; donor++) {
// Initialize per-donor parameters.
for (int j = 0; j < (int) donorParamNames.size(); j++)
......@@ -137,7 +135,7 @@ void ReferenceCustomHbondIxn::calculatePairIxn(vector<RealVec>& atomCoordinates,
// loop over atom pairs
for( int acceptor = 0; acceptor < numAcceptors; acceptor++ ){
for (int acceptor = 0; acceptor < numAcceptors; acceptor++) {
if (exclusions[donor].find(acceptor) == exclusions[donor].end()) {
for (int j = 0; j < (int) acceptorParamNames.size(); j++)
variables[acceptorParamNames[j]] = acceptorParameters[acceptor][j];
......
......@@ -26,8 +26,6 @@
#include <sstream>
#include <utility>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceCustomManyParticleIxn.h"
......@@ -104,7 +102,7 @@ ReferenceCustomManyParticleIxn::ReferenceCustomManyParticleIxn(const CustomManyP
CustomManyParticleForceImpl::buildFilterArrays(force, numTypes, particleTypes, orderIndex, particleOrder);
}
ReferenceCustomManyParticleIxn::~ReferenceCustomManyParticleIxn( ){
ReferenceCustomManyParticleIxn::~ReferenceCustomManyParticleIxn() {
}
void ReferenceCustomManyParticleIxn::calculateIxn(vector<RealVec>& atomCoordinates, RealOpenMM** particleParameters,
......
......@@ -25,8 +25,6 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceCustomNonbondedIxn.h"
......@@ -37,7 +35,7 @@ using std::string;
using std::stringstream;
using std::set;
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -73,7 +71,7 @@ ReferenceCustomNonbondedIxn::ReferenceCustomNonbondedIxn(const Lepton::CompiledE
--------------------------------------------------------------------------------------- */
ReferenceCustomNonbondedIxn::~ReferenceCustomNonbondedIxn( ){
ReferenceCustomNonbondedIxn::~ReferenceCustomNonbondedIxn() {
// ---------------------------------------------------------------------------------------
......@@ -92,7 +90,7 @@ ReferenceCustomNonbondedIxn::~ReferenceCustomNonbondedIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceCustomNonbondedIxn::setUseCutoff( RealOpenMM distance, const OpenMM::NeighborList& neighbors ) {
void ReferenceCustomNonbondedIxn::setUseCutoff(RealOpenMM distance, const OpenMM::NeighborList& neighbors) {
cutoff = true;
cutoffDistance = distance;
......@@ -120,7 +118,7 @@ void ReferenceCustomNonbondedIxn::setInteractionGroups(const vector<pair<set<int
--------------------------------------------------------------------------------------- */
void ReferenceCustomNonbondedIxn::setUseSwitchingFunction( RealOpenMM distance ) {
void ReferenceCustomNonbondedIxn::setUseSwitchingFunction(RealOpenMM distance) {
useSwitch = true;
switchingDistance = distance;
}
......@@ -166,10 +164,10 @@ void ReferenceCustomNonbondedIxn::setUseSwitchingFunction( RealOpenMM distance )
--------------------------------------------------------------------------------------- */
void ReferenceCustomNonbondedIxn::calculatePairIxn( int numberOfAtoms, vector<RealVec>& atomCoordinates,
void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<RealVec>& atomCoordinates,
RealOpenMM** atomParameters, vector<set<int> >& exclusions,
RealOpenMM* fixedParameters, const map<string, double>& globalParameters, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) {
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy) {
for (map<string, double>::const_iterator iter = globalParameters.begin(); iter != globalParameters.end(); ++iter) {
ReferenceForce::setVariable(ReferenceForce::getVariablePointer(energyExpression, iter->first), iter->second);
......@@ -245,8 +243,8 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn( int numberOfAtoms, vector<Re
--------------------------------------------------------------------------------------- */
void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& atomCoordinates, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) {
void ReferenceCustomNonbondedIxn::calculateOneIxn(int ii, int jj, vector<RealVec>& atomCoordinates, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy) {
// ---------------------------------------------------------------------------------------
......@@ -268,9 +266,9 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (periodic)
ReferenceForce::getDeltaRPeriodic( atomCoordinates[jj], atomCoordinates[ii], periodicBoxVectors, deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[jj], atomCoordinates[ii], periodicBoxVectors, deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[jj], atomCoordinates[ii], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[jj], atomCoordinates[ii], deltaR);
RealOpenMM r = deltaR[ReferenceForce::RIndex];
if (cutoff && r >= cutoffDistance)
return;
......@@ -290,7 +288,7 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
energy *= switchValue;
}
}
for( int kk = 0; kk < 3; kk++ ){
for (int kk = 0; kk < 3; kk++) {
RealOpenMM force = -dEdR*deltaR[kk];
forces[ii][kk] += force;
forces[jj][kk] -= force;
......@@ -298,10 +296,10 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
// accumulate energies
if( totalEnergy || energyByAtom ) {
if( totalEnergy )
if (totalEnergy || energyByAtom) {
if (totalEnergy)
*totalEnergy += energy;
if( energyByAtom ){
if (energyByAtom) {
energyByAtom[ii] += energy;
energyByAtom[jj] += energy;
}
......
......@@ -24,8 +24,6 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomTorsionIxn.h"
#include "ReferenceForce.h"
......@@ -62,7 +60,7 @@ ReferenceCustomTorsionIxn::ReferenceCustomTorsionIxn(const Lepton::CompiledExpre
--------------------------------------------------------------------------------------- */
ReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn( ){
ReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn() {
// ---------------------------------------------------------------------------------------
......@@ -84,11 +82,11 @@ ReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
void ReferenceCustomTorsionIxn::calculateBondIxn(int* atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* totalEnergy ) const {
RealOpenMM* totalEnergy) const {
static const std::string methodName = "\nReferenceCustomTorsionIxn::calculateTorsionIxn";
......@@ -136,20 +134,20 @@ void ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
RealOpenMM internalF[4][3];
RealOpenMM forceFactors[4];
RealOpenMM normCross1 = DOT3( crossProduct[0], crossProduct[0] );
RealOpenMM normCross1 = DOT3(crossProduct[0], crossProduct[0]);
RealOpenMM normBC = deltaR[1][ReferenceForce::RIndex];
forceFactors[0] = (-dEdAngle*normBC)/normCross1;
RealOpenMM normCross2 = DOT3( crossProduct[1], crossProduct[1] );
RealOpenMM normCross2 = DOT3(crossProduct[1], crossProduct[1]);
forceFactors[3] = (dEdAngle*normBC)/normCross2;
forceFactors[1] = DOT3( deltaR[0], deltaR[1] );
forceFactors[1] = DOT3(deltaR[0], deltaR[1]);
forceFactors[1] /= deltaR[1][ReferenceForce::R2Index];
forceFactors[2] = DOT3( deltaR[2], deltaR[1] );
forceFactors[2] = DOT3(deltaR[2], deltaR[1]);
forceFactors[2] /= deltaR[1][ReferenceForce::R2Index];
for( int ii = 0; ii < 3; ii++ ){
for (int ii = 0; ii < 3; ii++) {
internalF[0][ii] = forceFactors[0]*crossProduct[0][ii];
internalF[3][ii] = forceFactors[3]*crossProduct[1][ii];
......@@ -162,7 +160,7 @@ void ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
// accumulate forces
for( int ii = 0; ii < 3; ii++ ){
for (int ii = 0; ii < 3; ii++) {
forces[atomAIndex][ii] += internalF[0][ii];
forces[atomBIndex][ii] -= internalF[1][ii];
forces[atomCIndex][ii] -= internalF[2][ii];
......
......@@ -25,15 +25,13 @@
#include <cstring>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceDynamics.h"
#include <cstdio>
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -46,7 +44,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceDynamics::ReferenceDynamics( int numberOfAtoms, RealOpenMM deltaT, RealOpenMM temperature ) :
ReferenceDynamics::ReferenceDynamics(int numberOfAtoms, RealOpenMM deltaT, RealOpenMM temperature) :
_numberOfAtoms(numberOfAtoms), _deltaT(deltaT), _temperature(temperature) {
// ---------------------------------------------------------------------------------------
......@@ -69,7 +67,7 @@ ReferenceDynamics::ReferenceDynamics( int numberOfAtoms, RealOpenMM deltaT, Rea
--------------------------------------------------------------------------------------- */
ReferenceDynamics::~ReferenceDynamics( ){
ReferenceDynamics::~ReferenceDynamics() {
// ---------------------------------------------------------------------------------------
......@@ -77,7 +75,7 @@ ReferenceDynamics::~ReferenceDynamics( ){
// ---------------------------------------------------------------------------------------
if( _ownReferenceConstraint ){
if (_ownReferenceConstraint) {
delete _referenceConstraint;
}
}
......@@ -90,7 +88,7 @@ ReferenceDynamics::~ReferenceDynamics( ){
--------------------------------------------------------------------------------------- */
int ReferenceDynamics::getNumberOfAtoms( void ) const {
int ReferenceDynamics::getNumberOfAtoms() const {
// ---------------------------------------------------------------------------------------
......@@ -109,7 +107,7 @@ int ReferenceDynamics::getNumberOfAtoms( void ) const {
--------------------------------------------------------------------------------------- */
int ReferenceDynamics::getTimeStep( void ) const {
int ReferenceDynamics::getTimeStep() const {
// ---------------------------------------------------------------------------------------
......@@ -128,7 +126,7 @@ int ReferenceDynamics::getTimeStep( void ) const {
--------------------------------------------------------------------------------------- */
int ReferenceDynamics::incrementTimeStep( void ){
int ReferenceDynamics::incrementTimeStep() {
// ---------------------------------------------------------------------------------------
......@@ -147,7 +145,7 @@ int ReferenceDynamics::incrementTimeStep( void ){
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceDynamics::getDeltaT( void ) const {
RealOpenMM ReferenceDynamics::getDeltaT() const {
// ---------------------------------------------------------------------------------------
......@@ -164,7 +162,7 @@ RealOpenMM ReferenceDynamics::getDeltaT( void ) const {
--------------------------------------------------------------------------------------- */
void ReferenceDynamics::setDeltaT( RealOpenMM deltaT ) {
void ReferenceDynamics::setDeltaT(RealOpenMM deltaT) {
// ---------------------------------------------------------------------------------------
......@@ -183,7 +181,7 @@ void ReferenceDynamics::setDeltaT( RealOpenMM deltaT ) {
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceDynamics::getTemperature( void ) const {
RealOpenMM ReferenceDynamics::getTemperature() const {
// ---------------------------------------------------------------------------------------
......@@ -202,7 +200,7 @@ RealOpenMM ReferenceDynamics::getTemperature( void ) const {
--------------------------------------------------------------------------------------- */
ReferenceConstraintAlgorithm* ReferenceDynamics::getReferenceConstraintAlgorithm( void ) const {
ReferenceConstraintAlgorithm* ReferenceDynamics::getReferenceConstraintAlgorithm() const {
// ---------------------------------------------------------------------------------------
......@@ -221,7 +219,7 @@ ReferenceConstraintAlgorithm* ReferenceDynamics::getReferenceConstraintAlgorithm
--------------------------------------------------------------------------------------- */
void ReferenceDynamics::setReferenceConstraintAlgorithm( ReferenceConstraintAlgorithm* referenceConstraint ){
void ReferenceDynamics::setReferenceConstraintAlgorithm(ReferenceConstraintAlgorithm* referenceConstraint) {
// ---------------------------------------------------------------------------------------
......@@ -231,7 +229,7 @@ void ReferenceDynamics::setReferenceConstraintAlgorithm( ReferenceConstraintAlgo
// delete if own
if( _referenceConstraint && _ownReferenceConstraint ){
if (_referenceConstraint && _ownReferenceConstraint) {
delete _referenceConstraint;
}
......
......@@ -25,14 +25,12 @@
#include <cstring>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include <cstdio>
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceForce::ReferenceForce( ){
ReferenceForce::ReferenceForce() {
}
/**---------------------------------------------------------------------------------------
......@@ -49,7 +47,7 @@ ReferenceForce::ReferenceForce( ){
--------------------------------------------------------------------------------------- */
ReferenceForce::~ReferenceForce( ){
ReferenceForce::~ReferenceForce() {
}
/**---------------------------------------------------------------------------------------
......@@ -65,28 +63,28 @@ RealOpenMM ReferenceForce::periodicDifference(RealOpenMM val1, RealOpenMM val2,
}
void ReferenceForce::getDeltaR( const RealVec& atomCoordinatesI, const RealVec& atomCoordinatesJ,
RealOpenMM* deltaR ){
void ReferenceForce::getDeltaR(const RealVec& atomCoordinatesI, const RealVec& atomCoordinatesJ,
RealOpenMM* deltaR) {
deltaR[XIndex] = atomCoordinatesJ[0] - atomCoordinatesI[0];
deltaR[YIndex] = atomCoordinatesJ[1] - atomCoordinatesI[1];
deltaR[ZIndex] = atomCoordinatesJ[2] - atomCoordinatesI[2];
deltaR[R2Index] = DOT3( deltaR, deltaR );
deltaR[RIndex] = (RealOpenMM) SQRT( deltaR[R2Index] );
deltaR[R2Index] = DOT3(deltaR, deltaR);
deltaR[RIndex] = (RealOpenMM) SQRT(deltaR[R2Index]);
}
void ReferenceForce::getDeltaRPeriodic( const RealVec& atomCoordinatesI, const RealVec& atomCoordinatesJ,
const RealOpenMM* boxSize, RealOpenMM* deltaR ){
void ReferenceForce::getDeltaRPeriodic(const RealVec& atomCoordinatesI, const RealVec& atomCoordinatesJ,
const RealOpenMM* boxSize, RealOpenMM* deltaR) {
deltaR[XIndex] = periodicDifference(atomCoordinatesJ[0], atomCoordinatesI[0], boxSize[0]);
deltaR[YIndex] = periodicDifference(atomCoordinatesJ[1], atomCoordinatesI[1], boxSize[1]);
deltaR[ZIndex] = periodicDifference(atomCoordinatesJ[2], atomCoordinatesI[2], boxSize[2]);
deltaR[R2Index] = DOT3( deltaR, deltaR );
deltaR[RIndex] = (RealOpenMM) SQRT( deltaR[R2Index] );
deltaR[R2Index] = DOT3(deltaR, deltaR);
deltaR[RIndex] = (RealOpenMM) SQRT(deltaR[R2Index]);
}
void ReferenceForce::getDeltaRPeriodic( const RealVec& atomCoordinatesI, const RealVec& atomCoordinatesJ,
const RealVec* boxVectors, RealOpenMM* deltaR ){
void ReferenceForce::getDeltaRPeriodic(const RealVec& atomCoordinatesI, const RealVec& atomCoordinatesJ,
const RealVec* boxVectors, RealOpenMM* deltaR) {
RealVec diff = atomCoordinatesJ-atomCoordinatesI;
diff -= boxVectors[2]*floor(diff[2]/boxVectors[2][2]+0.5);
diff -= boxVectors[1]*floor(diff[1]/boxVectors[1][1]+0.5);
......
......@@ -25,14 +25,12 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceHarmonicBondIxn.h"
#include "ReferenceForce.h"
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn( ){
ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn() {
// ---------------------------------------------------------------------------------------
......@@ -56,7 +54,7 @@ ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn( ){
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn( ){
ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn() {
// ---------------------------------------------------------------------------------------
......@@ -79,11 +77,11 @@ ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceHarmonicBondIxn::calculateBondIxn( int* atomIndices,
void ReferenceHarmonicBondIxn::calculateBondIxn(int* atomIndices,
vector<RealVec>& atomCoordinates,
RealOpenMM* parameters,
vector<RealVec>& forces,
RealOpenMM* totalEnergy ) const {
RealOpenMM* totalEnergy) const {
static const std::string methodName = "\nReferenceHarmonicBondIxn::calculateBondIxn";
......@@ -101,7 +99,7 @@ void ReferenceHarmonicBondIxn::calculateBondIxn( int* atomIndices,
int atomAIndex = atomIndices[0];
int atomBIndex = atomIndices[1];
ReferenceForce::getDeltaR( atomCoordinates[atomAIndex], atomCoordinates[atomBIndex], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomAIndex], atomCoordinates[atomBIndex], deltaR);
// deltaIdeal = r - r_0
......
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