Commit 76e2849c authored by Peter Eastman's avatar Peter Eastman
Browse files

Moving the reference code into the platforms folder

parent ae4c6f96
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceAngleBondIxn.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceAngleBondIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn::ReferenceAngleBondIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceAngleBondIxn::ReferenceAngleBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceAngleBondIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn::~ReferenceAngleBondIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceAngleBondIxn::~ReferenceAngleBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Get dEdR and energy term for angle bond
@param cosine cosine of angle
@param angleParameters angleParameters: angleParameters[0] = angle in degrees
angleParameters[1] = k (force constant)
@param dEdR output dEdR
@param energyTerm output energyTerm
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, RealOpenMM* angleParameters,
RealOpenMM* dEdR, RealOpenMM* energyTerm ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceAngleBondIxn::getPrefactorsGivenAngleCosine";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM half = 0.5;
// ---------------------------------------------------------------------------------------
RealOpenMM angle;
if( cosine >= one ){
angle = zero;
} else if( cosine <= -one ){
angle = PI_M;
} else {
angle = ACOS(cosine);
}
RealOpenMM deltaIdeal = angle - (angleParameters[0]*DEGREE_TO_RADIAN);
RealOpenMM deltaIdeal2 = deltaIdeal*deltaIdeal;
*dEdR = angleParameters[1]*deltaIdeal;
*energyTerm = half*angleParameters[1]*deltaIdeal2;
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Calculate Angle Bond ixn
@param atomIndices two bond indices
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k (includes factor of 2)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
RealOpenMM** atomCoordinates,
RealOpenMM* parameters,
RealOpenMM** forces,
RealOpenMM* energiesByBond,
RealOpenMM* energiesByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceAngleBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static const std::string methodName = "\nReferenceAngleBondIxn::calculateBondIxn";
// constants -- reduce Visual Studio warnings regarding conversions between float & double
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
static const RealOpenMM oneM = -1.0;
static const int threeI = 3;
// debug flag
static const int debug = 0;
static const int LastAtomIndex = 3;
RealOpenMM deltaR[2][ReferenceForce::LastDeltaRIndex];
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms
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] );
RealOpenMM pVector[threeI];
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 dEdR;
RealOpenMM 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] );
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]);
}
// accumulate forces
for( int jj = 0; jj < LastAtomIndex; jj++ ){
for( int ii = 0; ii < threeI; ii++ ){
forces[atomIndices[jj]][ii] += deltaCrossP[jj][ii];
}
}
// accumulate energies
updateEnergy( energy, energiesByBond, LastAtomIndex, atomIndices, energiesByAtom );
// debug
if( debug ){
static bool printHeader = false;
std::stringstream message;
message << methodName;
message << std::endl;
if( !printHeader ){
printHeader = true;
message << std::endl;
message << methodName.c_str() << " a0 k [c q p s] r1 r2 angle dt rp p[] dot cosine angle dEdR*r F[]" << std::endl;
}
message << std::endl;
for( int ii = 0; ii < 3; ii++ ){
message << " Atm " << atomIndices[ii] << " [" << atomCoordinates[ii][0] << " " << atomCoordinates[ii][1] << " " << atomCoordinates[ii][2] << "] ";
}
message << std::endl << " Delta:";
for( int ii = 0; ii < 2; ii++ ){
message << " [";
for( int jj = 0; jj < ReferenceForce::LastDeltaRIndex; jj++ ){
message << deltaR[ii][jj] << " ";
}
message << "]";
}
message << std::endl;
message << " a0=" << parameters[0];
message << " k=" << parameters[1];
message << " rab2=" << deltaR[0][ReferenceForce::R2Index];
message << " rcb2=" << deltaR[1][ReferenceForce::R2Index];
message << std::endl << " ";
message << " rp=" << rp;
message << " p[";
SimTKOpenMMUtilities::formatRealStringStream( message, pVector );
message << "] dot=" << dot;
message << " cos=" << cosine;
message << std::endl << " ";
message << " dEdr=" << dEdR;
message << " trmA=" << termA;
message << " trmC=" << termC;
message << " E=" << energy << " F=compute force; f=cumulative force";
message << std::endl << " ";
for( int ii = 0; ii < 3; ii++ ){
message << " F" << (ii+1) << "[";
SimTKOpenMMUtilities::formatRealStringStream( message, deltaCrossP[ii], threeI );
message << "]";
}
message << std::endl << " ";
for( int ii = 0; ii < LastAtomIndex; ii++ ){
message << " f" << (ii+1) << "[";
SimTKOpenMMUtilities::formatRealStringStream( message, forces[atomIndices[ii]], threeI );
message << "]";
}
SimTKOpenMMLog::printMessage( message );
}
return ReferenceForce::DefaultReturn;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceAngleBondIxn_H__
#define __ReferenceAngleBondIxn_H__
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class ReferenceAngleBondIxn : public ReferenceBondIxn {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceAngleBondIxn( );
/**---------------------------------------------------------------------------------------
Get dEdR and energy term for angle bond
@param cosine cosine of angle
@param angleParameters angleParameters: angleParameters[0] = angle in degrees
angleParameters[1] = k (force constant)
@param dEdR output dEdR
@param energyTerm output energyTerm
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int getPrefactorsGivenAngleCosine( RealOpenMM cosine, RealOpenMM* angleParameters,
RealOpenMM* dEdR, RealOpenMM* energyTerm ) const;
/**---------------------------------------------------------------------------------------
Calculate Angle Bond ixn
@param atomIndices two bond indices
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k (includes factor of 2)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom ) const;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceAngleBondIxn_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceBondForce.h"
/**---------------------------------------------------------------------------------------
ReferenceBondForce constructor
--------------------------------------------------------------------------------------- */
ReferenceBondForce::ReferenceBondForce( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondForce::ReferenceBondForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceBondForce destructor
--------------------------------------------------------------------------------------- */
ReferenceBondForce::~ReferenceBondForce( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondForce::~ReferenceBondForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate forces/energy for bonds
@param numberOfBonds number of bonds
@param atomIndices indices of atoms participating in bond ixn: atomIndices[bondIndex][indices]
@param atomCoordinates atom coordinates: atomCoordinates[atomIndex][3]
@param parameters parameters: parameters[bondIndex][*]; contents of array
depend on ixn
@param forces force array (forces added to current values): forces[atomIndex][3]
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@param totalEnergy totalEnergy: sum over { energies[atomIndex] }
@param ReferenceBondIxn ixn to be calculated
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceBondForce::calculateForce( int numberOfBonds, int** atomIndices,
RealOpenMM** atomCoordinates,
RealOpenMM** parameters,
RealOpenMM** forces,
RealOpenMM* energiesByBond,
RealOpenMM* energiesByAtom,
RealOpenMM *totalEnergy,
ReferenceBondIxn& referenceBondIxn ){
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nReferenceBondForce::calculateForce";
// ---------------------------------------------------------------------------------------
for( int ii = 0; ii < numberOfBonds; ii++ ){
// diagnostics
if( 0 ){
std::stringstream message;
message << methodName << " " << ii;
//message << " XAtm" << (unsigned int) atomIndices << " " << (unsigned int) atomIndices[0];
//message << " atm[" << atomIndices[ii][0] << " " << atomIndices[ii][1] << "]";
SimTKOpenMMLog::printMessage( message );
}
// calculate bond ixn
referenceBondIxn.calculateBondIxn( atomIndices[ii], atomCoordinates, parameters[ii],
forces, (energiesByBond == NULL ? NULL : energiesByBond + ii), energiesByAtom );
if( energiesByBond != NULL ){
*totalEnergy += energiesByBond[ii];
}
}
return ReferenceForce::DefaultReturn;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceBondForce_H__
#define __ReferenceBondForce_H__
#include "ReferenceForce.h"
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class ReferenceBondForce : public ReferenceForce {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceBondForce( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceBondForce( );
/**---------------------------------------------------------------------------------------
Calculate forces/energy for bonds
@param numberOfBonds number of bonds
@param atomIndices indices of atoms participating in bond ixn: atomIndices[bondIndex][indices]
@param atomCoordinates atom coordinates: atomCoordinates[atomIndex][3]
@param parameters parameters: parameters[bondIndex][*]; contents of array
depend on ixn
@param forces force array (forces added to current values): forces[atomIndex][3]
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@param totalEnergy totalEnergy: sum over { energies[atomIndex] }
@param ReferenceBondIxn ixn to be calculated
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int calculateForce( int numberOfBonds, int** atomIndices,
RealOpenMM** atomCoordinates,
RealOpenMM** parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom,
RealOpenMM* totalEnergy, ReferenceBondIxn& referenceBondIxn );
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceBondForce_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceBondIxn.h"
/**---------------------------------------------------------------------------------------
ReferenceBondIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceBondIxn::ReferenceBondIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondIxn::ReferenceBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceBondIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceBondIxn::~ReferenceBondIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondIxn::~ReferenceBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Update energy
@param energy energy value to update
@param energyByBond ptr to energyByBond accumulator (may be null)
@param numberOfAtomIndices number of atoms in bond
@param atomIndices array of atom indices of size 'numberOfAtomIndices'
@param energyByAtom array of energies by atom (may be null)
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceBondIxn::updateEnergy( RealOpenMM energy, RealOpenMM* energyByBond,
int numberOfAtomIndices, int* atomIndices, RealOpenMM* energyByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::updateEnergy";
// ---------------------------------------------------------------------------------------
if( energyByBond ){
*energyByBond += energy;
}
if( energyByAtom ){
for( int ii = 0; ii < numberOfAtomIndices; ii++ ){
energyByAtom[atomIndices[ii]] += energy;
}
}
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Calculate Bond Ixn -- virtual method -- does nothing
@param atomIndices bond indices
@param atomCoordinates atom coordinates
@param parameters parameters
@param forces force array (forces added)
@param energyByBond bond energy
@param energy atom energy
--------------------------------------------------------------------------------------- */
int ReferenceBondIxn::calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energyByBond, RealOpenMM* energyByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Get normed dot product between two vectors
Do computation in double?
@param vector1 first vector
@param vector2 second vector
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector
defaults to 0 (i.e., R unavailable)
@return dot product
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenMM* vector2,
int hasREntry = 0 ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::getNormedDotProduct";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
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 );
}
}
// clamp dot product to [-1,1]
if( dotProduct > one ){
dotProduct = one;
} else if( dotProduct < -one ){
dotProduct = -one;
}
return dotProduct;
}
/**---------------------------------------------------------------------------------------
Get angle between two vectors
@param vector1 first vector
@param vector2 second vector
@param outputDotProduct output cosine of angle between two vectors (optional)
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector
defaults to 0 -> R unavailable
@return cosine of angles in radians
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, RealOpenMM* vector2,
RealOpenMM* outputDotProduct = NULL,
int hasREntry = 0 ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::getAngle";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
// get dot product betweenn vectors and then angle
RealOpenMM dotProduct = getNormedDotProduct( vector1, vector2, hasREntry );
RealOpenMM angle;
if( dotProduct >= one ){
angle = zero;
} else if( dotProduct <= -one ){
angle = PI_M;
} else {
angle = ACOS(dotProduct);
}
if( outputDotProduct ){
*outputDotProduct = dotProduct;
}
return angle;
}
/**---------------------------------------------------------------------------------------
Get dihedral angle between three vectors
@param vector1 first vector
@param vector2 second vector
@param vector3 third vector
@param outputCrossProduct output cross product vectors
@param cosineOfAngle cosine of angle (output)
@param signVector vector to test sign (optional)
@param signOfAngle sign of angle (output) (optional)
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector
defaults to 0
@return cosine of dihedral angle in radians
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* vector1,
RealOpenMM* vector2,
RealOpenMM* vector3,
RealOpenMM** outputCrossProduct = NULL,
RealOpenMM* cosineOfAngle = NULL,
RealOpenMM* signVector = NULL,
RealOpenMM* signOfAngle = NULL,
int hasREntry = 0 ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::getDihedralAngleBetweenThreeVectors";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
RealOpenMM tempVectors[6] = { zero, zero, zero, zero, zero, zero };
// ---------------------------------------------------------------------------------------
// get cross products between vectors and then angle between cross product vectors
RealOpenMM* crossProduct[2];
if( outputCrossProduct ){
crossProduct[0] = outputCrossProduct[0];
crossProduct[1] = outputCrossProduct[1];
} else {
crossProduct[0] = tempVectors;
crossProduct[1] = tempVectors + 3;
}
SimTKOpenMMUtilities::crossProductVector3( vector1, vector2, crossProduct[0] );
SimTKOpenMMUtilities::crossProductVector3( vector2, vector3, crossProduct[1] );
RealOpenMM angle = getAngleBetweenTwoVectors( crossProduct[0], crossProduct[1], cosineOfAngle, 0 );
// take care of sign of angle
if( signVector ){
RealOpenMM dotProduct = DOT3( signVector, crossProduct[1] );
RealOpenMM sign = dotProduct < zero ? -one : one;
if( signOfAngle ){
*signOfAngle = sign;
}
angle *= sign;
}
return angle;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceBondIxn_H__
#define __ReferenceBondIxn_H__
// #include "ReferenceIxn.h"
// ---------------------------------------------------------------------------------------
class ReferenceBondIxn {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceBondIxn( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceBondIxn( );
/**---------------------------------------------------------------------------------------
Calculate Bond Ixn -- virtual method
@param atomIndices bond indices
@param atomCoordinates atom coordinates
@param parameters parameters
@param forces force array (forces added)
@param energyByBond bond energy
@param energy atom energy
--------------------------------------------------------------------------------------- */
virtual int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energyByBond, RealOpenMM* energyByAtom ) const;
/**---------------------------------------------------------------------------------------
Update energy
@param energy energy value to update
@param energyByBond ptr to energyByBond accumulator (may be null)
@param numberOfAtomIndices number of atoms in bond
@param atomIndices array of atom indices of size 'numberOfAtomIndices'
@param energyByAtom array of energies by atom (may be null)
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int updateEnergy( RealOpenMM energy, RealOpenMM* energyByBond,
int numberOfAtomIndices, int* atomIndices, RealOpenMM* energyByAtom ) const;
/**---------------------------------------------------------------------------------------
Get normed dot product between two vectors
@param vector1 first vector
@param vector2 second vector
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector;
defaults to 0
@return dot product
--------------------------------------------------------------------------------------- */
RealOpenMM getNormedDotProduct( RealOpenMM* vector1, RealOpenMM* vector2, int hasREntry ) const;
/**---------------------------------------------------------------------------------------
Get angle between two vectors
@param vector1 first vector
@param vector2 second vector
@param outputDotProduct cosine of angle between two vectors (optional)
@param hasREntry if set, then vector1[ReferenceForce::R2Index] = square norm of vector;
defaults to 0
@return cosine of angles in radians
--------------------------------------------------------------------------------------- */
RealOpenMM getAngleBetweenTwoVectors( RealOpenMM* vector1, RealOpenMM* vector2,
RealOpenMM* outputDotProduct, int hasREntry ) const;
/**---------------------------------------------------------------------------------------
Get dihedral angle between two vectors
@param vector1 first vector
@param vector2 second vector
@param vector3 third vector
@param outputCrossProduct output cross product vectors
@param cosineOfAngle cosine of angle (output)
@param signVector vector to test sign (optional)
@param signOfAngle sign of angle (output) (optional)
@param hasREntry if set, then vector1[ReferenceForce::R2Index] = square norm of vector
defaults to 0
@return cosine of angles in radians
--------------------------------------------------------------------------------------- */
RealOpenMM getDihedralAngleBetweenThreeVectors( RealOpenMM* vector1, RealOpenMM* vector2,
RealOpenMM* vector3, RealOpenMM** outputCrossProduct,
RealOpenMM* cosineOfAngle, RealOpenMM* signVector,
RealOpenMM* signOfAngle, int hasREntry ) const;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceBondIxn_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceConstraint.h"
#include "ReferenceDynamics.h"
/**---------------------------------------------------------------------------------------
ReferenceConstraint constructor
--------------------------------------------------------------------------------------- */
ReferenceConstraint::ReferenceConstraint( ){
// ---------------------------------------------------------------------------------------
//static const char* methodName = "\nReferenceConstraint::ReferenceConstraint";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceConstraint destructor
--------------------------------------------------------------------------------------- */
ReferenceConstraint::~ReferenceConstraint( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceConstraint::~ReferenceConstraint";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceShakeConstraint constructor
@param numberOfAtoms number of atoms
@param deltaT delta t for dynamics
@param tau viscosity
@param temperature temperature
--------------------------------------------------------------------------------------- */
ReferenceShakeConstraint::ReferenceShakeConstraint( int atomIndex1, int atomIndex2,
RealOpenMM constraintDistance,
RealOpenMM inverseMass1,
RealOpenMM inverseMass2 ) : ReferenceConstraint( ) {
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nReferenceShakeConstraint::ReferenceShakeConstraint";
// ---------------------------------------------------------------------------------------
// insure heavy atom is in 0 slot
if( inverseMass1 > inverseMass2 ){
int temp = atomIndex1;
atomIndex1 = atomIndex2;
atomIndex2 = temp;
RealOpenMM tempR = inverseMass1;
inverseMass1 = inverseMass2;
inverseMass2 = tempR;
}
_atomIndices[0] = atomIndex1;
_atomIndices[1] = atomIndex2;
_inverseMasses[0] = inverseMass1;
_inverseMasses[1] = inverseMass2;
_constraintDistance = constraintDistance;
}
/**---------------------------------------------------------------------------------------
ReferenceShakeConstraint destructor
--------------------------------------------------------------------------------------- */
ReferenceShakeConstraint::~ReferenceShakeConstraint( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::~ReferenceShakeConstraint";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Get constraint distance
@return constraintDistance
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceShakeConstraint::getConstraintDistance( void ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getConstraintDistance";
// ---------------------------------------------------------------------------------------
return _constraintDistance;
}
/**---------------------------------------------------------------------------------------
Get inverse mass of heavy atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceShakeConstraint::getHeavyAtomInverseMass( void ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getHeavyAtomInverseMass";
// ---------------------------------------------------------------------------------------
return _inverseMasses[0];
}
/**---------------------------------------------------------------------------------------
Get inverse mass of light atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceShakeConstraint::getLightAtomInverseMass( void ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getLightAtomInverseMass";
// ---------------------------------------------------------------------------------------
return _inverseMasses[1];
}
/**---------------------------------------------------------------------------------------
Get index of heavy atom
@return index
--------------------------------------------------------------------------------------- */
int ReferenceShakeConstraint::getHeavyAtomIndex( void ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getHeavyAtomIndex";
// ---------------------------------------------------------------------------------------
return _atomIndices[0];
}
/**---------------------------------------------------------------------------------------
Get index of light atom
@return index
--------------------------------------------------------------------------------------- */
int ReferenceShakeConstraint::getLightAtomIndex( void ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getLightAtomIndex";
// ---------------------------------------------------------------------------------------
return _atomIndices[1];
}
/**---------------------------------------------------------------------------------------
Print state
@param message message
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceShakeConstraint::printState( std::stringstream& message ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::printState";
// ---------------------------------------------------------------------------------------
// print state
message << " atoms[" << _atomIndices[0] << " " << _atomIndices[1] << "]";
message << " d=" << _constraintDistance;
message << " massI[" << _inverseMasses[0] << " " << _inverseMasses[1] << "]";
return ReferenceDynamics::DefaultReturn;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceConstraint_H__
#define __ReferenceConstraint_H__
// ---------------------------------------------------------------------------------------
class ReferenceConstraint {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceConstraint( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceConstraint( );
};
class ReferenceShakeConstraint : public ReferenceConstraint {
private:
// force heavy atom into index 0
int _atomIndices[2];
RealOpenMM _inverseMasses[2];
RealOpenMM _constraintDistance;
public:
/**---------------------------------------------------------------------------------------
Constructor
@param atomIndex1 atom index 1
@param atomIndex2 atom index 2
@param distance distance constraint
@param inverseMass1 inverseMass of atom 1
@param inverseMass2 inverseMass of atom 2
--------------------------------------------------------------------------------------- */
ReferenceShakeConstraint( int atomIndex1, int atomIndex2, RealOpenMM distance,
RealOpenMM inverseMass1, RealOpenMM inverseMass2 );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceShakeConstraint( );
/**---------------------------------------------------------------------------------------
Get constraint distance
@return distance
--------------------------------------------------------------------------------------- */
RealOpenMM getConstraintDistance( void );
/**---------------------------------------------------------------------------------------
Get inverse mass of heavy atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM getHeavyAtomInverseMass( void );
/**---------------------------------------------------------------------------------------
Get inverse mass of light atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM getLightAtomInverseMass( void );
/**---------------------------------------------------------------------------------------
Get index of heavy atom
@return index
--------------------------------------------------------------------------------------- */
int getHeavyAtomIndex( void );
/**---------------------------------------------------------------------------------------
Get index of light atom
@return index
--------------------------------------------------------------------------------------- */
int getLightAtomIndex( void );
/**---------------------------------------------------------------------------------------
Print state
@param message message
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int printState( std::stringstream& message );
};
typedef std::vector<ReferenceShakeConstraint*> ShakeVector;
typedef ShakeVector::iterator ShakeVectorI;
typedef std::map<int, ShakeVector*> IntShakeMap;
typedef IntShakeMap::iterator IntShakeMapI;
// ---------------------------------------------------------------------------------------
#endif // __ReferenceShakeConstraint_H__
This diff is collapsed.
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceDynamics_H__
#define __ReferenceDynamics_H__
#include "ReferenceShakeAlgorithm.h"
// ---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Abstract class for dynamics
Main method (virtual) is update()
'Random' numbers are currently fixed to allow testing
--------------------------------------------------------------------------------------- */
class ReferenceDynamics {
public:
/**---------------------------------------------------------------------------------------
Fixed static variables
--------------------------------------------------------------------------------------- */
static const int DefaultReturn = 0;
static const int ErrorReturn = -1;
private:
int _numberOfAtoms;
int _timeStep;
RealOpenMM _deltaT;
RealOpenMM _temperature;
RealOpenMM _randomNumberSeed;
int _numberOf2DTempArrays;
RealOpenMM*** _twoDTempArrays;
int _numberOf1DTempArrays;
RealOpenMM** _oneDTempArrays;
int _ownReferenceShake;
ReferenceShakeAlgorithm* _referenceShake;
/**---------------------------------------------------------------------------------------
Free memory associated w/ 2D arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int _freeTwoDArrays( void );
/**---------------------------------------------------------------------------------------
Free memory associated w/ 1D arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int _freeOneDArrays( void );
protected:
/**---------------------------------------------------------------------------------------
Allocate memory associated w/ 2D arrays
@param dimension1 first dimension
@param dimension2 second dimension
@param numberOfArrays number of arrays to allocate
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int allocate2DArrays( int dimension1, int dimension2, int numberOfArrays );
/**---------------------------------------------------------------------------------------
Get array at specified index
@param index array index
@return array or NULL if index invalid or arrays not allocated
--------------------------------------------------------------------------------------- */
RealOpenMM** get2DArrayAtIndex( int index ) const;
/**---------------------------------------------------------------------------------------
Allocate memory associated w/ 1D arrays
@param dimension1 dimension
@param numberOfArrays number of arrays to allocate
@return DefaultReturn
--------------------------------------------------------------------------------------- */
int allocate1DArrays( int dimension, int numberOfArrays );
/**---------------------------------------------------------------------------------------
Get array at specified index
@param index array index
@return array or NULL if index invalid or arrays not allocated
--------------------------------------------------------------------------------------- */
RealOpenMM* get1DArrayAtIndex( int index ) const;
public:
/**---------------------------------------------------------------------------------------
Constructor
@param numberOfAtoms number of atoms
@param deltaT delta t for dynamics
@param temperature temperature
--------------------------------------------------------------------------------------- */
ReferenceDynamics( int numberOfAtoms, RealOpenMM _deltaT, RealOpenMM temperature );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceDynamics( );
/**---------------------------------------------------------------------------------------
Get number of atoms
@return number of atoms
--------------------------------------------------------------------------------------- */
int getNumberOfAtoms( void ) const;
/**---------------------------------------------------------------------------------------
Get time step
@return time step
--------------------------------------------------------------------------------------- */
int getTimeStep( void ) const;
/**---------------------------------------------------------------------------------------
Increment time step
@return incremented time step
--------------------------------------------------------------------------------------- */
int incrementTimeStep( void );
/**---------------------------------------------------------------------------------------
Get delta t
@return deltaT
--------------------------------------------------------------------------------------- */
RealOpenMM getDeltaT( void ) const;
/**---------------------------------------------------------------------------------------
Get temperature
@return temperature
--------------------------------------------------------------------------------------- */
RealOpenMM getTemperature( void ) const;
/**---------------------------------------------------------------------------------------
Remove total linear momentum
@param numberOfAtoms number of atoms
@param masses masses
@param velocities velocities
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int removeTotalLinearMomentum( int numberOfAtoms, RealOpenMM* masses, RealOpenMM** velocities ) const;
/**---------------------------------------------------------------------------------------
Print parameters
@param message message
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int printParameters( std::stringstream& message ) const;
/**---------------------------------------------------------------------------------------
Update
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param velocities velocities
@param forces forces
@param masses atom masses
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
virtual int update( int numberOfAtoms, RealOpenMM** atomCoordinates,
RealOpenMM** velocities, RealOpenMM** forces, RealOpenMM* masses );
/**---------------------------------------------------------------------------------------
Get normally distributed random number
@return random value
--------------------------------------------------------------------------------------- */
RealOpenMM getNormallyDistributedRandomNumber( void );
/**---------------------------------------------------------------------------------------
Get random number seed
@return random number seed
--------------------------------------------------------------------------------------- */
RealOpenMM getRandomNumberSeed( void ) const;
/**---------------------------------------------------------------------------------------
Set random number seed
@param seed new seed value
@return DefaultReturn
--------------------------------------------------------------------------------------- */
int setRandomNumberSeed( RealOpenMM seed );
/**---------------------------------------------------------------------------------------
Get ReferenceShake
@return referenceShake object
--------------------------------------------------------------------------------------- */
ReferenceShakeAlgorithm* getReferenceShakeAlgorithm( void ) const;
/**---------------------------------------------------------------------------------------
Set ReferenceShake
@param referenceShake referenceShake object
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int setReferenceShakeAlgorithm( ReferenceShakeAlgorithm* referenceShake );
/**---------------------------------------------------------------------------------------
Write state
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param velocities velocities
@param forces forces
@param masses atom masses
@param state 0 if initial state; otherwise nonzero
@param baseFileName base file name
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int writeState( int numberOfAtoms, RealOpenMM** atomCoordinates,
RealOpenMM** velocities, RealOpenMM** forces, RealOpenMM* masses,
int state, const std::string& baseFileName ) const;
/**---------------------------------------------------------------------------------------
Write state
@param stateFile file to write to
@param scalarNameI vector of scalar names for ints
@param scalarI vector of scalar ints
@param scalarNameR vector of scalar names for real
@param scalarR vector of scalar reals
@param dimension1 size of first dimension for 1D & 2D real arrays
@param scalarNameR1 vector of names for 1D real arrays
@param scalarR1 vector of 1D real arrays
@param dimension2 size of second dimension for 2D real arrays
@param scalarNameR2 vector of names for 2D real arrays
@param scalarR2 vector of 2D real arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int writeStateToFile( FILE* stateFile, StringVector& scalarNameI, IntVector& scalarI,
StringVector& scalarNameR, RealOpenMMVector& scalarR,
int dimension1, StringVector& scalarNameR1, RealOpenMMPtrVector& scalarR1,
int dimension2, StringVector& scalarNameR2, RealOpenMMPtrPtrVector& scalarR2 ) const;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceDynamics_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceForce constructor
--------------------------------------------------------------------------------------- */
ReferenceForce::ReferenceForce( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceForce::ReferenceForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceForce destructor
--------------------------------------------------------------------------------------- */
ReferenceForce::~ReferenceForce( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceForce::~ReferenceForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Get deltaR and distance and distance**2 between atomI and atomJ (static method)
deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ, R2, R upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceForce::getDeltaR( const RealOpenMM* atomCoordinatesI, const RealOpenMM* atomCoordinatesJ,
RealOpenMM* deltaR ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceForce::getDeltaR";
// ---------------------------------------------------------------------------------------
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] );
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Get deltaR between atomI and atomJ (static method); deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceForce::getDeltaROnly( const RealOpenMM* atomCoordinatesI,
const RealOpenMM* atomCoordinatesJ,
RealOpenMM* deltaR ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceForce::getDeltaR";
// ---------------------------------------------------------------------------------------
deltaR[XIndex] = atomCoordinatesJ[0] - atomCoordinatesI[0];
deltaR[YIndex] = atomCoordinatesJ[1] - atomCoordinatesI[1];
deltaR[ZIndex] = atomCoordinatesJ[2] - atomCoordinatesI[2];
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Write coordinates, energies and forces (Simbios)
@param numberOfAtoms number of atoms
@param atomsPerBond atoms/bond
@param atomCoordinates atomic coordinates
@param forces forces
@param energies energies (optional)
@param resultsFileName output file name
@param lengthConversion length conversion (optional defaults to 1)
@param energyConversion energy conversion (optional defaults to 1)
@param forceConversion force conversion (optional defaults to 1)
@return ReferenceForce::DefaultReturn unless
file cannot be opened
in which case return ReferenceForce::ErrorReturn
--------------------------------------------------------------------------------------- */
int ReferenceForce::writeForces( int numberOfAtoms, int atomsPerBond,
RealOpenMM** atomCoordinates, RealOpenMM** forces,
RealOpenMM* energies, const std::string& resultsFileName,
RealOpenMM lengthConversion = 1.0,
RealOpenMM forceConversion = 1.0,
RealOpenMM energyConversion = 1.0 ){
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nReferenceForce::writeBornEnergyForces";
static const RealOpenMM zero = 0.0;
// ---------------------------------------------------------------------------------------
// open file -- return if unsuccessful
FILE* resultsFile = NULL;
#ifdef WIN32
fopen_s( &resultsFile, resultsFileName.c_str(), "w" );
#else
resultsFile = fopen( resultsFileName.c_str(), "w" );
#endif
// ---------------------------------------------------------------------------------------
// diagnostics
std::stringstream message;
message << methodName;
if( resultsFile != NULL ){
std::stringstream message;
message << methodName;
message << " Opened file=<" << resultsFileName << ">.";
SimTKOpenMMLog::printMessage( message );
} else {
std::stringstream message;
message << methodName;
message << " could not open file=<" << resultsFileName << "> -- abort output.";
SimTKOpenMMLog::printMessage( message );
return ReferenceForce::ErrorReturn;
}
// total energy and normalize by number of atoms/bond
RealOpenMM totalEnergy = zero;
if( energies ){
for( int ii = 1; ii < numberOfAtoms; ii++ ){
totalEnergy += energies[ii];
}
if( atomsPerBond > 0 ){
totalEnergy /= (RealOpenMM) atomsPerBond;
}
}
// header
(void) fprintf( resultsFile, "# %d atoms E=%.7e format: coords(3) forces(3) energies\n",
numberOfAtoms, totalEnergy );
// output
if( forces != NULL && atomCoordinates != NULL ){
for( int ii = 0; ii < numberOfAtoms; ii++ ){
(void) fprintf( resultsFile, "%5d %15.7e %15.7e %15.7e %15.7e %15.7e %15.7e", ii,
lengthConversion*atomCoordinates[ii][0],
lengthConversion*atomCoordinates[ii][1],
lengthConversion*atomCoordinates[ii][2],
forceConversion*forces[ii][0],
forceConversion*forces[ii][1],
forceConversion*forces[ii][2]
);
if( energies != NULL ){
(void) fprintf( resultsFile, " %15.7e", energyConversion*energies[ii] );
}
(void) fprintf( resultsFile, "\n" );
}
}
(void) fclose( resultsFile );
return ReferenceForce::DefaultReturn;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceForce_H__
#define __ReferenceForce_H__
// ---------------------------------------------------------------------------------------
class ReferenceForce {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceForce( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceForce( );
/**---------------------------------------------------------------------------------------
Static variables
--------------------------------------------------------------------------------------- */
static const int XIndex = 0;
static const int YIndex = 1;
static const int ZIndex = 2;
static const int R2Index = 3;
static const int RIndex = 4;
static const int LastDeltaRIndex = 5;
static const int DeltaRMaxIndex = 5;
static const int DefaultReturn = 0;
static const int ErrorReturn = -1;
/**---------------------------------------------------------------------------------------
Get deltaR and distance and distance**2 between atomI and atomJ (static method)
deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ, R2, R upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
static int getDeltaR( const RealOpenMM* atomCoordinatesI, const RealOpenMM* atomCoordinatesJ,
RealOpenMM* deltaR );
/**---------------------------------------------------------------------------------------
Get deltaR between atomI and atomJ (static method): deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
static int getDeltaROnly( const RealOpenMM* atomCoordinatesI, const RealOpenMM* atomCoordinatesJ,
RealOpenMM* deltaR );
/**---------------------------------------------------------------------------------------
Write coordinates, energies and forces (Simbios)
@param numberOfAtoms number of atoms
@param atomsPerBond atoms/bond (used to normalize total energy)
@param atomCoordinates atomic coordinates
@param forces forces
@param energies energies (optional)
@param resultsFileName output file name
@param lengthConversion length conversion (optional defaults to 1)
@param forceConversion force conversion (optional defaults to 1)
@param energyConversion energy conversion (optional defaults to 1)
@return ReferenceForce::DefaultReturn unless
file cannot be opened
in which case return ReferenceForce::ErrorReturn
--------------------------------------------------------------------------------------- */
static int writeForces( int numberOfAtoms, int atomsPerBond, RealOpenMM** atomCoordinates,
RealOpenMM** forces, RealOpenMM* energies,
const std::string& resultsFileName,
RealOpenMM lengthConversion, RealOpenMM forceConversion,
RealOpenMM energyConversion );
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceForce_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceHarmonicBondIxn.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceHarmonicBondIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceHarmonicBondIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate Harmonic Bond Ixn
@param atomIndices atom indices of atom participating in bond
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k
@param forces force array (forces added to input values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn;
--------------------------------------------------------------------------------------- */
int ReferenceHarmonicBondIxn::calculateBondIxn( int* atomIndices,
RealOpenMM** atomCoordinates,
RealOpenMM* parameters,
RealOpenMM** forces,
RealOpenMM* energiesByBond,
RealOpenMM* energiesByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static const std::string methodName = "\nReferenceHarmonicBondIxn::calculateBondIxn";
static const int twoI = 2;
static const RealOpenMM zero = 0.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM half = 0.5;
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms
int atomAIndex = atomIndices[0];
int atomBIndex = atomIndices[1];
ReferenceForce::getDeltaR( atomCoordinates[atomAIndex], atomCoordinates[atomBIndex], deltaR );
// deltaIdeal = r - r_0
RealOpenMM deltaIdeal = deltaR[ReferenceForce::RIndex] - parameters[0];
RealOpenMM deltaIdeal2 = deltaIdeal*deltaIdeal;
RealOpenMM dEdR = parameters[1]*deltaIdeal;
// chain rule
dEdR = deltaR[ReferenceForce::RIndex] > zero ? (dEdR/deltaR[ReferenceForce::RIndex]) : zero;
forces[atomAIndex][0] += dEdR*deltaR[ReferenceForce::XIndex];
forces[atomAIndex][1] += dEdR*deltaR[ReferenceForce::YIndex];
forces[atomAIndex][2] += dEdR*deltaR[ReferenceForce::ZIndex];
forces[atomBIndex][0] -= dEdR*deltaR[ReferenceForce::XIndex];
forces[atomBIndex][1] -= dEdR*deltaR[ReferenceForce::YIndex];
forces[atomBIndex][2] -= dEdR*deltaR[ReferenceForce::ZIndex];
RealOpenMM energy = half*parameters[1]*deltaIdeal2;
updateEnergy( energy, energiesByBond, twoI, atomIndices, energiesByAtom );
return ReferenceForce::DefaultReturn;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceHarmonicBondIxn_H__
#define __ReferenceHarmonicBondIxn_H__
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class ReferenceHarmonicBondIxn : public ReferenceBondIxn {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceHarmonicBondIxn( );
/**---------------------------------------------------------------------------------------
Calculate Harmonic Bond Ixn
@param atomIndices two bond indices
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
--------------------------------------------------------------------------------------- */
int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom ) const;
};
// ---------------------------------------------------------------------------------------
#endif // _ReferenceHarmonicBondIxn___
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceLJ14.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceLJ14 constructor
--------------------------------------------------------------------------------------- */
ReferenceLJ14::ReferenceLJ14( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::ReferenceLJ14";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceLJ14 destructor
--------------------------------------------------------------------------------------- */
ReferenceLJ14::~ReferenceLJ14( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::~ReferenceLJ14";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ 1-4 ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom 1
@param q2 q2 charge atom 2
@param epsfac epsfac ????????????/
@param parameters output parameters:
parameter[0]= c6*c6/c12
parameter[1]= (c12/c6)**1/6
parameter[2]= epsfactor*q1*q2
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceLJ14::getDerivedParameters( RealOpenMM c6, RealOpenMM c12, RealOpenMM q1,
RealOpenMM q2, RealOpenMM epsfac,
RealOpenMM* parameters ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::getDerivedParameters";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM six = 6.0;
static const RealOpenMM oneSixth = one/six;
// ---------------------------------------------------------------------------------------
if( c12 <= zero ){
parameters[0] = one;
parameters[1] = zero;
} else {
parameters[0] = (c6*c6)/c12;
parameters[1] = POW( (c12/c6), oneSixth );
}
parameters[2] = epsfac*q1*q2;
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Calculate LJ 1-4 ixn
@param atomIndices atom indices of 4 atoms in bond
@param atomCoordinates atom coordinates
@param parameters two parameters:
parameter[0]= c6*c6/c12
parameter[1]= (c12/c6)**1/6
parameter[2]= epsfac*q1*q2
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceLJ14::calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond,
RealOpenMM* energiesByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static const std::string methodName = "\nReferenceLJ14::calculateBondIxn";
// constants -- reduce Visual Studio warnings regarding conversions between float & double
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
static const RealOpenMM six = 6.0;
static const RealOpenMM twelve = 12.0;
static const RealOpenMM oneM = -1.0;
static const int threeI = 3;
// number of parameters
static const int numberOfParameters = 3;
// debug flag
static const int debug = 0;
static const int LastAtomIndex = 2;
RealOpenMM deltaR[2][ReferenceForce::LastDeltaRIndex];
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms
int atomAIndex = atomIndices[0];
int atomBIndex = atomIndices[1];
ReferenceForce::getDeltaR( atomCoordinates[atomBIndex], atomCoordinates[atomAIndex], deltaR[0] );
RealOpenMM inverseR = one/(deltaR[0][ReferenceForce::RIndex]);
RealOpenMM sig2 = inverseR*parameters[1];
sig2 *= sig2;
RealOpenMM sig6 = sig2*sig2*sig2;
RealOpenMM dEdR = parameters[0]*( twelve*sig6 - six )*sig6;
dEdR += parameters[2]*inverseR;
dEdR *= inverseR*inverseR;
// accumulate forces
for( int ii = 0; ii < 3; ii++ ){
RealOpenMM force = dEdR*deltaR[0][ii];
forces[atomAIndex][ii] += force;
forces[atomBIndex][ii] -= force;
}
RealOpenMM energy = 0.0;
// accumulate energies
//updateEnergy( energy, energiesByBond, LastAtomIndex, atomIndices, energiesByAtom );
// debug
if( debug ){
static bool printHeader = false;
std::stringstream message;
message << methodName;
message << std::endl;
if( !printHeader ){
printHeader = true;
message << std::endl;
message << methodName.c_str() << " a0 k [c q p s] r1 r2 angle dt rp p[] dot cosine angle dEdR*r F[]" << std::endl;
}
message << std::endl;
for( int ii = 0; ii < LastAtomIndex; ii++ ){
message << " Atm " << atomIndices[ii] << " [" << atomCoordinates[atomIndices[ii]][0] << " " << atomCoordinates[atomIndices[ii]][1] << "] ";
}
message << std::endl << " Delta:";
for( int ii = 0; ii < (LastAtomIndex - 1); ii++ ){
message << " [";
for( int jj = 0; jj < ReferenceForce::LastDeltaRIndex; jj++ ){
message << deltaR[ii][jj] << " ";
}
message << "]";
}
message << std::endl;
message << " p1=" << parameters[0];
message << " p2=" << parameters[1];
message << " p3=" << parameters[2];
message << std::endl << " ";
message << " dEdR=" << dEdR;
message << " E=" << energy << " force factors: ";
message << "F=compute force; f=cumulative force";
message << std::endl << " ";
for( int ii = 0; ii < LastAtomIndex; ii++ ){
message << " F" << (ii+1) << "[";
SimTKOpenMMUtilities::formatRealStringStream( message, deltaR[0], threeI, dEdR );
message << "]";
}
message << std::endl << " ";
for( int ii = 0; ii < LastAtomIndex; ii++ ){
message << " f" << (ii+1) << "[";
SimTKOpenMMUtilities::formatRealStringStream( message, forces[atomIndices[ii]], threeI );
message << "]";
}
SimTKOpenMMLog::printMessage( message );
}
return ReferenceForce::DefaultReturn;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceLJ14_H__
#define __ReferenceLJ14_H__
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class ReferenceLJ14 : public ReferenceBondIxn {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceLJ14( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceLJ14( );
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ 1-4 ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom 1
@param q2 q2 charge atom 2
@param epsfac epsfac ????????????/
@param parameters output parameters:
parameter[0]= c6*c6/c12
parameter[1]= (c12/c6)**1/6
parameter[2]= epsfactor*q1*q2
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceLJ14::getDerivedParameters( RealOpenMM c6, RealOpenMM c12, RealOpenMM q1,
RealOpenMM q2, RealOpenMM epsfac,
RealOpenMM* parameters ) const;
/**---------------------------------------------------------------------------------------
Calculate Ryckaert-Bellemans bond ixn
@param atomIndices atom indices of 4 atoms in bond
@param atomCoordinates atom coordinates
@param parameters six RB parameters
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom ) const;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceLJ14_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceLJCoulombIxn.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceLJCoulombIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn::ReferenceLJCoulombIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::ReferenceLJCoulombIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceLJCoulombIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::~ReferenceLJCoulombIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ Coulomb ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom 1
@param epsfac epsfacSqrt ????????????/
@param parameters output parameters:
parameter[SigIndex] = sqrt(c6*c6/c12)
parameter[EpsIndex] = 0.5*( (c12/c6)**1/6 )
parameter[QIndex] = epsfactorSqrt*q1
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceLJCoulombIxn::getDerivedParameters( RealOpenMM c6, RealOpenMM c12, RealOpenMM q1,
RealOpenMM epsfacSqrt,
RealOpenMM* parameters ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::getDerivedParameters";
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM six = 6.0;
static const RealOpenMM half = 0.5;
static const RealOpenMM oneSixth = one/six;
static const RealOpenMM oneTweleth = half*oneSixth;
// ---------------------------------------------------------------------------------------
if( c12 <= 0.0 ){
parameters[EpsIndex] = zero;
parameters[SigIndex] = half;
} else {
parameters[EpsIndex] = c6*SQRT( one/c12 );
parameters[SigIndex] = POW( (c12/c6), oneSixth );
parameters[SigIndex] *= half;
}
parameters[QIndex] = epsfacSqrt*q1;
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Calculate LJ Coulomb pair ixn
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices exclusions[atomIndex][atomToExcludeIndex]
exclusions[atomIndex][0] = number of exclusions
exclusions[atomIndex][1-no.] = atom indices of atoms to excluded from
interacting w/ atom atomIndex
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int ReferenceLJCoulombIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** atomCoordinates,
RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::calculatePairIxn";
// ---------------------------------------------------------------------------------------
static const std::string methodName = "\nReferenceLJCoulombIxn::calculatePairIxn";
// constants -- reduce Visual Studio warnings regarding conversions between float & double
static const RealOpenMM zero = 0.0;
static const RealOpenMM one = 1.0;
static const RealOpenMM two = 2.0;
static const RealOpenMM three = 3.0;
static const RealOpenMM six = 6.0;
static const RealOpenMM twelve = 12.0;
static const RealOpenMM oneM = -1.0;
static const int threeI = 3;
// debug flag
static const int debug = -1;
static const int LastAtomIndex = 2;
RealOpenMM deltaR[2][ReferenceForce::LastDeltaRIndex];
// ---------------------------------------------------------------------------------------
// allocate and initialize exclusion array
int* exclusionIndices = new int[numberOfAtoms];
for( int ii = 0; ii < numberOfAtoms; ii++ ){
exclusionIndices[ii] = -1;
}
for( int ii = 0; ii < numberOfAtoms; ii++ ){
// set exclusions
for( int jj = 1; jj <= exclusions[ii][0]; jj++ ){
exclusionIndices[exclusions[ii][jj]] = ii;
}
// loop over atom pairs
for( int jj = ii+1; jj < numberOfAtoms; jj++ ){
if( exclusionIndices[jj] != ii ){
// get deltaR, R2, and R between 2 atoms
ReferenceForce::getDeltaR( atomCoordinates[jj], atomCoordinates[ii], deltaR[0] );
RealOpenMM inverseR = one/(deltaR[0][ReferenceForce::RIndex]);
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];
RealOpenMM dEdR = eps*( twelve*sig6 - six )*sig6;
dEdR += atomParameters[ii][QIndex]*atomParameters[jj][QIndex]*inverseR;
dEdR *= inverseR*inverseR;
// accumulate forces
for( int kk = 0; kk < 3; kk++ ){
RealOpenMM force = dEdR*deltaR[0][kk];
forces[ii][kk] += force;
forces[jj][kk] -= force;
}
RealOpenMM energy = 0.0;
// accumulate energies
*totalEnergy += energy;
if( energyByAtom ){
energyByAtom[ii] += energy;
energyByAtom[jj] += energy;
}
// debug
if( debug == ii ){
static bool printHeader = false;
std::stringstream message;
message << methodName;
message << std::endl;
int pairArray[2] = { ii, jj };
if( !printHeader ){
printHeader = true;
message << std::endl;
message << methodName.c_str() << " a0 k [c q p s] r1 r2 angle dt rp p[] dot cosine angle dEdR*r F[]" << std::endl;
}
message << std::endl;
for( int kk = 0; kk < 2; kk++ ){
message << " Atm " << pairArray[kk] << " [" << atomCoordinates[pairArray[kk]][0] << " " << atomCoordinates[pairArray[kk]][1] << " " << atomCoordinates[pairArray[kk]][2] << "] ";
}
message << std::endl << " Delta:";
for( int kk = 0; kk < (LastAtomIndex - 1); kk++ ){
message << " [";
for( int jj = 0; jj < ReferenceForce::LastDeltaRIndex; jj++ ){
message << deltaR[kk][jj] << " ";
}
message << "]";
}
message << std::endl;
for( int kk = 0; kk < 2; kk++ ){
message << " p" << pairArray[kk] << " [";
message << atomParameters[pairArray[kk]][0] << " " << atomParameters[pairArray[kk]][1] << " " << atomParameters[pairArray[kk]][2];
message << "]";
}
message << std::endl;
message << " dEdR=" << dEdR;
message << " E=" << energy << " force factors: ";
message << "F=compute force; f=cumulative force";
message << std::endl << " ";
message << " f" << ii << "[";
SimTKOpenMMUtilities::formatRealStringStream( message, deltaR[0], threeI, dEdR );
message << "]";
for( int kk = 0; kk < 2; kk++ ){
message << " F" << pairArray[kk] << " [";
SimTKOpenMMUtilities::formatRealStringStream( message, forces[pairArray[kk]], threeI );
message << "]";
}
SimTKOpenMMLog::printMessage( message );
}
}
}
}
delete[] exclusionIndices;
return ReferenceForce::DefaultReturn;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceLJCoulombIxn_H__
#define __ReferenceLJCoulombIxn_H__
#include "ReferencePairIxn.h"
// ---------------------------------------------------------------------------------------
class ReferenceLJCoulombIxn : public ReferencePairIxn {
private:
// parameter indices
static const int SigIndex = 0;
static const int EpsIndex = 1;
static const int QIndex = 2;
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferenceLJCoulombIxn( );
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ 1-4 ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom
@param epsfacSqrt epsfacSqrt ????????????/
@param parameters output parameters:
parameter[SigIndex] = sqrt(c6*c6/c12)
parameter[EpsIndex] = 0.5*( (c12/c6)**1/6 )
parameter[QIndex] = epsfactorSqrt*q1
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int getDerivedParameters( RealOpenMM c6, RealOpenMM c12, RealOpenMM q1,
RealOpenMM epsfacSqrt,
RealOpenMM* parameters ) const;
/**---------------------------------------------------------------------------------------
Calculate LJ Coulomb pair ixn
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices exclusions[atomIndex][atomToExcludeIndex]
exclusions[atomIndex][0] = number of exclusions
exclusions[atomIndex][1-no.] = atom indices of atoms to excluded from
interacting w/ atom atomIndex
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int calculatePairIxn( int numberOfAtoms, RealOpenMM** atomCoordinates,
RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceLJCoulombIxn_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferencePairIxn.h"
/**---------------------------------------------------------------------------------------
ReferencePairIxn constructor
--------------------------------------------------------------------------------------- */
ReferencePairIxn::ReferencePairIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferencePairIxn::ReferencePairIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferencePairIxn destructor
--------------------------------------------------------------------------------------- */
ReferencePairIxn::~ReferencePairIxn( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferencePairIxn::~ReferencePairIxn";
// ---------------------------------------------------------------------------------------
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferencePairIxn_H__
#define __ReferencePairIxn_H__
// #include "ReferenceIxn.h"
// ---------------------------------------------------------------------------------------
class ReferencePairIxn {
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferencePairIxn( );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~ReferencePairIxn( );
/**---------------------------------------------------------------------------------------
Calculate pair ixn
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices exclusions[atomIndex][atomToExcludeIndex]
@param fixedParameters non-atom parameters
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
virtual int calculatePairIxn( int numberOfAtoms, RealOpenMM** atomCoordinates,
RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const = 0;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferencePairIxn_H__
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