Commit 6718e0cc authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Code cleanup

parent 1079a319
...@@ -23,15 +23,13 @@ ...@@ -23,15 +23,13 @@
*/ */
#include <string.h> #include <string.h>
#include <math.h>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include "../SimTKUtilities/SimTKOpenMMCommon.h" #include "../SimTKUtilities/SimTKOpenMMCommon.h"
#include "../SimTKUtilities/SimTKOpenMMLog.h"
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "CpuGBVISoftcore.h"
#include "../SimTKReference/ReferenceForce.h" #include "../SimTKReference/ReferenceForce.h"
#include <math.h> #include "CpuGBVISoftcore.h"
using std::vector; using std::vector;
using OpenMM::RealVec; using OpenMM::RealVec;
......
/* Portions copyright (c) 2006-2009 Stanford University and Simbios. /* Portions copyright (c) 2006-2009 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
...@@ -26,15 +25,14 @@ ...@@ -26,15 +25,14 @@
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
//#include "../SimTKUtilities/SimTKOpenMMCommon.h"
#include "../SimTKUtilities/SimTKOpenMMLog.h"
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "CpuObcSoftcore.h"
#include "../SimTKReference/ReferenceForce.h"
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
#include <vector> #include <vector>
#include "../SimTKUtilities/SimTKOpenMMCommon.h"
#include "../SimTKReference/ReferenceForce.h"
#include "CpuObcSoftcore.h"
using std::vector; using std::vector;
using OpenMM::RealVec; using OpenMM::RealVec;
...@@ -46,18 +44,10 @@ using OpenMM::RealVec; ...@@ -46,18 +44,10 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
CpuObcSoftcore::CpuObcSoftcore( ImplicitSolventParameters* obcSoftcoreParameters ) : CpuImplicitSolvent( obcSoftcoreParameters ){ CpuObcSoftcore::CpuObcSoftcore( ObcSoftcoreParameters* obcSoftcoreParameters ){
_obcSoftcoreParameters = obcSoftcoreParameters;
// --------------------------------------------------------------------------------------- _includeAceApproximation = 1;
_obcChain.resize(_obcSoftcoreParameters->getNumberOfAtoms());
// static const char* methodName = "\nCpuObcSoftcore::CpuObcSoftcore";
// ---------------------------------------------------------------------------------------
_initializeObcDataMembers( );
_obcSoftcoreParameters = static_cast<ObcSoftcoreParameters*> (obcSoftcoreParameters);
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -67,29 +57,6 @@ CpuObcSoftcore::CpuObcSoftcore( ImplicitSolventParameters* obcSoftcoreParameters ...@@ -67,29 +57,6 @@ CpuObcSoftcore::CpuObcSoftcore( ImplicitSolventParameters* obcSoftcoreParameters
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
CpuObcSoftcore::~CpuObcSoftcore( ){ CpuObcSoftcore::~CpuObcSoftcore( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::~CpuObcSoftcore";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Initialize data members
--------------------------------------------------------------------------------------- */
void CpuObcSoftcore::_initializeObcDataMembers( void ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::initializeDataMembers";
// ---------------------------------------------------------------------------------------
_obcSoftcoreParameters = NULL;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -101,13 +68,6 @@ void CpuObcSoftcore::_initializeObcDataMembers( void ){ ...@@ -101,13 +68,6 @@ void CpuObcSoftcore::_initializeObcDataMembers( void ){
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
ObcSoftcoreParameters* CpuObcSoftcore::getObcSoftcoreParameters( void ) const { ObcSoftcoreParameters* CpuObcSoftcore::getObcSoftcoreParameters( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::getObcSoftcoreParameters";
// ---------------------------------------------------------------------------------------
return _obcSoftcoreParameters; return _obcSoftcoreParameters;
} }
...@@ -120,13 +80,6 @@ ObcSoftcoreParameters* CpuObcSoftcore::getObcSoftcoreParameters( void ) const { ...@@ -120,13 +80,6 @@ ObcSoftcoreParameters* CpuObcSoftcore::getObcSoftcoreParameters( void ) const {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void CpuObcSoftcore::setObcSoftcoreParameters( ObcSoftcoreParameters* obcSoftcoreParameters ){ void CpuObcSoftcore::setObcSoftcoreParameters( ObcSoftcoreParameters* obcSoftcoreParameters ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::setObcSoftcoreParameters";
// ---------------------------------------------------------------------------------------
_obcSoftcoreParameters = obcSoftcoreParameters; _obcSoftcoreParameters = obcSoftcoreParameters;
} }
...@@ -139,65 +92,37 @@ void CpuObcSoftcore::setObcSoftcoreParameters( ObcSoftcoreParameters* obcSoftco ...@@ -139,65 +92,37 @@ void CpuObcSoftcore::setObcSoftcoreParameters( ObcSoftcoreParameters* obcSoftco
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
vector<RealOpenMM>& CpuObcSoftcore::getObcChain( void ){ RealOpenMMVector& CpuObcSoftcore::getObcChain( void ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::getObcChain";
// ---------------------------------------------------------------------------------------
if( _obcChain.size() == 0 ){
_obcChain.resize(_obcSoftcoreParameters->getNumberOfAtoms());
}
return _obcChain; return _obcChain;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC chain derivative: size = _obcSoftcoreParameters->getNumberOfAtoms() Return flag signalling whether AceApproximation for nonpolar term is to be included
@return array @return flag
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const vector<RealOpenMM>& CpuObcSoftcore::getObcChainConst( void ) const { int CpuObcSoftcore::includeAceApproximation( void ) const {
return _includeAceApproximation;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::getObcChain";
// ---------------------------------------------------------------------------------------
return _obcChain;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC chain temp work array of size=_obcSoftcoreParameters->getNumberOfAtoms() Set flag indicating whether AceApproximation is to be included
On first call, memory for array is allocated if not set
@return array @param includeAceApproximation new includeAceApproximation value
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
vector<RealOpenMM>& CpuObcSoftcore::getObcChainTemp( void ){ void CpuObcSoftcore::setIncludeAceApproximation( int includeAceApproximation ){
_includeAceApproximation = includeAceApproximation;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::getImplicitSolventObcChainTemp";
// ---------------------------------------------------------------------------------------
if( _obcChainTemp.size() == 0 ){
_obcChainTemp.resize(_obcSoftcoreParameters->getNumberOfAtoms());
}
return _obcChainTemp;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get Born radii based on papers: Calculation of Born radii based on papers:
J. Phys. Chem. 1996 100, 19824-19839 (HCT paper) J. Phys. Chem. 1996 100, 19824-19839 (HCT paper)
Proteins: Structure, Function, and Bioinformatcis 55:383-394 (2004) (OBC paper) Proteins: Structure, Function, and Bioinformatcis 55:383-394 (2004) (OBC paper)
...@@ -207,29 +132,28 @@ vector<RealOpenMM>& CpuObcSoftcore::getObcChainTemp( void ){ ...@@ -207,29 +132,28 @@ vector<RealOpenMM>& CpuObcSoftcore::getObcChainTemp( void ){
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, std::vector<RealOpenMM>& bornRadii ){ void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, RealOpenMMVector& bornRadii ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
static const RealOpenMM zero = (RealOpenMM) 0.0; static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = (RealOpenMM) 1.0; static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM two = (RealOpenMM) 2.0; static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM three = (RealOpenMM) 3.0; static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM half = (RealOpenMM) 0.5; static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM fourth = (RealOpenMM) 0.25; static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const char* methodName = "\nCpuObcSoftcore::computeBornRadii";
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
ObcSoftcoreParameters* obcSoftcoreParameters = getObcSoftcoreParameters(); ObcSoftcoreParameters* obcSoftcoreParameters = getObcSoftcoreParameters();
int numberOfAtoms = obcSoftcoreParameters->getNumberOfAtoms(); int numberOfAtoms = obcSoftcoreParameters->getNumberOfAtoms();
RealOpenMM* atomicRadii = obcSoftcoreParameters->getAtomicRadii();
const RealOpenMM* scaledRadiusFactor = obcSoftcoreParameters->getScaledRadiusFactors();
vector<RealOpenMM>& obcChain = getObcChain();
const RealOpenMM* nonPolarScaleFactors = obcSoftcoreParameters->getNonPolarScaleFactors(); const RealOpenMMVector& atomicRadii = obcSoftcoreParameters->getAtomicRadii();
const RealOpenMMVector& scaledRadiusFactor = obcSoftcoreParameters->getScaledRadiusFactors();
RealOpenMMVector& obcChain = getObcChain();
const RealOpenMMVector& nonPolarScaleFactors = obcSoftcoreParameters->getNonPolarScaleFactors();
RealOpenMM dielectricOffset = obcSoftcoreParameters->getDielectricOffset(); RealOpenMM dielectricOffset = obcSoftcoreParameters->getDielectricOffset();
RealOpenMM alphaObc = obcSoftcoreParameters->getAlphaObc(); RealOpenMM alphaObc = obcSoftcoreParameters->getAlphaObc();
RealOpenMM betaObc = obcSoftcoreParameters->getBetaObc(); RealOpenMM betaObc = obcSoftcoreParameters->getBetaObc();
...@@ -239,10 +163,6 @@ void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, std::v ...@@ -239,10 +163,6 @@ void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, std::v
// calculate Born radii // calculate Born radii
//FILE* logFile = SimTKOpenMMLog::getSimTKOpenMMLogFile( );
//FILE* logFile = NULL;
//FILE* logFile = fopen( "bRSoft", "w" );
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){ for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
RealOpenMM radiusI = atomicRadii[atomI]; RealOpenMM radiusI = atomicRadii[atomI];
...@@ -265,6 +185,7 @@ void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, std::v ...@@ -265,6 +185,7 @@ void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, std::v
RealOpenMM r = deltaR[ReferenceForce::RIndex]; RealOpenMM r = deltaR[ReferenceForce::RIndex];
if (_obcSoftcoreParameters->getUseCutoff() && r > _obcSoftcoreParameters->getCutoffDistance()) if (_obcSoftcoreParameters->getUseCutoff() && r > _obcSoftcoreParameters->getCutoffDistance())
continue; continue;
RealOpenMM offsetRadiusJ = atomicRadii[atomJ] - dielectricOffset; RealOpenMM offsetRadiusJ = atomicRadii[atomJ] - dielectricOffset;
RealOpenMM scaledRadiusJ = offsetRadiusJ*scaledRadiusFactor[atomJ]; RealOpenMM scaledRadiusJ = offsetRadiusJ*scaledRadiusFactor[atomJ];
RealOpenMM rScaledRadiusJ = r + scaledRadiusJ; RealOpenMM rScaledRadiusJ = r + scaledRadiusJ;
...@@ -306,27 +227,9 @@ void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, std::v ...@@ -306,27 +227,9 @@ void CpuObcSoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, std::v
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;
#if 0
if( logFile && atomI >= 0 ){
(void) fprintf( logFile, "RRQ %d sum %12.6e tanhS %12.6e radI %.5f %.5f born %18.10e obc %12.6e\n",
atomI, sum, tanhSum, radiusI, offsetRadiusI, bornRadii[atomI], obcChain[atomI] );
}
#endif
}
#if 0
if( logFile ){
(void) fclose( logFile );
logFile = fopen( "bRSoftJ", "w" );
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
(void) fprintf( logFile, "%6d %18.10e %18.10e\n",
atomI, bornRadii[atomI], obcChain[atomI] );
} }
(void) fclose( logFile );
}
#endif
return;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -345,10 +248,6 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo ...@@ -345,10 +248,6 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo
const vector<RealOpenMM>& bornRadii, RealOpenMM* energy, const vector<RealOpenMM>& bornRadii, RealOpenMM* energy,
vector<RealOpenMM>& forces ) const { vector<RealOpenMM>& forces ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuImplicitSolvent::computeAceNonPolarForce";
static const RealOpenMM minusSix = -6.0; static const RealOpenMM minusSix = -6.0;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -358,11 +257,10 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo ...@@ -358,11 +257,10 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo
const RealOpenMM probeRadius = obcSoftcoreParameters->getProbeRadius(); const RealOpenMM probeRadius = obcSoftcoreParameters->getProbeRadius();
const RealOpenMM surfaceAreaFactor = obcSoftcoreParameters->getPi4Asolv(); const RealOpenMM surfaceAreaFactor = obcSoftcoreParameters->getPi4Asolv();
const RealOpenMM* atomicRadii = obcSoftcoreParameters->getAtomicRadii(); const RealOpenMMVector& atomicRadii = obcSoftcoreParameters->getAtomicRadii();
const RealOpenMM* nonPolarScaleFactors = obcSoftcoreParameters->getNonPolarScaleFactors(); const RealOpenMMVector& nonPolarScaleFactors = obcSoftcoreParameters->getNonPolarScaleFactors();
int numberOfAtoms = obcSoftcoreParameters->getNumberOfAtoms();
// 1 + 1 + pow + 3 + 1 + 2 FLOP int numberOfAtoms = obcSoftcoreParameters->getNumberOfAtoms();
// the original ACE equation is based on Eq.2 of // the original ACE equation is based on Eq.2 of
...@@ -374,14 +272,14 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo ...@@ -374,14 +272,14 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo
// The original equation includes the factor (atomicRadii[atomI]/bornRadii[atomI]) to the first power, // The original equation includes the factor (atomicRadii[atomI]/bornRadii[atomI]) to the first power,
// whereas here the ratio is raised to the sixth power: (atomicRadii[atomI]/bornRadii[atomI])**6 // whereas here the ratio is raised to the sixth power: (atomicRadii[atomI]/bornRadii[atomI])**6
// This modification was made by Jay Ponder who observed it gave better correlations w/ // This modification was made by Jay Ponder and is based on observations that the change yields better correlations w/
// observed values. He did not think it was important enough to write up, so there is // expected values. Jay 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] > 0.0 ){ if( bornRadii[atomI] > 0.0 ){
RealOpenMM r = atomicRadii[atomI] + probeRadius; RealOpenMM r = atomicRadii[atomI] + probeRadius;
RealOpenMM ratio6 = POW( atomicRadii[atomI]/bornRadii[atomI], (RealOpenMM) 6.0 ); RealOpenMM ratio6 = POW( atomicRadii[atomI]/bornRadii[atomI], static_cast<RealOpenMM>( 6.0 ) );
RealOpenMM saTerm = nonPolarScaleFactors[atomI]*surfaceAreaFactor*r*r*ratio6; RealOpenMM saTerm = nonPolarScaleFactors[atomI]*surfaceAreaFactor*r*r*ratio6;
*energy += saTerm; *energy += saTerm;
forces[atomI] += minusSix*saTerm/bornRadii[atomI]; forces[atomI] += minusSix*saTerm/bornRadii[atomI];
...@@ -393,8 +291,6 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo ...@@ -393,8 +291,6 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo
Get Obc Born energy and forces Get Obc Born energy and forces
@param bornRadii Born radii -- optional; if NULL, then ObcSoftcoreParameters
entry is used
@param atomCoordinates atomic coordinates @param atomCoordinates atomic coordinates
@param partialCharges partial charges @param partialCharges partial charges
@param forces forces @param forces forces
...@@ -403,21 +299,20 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo ...@@ -403,21 +299,20 @@ void CpuObcSoftcore::computeAceNonPolarForce( const ObcSoftcoreParameters* obcSo
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vector<RealVec>& atomCoordinates, RealOpenMM CpuObcSoftcore::computeBornEnergyForces( vector<RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, vector<RealVec>& inputForces ){ const RealOpenMMVector& partialCharges,
vector<RealVec>& inputForces ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObcSoftcore::computeBornEnergyForces"; static const RealOpenMM zero = static_cast<RealOpenMM>( 0.0 );
static const RealOpenMM one = static_cast<RealOpenMM>( 1.0 );
static const RealOpenMM zero = (RealOpenMM) 0.0; static const RealOpenMM two = static_cast<RealOpenMM>( 2.0 );
static const RealOpenMM one = (RealOpenMM) 1.0; static const RealOpenMM three = static_cast<RealOpenMM>( 3.0 );
static const RealOpenMM two = (RealOpenMM) 2.0; static const RealOpenMM four = static_cast<RealOpenMM>( 4.0 );
static const RealOpenMM three = (RealOpenMM) 3.0; static const RealOpenMM half = static_cast<RealOpenMM>( 0.5 );
static const RealOpenMM four = (RealOpenMM) 4.0; static const RealOpenMM fourth = static_cast<RealOpenMM>( 0.25 );
static const RealOpenMM half = (RealOpenMM) 0.5; static const RealOpenMM eighth = static_cast<RealOpenMM>( 0.125 );
static const RealOpenMM fourth = (RealOpenMM) 0.25;
static const RealOpenMM eighth = (RealOpenMM) 0.125;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -428,43 +323,25 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec ...@@ -428,43 +323,25 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec
// constants // constants
const RealOpenMM preFactor = obcSoftcoreParameters->getPreFactor(); const RealOpenMM preFactor = two*obcSoftcoreParameters->getElectricConstant()*(
(one/obcSoftcoreParameters->getSoluteDielectric()) -
(one/obcSoftcoreParameters->getSolventDielectric()) );
const RealOpenMM dielectricOffset = obcSoftcoreParameters->getDielectricOffset(); const RealOpenMM dielectricOffset = obcSoftcoreParameters->getDielectricOffset();
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
#if 0 // compute Born radii
{
RealOpenMM* atomicRadii = obcSoftcoreParameters->getAtomicRadii();
const RealOpenMM* scaledRadiusFactor = obcSoftcoreParameters->getScaledRadiusFactors();
RealOpenMM* obcChain = getObcChain();
FILE* logFile = fopen( "bornParameters", "w" );
(void) fprintf( logFile, "%5d dielOff=%.4e rad::hct::q::bR::Chain::coords\n", numberOfAtoms, dielectricOffset );
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
(void) fprintf( logFile, "%5d %10.5f %10.5f %10.5f %14.7e %14.7e %14.7e %14.7e %14.7e\n", atomI,
atomicRadii[atomI], scaledRadiusFactor[atomI], partialCharges[atomI], bornRadii[atomI], obcChain[atomI],
atomCoordinates[atomI][0], atomCoordinates[atomI][1], atomCoordinates[atomI][2] );
}
(void) fclose( logFile );
}
#endif
// set energy/forces to zero RealOpenMMVector bornRadii( numberOfAtoms );
computeBornRadii( atomCoordinates, bornRadii );
RealOpenMM obcEnergy = zero; RealOpenMM obcEnergy = zero;
RealOpenMMVector bornForces( numberOfAtoms );
RealOpenMM** forces = (RealOpenMM**) malloc( sizeof( RealOpenMM* )*numberOfAtoms );
RealOpenMM* block = (RealOpenMM*) malloc( sizeof( RealOpenMM )*numberOfAtoms*3 );
memset( block, 0, sizeof( RealOpenMM )*numberOfAtoms*3 );
RealOpenMM* blockPtr = block;
for( int ii = 0; ii < numberOfAtoms; ii++ ){ for( int ii = 0; ii < numberOfAtoms; ii++ ){
forces[ii] = blockPtr; bornForces[ii] = zero;
blockPtr += 3;
} }
vector<RealOpenMM>& bornForces = getBornForce();
bornForces.assign(numberOfAtoms, 0.0);
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// N*( 8 + pow) ACE // N*( 8 + pow) ACE
...@@ -474,7 +351,7 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec ...@@ -474,7 +351,7 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec
computeAceNonPolarForce( obcSoftcoreParameters, bornRadii, &obcEnergy, bornForces ); computeAceNonPolarForce( obcSoftcoreParameters, bornRadii, &obcEnergy, bornForces );
} }
const RealOpenMM* nonPolarScaleFactors = obcSoftcoreParameters->getNonPolarScaleFactors(); const RealOpenMMVector& nonPolarScaleFactors = obcSoftcoreParameters->getNonPolarScaleFactors();
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -506,10 +383,7 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec ...@@ -506,10 +383,7 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec
// charges are assumed to be scaled on input so nonPolarScaleFactor is not needed // charges are assumed to be scaled on input so nonPolarScaleFactor is not needed
//RealOpenMM nonPolarScaleFactor = atomI != atomJ ? nonPolarScaleFactors[atomI]*nonPolarScaleFactors[atomJ] : nonPolarScaleFactors[atomI];
RealOpenMM Gpol = (partialChargeI*partialCharges[atomJ])/denominator; RealOpenMM Gpol = (partialChargeI*partialCharges[atomJ])/denominator;
// Gpol *= nonPolarScaleFactor;
RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*( one + D_ij )/denominator2; RealOpenMM dGpol_dalpha2_ij = -half*Gpol*expTerm*( one + D_ij )/denominator2;
...@@ -523,20 +397,18 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec ...@@ -523,20 +397,18 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec
deltaY *= dGpol_dr; deltaY *= dGpol_dr;
deltaZ *= dGpol_dr; deltaZ *= dGpol_dr;
forces[atomI][0] += deltaX; inputForces[atomI][0] += deltaX;
forces[atomI][1] += deltaY; inputForces[atomI][1] += deltaY;
forces[atomI][2] += deltaZ; inputForces[atomI][2] += deltaZ;
forces[atomJ][0] -= deltaX; inputForces[atomJ][0] -= deltaX;
forces[atomJ][1] -= deltaY; inputForces[atomJ][1] -= deltaY;
forces[atomJ][2] -= deltaZ; inputForces[atomJ][2] -= deltaZ;
} else { } else {
Gpol *= half; Gpol *= half;
} }
// 3 FLOP
obcEnergy += Gpol; obcEnergy += Gpol;
bornForces[atomI] += dGpol_dalpha2_ij*bornRadii[atomJ]; bornForces[atomI] += dGpol_dalpha2_ij*bornRadii[atomJ];
...@@ -547,22 +419,13 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec ...@@ -547,22 +419,13 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec
// second main loop // second main loop
// initialize Born radii & ObcChain temp arrays -- contain values RealOpenMMVector& obcChain = getObcChain();
// used in next iteration const RealOpenMMVector& atomicRadii = obcSoftcoreParameters->getAtomicRadii();
vector<RealOpenMM>& bornRadiiTemp = getBornRadiiTemp();
bornRadiiTemp.assign(numberOfAtoms, 0.0);
vector<RealOpenMM>& obcChainTemp = getObcChainTemp();
obcChainTemp.assign(numberOfAtoms, 0.0);
vector<RealOpenMM>& obcChain = getObcChain();
const RealOpenMM* atomicRadii = obcSoftcoreParameters->getAtomicRadii();
const RealOpenMM alphaObc = obcSoftcoreParameters->getAlphaObc(); const RealOpenMM alphaObc = obcSoftcoreParameters->getAlphaObc();
const RealOpenMM betaObc = obcSoftcoreParameters->getBetaObc(); const RealOpenMM betaObc = obcSoftcoreParameters->getBetaObc();
const RealOpenMM gammaObc = obcSoftcoreParameters->getGammaObc(); const RealOpenMM gammaObc = obcSoftcoreParameters->getGammaObc();
const RealOpenMM* scaledRadiusFactor = obcSoftcoreParameters->getScaledRadiusFactors(); const RealOpenMMVector& scaledRadiusFactor = obcSoftcoreParameters->getScaledRadiusFactors();
// compute factor that depends only on the outer loop index // compute factor that depends only on the outer loop index
...@@ -577,10 +440,6 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec ...@@ -577,10 +440,6 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec
RealOpenMM radiusI = atomicRadii[atomI]; RealOpenMM radiusI = atomicRadii[atomI];
RealOpenMM offsetRadiusI = radiusI - dielectricOffset; RealOpenMM offsetRadiusI = radiusI - dielectricOffset;
// used to compute Born radius for next iteration
RealOpenMM bornSum = zero;
for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){ for( int atomJ = 0; atomJ < numberOfAtoms; atomJ++ ){
if( atomJ != atomI ){ if( atomJ != atomI ){
...@@ -632,75 +491,19 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec ...@@ -632,75 +491,19 @@ void CpuObcSoftcore::computeBornEnergyForces( vector<RealOpenMM>& bornRadii, vec
deltaY *= de; deltaY *= de;
deltaZ *= de; deltaZ *= de;
forces[atomI][0] -= deltaX; inputForces[atomI][0] -= deltaX;
forces[atomI][1] -= deltaY; inputForces[atomI][1] -= deltaY;
forces[atomI][2] -= deltaZ; inputForces[atomI][2] -= deltaZ;
forces[atomJ][0] += deltaX;
forces[atomJ][1] += deltaY;
forces[atomJ][2] += deltaZ;
// Born radius term inputForces[atomJ][0] += deltaX;
inputForces[atomJ][1] += deltaY;
inputForces[atomJ][2] += deltaZ;
RealOpenMM term = l_ij - u_ij + fourth*r*(u_ij2 - l_ij2) + (half*rInverse)*LN(u_ij/l_ij) +
(fourth*scaledRadiusJ*scaledRadiusJ*rInverse)*(l_ij2-u_ij2);
if( offsetRadiusI < (scaledRadiusJ - r) ){
term += two*( (one/offsetRadiusI) - l_ij);
} }
bornSum += term;
} }
} }
} }
// OBC-specific code (Eqs. 6-8 in paper) return obcEnergy;;
bornSum *= half*offsetRadiusI;
RealOpenMM sum2 = bornSum*bornSum;
RealOpenMM sum3 = bornSum*sum2;
RealOpenMM tanhSum = TANH( alphaObc*bornSum - betaObc*sum2 + gammaObc*sum3 );
bornRadiiTemp[atomI] = one/( one/offsetRadiusI - tanhSum/radiusI );
obcChainTemp[atomI] = offsetRadiusI*( alphaObc - two*betaObc*bornSum + three*gammaObc*sum2 );
obcChainTemp[atomI] = (one - tanhSum*tanhSum)*obcChainTemp[atomI]/radiusI;
}
// cal to Joule conversion
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
inputForces[atomI][0] += forces[atomI][0];
inputForces[atomI][1] += forces[atomI][1];
inputForces[atomI][2] += forces[atomI][2];
}
setEnergy( obcEnergy );
#if 0
{
RealOpenMM* atomicRadii = obcSoftcoreParameters->getAtomicRadii();
const RealOpenMM* scaledRadiusFactor = obcSoftcoreParameters->getScaledRadiusFactors();
RealOpenMM* obcChain = getObcChain();
//FILE* logFile = fopen( "bornParameters", "w" );
FILE* logFile = stderr;
(void) fprintf( logFile, "%5d dielOff=%.4e rad::hct::q::bR::Chain::bF::f::coords\n", numberOfAtoms, dielectricOffset );
for( int atomI = 0; atomI < numberOfAtoms; atomI++ ){
(void) fprintf( logFile, "%5d %10.5f %10.5f q=%10.5f b[%14.7e %14.7e %14.7e] f[%14.7e %14.7e %14.7e] x[%14.7e %14.7e %14.7e]\n", atomI,
atomicRadii[atomI], scaledRadiusFactor[atomI], partialCharges[atomI], bornRadii[atomI], obcChain[atomI],
conversion*bornForces[atomI],
conversion*forces[atomI][0], conversion*forces[atomI][1], conversion*forces[atomI][2],
atomCoordinates[atomI][0], atomCoordinates[atomI][1], atomCoordinates[atomI][2] );
}
if( logFile != stderr || logFile != stdout ){
(void) fclose( logFile );
}
}
#endif
// copy new Born radii and obcChain values into permanent array
bornRadii = bornRadiiTemp;
obcChain = obcChainTemp;
free( (char*) block );
free( (char*) forces );
} }
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
class CpuObcSoftcore : public CpuImplicitSolvent { class CpuObcSoftcore {
private: private:
...@@ -40,13 +40,12 @@ class CpuObcSoftcore : public CpuImplicitSolvent { ...@@ -40,13 +40,12 @@ class CpuObcSoftcore : public CpuImplicitSolvent {
// arrays containing OBC chain derivative // arrays containing OBC chain derivative
std::vector<RealOpenMM> _obcChain; RealOpenMMVector _obcChain;
std::vector<RealOpenMM> _obcChainTemp;
// initialize data members (more than // flag to signal whether ACE approximation
// one constructor, so centralize intialization here) // is to be included
void _initializeObcDataMembers( void ); int _includeAceApproximation;
public: public:
...@@ -60,7 +59,7 @@ class CpuObcSoftcore : public CpuImplicitSolvent { ...@@ -60,7 +59,7 @@ class CpuObcSoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
CpuObcSoftcore( ImplicitSolventParameters* obcSoftcoreParameters ); CpuObcSoftcore( ObcSoftcoreParameters* obcSoftcoreParameters );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -92,26 +91,45 @@ class CpuObcSoftcore : public CpuImplicitSolvent { ...@@ -92,26 +91,45 @@ class CpuObcSoftcore : public CpuImplicitSolvent {
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC chain derivative: size = _implicitSolventParameters->getNumberOfAtoms() Return flag signalling whether AceApproximation for nonpolar term is to be included
On first call, memory for array is allocated if not set
@return array @return flag
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getObcChain( void ); int includeAceApproximation( void ) const;
const std::vector<RealOpenMM>& getObcChainConst( void ) const;
/**---------------------------------------------------------------------------------------
Set flag indicating whether AceApproximation is to be included
@param includeAceApproximation new includeAceApproximation value
--------------------------------------------------------------------------------------- */
void setIncludeAceApproximation( int includeAceApproximation );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC chain temp work array of size=_implicitSolventParameters->getNumberOfAtoms() Get energy
@return energy
--------------------------------------------------------------------------------------- */
RealOpenMM getEnergy( void ) const;
/**---------------------------------------------------------------------------------------
Return OBC chain derivative: size = _implicitSolventParameters->getNumberOfAtoms()
On first call, memory for array is allocated if not set On first call, memory for array is allocated if not set
@return array @return array
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getObcChainTemp( void ); RealOpenMMVector& getObcChain( void );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -124,7 +142,7 @@ class CpuObcSoftcore : public CpuImplicitSolvent { ...@@ -124,7 +142,7 @@ class CpuObcSoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void computeBornRadii( std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<RealOpenMM>& bornRadii ); void computeBornRadii( std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMMVector& bornRadii );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -139,22 +157,23 @@ class CpuObcSoftcore : public CpuImplicitSolvent { ...@@ -139,22 +157,23 @@ class CpuObcSoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void computeAceNonPolarForce( const ObcSoftcoreParameters* obcSoftcoreParameters, void computeAceNonPolarForce( const ObcSoftcoreParameters* obcSoftcoreParameters,
const std::vector<RealOpenMM>& bornRadii, RealOpenMM* energy, const RealOpenMMVector& bornRadii, RealOpenMM* energy,
std::vector<RealOpenMM>& forces ) const; RealOpenMMVector& forces ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get Born energy and forces based on OBC Get Born energy and forces based on OBC
@param bornRadii Born radii
@param atomCoordinates atomic coordinates @param atomCoordinates atomic coordinates
@param partialCharges partial charges @param partialCharges partial charges
@param forces forces @param forces forces
@return energy
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void computeBornEnergyForces( std::vector<RealOpenMM>& bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMM computeBornEnergyForces( std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& forces ); const RealOpenMMVector& partialCharges, std::vector<OpenMM::RealVec>& forces );
}; };
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
...@@ -26,100 +26,29 @@ ...@@ -26,100 +26,29 @@
#include <string.h> #include <string.h>
#include <sstream> #include <sstream>
#include "openmm/OpenMMException.h"
#include "ObcSoftcoreParameters.h" #include "ObcSoftcoreParameters.h"
#include "../SimTKUtilities/SimTKOpenMMCommon.h" #include "../SimTKUtilities/SimTKOpenMMCommon.h"
#include "../SimTKUtilities/SimTKOpenMMLog.h"
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
// #define UseGromacsMalloc 1
#ifdef UseGromacsMalloc
extern "C" {
#include "smalloc.h"
}
#endif
const std::string ObcSoftcoreParameters::ParameterFileName = std::string( "params.agb" );
/**---------------------------------------------------------------------------------------
ObcSoftcoreParameters:
Calculates for each atom
(1) the van der Waal radii
(2) volume
(3) fixed terms in Obc equation gPol
(4) list of atoms that should be excluded in calculating
force -- nonbonded atoms (1-2, and 1-3 atoms)
Implementation:
Slightly different sequence of calls when running on CPU vs GPU.
Difference arise because the CPU-side data arrays for the Brook
streams are allocated by the BrookStreamWrapper objects. These
arrays are then used by ObcSoftcoreParameters when initializing the
the values (vdwRadii, volume, ...) to be used in the calculation.
Cpu:
ObcSoftcoreParameters* obcParameters = new ObcSoftcoreParameters( numberOfAtoms, log );
obcParameters->initializeParameters( top );
Gpu:
obcParameters = new ObcSoftcoreParameters( gpu->natoms, log );
// set arrays for cpu using stream data field;
// initializeParameters() only allocates space for arrays if they are not set (==NULL)
// also set flag so that ObcSoftcoreParameters destructor does not free arrays
obcParameters->setVdwRadii( getBrookStreamWrapperAtIndex( GpuObc::obcVdwRadii )->getData() );
obcParameters->setVolume( getBrookStreamWrapperAtIndex( GpuObc::obcVolume )->getData() );
obcParameters->setGPolFixed( getBrookStreamWrapperAtIndex( GpuObc::obcGpolFixed )->getData() );
obcParameters->setBornRadii( getBrookStreamWrapperAtIndex( GpuObc::obcBornRadii )->getData() );
obcParameters->setFreeArrays( false );
obcParameters->initializeParameters( top );
Issues:
Tinker's atom radii are used.
The logic for mapping the Gromacs atom names to Tinker type may be incomplete;
only tested for generic proteins
see mapGmxAtomNameToTinkerAtomNumber()
--------------------------------------------------------------------------------------- */
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
ObcSoftcoreParameters constructor (Simbios) ObcSoftcoreParameters constructor
@param numberOfAtoms number of atoms @param numberOfAtoms number of atoms
@param obcType OBC type (Eq. 7 or 8 in paper) @param obcType OBC type (Eq. 7 or 8 in paper)
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
ObcSoftcoreParameters::ObcSoftcoreParameters( int numberOfAtoms, ObcSoftcoreParameters::ObcType obcType ) : ImplicitSolventParameters( numberOfAtoms ), cutoff(false), periodic(false) { ObcSoftcoreParameters::ObcSoftcoreParameters( int numberOfAtoms, ObcSoftcoreParameters::ObcType obcType ) :
_numberOfAtoms(numberOfAtoms),
// --------------------------------------------------------------------------------------- _obcType(obcType), _dielectricOffset(0.009), _nonPolarPreFactor(2.25936),
_soluteDielectric(1.0), _solventDielectric(78.3), _probeRadius(0.14),
_electricConstant(-0.5*ONE_4PI_EPS0), _pi4Asolv( 28.3919551),
_cutoff(false), _periodic(false) {
// static const char* methodName = "\nObcSoftcoreParameters::ObcSoftcoreParameters"; _atomicRadii.resize( numberOfAtoms );
_scaledRadiusFactors.resize( numberOfAtoms );
// --------------------------------------------------------------------------------------- _nonPolarScaleFactors.resize( numberOfAtoms );
_obcType = obcType;
_dielectricOffset = 0.009f;
_ownScaledRadiusFactors = 0;
_scaledRadiusFactors = NULL;
_ownNonPolarScaleFactors = 0;
_nonPolarScaleFactors = NULL;
_nonPolarPreFactor = (RealOpenMM) 2.25936;
setObcTypeParameters( obcType ); setObcTypeParameters( obcType );
...@@ -127,49 +56,23 @@ ObcSoftcoreParameters::ObcSoftcoreParameters( int numberOfAtoms, ObcSoftcorePara ...@@ -127,49 +56,23 @@ ObcSoftcoreParameters::ObcSoftcoreParameters( int numberOfAtoms, ObcSoftcorePara
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
ObcSoftcoreParameters destructor (Simbios) ObcSoftcoreParameters destructor
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
ObcSoftcoreParameters::~ObcSoftcoreParameters( ){ ObcSoftcoreParameters::~ObcSoftcoreParameters( ){
}
// --------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::~ObcSoftcoreParameters";
// ---------------------------------------------------------------------------------------
// in GPU runs, arrays may be 'owned' by BrookStreamWrapper -- hence they should not
// be freed here, i.e., _freeArrays should be 'false'
#ifdef UseGromacsMalloc
/*
if( _freeArrays ){
if( _vdwRadii != NULL ){
save_free( "_vdwRadii", __FILE__, __LINE__, _vdwRadii );
}
} */
#else
if( _ownScaledRadiusFactors ){
delete[] _scaledRadiusFactors;
}
if( _ownNonPolarScaleFactors ){
delete[] _nonPolarScaleFactors;
}
/* Get number of atoms
if( getFreeArrays() ){
} */ @return number of atoms
#endif --------------------------------------------------------------------------------------- */
int ObcSoftcoreParameters::getNumberOfAtoms( void ) const {
return _numberOfAtoms;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -181,13 +84,6 @@ ObcSoftcoreParameters::~ObcSoftcoreParameters( ){ ...@@ -181,13 +84,6 @@ ObcSoftcoreParameters::~ObcSoftcoreParameters( ){
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
ObcSoftcoreParameters::ObcType ObcSoftcoreParameters::getObcType( void ) const { ObcSoftcoreParameters::ObcType ObcSoftcoreParameters::getObcType( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::getObcType:";
// ---------------------------------------------------------------------------------------
return _obcType; return _obcType;
} }
...@@ -201,12 +97,6 @@ ObcSoftcoreParameters::ObcType ObcSoftcoreParameters::getObcType( void ) const { ...@@ -201,12 +97,6 @@ ObcSoftcoreParameters::ObcType ObcSoftcoreParameters::getObcType( void ) const {
void ObcSoftcoreParameters::setObcTypeParameters( ObcSoftcoreParameters::ObcType obcType ){ void ObcSoftcoreParameters::setObcTypeParameters( ObcSoftcoreParameters::ObcType obcType ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::setObcTypeParameters:";
// ---------------------------------------------------------------------------------------
if( obcType == ObcTypeI ){ if( obcType == ObcTypeI ){
_alphaObc = 0.8f; _alphaObc = 0.8f;
_betaObc = 0.0f; _betaObc = 0.0f;
...@@ -228,13 +118,6 @@ void ObcSoftcoreParameters::setObcTypeParameters( ObcSoftcoreParameters::ObcType ...@@ -228,13 +118,6 @@ void ObcSoftcoreParameters::setObcTypeParameters( ObcSoftcoreParameters::ObcType
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM ObcSoftcoreParameters::getDielectricOffset( void ) const { RealOpenMM ObcSoftcoreParameters::getDielectricOffset( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::getDielectricOffset:";
// ---------------------------------------------------------------------------------------
return _dielectricOffset; return _dielectricOffset;
} }
...@@ -247,13 +130,6 @@ RealOpenMM ObcSoftcoreParameters::getDielectricOffset( void ) const { ...@@ -247,13 +130,6 @@ RealOpenMM ObcSoftcoreParameters::getDielectricOffset( void ) const {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM ObcSoftcoreParameters::getAlphaObc( void ) const { RealOpenMM ObcSoftcoreParameters::getAlphaObc( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::getAlphaObc:";
// ---------------------------------------------------------------------------------------
return _alphaObc; return _alphaObc;
} }
...@@ -266,13 +142,6 @@ RealOpenMM ObcSoftcoreParameters::getAlphaObc( void ) const { ...@@ -266,13 +142,6 @@ RealOpenMM ObcSoftcoreParameters::getAlphaObc( void ) const {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM ObcSoftcoreParameters::getBetaObc( void ) const { RealOpenMM ObcSoftcoreParameters::getBetaObc( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::getBetaObc:";
// ---------------------------------------------------------------------------------------
return _betaObc; return _betaObc;
} }
...@@ -285,309 +154,174 @@ RealOpenMM ObcSoftcoreParameters::getBetaObc( void ) const { ...@@ -285,309 +154,174 @@ RealOpenMM ObcSoftcoreParameters::getBetaObc( void ) const {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM ObcSoftcoreParameters::getGammaObc( void ) const { RealOpenMM ObcSoftcoreParameters::getGammaObc( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::getGammaObc:";
// ---------------------------------------------------------------------------------------
return _gammaObc; return _gammaObc;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get AtomicRadii array Get solvent dielectric
@return array of atomic radii @return solvent dielectric
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM* ObcSoftcoreParameters::getAtomicRadii( void ) const { RealOpenMM ObcSoftcoreParameters::getSolventDielectric( void ) const {
return _solventDielectric;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nImplicitSolventParameters::getAtomicRadii:";
// ---------------------------------------------------------------------------------------
RealOpenMM* atomicRadii = ImplicitSolventParameters::getAtomicRadii();
// if dielectric offset applied, then unapply
return atomicRadii;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set AtomicRadii array Set solvent dielectric
@param atomicRadii array of atomic radii @param solventDielectric solvent dielectric
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setAtomicRadii( RealOpenMM* atomicRadii ){ void ObcSoftcoreParameters::setSolventDielectric( RealOpenMM solventDielectric ){
_solventDielectric = solventDielectric;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::setAtomicRadii:";
// ---------------------------------------------------------------------------------------
ImplicitSolventParameters::setAtomicRadii( atomicRadii );
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set AtomicRadii array Get solute dielectric
@param atomicRadii vector of atomic radii @return soluteDielectric
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setAtomicRadii( const RealOpenMMVector& atomicRadii ){ RealOpenMM ObcSoftcoreParameters::getSoluteDielectric( void ) const {
return _soluteDielectric;
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nObcSoftcoreParameters::setAtomicRadii:";
// ---------------------------------------------------------------------------------------
ImplicitSolventParameters::setAtomicRadii( atomicRadii );
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC scale factors Set solute dielectric
If not previously set, allocate space
@return array @param soluteDielectric solute dielectric
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const RealOpenMM* ObcSoftcoreParameters::getScaledRadiusFactors( void ) const { void ObcSoftcoreParameters::setSoluteDielectric( RealOpenMM soluteDielectric ){
_soluteDielectric = soluteDielectric;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::getScaledRadiusFactors";
// ---------------------------------------------------------------------------------------
if( _scaledRadiusFactors == NULL ){
ObcSoftcoreParameters* localThis = const_cast<ObcSoftcoreParameters* const>(this);
localThis->_scaledRadiusFactors = new RealOpenMM[getNumberOfAtoms()];
localThis->_ownScaledRadiusFactors = true;
memset( _scaledRadiusFactors, 0, sizeof( RealOpenMM )*getNumberOfAtoms() );
}
return _scaledRadiusFactors;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set flag indicating whether scale factors array should be deleted Get electric constant
@param ownScaledRadiusFactors flag indicating whether scale factors @return electricConstant
array should be deleted
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setOwnScaleFactors( int ownScaledRadiusFactors ){ RealOpenMM ObcSoftcoreParameters::getElectricConstant( void ) const {
return _electricConstant;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::setOwnScaleFactors";
// ---------------------------------------------------------------------------------------
_ownScaledRadiusFactors = ownScaledRadiusFactors;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set OBC scale factors Get probe radius
@param scaledRadiusFactors scaledRadiusFactors @return probeRadius
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setScaledRadiusFactors( RealOpenMM* scaledRadiusFactors ){ RealOpenMM ObcSoftcoreParameters::getProbeRadius( void ) const {
return _probeRadius;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::setScaledRadiusFactors";
// ---------------------------------------------------------------------------------------
if( _ownScaledRadiusFactors && _scaledRadiusFactors != scaledRadiusFactors ){
delete[] _scaledRadiusFactors;
_ownScaledRadiusFactors = false;
}
_scaledRadiusFactors = scaledRadiusFactors;
} }
#if RealOpenMMType == 0
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set OBC scale factors Set probe radius
@param scaledRadiusFactors scaledRadiusFactors @param probeRadius probe radius
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setScaledRadiusFactors( float* scaledRadiusFactors ){ void ObcSoftcoreParameters::setProbeRadius( RealOpenMM probeRadius ){
_probeRadius = probeRadius;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::setScaledRadiusFactors";
// ---------------------------------------------------------------------------------------
if( _scaledRadiusFactors == NULL ){
_scaledRadiusFactors = new RealOpenMM[getNumberOfAtoms()];
_ownScaledRadiusFactors = true;
}
for( int ii = 0; ii < getNumberOfAtoms(); ii++ ){
_scaledRadiusFactors[ii] = (RealOpenMM) scaledRadiusFactors[ii];
}
} }
#endif
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set OBC scale factors Get pi*4*Asolv: used in ACE approximation for nonpolar term
((RealOpenMM) M_PI)*4.0f*0.0049*1000.0; (Still)
((RealOpenMM) M_PI)*4.0f*0.0054*1000.0; (OBC)
@param scaledRadiusFactors scaledRadiusFactors @return pi4Asolv
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setScaledRadiusFactors( const RealOpenMMVector& scaledRadiusFactors ){ RealOpenMM ObcSoftcoreParameters::getPi4Asolv( void ) const {
return _pi4Asolv;
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::setScaledRadiusFactors";
// ---------------------------------------------------------------------------------------
if( _ownScaledRadiusFactors && _scaledRadiusFactors != NULL ){
delete[] _scaledRadiusFactors;
}
_ownScaledRadiusFactors = true;
_scaledRadiusFactors = new RealOpenMM[getNumberOfAtoms()];
for( int ii = 0; ii < (int) scaledRadiusFactors.size(); ii++ ){
_scaledRadiusFactors[ii] = scaledRadiusFactors[ii];
}
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Map Gmx atom name to Tinker atom number (Simbios) Get AtomicRadii array
@param atomName atom name (CA, HA, ...); upper and lower case should both work
@param log if set, then print error messages to log file
@return Tinker atom number if atom name is valid; else return -1 @return array of atomic radii
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int ObcSoftcoreParameters::mapGmxAtomNameToTinkerAtomNumber( const char* atomName, FILE* log ) const { const RealOpenMMVector& ObcSoftcoreParameters::getAtomicRadii( void ) const {
return _atomicRadii;
// --------------------------------------------------------------------------------------- }
static int mapCreated = 0;
static int atomNameMap[26];
// ---------------------------------------------------------------------------------------
// set up atomNameMap array on first call to this method
// atomNameMap[ii] = Tinker atom number
// where ii = (the ASCII index - 65) of the first character in the
// input atom name; name may be lower case
if( !mapCreated ){
mapCreated = 1;
for( int ii = 0; ii < 26; ii++ ){
atomNameMap[ii] = -1;
}
// H
atomNameMap[7] = 1;
// C
atomNameMap[2] = 6;
// N
atomNameMap[13] = 7;
// O
atomNameMap[14] = 8;
// S
atomNameMap[18] = 16;
}
// map first letter in atom name to Tinker atom number /**---------------------------------------------------------------------------------------
int firstAsciiValue = ((int) atomName[0]) - 65; Set AtomicRadii array
// check for lower case @param atomicRadii vector of atomic radii
if( firstAsciiValue > 25 ){ --------------------------------------------------------------------------------------- */
firstAsciiValue -= 32;
}
// validate void ObcSoftcoreParameters::setAtomicRadii( const RealOpenMMVector& atomicRadii ){
if( firstAsciiValue < 0 || firstAsciiValue > 25 ){ if( atomicRadii.size() == _atomicRadii.size() ){
if( log != NULL ){ for( unsigned int ii = 0; ii < atomicRadii.size(); ii++ ){
(void) fprintf( log, "Atom name=<%s> unrecognized.", atomName ); _atomicRadii[ii] = atomicRadii[ii];
} }
(void) fprintf( stderr, "Atom name=<%s> unrecognized.", atomName ); } else {
return -1; std::stringstream msg;
msg << "ObcSoftcoreParameters: input size for atomic radii does not agree w/ current size: input=";
msg << atomicRadii.size();
msg << " current size=" << _atomicRadii.size();
throw OpenMM::OpenMMException(msg.str());
} }
return atomNameMap[firstAsciiValue];
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get string w/ state Return OBC scale factors
@param title title (optional)
@return string @return array
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
std::string ObcSoftcoreParameters::getStateString( const char* title ) const { const RealOpenMMVector& ObcSoftcoreParameters::getScaledRadiusFactors( void ) const {
return _scaledRadiusFactors;
}
// --------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
// static const char* methodName = "\nObcSoftcoreParameters::getStateString"; Set OBC scale factors
// --------------------------------------------------------------------------------------- @param scaledRadiusFactors scaledRadiusFactors
std::stringstream message; --------------------------------------------------------------------------------------- */
message << ImplicitSolventParameters::getStateString( title );
std::string tab = getStringTab(); void ObcSoftcoreParameters::setScaledRadiusFactors( const RealOpenMMVector& scaledRadiusFactors ){
if( getObcType() == ObcTypeI ){ if( scaledRadiusFactors.size() == _scaledRadiusFactors.size() ){
message << tab << "OBC type: Type I"; for( unsigned int ii = 0; ii < scaledRadiusFactors.size(); ii++ ){
_scaledRadiusFactors[ii] = scaledRadiusFactors[ii];
}
} else { } else {
message << tab << "OBC type: Type II"; std::stringstream msg;
msg << "ObcSoftcoreParameters: input size for scaled radius factors does not agree w/ current size: input=";
msg << scaledRadiusFactors.size();
msg << " current size=" << _scaledRadiusFactors.size();
throw OpenMM::OpenMMException(msg.str());
} }
message << tab << "Alpha: " << getAlphaObc();
message << tab << "Beta: " << getBetaObc();
message << tab << "Gamma: " << getGammaObc();
return message.str();
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -599,9 +333,8 @@ std::string ObcSoftcoreParameters::getStateString( const char* title ) const { ...@@ -599,9 +333,8 @@ std::string ObcSoftcoreParameters::getStateString( const char* title ) const {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setUseCutoff( RealOpenMM distance ) { void ObcSoftcoreParameters::setUseCutoff( RealOpenMM distance ) {
_cutoff = true;
cutoff = true; _cutoffDistance = distance;
cutoffDistance = distance;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -611,7 +344,7 @@ void ObcSoftcoreParameters::setUseCutoff( RealOpenMM distance ) { ...@@ -611,7 +344,7 @@ void ObcSoftcoreParameters::setUseCutoff( RealOpenMM distance ) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
bool ObcSoftcoreParameters::getUseCutoff() { bool ObcSoftcoreParameters::getUseCutoff() {
return cutoff; return _cutoff;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -621,7 +354,7 @@ bool ObcSoftcoreParameters::getUseCutoff() { ...@@ -621,7 +354,7 @@ bool ObcSoftcoreParameters::getUseCutoff() {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM ObcSoftcoreParameters::getCutoffDistance() { RealOpenMM ObcSoftcoreParameters::getCutoffDistance() {
return cutoffDistance; return _cutoffDistance;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -636,14 +369,16 @@ RealOpenMM ObcSoftcoreParameters::getCutoffDistance() { ...@@ -636,14 +369,16 @@ RealOpenMM ObcSoftcoreParameters::getCutoffDistance() {
void ObcSoftcoreParameters::setPeriodic( RealOpenMM* boxSize ) { void ObcSoftcoreParameters::setPeriodic( RealOpenMM* boxSize ) {
assert(cutoff); assert(_cutoff);
assert(boxSize[0] >= 2.0*cutoffDistance);
assert(boxSize[1] >= 2.0*cutoffDistance); assert(boxSize[0] >= 2.0*_cutoffDistance);
assert(boxSize[2] >= 2.0*cutoffDistance); assert(boxSize[1] >= 2.0*_cutoffDistance);
periodic = true; assert(boxSize[2] >= 2.0*_cutoffDistance);
periodicBoxSize[0] = boxSize[0];
periodicBoxSize[1] = boxSize[1]; _periodic = true;
periodicBoxSize[2] = boxSize[2]; _periodicBoxSize[0] = boxSize[0];
_periodicBoxSize[1] = boxSize[1];
_periodicBoxSize[2] = boxSize[2];
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -653,7 +388,7 @@ void ObcSoftcoreParameters::setPeriodic( RealOpenMM* boxSize ) { ...@@ -653,7 +388,7 @@ void ObcSoftcoreParameters::setPeriodic( RealOpenMM* boxSize ) {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
bool ObcSoftcoreParameters::getPeriodic() { bool ObcSoftcoreParameters::getPeriodic() {
return periodic; return _periodic;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -663,55 +398,21 @@ bool ObcSoftcoreParameters::getPeriodic() { ...@@ -663,55 +398,21 @@ bool ObcSoftcoreParameters::getPeriodic() {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const RealOpenMM* ObcSoftcoreParameters::getPeriodicBox() { const RealOpenMM* ObcSoftcoreParameters::getPeriodicBox() {
return periodicBoxSize; return _periodicBoxSize;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return non-polar scale factors Return non-polar scale factors
If not previously set, allocate space
@return array @return array
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const RealOpenMM* ObcSoftcoreParameters::getNonPolarScaleFactors( void ) const { const RealOpenMMVector& ObcSoftcoreParameters::getNonPolarScaleFactors( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "ObcSoftcoreParameters::getNonPolarScaleFactors";
// ---------------------------------------------------------------------------------------
if( _nonPolarScaleFactors == NULL ){
ObcSoftcoreParameters* localThis = const_cast<ObcSoftcoreParameters* const>(this);
localThis->_nonPolarScaleFactors = new RealOpenMM[getNumberOfAtoms()];
localThis->_ownNonPolarScaleFactors = true;
memset( _nonPolarScaleFactors, 0, sizeof( RealOpenMM )*getNumberOfAtoms() );
}
return _nonPolarScaleFactors; return _nonPolarScaleFactors;
} }
/**---------------------------------------------------------------------------------------
Set flag indicating whether scale factors array should be deleted
@param ownNonPolarScaleFactors flag indicating whether scale factors
array should be deleted
--------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setOwnNonPolarScaleFactors( int ownNonPolarScaleFactors ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::setOwnScaleFactors";
// ---------------------------------------------------------------------------------------
_ownNonPolarScaleFactors = ownNonPolarScaleFactors;
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set non-polar scale factors Set non-polar scale factors
...@@ -722,52 +423,19 @@ void ObcSoftcoreParameters::setOwnNonPolarScaleFactors( int ownNonPolarScaleFact ...@@ -722,52 +423,19 @@ void ObcSoftcoreParameters::setOwnNonPolarScaleFactors( int ownNonPolarScaleFact
void ObcSoftcoreParameters::setNonPolarScaleFactors( const RealOpenMMVector& nonPolarScaleFactors ){ void ObcSoftcoreParameters::setNonPolarScaleFactors( const RealOpenMMVector& nonPolarScaleFactors ){
// --------------------------------------------------------------------------------------- if( nonPolarScaleFactors.size() == _nonPolarScaleFactors.size() ){
for( unsigned int ii = 0; ii < nonPolarScaleFactors.size(); ii++ ){
// static const char* methodName = "\nCpuObc::setNonPolarScaleFactors";
// ---------------------------------------------------------------------------------------
if( _ownNonPolarScaleFactors ){
delete[] _nonPolarScaleFactors;
}
_ownNonPolarScaleFactors = true;
_nonPolarScaleFactors = new RealOpenMM[nonPolarScaleFactors.size()];
for( int ii = 0; ii < getNumberOfAtoms(); ii++ ){
_nonPolarScaleFactors[ii] = nonPolarScaleFactors[ii]; _nonPolarScaleFactors[ii] = nonPolarScaleFactors[ii];
} }
} } else {
std::stringstream msg;
#if RealOpenMMType == 0 msg << "ObcSoftcoreParameters: input size for non-polar scale factors does not agree w/ current size: input=";
msg << nonPolarScaleFactors.size();
/**--------------------------------------------------------------------------------------- msg << " current size=" << _nonPolarScaleFactors.size();
throw OpenMM::OpenMMException(msg.str());
Set non-polar scale factors
@param nonPolarScaleFactors nonPolarScaleFactors
--------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setNonPolarScaleFactors( float* nonPolarScaleFactors ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::setNonPolarScaleFactors";
// ---------------------------------------------------------------------------------------
if( _nonPolarScaleFactors == NULL ){
_nonPolarScaleFactors = new RealOpenMM[getNumberOfAtoms()];
_ownNonPolarScaleFactors = true;
}
for( int ii = 0; ii < getNumberOfAtoms(); ii++ ){
_nonPolarScaleFactors[ii] = (RealOpenMM) nonPolarScaleFactors[ii];
} }
} }
#endif
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set OBC scale factors Set OBC scale factors
...@@ -777,13 +445,6 @@ void ObcSoftcoreParameters::setNonPolarScaleFactors( float* nonPolarScaleFactors ...@@ -777,13 +445,6 @@ void ObcSoftcoreParameters::setNonPolarScaleFactors( float* nonPolarScaleFactors
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void ObcSoftcoreParameters::setNonPolarPrefactor( RealOpenMM nonPolarPreFactor ){ void ObcSoftcoreParameters::setNonPolarPrefactor( RealOpenMM nonPolarPreFactor ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuObc::setNonPolarScaleFactors";
// ---------------------------------------------------------------------------------------
_nonPolarPreFactor = nonPolarPreFactor; _nonPolarPreFactor = nonPolarPreFactor;
} }
/* Portions copyright (c) 2006-2009 Stanford University and Simbios. /* Portions copyright (c) 2006-2009 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
...@@ -26,11 +25,10 @@ ...@@ -26,11 +25,10 @@
#define __ObcSoftcoreParameters_H__ #define __ObcSoftcoreParameters_H__
#include "../SimTKUtilities/SimTKOpenMMCommon.h" #include "../SimTKUtilities/SimTKOpenMMCommon.h"
#include "gbsa/ImplicitSolventParameters.h"
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
class ObcSoftcoreParameters : public ImplicitSolventParameters { class ObcSoftcoreParameters {
public: public:
...@@ -38,37 +36,42 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -38,37 +36,42 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
enum ObcType { ObcTypeI, ObcTypeII }; enum ObcType { ObcTypeI, ObcTypeII };
static const std::string ParameterFileName;
private: private:
int _numberOfAtoms;
// OBC constants & parameters // OBC constants & parameters
RealOpenMM _dielectricOffset; RealOpenMM _dielectricOffset;
RealOpenMM _alphaObc; RealOpenMM _alphaObc;
RealOpenMM _betaObc; RealOpenMM _betaObc;
RealOpenMM _gammaObc; RealOpenMM _gammaObc;
RealOpenMM _probeRadius;
RealOpenMM _pi4Asolv;
ObcType _obcType; ObcType _obcType;
RealOpenMM _nonPolarPreFactor; RealOpenMM _nonPolarPreFactor;
RealOpenMM _solventDielectric;
RealOpenMM _soluteDielectric;
RealOpenMM _electricConstant;
// scaling factors for nonpolar term // scaling factors for nonpolar term
int _ownNonPolarScaleFactors; RealOpenMMVector _atomicRadii;
RealOpenMM* _nonPolarScaleFactors; RealOpenMMVector _nonPolarScaleFactors;
// scaled radius factors (S_kk in HCT paper) // scaled radius factors (S_kk in HCT paper)
int _ownScaledRadiusFactors; RealOpenMMVector _scaledRadiusFactors;
RealOpenMM* _scaledRadiusFactors;
// cutoff and periodic boundary conditions // cutoff and periodic boundary conditions
bool cutoff; bool _cutoff;
bool periodic; bool _periodic;
RealOpenMM periodicBoxSize[3]; RealOpenMM _periodicBoxSize[3];
RealOpenMM cutoffDistance; RealOpenMM _cutoffDistance;
public: public:
...@@ -92,153 +95,194 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -92,153 +95,194 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get OBC type Get number of atoms
@return OBC type @return number of atoms
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
ObcSoftcoreParameters::ObcType getObcType( void ) const; int getNumberOfAtoms( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set OBC type specific parameters Get electric constant
@param obcType OBC type (ObcTypeI or ObcTypeII -- Eq. 7 or 8) @return electric constant
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setObcTypeParameters( ObcSoftcoreParameters::ObcType obcType ); RealOpenMM getElectricConstant( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get alpha OBC (Eqs. 6 & 7) in Proteins paper Get probe radius (Simbios)
@return alphaObc @return probeRadius
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM getAlphaObc( void ) const; RealOpenMM getProbeRadius( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get beta OBC (Eqs. 6 & 7) in Proteins paper Set probe radius (Simbios)
@return betaObc @param probeRadius probe radius
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM getBetaObc( void ) const; void setProbeRadius( RealOpenMM probeRadius );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get gamma OBC (Eqs. 6 & 7) in Proteins paper Get pi4Asolv: used in ACE approximation for nonpolar term
((RealOpenMM) M_PI)*4.0f*0.0049f*1000.0f; (Simbios)
@return gammaObc @return pi4Asolv
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM getGammaObc( void ) const; RealOpenMM getPi4Asolv( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get solvent dielectric (Simbios) Get solvent dielectric
@return dielectricOffset dielectric offset @return solvent dielectric
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM getDielectricOffset( void ) const; RealOpenMM getSolventDielectric( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC scale factors Set solvent dielectric
@return array @param solventDielectric solvent dielectric
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const RealOpenMM* getScaledRadiusFactors( void ) const; void setSolventDielectric( RealOpenMM solventDielectric );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC scale factors Get solute dielectric
@return array @return soluteDielectric
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setScaledRadiusFactors( RealOpenMM* scaledRadiusFactors ); RealOpenMM getSoluteDielectric( void ) const;
#if RealOpenMMType == 0
void setScaledRadiusFactors( float* scaledRadiusFactors );
#endif
void setScaledRadiusFactors( const RealOpenMMVector& scaledRadiusFactors );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set flag indicating whether scale factors arra should be deleted Set solute dielectric
@param ownScaledRadiusFactors flag indicating whether scale factors @param soluteDielectric solute dielectric
array should be deleted
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setOwnScaleFactors( int ownScaledRadiusFactors ); void setSoluteDielectric( RealOpenMM soluteDielectric );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get AtomicRadii array w/ dielectric offset applied Get OBC type
@return array of atom volumes @return OBC type
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM* getAtomicRadii( void ) const; ObcSoftcoreParameters::ObcType getObcType( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set AtomicRadii array Set OBC type specific parameters
@param atomicRadii array of atomic radii @param obcType OBC type (ObcTypeI or ObcTypeII -- Eq. 7 or 8)
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setAtomicRadii( RealOpenMM* atomicRadii ); void setObcTypeParameters( ObcSoftcoreParameters::ObcType obcType );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set AtomicRadii array Get alpha OBC (Eqs. 6 & 7) in Proteins paper
@param atomicRadii vector of atomic radii @return alphaObc
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setAtomicRadii( const RealOpenMMVector& atomicRadii ); RealOpenMM getAlphaObc( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Map Gmx atom name to Tinker atom number (Simbios) Get beta OBC (Eqs. 6 & 7) in Proteins paper
@param atomName atom name (CA, HA, ...); upper and lower case should both work @return betaObc
@param log if set, then print error messages to log file
return Tinker atom number if atom name is valid; else return -1 --------------------------------------------------------------------------------------- */
RealOpenMM getBetaObc( void ) const;
/**---------------------------------------------------------------------------------------
Get gamma OBC (Eqs. 6 & 7) in Proteins paper
@return gammaObc
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int mapGmxAtomNameToTinkerAtomNumber( const char* atomName, FILE* log ) const; RealOpenMM getGammaObc( void ) const;
/**---------------------------------------------------------------------------------------
Get solvent dielectric (Simbios)
@return dielectricOffset dielectric offset
--------------------------------------------------------------------------------------- */
RealOpenMM getDielectricOffset( void ) const;
/**---------------------------------------------------------------------------------------
Return OBC scale factors
@return array
--------------------------------------------------------------------------------------- */
const RealOpenMMVector& getScaledRadiusFactors( void ) const;
/**---------------------------------------------------------------------------------------
Set OBC scale factors
@param input vector of radius factors
--------------------------------------------------------------------------------------- */
void setScaledRadiusFactors( const RealOpenMMVector& scaledRadiusFactors );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get string w/ state Get AtomicRadii array w/ dielectric offset applied
@param title title (optional) @return array of atom volumes
@return string --------------------------------------------------------------------------------------- */
const RealOpenMMVector& getAtomicRadii( void ) const;
/**---------------------------------------------------------------------------------------
Set AtomicRadii array
@param atomicRadii vector of atomic radii
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const; void setAtomicRadii( const RealOpenMMVector& atomicRadii );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -256,7 +300,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -256,7 +300,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
bool getUseCutoff(); bool getUseCutoff( void );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -264,7 +308,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -264,7 +308,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM getCutoffDistance(); RealOpenMM getCutoffDistance( void );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -284,7 +328,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -284,7 +328,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
bool getPeriodic(); bool getPeriodic( void );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -292,29 +336,17 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -292,29 +336,17 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const RealOpenMM* getPeriodicBox(); const RealOpenMM* getPeriodicBox( void );
/**---------------------------------------------------------------------------------------
Set flag indicating whether scale factors array should be deleted
@param ownNonPolarScaleFactors flag indicating whether scale factors
array should be deleted
--------------------------------------------------------------------------------------- */
void setOwnNonPolarScaleFactors( int ownNonPolarScaleFactors );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return non-polar scale factors Return non-polar scale factors
If not previously set, allocate space
@return array @return array
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const RealOpenMM* getNonPolarScaleFactors( void ) const; const RealOpenMMVector& getNonPolarScaleFactors( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -338,19 +370,6 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -338,19 +370,6 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
}; };
/**---------------------------------------------------------------------------------------
Qsort/heapsort integer comparison (Simbios)
@parma a first value to compare
@param b second value to compare
@return -1, 0, 1
--------------------------------------------------------------------------------------- */
int integerComparison( const void *a, const void *b);
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
#endif // __ObcSoftcoreParameters_H__ #endif // __ObcSoftcoreParameters_H__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment