Commit eb232608 authored by John Chodera (MSKCC)'s avatar John Chodera (MSKCC)
Browse files

Merge remote-tracking branch 'upstream/master'

parents 62581e9c 7f8c5089
......@@ -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);
......
......@@ -26,32 +26,31 @@
#include <sstream>
#include <stdio.h>
#include "SimTKOpenMMCommon.h"
#include "ReferenceForce.h"
#include "CpuGBVI.h"
#include "ReferenceGBVI.h"
using namespace std;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
CpuGBVI constructor
ReferenceGBVI constructor
gbviParameters gbviParameters object
--------------------------------------------------------------------------------------- */
CpuGBVI::CpuGBVI( GBVIParameters* gbviParameters ) : _gbviParameters(gbviParameters) {
_switchDeriviative.resize( gbviParameters->getNumberOfAtoms() );
ReferenceGBVI::ReferenceGBVI(GBVIParameters* gbviParameters) : _gbviParameters(gbviParameters) {
_switchDeriviative.resize(gbviParameters->getNumberOfAtoms());
}
/**---------------------------------------------------------------------------------------
CpuGBVI destructor
ReferenceGBVI destructor
--------------------------------------------------------------------------------------- */
CpuGBVI::~CpuGBVI( ){
ReferenceGBVI::~ReferenceGBVI() {
}
/**---------------------------------------------------------------------------------------
......@@ -62,7 +61,7 @@ CpuGBVI::~CpuGBVI( ){
--------------------------------------------------------------------------------------- */
GBVIParameters* CpuGBVI::getGBVIParameters( void ) const {
GBVIParameters* ReferenceGBVI::getGBVIParameters() const {
return _gbviParameters;
}
......@@ -74,7 +73,7 @@ GBVIParameters* CpuGBVI::getGBVIParameters( void ) const {
--------------------------------------------------------------------------------------- */
void CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
void ReferenceGBVI::setGBVIParameters(GBVIParameters* gbviParameters) {
_gbviParameters = gbviParameters;
}
......@@ -86,7 +85,7 @@ void CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
--------------------------------------------------------------------------------------- */
RealOpenMMVector& CpuGBVI::getSwitchDeriviative( void ){
vector<RealOpenMM>& ReferenceGBVI::getSwitchDeriviative() {
return _switchDeriviative;
}
......@@ -102,17 +101,17 @@ RealOpenMMVector& CpuGBVI::getSwitchDeriviative( void ){
--------------------------------------------------------------------------------------- */
void CpuGBVI::quinticSpline( RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
RealOpenMM* outValue, RealOpenMM* outDerivative ){
void ReferenceGBVI::quinticSpline(RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
RealOpenMM* outValue, RealOpenMM* outDerivative) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM minusSix = static_cast<RealOpenMM>( -6.0 );
static const RealOpenMM minusTen = static_cast<RealOpenMM>( -10.0 );
static const RealOpenMM minusThirty = static_cast<RealOpenMM>( -30.0 );
static const RealOpenMM fifteen = static_cast<RealOpenMM>( 15.0 );
static const RealOpenMM sixty = static_cast<RealOpenMM>( 60.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0);
static const RealOpenMM minusSix = static_cast<RealOpenMM>( -6.0);
static const RealOpenMM minusTen = static_cast<RealOpenMM>(-10.0);
static const RealOpenMM minusThirty = static_cast<RealOpenMM>(-30.0);
static const RealOpenMM fifteen = static_cast<RealOpenMM>( 15.0);
static const RealOpenMM sixty = static_cast<RealOpenMM>( 60.0);
// ---------------------------------------------------------------------------------------
......@@ -140,19 +139,19 @@ void CpuGBVI::quinticSpline( RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
--------------------------------------------------------------------------------------- */
void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, RealOpenMM bornSum,
GBVIParameters* gbviParameters,
RealOpenMM* bornRadius, RealOpenMM* switchDeriviative ){
void ReferenceGBVI::computeBornRadiiUsingQuinticSpline(RealOpenMM atomicRadius3, RealOpenMM bornSum,
GBVIParameters* gbviParameters,
RealOpenMM* bornRadius, RealOpenMM* switchDeriviative) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM minusOne = static_cast<RealOpenMM>( -1.0 );
static const RealOpenMM minusThree = static_cast<RealOpenMM>( -3.0 );
static const RealOpenMM oneEighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>( (-1.0/3.0) );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0);
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0);
static const RealOpenMM minusOne = static_cast<RealOpenMM>(-1.0);
static const RealOpenMM minusThree = static_cast<RealOpenMM>(-3.0);
static const RealOpenMM oneEighth = static_cast<RealOpenMM>( 0.125);
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>((-1.0/3.0));
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0);
// ---------------------------------------------------------------------------------------
......@@ -176,10 +175,10 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
RealOpenMM splineL = gbviParameters->getQuinticLowerLimitFactor()*atomicRadius3;
RealOpenMM sum;
if( bornSum > splineL ){
if( bornSum < atomicRadius3 ){
if (bornSum > splineL) {
if (bornSum < atomicRadius3) {
RealOpenMM splineValue, splineDerivative;
quinticSpline( bornSum, splineL, atomicRadius3, &splineValue, &splineDerivative );
quinticSpline(bornSum, splineL, atomicRadius3, &splineValue, &splineDerivative);
sum = (atomicRadius3 - bornSum)*splineValue + gbviParameters->getQuinticUpperBornRadiusLimit();
*switchDeriviative = splineValue - (atomicRadius3 - bornSum)*splineDerivative;
} else {
......@@ -190,7 +189,7 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
sum = atomicRadius3 - bornSum;
*switchDeriviative = one;
}
*bornRadius = POW( sum, minusOneThird );
*bornRadius = POW(sum, minusOneThird);
}
/**---------------------------------------------------------------------------------------
......@@ -203,66 +202,66 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
--------------------------------------------------------------------------------------- */
void CpuGBVI::computeBornRadii( const vector<RealVec>& atomCoordinates, RealOpenMMVector& bornRadii ){
void ReferenceGBVI::computeBornRadii(const vector<RealVec>& atomCoordinates, vector<RealOpenMM>& bornRadii) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM minusThree = static_cast<RealOpenMM>( -3.0 );
static const RealOpenMM oneEighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>( (-1.0/3.0) );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM minusThree = static_cast<RealOpenMM>(-3.0);
static const RealOpenMM oneEighth = static_cast<RealOpenMM>(0.125);
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>((-1.0/3.0));
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
// ---------------------------------------------------------------------------------------
GBVIParameters* gbviParameters = getGBVIParameters();
int numberOfAtoms = gbviParameters->getNumberOfAtoms();
const RealOpenMMVector& atomicRadii = gbviParameters->getAtomicRadii();
const RealOpenMMVector& scaledRadii = gbviParameters->getScaledRadii();
const vector<RealOpenMM>& atomicRadii = gbviParameters->getAtomicRadii();
const vector<RealOpenMM>& scaledRadii = gbviParameters->getScaledRadii();
RealOpenMMVector& switchDeriviatives = getSwitchDeriviative();
vector<RealOpenMM>& switchDeriviatives = getSwitchDeriviative();
// ---------------------------------------------------------------------------------------
// calculate Born radii
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM radiusI = atomicRadii[atomI];
RealOpenMM sum = zero;
// sum over volumes
for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = 0; atomJ < numberOfAtoms; atomJ++) {
if( atomJ != atomI ){
if (atomJ != atomI) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
RealOpenMM r = deltaR[ReferenceForce::RIndex];
if (_gbviParameters->getUseCutoff() && r > _gbviParameters->getCutoffDistance())
continue;
sum += CpuGBVI::getVolume( r, radiusI, scaledRadii[atomJ] );
sum += ReferenceGBVI::getVolume(r, radiusI, scaledRadii[atomJ]);
}
}
RealOpenMM atomicRadius3 = POW( radiusI, minusThree );
if( _gbviParameters->getBornRadiusScalingMethod() != GBVIParameters::QuinticSpline ){
RealOpenMM atomicRadius3 = POW(radiusI, minusThree);
if (_gbviParameters->getBornRadiusScalingMethod() != GBVIParameters::QuinticSpline) {
sum = atomicRadius3 - sum;
bornRadii[atomI] = POW( sum, minusOneThird );
bornRadii[atomI] = POW(sum, minusOneThird);
switchDeriviatives[atomI] = one;
} else {
RealOpenMM bornRadius, switchDeriviative;
computeBornRadiiUsingQuinticSpline( atomicRadius3, sum, gbviParameters,
&bornRadius, &switchDeriviative );
computeBornRadiiUsingQuinticSpline(atomicRadius3, sum, gbviParameters,
&bornRadius, &switchDeriviative);
bornRadii[atomI] = bornRadius;
switchDeriviatives[atomI] = switchDeriviative;
}
......@@ -281,25 +280,25 @@ void CpuGBVI::computeBornRadii( const vector<RealVec>& atomCoordinates, RealOpen
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::getVolume( RealOpenMM r, RealOpenMM R, RealOpenMM S ){
RealOpenMM ReferenceGBVI::getVolume(RealOpenMM r, RealOpenMM R, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM minusThree = static_cast<RealOpenMM>( -3.0 );
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0);
static const RealOpenMM minusThree = static_cast<RealOpenMM>(-3.0);
RealOpenMM diff = (S - R);
if( FABS( diff ) < r ){
if (FABS(diff) < r) {
RealOpenMM lowerBound = (R > (r - S)) ? R : (r - S);
return (CpuGBVI::getL( r, (r + S), S ) -
CpuGBVI::getL( r, lowerBound, S ));
return (ReferenceGBVI::getL(r, (r + S), S) -
ReferenceGBVI::getL(r, lowerBound, S));
} else if( r <= diff ){
} else if (r <= diff) {
return CpuGBVI::getL( r, (r + S), S ) -
CpuGBVI::getL( r, (r - S), S ) +
POW( R, minusThree );
return ReferenceGBVI::getL(r, (r + S), S) -
ReferenceGBVI::getL(r, (r - S), S) +
POW(R, minusThree);
} else {
return zero;
......@@ -318,15 +317,15 @@ RealOpenMM CpuGBVI::getVolume( RealOpenMM r, RealOpenMM R, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM ReferenceGBVI::getL(RealOpenMM r, RealOpenMM x, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM threeHalves = static_cast<RealOpenMM>( 1.5 );
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM threeHalves = static_cast<RealOpenMM>(1.5);
static const RealOpenMM third = static_cast<RealOpenMM>((1.0/3.0));
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
......@@ -338,7 +337,7 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM diff2 = (r + S)*(r - S);
return (threeHalves*xInv)*( (xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv) );
return (threeHalves*xInv)*((xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv));
}
/**---------------------------------------------------------------------------------------
......@@ -353,16 +352,16 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM ReferenceGBVI::dL_dr(RealOpenMM r, RealOpenMM x, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM threeHalves = static_cast<RealOpenMM>( 1.5 );
static const RealOpenMM threeEights = static_cast<RealOpenMM>( 0.375 );
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM threeHalves = static_cast<RealOpenMM>(1.5);
static const RealOpenMM threeEights = static_cast<RealOpenMM>(0.375);
static const RealOpenMM third = static_cast<RealOpenMM>((1.0/3.0));
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
......@@ -375,7 +374,7 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM diff2 = (r + S)*(r - S);
return ( (-threeHalves*xInv2*rInv2)*( fourth + eighth*diff2*xInv2 ) + threeEights*xInv3*xInv );
return ((-threeHalves*xInv2*rInv2)*(fourth + eighth*diff2*xInv2) + threeEights*xInv3*xInv);
}
/**---------------------------------------------------------------------------------------
......@@ -390,14 +389,14 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM ReferenceGBVI::dL_dx(RealOpenMM r, RealOpenMM x, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM threeHalvesM = static_cast<RealOpenMM>( -1.5 );
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0);
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5);
static const RealOpenMM threeHalvesM = static_cast<RealOpenMM>(-1.5);
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0));
// ---------------------------------------------------------------------------------------
......@@ -409,7 +408,7 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM diff = (r + S)*(r - S);
return (threeHalvesM*xInv3)*( (half*rInv) - xInv + (half*diff*xInv2*rInv) );
return (threeHalvesM*xInv3)*((half*rInv) - xInv + (half*diff*xInv2*rInv));
}
/**---------------------------------------------------------------------------------------
......@@ -422,19 +421,19 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
RealOpenMM ReferenceGBVI::Sgb(RealOpenMM t) {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "CpuGBVI::Sgb";
// static const char* methodName = "ReferenceGBVI::Sgb";
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
// ---------------------------------------------------------------------------------------
return ( (t != zero) ? one/SQRT( (one + (fourth*EXP( -t ))/t) ) : zero);
return ((t != zero) ? one/SQRT((one + (fourth*EXP(-t))/t)) : zero);
}
/**---------------------------------------------------------------------------------------
......@@ -448,31 +447,31 @@ RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges ){
RealOpenMM ReferenceGBVI::computeBornEnergy(const vector<RealVec>& atomCoordinates, const vector<RealOpenMM>& partialCharges) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM four = static_cast<RealOpenMM>( 4.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM two = static_cast<RealOpenMM>(2.0);
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
static const RealOpenMM four = static_cast<RealOpenMM>(4.0);
static const RealOpenMM half = static_cast<RealOpenMM>(0.5);
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
const GBVIParameters* gbviParameters = getGBVIParameters();
const RealOpenMM preFactor = gbviParameters->getElectricConstant();
const int numberOfAtoms = gbviParameters->getNumberOfAtoms();
const RealOpenMMVector& atomicRadii = gbviParameters->getAtomicRadii();
const RealOpenMMVector& gammaParameters = gbviParameters->getGammaParameters();
const vector<RealOpenMM>& atomicRadii = gbviParameters->getAtomicRadii();
const vector<RealOpenMM>& gammaParameters = gbviParameters->getGammaParameters();
// compute Born radii
RealOpenMMVector bornRadii( numberOfAtoms );
computeBornRadii( atomCoordinates, bornRadii );
vector<RealOpenMM> bornRadii(numberOfAtoms);
computeBornRadii(atomCoordinates, bornRadii);
// ---------------------------------------------------------------------------------------
......@@ -483,7 +482,7 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
RealOpenMM energy = zero;
RealOpenMM cavityEnergy = zero;
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM partialChargeI = partialCharges[atomI];
......@@ -496,19 +495,19 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
RealOpenMM ratio = (atomicRadii[atomI]/bornRadii[atomI]);
cavityEnergy += gammaParameters[atomI]*ratio*ratio*ratio;
for( int atomJ = atomI + 1; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = atomI + 1; atomJ < numberOfAtoms; atomJ++) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_gbviParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > _gbviParameters->getCutoffDistance())
continue;
RealOpenMM r2 = deltaR[ReferenceForce::R2Index];
RealOpenMM t = fourth*r2/(bornRadii[atomI]*bornRadii[atomJ]);
atomIEnergy += partialCharges[atomJ]*Sgb( t )/deltaR[ReferenceForce::RIndex];
atomIEnergy += partialCharges[atomJ]*Sgb(t)/deltaR[ReferenceForce::RIndex];
}
energy += two*partialChargeI*atomIEnergy;
......@@ -532,27 +531,27 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
--------------------------------------------------------------------------------------- */
void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges,
std::vector<OpenMM::RealVec>& inputForces){
void ReferenceGBVI::computeBornForces(std::vector<RealVec>& atomCoordinates, const vector<RealOpenMM>& partialCharges,
std::vector<OpenMM::RealVec>& inputForces) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM four = static_cast<RealOpenMM>( 4.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM oneThird = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM two = static_cast<RealOpenMM>(2.0);
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
static const RealOpenMM four = static_cast<RealOpenMM>(4.0);
static const RealOpenMM half = static_cast<RealOpenMM>(0.5);
static const RealOpenMM oneThird = static_cast<RealOpenMM>((1.0/3.0));
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
const GBVIParameters* gbviParameters = getGBVIParameters();
const int numberOfAtoms = gbviParameters->getNumberOfAtoms();
const RealOpenMMVector& atomicRadii = gbviParameters->getAtomicRadii();
const RealOpenMMVector& gammaParameters = gbviParameters->getGammaParameters();
const vector<RealOpenMM>& atomicRadii = gbviParameters->getAtomicRadii();
const vector<RealOpenMM>& gammaParameters = gbviParameters->getGammaParameters();
// ---------------------------------------------------------------------------------------
......@@ -564,37 +563,37 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// compute Born radii
RealOpenMMVector bornRadii( numberOfAtoms );
computeBornRadii( atomCoordinates, bornRadii );
vector<RealOpenMM> bornRadii(numberOfAtoms);
computeBornRadii(atomCoordinates, bornRadii);
// set energy/forces to zero
std::vector<OpenMM::RealVec> forces( numberOfAtoms );
for( int ii = 0; ii < numberOfAtoms; ii++ ){
std::vector<OpenMM::RealVec> forces(numberOfAtoms);
for (int ii = 0; ii < numberOfAtoms; ii++) {
forces[ii][0] = zero;
forces[ii][1] = zero;
forces[ii][2] = zero;
}
RealOpenMMVector bornForces( numberOfAtoms, 0.0);
vector<RealOpenMM> bornForces(numberOfAtoms, 0.0);
// ---------------------------------------------------------------------------------------
// first main loop
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
// partial of polar term wrt Born radius
// and (dGpol/dr)(dr/dx)
RealOpenMM partialChargeI = preFactor*partialCharges[atomI];
for( int atomJ = atomI; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = atomI; atomJ < numberOfAtoms; atomJ++) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_gbviParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > _gbviParameters->getCutoffDistance())
continue;
......@@ -607,16 +606,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM alpha2_ij = bornRadii[atomI]*bornRadii[atomJ];
RealOpenMM D_ij = r2/(four*alpha2_ij);
RealOpenMM expTerm = EXP( -D_ij );
RealOpenMM expTerm = EXP(-D_ij);
RealOpenMM denominator2 = r2 + alpha2_ij*expTerm;
RealOpenMM denominator = SQRT( denominator2 );
RealOpenMM denominator = SQRT(denominator2);
RealOpenMM Gpol = (partialChargeI*partialCharges[atomJ])/denominator;
RealOpenMM dGpol_dr = -Gpol*( one - fourth*expTerm )/denominator2;
RealOpenMM dGpol_dr = -Gpol*(one - fourth*expTerm)/denominator2;
RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*( one + D_ij )/denominator2;
RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*(one + D_ij)/denominator2;
if( atomI != atomJ ){
if (atomI != atomJ) {
bornForces[atomJ] += dGpol_dalpha2_ij*bornRadii[atomI];
......@@ -645,9 +644,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// dGpol/dBornRadius) = bornForces[]
// dBornRadius/dr = (1/3)*(bR**4)*(dV/dr)
const RealOpenMMVector& scaledRadii = gbviParameters->getScaledRadii();
const RealOpenMMVector& switchDeriviative = getSwitchDeriviative();
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
const vector<RealOpenMM>& scaledRadii = gbviParameters->getScaledRadii();
const vector<RealOpenMM>& switchDeriviative = getSwitchDeriviative();
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM R = atomicRadii[atomI];
......@@ -659,9 +658,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM b2 = bornRadii[atomI]*bornRadii[atomI];
bornForces[atomI] *= switchDeriviative[atomI]*oneThird*b2*b2;
for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = 0; atomJ < numberOfAtoms; atomJ++) {
if( atomJ != atomI ){
if (atomJ != atomI) {
RealOpenMM deltaX = atomCoordinates[atomJ][0] - atomCoordinates[atomI][0];
RealOpenMM deltaY = atomCoordinates[atomJ][1] - atomCoordinates[atomI][1];
......@@ -669,9 +668,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_gbviParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > _gbviParameters->getCutoffDistance())
continue;
......@@ -680,7 +679,7 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
deltaY = deltaR[ReferenceForce::YIndex];
deltaZ = deltaR[ReferenceForce::ZIndex];
RealOpenMM r = SQRT( r2 );
RealOpenMM r = SQRT(r2);
RealOpenMM S = scaledRadii[atomJ];
RealOpenMM diff = (S - R);
......@@ -689,16 +688,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// find dRb/dr, where Rb is the Born radius
if( FABS( diff ) < r ){
de = CpuGBVI::dL_dr( r, r+S, S ) + CpuGBVI::dL_dx( r, r+S, S );
if( R > (r - S) ){
de -= CpuGBVI::dL_dr( r, R, S );
if (FABS(diff) < r) {
de = ReferenceGBVI::dL_dr(r, r+S, S) + ReferenceGBVI::dL_dx(r, r+S, S);
if (R > (r - S)) {
de -= ReferenceGBVI::dL_dr(r, R, S);
} else {
de -= ( CpuGBVI::dL_dr( r, (r-S), S ) + CpuGBVI::dL_dx( r, (r-S), S ) );
de -= (ReferenceGBVI::dL_dr(r, (r-S), S) + ReferenceGBVI::dL_dx(r, (r-S), S));
}
} else if( r < (S - R) ){
de = CpuGBVI::dL_dr( r, r+S, S ) + CpuGBVI::dL_dx( r, r+S, S );
de -= ( CpuGBVI::dL_dr( r, r-S, S ) + CpuGBVI::dL_dx( r, r-S, S ) );
} else if (r < (S - R)) {
de = ReferenceGBVI::dL_dr(r, r+S, S) + ReferenceGBVI::dL_dx(r, r+S, S);
de -= (ReferenceGBVI::dL_dr(r, r-S, S) + ReferenceGBVI::dL_dx(r, r-S, S));
}
// de = (dG/dRb)(dRb/dr)
......@@ -721,12 +720,10 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
}
}
//printGbvi( atomCoordinates, partialCharges, bornRadii, bornForces, forces, "GBVI: Post loop2", stderr );
// convert from cal to Joule & apply prefactor tau = (1/diel_solute - 1/diel_solvent)
RealOpenMM conversion = static_cast<RealOpenMM>(gbviParameters->getTau());
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
inputForces[atomI][0] += conversion*forces[atomI][0];
inputForces[atomI][1] += conversion*forces[atomI][1];
inputForces[atomI][2] += conversion*forces[atomI][2];
......@@ -734,93 +731,6 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
}
/**---------------------------------------------------------------------------------------
Print GB/VI parameters, radii, forces, ...
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param bornRadii Born radii (may be empty)
@param bornForces Born forces (may be empty)
@param forces forces (may be empty)
@param idString id string (who is calling)
@param log log file
--------------------------------------------------------------------------------------- */
void CpuGBVI::printGbvi( const std::vector<OpenMM::RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges,
const RealOpenMMVector& bornRadii,
const RealOpenMMVector& bornForces,
const std::vector<OpenMM::RealVec>& forces,
const std::string& idString, FILE* log ){
// ---------------------------------------------------------------------------------------
const GBVIParameters* gbviParameters = getGBVIParameters();
const int numberOfAtoms = gbviParameters->getNumberOfAtoms();
const RealOpenMMVector& atomicRadii = gbviParameters->getAtomicRadii();
const RealOpenMMVector& gammaParameters = gbviParameters->getGammaParameters();
// ---------------------------------------------------------------------------------------
// constants
const RealOpenMM preFactor = 2.0*gbviParameters->getElectricConstant();
// ---------------------------------------------------------------------------------------
const RealOpenMMVector& scaledRadii = gbviParameters->getScaledRadii();
const RealOpenMMVector& switchDeriviative = getSwitchDeriviative();
RealOpenMM tau = static_cast<RealOpenMM>(gbviParameters->getTau());
int useComparisonFormat = 1;
(void) fprintf( log, "Reference Gbvi %s atoms=%d\n", idString.c_str(), numberOfAtoms );
(void) fprintf( log, " tau %15.7e\n", tau );
(void) fprintf( log, " scaleMethod %d (QuinticEnum=%d)\n",
_gbviParameters->getBornRadiusScalingMethod(), GBVIParameters::QuinticSpline );
(void) fprintf( log, " preFactor %15.7e)\n", preFactor );
if( useComparisonFormat ){
(void) fprintf( log, " br bF swd r scR tau*gamma q)\n" );
for( unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++ ){
(void) fprintf( log, "%6d ", atomI );
if( bornRadii.size() > atomI ){
(void) fprintf( log, "%15.7e ", bornRadii[atomI] );
}
if( bornForces.size() > atomI ){
(void) fprintf( log, "%15.7e ", tau*bornForces[atomI] );
}
(void) fprintf( log, " %15.7e %15.7e %15.7e %15.7e %15.7e",
switchDeriviative[atomI],
atomicRadii[atomI],
scaledRadii[atomI],
tau*gammaParameters[atomI],
partialCharges[atomI] );
(void) fprintf( log, "\n" );
}
} else {
for( unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++ ){
(void) fprintf( log, "%6d r=%15.7e rSc=%15.7e swd=%15.7e tau*gam=%15.7e q=%15.7e", atomI,
atomicRadii[atomI],
scaledRadii[atomI],
switchDeriviative[atomI],
tau*gammaParameters[atomI],
partialCharges[atomI] );
if( bornRadii.size() > atomI ){
(void) fprintf( log, " bR=%15.7e", bornRadii[atomI] );
}
if( bornForces.size() > atomI ){
(void) fprintf( log, " tau*bF=%15.7e", tau*bornForces[atomI] );
}
(void) fprintf( log, "\n" );
}
}
return;
}
/**---------------------------------------------------------------------------------------
Use double precision
......@@ -835,7 +745,7 @@ void CpuGBVI::printGbvi( const std::vector<OpenMM::RealVec>& atomCoordinates, co
--------------------------------------------------------------------------------------- */
double CpuGBVI::getVolumeD( double r, double R, double S ){
double ReferenceGBVI::getVolumeD(double r, double R, double S) {
// ---------------------------------------------------------------------------------------
......@@ -843,18 +753,18 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
static const double minusThree = -3.0;
double diff = (S - R);
if( fabs( diff ) < r ){
if (fabs(diff) < r) {
double lowerBound = (R > (r - S)) ? R : (r - S);
return (CpuGBVI::getLD( r, (r + S), S ) -
CpuGBVI::getLD( r, lowerBound, S ));
return (ReferenceGBVI::getLD(r, (r + S), S) -
ReferenceGBVI::getLD(r, lowerBound, S));
} else if( r < diff ){
} else if (r < diff) {
return CpuGBVI::getLD( r, (r + S), S ) -
CpuGBVI::getLD( r, (r - S), S ) +
pow( R, minusThree );
return ReferenceGBVI::getLD(r, (r + S), S) -
ReferenceGBVI::getLD(r, (r - S), S) +
pow(R, minusThree);
} else {
return zero;
......@@ -875,7 +785,7 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
--------------------------------------------------------------------------------------- */
double CpuGBVI::getLD( double r, double x, double S ){
double ReferenceGBVI::getLD(double r, double x, double S) {
// ---------------------------------------------------------------------------------------
......@@ -895,7 +805,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
double diff2 = (r + S)*(r - S);
return (threeHalves*xInv)*( (xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv) );
return (threeHalves*xInv)*((xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv));
}
/**---------------------------------------------------------------------------------------
......@@ -912,7 +822,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
--------------------------------------------------------------------------------------- */
double CpuGBVI::dL_drD( double r, double x, double S ){
double ReferenceGBVI::dL_drD(double r, double x, double S) {
// ---------------------------------------------------------------------------------------
......@@ -934,7 +844,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
double diff2 = (r + S)*(r - S);
return ( (-threeHalves*xInv2*rInv2)*( fourth + eighth*diff2*xInv2 ) + threeEights*xInv3*xInv );
return ((-threeHalves*xInv2*rInv2)*(fourth + eighth*diff2*xInv2) + threeEights*xInv3*xInv);
}
/**---------------------------------------------------------------------------------------
......@@ -951,7 +861,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
--------------------------------------------------------------------------------------- */
double CpuGBVI::dL_dxD( double r, double x, double S ){
double ReferenceGBVI::dL_dxD(double r, double x, double S) {
// ---------------------------------------------------------------------------------------
......@@ -970,5 +880,5 @@ double CpuGBVI::dL_dxD( double r, double x, double S ){
double diff = (r + S)*(r - S);
return (threeHalvesM*xInv3)*( (half*rInv) - xInv + (half*diff*xInv2*rInv) );
return (threeHalvesM*xInv3)*((half*rInv) - xInv + (half*diff*xInv2*rInv));
}
......@@ -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
......
......@@ -25,14 +25,12 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceLJCoulomb14.h"
#include "ReferenceForce.h"
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceLJCoulomb14::ReferenceLJCoulomb14( ) {
ReferenceLJCoulomb14::ReferenceLJCoulomb14() {
// ---------------------------------------------------------------------------------------
......@@ -56,7 +54,7 @@ ReferenceLJCoulomb14::ReferenceLJCoulomb14( ) {
--------------------------------------------------------------------------------------- */
ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){
ReferenceLJCoulomb14::~ReferenceLJCoulomb14() {
// ---------------------------------------------------------------------------------------
......@@ -81,9 +79,9 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){
--------------------------------------------------------------------------------------- */
void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>& atomCoordinates,
void ReferenceLJCoulomb14::calculateBondIxn(int* atomIndices, vector<RealVec>& atomCoordinates,
RealOpenMM* parameters, vector<RealVec>& forces,
RealOpenMM* totalEnergy ) const {
RealOpenMM* totalEnergy) const {
static const std::string methodName = "\nReferenceLJCoulomb14::calculateBondIxn";
......@@ -113,7 +111,7 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
int atomAIndex = atomIndices[0];
int atomBIndex = atomIndices[1];
ReferenceForce::getDeltaR( atomCoordinates[atomBIndex], atomCoordinates[atomAIndex], deltaR[0] );
ReferenceForce::getDeltaR(atomCoordinates[atomBIndex], atomCoordinates[atomAIndex], deltaR[0]);
RealOpenMM r2 = deltaR[0][ReferenceForce::R2Index];
RealOpenMM inverseR = one/(deltaR[0][ReferenceForce::RIndex]);
......@@ -121,13 +119,13 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
sig2 *= sig2;
RealOpenMM sig6 = sig2*sig2*sig2;
RealOpenMM dEdR = parameters[1]*( twelve*sig6 - six )*sig6;
RealOpenMM dEdR = parameters[1]*(twelve*sig6 - six)*sig6;
dEdR += (RealOpenMM) (ONE_4PI_EPS0*parameters[2]*inverseR);
dEdR *= inverseR*inverseR;
// accumulate forces
for( int ii = 0; ii < 3; ii++ ){
for (int ii = 0; ii < 3; ii++) {
RealOpenMM force = dEdR*deltaR[0][ii];
forces[atomAIndex][ii] += force;
forces[atomBIndex][ii] -= force;
......@@ -136,5 +134,5 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
// accumulate energies
if (totalEnergy != NULL)
*totalEnergy += parameters[1]*( sig6 - one )*sig6 + (ONE_4PI_EPS0*parameters[2]*inverseR);
*totalEnergy += parameters[1]*(sig6 - one)*sig6 + (ONE_4PI_EPS0*parameters[2]*inverseR);
}
......@@ -27,12 +27,11 @@
#include <complex>
#include <algorithm>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceLJCoulombIxn.h"
#include "ReferenceForce.h"
#include "ReferencePME.h"
#include "openmm/OpenMMException.h"
// In case we're using some primitive version of Visual Studio this will
// make sure that erf() and erfc() are defined.
......@@ -40,7 +39,7 @@
using std::set;
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -48,7 +47,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn::ReferenceLJCoulombIxn( ) : cutoff(false), useSwitch(false), periodic(false), ewald(false), pme(false) {
ReferenceLJCoulombIxn::ReferenceLJCoulombIxn() : cutoff(false), useSwitch(false), periodic(false), ewald(false), pme(false) {
// ---------------------------------------------------------------------------------------
......@@ -64,7 +63,7 @@ ReferenceLJCoulombIxn::ReferenceLJCoulombIxn( ) : cutoff(false), useSwitch(false
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn() {
// ---------------------------------------------------------------------------------------
......@@ -84,7 +83,7 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceLJCoulombIxn::setUseCutoff( RealOpenMM distance, const OpenMM::NeighborList& neighbors, RealOpenMM solventDielectric ) {
void ReferenceLJCoulombIxn::setUseCutoff(RealOpenMM distance, const OpenMM::NeighborList& neighbors, RealOpenMM solventDielectric) {
cutoff = true;
cutoffDistance = distance;
......@@ -101,7 +100,7 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
--------------------------------------------------------------------------------------- */
void ReferenceLJCoulombIxn::setUseSwitchingFunction( RealOpenMM distance ) {
void ReferenceLJCoulombIxn::setUseSwitchingFunction(RealOpenMM distance) {
useSwitch = true;
switchingDistance = distance;
}
......@@ -210,16 +209,16 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
// **************************************************************************************
if (includeReciprocal) {
for( int atomID = 0; atomID < numberOfAtoms; atomID++ ){
for (int atomID = 0; atomID < numberOfAtoms; atomID++) {
RealOpenMM selfEwaldEnergy = (RealOpenMM) (ONE_4PI_EPS0*atomParameters[atomID][QIndex]*atomParameters[atomID][QIndex] * alphaEwald/SQRT_PI);
totalSelfEwaldEnergy -= selfEwaldEnergy;
if( energyByAtom ){
if (energyByAtom) {
energyByAtom[atomID] -= selfEwaldEnergy;
}
}
}
if( totalEnergy ){
if (totalEnergy) {
*totalEnergy += totalSelfEwaldEnergy;
}
......@@ -238,11 +237,11 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
charges[i] = atomParameters[i][QIndex];
pme_exec(pmedata,atomCoordinates,forces,charges,periodicBoxVectors,&recipEnergy);
if( totalEnergy )
if (totalEnergy)
*totalEnergy += recipEnergy;
if( energyByAtom )
for(int n = 0; n < numberOfAtoms; n++)
if (energyByAtom)
for (int n = 0; n < numberOfAtoms; n++)
energyByAtom[n] += recipEnergy;
pme_destroy(pmedata);
......@@ -264,22 +263,19 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
vector<d_complex> tab_xy(numberOfAtoms);
vector<d_complex> tab_qxyz(numberOfAtoms);
if (kmax < 1) {
std::stringstream message;
message << " kmax < 1 , Aborting" << std::endl;
SimTKOpenMMLog::printError( message );
}
if (kmax < 1)
throw OpenMMException("kmax for Ewald summation < 1");
for(int i = 0; (i < numberOfAtoms); i++) {
for(int m = 0; (m < 3); m++)
for (int i = 0; (i < numberOfAtoms); i++) {
for (int m = 0; (m < 3); m++)
EIR(0, i, m) = d_complex(1,0);
for(int m=0; (m<3); m++)
for (int m=0; (m<3); m++)
EIR(1, i, m) = d_complex(cos(atomCoordinates[i][m]*recipBoxSize[m]),
sin(atomCoordinates[i][m]*recipBoxSize[m]));
for(int j=2; (j<kmax); j++)
for(int m=0; (m<3); m++)
for (int j=2; (j<kmax); j++)
for (int m=0; (m<3); m++)
EIR(j, i, m) = EIR(j-1, i, m) * EIR(1, i, m);
}
......@@ -288,40 +284,40 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
int lowry = 0;
int lowrz = 1;
for(int rx = 0; rx < numRx; rx++) {
for (int rx = 0; rx < numRx; rx++) {
RealOpenMM kx = rx * recipBoxSize[0];
for(int ry = lowry; ry < numRy; ry++) {
for (int ry = lowry; ry < numRy; ry++) {
RealOpenMM ky = ry * recipBoxSize[1];
if(ry >= 0) {
for(int n = 0; n < numberOfAtoms; n++)
if (ry >= 0) {
for (int n = 0; n < numberOfAtoms; n++)
tab_xy[n] = EIR(rx, n, 0) * EIR(ry, n, 1);
}
else {
for(int n = 0; n < numberOfAtoms; n++)
for (int n = 0; n < numberOfAtoms; n++)
tab_xy[n]= EIR(rx, n, 0) * conj (EIR(-ry, n, 1));
}
for (int rz = lowrz; rz < numRz; rz++) {
if( rz >= 0) {
for( int n = 0; n < numberOfAtoms; n++)
if (rz >= 0) {
for (int n = 0; n < numberOfAtoms; n++)
tab_qxyz[n] = atomParameters[n][QIndex] * (tab_xy[n] * EIR(rz, n, 2));
}
else {
for( int n = 0; n < numberOfAtoms; n++)
for (int n = 0; n < numberOfAtoms; n++)
tab_qxyz[n] = atomParameters[n][QIndex] * (tab_xy[n] * conj(EIR(-rz, n, 2)));
}
RealOpenMM cs = 0.0f;
RealOpenMM ss = 0.0f;
for( int n = 0; n < numberOfAtoms; n++) {
for (int n = 0; n < numberOfAtoms; n++) {
cs += tab_qxyz[n].real();
ss += tab_qxyz[n].imag();
}
......@@ -330,21 +326,21 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
RealOpenMM k2 = kx * kx + ky * ky + kz * kz;
RealOpenMM ak = exp(k2*factorEwald) / k2;
for(int n = 0; n < numberOfAtoms; n++) {
for (int n = 0; n < numberOfAtoms; n++) {
RealOpenMM force = ak * (cs * tab_qxyz[n].imag() - ss * tab_qxyz[n].real());
forces[n][0] += 2 * recipCoeff * force * kx ;
forces[n][1] += 2 * recipCoeff * force * ky ;
forces[n][2] += 2 * recipCoeff * force * kz ;
}
recipEnergy = recipCoeff * ak * ( cs * cs + ss * ss);
recipEnergy = recipCoeff * ak * (cs * cs + ss * ss);
totalRecipEnergy += recipEnergy;
if( totalEnergy )
if (totalEnergy)
*totalEnergy += recipEnergy;
if( energyByAtom )
for(int n = 0; n < numberOfAtoms; n++)
if (energyByAtom)
for (int n = 0; n < numberOfAtoms; n++)
energyByAtom[n] += recipEnergy;
lowrz = 1 - numRz;
......@@ -369,7 +365,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
int jj = pair.second;
RealOpenMM deltaR[2][ReferenceForce::LastDeltaRIndex];
ReferenceForce::getDeltaRPeriodic( atomCoordinates[jj], atomCoordinates[ii], periodicBoxVectors, deltaR[0] );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[jj], atomCoordinates[ii], periodicBoxVectors, deltaR[0]);
RealOpenMM r = deltaR[0][ReferenceForce::RIndex];
RealOpenMM inverseR = one/(deltaR[0][ReferenceForce::RIndex]);
RealOpenMM switchValue = 1, switchDeriv = 0;
......@@ -382,14 +378,14 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
RealOpenMM dEdR = (RealOpenMM) (ONE_4PI_EPS0 * atomParameters[ii][QIndex] * atomParameters[jj][QIndex] * inverseR * inverseR * inverseR);
dEdR = (RealOpenMM) (dEdR * (erfc(alphaR) + 2 * alphaR * exp ( - alphaR * alphaR) / SQRT_PI ));
dEdR = (RealOpenMM) (dEdR * (erfc(alphaR) + 2 * alphaR * exp (- alphaR * alphaR) / SQRT_PI));
RealOpenMM sig = atomParameters[ii][SigIndex] + atomParameters[jj][SigIndex];
RealOpenMM sig2 = inverseR*sig;
sig2 *= sig2;
RealOpenMM sig6 = sig2*sig2*sig2;
RealOpenMM eps = atomParameters[ii][EpsIndex]*atomParameters[jj][EpsIndex];
dEdR += switchValue*eps*( twelve*sig6 - six )*sig6*inverseR*inverseR;
dEdR += switchValue*eps*(twelve*sig6 - six)*sig6*inverseR*inverseR;
vdwEnergy = eps*(sig6-one)*sig6;
if (useSwitch) {
dEdR -= vdwEnergy*switchDeriv*inverseR;
......@@ -398,7 +394,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
// accumulate forces
for( int kk = 0; kk < 3; kk++ ){
for (int kk = 0; kk < 3; kk++) {
RealOpenMM force = dEdR*deltaR[0][kk];
forces[ii][kk] += force;
forces[jj][kk] -= force;
......@@ -411,14 +407,14 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
totalVdwEnergy += vdwEnergy;
totalRealSpaceEwaldEnergy += realSpaceEwaldEnergy;
if( energyByAtom ){
if (energyByAtom) {
energyByAtom[ii] += realSpaceEwaldEnergy + vdwEnergy;
energyByAtom[jj] += realSpaceEwaldEnergy + vdwEnergy;
}
}
if( totalEnergy )
if (totalEnergy)
*totalEnergy += totalRealSpaceEwaldEnergy + totalVdwEnergy;
// Now subtract off the exclusions, since they were implicitly included in the reciprocal space sum.
......@@ -431,17 +427,17 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
int jj = *iter;
RealOpenMM deltaR[2][ReferenceForce::LastDeltaRIndex];
ReferenceForce::getDeltaR( atomCoordinates[jj], atomCoordinates[ii], deltaR[0] );
ReferenceForce::getDeltaR(atomCoordinates[jj], atomCoordinates[ii], deltaR[0]);
RealOpenMM r = deltaR[0][ReferenceForce::RIndex];
RealOpenMM inverseR = one/(deltaR[0][ReferenceForce::RIndex]);
RealOpenMM alphaR = alphaEwald * r;
if (erf(alphaR) > 1e-6) {
RealOpenMM dEdR = (RealOpenMM) (ONE_4PI_EPS0 * atomParameters[ii][QIndex] * atomParameters[jj][QIndex] * inverseR * inverseR * inverseR);
dEdR = (RealOpenMM) (dEdR * (erf(alphaR) - 2 * alphaR * exp ( - alphaR * alphaR) / SQRT_PI ));
dEdR = (RealOpenMM) (dEdR * (erf(alphaR) - 2 * alphaR * exp (- alphaR * alphaR) / SQRT_PI));
// accumulate forces
for( int kk = 0; kk < 3; kk++ ){
for (int kk = 0; kk < 3; kk++) {
RealOpenMM force = dEdR*deltaR[0][kk];
forces[ii][kk] -= force;
forces[jj][kk] += force;
......@@ -452,7 +448,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
realSpaceEwaldEnergy = (RealOpenMM) (ONE_4PI_EPS0*atomParameters[ii][QIndex]*atomParameters[jj][QIndex]*inverseR*erf(alphaR));
totalExclusionEnergy += realSpaceEwaldEnergy;
if( energyByAtom ){
if (energyByAtom) {
energyByAtom[ii] -= realSpaceEwaldEnergy;
energyByAtom[jj] -= realSpaceEwaldEnergy;
}
......@@ -460,7 +456,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
}
}
if( totalEnergy )
if (totalEnergy)
*totalEnergy -= totalExclusionEnergy;
}
......@@ -502,10 +498,10 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<RealVec>&
}
}
else {
for( int ii = 0; ii < numberOfAtoms; ii++ ){
for (int ii = 0; ii < numberOfAtoms; ii++) {
// loop over atom pairs
for( int jj = ii+1; jj < numberOfAtoms; jj++ )
for (int jj = ii+1; jj < numberOfAtoms; jj++)
if (exclusions[jj].find(ii) == exclusions[jj].end())
calculateOneIxn(ii, jj, atomCoordinates, atomParameters, forces, energyByAtom, totalEnergy);
}
......@@ -526,9 +522,9 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<RealVec>&
--------------------------------------------------------------------------------------- */
void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& atomCoordinates,
void ReferenceLJCoulombIxn::calculateOneIxn(int ii, int jj, vector<RealVec>& atomCoordinates,
RealOpenMM** atomParameters, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const {
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy) const {
// ---------------------------------------------------------------------------------------
......@@ -555,9 +551,9 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
// get deltaR, R2, and R between 2 atoms
if (periodic)
ReferenceForce::getDeltaRPeriodic( atomCoordinates[jj], atomCoordinates[ii], periodicBoxVectors, deltaR[0] );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[jj], atomCoordinates[ii], periodicBoxVectors, deltaR[0]);
else
ReferenceForce::getDeltaR( atomCoordinates[jj], atomCoordinates[ii], deltaR[0] );
ReferenceForce::getDeltaR(atomCoordinates[jj], atomCoordinates[ii], deltaR[0]);
RealOpenMM r2 = deltaR[0][ReferenceForce::R2Index];
RealOpenMM inverseR = one/(deltaR[0][ReferenceForce::RIndex]);
......@@ -576,7 +572,7 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
RealOpenMM sig6 = sig2*sig2*sig2;
RealOpenMM eps = atomParameters[ii][EpsIndex]*atomParameters[jj][EpsIndex];
RealOpenMM dEdR = switchValue*eps*( twelve*sig6 - six )*sig6;
RealOpenMM dEdR = switchValue*eps*(twelve*sig6 - six)*sig6;
if (cutoff)
dEdR += (RealOpenMM) (ONE_4PI_EPS0*atomParameters[ii][QIndex]*atomParameters[jj][QIndex]*(inverseR-2.0f*krf*r2));
else
......@@ -594,7 +590,7 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
// accumulate forces
for( int kk = 0; kk < 3; kk++ ){
for (int kk = 0; kk < 3; kk++) {
RealOpenMM force = dEdR*deltaR[0][kk];
forces[ii][kk] += force;
forces[jj][kk] -= force;
......@@ -602,9 +598,9 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
// accumulate energies
if( totalEnergy )
if (totalEnergy)
*totalEnergy += energy;
if( energyByAtom ){
if (energyByAtom) {
energyByAtom[ii] += energy;
energyByAtom[jj] += energy;
}
......
......@@ -24,15 +24,13 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMLog.h"
#include "ReferenceLincsAlgorithm.h"
#include "ReferenceDynamics.h"
#include "openmm/OpenMMException.h"
using std::vector;
using OpenMM::RealVec;
using namespace OpenMM;
/**---------------------------------------------------------------------------------------
......@@ -44,9 +42,9 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
ReferenceLincsAlgorithm::ReferenceLincsAlgorithm( int numberOfConstraints,
int** atomIndices,
RealOpenMM* distance ){
ReferenceLincsAlgorithm::ReferenceLincsAlgorithm(int numberOfConstraints,
int** atomIndices,
RealOpenMM* distance) {
// ---------------------------------------------------------------------------------------
......@@ -70,7 +68,7 @@ ReferenceLincsAlgorithm::ReferenceLincsAlgorithm( int numberOfConstraints,
--------------------------------------------------------------------------------------- */
int ReferenceLincsAlgorithm::getNumberOfConstraints( void ) const {
int ReferenceLincsAlgorithm::getNumberOfConstraints() const {
// ---------------------------------------------------------------------------------------
......@@ -89,7 +87,7 @@ int ReferenceLincsAlgorithm::getNumberOfConstraints( void ) const {
--------------------------------------------------------------------------------------- */
int ReferenceLincsAlgorithm::getNumTerms( void ) const {
int ReferenceLincsAlgorithm::getNumTerms() const {
// ---------------------------------------------------------------------------------------
......@@ -106,7 +104,7 @@ int ReferenceLincsAlgorithm::getNumTerms( void ) const {
--------------------------------------------------------------------------------------- */
void ReferenceLincsAlgorithm::setNumTerms( int terms ){
void ReferenceLincsAlgorithm::setNumTerms(int terms) {
// ---------------------------------------------------------------------------------------
......@@ -214,14 +212,11 @@ void ReferenceLincsAlgorithm::updateAtomPositions(int numberOfAtoms, vector<Real
@param atomCoordinatesP atom coordinates prime
@param inverseMasses 1/mass
@return SimTKOpenMMCommon::DefaultReturn if converge; else
return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoordinates,
void ReferenceLincsAlgorithm::apply(int numberOfAtoms, vector<RealVec>& atomCoordinates,
vector<RealVec>& atomCoordinatesP,
vector<RealOpenMM>& inverseMasses ){
vector<RealOpenMM>& inverseMasses) {
// ---------------------------------------------------------------------------------------
......@@ -234,9 +229,9 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
// ---------------------------------------------------------------------------------------
if (_numberOfConstraints == 0)
return SimTKOpenMMCommon::DefaultReturn;
return;
if( !_hasInitialized )
if (!_hasInitialized)
initialize(numberOfAtoms, inverseMasses);
// Calculate the direction of each constraint, along with the initial RHS and solution vectors.
......@@ -288,9 +283,6 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
}
solveMatrix();
updateAtomPositions(numberOfAtoms, atomCoordinatesP, inverseMasses);
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
......@@ -302,12 +294,9 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
@param velocities atom velocities
@param inverseMasses 1/mass
@return SimTKOpenMMCommon::DefaultReturn if converge; else
return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
int ReferenceLincsAlgorithm::applyToVelocities(int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates,
void ReferenceLincsAlgorithm::applyToVelocities(int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates,
std::vector<OpenMM::RealVec>& velocities, std::vector<RealOpenMM>& inverseMasses) {
throw OpenMM::OpenMMException("applyToVelocities is not implemented");
}
......@@ -49,7 +49,7 @@ ReferenceMonteCarloBarostat::ReferenceMonteCarloBarostat(int numAtoms, const vec
--------------------------------------------------------------------------------------- */
ReferenceMonteCarloBarostat::~ReferenceMonteCarloBarostat( ) {
ReferenceMonteCarloBarostat::~ReferenceMonteCarloBarostat() {
}
/**---------------------------------------------------------------------------------------
......
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