Commit 326627a8 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Cleaned up code

parent a587c652
......@@ -847,12 +847,13 @@ double ReferenceCalcGBSAOBCForceKernel::execute(ContextImpl& context, bool inclu
vector<RealVec>& forceData = extractForces(context);
if (isPeriodic)
obc->getObcParameters()->setPeriodic(extractBoxSize(context));
obc->computeImplicitSolventForces(posData, &charges[0], forceData, 1);
return obc->getEnergy();
return obc->computeBornEnergyForces(posData, charges, forceData);
}
ReferenceCalcGBVIForceKernel::~ReferenceCalcGBVIForceKernel() {
if (gbvi) {
GBVIParameters * gBVIParameters = gbvi->getGBVIParameters();
delete gBVIParameters;
delete gbvi;
}
}
......@@ -887,18 +888,21 @@ void ReferenceCalcGBVIForceKernel::initialize(const System& system, const GBVIFo
}
double ReferenceCalcGBVIForceKernel::execute(ContextImpl& context, bool includeForces, bool includeEnergy) {
vector<RealVec>& posData = extractPositions(context);
vector<RealOpenMM> bornRadii(context.getSystem().getNumParticles());
if (isPeriodic)
gbvi->getGBVIParameters()->setPeriodic(extractBoxSize(context));
gbvi->computeBornRadii(posData, bornRadii );
RealOpenMM energy;
if (includeForces) {
vector<RealVec>& forceData = extractForces(context);
gbvi->computeBornForces(bornRadii, posData, &charges[0], forceData);
gbvi->computeBornForces(posData, charges, forceData);
energy = 0.0;
}
if( includeEnergy ){
energy = gbvi->computeBornEnergy(posData, charges);
}
RealOpenMM energy = 0.0;
if (includeEnergy)
energy = gbvi->computeBornEnergy(bornRadii ,posData, &charges[0]);
return static_cast<double>(energy);
}
......
This diff is collapsed.
......@@ -25,26 +25,21 @@
#ifndef __CpuGBVI_H__
#define __CpuGBVI_H__
#include <vector>
#include "../SimTKUtilities/RealVec.h"
#include "GBVIParameters.h"
#include "CpuImplicitSolvent.h"
#include <vector>
// ---------------------------------------------------------------------------------------
class CpuGBVI : public CpuImplicitSolvent {
class CpuGBVI {
private:
// GB/VI parameters
GBVIParameters* _gbviParameters;
std::vector<RealOpenMM> _switchDeriviative;
// initialize data members (more than
// one constructor, so centralize intialization here)
void _initializeGBVIDataMembers( void );
RealOpenMMVector _switchDeriviative;
public:
......@@ -58,7 +53,7 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
CpuGBVI( ImplicitSolventParameters* gbviParameters );
CpuGBVI( GBVIParameters* gbviParameters );
/**---------------------------------------------------------------------------------------
......@@ -98,50 +93,7 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
void computeBornRadii( std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<RealOpenMM>& bornRadii );
/**---------------------------------------------------------------------------------------
Get Born energy and forces (not used)
@param bornRadii Born radii
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param forces forces
--------------------------------------------------------------------------------------- */
void computeBornEnergyForces( RealOpenMM* bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& forces );
/**---------------------------------------------------------------------------------------
Get state
title title (optional)
@return state string
--------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const;
/**---------------------------------------------------------------------------------------
Write Born energy and forces (Simbios)
@param atomCoordinates atomic coordinates
@param partialCharges partial atom charges
@param forces force array
@param resultsFileName output file name
@return SimTKOpenMMCommon::DefaultReturn if file opened; else return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
int writeBornEnergyForces( std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& forces,
const std::string& resultsFileName ) const;
void computeBornRadii( const std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMMVector& bornRadii );
/**---------------------------------------------------------------------------------------
......@@ -215,7 +167,6 @@ class CpuGBVI : public CpuImplicitSolvent {
Get GB/VI energy
@param bornRadii Born radii
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
......@@ -223,22 +174,20 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
RealOpenMM computeBornEnergy( const std::vector<RealOpenMM>& bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges );
RealOpenMM computeBornEnergy( const std::vector<OpenMM::RealVec>& atomCoordinates, const RealOpenMMVector& partialCharges );
/**---------------------------------------------------------------------------------------
Get GB/VI forces
@param bornRadii Born radii
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param forces output forces
--------------------------------------------------------------------------------------- */
void computeBornForces( const std::vector<RealOpenMM>& bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& inputForces );
void computeBornForces( std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMMVector& partialCharges, std::vector<OpenMM::RealVec>& inputForces );
/**---------------------------------------------------------------------------------------
......@@ -305,7 +254,7 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getSwitchDeriviative( void );
RealOpenMMVector& getSwitchDeriviative( void );
/**---------------------------------------------------------------------------------------
......
This diff is collapsed.
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __CpuImplicitSolvent_H__
#define __CpuImplicitSolvent_H__
#include "ImplicitSolventParameters.h"
#include <vector>
// ---------------------------------------------------------------------------------------
class OPENMM_EXPORT CpuImplicitSolvent {
private:
// used for direct calls
static CpuImplicitSolvent* _cpuImplicitSolvent;
// parameters
ImplicitSolventParameters* _implicitSolventParameters;
// flag to signal whether ACE approximation
// is to be included
int _includeAceApproximation;
// force index call
int _forceCallIndex;
// work arrays
std::vector<RealOpenMM> _bornForce;
// Born radii and force
std::vector<RealOpenMM> _bornRadii;
std::vector<RealOpenMM> _tempBornRadii;
// convert units for energy/force
RealOpenMM _forceConversionFactor;
RealOpenMM _energyConversionFactor;
// Ed, 2007-04-27: Store the energy internally
RealOpenMM _implicitSolventEnergy;
/**---------------------------------------------------------------------------------------
Initialize data members -- potentially more than
one constructor, so centralize intialization here
--------------------------------------------------------------------------------------- */
void _initializeDataMembers( void );
protected:
/**---------------------------------------------------------------------------------------
Return implicitSolventBornForce, a work array of size _implicitSolventParameters->getNumberOfAtoms()*sizeof( RealOpenMM )
On first call, memory for array is allocated if not set
@return array
--------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getBornForce( void );
/**---------------------------------------------------------------------------------------
Return Born radii temp work array of size=_implicitSolventParameters->getNumberOfAtoms()
On first call, memory for array is allocated if not set
@return array
--------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getBornRadiiTemp( void );
/**---------------------------------------------------------------------------------------
Set energy
@param energy new energy
--------------------------------------------------------------------------------------- */
void setEnergy( RealOpenMM energy );
public:
/**---------------------------------------------------------------------------------------
Constructor
@param implicitSolventParameters ImplicitSolventParameters reference
@return CpuImplicitSolvent object
--------------------------------------------------------------------------------------- */
CpuImplicitSolvent( ImplicitSolventParameters* implicitSolventParameters );
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
virtual ~CpuImplicitSolvent( );
/**---------------------------------------------------------------------------------------
Delete static _cpuImplicitSolvent object if set
@return SimTKOpenMMCommon::DefaultReturn if _cpuImplicitSolvent was set;
otherwise return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
static int deleteCpuImplicitSolvent( void );
/**---------------------------------------------------------------------------------------
Set static member _cpuImplicitSolvent
--------------------------------------------------------------------------------------- */
static void setCpuImplicitSolvent( CpuImplicitSolvent* cpuImplicitSolvent );
/**---------------------------------------------------------------------------------------
Get static member cpuImplicitSolvent
@return static member cpuImplicitSolvent
--------------------------------------------------------------------------------------- */
static CpuImplicitSolvent* getCpuImplicitSolvent( void );
/**---------------------------------------------------------------------------------------
Get number of atoms
@return number of atoms
--------------------------------------------------------------------------------------- */
int getNumberOfAtoms( void ) const;
/**---------------------------------------------------------------------------------------
Get energy
@return energy
--------------------------------------------------------------------------------------- */
RealOpenMM getEnergy( void ) const;
/**---------------------------------------------------------------------------------------
Return ImplicitSolventParameters
@return ImplicitSolventParameters
--------------------------------------------------------------------------------------- */
ImplicitSolventParameters* getImplicitSolventParameters( void ) const;
/**---------------------------------------------------------------------------------------
Set ImplicitSolventParameters
@param ImplicitSolventParameters
--------------------------------------------------------------------------------------- */
void setImplicitSolventParameters( ImplicitSolventParameters* implicitSolventParameters );
/**---------------------------------------------------------------------------------------
Return flag signalling whether AceApproximation for nonpolar term is to be included
@return flag
--------------------------------------------------------------------------------------- */
int includeAceApproximation( void ) const;
/**---------------------------------------------------------------------------------------
Set flag indicating whether AceApproximation is to be included
@param includeAceApproximation new includeAceApproximation value
--------------------------------------------------------------------------------------- */
void setIncludeAceApproximation( int includeAceApproximation );
/**---------------------------------------------------------------------------------------
Return ForceConversionFactor for units
@return ForceConversionFactor
--------------------------------------------------------------------------------------- */
RealOpenMM getForceConversionFactor( void ) const;
/**---------------------------------------------------------------------------------------
Set ForceConversionFactor
@param ForceConversionFactor (units conversion)
--------------------------------------------------------------------------------------- */
void setForceConversionFactor( RealOpenMM forceConversionFactor );
/**---------------------------------------------------------------------------------------
Return EnergyConversionFactor for units
@return EnergyConversionFactor
--------------------------------------------------------------------------------------- */
RealOpenMM getEnergyConversionFactor( void ) const;
/**---------------------------------------------------------------------------------------
Set EnergyConversionFactor
@param EnergyConversionFactor (units conversion)
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
void setEnergyConversionFactor( RealOpenMM energyConversionFactor );
/**---------------------------------------------------------------------------------------
Return ForceCallIndex -- number of times forces have been calculated
@return ForceCallIndex
--------------------------------------------------------------------------------------- */
int getForceCallIndex( void ) const;
/**---------------------------------------------------------------------------------------
Increment ForceCallIndex
@return incremented forceCallIndex
--------------------------------------------------------------------------------------- */
int incrementForceCallIndex( void );
/**---------------------------------------------------------------------------------------
Return Born radii: size = _implicitSolventParameters->getNumberOfAtoms()
On first call, memory for array is allocated if not set
@return array
--------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getBornRadii( void );
/**---------------------------------------------------------------------------------------
Return Born radii: size = _implicitSolventParameters->getNumberOfAtoms()
@return array
--------------------------------------------------------------------------------------- */
const std::vector<RealOpenMM>& getBornRadiiConst( void ) const;
/**---------------------------------------------------------------------------------------
Get Born energy and forces
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param forces forces (output); if not set on input, then memory is allocated
@param updateBornRadii if set, then Born radii are updated for current configuration;
otherwise radii correspond to configuration from previous iteration
--------------------------------------------------------------------------------------- */
void computeImplicitSolventForces( std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges,
std::vector<OpenMM::RealVec>& forces, int updateBornRadii = 0 );
/**---------------------------------------------------------------------------------------
Get Born radii based on J. Phys. Chem. A V101 No 16, p. 3005 (Simbios)
@param atomCoordinates atomic coordinates dimension: [0-numberAtoms-1][0-2]
@param bornRadii output array of Born radii
@param obcChain output array of OBC chain derivative
@return array of Born radii
--------------------------------------------------------------------------------------- */
virtual void computeBornRadii( std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<RealOpenMM>& bornRadii ) = 0;
/**---------------------------------------------------------------------------------------
Get Born energy and forces based on J. Phys. Chem. A V101 No 16, p. 3005 (Simbios)
@param bornRadii Born radii
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param forces forces
@return force array
--------------------------------------------------------------------------------------- */
virtual void computeBornEnergyForces( std::vector<RealOpenMM>& bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& forces );
/**---------------------------------------------------------------------------------------
Get nonpolar solvation force constribution via ACE approximation
@param implicitSolventParameters parameters
@param bornRadii Born radii
@param energy energy (output): value is incremented from input value
@param forces forces: values are incremented from input values
--------------------------------------------------------------------------------------- */
void computeAceNonPolarForce( const ImplicitSolventParameters* implicitSolventParameters,
const std::vector<RealOpenMM>& bornRadii, RealOpenMM* energy,
std::vector<RealOpenMM>& forces ) const;
/**---------------------------------------------------------------------------------------
Get string w/ state
@param title title (optional)
@return string containing state
--------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const;
};
// ---------------------------------------------------------------------------------------
#endif // __CpuImplicitSolvent_H__
This diff is collapsed.
......@@ -26,11 +26,10 @@
#define __CpuObc_H__
#include "ObcParameters.h"
#include "CpuImplicitSolvent.h"
// ---------------------------------------------------------------------------------------
class CpuObc : public CpuImplicitSolvent {
class CpuObc {
private:
......@@ -40,13 +39,13 @@ class CpuObc : public CpuImplicitSolvent {
// arrays containing OBC chain derivative
std::vector<RealOpenMM> _obcChain;
std::vector<RealOpenMM> _obcChainTemp;
RealOpenMMVector _obcChain;
// initialize data members (more than
// one constructor, so centralize intialization here)
// flag to signal whether ACE approximation
// is to be included
int _includeAceApproximation;
void _initializeObcDataMembers( void );
public:
......@@ -60,7 +59,7 @@ class CpuObc : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
CpuObc( ImplicitSolventParameters* obcParameters );
CpuObc( ObcParameters* obcParameters );
/**---------------------------------------------------------------------------------------
......@@ -92,26 +91,33 @@ class CpuObc : public CpuImplicitSolvent {
/**---------------------------------------------------------------------------------------
Return OBC chain derivative: size = _implicitSolventParameters->getNumberOfAtoms()
On first call, memory for array is allocated if not set
Return flag signalling whether AceApproximation for nonpolar term is to be included
@return array
@return flag
--------------------------------------------------------------------------------------- */
int includeAceApproximation( void ) const;
/**---------------------------------------------------------------------------------------
Set flag indicating whether AceApproximation is to be included
@param includeAceApproximation new includeAceApproximation value
--------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getObcChain( void );
const std::vector<RealOpenMM>& getObcChainConst( void ) const;
void setIncludeAceApproximation( int includeAceApproximation );
/**---------------------------------------------------------------------------------------
Return OBC chain temp work array of size=_implicitSolventParameters->getNumberOfAtoms()
On first call, memory for array is allocated if not set
Return OBC chain derivative: size = _implicitSolventParameters->getNumberOfAtoms()
@return array
--------------------------------------------------------------------------------------- */
std::vector<RealOpenMM>& getObcChainTemp( void );
RealOpenMMVector& getObcChain( void );
/**---------------------------------------------------------------------------------------
......@@ -119,38 +125,38 @@ class CpuObc : public CpuImplicitSolvent {
@param atomCoordinates atomic coordinates
@param bornRadii output array of Born radii
@param obcChain output array of OBC chain derivative factors; if NULL,
then ignored
--------------------------------------------------------------------------------------- */
void computeBornRadii( std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<RealOpenMM>& bornRadii );
void computeBornRadii( const std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMMVector& bornRadii );
/**---------------------------------------------------------------------------------------
Get Born energy and forces based on OBC
Get nonpolar solvation force constribution via ACE approximation
@param obcParameters parameters
@param vdwRadii Vdw radii
@param bornRadii Born radii
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param forces forces
@param energy energy (output): value is incremented from input value
@param forces forces: values are incremented from input values
--------------------------------------------------------------------------------------- */
void computeBornEnergyForces( std::vector<RealOpenMM>& bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& forces );
void computeAceNonPolarForce( const ObcParameters* obcParameters, const RealOpenMMVector& bornRadii,
RealOpenMM* energy, RealOpenMMVector& forces ) const;
/**---------------------------------------------------------------------------------------
Get state
title title (optional)
Get Born energy and forces based on OBC
@return state string
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param forces forces
--------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const;
RealOpenMM computeBornEnergyForces( const std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMMVector& partialCharges, std::vector<OpenMM::RealVec>& forces );
};
......
......@@ -26,16 +26,13 @@
#define __GBVIParameters_H__
#include "../SimTKUtilities/SimTKOpenMMCommon.h"
#include "ImplicitSolventParameters.h"
// ---------------------------------------------------------------------------------------
class GBVIParameters : public ImplicitSolventParameters {
class GBVIParameters {
public:
static const std::string ParameterFileName;
/**
* This is an enumeration of the different methods that may be used for scaling of the Born radii.
*/
......@@ -44,10 +41,6 @@ class GBVIParameters : public ImplicitSolventParameters {
* No scaling method is applied.
*/
NoScaling = 0,
/**
* Use the method outlined in Proteins 55, 383-394 (2004), Eq. 6
*/
Tanh = 2,
/**
* Use quintic spline scaling function
*/
......@@ -56,21 +49,24 @@ class GBVIParameters : public ImplicitSolventParameters {
private:
// scaled radii
int _numberOfAtoms;
int _ownScaledRadii;
RealOpenMM* _scaledRadii;
RealOpenMM _solventDielectric;
RealOpenMM _soluteDielectric;
RealOpenMM _electricConstant;
// gamma parameters
int _ownGammaParameters;
RealOpenMM* _gammaParameters;
// parameter vectors
RealOpenMMVector _atomicRadii;
RealOpenMMVector _scaledRadii;
RealOpenMMVector _gammaParameters;
// cutoff and periodic boundary conditions
bool cutoff;
bool periodic;
RealOpenMM periodicBoxSize[3];
RealOpenMM cutoffDistance;
bool _cutoff;
bool _periodic;
RealOpenMM _periodicBoxSize[3];
RealOpenMM _cutoffDistance;
int _bornRadiusScalingMethod;
RealOpenMM _quinticLowerLimitFactor;
......@@ -98,118 +94,123 @@ class GBVIParameters : public ImplicitSolventParameters {
/**---------------------------------------------------------------------------------------
Return scaled radii
Get number of atoms
@return array
@return number of atoms
--------------------------------------------------------------------------------------- */
const RealOpenMM* getScaledRadii( void ) const;
int getNumberOfAtoms( void ) const;
/**---------------------------------------------------------------------------------------
Return scaled radii
Get electric constant
@return array
@return electric constant
--------------------------------------------------------------------------------------- */
void setScaledRadii( RealOpenMM* scaledRadii );
void setScaledRadii( const RealOpenMMVector& scaledRadii );
RealOpenMM getElectricConstant( void ) const;
/**---------------------------------------------------------------------------------------
Set flag indicating whether scaled radii array should be deleted
Get solvent dielectric
@param ownScaledRadiusFactors flag indicating whether scaled radii
array should be deleted
@return solvent dielectric
--------------------------------------------------------------------------------------- */
void setOwnScaledRadii( int ownScaledRadii );
RealOpenMM getSolventDielectric( void ) const;
/**---------------------------------------------------------------------------------------
Get AtomicRadii array w/ dielectric offset applied
Set solvent dielectric
@return array of atom volumes
@param solventDielectric solvent dielectric
--------------------------------------------------------------------------------------- */
RealOpenMM* getAtomicRadii( void ) const;
void setSolventDielectric( RealOpenMM solventDielectric );
/**---------------------------------------------------------------------------------------
Set AtomicRadii array
Get solute dielectric
@param atomicRadii array of atomic radii
@return soluteDielectric
--------------------------------------------------------------------------------------- */
void setAtomicRadii( RealOpenMM* atomicRadii );
RealOpenMM getSoluteDielectric( void ) const;
/**---------------------------------------------------------------------------------------
Set AtomicRadii array
Set solute dielectric
@param atomicRadii vector of atomic radii
@param soluteDielectric solute dielectric
--------------------------------------------------------------------------------------- */
void setAtomicRadii( const RealOpenMMVector& atomicRadii );
void setSoluteDielectric( RealOpenMM soluteDielectric );
/**---------------------------------------------------------------------------------------
Set flag indicating whether gamma parameter array should be deleted
Return scaled radii
@param ownGammaParameters flag indicating whether gamma parameter
array should be deleted
@return array
--------------------------------------------------------------------------------------- */
void setOwnGammaParameters( int ownGammaParameters );
const RealOpenMMVector& getScaledRadii( void ) const;
/**---------------------------------------------------------------------------------------
Get GammaParameters array
Return scaled radii
@return array of gamma values
@return array
--------------------------------------------------------------------------------------- */
RealOpenMM* getGammaParameters( void ) const;
void setScaledRadii( const RealOpenMMVector& scaledRadii );
/**---------------------------------------------------------------------------------------
Set GammaParameters array
Get AtomicRadii array w/ dielectric offset applied
@param gammaParameters array of gamma parameters
@return array of atom volumes
--------------------------------------------------------------------------------------- */
void setGammaParameters( RealOpenMM* gammaParameters );
const RealOpenMMVector& getAtomicRadii( void ) const;
/**---------------------------------------------------------------------------------------
Set GammaParameters array
Set AtomicRadii array
@param gammaParameters array of gamma parameters
@param atomicRadii vector of atomic radii
--------------------------------------------------------------------------------------- */
void setGammaParameters( const RealOpenMMVector& gammaParameters );
void setAtomicRadii( const RealOpenMMVector& atomicRadii );
/**---------------------------------------------------------------------------------------
Get string w/ state
Get GammaParameters array
@param title title (optional)
@return array of gamma values
--------------------------------------------------------------------------------------- */
const RealOpenMMVector& getGammaParameters( void ) const;
/**---------------------------------------------------------------------------------------
@return string
Set GammaParameters array
@param gammaParameters array of gamma parameters
--------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const;
void setGammaParameters( const RealOpenMMVector& gammaParameters );
/**---------------------------------------------------------------------------------------
......
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ImplicitSolventParameters_H__
#define __ImplicitSolventParameters_H__
#include "../SimTKUtilities/SimTKOpenMMRealType.h"
#include "../../../../openmmapi/include/openmm/internal/windowsExport.h"
#include <string>
// ---------------------------------------------------------------------------------------
class OPENMM_EXPORT ImplicitSolventParameters {
protected:
// parameters common to implicit solvent models
RealOpenMM _solventDielectric;
RealOpenMM _soluteDielectric;
RealOpenMM _kcalA_To_kJNm;
RealOpenMM _electricConstant;
RealOpenMM _probeRadius;
RealOpenMM _pi4Asolv;
RealOpenMM _preFactor;
// ---------------------------------------------------------------------------------------
// atom count
int _numberOfAtoms;
// flag signalling whether arrays are to be freed
int _freeArrays;
// atomic radii
int _ownAtomicRadii;
RealOpenMM* _atomicRadii;
/**---------------------------------------------------------------------------------------
Initialize ImplicitSolvent Parameters (Simbios)
--------------------------------------------------------------------------------------- */
void _initializeImplicitSolventConstants( void );
/**---------------------------------------------------------------------------------------
Set KcalA_To_kJNm
@param kcalA_To_kJNm probe radius
--------------------------------------------------------------------------------------- */
void setKcalA_To_kJNm( RealOpenMM kcalA_To_kJNm );
/**---------------------------------------------------------------------------------------
Set free array flag -- if set then work arrays are freed when destructor is called
@param freeArrays flag
--------------------------------------------------------------------------------------- */
void setFreeArrays( int freeArrays );
/**---------------------------------------------------------------------------------------
Reset prefactor (Simbios)
called when _electricConstant, _soluteDielectric, or _solventDielectric are modified
--------------------------------------------------------------------------------------- */
void _resetPreFactor( void );
public:
/**---------------------------------------------------------------------------------------
ImplicitSolventParameters constructor (Simbios)
@param numberOfAtoms number of atoms
--------------------------------------------------------------------------------------- */
ImplicitSolventParameters( int numberOfAtoms );
/**---------------------------------------------------------------------------------------
ImplicitSolventParameters destructor (Simbios)
--------------------------------------------------------------------------------------- */
virtual ~ImplicitSolventParameters( );
// override of new/delete
//static void* operator new( size_t size );
//static void operator delete( void *p );
//static void* operator new[]( size_t size );
//static void operator delete[]( void *p );
/**---------------------------------------------------------------------------------------
Get number of atoms
@return number of atoms
--------------------------------------------------------------------------------------- */
int getNumberOfAtoms( void ) const;
/**---------------------------------------------------------------------------------------
Get free array flag -- if set then work arrays are freed when destructor is called
@return freeArrays flag
--------------------------------------------------------------------------------------- */
int getFreeArrays( 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 conversion factor for kcal/A -> kJ/nm (Simbios)
@return kcalA_To_kJNm factor
--------------------------------------------------------------------------------------- */
RealOpenMM getKcalA_To_kJNm( void ) const;
/**---------------------------------------------------------------------------------------
Get electric constant (Simbios)
@return electricConstant
--------------------------------------------------------------------------------------- */
RealOpenMM getElectricConstant( void ) const;
/**---------------------------------------------------------------------------------------
Set electric constant (Simbios)
@param electricConstant electric constant
--------------------------------------------------------------------------------------- */
void setElectricConstant( RealOpenMM electricConstant );
/**---------------------------------------------------------------------------------------
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 prefactor
@returnpreFactor
--------------------------------------------------------------------------------------- */
RealOpenMM getPreFactor( void ) const;
/**---------------------------------------------------------------------------------------
Set values used in ACE approximation for nonpolar term
((RealOpenMM) M_PI)*4.0f*0.0049f*1000.0f; (Simbios)
@param pi4Asolv see above
--------------------------------------------------------------------------------------- */
void setPi4Asolv( RealOpenMM pi4Asolv );
/**---------------------------------------------------------------------------------------
Get AtomicRadii array
@return array of atom volumes
--------------------------------------------------------------------------------------- */
virtual RealOpenMM* getAtomicRadii( void ) const;
/**---------------------------------------------------------------------------------------
Set AtomicRadii array
@param atomicRadii array of atomic radii
--------------------------------------------------------------------------------------- */
virtual void setAtomicRadii( RealOpenMM* atomicRadii );
/**---------------------------------------------------------------------------------------
Set AtomicRadii array
@param atomicRadii vector of atomic radii
--------------------------------------------------------------------------------------- */
virtual void setAtomicRadii( const RealOpenMMVector& atomicRadii );
/**---------------------------------------------------------------------------------------
Set flag indicating whether AtomicRadii array is owned by
object; if flag is set, then when the object is deleted,
the array will be freed
@param ownAtomicRadii flag indicating whether array of atomic radii
should be freed
--------------------------------------------------------------------------------------- */
void setOwnAtomicRadii( int ownAtomicRadii );
/**---------------------------------------------------------------------------------------
Print state to log file (Simbios)
@param title title (optional)
--------------------------------------------------------------------------------------- */
virtual std::string getStateString( const char* title ) const;
/**---------------------------------------------------------------------------------------
Get string tab -- centralized
@return tab string
--------------------------------------------------------------------------------------- */
std::string getStringTab( void ) const;
};
// ---------------------------------------------------------------------------------------
#endif // __ImplicitSolventParameters_H__
This diff is collapsed.
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __CpuObcInterface_H__
#define __CpuObcInterface_H__
#ifdef __cplusplus
#define externC extern "C"
#else
#define externC extern
#endif
#include "../SimTKUtilities/RealVec.h"
#include <stdio.h>
#include <vector>
/**---------------------------------------------------------------------------------------
Retrieve the calculated implicit solvation energy from the static class member
@return the calculated energy from the static class member
--------------------------------------------------------------------------------------- */
externC RealOpenMM cpuGetImplicitSolventEnergy( void );
/**---------------------------------------------------------------------------------------
Delete the Obc associated object(s)
@return 0 if static CpuObc object was set; else return -1
--------------------------------------------------------------------------------------- */
externC int cpuDeleteObcParameters( void );
/**---------------------------------------------------------------------------------------
Setup for Obc calculations from Gromacs
@param numberOfAtoms number of atoms
@param obcScaleFactors array of OBC scale factors (one entry each atom)
@param atomicRadii atomic radii in Angstrom (one entry each atom)
@param includeAceApproximation if true, then include nonpolar
ACE term in calculations
@param soluteDielectric solute dielectric
@param solventDielectric solvent dielectric
@param log log reference -- if NULL, then errors/warnings
output to stderr
The method creates a CpuObc instance -- currently the OBC type II model is the
default (see paper). If the OBC type I model is desired change
ObcParameters* obcParameters = new ObcParameters( numberOfAtoms, ObcParameters::ObcTypeII );
to
ObcParameters* obcParameters = new ObcParameters( numberOfAtoms, ObcParameters::ObcTypeI );
The created object is a static member of the class CpuObc;
when the force routine, cpuCalculateObcForces(), is called,
the static object is used to compute the forces and energy
@return 0
--------------------------------------------------------------------------------------- */
externC
int cpuSetObcParameters( int numberOfAtoms, RealOpenMM* atomicRadii, RealOpenMM* obcScaleFactors,
int includeAceApproximation, RealOpenMM soluteDielectric,
RealOpenMM solventDielectric, FILE* log );
/**---------------------------------------------------------------------------------------
Calculate implicit solvent forces and energy
@param atomCoordinates atom coordinates in Angstrom; format of array is
atomCoordinates[atom][3]
@param partialCharges partial atom charges
@param forces output forces in kcal/mol.A; format of array is
forces[atom][3]
@param energy energy
@param updateBornRadii if set, then Born radii are updated for current configuration;
otherwise radii correspond to configuration from previous iteration
Function calls a static method in CpuImplicitSolvent class to calculate forces/energy
--------------------------------------------------------------------------------------- */
externC void cpuCalculateImplicitSolventForces( std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialChargesIn,
std::vector<OpenMM::RealVec>& forces, RealOpenMM* energy,
int updateBornRadii );
/**---------------------------------------------------------------------------------------
Get OBC scale factors given masses
@param numberOfAtoms number of atoms
@param masses input masses
@param scaleFactors output atomic numbers
--------------------------------------------------------------------------------------- */
externC void getObcScaleFactorsGivenAtomMasses( int numberOfAtoms, const RealOpenMM* masses,
RealOpenMM* scaleFactors );
/**---------------------------------------------------------------------------------------
Get OBC scale factors given atomic numbers
@param numberOfAtoms number of atoms
@param atomicNumber input atomic number for each atom
@param scaleFactors output atomic numbers
--------------------------------------------------------------------------------------- */
externC void getObcScaleFactors( int numberOfAtoms, const int* atomicNumber,
RealOpenMM* scaleFactors );
/**---------------------------------------------------------------------------------------
Get GBSA radii
@param numberOfAtoms number of atoms
@param atomicNumber input atomic number for each atom
@param numberOfCovalentPartners input number of covalent partners for each atom
1 for H, ...; only used for C, N & O
@param indexOfCovalentPartner index of covalent partner -- only used for H
e.g. if atom 22 is a H and it is bonded to atom 24
then indexOfCovalentPartner[22] = 24
@param gbsaRadii output GBSA radii
--------------------------------------------------------------------------------------- */
externC void getGbsaRadii( int numberOfAtoms, const int* atomicNumber,
const int* numberOfCovalentPartners,
const int* indexOfCovalentPartner, RealOpenMM* gbsaRadii );
#undef externC
#endif
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