Commit 08c2e027 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Mods

parent 9936ec46
...@@ -48,6 +48,7 @@ using namespace std; ...@@ -48,6 +48,7 @@ using namespace std;
BrookBondParameters::BrookBondParameters( std::string bondName, int numberOfParticlesInBond, BrookBondParameters::BrookBondParameters( std::string bondName, int numberOfParticlesInBond,
int numberOfParametersInBond, int numberOfBonds, FILE* log = NULL ) : int numberOfParametersInBond, int numberOfBonds, FILE* log = NULL ) :
_bondName( bondName ), _numberOfParticlesInBond( numberOfParticlesInBond ), _bondName( bondName ), _numberOfParticlesInBond( numberOfParticlesInBond ),
_numberOfParametersInBond( numberOfParametersInBond ), _numberOfBonds( numberOfBonds ), _log( log ){ _numberOfParametersInBond( numberOfParametersInBond ), _numberOfBonds( numberOfBonds ), _log( log ){
...@@ -212,21 +213,13 @@ int BrookBondParameters::setBond( int bondIndex, int* particleIndices, double* b ...@@ -212,21 +213,13 @@ int BrookBondParameters::setBond( int bondIndex, int* particleIndices, double* b
// load'em up // load'em up
int numberOfParticlesInBond = getNumberOfParticlesInBond(); int numberOfParticlesInBond = getNumberOfParticlesInBond();
std::vector<int> indices;
_particleIndices[bondIndex] = indices;
indices.resize( numberOfParticlesInBond );
for( int ii = 0; ii < numberOfParticlesInBond; ii++ ){ for( int ii = 0; ii < numberOfParticlesInBond; ii++ ){
indices[ii] = particleIndices[ii]; _particleIndices[bondIndex].push_back( particleIndices[ii] );
} }
int numberOfParametersInBond = getNumberOfParametersInBond(); int numberOfParametersInBond = getNumberOfParametersInBond();
std::vector<double> parameters;
_bondParameters[bondIndex] = parameters;
parameters.resize( numberOfParametersInBond );
for( int ii = 0; ii < numberOfParametersInBond; ii++ ){ for( int ii = 0; ii < numberOfParametersInBond; ii++ ){
parameters[ii] = bondParameters[ii]; _bondParameters[bondIndex].push_back( bondParameters[ii] );
} }
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -317,16 +310,19 @@ std::string BrookBondParameters::getContentsString( int level ) const { ...@@ -317,16 +310,19 @@ std::string BrookBondParameters::getContentsString( int level ) const {
(void) LOCAL_SPRINTF( value, "%d", getNumberOfParametersInBond() ); (void) LOCAL_SPRINTF( value, "%d", getNumberOfParametersInBond() );
message << _getLine( tab, "Parameters/bond:", value ); message << _getLine( tab, "Parameters/bond:", value );
//(void) fprintf( getLog(), "%s %s QQQ1\n", methodName.c_str(), message.str().c_str() ); (void) fflush( getLog() );
message << "Bonds:" << std::endl; message << "Bonds:" << std::endl;
for( int ii = 0; ii < getNumberOfBonds(); ii++ ){ for( int ii = 0; ii < getNumberOfBonds(); ii++ ){
const static size_t descriptionSz = 256; const static size_t descriptionSz = 1024;
char description[256]; char description[1024];
char buffer[256]; char buffer[1024];
(void) LOCAL_SPRINTF( description, "%6d [", ii ); (void) LOCAL_SPRINTF( description, "%6d [", ii );
#ifdef WIN32
// particle indices // particle indices
#ifdef WIN32
for( int jj = 0; jj < getNumberOfParticlesInBond(); jj++ ){ for( int jj = 0; jj < getNumberOfParticlesInBond(); jj++ ){
(void) LOCAL_SPRINTF( buffer, "%6d ", _particleIndices[ii][jj] ); (void) LOCAL_SPRINTF( buffer, "%6d ", _particleIndices[ii][jj] );
(void) strcat_s( description, descriptionSz, buffer ); (void) strcat_s( description, descriptionSz, buffer );
...@@ -339,8 +335,12 @@ std::string BrookBondParameters::getContentsString( int level ) const { ...@@ -339,8 +335,12 @@ std::string BrookBondParameters::getContentsString( int level ) const {
(void) LOCAL_SPRINTF( buffer, "%18.10e ", _bondParameters[ii][jj] ); (void) LOCAL_SPRINTF( buffer, "%18.10e ", _bondParameters[ii][jj] );
(void) strcat_s( description, descriptionSz, buffer ); (void) strcat_s( description, descriptionSz, buffer );
} }
(void) strcat_s( description, descriptionSz, "]" ); (void) strcat_s( description, descriptionSz, "]" );
#else #else
// particle indices
for( int jj = 0; jj < getNumberOfParticlesInBond(); jj++ ){ for( int jj = 0; jj < getNumberOfParticlesInBond(); jj++ ){
(void) LOCAL_SPRINTF( buffer, "%6d ", _particleIndices[ii][jj] ); (void) LOCAL_SPRINTF( buffer, "%6d ", _particleIndices[ii][jj] );
(void) strcat( description, buffer ); (void) strcat( description, buffer );
......
...@@ -131,6 +131,8 @@ void BrookCalcHarmonicBondForceKernel::initialize( const System& system, const H ...@@ -131,6 +131,8 @@ void BrookCalcHarmonicBondForceKernel::initialize( const System& system, const H
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
//(void) fprintf( getLog(), "%s\n", methodName.c_str() ); (void) fflush( getLog() );
// create _brookBondParameters object containing particle indices/parameters // create _brookBondParameters object containing particle indices/parameters
int numberOfBonds = force.getNumBonds(); int numberOfBonds = force.getNumBonds();
...@@ -182,7 +184,7 @@ void BrookCalcHarmonicBondForceKernel::executeForces( OpenMMContextImpl& context ...@@ -182,7 +184,7 @@ void BrookCalcHarmonicBondForceKernel::executeForces( OpenMMContextImpl& context
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcHarmonicBondForceKernel::executeForces"; static const std::string methodName = "BrookCalcHarmonicBondForceKernel::executeForces";
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
...@@ -251,7 +251,7 @@ void BrookCalcNonbondedForceKernel::initialize14Interactions( const System& syst ...@@ -251,7 +251,7 @@ void BrookCalcNonbondedForceKernel::initialize14Interactions( const System& syst
_brookBondParameters->setBond( ii, particles, parameters ); _brookBondParameters->setBond( ii, particles, parameters );
} }
_openMMBrookInterface.setNonBonded14ForceParameters( _brookBondParameters ); _openMMBrookInterface.setNonBonded14ForceParameters( _brookBondParameters, 1.0, 1.0 );
if( log ){ if( log ){
std::string contents = _brookBondParameters->getContentsString( ); std::string contents = _brookBondParameters->getContentsString( );
......
...@@ -345,6 +345,16 @@ double BrookPlatform::getSpeed() const { ...@@ -345,6 +345,16 @@ double BrookPlatform::getSpeed() const {
return 10.0; return 10.0;
} }
/**
* Return particle stream width
*
* @return particle stream width
*/
int BrookPlatform::getParticleStreamWidth() const {
return _particleStreamWidth;
}
/** /**
* Return true if BrookPlatform supports double precison * Return true if BrookPlatform supports double precison
* *
...@@ -393,7 +403,7 @@ int BrookPlatform::getStreamSize( int size, int streamWidth, int* outputHeight ) ...@@ -393,7 +403,7 @@ int BrookPlatform::getStreamSize( int size, int streamWidth, int* outputHeight )
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
if( streamWidth < 1 || size < 1){ if( streamWidth < 1 || size < 1 ){
return -1; return -1;
} }
...@@ -446,7 +456,7 @@ void BrookPlatform::contextCreated( OpenMMContextImpl& context ) const { ...@@ -446,7 +456,7 @@ void BrookPlatform::contextCreated( OpenMMContextImpl& context ) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
context.setPlatformData( new OpenMMBrookInterface() ); context.setPlatformData( new OpenMMBrookInterface( getParticleStreamWidth() ) );
} }
/** /**
......
...@@ -46,7 +46,7 @@ using namespace std; ...@@ -46,7 +46,7 @@ using namespace std;
* *
*/ */
OpenMMBrookInterface::OpenMMBrookInterface( void ){ OpenMMBrookInterface::OpenMMBrookInterface( int streamWidth ) : _particleStreamWidth(streamWidth){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -54,7 +54,7 @@ OpenMMBrookInterface::OpenMMBrookInterface( void ){ ...@@ -54,7 +54,7 @@ OpenMMBrookInterface::OpenMMBrookInterface( void ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
_numberOfParticles = 0; _numberOfParticles = 0;
_brookBonded = NULL; _brookBonded = NULL;
_brookNonBonded = NULL; _brookNonBonded = NULL;
...@@ -76,6 +76,14 @@ OpenMMBrookInterface::OpenMMBrookInterface( void ){ ...@@ -76,6 +76,14 @@ OpenMMBrookInterface::OpenMMBrookInterface( void ){
_referencePlatform = NULL; _referencePlatform = NULL;
_refVerletIntegrator = NULL; _refVerletIntegrator = NULL;
_lj14Scale = 1.0;
_coulomb14Scale = 1.0;
_particleStreamSize = -1;
for( int ii = 0; ii < LastBondForce; ii++ ){
_bondParameters[ii] = NULL;
}
} }
/** /**
...@@ -93,6 +101,10 @@ OpenMMBrookInterface::~OpenMMBrookInterface( ){ ...@@ -93,6 +101,10 @@ OpenMMBrookInterface::~OpenMMBrookInterface( ){
delete _brookBonded; delete _brookBonded;
delete _brookNonBonded; delete _brookNonBonded;
delete _brookGbsa;
for( int ii = 0; ii < LastBondForce; ii++ ){
delete _bondParameters[ii];
}
// deleted w/ kernel delete? If activated, program crashes // deleted w/ kernel delete? If activated, program crashes
...@@ -105,6 +117,65 @@ OpenMMBrookInterface::~OpenMMBrookInterface( ){ ...@@ -105,6 +117,65 @@ OpenMMBrookInterface::~OpenMMBrookInterface( ){
*/ */
} }
/**
* Get number of particles
*
* @return number of particles
*
*/
int OpenMMBrookInterface::getNumberOfParticles( void ) const {
return _numberOfParticles;
}
/**
* Get particle stream width
*
* @return particle stream width
*
*/
int OpenMMBrookInterface::getParticleStreamWidth( void ) const {
return _particleStreamWidth;
}
/**
* Get particle stream size
*
* @return particle stream size
*
*/
int OpenMMBrookInterface::getParticleStreamSize( void ) const {
if( _particleStreamSize < 0 && _numberOfParticles > 0 ){
OpenMMBrookInterface* localThis = const_cast<OpenMMBrookInterface* const>(this);
localThis->_particleStreamSize = BrookPlatform::getStreamSize( _numberOfParticles, _particleStreamWidth, NULL );
}
return _particleStreamSize;
}
/**
* Get LJ-14 scale factor
*
* @return LJ-14 scale factor
*
*/
double OpenMMBrookInterface::getLj14Scale( void ) const {
return _lj14Scale;
}
/**
* Get Coulomb scale factor
*
* @return Coulomb scale factor
*
*/
double OpenMMBrookInterface::getCoulomb14Scale( void ) const {
return _coulomb14Scale;
}
/** /**
* Get log file reference * Get log file reference
* *
...@@ -130,6 +201,19 @@ int OpenMMBrookInterface::setLog( FILE* log ){ ...@@ -130,6 +201,19 @@ int OpenMMBrookInterface::setLog( FILE* log ){
return BrookCommon::DefaultReturnValue; return BrookCommon::DefaultReturnValue;
} }
/**
* Get BrookBondParameters at specified index
*
* @param index
*
* @return BrookBondParameters* object
*
*/
BrookBondParameters* OpenMMBrookInterface::_getBondParameters( BondParameterIndices index ) const {
return _bondParameters[index];
}
/** /**
* Set BrookBondParameters at specified index * Set BrookBondParameters at specified index
* *
...@@ -145,6 +229,17 @@ int OpenMMBrookInterface::_setBondParameters( BondParameterIndices index, BrookB ...@@ -145,6 +229,17 @@ int OpenMMBrookInterface::_setBondParameters( BondParameterIndices index, BrookB
return BrookCommon::DefaultReturnValue; return BrookCommon::DefaultReturnValue;
} }
/**
* Get BrookBondParameters for harmonic bond force
*
* @return brookBondParameters for harmonic bond force
*
*/
BrookBondParameters* OpenMMBrookInterface::getHarmonicBondForceParameters( void ) const {
return _getBondParameters( HarmonicBondIndex );
}
/** /**
* Set BrookBondParameters for harmonic bond force * Set BrookBondParameters for harmonic bond force
* *
...@@ -155,7 +250,18 @@ int OpenMMBrookInterface::_setBondParameters( BondParameterIndices index, BrookB ...@@ -155,7 +250,18 @@ int OpenMMBrookInterface::_setBondParameters( BondParameterIndices index, BrookB
*/ */
int OpenMMBrookInterface::setHarmonicBondForceParameters( BrookBondParameters* brookBondParameters ){ int OpenMMBrookInterface::setHarmonicBondForceParameters( BrookBondParameters* brookBondParameters ){
return _setBondParameters( HarmonicAngleIndex, brookBondParameters ); return _setBondParameters( HarmonicBondIndex, brookBondParameters );
}
/**
* Get BrookBondParameters for harmonic angle force
*
* @return brookBondParameters for harmonic angle force
*
*/
BrookBondParameters* OpenMMBrookInterface::getHarmonicAngleForceParameters( void ) const {
return _getBondParameters( HarmonicAngleIndex );
} }
/** /**
...@@ -172,9 +278,20 @@ int OpenMMBrookInterface::setHarmonicAngleForceParameters( BrookBondParameters* ...@@ -172,9 +278,20 @@ int OpenMMBrookInterface::setHarmonicAngleForceParameters( BrookBondParameters*
} }
/** /**
* Set BrookBondParameters for proper dihedral force * Get BrookBondParameters for periodic torsion force
*
* @return brookBondParameters for periodic torsion force
*
*/
BrookBondParameters* OpenMMBrookInterface::getPeriodicTorsionForceParameters( void ) const {
return _getBondParameters( PeriodicTorsionForceIndex );
}
/**
* Set BrookBondParameters for periodic torsion force
* *
* @param brookBondParameters brookBondParameters for proper dihedral force * @param brookBondParameters brookBondParameters for periodic torsion force
* *
* @return DefaultReturnValue * @return DefaultReturnValue
* *
...@@ -185,9 +302,20 @@ int OpenMMBrookInterface::setPeriodicTorsionForceParameters( BrookBondParameters ...@@ -185,9 +302,20 @@ int OpenMMBrookInterface::setPeriodicTorsionForceParameters( BrookBondParameters
} }
/** /**
* Set BrookBondParameters for RB dihedral force * Get BrookBondParameters for rb torsion force
*
* @return brookBondParameters for rb torsion force
*
*/
BrookBondParameters* OpenMMBrookInterface::getRBTorsionForceParameters( void ) const {
return _getBondParameters( RbTorsionForceIndex );
}
/**
* Set BrookBondParameters for RB torsion force
* *
* @param brookBondParameters brookBondParameters for RB force * @param brookBondParameters brookBondParameters for RB torsion force
* *
* @return DefaultReturnValue * @return DefaultReturnValue
* *
...@@ -197,16 +325,32 @@ int OpenMMBrookInterface::setRBTorsionForceParameters( BrookBondParameters* broo ...@@ -197,16 +325,32 @@ int OpenMMBrookInterface::setRBTorsionForceParameters( BrookBondParameters* broo
return _setBondParameters( RbTorsionForceIndex, brookBondParameters ); return _setBondParameters( RbTorsionForceIndex, brookBondParameters );
} }
/**
* Get BrookBondParameters for LJ 14 force
*
* @return brookBondParameters for LJ 14 force
*
*/
BrookBondParameters* OpenMMBrookInterface::getNonBonded14ForceParameters( void ) const {
return _getBondParameters( LJ14Index );
}
/** /**
* Set BrookBondParameters for LJ 14 force * Set BrookBondParameters for LJ 14 force
* *
* @param brookBondParameters brookBondParameters for LJ 14 force * @param brookBondParameters brookBondParameters for LJ 14 force
* @param lj14Scale LJ 14 scale factor
* @param coulomb14Scale Coulomb 14 scale factor
* *
* @return DefaultReturnValue * @return DefaultReturnValue
* *
*/ */
int OpenMMBrookInterface::setNonBonded14ForceParameters( BrookBondParameters* brookBondParameters ){ int OpenMMBrookInterface::setNonBonded14ForceParameters( BrookBondParameters* brookBondParameters,
double lj14Scale, double coulomb14Scale ){
_lj14Scale = lj14Scale;
_coulomb14Scale = coulomb14Scale;
return _setBondParameters( LJ14Index, brookBondParameters ); return _setBondParameters( LJ14Index, brookBondParameters );
} }
...@@ -373,6 +517,8 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){ ...@@ -373,6 +517,8 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
// static const int debug = 1; // static const int debug = 1;
(void) fprintf( stderr, "%s ", methodName.c_str() ); (void) fflush( stderr );
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// nonbonded forces // nonbonded forces
...@@ -390,6 +536,16 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){ ...@@ -390,6 +536,16 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
if( _brookBonded ){ if( _brookBonded ){
(void) fprintf( stderr, "%s Bonded", methodName.c_str() ); (void) fflush( stderr );
// perform setup first time through
if( _brookBonded->isSetupCompleted() == 0 ){
_brookBonded->setup( getNumberOfParticles(), getHarmonicBondForceParameters(), getHarmonicAngleForceParameters(),
getPeriodicTorsionForceParameters(), getRBTorsionForceParameters(),
getNonBonded14ForceParameters(),
getLj14Scale(), getCoulomb14Scale(), getParticleStreamWidth(), getParticleStreamSize() );
}
_brookBonded->computeForces( *positions, *forces ); _brookBonded->computeForces( *positions, *forces );
// diagnostics // diagnostics
......
...@@ -53,7 +53,7 @@ class OpenMMBrookInterface { ...@@ -53,7 +53,7 @@ class OpenMMBrookInterface {
public: public:
OpenMMBrookInterface( void ); OpenMMBrookInterface( int streamWidth );
~OpenMMBrookInterface(); ~OpenMMBrookInterface();
...@@ -90,6 +90,51 @@ class OpenMMBrookInterface { ...@@ -90,6 +90,51 @@ class OpenMMBrookInterface {
std::string getContents( int level ) const; std::string getContents( int level ) const;
/**
* Get number of particles
*
* @return number of particles
*
*/
int getNumberOfParticles( void ) const;
/**
* Get particle stream width
*
* @return particle stream width
*
*/
int getParticleStreamWidth( void ) const;
/**
* Get particle stream size
*
* @return particle stream size
*
*/
int getParticleStreamSize( void ) const;
/**
* Get LJ-14 scale factor
*
* @return LJ-14 scale factor
*
*/
double getLj14Scale( void ) const;
/**
* Get Coulomb scale factor
*
* @return Coulomb scale factor
*
*/
double getCoulomb14Scale( void ) const;
/** /**
* Get log file reference * Get log file reference
* *
...@@ -169,7 +214,7 @@ class OpenMMBrookInterface { ...@@ -169,7 +214,7 @@ class OpenMMBrookInterface {
* *
*/ */
BrookBondParameters* getHarmonicBondForceParameters( void ); BrookBondParameters* getHarmonicBondForceParameters( void ) const;
/** /**
* Set BrookBondParameters for harmonic bond force * Set BrookBondParameters for harmonic bond force
...@@ -189,7 +234,7 @@ class OpenMMBrookInterface { ...@@ -189,7 +234,7 @@ class OpenMMBrookInterface {
* *
*/ */
BrookBondParameters* getHarmonicAngleForceParameters( void ); BrookBondParameters* getHarmonicAngleForceParameters( void ) const;
/** /**
* Set BrookBondParameters for harmonic angle force * Set BrookBondParameters for harmonic angle force
...@@ -209,7 +254,7 @@ class OpenMMBrookInterface { ...@@ -209,7 +254,7 @@ class OpenMMBrookInterface {
* *
*/ */
BrookBondParameters* getPeriodicTorsionForceParameters( void ); BrookBondParameters* getPeriodicTorsionForceParameters( void ) const;
/** /**
* Set BrookBondParameters for periodic torsion force * Set BrookBondParameters for periodic torsion force
...@@ -229,7 +274,7 @@ class OpenMMBrookInterface { ...@@ -229,7 +274,7 @@ class OpenMMBrookInterface {
* *
*/ */
BrookBondParameters* getRBTorsionForceParameters( void ); BrookBondParameters* getRBTorsionForceParameters( void ) const;
/** /**
* Set BrookBondParameters for RB torsion force * Set BrookBondParameters for RB torsion force
...@@ -249,18 +294,20 @@ class OpenMMBrookInterface { ...@@ -249,18 +294,20 @@ class OpenMMBrookInterface {
* *
*/ */
BrookBondParameters* getNonBonded14ForceParameters( void ); BrookBondParameters* getNonBonded14ForceParameters( void ) const;
/** /**
* Set BrookBondParameters for LJ 14 force * Set BrookBondParameters for LJ 14 force
* *
* @param brookBondParameters brookBondParameters for LJ 14 force * @param brookBondParameters brookBondParameters for LJ 14 force
* @param lj14Scale LJ 14 scale factor
* @param coulomb14Scale Coulomb 14 scale factor
* *
* @return DefaultReturnValue * @return DefaultReturnValue
* *
*/ */
int setNonBonded14ForceParameters( BrookBondParameters* brookBondParameters ); int setNonBonded14ForceParameters( BrookBondParameters* brookBondParameters, double lj14Scale, double coulomb14Scale );
/** /**
* Get positions stream * Get positions stream
...@@ -333,10 +380,16 @@ class OpenMMBrookInterface { ...@@ -333,10 +380,16 @@ class OpenMMBrookInterface {
FILE* _log; FILE* _log;
int _particleStreamWidth;
int _particleStreamSize;
// number of particles // number of particles
int _numberOfParticles; int _numberOfParticles;
double _lj14Scale;
double _coulomb14Scale;
// Brook bonded, nonbonded, Gbsa // Brook bonded, nonbonded, Gbsa
BrookBonded* _brookBonded; BrookBonded* _brookBonded;
...@@ -374,6 +427,17 @@ class OpenMMBrookInterface { ...@@ -374,6 +427,17 @@ class OpenMMBrookInterface {
int _setBondParameters( BondParameterIndices index, BrookBondParameters* brookBondParameters ); int _setBondParameters( BondParameterIndices index, BrookBondParameters* brookBondParameters );
/**
* Get BrookBondParameters at specified index
*
* @param index
*
* @return BrookBondParameters* object
*
*/
BrookBondParameters* _getBondParameters( BondParameterIndices index ) const;
}; };
} // namespace OpenMM } // namespace OpenMM
......
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