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
--------------------------------------------------------------------------------------- */
int includeAceApproximation( void ) const;
/**---------------------------------------------------------------------------------------
Set flag indicating whether AceApproximation is to be included
@param includeAceApproximation new includeAceApproximation value
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setIncludeAceApproximation( int includeAceApproximation );
/**---------------------------------------------------------------------------------------
Get energy
std::vector<RealOpenMM>& getObcChain( void ); @return energy
const std::vector<RealOpenMM>& getObcChainConst( void ) const;
--------------------------------------------------------------------------------------- */
RealOpenMM getEnergy( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC chain temp work array of size=_implicitSolventParameters->getNumberOfAtoms() 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:
...@@ -90,6 +93,97 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -90,6 +93,97 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
~ObcSoftcoreParameters( ); ~ObcSoftcoreParameters( );
/**---------------------------------------------------------------------------------------
Get number of atoms
@return number of atoms
--------------------------------------------------------------------------------------- */
int getNumberOfAtoms( void ) const;
/**---------------------------------------------------------------------------------------
Get electric constant
@return electric constant
--------------------------------------------------------------------------------------- */
RealOpenMM getElectricConstant( void ) const;
/**---------------------------------------------------------------------------------------
Get probe radius (Simbios)
@return probeRadius
--------------------------------------------------------------------------------------- */
RealOpenMM getProbeRadius( void ) const;
/**---------------------------------------------------------------------------------------
Set probe radius (Simbios)
@param probeRadius probe radius
--------------------------------------------------------------------------------------- */
void setProbeRadius( RealOpenMM probeRadius );
/**---------------------------------------------------------------------------------------
Get pi4Asolv: used in ACE approximation for nonpolar term
((RealOpenMM) M_PI)*4.0f*0.0049f*1000.0f; (Simbios)
@return pi4Asolv
--------------------------------------------------------------------------------------- */
RealOpenMM getPi4Asolv( void ) const;
/**---------------------------------------------------------------------------------------
Get solvent dielectric
@return solvent dielectric
--------------------------------------------------------------------------------------- */
RealOpenMM getSolventDielectric( void ) const;
/**---------------------------------------------------------------------------------------
Set solvent dielectric
@param solventDielectric solvent dielectric
--------------------------------------------------------------------------------------- */
void setSolventDielectric( RealOpenMM solventDielectric );
/**---------------------------------------------------------------------------------------
Get solute dielectric
@return soluteDielectric
--------------------------------------------------------------------------------------- */
RealOpenMM getSoluteDielectric( void ) const;
/**---------------------------------------------------------------------------------------
Set solute dielectric
@param soluteDielectric solute dielectric
--------------------------------------------------------------------------------------- */
void setSoluteDielectric( RealOpenMM soluteDielectric );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get OBC type Get OBC type
...@@ -158,33 +252,18 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -158,33 +252,18 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
const RealOpenMM* getScaledRadiusFactors( void ) const; const RealOpenMMVector& getScaledRadiusFactors( void ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Return OBC scale factors Set OBC scale factors
@return array @param input vector of radius factors
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void setScaledRadiusFactors( RealOpenMM* scaledRadiusFactors );
#if RealOpenMMType == 0
void setScaledRadiusFactors( float* scaledRadiusFactors );
#endif
void setScaledRadiusFactors( const RealOpenMMVector& scaledRadiusFactors ); void setScaledRadiusFactors( const RealOpenMMVector& scaledRadiusFactors );
/**---------------------------------------------------------------------------------------
Set flag indicating whether scale factors arra should be deleted
@param ownScaledRadiusFactors flag indicating whether scale factors
array should be deleted
--------------------------------------------------------------------------------------- */
void setOwnScaleFactors( int ownScaledRadiusFactors );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Get AtomicRadii array w/ dielectric offset applied Get AtomicRadii array w/ dielectric offset applied
...@@ -193,17 +272,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -193,17 +272,7 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM* getAtomicRadii( void ) const; const RealOpenMMVector& getAtomicRadii( void ) const;
/**---------------------------------------------------------------------------------------
Set AtomicRadii array
@param atomicRadii array of atomic radii
--------------------------------------------------------------------------------------- */
void setAtomicRadii( RealOpenMM* atomicRadii );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -215,31 +284,6 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters { ...@@ -215,31 +284,6 @@ class ObcSoftcoreParameters : public ImplicitSolventParameters {
void setAtomicRadii( const RealOpenMMVector& atomicRadii ); void setAtomicRadii( const RealOpenMMVector& atomicRadii );
/**---------------------------------------------------------------------------------------
Map Gmx atom name to Tinker atom number (Simbios)
@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
--------------------------------------------------------------------------------------- */
int mapGmxAtomNameToTinkerAtomNumber( const char* atomName, FILE* log ) const;
/**---------------------------------------------------------------------------------------
Get string w/ state
@param title title (optional)
@return string
--------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Set the force to use a cutoff. Set the force to use a cutoff.
...@@ -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