"csrc/include/grouped_gemm_ck.h" did not exist on "d9ebb683c125aee936c84deaed31e0ec95e79d0c"
Commit 7fb10336 authored by peastman's avatar peastman
Browse files

Cleaned up lots of formatting to be more consistent with the rest of OpenMM

parent 1d3ffd7b
......@@ -47,10 +47,10 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceStochasticDynamics::ReferenceStochasticDynamics( int numberOfAtoms,
RealOpenMM deltaT, RealOpenMM tau,
RealOpenMM temperature ) :
ReferenceDynamics( numberOfAtoms, deltaT, temperature ), _tau( tau ) {
ReferenceStochasticDynamics::ReferenceStochasticDynamics(int numberOfAtoms,
RealOpenMM deltaT, RealOpenMM tau,
RealOpenMM temperature) :
ReferenceDynamics(numberOfAtoms, deltaT, temperature), _tau(tau) {
if (tau <= 0) {
std::stringstream message;
message << "illegal tau value: " << tau;
......@@ -66,7 +66,7 @@ ReferenceStochasticDynamics::ReferenceStochasticDynamics( int numberOfAtoms,
--------------------------------------------------------------------------------------- */
ReferenceStochasticDynamics::~ReferenceStochasticDynamics( ){
ReferenceStochasticDynamics::~ReferenceStochasticDynamics() {
// ---------------------------------------------------------------------------------------
......@@ -84,7 +84,7 @@ ReferenceStochasticDynamics::~ReferenceStochasticDynamics( ){
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceStochasticDynamics::getTau( void ) const {
RealOpenMM ReferenceStochasticDynamics::getTau() const {
// ---------------------------------------------------------------------------------------
......@@ -108,10 +108,10 @@ RealOpenMM ReferenceStochasticDynamics::getTau( void ) const {
--------------------------------------------------------------------------------------- */
void ReferenceStochasticDynamics::updatePart1( int numberOfAtoms, vector<RealVec>& atomCoordinates,
void ReferenceStochasticDynamics::updatePart1(int numberOfAtoms, vector<RealVec>& atomCoordinates,
vector<RealVec>& velocities,
vector<RealVec>& forces, vector<RealOpenMM>& inverseMasses,
vector<RealVec>& xPrime ){
vector<RealVec>& xPrime) {
// ---------------------------------------------------------------------------------------
......@@ -149,10 +149,10 @@ void ReferenceStochasticDynamics::updatePart1( int numberOfAtoms, vector<RealVec
--------------------------------------------------------------------------------------- */
void ReferenceStochasticDynamics::updatePart2( int numberOfAtoms, vector<RealVec>& atomCoordinates,
void ReferenceStochasticDynamics::updatePart2(int numberOfAtoms, vector<RealVec>& atomCoordinates,
vector<RealVec>& velocities,
vector<RealVec>& forces, vector<RealOpenMM>& inverseMasses,
vector<RealVec>& xPrime ){
vector<RealVec>& xPrime) {
// ---------------------------------------------------------------------------------------
......@@ -197,10 +197,10 @@ void ReferenceStochasticDynamics::update(const OpenMM::System& system, vector<Re
// first-time-through initialization
int numberOfAtoms = system.getNumParticles();
if( getTimeStep() == 0 ){
if (getTimeStep() == 0) {
// invert masses
for( int ii = 0; ii < numberOfAtoms; ii++ ){
for (int ii = 0; ii < numberOfAtoms; ii++) {
if (masses[ii] == zero)
inverseMasses[ii] = zero;
else
......@@ -210,11 +210,11 @@ void ReferenceStochasticDynamics::update(const OpenMM::System& system, vector<Re
// 1st update
updatePart1( numberOfAtoms, atomCoordinates, velocities, forces, inverseMasses, xPrime );
updatePart1(numberOfAtoms, atomCoordinates, velocities, forces, inverseMasses, xPrime);
// 2nd update
updatePart2( numberOfAtoms, atomCoordinates, velocities, forces, inverseMasses, xPrime );
updatePart2(numberOfAtoms, atomCoordinates, velocities, forces, inverseMasses, xPrime);
ReferenceConstraintAlgorithm* referenceConstraintAlgorithm = getReferenceConstraintAlgorithm();
if (referenceConstraintAlgorithm)
......
......@@ -49,9 +49,9 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceVariableStochasticDynamics::ReferenceVariableStochasticDynamics( int numberOfAtoms,
ReferenceVariableStochasticDynamics::ReferenceVariableStochasticDynamics(int numberOfAtoms,
RealOpenMM tau, RealOpenMM temperature,
RealOpenMM accuracy ) :
RealOpenMM accuracy) :
ReferenceDynamics(numberOfAtoms, 0.0f, temperature), _tau(tau), _accuracy(accuracy) {
if (tau <= 0) {
std::stringstream message;
......@@ -68,7 +68,7 @@ ReferenceVariableStochasticDynamics::ReferenceVariableStochasticDynamics( int nu
--------------------------------------------------------------------------------------- */
ReferenceVariableStochasticDynamics::~ReferenceVariableStochasticDynamics( ){
ReferenceVariableStochasticDynamics::~ReferenceVariableStochasticDynamics() {
// ---------------------------------------------------------------------------------------
......@@ -86,7 +86,7 @@ ReferenceVariableStochasticDynamics::~ReferenceVariableStochasticDynamics( ){
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceVariableStochasticDynamics::getAccuracy( void ) const {
RealOpenMM ReferenceVariableStochasticDynamics::getAccuracy() const {
return _accuracy;
}
......@@ -96,7 +96,7 @@ RealOpenMM ReferenceVariableStochasticDynamics::getAccuracy( void ) const {
--------------------------------------------------------------------------------------- */
void ReferenceVariableStochasticDynamics::setAccuracy( RealOpenMM accuracy ) {
void ReferenceVariableStochasticDynamics::setAccuracy(RealOpenMM accuracy) {
_accuracy = accuracy;
}
......@@ -108,7 +108,7 @@ void ReferenceVariableStochasticDynamics::setAccuracy( RealOpenMM accuracy ) {
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceVariableStochasticDynamics::getTau( void ) const {
RealOpenMM ReferenceVariableStochasticDynamics::getTau() const {
// ---------------------------------------------------------------------------------------
......@@ -134,10 +134,10 @@ RealOpenMM ReferenceVariableStochasticDynamics::getTau( void ) const {
--------------------------------------------------------------------------------------- */
void ReferenceVariableStochasticDynamics::updatePart1( int numberOfAtoms, vector<RealVec>& atomCoordinates,
void ReferenceVariableStochasticDynamics::updatePart1(int numberOfAtoms, vector<RealVec>& atomCoordinates,
vector<RealVec>& velocities,
vector<RealVec>& forces, vector<RealOpenMM>& masses, vector<RealOpenMM>& inverseMasses,
vector<RealVec>& xPrime, RealOpenMM maxStepSize ){
vector<RealVec>& xPrime, RealOpenMM maxStepSize) {
// ---------------------------------------------------------------------------------------
......@@ -148,10 +148,10 @@ void ReferenceVariableStochasticDynamics::updatePart1( int numberOfAtoms, vector
// first-time-through initialization
if( getTimeStep() == 0 ){
if (getTimeStep() == 0) {
// invert masses
for( int ii = 0; ii < numberOfAtoms; ii++ ){
for (int ii = 0; ii < numberOfAtoms; ii++) {
if (masses[ii] == 0)
inverseMasses[ii] = 0;
else
......@@ -208,10 +208,10 @@ void ReferenceVariableStochasticDynamics::updatePart1( int numberOfAtoms, vector
--------------------------------------------------------------------------------------- */
void ReferenceVariableStochasticDynamics::updatePart2( int numberOfAtoms, vector<RealVec>& atomCoordinates,
void ReferenceVariableStochasticDynamics::updatePart2(int numberOfAtoms, vector<RealVec>& atomCoordinates,
vector<RealVec>& velocities,
vector<RealVec>& forces, vector<RealOpenMM>& inverseMasses,
vector<RealVec>& xPrime ){
vector<RealVec>& xPrime) {
// ---------------------------------------------------------------------------------------
......@@ -255,11 +255,11 @@ void ReferenceVariableStochasticDynamics::update(const OpenMM::System& system, v
// 1st update
int numberOfAtoms = system.getNumParticles();
updatePart1( numberOfAtoms, atomCoordinates, velocities, forces, masses, inverseMasses, xPrime, maxStepSize );
updatePart1(numberOfAtoms, atomCoordinates, velocities, forces, masses, inverseMasses, xPrime, maxStepSize);
// 2nd update
updatePart2( numberOfAtoms, atomCoordinates, velocities, forces, inverseMasses, xPrime );
updatePart2(numberOfAtoms, atomCoordinates, velocities, forces, inverseMasses, xPrime);
ReferenceConstraintAlgorithm* referenceConstraintAlgorithm = getReferenceConstraintAlgorithm();
if (referenceConstraintAlgorithm)
......@@ -267,7 +267,7 @@ void ReferenceVariableStochasticDynamics::update(const OpenMM::System& system, v
// copy xPrime -> atomCoordinates
for( int ii = 0; ii < numberOfAtoms; ii++ ) {
for (int ii = 0; ii < numberOfAtoms; ii++) {
if (masses[ii] != 0.0) {
atomCoordinates[ii][0] = xPrime[ii][0];
atomCoordinates[ii][1] = xPrime[ii][1];
......
......@@ -44,8 +44,8 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceVariableVerletDynamics::ReferenceVariableVerletDynamics( int numberOfAtoms, RealOpenMM accuracy ) :
ReferenceDynamics( numberOfAtoms, 0.0f, 0.0f ), _accuracy(accuracy) {
ReferenceVariableVerletDynamics::ReferenceVariableVerletDynamics(int numberOfAtoms, RealOpenMM accuracy) :
ReferenceDynamics(numberOfAtoms, 0.0f, 0.0f), _accuracy(accuracy) {
xPrime.resize(numberOfAtoms);
inverseMasses.resize(numberOfAtoms);
}
......@@ -56,7 +56,7 @@ ReferenceVariableVerletDynamics::ReferenceVariableVerletDynamics( int numberOfAt
--------------------------------------------------------------------------------------- */
ReferenceVariableVerletDynamics::~ReferenceVariableVerletDynamics( ){
ReferenceVariableVerletDynamics::~ReferenceVariableVerletDynamics() {
// ---------------------------------------------------------------------------------------
......@@ -74,7 +74,7 @@ ReferenceVariableVerletDynamics::~ReferenceVariableVerletDynamics( ){
--------------------------------------------------------------------------------------- */
RealOpenMM ReferenceVariableVerletDynamics::getAccuracy( void ) const {
RealOpenMM ReferenceVariableVerletDynamics::getAccuracy() const {
return _accuracy;
}
......@@ -84,7 +84,7 @@ RealOpenMM ReferenceVariableVerletDynamics::getAccuracy( void ) const {
--------------------------------------------------------------------------------------- */
void ReferenceVariableVerletDynamics::setAccuracy( RealOpenMM accuracy ) {
void ReferenceVariableVerletDynamics::setAccuracy(RealOpenMM accuracy) {
_accuracy = accuracy;
}
......@@ -118,10 +118,10 @@ void ReferenceVariableVerletDynamics::update(const OpenMM::System& system, vecto
// first-time-through initialization
int numberOfAtoms = system.getNumParticles();
if( getTimeStep() == 0 ){
if (getTimeStep() == 0) {
// invert masses
for( int ii = 0; ii < numberOfAtoms; ii++ ){
for (int ii = 0; ii < numberOfAtoms; ii++) {
if (masses[ii] == zero)
inverseMasses[ii] = zero;
else
......
......@@ -46,9 +46,8 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceVerletDynamics::ReferenceVerletDynamics( int numberOfAtoms,
RealOpenMM deltaT ) :
ReferenceDynamics( numberOfAtoms, deltaT, 0.0 ) {
ReferenceVerletDynamics::ReferenceVerletDynamics(int numberOfAtoms, RealOpenMM deltaT) :
ReferenceDynamics(numberOfAtoms, deltaT, 0.0) {
// ---------------------------------------------------------------------------------------
......@@ -69,7 +68,7 @@ ReferenceVerletDynamics::ReferenceVerletDynamics( int numberOfAtoms,
--------------------------------------------------------------------------------------- */
ReferenceVerletDynamics::~ReferenceVerletDynamics( ){
ReferenceVerletDynamics::~ReferenceVerletDynamics() {
// ---------------------------------------------------------------------------------------
......@@ -108,10 +107,10 @@ void ReferenceVerletDynamics::update(const OpenMM::System& system, vector<RealVe
// first-time-through initialization
int numberOfAtoms = system.getNumParticles();
if( getTimeStep() == 0 ){
if (getTimeStep() == 0) {
// invert masses
for( int ii = 0; ii < numberOfAtoms; ii++ ){
for (int ii = 0; ii < numberOfAtoms; ii++) {
if (masses[ii] == zero)
inverseMasses[ii] = zero;
else
......@@ -134,7 +133,7 @@ void ReferenceVerletDynamics::update(const OpenMM::System& system, vector<RealVe
// Update the positions and velocities.
RealOpenMM velocityScale = static_cast<RealOpenMM>( 1.0/getDeltaT() );
RealOpenMM velocityScale = static_cast<RealOpenMM>(1.0/getDeltaT());
for (int i = 0; i < numberOfAtoms; ++i) {
if (masses[i] != zero)
for (int j = 0; j < 3; ++j) {
......
......@@ -672,16 +672,16 @@ fftpack_transpose_2d(t_complex * in_data,
t_complex * src;
int i,j;
if(nx<2 || ny<2)
if (nx<2 || ny<2)
{
if(in_data != out_data)
if (in_data != out_data)
{
memcpy(out_data,in_data,sizeof(t_complex)*nx*ny);
}
return 0;
}
if(in_data == out_data)
if (in_data == out_data)
{
src = (t_complex *)malloc(sizeof(t_complex)*nx*ny);
memcpy(src,in_data,sizeof(t_complex)*nx*ny);
......@@ -691,16 +691,16 @@ fftpack_transpose_2d(t_complex * in_data,
src = in_data;
}
for(i=0;i<nx;i++)
for (i=0;i<nx;i++)
{
for(j=0;j<ny;j++)
for (j=0;j<ny;j++)
{
out_data[j*nx+i].re = src[i*ny+j].re;
out_data[j*nx+i].im = src[i*ny+j].im;
}
}
if(src != in_data)
if (src != in_data)
{
free(src);
}
......@@ -722,16 +722,16 @@ fftpack_transpose_2d_nelem(t_complex * in_data,
ncopy = nelem*sizeof(t_complex);
if(nx<2 || ny<2)
if (nx<2 || ny<2)
{
if(in_data != out_data)
if (in_data != out_data)
{
memcpy(out_data,in_data,nx*ny*ncopy);
}
return 0;
}
if(in_data == out_data)
if (in_data == out_data)
{
src = (t_complex *)malloc(nx*ny*ncopy);
memcpy(src,in_data,nx*ny*ncopy);
......@@ -741,15 +741,15 @@ fftpack_transpose_2d_nelem(t_complex * in_data,
src = in_data;
}
for(i=0;i<nx;i++)
for (i=0;i<nx;i++)
{
for(j=0;j<ny;j++)
for (j=0;j<ny;j++)
{
memcpy(out_data + (j*nx+i)*nelem , src + (i*ny+j)*nelem , ncopy);
}
}
if(src != in_data)
if (src != in_data)
{
free(src);
}
......@@ -767,14 +767,14 @@ fftpack_init_1d(fftpack_t * pfft,
{
fftpack_t fft;
if(pfft==NULL)
if (pfft==NULL)
{
fprintf(stderr,"Fatal error - Invalid FFT opaque type pointer.");
return EINVAL;
}
*pfft = NULL;
if( (fft = (struct fftpack *)malloc(sizeof(struct fftpack))) == NULL)
if ((fft = (struct fftpack *)malloc(sizeof(struct fftpack))) == NULL)
{
return ENOMEM;
}
......@@ -783,13 +783,13 @@ fftpack_init_1d(fftpack_t * pfft,
fft->n = nx;
/* Need 4*n storage for 1D complex FFT */
if( (fft->work = (RealOpenMM *)malloc(sizeof(RealOpenMM)*(4*nx))) == NULL)
if ((fft->work = (RealOpenMM *)malloc(sizeof(RealOpenMM)*(4*nx))) == NULL)
{
free(fft);
return ENOMEM;
}
if(fft->n>1)
if (fft->n>1)
fftpack_cffti1(nx,fft->work,fft->ifac);
*pfft = fft;
......@@ -807,7 +807,7 @@ fftpack_init_2d(fftpack_t * pfft,
fftpack_t fft;
int rc;
if(pfft==NULL)
if (pfft==NULL)
{
fprintf(stderr,"Fatal error - Invalid FFT opaque type pointer.");
return EINVAL;
......@@ -815,13 +815,13 @@ fftpack_init_2d(fftpack_t * pfft,
*pfft = NULL;
/* Create the X transform */
if( (rc = fftpack_init_1d(&fft,nx)) != 0)
if ((rc = fftpack_init_1d(&fft,nx)) != 0)
{
return rc;
}
/* Create Y transform as a link from X */
if( (rc=fftpack_init_1d(&(fft->next),ny)) != 0)
if ((rc=fftpack_init_1d(&(fft->next),ny)) != 0)
{
free(fft);
return rc;
......@@ -842,7 +842,7 @@ fftpack_init_3d(fftpack_t * pfft,
fftpack_t fft;
int rc;
if(pfft==NULL)
if (pfft==NULL)
{
fprintf(stderr,"Fatal error - Invalid FFT opaque type pointer.");
return EINVAL;
......@@ -851,7 +851,7 @@ fftpack_init_3d(fftpack_t * pfft,
/* Create the X transform */
if( (fft = (struct fftpack *)malloc(sizeof(struct fftpack))) == NULL)
if ((fft = (struct fftpack *)malloc(sizeof(struct fftpack))) == NULL)
{
return ENOMEM;
}
......@@ -860,7 +860,7 @@ fftpack_init_3d(fftpack_t * pfft,
/* Need 4*nx storage for 1D complex FFT.
*/
if( (fft->work = (RealOpenMM *)malloc(sizeof(RealOpenMM)*(4*nx))) == NULL)
if ((fft->work = (RealOpenMM *)malloc(sizeof(RealOpenMM)*(4*nx))) == NULL)
{
free(fft);
return ENOMEM;
......@@ -869,7 +869,7 @@ fftpack_init_3d(fftpack_t * pfft,
fftpack_cffti1(nx,fft->work,fft->ifac);
/* Create 2D Y/Z transforms as a link from X */
if( (rc=fftpack_init_2d(&(fft->next),ny,nz)) != 0)
if ((rc=fftpack_init_2d(&(fft->next),ny,nz)) != 0)
{
free(fft);
return rc;
......@@ -893,7 +893,7 @@ fftpack_exec_1d (fftpack_t fft,
n=fft->n;
if(n==1)
if (n==1)
{
p1 = (RealOpenMM *)in_data;
p2 = (RealOpenMM *)out_data;
......@@ -904,13 +904,13 @@ fftpack_exec_1d (fftpack_t fft,
/* FFTPACK only does in-place transforms, so emulate out-of-place
* by copying data to the output array first.
*/
if( in_data != out_data )
if (in_data != out_data)
{
p1 = (RealOpenMM *)in_data;
p2 = (RealOpenMM *)out_data;
/* n complex = 2*n RealOpenMM elements */
for(i=0;i<2*n;i++)
for (i=0;i<2*n;i++)
{
p2[i] = p1[i];
}
......@@ -920,11 +920,11 @@ fftpack_exec_1d (fftpack_t fft,
* Elements 2*n .. 4*n-1 are internal FFTPACK work space.
*/
if(dir == FFTPACK_FORWARD)
if (dir == FFTPACK_FORWARD)
{
fftpack_cfftf1(n,(RealOpenMM *)out_data,fft->work+2*n,fft->work,fft->ifac, -1);
}
else if(dir == FFTPACK_BACKWARD)
else if (dir == FFTPACK_BACKWARD)
{
fftpack_cfftf1(n,(RealOpenMM *)out_data,fft->work+2*n,fft->work,fft->ifac, 1);
}
......@@ -957,7 +957,7 @@ fftpack_exec_2d (fftpack_t fft,
* by copying data to the output array first.
* For 2D there is likely enough data to benefit from memcpy().
*/
if( in_data != out_data )
if (in_data != out_data)
{
memcpy(out_data,in_data,sizeof(t_complex)*nx*ny);
}
......@@ -966,7 +966,7 @@ fftpack_exec_2d (fftpack_t fft,
data = (t_complex *)out_data;
/* y transforms */
for(i=0;i<nx;i++)
for (i=0;i<nx;i++)
{
fftpack_exec_1d(fft->next,dir,data+i*ny,data+i*ny);
}
......@@ -975,7 +975,7 @@ fftpack_exec_2d (fftpack_t fft,
fftpack_transpose_2d(data,data,nx,ny);
/* x transforms */
for(i=0;i<ny;i++)
for (i=0;i<ny;i++)
{
fftpack_exec_1d(fft,dir,data+i*nx,data+i*nx);
}
......@@ -1007,7 +1007,7 @@ fftpack_exec_3d (fftpack_t fft,
* by copying data to the output array first.
* For 3D there is likely enough data to benefit from memcpy().
*/
if( in_data != out_data )
if (in_data != out_data)
{
memcpy(out_data,in_data,sizeof(t_complex)*nx*ny*nz);
}
......@@ -1016,23 +1016,23 @@ fftpack_exec_3d (fftpack_t fft,
data = (t_complex *)out_data;
/* Perform z transforms */
for(i=0;i<nx*ny;i++)
for (i=0;i<nx*ny;i++)
fftpack_exec_1d(fft->next->next,dir,data+i*nz,data+i*nz);
/* For each X slice, transpose the y & z dimensions inside the slice */
for(i=0;i<nx;i++)
for (i=0;i<nx;i++)
{
fftpack_transpose_2d(data+i*ny*nz,data+i*ny*nz,ny,nz);
}
/* Array is now (nx,nz,ny) - perform y transforms */
for(i=0;i<nx*nz;i++)
for (i=0;i<nx*nz;i++)
{
fftpack_exec_1d(fft->next,dir,data+i*ny,data+i*ny);
}
/* Transpose back to (nx,ny,nz) */
for(i=0;i<nx;i++)
for (i=0;i<nx;i++)
{
fftpack_transpose_2d(data+i*ny*nz,data+i*ny*nz,nz,ny);
}
......@@ -1041,26 +1041,26 @@ fftpack_exec_3d (fftpack_t fft,
* (nx,ny,nz) to (ny,nx,nz).
*/
rc=fftpack_transpose_2d_nelem(data,data,nx,ny,nz);
if( rc != 0)
if (rc != 0)
{
fprintf(stderr,"Fatal error - cannot transpose X & Y/Z in fftpack_exec_3d().");
return rc;
}
/* Then go from (ny,nx,nz) to (ny,nz,nx) */
for(i=0;i<ny;i++)
for (i=0;i<ny;i++)
{
fftpack_transpose_2d(data+i*nx*nz,data+i*nx*nz,nx,nz);
}
/* Perform x transforms */
for(i=0;i<ny*nz;i++)
for (i=0;i<ny*nz;i++)
{
fftpack_exec_1d(fft,dir,data+i*nx,data+i*nx);
}
/* Transpose back from (ny,nz,nx) to (ny,nx,nz) */
for(i=0;i<ny;i++)
for (i=0;i<ny;i++)
{
fftpack_transpose_2d(data+i*nz*nx,data+i*nz*nx,nz,nx);
}
......@@ -1068,7 +1068,7 @@ fftpack_exec_3d (fftpack_t fft,
/* Transpose from (ny,nx,nz) to (nx,ny,nz).
*/
rc = fftpack_transpose_2d_nelem(data,data,ny,nx,nz);
if( rc != 0)
if (rc != 0)
{
fprintf(stderr,"Fatal error - cannot transpose Y/Z & X in fftpack_exec_3d().");
return rc;
......@@ -1082,10 +1082,10 @@ fftpack_exec_3d (fftpack_t fft,
void
fftpack_destroy(fftpack_t fft)
{
if(fft != NULL)
if (fft != NULL)
{
free(fft->work);
if(fft->next != NULL)
if (fft->next != NULL)
fftpack_destroy(fft->next);
free(fft);
}
......
......@@ -30,9 +30,9 @@ using namespace OpenMM;
// initialization of static data members
const std::string SimTKOpenMMCommon::NotSet = std::string( "NotSet" );
const std::string SimTKOpenMMCommon::Comment = std::string( "#" );
const std::string SimTKOpenMMCommon::Tab = std::string( "\t" );
const std::string SimTKOpenMMCommon::NotSet = std::string("NotSet");
const std::string SimTKOpenMMCommon::Comment = std::string("#");
const std::string SimTKOpenMMCommon::Tab = std::string("\t");
const int SimTKOpenMMCommon::DefaultReturn = 0;
const int SimTKOpenMMCommon::ErrorReturn = -1;
......
......@@ -59,9 +59,9 @@ OpenMM_SFMT::SFMT SimTKOpenMMUtilities::sfmt;
--------------------------------------------------------------------------------------- */
RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOpenMM* array1D,
int initialize, RealOpenMM initialValue,
const std::string& idString ){
RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray(int iSize, RealOpenMM* array1D,
int initialize, RealOpenMM initialValue,
const std::string& idString) {
// ---------------------------------------------------------------------------------------
......@@ -71,17 +71,17 @@ RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOp
// ---------------------------------------------------------------------------------------
if( array1D == NULL ){
if (array1D == NULL) {
array1D = new RealOpenMM[iSize];
}
if( initialize ){
if( initialValue == zero ){
memset( array1D, 0, iSize*sizeof( RealOpenMM ) );
if (initialize) {
if (initialValue == zero) {
memset(array1D, 0, iSize*sizeof(RealOpenMM));
} else {
for( int ii = 0; ii < iSize; ii++ ){
for (int ii = 0; ii < iSize; ii++) {
array1D[ii] = initialValue;
}
}
......@@ -107,9 +107,9 @@ RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOp
--------------------------------------------------------------------------------------- */
RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int jSize, RealOpenMM** array2D,
int initialize, RealOpenMM initialValue,
const std::string& idString ){
RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray(int iSize, int jSize, RealOpenMM** array2D,
int initialize, RealOpenMM initialValue,
const std::string& idString) {
// ---------------------------------------------------------------------------------------
......@@ -117,22 +117,22 @@ RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int j
// ---------------------------------------------------------------------------------------
if( array2D == NULL ){
if (array2D == NULL) {
array2D = new RealOpenMM*[iSize];
std::string blockString = idString;
blockString.append( "Block" );
blockString.append("Block");
RealOpenMM* block = new RealOpenMM[jSize*iSize];
for( int ii = 0; ii < iSize; ii++ ){
for (int ii = 0; ii < iSize; ii++) {
array2D[ii] = block;
block += jSize;
}
}
if( initialize ){
initialize2DRealOpenMMArray( iSize, jSize, array2D, initialValue );
if (initialize) {
initialize2DRealOpenMMArray(iSize, jSize, array2D, initialValue);
}
return array2D;
......@@ -149,7 +149,7 @@ RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int j
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const std::string& idString ){
void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray(RealOpenMM** array2D, const std::string& idString) {
// ---------------------------------------------------------------------------------------
......@@ -157,10 +157,10 @@ void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const
// ---------------------------------------------------------------------------------------
if( array2D != NULL ){
if (array2D != NULL) {
std::string blockString = idString;
blockString.append( "Block" );
blockString.append("Block");
delete[] array2D[0];
delete[] array2D;
......@@ -178,7 +178,7 @@ void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const std::string& idString ){
void SimTKOpenMMUtilities::freeOneDRealOpenMMArray(RealOpenMM* array1D, const std::string& idString) {
// ---------------------------------------------------------------------------------------
......@@ -186,7 +186,7 @@ void SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const s
// ---------------------------------------------------------------------------------------
if( array1D != NULL ){
if (array1D != NULL) {
delete[] array1D;
}
}
......@@ -204,9 +204,9 @@ void SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const s
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
void SimTKOpenMMUtilities::initialize2DRealOpenMMArray(int iSize, int jSize,
RealOpenMM** array2D,
RealOpenMM initialValue ){
RealOpenMM initialValue) {
// ---------------------------------------------------------------------------------------
......@@ -217,9 +217,9 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
bool useMemset;
bool useMemsetSingleBlock;
if( initialValue == 0.0f ){
if (initialValue == 0.0f) {
useMemset = true;
if( jSize > 1 && (array2D[0] + jSize) == array2D[1] ){
if (jSize > 1 && (array2D[0] + jSize) == array2D[1]) {
useMemsetSingleBlock = true;
} else {
useMemsetSingleBlock = false;
......@@ -229,17 +229,17 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
useMemset = false;
}
if( useMemset ){
if( useMemsetSingleBlock ){
memset( array2D[0], 0, iSize*jSize*sizeof( RealOpenMM ) );
if (useMemset) {
if (useMemsetSingleBlock) {
memset(array2D[0], 0, iSize*jSize*sizeof(RealOpenMM));
} else {
for( int ii = 0; ii < iSize; ii++ ){
memset( array2D[ii], 0, jSize*sizeof( RealOpenMM ) );
for (int ii = 0; ii < iSize; ii++) {
memset(array2D[ii], 0, jSize*sizeof(RealOpenMM));
}
}
} else {
for( int ii = 0; ii < iSize; ii++ ){
for( int jj = 0; jj < jSize; jj++ ){
for (int ii = 0; ii < iSize; ii++) {
for (int jj = 0; jj < jSize; jj++) {
array2D[ii][jj] = initialValue;
}
}
......@@ -260,9 +260,9 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::crossProductVector3( RealOpenMM* vectorX,
RealOpenMM* vectorY,
RealOpenMM* vectorZ ){
void SimTKOpenMMUtilities::crossProductVector3(RealOpenMM* vectorX,
RealOpenMM* vectorY,
RealOpenMM* vectorZ) {
// ---------------------------------------------------------------------------------------
......@@ -285,7 +285,7 @@ void SimTKOpenMMUtilities::crossProductVector3( RealOpenMM* vectorX,
--------------------------------------------------------------------------------------- */
RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber( void ) {
RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber() {
if (nextGaussianIsValid) {
nextGaussianIsValid = false;
return nextGaussian;
......@@ -304,7 +304,7 @@ RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber( void ) {
y = static_cast<RealOpenMM>(2.0 * genrand_real2(sfmt) - 1.0);
r2 = x*x + y*y;
} while (r2 >= 1.0 || r2 == 0.0);
RealOpenMM multiplier = static_cast<RealOpenMM>( sqrt((-2.0*log(r2))/r2) );
RealOpenMM multiplier = static_cast<RealOpenMM>(sqrt((-2.0*log(r2))/r2));
nextGaussian = y*multiplier;
nextGaussianIsValid = true;
return x*multiplier;
......@@ -318,13 +318,13 @@ RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber( void ) {
--------------------------------------------------------------------------------------- */
RealOpenMM SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber( void ) {
RealOpenMM SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() {
if (!_randomInitialized) {
init_gen_rand(_randomNumberSeed, sfmt);
_randomInitialized = true;
nextGaussianIsValid = false;
}
RealOpenMM value = static_cast<RealOpenMM>( genrand_real2(sfmt) );
RealOpenMM value = static_cast<RealOpenMM>(genrand_real2(sfmt));
return value;
}
......@@ -336,7 +336,7 @@ RealOpenMM SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber( void ) {
--------------------------------------------------------------------------------------- */
uint32_t SimTKOpenMMUtilities::getRandomNumberSeed( void ) {
uint32_t SimTKOpenMMUtilities::getRandomNumberSeed() {
// ---------------------------------------------------------------------------------------
......@@ -355,7 +355,7 @@ uint32_t SimTKOpenMMUtilities::getRandomNumberSeed( void ) {
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::setRandomNumberSeed( uint32_t seed ) {
void SimTKOpenMMUtilities::setRandomNumberSeed(uint32_t seed) {
// ---------------------------------------------------------------------------------------
......
......@@ -41,8 +41,8 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
CpuGBVI::CpuGBVI( GBVIParameters* gbviParameters ) : _gbviParameters(gbviParameters) {
_switchDeriviative.resize( gbviParameters->getNumberOfAtoms() );
CpuGBVI::CpuGBVI(GBVIParameters* gbviParameters) : _gbviParameters(gbviParameters) {
_switchDeriviative.resize(gbviParameters->getNumberOfAtoms());
}
/**---------------------------------------------------------------------------------------
......@@ -51,7 +51,7 @@ CpuGBVI::CpuGBVI( GBVIParameters* gbviParameters ) : _gbviParameters(gbviParamet
--------------------------------------------------------------------------------------- */
CpuGBVI::~CpuGBVI( ){
CpuGBVI::~CpuGBVI() {
}
/**---------------------------------------------------------------------------------------
......@@ -62,7 +62,7 @@ CpuGBVI::~CpuGBVI( ){
--------------------------------------------------------------------------------------- */
GBVIParameters* CpuGBVI::getGBVIParameters( void ) const {
GBVIParameters* CpuGBVI::getGBVIParameters() const {
return _gbviParameters;
}
......@@ -74,7 +74,7 @@ GBVIParameters* CpuGBVI::getGBVIParameters( void ) const {
--------------------------------------------------------------------------------------- */
void CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
void CpuGBVI::setGBVIParameters(GBVIParameters* gbviParameters) {
_gbviParameters = gbviParameters;
}
......@@ -86,7 +86,7 @@ void CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
--------------------------------------------------------------------------------------- */
RealOpenMMVector& CpuGBVI::getSwitchDeriviative( void ){
RealOpenMMVector& CpuGBVI::getSwitchDeriviative() {
return _switchDeriviative;
}
......@@ -102,17 +102,17 @@ RealOpenMMVector& CpuGBVI::getSwitchDeriviative( void ){
--------------------------------------------------------------------------------------- */
void CpuGBVI::quinticSpline( RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
RealOpenMM* outValue, RealOpenMM* outDerivative ){
void CpuGBVI::quinticSpline(RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
RealOpenMM* outValue, RealOpenMM* outDerivative) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM minusSix = static_cast<RealOpenMM>( -6.0 );
static const RealOpenMM minusTen = static_cast<RealOpenMM>( -10.0 );
static const RealOpenMM minusThirty = static_cast<RealOpenMM>( -30.0 );
static const RealOpenMM fifteen = static_cast<RealOpenMM>( 15.0 );
static const RealOpenMM sixty = static_cast<RealOpenMM>( 60.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0);
static const RealOpenMM minusSix = static_cast<RealOpenMM>( -6.0);
static const RealOpenMM minusTen = static_cast<RealOpenMM>(-10.0);
static const RealOpenMM minusThirty = static_cast<RealOpenMM>(-30.0);
static const RealOpenMM fifteen = static_cast<RealOpenMM>( 15.0);
static const RealOpenMM sixty = static_cast<RealOpenMM>( 60.0);
// ---------------------------------------------------------------------------------------
......@@ -140,19 +140,19 @@ void CpuGBVI::quinticSpline( RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
--------------------------------------------------------------------------------------- */
void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, RealOpenMM bornSum,
GBVIParameters* gbviParameters,
RealOpenMM* bornRadius, RealOpenMM* switchDeriviative ){
void CpuGBVI::computeBornRadiiUsingQuinticSpline(RealOpenMM atomicRadius3, RealOpenMM bornSum,
GBVIParameters* gbviParameters,
RealOpenMM* bornRadius, RealOpenMM* switchDeriviative) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM minusOne = static_cast<RealOpenMM>( -1.0 );
static const RealOpenMM minusThree = static_cast<RealOpenMM>( -3.0 );
static const RealOpenMM oneEighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>( (-1.0/3.0) );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0);
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0);
static const RealOpenMM minusOne = static_cast<RealOpenMM>(-1.0);
static const RealOpenMM minusThree = static_cast<RealOpenMM>(-3.0);
static const RealOpenMM oneEighth = static_cast<RealOpenMM>( 0.125);
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>((-1.0/3.0));
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0);
// ---------------------------------------------------------------------------------------
......@@ -176,10 +176,10 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
RealOpenMM splineL = gbviParameters->getQuinticLowerLimitFactor()*atomicRadius3;
RealOpenMM sum;
if( bornSum > splineL ){
if( bornSum < atomicRadius3 ){
if (bornSum > splineL) {
if (bornSum < atomicRadius3) {
RealOpenMM splineValue, splineDerivative;
quinticSpline( bornSum, splineL, atomicRadius3, &splineValue, &splineDerivative );
quinticSpline(bornSum, splineL, atomicRadius3, &splineValue, &splineDerivative);
sum = (atomicRadius3 - bornSum)*splineValue + gbviParameters->getQuinticUpperBornRadiusLimit();
*switchDeriviative = splineValue - (atomicRadius3 - bornSum)*splineDerivative;
} else {
......@@ -190,7 +190,7 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
sum = atomicRadius3 - bornSum;
*switchDeriviative = one;
}
*bornRadius = POW( sum, minusOneThird );
*bornRadius = POW(sum, minusOneThird);
}
/**---------------------------------------------------------------------------------------
......@@ -203,16 +203,16 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
--------------------------------------------------------------------------------------- */
void CpuGBVI::computeBornRadii( const vector<RealVec>& atomCoordinates, RealOpenMMVector& bornRadii ){
void CpuGBVI::computeBornRadii(const vector<RealVec>& atomCoordinates, RealOpenMMVector& bornRadii) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM minusThree = static_cast<RealOpenMM>( -3.0 );
static const RealOpenMM oneEighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>( (-1.0/3.0) );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM minusThree = static_cast<RealOpenMM>(-3.0);
static const RealOpenMM oneEighth = static_cast<RealOpenMM>(0.125);
static const RealOpenMM minusOneThird = static_cast<RealOpenMM>((-1.0/3.0));
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
// ---------------------------------------------------------------------------------------
......@@ -227,42 +227,42 @@ void CpuGBVI::computeBornRadii( const vector<RealVec>& atomCoordinates, RealOpen
// calculate Born radii
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM radiusI = atomicRadii[atomI];
RealOpenMM sum = zero;
// sum over volumes
for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = 0; atomJ < numberOfAtoms; atomJ++) {
if( atomJ != atomI ){
if (atomJ != atomI) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
RealOpenMM r = deltaR[ReferenceForce::RIndex];
if (_gbviParameters->getUseCutoff() && r > _gbviParameters->getCutoffDistance())
continue;
sum += CpuGBVI::getVolume( r, radiusI, scaledRadii[atomJ] );
sum += CpuGBVI::getVolume(r, radiusI, scaledRadii[atomJ]);
}
}
RealOpenMM atomicRadius3 = POW( radiusI, minusThree );
if( _gbviParameters->getBornRadiusScalingMethod() != GBVIParameters::QuinticSpline ){
RealOpenMM atomicRadius3 = POW(radiusI, minusThree);
if (_gbviParameters->getBornRadiusScalingMethod() != GBVIParameters::QuinticSpline) {
sum = atomicRadius3 - sum;
bornRadii[atomI] = POW( sum, minusOneThird );
bornRadii[atomI] = POW(sum, minusOneThird);
switchDeriviatives[atomI] = one;
} else {
RealOpenMM bornRadius, switchDeriviative;
computeBornRadiiUsingQuinticSpline( atomicRadius3, sum, gbviParameters,
&bornRadius, &switchDeriviative );
computeBornRadiiUsingQuinticSpline(atomicRadius3, sum, gbviParameters,
&bornRadius, &switchDeriviative);
bornRadii[atomI] = bornRadius;
switchDeriviatives[atomI] = switchDeriviative;
}
......@@ -281,25 +281,25 @@ void CpuGBVI::computeBornRadii( const vector<RealVec>& atomCoordinates, RealOpen
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::getVolume( RealOpenMM r, RealOpenMM R, RealOpenMM S ){
RealOpenMM CpuGBVI::getVolume(RealOpenMM r, RealOpenMM R, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM minusThree = static_cast<RealOpenMM>( -3.0 );
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0);
static const RealOpenMM minusThree = static_cast<RealOpenMM>(-3.0);
RealOpenMM diff = (S - R);
if( FABS( diff ) < r ){
if (FABS(diff) < r) {
RealOpenMM lowerBound = (R > (r - S)) ? R : (r - S);
return (CpuGBVI::getL( r, (r + S), S ) -
CpuGBVI::getL( r, lowerBound, S ));
return (CpuGBVI::getL(r, (r + S), S) -
CpuGBVI::getL(r, lowerBound, S));
} else if( r <= diff ){
} else if (r <= diff) {
return CpuGBVI::getL( r, (r + S), S ) -
CpuGBVI::getL( r, (r - S), S ) +
POW( R, minusThree );
return CpuGBVI::getL(r, (r + S), S) -
CpuGBVI::getL(r, (r - S), S) +
POW(R, minusThree);
} else {
return zero;
......@@ -318,15 +318,15 @@ RealOpenMM CpuGBVI::getVolume( RealOpenMM r, RealOpenMM R, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM CpuGBVI::getL(RealOpenMM r, RealOpenMM x, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM threeHalves = static_cast<RealOpenMM>( 1.5 );
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM threeHalves = static_cast<RealOpenMM>(1.5);
static const RealOpenMM third = static_cast<RealOpenMM>((1.0/3.0));
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
......@@ -338,7 +338,7 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM diff2 = (r + S)*(r - S);
return (threeHalves*xInv)*( (xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv) );
return (threeHalves*xInv)*((xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv));
}
/**---------------------------------------------------------------------------------------
......@@ -353,16 +353,16 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM CpuGBVI::dL_dr(RealOpenMM r, RealOpenMM x, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM threeHalves = static_cast<RealOpenMM>( 1.5 );
static const RealOpenMM threeEights = static_cast<RealOpenMM>( 0.375 );
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM threeHalves = static_cast<RealOpenMM>(1.5);
static const RealOpenMM threeEights = static_cast<RealOpenMM>(0.375);
static const RealOpenMM third = static_cast<RealOpenMM>((1.0/3.0));
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
......@@ -375,7 +375,7 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM diff2 = (r + S)*(r - S);
return ( (-threeHalves*xInv2*rInv2)*( fourth + eighth*diff2*xInv2 ) + threeEights*xInv3*xInv );
return ((-threeHalves*xInv2*rInv2)*(fourth + eighth*diff2*xInv2) + threeEights*xInv3*xInv);
}
/**---------------------------------------------------------------------------------------
......@@ -390,14 +390,14 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM CpuGBVI::dL_dx(RealOpenMM r, RealOpenMM x, RealOpenMM S) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM threeHalvesM = static_cast<RealOpenMM>( -1.5 );
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0);
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5);
static const RealOpenMM threeHalvesM = static_cast<RealOpenMM>(-1.5);
static const RealOpenMM third = static_cast<RealOpenMM>( (1.0/3.0));
// ---------------------------------------------------------------------------------------
......@@ -409,7 +409,7 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM diff = (r + S)*(r - S);
return (threeHalvesM*xInv3)*( (half*rInv) - xInv + (half*diff*xInv2*rInv) );
return (threeHalvesM*xInv3)*((half*rInv) - xInv + (half*diff*xInv2*rInv));
}
/**---------------------------------------------------------------------------------------
......@@ -422,19 +422,19 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
RealOpenMM CpuGBVI::Sgb(RealOpenMM t) {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "CpuGBVI::Sgb";
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
// ---------------------------------------------------------------------------------------
return ( (t != zero) ? one/SQRT( (one + (fourth*EXP( -t ))/t) ) : zero);
return ((t != zero) ? one/SQRT((one + (fourth*EXP(-t))/t)) : zero);
}
/**---------------------------------------------------------------------------------------
......@@ -448,18 +448,18 @@ RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
--------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges ){
RealOpenMM CpuGBVI::computeBornEnergy(const vector<RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM four = static_cast<RealOpenMM>( 4.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM two = static_cast<RealOpenMM>(2.0);
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
static const RealOpenMM four = static_cast<RealOpenMM>(4.0);
static const RealOpenMM half = static_cast<RealOpenMM>(0.5);
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
......@@ -471,8 +471,8 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
// compute Born radii
RealOpenMMVector bornRadii( numberOfAtoms );
computeBornRadii( atomCoordinates, bornRadii );
RealOpenMMVector bornRadii(numberOfAtoms);
computeBornRadii(atomCoordinates, bornRadii);
// ---------------------------------------------------------------------------------------
......@@ -483,7 +483,7 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
RealOpenMM energy = zero;
RealOpenMM cavityEnergy = zero;
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM partialChargeI = partialCharges[atomI];
......@@ -496,19 +496,19 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
RealOpenMM ratio = (atomicRadii[atomI]/bornRadii[atomI]);
cavityEnergy += gammaParameters[atomI]*ratio*ratio*ratio;
for( int atomJ = atomI + 1; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = atomI + 1; atomJ < numberOfAtoms; atomJ++) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_gbviParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > _gbviParameters->getCutoffDistance())
continue;
RealOpenMM r2 = deltaR[ReferenceForce::R2Index];
RealOpenMM t = fourth*r2/(bornRadii[atomI]*bornRadii[atomJ]);
atomIEnergy += partialCharges[atomJ]*Sgb( t )/deltaR[ReferenceForce::RIndex];
atomIEnergy += partialCharges[atomJ]*Sgb(t)/deltaR[ReferenceForce::RIndex];
}
energy += two*partialChargeI*atomIEnergy;
......@@ -532,20 +532,20 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
--------------------------------------------------------------------------------------- */
void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges,
std::vector<OpenMM::RealVec>& inputForces){
void CpuGBVI::computeBornForces(std::vector<RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges,
std::vector<OpenMM::RealVec>& inputForces) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM four = static_cast<RealOpenMM>( 4.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM oneThird = static_cast<RealOpenMM>( (1.0/3.0) );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM two = static_cast<RealOpenMM>(2.0);
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
static const RealOpenMM four = static_cast<RealOpenMM>(4.0);
static const RealOpenMM half = static_cast<RealOpenMM>(0.5);
static const RealOpenMM oneThird = static_cast<RealOpenMM>((1.0/3.0));
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// ---------------------------------------------------------------------------------------
......@@ -564,37 +564,37 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// compute Born radii
RealOpenMMVector bornRadii( numberOfAtoms );
computeBornRadii( atomCoordinates, bornRadii );
RealOpenMMVector bornRadii(numberOfAtoms);
computeBornRadii(atomCoordinates, bornRadii);
// set energy/forces to zero
std::vector<OpenMM::RealVec> forces( numberOfAtoms );
for( int ii = 0; ii < numberOfAtoms; ii++ ){
std::vector<OpenMM::RealVec> forces(numberOfAtoms);
for (int ii = 0; ii < numberOfAtoms; ii++) {
forces[ii][0] = zero;
forces[ii][1] = zero;
forces[ii][2] = zero;
}
RealOpenMMVector bornForces( numberOfAtoms, 0.0);
RealOpenMMVector bornForces(numberOfAtoms, 0.0);
// ---------------------------------------------------------------------------------------
// first main loop
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
// partial of polar term wrt Born radius
// and (dGpol/dr)(dr/dx)
RealOpenMM partialChargeI = preFactor*partialCharges[atomI];
for( int atomJ = atomI; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = atomI; atomJ < numberOfAtoms; atomJ++) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_gbviParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > _gbviParameters->getCutoffDistance())
continue;
......@@ -607,16 +607,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM alpha2_ij = bornRadii[atomI]*bornRadii[atomJ];
RealOpenMM D_ij = r2/(four*alpha2_ij);
RealOpenMM expTerm = EXP( -D_ij );
RealOpenMM expTerm = EXP(-D_ij);
RealOpenMM denominator2 = r2 + alpha2_ij*expTerm;
RealOpenMM denominator = SQRT( denominator2 );
RealOpenMM denominator = SQRT(denominator2);
RealOpenMM Gpol = (partialChargeI*partialCharges[atomJ])/denominator;
RealOpenMM dGpol_dr = -Gpol*( one - fourth*expTerm )/denominator2;
RealOpenMM dGpol_dr = -Gpol*(one - fourth*expTerm)/denominator2;
RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*( one + D_ij )/denominator2;
RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*(one + D_ij)/denominator2;
if( atomI != atomJ ){
if (atomI != atomJ) {
bornForces[atomJ] += dGpol_dalpha2_ij*bornRadii[atomI];
......@@ -647,7 +647,7 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
const RealOpenMMVector& scaledRadii = gbviParameters->getScaledRadii();
const RealOpenMMVector& switchDeriviative = getSwitchDeriviative();
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM R = atomicRadii[atomI];
......@@ -659,9 +659,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM b2 = bornRadii[atomI]*bornRadii[atomI];
bornForces[atomI] *= switchDeriviative[atomI]*oneThird*b2*b2;
for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = 0; atomJ < numberOfAtoms; atomJ++) {
if( atomJ != atomI ){
if (atomJ != atomI) {
RealOpenMM deltaX = atomCoordinates[atomJ][0] - atomCoordinates[atomI][0];
RealOpenMM deltaY = atomCoordinates[atomJ][1] - atomCoordinates[atomI][1];
......@@ -669,9 +669,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_gbviParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _gbviParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_gbviParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > _gbviParameters->getCutoffDistance())
continue;
......@@ -680,7 +680,7 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
deltaY = deltaR[ReferenceForce::YIndex];
deltaZ = deltaR[ReferenceForce::ZIndex];
RealOpenMM r = SQRT( r2 );
RealOpenMM r = SQRT(r2);
RealOpenMM S = scaledRadii[atomJ];
RealOpenMM diff = (S - R);
......@@ -689,16 +689,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// find dRb/dr, where Rb is the Born radius
if( FABS( diff ) < r ){
de = CpuGBVI::dL_dr( r, r+S, S ) + CpuGBVI::dL_dx( r, r+S, S );
if( R > (r - S) ){
de -= CpuGBVI::dL_dr( r, R, S );
if (FABS(diff) < r) {
de = CpuGBVI::dL_dr(r, r+S, S) + CpuGBVI::dL_dx(r, r+S, S);
if (R > (r - S)) {
de -= CpuGBVI::dL_dr(r, R, S);
} else {
de -= ( CpuGBVI::dL_dr( r, (r-S), S ) + CpuGBVI::dL_dx( r, (r-S), S ) );
de -= (CpuGBVI::dL_dr(r, (r-S), S) + CpuGBVI::dL_dx(r, (r-S), S));
}
} else if( r < (S - R) ){
de = CpuGBVI::dL_dr( r, r+S, S ) + CpuGBVI::dL_dx( r, r+S, S );
de -= ( CpuGBVI::dL_dr( r, r-S, S ) + CpuGBVI::dL_dx( r, r-S, S ) );
} else if (r < (S - R)) {
de = CpuGBVI::dL_dr(r, r+S, S) + CpuGBVI::dL_dx(r, r+S, S);
de -= (CpuGBVI::dL_dr(r, r-S, S) + CpuGBVI::dL_dx(r, r-S, S));
}
// de = (dG/dRb)(dRb/dr)
......@@ -721,12 +721,12 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
}
}
//printGbvi( atomCoordinates, partialCharges, bornRadii, bornForces, forces, "GBVI: Post loop2", stderr );
//printGbvi(atomCoordinates, partialCharges, bornRadii, bornForces, forces, "GBVI: Post loop2", stderr);
// convert from cal to Joule & apply prefactor tau = (1/diel_solute - 1/diel_solvent)
RealOpenMM conversion = static_cast<RealOpenMM>(gbviParameters->getTau());
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
inputForces[atomI][0] += conversion*forces[atomI][0];
inputForces[atomI][1] += conversion*forces[atomI][1];
inputForces[atomI][2] += conversion*forces[atomI][2];
......@@ -748,11 +748,11 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
--------------------------------------------------------------------------------------- */
void CpuGBVI::printGbvi( const std::vector<OpenMM::RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges,
const RealOpenMMVector& bornRadii,
const RealOpenMMVector& bornForces,
const std::vector<OpenMM::RealVec>& forces,
const std::string& idString, FILE* log ){
void CpuGBVI::printGbvi(const std::vector<OpenMM::RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges,
const RealOpenMMVector& bornRadii,
const RealOpenMMVector& bornForces,
const std::vector<OpenMM::RealVec>& forces,
const std::string& idString, FILE* log) {
// ---------------------------------------------------------------------------------------
......@@ -775,45 +775,45 @@ void CpuGBVI::printGbvi( const std::vector<OpenMM::RealVec>& atomCoordinates, co
int useComparisonFormat = 1;
(void) fprintf( log, "Reference Gbvi %s atoms=%d\n", idString.c_str(), numberOfAtoms );
(void) fprintf( log, " tau %15.7e\n", tau );
(void) fprintf( log, " scaleMethod %d (QuinticEnum=%d)\n",
_gbviParameters->getBornRadiusScalingMethod(), GBVIParameters::QuinticSpline );
(void) fprintf( log, " preFactor %15.7e)\n", preFactor );
(void) fprintf(log, "Reference Gbvi %s atoms=%d\n", idString.c_str(), numberOfAtoms);
(void) fprintf(log, " tau %15.7e\n", tau);
(void) fprintf(log, " scaleMethod %d (QuinticEnum=%d)\n",
_gbviParameters->getBornRadiusScalingMethod(), GBVIParameters::QuinticSpline);
(void) fprintf(log, " preFactor %15.7e)\n", preFactor);
if( useComparisonFormat ){
(void) fprintf( log, " br bF swd r scR tau*gamma q)\n" );
for( unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++ ){
(void) fprintf( log, "%6d ", atomI );
if( bornRadii.size() > atomI ){
(void) fprintf( log, "%15.7e ", bornRadii[atomI] );
if (useComparisonFormat) {
(void) fprintf(log, " br bF swd r scR tau*gamma q)\n");
for (unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++) {
(void) fprintf(log, "%6d ", atomI);
if (bornRadii.size() > atomI) {
(void) fprintf(log, "%15.7e ", bornRadii[atomI]);
}
if( bornForces.size() > atomI ){
(void) fprintf( log, "%15.7e ", tau*bornForces[atomI] );
if (bornForces.size() > atomI) {
(void) fprintf(log, "%15.7e ", tau*bornForces[atomI]);
}
(void) fprintf( log, " %15.7e %15.7e %15.7e %15.7e %15.7e",
(void) fprintf(log, " %15.7e %15.7e %15.7e %15.7e %15.7e",
switchDeriviative[atomI],
atomicRadii[atomI],
scaledRadii[atomI],
tau*gammaParameters[atomI],
partialCharges[atomI] );
(void) fprintf( log, "\n" );
partialCharges[atomI]);
(void) fprintf(log, "\n");
}
} else {
for( unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++ ){
(void) fprintf( log, "%6d r=%15.7e rSc=%15.7e swd=%15.7e tau*gam=%15.7e q=%15.7e", atomI,
for (unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++) {
(void) fprintf(log, "%6d r=%15.7e rSc=%15.7e swd=%15.7e tau*gam=%15.7e q=%15.7e", atomI,
atomicRadii[atomI],
scaledRadii[atomI],
switchDeriviative[atomI],
tau*gammaParameters[atomI],
partialCharges[atomI] );
if( bornRadii.size() > atomI ){
(void) fprintf( log, " bR=%15.7e", bornRadii[atomI] );
partialCharges[atomI]);
if (bornRadii.size() > atomI) {
(void) fprintf(log, " bR=%15.7e", bornRadii[atomI]);
}
if( bornForces.size() > atomI ){
(void) fprintf( log, " tau*bF=%15.7e", tau*bornForces[atomI] );
if (bornForces.size() > atomI) {
(void) fprintf(log, " tau*bF=%15.7e", tau*bornForces[atomI]);
}
(void) fprintf( log, "\n" );
(void) fprintf(log, "\n");
}
}
......@@ -835,7 +835,7 @@ void CpuGBVI::printGbvi( const std::vector<OpenMM::RealVec>& atomCoordinates, co
--------------------------------------------------------------------------------------- */
double CpuGBVI::getVolumeD( double r, double R, double S ){
double CpuGBVI::getVolumeD(double r, double R, double S) {
// ---------------------------------------------------------------------------------------
......@@ -843,18 +843,18 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
static const double minusThree = -3.0;
double diff = (S - R);
if( fabs( diff ) < r ){
if (fabs(diff) < r) {
double lowerBound = (R > (r - S)) ? R : (r - S);
return (CpuGBVI::getLD( r, (r + S), S ) -
CpuGBVI::getLD( r, lowerBound, S ));
return (CpuGBVI::getLD(r, (r + S), S) -
CpuGBVI::getLD(r, lowerBound, S));
} else if( r < diff ){
} else if (r < diff) {
return CpuGBVI::getLD( r, (r + S), S ) -
CpuGBVI::getLD( r, (r - S), S ) +
pow( R, minusThree );
return CpuGBVI::getLD(r, (r + S), S) -
CpuGBVI::getLD(r, (r - S), S) +
pow(R, minusThree);
} else {
return zero;
......@@ -875,7 +875,7 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
--------------------------------------------------------------------------------------- */
double CpuGBVI::getLD( double r, double x, double S ){
double CpuGBVI::getLD(double r, double x, double S) {
// ---------------------------------------------------------------------------------------
......@@ -895,7 +895,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
double diff2 = (r + S)*(r - S);
return (threeHalves*xInv)*( (xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv) );
return (threeHalves*xInv)*((xInv*fourth*rInv) - (xInv2*third) + (diff2*xInv3*eighth*rInv));
}
/**---------------------------------------------------------------------------------------
......@@ -912,7 +912,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
--------------------------------------------------------------------------------------- */
double CpuGBVI::dL_drD( double r, double x, double S ){
double CpuGBVI::dL_drD(double r, double x, double S) {
// ---------------------------------------------------------------------------------------
......@@ -934,7 +934,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
double diff2 = (r + S)*(r - S);
return ( (-threeHalves*xInv2*rInv2)*( fourth + eighth*diff2*xInv2 ) + threeEights*xInv3*xInv );
return ((-threeHalves*xInv2*rInv2)*(fourth + eighth*diff2*xInv2) + threeEights*xInv3*xInv);
}
/**---------------------------------------------------------------------------------------
......@@ -951,7 +951,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
--------------------------------------------------------------------------------------- */
double CpuGBVI::dL_dxD( double r, double x, double S ){
double CpuGBVI::dL_dxD(double r, double x, double S) {
// ---------------------------------------------------------------------------------------
......@@ -970,5 +970,5 @@ double CpuGBVI::dL_dxD( double r, double x, double S ){
double diff = (r + S)*(r - S);
return (threeHalvesM*xInv3)*( (half*rInv) - xInv + (half*diff*xInv2*rInv) );
return (threeHalvesM*xInv3)*((half*rInv) - xInv + (half*diff*xInv2*rInv));
}
......@@ -43,7 +43,7 @@ using namespace std;
--------------------------------------------------------------------------------------- */
CpuObc::CpuObc( ObcParameters* obcParameters ) : _obcParameters(obcParameters), _includeAceApproximation(1) {
CpuObc::CpuObc(ObcParameters* obcParameters) : _obcParameters(obcParameters), _includeAceApproximation(1) {
_obcChain.resize(_obcParameters->getNumberOfAtoms());
}
......@@ -53,7 +53,7 @@ CpuObc::CpuObc( ObcParameters* obcParameters ) : _obcParameters(obcParameters),
--------------------------------------------------------------------------------------- */
CpuObc::~CpuObc( ){
CpuObc::~CpuObc() {
}
/**---------------------------------------------------------------------------------------
......@@ -64,7 +64,7 @@ CpuObc::~CpuObc( ){
--------------------------------------------------------------------------------------- */
ObcParameters* CpuObc::getObcParameters( void ) const {
ObcParameters* CpuObc::getObcParameters() const {
return _obcParameters;
}
......@@ -76,7 +76,7 @@ ObcParameters* CpuObc::getObcParameters( void ) const {
--------------------------------------------------------------------------------------- */
void CpuObc::setObcParameters( ObcParameters* obcParameters ){
void CpuObc::setObcParameters( ObcParameters* obcParameters) {
_obcParameters = obcParameters;
}
......@@ -88,7 +88,7 @@ void CpuObc::setObcParameters( ObcParameters* obcParameters ){
--------------------------------------------------------------------------------------- */
int CpuObc::includeAceApproximation( void ) const {
int CpuObc::includeAceApproximation() const {
return _includeAceApproximation;
}
......@@ -100,7 +100,7 @@ int CpuObc::includeAceApproximation( void ) const {
--------------------------------------------------------------------------------------- */
void CpuObc::setIncludeAceApproximation( int includeAceApproximation ){
void CpuObc::setIncludeAceApproximation(int includeAceApproximation) {
_includeAceApproximation = includeAceApproximation;
}
......@@ -112,7 +112,7 @@ void CpuObc::setIncludeAceApproximation( int includeAceApproximation ){
--------------------------------------------------------------------------------------- */
vector<RealOpenMM>& CpuObc::getObcChain( void ){
vector<RealOpenMM>& CpuObc::getObcChain() {
return _obcChain;
}
......@@ -128,16 +128,16 @@ vector<RealOpenMM>& CpuObc::getObcChain( void ){
--------------------------------------------------------------------------------------- */
void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<RealOpenMM>& bornRadii ){
void CpuObc::computeBornRadii(const vector<RealVec>& atomCoordinates, vector<RealOpenMM>& bornRadii) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM two = static_cast<RealOpenMM>(2.0);
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
static const RealOpenMM half = static_cast<RealOpenMM>(0.5);
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
// ---------------------------------------------------------------------------------------
......@@ -157,7 +157,7 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
// calculate Born radii
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM radiusI = atomicRadii[atomI];
RealOpenMM offsetRadiusI = radiusI - dielectricOffset;
......@@ -167,15 +167,15 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
// HCT code
for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = 0; atomJ < numberOfAtoms; atomJ++) {
if( atomJ != atomI ){
if (atomJ != atomI) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_obcParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _obcParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _obcParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
RealOpenMM r = deltaR[ReferenceForce::RIndex];
if (_obcParameters->getUseCutoff() && r > _obcParameters->getCutoffDistance())
continue;
......@@ -184,9 +184,9 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
RealOpenMM scaledRadiusJ = offsetRadiusJ*scaledRadiusFactor[atomJ];
RealOpenMM rScaledRadiusJ = r + scaledRadiusJ;
if( offsetRadiusI < rScaledRadiusJ ){
if (offsetRadiusI < rScaledRadiusJ) {
RealOpenMM rInverse = one/r;
RealOpenMM l_ij = offsetRadiusI > FABS( r - scaledRadiusJ ) ? offsetRadiusI : FABS( r - scaledRadiusJ );
RealOpenMM l_ij = offsetRadiusI > FABS(r - scaledRadiusJ) ? offsetRadiusI : FABS(r - scaledRadiusJ);
l_ij = one/l_ij;
RealOpenMM u_ij = one/rScaledRadiusJ;
......@@ -194,15 +194,15 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
RealOpenMM l_ij2 = l_ij*l_ij;
RealOpenMM u_ij2 = u_ij*u_ij;
RealOpenMM ratio = LN( (u_ij/l_ij) );
RealOpenMM term = l_ij - u_ij + fourth*r*(u_ij2 - l_ij2) + ( half*rInverse*ratio) + (fourth*scaledRadiusJ*scaledRadiusJ*rInverse)*(l_ij2 - u_ij2);
RealOpenMM ratio = LN((u_ij/l_ij));
RealOpenMM term = l_ij - u_ij + fourth*r*(u_ij2 - l_ij2) + (half*rInverse*ratio) + (fourth*scaledRadiusJ*scaledRadiusJ*rInverse)*(l_ij2 - u_ij2);
// this case (atom i completely inside atom j) is not considered in the original paper
// Jay Ponder and the authors of Tinker recognized this and
// worked out the details
if( offsetRadiusI < (scaledRadiusJ - r) ){
term += two*( radiusIInverse - l_ij);
if (offsetRadiusI < (scaledRadiusJ - r)) {
term += two*(radiusIInverse - l_ij);
}
sum += term;
......@@ -215,11 +215,11 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
sum *= half*offsetRadiusI;
RealOpenMM sum2 = sum*sum;
RealOpenMM sum3 = sum*sum2;
RealOpenMM tanhSum = TANH( alphaObc*sum - betaObc*sum2 + gammaObc*sum3 );
RealOpenMM tanhSum = TANH(alphaObc*sum - betaObc*sum2 + gammaObc*sum3);
bornRadii[atomI] = one/( one/offsetRadiusI - tanhSum/radiusI );
bornRadii[atomI] = one/(one/offsetRadiusI - tanhSum/radiusI);
obcChain[atomI] = offsetRadiusI*( alphaObc - two*betaObc*sum + three*gammaObc*sum2 );
obcChain[atomI] = offsetRadiusI*(alphaObc - two*betaObc*sum + three*gammaObc*sum2);
obcChain[atomI] = (one - tanhSum*tanhSum)*obcChain[atomI]/radiusI;
}
......@@ -236,16 +236,16 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
--------------------------------------------------------------------------------------- */
void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
void CpuObc::computeAceNonPolarForce(const ObcParameters* obcParameters,
const RealOpenMMVector& bornRadii,
RealOpenMM* energy,
RealOpenMMVector& forces ) const {
RealOpenMMVector& forces) const {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM minusSix = -6.0;
static const RealOpenMM six = static_cast<RealOpenMM>( 6.0 );
static const RealOpenMM six = static_cast<RealOpenMM>(6.0);
// ---------------------------------------------------------------------------------------
......@@ -271,10 +271,10 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
// observed values. He did not think it was important enough to write up, so there is
// no paper to cite.
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
if( bornRadii[atomI] > zero ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
if (bornRadii[atomI] > zero) {
RealOpenMM r = atomicRadii[atomI] + probeRadius;
RealOpenMM ratio6 = POW( atomicRadii[atomI]/bornRadii[atomI], six );
RealOpenMM ratio6 = POW(atomicRadii[atomI]/bornRadii[atomI], six);
RealOpenMM saTerm = surfaceAreaFactor*r*r*ratio6;
*energy += saTerm;
forces[atomI] += minusSix*saTerm/bornRadii[atomI];
......@@ -294,19 +294,19 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
--------------------------------------------------------------------------------------- */
RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinates,
const RealOpenMMVector& partialCharges, vector<RealVec>& inputForces ){
RealOpenMM CpuObc::computeBornEnergyForces(const vector<RealVec>& atomCoordinates,
const RealOpenMMVector& partialCharges, vector<RealVec>& inputForces) {
// ---------------------------------------------------------------------------------------
static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM four = static_cast<RealOpenMM>( 4.0 );
static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM zero = static_cast<RealOpenMM>(0.0);
static const RealOpenMM one = static_cast<RealOpenMM>(1.0);
static const RealOpenMM two = static_cast<RealOpenMM>(2.0);
static const RealOpenMM three = static_cast<RealOpenMM>(3.0);
static const RealOpenMM four = static_cast<RealOpenMM>(4.0);
static const RealOpenMM half = static_cast<RealOpenMM>(0.5);
static const RealOpenMM fourth = static_cast<RealOpenMM>(0.25);
static const RealOpenMM eighth = static_cast<RealOpenMM>(0.125);
// constants
......@@ -325,36 +325,36 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
// compute Born radii
RealOpenMMVector bornRadii( numberOfAtoms );
computeBornRadii( atomCoordinates, bornRadii );
RealOpenMMVector bornRadii(numberOfAtoms);
computeBornRadii(atomCoordinates, bornRadii);
// set energy/forces to zero
RealOpenMM obcEnergy = zero;
RealOpenMMVector bornForces( numberOfAtoms, 0.0 );
RealOpenMMVector bornForces(numberOfAtoms, 0.0);
// ---------------------------------------------------------------------------------------
// compute the nonpolar solvation via ACE approximation
if( includeAceApproximation() ){
computeAceNonPolarForce( _obcParameters, bornRadii, &obcEnergy, bornForces );
if (includeAceApproximation()) {
computeAceNonPolarForce(_obcParameters, bornRadii, &obcEnergy, bornForces);
}
// ---------------------------------------------------------------------------------------
// first main loop
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
RealOpenMM partialChargeI = preFactor*partialCharges[atomI];
for( int atomJ = atomI; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = atomI; atomJ < numberOfAtoms; atomJ++) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_obcParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _obcParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _obcParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_obcParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > cutoffDistance)
continue;
......@@ -366,18 +366,18 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
RealOpenMM alpha2_ij = bornRadii[atomI]*bornRadii[atomJ];
RealOpenMM D_ij = r2/(four*alpha2_ij);
RealOpenMM expTerm = EXP( -D_ij );
RealOpenMM expTerm = EXP(-D_ij);
RealOpenMM denominator2 = r2 + alpha2_ij*expTerm;
RealOpenMM denominator = SQRT( denominator2 );
RealOpenMM denominator = SQRT(denominator2);
RealOpenMM Gpol = (partialChargeI*partialCharges[atomJ])/denominator;
RealOpenMM dGpol_dr = -Gpol*( one - fourth*expTerm )/denominator2;
RealOpenMM dGpol_dr = -Gpol*(one - fourth*expTerm)/denominator2;
RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*( one + D_ij )/denominator2;
RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*(one + D_ij)/denominator2;
RealOpenMM energy = Gpol;
if( atomI != atomJ ){
if (atomI != atomJ) {
if (_obcParameters->getUseCutoff())
energy -= partialChargeI*partialCharges[atomJ]/cutoffDistance;
......@@ -420,26 +420,26 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
// compute factor that depends only on the outer loop index
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
bornForces[atomI] *= bornRadii[atomI]*bornRadii[atomI]*obcChain[atomI];
}
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
for (int atomI = 0; atomI < numberOfAtoms; atomI++) {
// radius w/ dielectric offset applied
RealOpenMM radiusI = atomicRadii[atomI];
RealOpenMM offsetRadiusI = radiusI - dielectricOffset;
for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){
for (int atomJ = 0; atomJ < numberOfAtoms; atomJ++) {
if( atomJ != atomI ){
if (atomJ != atomI) {
RealOpenMM deltaR[ReferenceForce::LastDeltaRIndex];
if (_obcParameters->getPeriodic())
ReferenceForce::getDeltaRPeriodic( atomCoordinates[atomI], atomCoordinates[atomJ], _obcParameters->getPeriodicBox(), deltaR );
ReferenceForce::getDeltaRPeriodic(atomCoordinates[atomI], atomCoordinates[atomJ], _obcParameters->getPeriodicBox(), deltaR);
else
ReferenceForce::getDeltaR( atomCoordinates[atomI], atomCoordinates[atomJ], deltaR );
ReferenceForce::getDeltaR(atomCoordinates[atomI], atomCoordinates[atomJ], deltaR);
if (_obcParameters->getUseCutoff() && deltaR[ReferenceForce::RIndex] > cutoffDistance)
continue;
......@@ -459,9 +459,9 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
// dL/dr & dU/dr are zero (this can be shown analytically)
// removed from calculation
if( offsetRadiusI < rScaledRadiusJ ){
if (offsetRadiusI < rScaledRadiusJ) {
RealOpenMM l_ij = offsetRadiusI > FABS( r - scaledRadiusJ ) ? offsetRadiusI : FABS( r - scaledRadiusJ );
RealOpenMM l_ij = offsetRadiusI > FABS(r - scaledRadiusJ) ? offsetRadiusI : FABS(r - scaledRadiusJ);
l_ij = one/l_ij;
RealOpenMM u_ij = one/rScaledRadiusJ;
......@@ -473,7 +473,7 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
RealOpenMM rInverse = one/r;
RealOpenMM r2Inverse = rInverse*rInverse;
RealOpenMM t3 = eighth*(one + scaledRadiusJ2*r2Inverse)*(l_ij2 - u_ij2) + fourth*LN( u_ij/l_ij )*r2Inverse;
RealOpenMM t3 = eighth*(one + scaledRadiusJ2*r2Inverse)*(l_ij2 - u_ij2) + fourth*LN(u_ij/l_ij)*r2Inverse;
RealOpenMM de = bornForces[atomI]*t3*rInverse;
......@@ -495,7 +495,7 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
}
//printObc( atomCoordinates, partialCharges, bornRadii, bornForces, inputForces, "Obc Post loop2", stderr );
//printObc(atomCoordinates, partialCharges, bornRadii, bornForces, inputForces, "Obc Post loop2", stderr);
return obcEnergy;
}
......@@ -514,12 +514,12 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
--------------------------------------------------------------------------------------- */
void CpuObc::printObc( const std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMMVector& partialCharges,
const RealOpenMMVector& bornRadii,
const RealOpenMMVector& bornForces,
const std::vector<OpenMM::RealVec>& forces,
const std::string& idString, FILE* log ){
void CpuObc::printObc(const std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMMVector& partialCharges,
const RealOpenMMVector& bornRadii,
const RealOpenMMVector& bornForces,
const std::vector<OpenMM::RealVec>& forces,
const std::string& idString, FILE* log) {
// ---------------------------------------------------------------------------------------
......@@ -538,43 +538,43 @@ void CpuObc::printObc( const std::vector<OpenMM::RealVec>& atomCoordinates,
// ---------------------------------------------------------------------------------------
(void) fprintf( log, "Reference Obc %s atoms=%d\n", idString.c_str(), numberOfAtoms );
if( comparisonFormat ){
(void) fprintf( log, "Reference Obc %s atoms=%d Chain/Radii/Force\n", idString.c_str(), numberOfAtoms );
for( unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++ ){
(void) fprintf( log, "%6d ", atomI );
if( obcChain.size() > atomI ){
(void) fprintf( log, " %15.7e", obcChain[atomI] );
(void) fprintf(log, "Reference Obc %s atoms=%d\n", idString.c_str(), numberOfAtoms);
if (comparisonFormat) {
(void) fprintf(log, "Reference Obc %s atoms=%d Chain/Radii/Force\n", idString.c_str(), numberOfAtoms);
for (unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++) {
(void) fprintf(log, "%6d ", atomI);
if (obcChain.size() > atomI) {
(void) fprintf(log, " %15.7e", obcChain[atomI]);
}
if( bornRadii.size() > atomI ){
(void) fprintf( log, " %15.7e", bornRadii[atomI] );
if (bornRadii.size() > atomI) {
(void) fprintf(log, " %15.7e", bornRadii[atomI]);
}
if( bornForces.size() > atomI ){
(void) fprintf( log, " %15.7e", bornForces[atomI] );
if (bornForces.size() > atomI) {
(void) fprintf(log, " %15.7e", bornForces[atomI]);
}
(void) fprintf( log, " %15.7e %6.3f", atomicRadii[atomI], partialCharges[atomI] );
(void) fprintf( log, "\n" );
(void) fprintf(log, " %15.7e %6.3f", atomicRadii[atomI], partialCharges[atomI]);
(void) fprintf(log, "\n");
}
} else {
(void) fprintf( log, "Reference Obc %s atoms=%d\n", idString.c_str(), numberOfAtoms );
(void) fprintf( log, " preFactor %15.7e\n", preFactor );
(void) fprintf( log, " alpha %15.7e\n", alphaObc);
(void) fprintf( log, " beta %15.7e\n", betaObc);
(void) fprintf( log, " gamma %15.7e\n", gammaObc );
(void) fprintf(log, "Reference Obc %s atoms=%d\n", idString.c_str(), numberOfAtoms);
(void) fprintf(log, " preFactor %15.7e\n", preFactor);
(void) fprintf(log, " alpha %15.7e\n", alphaObc);
(void) fprintf(log, " beta %15.7e\n", betaObc);
(void) fprintf(log, " gamma %15.7e\n", gammaObc);
for( unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++ ){
(void) fprintf( log, "%6d r=%15.7e q=%6.3f", atomI,
atomicRadii[atomI], partialCharges[atomI] );
if( obcChain.size() > atomI ){
(void) fprintf( log, " bChn=%15.7e", obcChain[atomI] );
for (unsigned int atomI = 0; atomI < static_cast<unsigned int>(numberOfAtoms); atomI++) {
(void) fprintf(log, "%6d r=%15.7e q=%6.3f", atomI,
atomicRadii[atomI], partialCharges[atomI]);
if (obcChain.size() > atomI) {
(void) fprintf(log, " bChn=%15.7e", obcChain[atomI]);
}
if( bornRadii.size() > atomI ){
(void) fprintf( log, " bR=%15.7e", bornRadii[atomI] );
if (bornRadii.size() > atomI) {
(void) fprintf(log, " bR=%15.7e", bornRadii[atomI]);
}
if( bornForces.size() > atomI ){
(void) fprintf( log, " bF=%15.7e", bornForces[atomI] );
if (bornForces.size() > atomI) {
(void) fprintf(log, " bF=%15.7e", bornForces[atomI]);
}
(void) fprintf( log, "\n" );
(void) fprintf(log, "\n");
}
}
......
......@@ -41,19 +41,19 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
GBVIParameters::GBVIParameters( int numberOfAtoms ) : _numberOfAtoms(numberOfAtoms),
_soluteDielectric(1.0),
_solventDielectric(78.3),
_electricConstant(-0.5*ONE_4PI_EPS0),
_cutoff(false),
_periodic(false),
_bornRadiusScalingMethod(0),
_quinticLowerLimitFactor(0.8),
_quinticUpperBornRadiusLimit(5.0) {
_atomicRadii.resize( numberOfAtoms );
_scaledRadii.resize( numberOfAtoms );
_gammaParameters.resize( numberOfAtoms );
GBVIParameters::GBVIParameters(int numberOfAtoms) : _numberOfAtoms(numberOfAtoms),
_soluteDielectric(1.0),
_solventDielectric(78.3),
_electricConstant(-0.5*ONE_4PI_EPS0),
_cutoff(false),
_periodic(false),
_bornRadiusScalingMethod(0),
_quinticLowerLimitFactor(0.8),
_quinticUpperBornRadiusLimit(5.0) {
_atomicRadii.resize(numberOfAtoms);
_scaledRadii.resize(numberOfAtoms);
_gammaParameters.resize(numberOfAtoms);
}
......@@ -63,7 +63,7 @@ GBVIParameters::GBVIParameters( int numberOfAtoms ) : _numberOfAtoms(numberOfAto
--------------------------------------------------------------------------------------- */
GBVIParameters::~GBVIParameters( ){
GBVIParameters::~GBVIParameters() {
}
/**---------------------------------------------------------------------------------------
......@@ -74,7 +74,7 @@ GBVIParameters::~GBVIParameters( ){
--------------------------------------------------------------------------------------- */
int GBVIParameters::getNumberOfAtoms( void ) const {
int GBVIParameters::getNumberOfAtoms() const {
return _numberOfAtoms;
}
......@@ -86,7 +86,7 @@ int GBVIParameters::getNumberOfAtoms( void ) const {
--------------------------------------------------------------------------------------- */
RealOpenMM GBVIParameters::getElectricConstant( void ) const {
RealOpenMM GBVIParameters::getElectricConstant() const {
return _electricConstant;
}
......@@ -98,7 +98,7 @@ RealOpenMM GBVIParameters::getElectricConstant( void ) const {
--------------------------------------------------------------------------------------- */
RealOpenMM GBVIParameters::getSolventDielectric( void ) const {
RealOpenMM GBVIParameters::getSolventDielectric() const {
return _solventDielectric;
}
......@@ -110,7 +110,7 @@ RealOpenMM GBVIParameters::getSolventDielectric( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setSolventDielectric( RealOpenMM solventDielectric ){
void GBVIParameters::setSolventDielectric(RealOpenMM solventDielectric) {
_solventDielectric = solventDielectric;
}
......@@ -122,7 +122,7 @@ void GBVIParameters::setSolventDielectric( RealOpenMM solventDielectric ){
--------------------------------------------------------------------------------------- */
RealOpenMM GBVIParameters::getSoluteDielectric( void ) const {
RealOpenMM GBVIParameters::getSoluteDielectric() const {
return _soluteDielectric;
}
......@@ -134,7 +134,7 @@ RealOpenMM GBVIParameters::getSoluteDielectric( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setSoluteDielectric( RealOpenMM soluteDielectric ){
void GBVIParameters::setSoluteDielectric(RealOpenMM soluteDielectric) {
_soluteDielectric = soluteDielectric;
}
......@@ -146,7 +146,7 @@ void GBVIParameters::setSoluteDielectric( RealOpenMM soluteDielectric ){
--------------------------------------------------------------------------------------- */
const RealOpenMMVector& GBVIParameters::getAtomicRadii( void ) const {
const RealOpenMMVector& GBVIParameters::getAtomicRadii() const {
return _atomicRadii;
}
......@@ -158,10 +158,10 @@ const RealOpenMMVector& GBVIParameters::getAtomicRadii( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setAtomicRadii( const RealOpenMMVector& atomicRadii ){
void GBVIParameters::setAtomicRadii(const RealOpenMMVector& atomicRadii) {
if( atomicRadii.size() == _atomicRadii.size() ){
for( unsigned int ii = 0; ii < atomicRadii.size(); ii++ ){
if (atomicRadii.size() == _atomicRadii.size()) {
for (unsigned int ii = 0; ii < atomicRadii.size(); ii++) {
_atomicRadii[ii] = atomicRadii[ii];
}
} else {
......@@ -181,7 +181,7 @@ void GBVIParameters::setAtomicRadii( const RealOpenMMVector& atomicRadii ){
--------------------------------------------------------------------------------------- */
const RealOpenMMVector& GBVIParameters::getScaledRadii( void ) const {
const RealOpenMMVector& GBVIParameters::getScaledRadii() const {
return _scaledRadii;
}
......@@ -193,10 +193,10 @@ const RealOpenMMVector& GBVIParameters::getScaledRadii( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setScaledRadii( const RealOpenMMVector& scaledRadii ){
void GBVIParameters::setScaledRadii(const RealOpenMMVector& scaledRadii) {
if( scaledRadii.size() == _scaledRadii.size() ){
for( unsigned int ii = 0; ii < scaledRadii.size(); ii++ ){
if (scaledRadii.size() == _scaledRadii.size()) {
for (unsigned int ii = 0; ii < scaledRadii.size(); ii++) {
_scaledRadii[ii] = scaledRadii[ii];
}
} else {
......@@ -218,7 +218,7 @@ void GBVIParameters::setScaledRadii( const RealOpenMMVector& scaledRadii ){
--------------------------------------------------------------------------------------- */
const RealOpenMMVector& GBVIParameters::getGammaParameters( void ) const {
const RealOpenMMVector& GBVIParameters::getGammaParameters() const {
return _gammaParameters;
}
......@@ -230,10 +230,10 @@ const RealOpenMMVector& GBVIParameters::getGammaParameters( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setGammaParameters( const RealOpenMMVector& gammas ){
void GBVIParameters::setGammaParameters(const RealOpenMMVector& gammas) {
if( gammas.size() == _gammaParameters.size() ){
for( unsigned int ii = 0; ii < gammas.size(); ii++ ){
if (gammas.size() == _gammaParameters.size()) {
for (unsigned int ii = 0; ii < gammas.size(); ii++) {
_gammaParameters[ii] = gammas[ii];
}
} else {
......@@ -254,7 +254,7 @@ void GBVIParameters::setGammaParameters( const RealOpenMMVector& gammas ){
--------------------------------------------------------------------------------------- */
void GBVIParameters::setUseCutoff( RealOpenMM distance ) {
void GBVIParameters::setUseCutoff(RealOpenMM distance) {
_cutoff = true;
_cutoffDistance = distance;
......@@ -330,7 +330,7 @@ const OpenMM::RealVec* GBVIParameters::getPeriodicBox() {
--------------------------------------------------------------------------------------- */
RealOpenMM GBVIParameters::getTau( void ) const {
RealOpenMM GBVIParameters::getTau() const {
// ---------------------------------------------------------------------------------------
......@@ -340,7 +340,7 @@ RealOpenMM GBVIParameters::getTau( void ) const {
// ---------------------------------------------------------------------------------------
RealOpenMM tau;
if( getSoluteDielectric() != zero && getSolventDielectric() != zero ){
if (getSoluteDielectric() != zero && getSolventDielectric() != zero) {
tau = (one/getSoluteDielectric()) - (one/getSolventDielectric());
} else {
tau = zero;
......@@ -357,7 +357,7 @@ RealOpenMM GBVIParameters::getTau( void ) const {
--------------------------------------------------------------------------------------- */
int GBVIParameters::getBornRadiusScalingMethod( void ) const {
int GBVIParameters::getBornRadiusScalingMethod() const {
return _bornRadiusScalingMethod;
}
......@@ -369,7 +369,7 @@ int GBVIParameters::getBornRadiusScalingMethod( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setBornRadiusScalingMethod( int bornRadiusScalingMethod ){
void GBVIParameters::setBornRadiusScalingMethod(int bornRadiusScalingMethod) {
_bornRadiusScalingMethod = bornRadiusScalingMethod;
}
......@@ -381,7 +381,7 @@ void GBVIParameters::setBornRadiusScalingMethod( int bornRadiusScalingMethod ){
--------------------------------------------------------------------------------------- */
RealOpenMM GBVIParameters::getQuinticLowerLimitFactor( void ) const {
RealOpenMM GBVIParameters::getQuinticLowerLimitFactor() const {
return _quinticLowerLimitFactor;
}
......@@ -393,7 +393,7 @@ RealOpenMM GBVIParameters::getQuinticLowerLimitFactor( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setQuinticLowerLimitFactor( RealOpenMM quinticLowerLimitFactor ){
void GBVIParameters::setQuinticLowerLimitFactor(RealOpenMM quinticLowerLimitFactor) {
_quinticLowerLimitFactor = quinticLowerLimitFactor;
}
......@@ -405,7 +405,7 @@ void GBVIParameters::setQuinticLowerLimitFactor( RealOpenMM quinticLowerLimitFac
--------------------------------------------------------------------------------------- */
RealOpenMM GBVIParameters::getQuinticUpperBornRadiusLimit( void ) const {
RealOpenMM GBVIParameters::getQuinticUpperBornRadiusLimit() const {
return _quinticUpperBornRadiusLimit;
}
......@@ -417,6 +417,6 @@ RealOpenMM GBVIParameters::getQuinticUpperBornRadiusLimit( void ) const {
--------------------------------------------------------------------------------------- */
void GBVIParameters::setQuinticUpperBornRadiusLimit( RealOpenMM quinticUpperBornRadiusLimit ){
void GBVIParameters::setQuinticUpperBornRadiusLimit(RealOpenMM quinticUpperBornRadiusLimit) {
_quinticUpperBornRadiusLimit = quinticUpperBornRadiusLimit;
}
......@@ -42,21 +42,21 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ObcParameters::ObcParameters( int numberOfAtoms, ObcParameters::ObcType obcType ) :
_numberOfAtoms(numberOfAtoms),
_solventDielectric( 78.3 ),
_soluteDielectric( 1.0 ),
_electricConstant(-0.5*ONE_4PI_EPS0),
_probeRadius(0.14),
_pi4Asolv( 28.3919551),
_dielectricOffset( 0.009 ),
_obcType( obcType ),
_cutoff(false),
_periodic(false) {
_atomicRadii.resize( numberOfAtoms );
_scaledRadiusFactors.resize( numberOfAtoms );
setObcTypeParameters( obcType );
ObcParameters::ObcParameters(int numberOfAtoms, ObcParameters::ObcType obcType) :
_numberOfAtoms(numberOfAtoms),
_solventDielectric(78.3),
_soluteDielectric(1.0),
_electricConstant(-0.5*ONE_4PI_EPS0),
_probeRadius(0.14),
_pi4Asolv(28.3919551),
_dielectricOffset(0.009),
_obcType(obcType),
_cutoff(false),
_periodic(false) {
_atomicRadii.resize(numberOfAtoms);
_scaledRadiusFactors.resize(numberOfAtoms);
setObcTypeParameters(obcType);
}
......@@ -66,7 +66,7 @@ ObcParameters::ObcParameters( int numberOfAtoms, ObcParameters::ObcType obcType
--------------------------------------------------------------------------------------- */
ObcParameters::~ObcParameters( ){
ObcParameters::~ObcParameters() {
}
/**---------------------------------------------------------------------------------------
......@@ -77,7 +77,7 @@ ObcParameters::~ObcParameters( ){
--------------------------------------------------------------------------------------- */
int ObcParameters::getNumberOfAtoms( void ) const {
int ObcParameters::getNumberOfAtoms() const {
return _numberOfAtoms;
}
......@@ -89,7 +89,7 @@ int ObcParameters::getNumberOfAtoms( void ) const {
--------------------------------------------------------------------------------------- */
ObcParameters::ObcType ObcParameters::getObcType( void ) const {
ObcParameters::ObcType ObcParameters::getObcType() const {
return _obcType;
}
......@@ -101,8 +101,8 @@ ObcParameters::ObcType ObcParameters::getObcType( void ) const {
--------------------------------------------------------------------------------------- */
void ObcParameters::setObcTypeParameters( ObcParameters::ObcType obcType ){
if( obcType == ObcTypeI ){
void ObcParameters::setObcTypeParameters(ObcParameters::ObcType obcType) {
if (obcType == ObcTypeI) {
_alphaObc = 0.8f;
_betaObc = 0.0f;
_gammaObc = 2.91f;
......@@ -122,7 +122,7 @@ void ObcParameters::setObcTypeParameters( ObcParameters::ObcType obcType ){
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getDielectricOffset( void ) const {
RealOpenMM ObcParameters::getDielectricOffset() const {
return _dielectricOffset;
}
......@@ -134,7 +134,7 @@ RealOpenMM ObcParameters::getDielectricOffset( void ) const {
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getAlphaObc( void ) const {
RealOpenMM ObcParameters::getAlphaObc() const {
return _alphaObc;
}
......@@ -146,7 +146,7 @@ RealOpenMM ObcParameters::getAlphaObc( void ) const {
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getBetaObc( void ) const {
RealOpenMM ObcParameters::getBetaObc() const {
return _betaObc;
}
......@@ -158,7 +158,7 @@ RealOpenMM ObcParameters::getBetaObc( void ) const {
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getGammaObc( void ) const {
RealOpenMM ObcParameters::getGammaObc() const {
return _gammaObc;
}
......@@ -170,7 +170,7 @@ RealOpenMM ObcParameters::getGammaObc( void ) const {
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getSolventDielectric( void ) const {
RealOpenMM ObcParameters::getSolventDielectric() const {
return _solventDielectric;
}
......@@ -182,7 +182,7 @@ RealOpenMM ObcParameters::getSolventDielectric( void ) const {
--------------------------------------------------------------------------------------- */
void ObcParameters::setSolventDielectric( RealOpenMM solventDielectric ){
void ObcParameters::setSolventDielectric(RealOpenMM solventDielectric) {
_solventDielectric = solventDielectric;
}
/**---------------------------------------------------------------------------------------
......@@ -193,7 +193,7 @@ void ObcParameters::setSolventDielectric( RealOpenMM solventDielectric ){
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getSoluteDielectric( void ) const {
RealOpenMM ObcParameters::getSoluteDielectric() const {
return _soluteDielectric;
}
......@@ -205,7 +205,7 @@ RealOpenMM ObcParameters::getSoluteDielectric( void ) const {
--------------------------------------------------------------------------------------- */
void ObcParameters::setSoluteDielectric( RealOpenMM soluteDielectric ){
void ObcParameters::setSoluteDielectric(RealOpenMM soluteDielectric) {
_soluteDielectric = soluteDielectric;
}
......@@ -217,7 +217,7 @@ void ObcParameters::setSoluteDielectric( RealOpenMM soluteDielectric ){
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getElectricConstant( void ) const {
RealOpenMM ObcParameters::getElectricConstant() const {
return _electricConstant;
}
......@@ -229,7 +229,7 @@ RealOpenMM ObcParameters::getElectricConstant( void ) const {
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getProbeRadius( void ) const {
RealOpenMM ObcParameters::getProbeRadius() const {
return _probeRadius;
}
......@@ -241,7 +241,7 @@ RealOpenMM ObcParameters::getProbeRadius( void ) const {
--------------------------------------------------------------------------------------- */
void ObcParameters::setProbeRadius( RealOpenMM probeRadius ){
void ObcParameters::setProbeRadius(RealOpenMM probeRadius) {
_probeRadius = probeRadius;
}
......@@ -255,7 +255,7 @@ void ObcParameters::setProbeRadius( RealOpenMM probeRadius ){
--------------------------------------------------------------------------------------- */
RealOpenMM ObcParameters::getPi4Asolv( void ) const {
RealOpenMM ObcParameters::getPi4Asolv() const {
return _pi4Asolv;
}
......@@ -271,7 +271,7 @@ void ObcParameters::setPi4Asolv(RealOpenMM pi4Asolv) {
--------------------------------------------------------------------------------------- */
const RealOpenMMVector& ObcParameters::getAtomicRadii( void ) const {
const RealOpenMMVector& ObcParameters::getAtomicRadii() const {
return _atomicRadii;
}
......@@ -283,10 +283,10 @@ const RealOpenMMVector& ObcParameters::getAtomicRadii( void ) const {
--------------------------------------------------------------------------------------- */
void ObcParameters::setAtomicRadii( const RealOpenMMVector& atomicRadii ){
void ObcParameters::setAtomicRadii(const RealOpenMMVector& atomicRadii) {
if( atomicRadii.size() == _atomicRadii.size() ){
for( unsigned int ii = 0; ii < atomicRadii.size(); ii++ ){
if (atomicRadii.size() == _atomicRadii.size()) {
for (unsigned int ii = 0; ii < atomicRadii.size(); ii++) {
_atomicRadii[ii] = atomicRadii[ii];
}
} else {
......@@ -307,7 +307,7 @@ void ObcParameters::setAtomicRadii( const RealOpenMMVector& atomicRadii ){
--------------------------------------------------------------------------------------- */
const RealOpenMMVector& ObcParameters::getScaledRadiusFactors( void ) const {
const RealOpenMMVector& ObcParameters::getScaledRadiusFactors() const {
return _scaledRadiusFactors;
}
......@@ -319,10 +319,10 @@ const RealOpenMMVector& ObcParameters::getScaledRadiusFactors( void ) const {
--------------------------------------------------------------------------------------- */
void ObcParameters::setScaledRadiusFactors( const RealOpenMMVector& scaledRadiusFactors ){
void ObcParameters::setScaledRadiusFactors(const RealOpenMMVector& scaledRadiusFactors) {
if( scaledRadiusFactors.size() == _scaledRadiusFactors.size() ){
for( unsigned int ii = 0; ii < scaledRadiusFactors.size(); ii++ ){
if (scaledRadiusFactors.size() == _scaledRadiusFactors.size()) {
for (unsigned int ii = 0; ii < scaledRadiusFactors.size(); ii++) {
_scaledRadiusFactors[ii] = scaledRadiusFactors[ii];
}
} else {
......@@ -343,7 +343,7 @@ void ObcParameters::setScaledRadiusFactors( const RealOpenMMVector& scaledRadius
--------------------------------------------------------------------------------------- */
void ObcParameters::setUseCutoff( RealOpenMM distance ) {
void ObcParameters::setUseCutoff(RealOpenMM distance) {
_cutoff = true;
_cutoffDistance = distance;
......
......@@ -473,7 +473,7 @@ void testExclusions() {
// create custom GB/VI force
static CustomGBForce* createCustomGBVI( double solventDielectric, double soluteDielectric ) {
static CustomGBForce* createCustomGBVI(double solventDielectric, double soluteDielectric) {
CustomGBForce* customGbviForce = new CustomGBForce();
......@@ -524,7 +524,7 @@ static CustomGBForce* createCustomGBVI( double solventDielectric, double soluteD
// ethance GB/VI test case
static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
static void buildEthane(GBVIForce* gbviForce, std::vector<Vec3>& positions) {
const int numParticles = 8;
......@@ -535,7 +535,7 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
int AM1_BCC = 1;
H_charge = -0.053;
C_charge = -3.0*H_charge;
if( AM1_BCC ){
if (AM1_BCC) {
C_radius = 0.180;
C_gamma = -0.2863;
H_radius = 0.125;
......@@ -548,43 +548,43 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_gamma = 0.1237;
}
for( int i = 0; i < numParticles; i++ ){
gbviForce->addParticle( H_charge, H_radius, H_gamma);
for (int i = 0; i < numParticles; i++) {
gbviForce->addParticle(H_charge, H_radius, H_gamma);
}
gbviForce->setParticleParameters( 1, C_charge, C_radius, C_gamma);
gbviForce->setParticleParameters( 4, C_charge, C_radius, C_gamma);
gbviForce->setParticleParameters(1, C_charge, C_radius, C_gamma);
gbviForce->setParticleParameters(4, C_charge, C_radius, C_gamma);
gbviForce->addBond( 0, 1, C_HBondDistance );
gbviForce->addBond( 2, 1, C_HBondDistance );
gbviForce->addBond( 3, 1, C_HBondDistance );
gbviForce->addBond( 1, 4, C_CBondDistance );
gbviForce->addBond( 5, 4, C_HBondDistance );
gbviForce->addBond( 6, 4, C_HBondDistance );
gbviForce->addBond( 7, 4, C_HBondDistance );
gbviForce->addBond(0, 1, C_HBondDistance);
gbviForce->addBond(2, 1, C_HBondDistance);
gbviForce->addBond(3, 1, C_HBondDistance);
gbviForce->addBond(1, 4, C_CBondDistance);
gbviForce->addBond(5, 4, C_HBondDistance);
gbviForce->addBond(6, 4, C_HBondDistance);
gbviForce->addBond(7, 4, C_HBondDistance);
std::vector<pair<int, int> > bondExceptions;
std::vector<double> bondDistances;
bondExceptions.push_back(pair<int, int>(0, 1));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(2, 1));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(3, 1));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(1, 4));
bondDistances.push_back( C_CBondDistance );
bondDistances.push_back(C_CBondDistance);
bondExceptions.push_back(pair<int, int>(5, 4));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(6, 4));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(7, 4));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
positions.resize(numParticles);
positions[0] = Vec3(0.5480, 1.7661, 0.0000);
......@@ -600,7 +600,7 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
// dimer GB/VI test case
static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
static void buildDimer(GBVIForce* gbviForce, std::vector<Vec3>& positions) {
const int numParticles = 2;
......@@ -614,7 +614,7 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_charge = 0.0;
C_charge = 0.0;
if( AM1_BCC ){
if (AM1_BCC) {
C_radius = 0.180;
C_gamma = -0.2863;
H_radius = 0.125;
......@@ -627,17 +627,17 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_gamma = 0.1237;
}
for( int i = 0; i < numParticles; i++ ){
gbviForce->addParticle( H_charge, H_radius, H_gamma);
for (int i = 0; i < numParticles; i++) {
gbviForce->addParticle(H_charge, H_radius, H_gamma);
}
gbviForce->setParticleParameters( 1, C_charge, C_radius, C_gamma);
gbviForce->setParticleParameters(1, C_charge, C_radius, C_gamma);
gbviForce->addBond( 0, 1, C_HBondDistance );
gbviForce->addBond(0, 1, C_HBondDistance);
std::vector<pair<int, int> > bondExceptions;
std::vector<double> bondDistances;
bondExceptions.push_back(pair<int, int>(0, 1));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
positions.resize(numParticles);
positions[0] = Vec3(0.0, 0.0, 0.0);
......@@ -646,7 +646,7 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
// monomer GB/VI test case
static void buildMonomer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
static void buildMonomer(GBVIForce* gbviForce, std::vector<Vec3>& positions) {
const int numParticles = 1;
......@@ -656,8 +656,8 @@ static void buildMonomer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_radius = 0.125;
H_gamma = 0.2437;
for( int i = 0; i < numParticles; i++ ){
gbviForce->addParticle( H_charge, H_radius, H_gamma);
for (int i = 0; i < numParticles; i++) {
gbviForce->addParticle(H_charge, H_radius, H_gamma);
}
positions.resize(numParticles);
positions[0] = Vec3(0.0, 0.0, 0.0);
......@@ -666,7 +666,7 @@ static void buildMonomer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
// taken from gbviForceImpl class
// computes the scaled radii based on covalent info and atomic radii
static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledRadii) {
static void findScaledRadii(GBVIForce& gbviForce, std::vector<double> & scaledRadii) {
int numberOfParticles = gbviForce.getNumParticles();
int numberOfBonds = gbviForce.getNumBonds();
......@@ -674,15 +674,15 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
// load 1-2 atom pairs along w/ bond distance using HarmonicBondForce & constraints
// numberOfBonds < 1, indicating they were not set by the user
if( numberOfBonds < 1 && numberOfParticles > 1 ){
(void) fprintf( stderr, "Warning: no covalent bonds set for GB/VI force!\n" );
if (numberOfBonds < 1 && numberOfParticles > 1) {
(void) fprintf(stderr, "Warning: no covalent bonds set for GB/VI force!\n");
}
std::vector< std::vector<int> > bondIndices;
bondIndices.resize( numberOfBonds );
bondIndices.resize(numberOfBonds);
std::vector<double> bondLengths;
bondLengths.resize( numberOfBonds );
bondLengths.resize(numberOfBonds);
scaledRadii.resize(numberOfParticles);
for (int i = 0; i < numberOfParticles; i++) {
......@@ -707,14 +707,14 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
msg << particle2;
throw OpenMMException(msg.str());
}
if (bondLength < 0 ) {
if (bondLength < 0) {
std::stringstream msg;
msg << "GBVISoftcoreForce: negative bondlength: ";
msg << bondLength;
throw OpenMMException(msg.str());
}
bondIndices[i].push_back( particle1 );
bondIndices[i].push_back( particle2 );
bondIndices[i].push_back(particle1);
bondIndices[i].push_back(particle2);
bondLengths[i] = bondLength;
}
......@@ -732,7 +732,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
// compute scaled radii (Eq. 5 of Labute paper [JCC 29 p. 1693-1698 2008])
for (int j = 0; j < (int) bonded12.size(); ++j){
for (int j = 0; j < (int) bonded12.size(); ++j) {
double charge;
double gamma;
......@@ -741,9 +741,9 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
gbviForce.getParticleParameters(j, charge, radiusJ, gamma);
if( bonded12[j].size() == 0 ){
if( numberOfParticles > 1 ){
(void) fprintf( stderr, "Warning GBVIForceImpl::findScaledRadii atom %d has no covalent bonds; using atomic radius=%.3f.\n", j, radiusJ );
if ( bonded12[j].size() == 0) {
if (numberOfParticles > 1) {
(void) fprintf(stderr, "Warning GBVIForceImpl::findScaledRadii atom %d has no covalent bonds; using atomic radius=%.3f.\n", j, radiusJ);
}
scaledRadiusJ = radiusJ;
// errors++;
......@@ -755,7 +755,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
// loop over bonded neighbors of atom j, applying Eq. 5 in Labute
scaledRadiusJ = 0.0;
for (int i = 0; i < (int) bonded12[j].size(); ++i){
for (int i = 0; i < (int) bonded12[j].size(); ++i) {
int index = bonded12[j][i];
int bondedAtomIndex = (j == bondIndices[index][0]) ? bondIndices[index][1] : bondIndices[index][0];
......@@ -772,32 +772,32 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
a_ji *= a_ji;
a_ji = (rI2 - a_ji)/(2.0*bondLengths[index]);
scaledRadiusJ += a_ij*a_ij*(3.0*radiusI - a_ij) + a_ji*a_ji*( 3.0*radiusJ - a_ji );
scaledRadiusJ += a_ij*a_ij*(3.0*radiusI - a_ij) + a_ji*a_ji*(3.0*radiusJ - a_ji);
}
scaledRadiusJ = (radiusJ*radiusJ*radiusJ) - 0.125*scaledRadiusJ;
if( scaledRadiusJ > 0.0 ){
scaledRadiusJ = 0.95*pow( scaledRadiusJ, (1.0/3.0) );
if (scaledRadiusJ > 0.0) {
scaledRadiusJ = 0.95*pow(scaledRadiusJ, (1.0/3.0));
}
else {
scaledRadiusJ = 0.0;
}
}
//(void) fprintf( stderr, "scaledRadii %d %12.4f\n", j, scaledRadiusJ );
//(void) fprintf(stderr, "scaledRadii %d %12.4f\n", j, scaledRadiusJ);
scaledRadii[j] = scaledRadiusJ;
}
// abort if errors
if( errors ){
if (errors) {
throw OpenMMException("GBVIForceImpl::findScaledRadii errors -- aborting");
}
#if GBVIDebug
(void) fprintf( stderr, " R q gamma scaled radii no. bnds\n" );
(void) fprintf(stderr, " R q gamma scaled radii no. bnds\n");
double totalQ = 0.0;
for( int i = 0; i < (int) scaledRadii.size(); i++ ){
for (int i = 0; i < (int) scaledRadii.size(); i++) {
double charge;
double gamma;
......@@ -805,10 +805,10 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
gbviForce.getParticleParameters(i, charge, radiusI, gamma);
totalQ += charge;
(void) fprintf( stderr, "%4d %14.5e %14.5e %14.5e %14.5e %d\n", i, radiusI, charge, gamma, scaledRadii[i], (int) bonded12[i].size() );
(void) fprintf(stderr, "%4d %14.5e %14.5e %14.5e %14.5e %d\n", i, radiusI, charge, gamma, scaledRadii[i], (int) bonded12[i].size());
}
(void) fprintf( stderr, "Total charge=%e\n", totalQ );
(void) fflush( stderr );
(void) fprintf(stderr, "Total charge=%e\n", totalQ);
(void) fflush(stderr);
#endif
#undef GBVIDebug
......@@ -819,7 +819,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
// findScaledRadii() is called to calculate the scaled radii (S)
// S is derived quantity in GBVIForce, not a parameter is the case here
static void loadGbviParameters( GBVIForce* gbviForce, CustomGBForce* customGbviForce ) {
static void loadGbviParameters(GBVIForce* gbviForce, CustomGBForce* customGbviForce) {
int numParticles = gbviForce->getNumParticles();
......@@ -827,11 +827,11 @@ static void loadGbviParameters( GBVIForce* gbviForce, CustomGBForce* customGbviF
vector<double> params(4);
std::vector<double> scaledRadii;
findScaledRadii( *gbviForce, scaledRadii);
findScaledRadii(*gbviForce, scaledRadii);
for( int ii = 0; ii < numParticles; ii++) {
for (int ii = 0; ii < numParticles; ii++) {
double charge, radius, gamma;
gbviForce->getParticleParameters( ii, charge, radius, gamma );
gbviForce->getParticleParameters(ii, charge, radius, gamma);
params[0] = charge;
params[1] = radius;
params[2] = scaledRadii[ii];
......@@ -852,14 +852,14 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
// select molecule
if( molecule == "Monomer" ){
buildMonomer( gbvi, positions );
if (molecule == "Monomer") {
buildMonomer(gbvi, positions);
}
else if( molecule == "Dimer" ){
buildDimer( gbvi, positions );
else if (molecule == "Dimer") {
buildDimer(gbvi, positions);
}
else {
buildEthane( gbvi, positions );
buildEthane(gbvi, positions);
}
int numParticles = gbvi->getNumParticles();
......@@ -875,12 +875,12 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
// create customGbviForce GBVI force
CustomGBForce* customGbviForce = createCustomGBVI( gbvi->getSolventDielectric(), gbvi->getSoluteDielectric() );
CustomGBForce* customGbviForce = createCustomGBVI(gbvi->getSolventDielectric(), gbvi->getSoluteDielectric());
customGbviForce->setCutoffDistance(2.0);
// load parameters from gbvi to customGbviForce
loadGbviParameters( gbvi, customGbviForce );
loadGbviParameters(gbvi, customGbviForce);
OpenMM_SFMT::SFMT sfmt;
init_gen_rand(0, sfmt);
......
......@@ -80,20 +80,20 @@ void testSingleParticle() {
double tau = (1.0/forceField->getSoluteDielectric()-1.0/forceField->getSolventDielectric());
double bornEnergy = (-charge*charge/(8*PI_M*eps0))*tau/bornRadius;
double nonpolarEnergy = -gamma*tau*std::pow( radius/bornRadius, 3.0);
double nonpolarEnergy = -gamma*tau*std::pow(radius/bornRadius, 3.0);
double expectedE = (bornEnergy+nonpolarEnergy);
double obtainedE = state.getPotentialEnergy();
double diff = fabs( (obtainedE - expectedE)/expectedE );
if( log ){
(void) fprintf( stderr, "testSingleParticle expected=%14.6e obtained=%14.6e diff=%14.6e breakdown:[%14.6e %14.6e]\n",
expectedE, obtainedE, diff, bornEnergy, nonpolarEnergy );
double diff = fabs((obtainedE - expectedE)/expectedE);
if (log) {
(void) fprintf(stderr, "testSingleParticle expected=%14.6e obtained=%14.6e diff=%14.6e breakdown:[%14.6e %14.6e]\n",
expectedE, obtainedE, diff, bornEnergy, nonpolarEnergy);
}
ASSERT_EQUAL_TOL((bornEnergy+nonpolarEnergy), state.getPotentialEnergy(), 0.01);
}
void testEnergyEthane( int applyBornRadiiScaling ) {
void testEnergyEthane(int applyBornRadiiScaling) {
ReferencePlatform platform;
const int numParticles = 8;
......@@ -123,7 +123,7 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
int AM1_BCC = 1;
H_charge = -0.053;
C_charge = -3.0*H_charge;
if( AM1_BCC ){
if (AM1_BCC) {
C_radius = 0.180;
C_gamma = -0.2863;
H_radius = 0.125;
......@@ -139,59 +139,59 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
NonbondedForce* nonbonded = new NonbondedForce();
nonbonded->setNonbondedMethod(NonbondedForce::NoCutoff);
if( log ){
(void) fprintf( stderr, "Applying GB/VI\n" );
if (log) {
(void) fprintf(stderr, "Applying GB/VI\n");
}
GBVIForce* forceField = new GBVIForce();
if( applyBornRadiiScaling ){
forceField->setBornRadiusScalingMethod( GBVIForce::QuinticSpline );
if (applyBornRadiiScaling) {
forceField->setBornRadiusScalingMethod(GBVIForce::QuinticSpline);
}
else {
forceField->setBornRadiusScalingMethod( GBVIForce::NoScaling );
forceField->setBornRadiusScalingMethod(GBVIForce::NoScaling);
}
for( int i = 0; i < numParticles; i++ ){
for (int i = 0; i < numParticles; i++) {
system.addParticle(1.0);
forceField->addParticle( H_charge, H_radius, H_gamma);
nonbonded->addParticle( H_charge, H_radius, 0.0);
forceField->addParticle(H_charge, H_radius, H_gamma);
nonbonded->addParticle( H_charge, H_radius, 0.0);
}
forceField->setParticleParameters( 1, C_charge, C_radius, C_gamma);
forceField->setParticleParameters( 4, C_charge, C_radius, C_gamma);
forceField->setParticleParameters(1, C_charge, C_radius, C_gamma);
forceField->setParticleParameters(4, C_charge, C_radius, C_gamma);
nonbonded->setParticleParameters( 1, C_charge, C_radius, 0.0);
nonbonded->setParticleParameters( 4, C_charge, C_radius, 0.0);
nonbonded->setParticleParameters( 1, C_charge, C_radius, 0.0);
nonbonded->setParticleParameters( 4, C_charge, C_radius, 0.0);
forceField->addBond( 0, 1, C_HBondDistance );
forceField->addBond( 2, 1, C_HBondDistance );
forceField->addBond( 3, 1, C_HBondDistance );
forceField->addBond( 1, 4, C_CBondDistance );
forceField->addBond( 5, 4, C_HBondDistance );
forceField->addBond( 6, 4, C_HBondDistance );
forceField->addBond( 7, 4, C_HBondDistance );
forceField->addBond(0, 1, C_HBondDistance);
forceField->addBond(2, 1, C_HBondDistance);
forceField->addBond(3, 1, C_HBondDistance);
forceField->addBond(1, 4, C_CBondDistance);
forceField->addBond(5, 4, C_HBondDistance);
forceField->addBond(6, 4, C_HBondDistance);
forceField->addBond(7, 4, C_HBondDistance);
std::vector<pair<int, int> > bondExceptions;
std::vector<double> bondDistances;
bondExceptions.push_back(pair<int, int>(0, 1));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(2, 1));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(3, 1));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(1, 4));
bondDistances.push_back( C_CBondDistance );
bondDistances.push_back(C_CBondDistance);
bondExceptions.push_back(pair<int, int>(5, 4));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(6, 4));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
bondExceptions.push_back(pair<int, int>(7, 4));
bondDistances.push_back( C_HBondDistance );
bondDistances.push_back(C_HBondDistance);
nonbonded->createExceptionsFromBonds(bondExceptions, 0.0, 0.0);
......@@ -212,8 +212,8 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
context.setPositions(positions);
State state = context.getState(State::Forces | State::Energy);
if( log ){
(void) fprintf( stderr, "Energy %.4e\n", state.getPotentialEnergy() );
if (log) {
(void) fprintf(stderr, "Energy %.4e\n", state.getPotentialEnergy());
}
// Take a small step in the direction of the energy gradient.
......@@ -222,8 +222,8 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
double forceSum[3] = { 0.0, 0.0, 0.0 };
for (int i = 0; i < numParticles; ++i) {
Vec3 f = state.getForces()[i];
if( log ){
(void) fprintf( stderr, "F %d [%14.6e %14.6e %14.6e]\n", i, f[0], f[1], f[2] );
if (log) {
(void) fprintf(stderr, "F %d [%14.6e %14.6e %14.6e]\n", i, f[0], f[1], f[2]);
}
norm += f[0]*f[0] + f[1]*f[1] + f[2]*f[2];
forceSum[0] += f[0];
......@@ -231,8 +231,8 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
forceSum[2] += f[2];
}
norm = std::sqrt(norm);
if( log ){
(void) fprintf( stderr, "Fsum [%14.6e %14.6e %14.6e] norm=%14.6e\n", forceSum[0], forceSum[1], forceSum[2], norm );
if (log) {
(void) fprintf(stderr, "Fsum [%14.6e %14.6e %14.6e] norm=%14.6e\n", forceSum[0], forceSum[1], forceSum[2], norm);
}
const double delta = 1e-4;
......@@ -246,10 +246,10 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
State state2 = context.getState(State::Energy);
if( log ){
double deltaE = fabs( state.getPotentialEnergy() - state2.getPotentialEnergy() )/delta;
if (log) {
double deltaE = fabs(state.getPotentialEnergy() - state2.getPotentialEnergy())/delta;
double diff = (deltaE - norm)/norm;
(void) fprintf( stderr, "Energies %.8e %.8e deltaE=%14.7e %14.7e diff=%14.7e\n", state.getPotentialEnergy(), state2.getPotentialEnergy(), deltaE, norm, diff );
(void) fprintf(stderr, "Energies %.8e %.8e deltaE=%14.7e %14.7e diff=%14.7e\n", state.getPotentialEnergy(), state2.getPotentialEnergy(), deltaE, norm, diff);
}
// See whether the potential energy changed by the expected amount.
......@@ -260,8 +260,8 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
int main() {
try {
testSingleParticle();
testEnergyEthane( 0 );
testEnergyEthane( 1 );
testEnergyEthane(0);
testEnergyEthane(1);
}
catch(const exception& e) {
cout << "exception: " << e.what() << endl;
......
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