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;
......
...@@ -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 );
}; };
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
/* 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