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