Commit 309008f7 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Mods

parent cdee990d
...@@ -49,7 +49,7 @@ const std::string BrookCalcRBTorsionForceKernel::BondName = "RbDihedral"; ...@@ -49,7 +49,7 @@ const std::string BrookCalcRBTorsionForceKernel::BondName = "RbDihedral";
*/ */
BrookCalcRBTorsionForceKernel::BrookCalcRBTorsionForceKernel( std::string name, const Platform& platform, BrookCalcRBTorsionForceKernel::BrookCalcRBTorsionForceKernel( std::string name, const Platform& platform,
OpenMMBrookInterface& openMMBrookInterface, System& system ) : OpenMMBrookInterface& openMMBrookInterface, System& system ) :
CalcRBTorsionForceKernel( name, platform ), _openMMBrookInterface( openMMBrookInterface ), _system( system ){ CalcRBTorsionForceKernel( name, platform ), _openMMBrookInterface( openMMBrookInterface ), _system( system ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -131,21 +131,21 @@ void BrookCalcRBTorsionForceKernel::initialize( const System& system, const RBTo ...@@ -131,21 +131,21 @@ void BrookCalcRBTorsionForceKernel::initialize( const System& system, const RBTo
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// create _brookBondParameters object containing atom indices/parameters // create _brookBondParameters object containing particle indices/parameters
int numberOfBonds = force.getNumTorsions(); int numberOfBonds = force.getNumTorsions();
if( _brookBondParameters ){ if( _brookBondParameters ){
delete _brookBondParameters; delete _brookBondParameters;
} }
_brookBondParameters = new BrookBondParameters( BondName, NumberOfAtomsInBond, NumberOfParametersInBond, numberOfBonds, getLog() ); _brookBondParameters = new BrookBondParameters( BondName, NumberOfParticlesInBond, NumberOfParametersInBond, numberOfBonds, getLog() );
for( int ii = 0; ii < numberOfBonds; ii++ ){ for( int ii = 0; ii < numberOfBonds; ii++ ){
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
double c0, c1, c2, c3, c4, c5; double c0, c1, c2, c3, c4, c5;
int particles[NumberOfAtomsInBond]; int particles[NumberOfParticlesInBond];
double parameters[NumberOfParametersInBond]; double parameters[NumberOfParametersInBond];
force.getTorsionParameters( ii, particle1, particle2, particle3, particle4, c0, c1, c2, c3, c4, c5 ); force.getTorsionParameters( ii, particle1, particle2, particle3, particle4, c0, c1, c2, c3, c4, c5 );
...@@ -178,7 +178,7 @@ void BrookCalcRBTorsionForceKernel::initialize( const System& system, const RBTo ...@@ -178,7 +178,7 @@ void BrookCalcRBTorsionForceKernel::initialize( const System& system, const RBTo
} }
/** /**
* Compute forces given atom coordinates * Compute forces given particle coordinates
* *
* @param context OpenMMContextImpl context * @param context OpenMMContextImpl context
* *
......
...@@ -72,7 +72,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel { ...@@ -72,7 +72,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
/** /**
* Execute the kernel to calculate the forces. * Execute the kernel to calculate the forces.
* *
* @param positions atom coordiantes * @param positions particle coordiantes
* @param forces output forces * @param forces output forces
* *
*/ */
...@@ -133,7 +133,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel { ...@@ -133,7 +133,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
/** /**
* Get indices/parameters * Get indices/parameters
* *
* @return BrookBondParameters containing atom indices/parameters * @return BrookBondParameters containing particle indices/parameters
* *
*/ */
...@@ -141,7 +141,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel { ...@@ -141,7 +141,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
private: private:
static const int NumberOfAtomsInBond = 4; static const int NumberOfParticlesInBond = 4;
static const int NumberOfParametersInBond = 6; static const int NumberOfParametersInBond = 6;
// bond name // bond name
......
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs *
* Contributors: *
* *
* 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. *
* -------------------------------------------------------------------------- */
#include <cmath>
#include <limits>
#include "OpenMMException.h"
#include <sstream>
#include "BrookStreamImpl.h"
#include "BrookCalcNonbondedForceKernel.h"
#include "gpu/kforce.h"
#include "gpu/kinvmap_gather.h"
#include "NonbondedForce.h"
using namespace OpenMM;
using namespace std;
/**
* BrookCalcNonbondedForceKernel constructor
*
* @param name kernel name
* @param platform platform
*
*/
BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel( std::string name, const Platform& platform ) :
CalcNonbondedForceKernel( name, platform ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel";
// ---------------------------------------------------------------------------------------
_numberOfAtoms = 0;
_brookBonded = NULL;
_brookNonBonded = NULL;
_refForceField = NULL;
_log = NULL;
_refForceField = NULL;
_refSystem = NULL;
_refOpenMMContext = NULL;
_referencePlatform = NULL;
_refVerletIntegrator = NULL;
const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
if( brookPlatform.getLog() != NULL ){
setLog( brookPlatform.getLog() );
}
}
/**
* BrookCalcNonbondedForceKernel destructor
*
*/
BrookCalcNonbondedForceKernel::~BrookCalcNonbondedForceKernel( ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel";
// ---------------------------------------------------------------------------------------
delete _brookBonded;
delete _brookNonBonded;
// deleted w/ kernel delete? If activated, program crashes
//delete _refForceField;
/*
delete _refSystem;
delete _refOpenMMContext;
delete _referencePlatform;
delete _refVerletIntegrator;
*/
}
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE* BrookCalcNonbondedForceKernel::getLog( void ) const {
return _log;
}
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int BrookCalcNonbondedForceKernel::setLog( FILE* log ){
_log = log;
return BrookCommon::DefaultReturnValue;
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param bondIndices the two atoms connected by each bond term
* @param bondParameters the force parameters (length, k) for each bond term
* @param angleIndices the three atoms connected by each angle term
* @param angleParameters the force parameters (angle, k) for each angle term
* @param periodicTorsionIndices the four atoms connected by each periodic torsion term
* @param periodicTorsionParameters the force parameters (k, phase, periodicity) for each periodic torsion term
* @param rbTorsionIndices the four atoms connected by each Ryckaert-Bellemans torsion term
* @param rbTorsionParameters the coefficients (in order of increasing powers) for each Ryckaert-Bellemans torsion term
* @param bonded14Indices each element contains the indices of two atoms whose nonbonded interactions should be reduced since
* they form a bonded 1-4 pair
* @param lj14Scale the factor by which van der Waals interactions should be reduced for bonded 1-4 pairs
* @param coulomb14Scale the factor by which Coulomb interactions should be reduced for bonded 1-4 pairs
* @param exclusions the i'th element lists the indices of all atoms with which the i'th atom should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation.
* @param nonbondedParameters the nonbonded force parameters (charge, sigma, epsilon) for each atom
* @param nonbondedMethod the method to use for handling long range nonbonded interactions
* @param nonbondedCutoff the cutoff distance for nonbonded interactions (if nonbondedMethod involves a cutoff)
* @param periodicBoxSize the size of the periodic box (if nonbondedMethod involves a periodic boundary conditions)
*/
void BrookCalcNonbondedForceKernel::initialize(
const vector<vector<int> >& bondIndices, const vector<vector<double> >& bondParameters,
const vector<vector<int> >& angleIndices, const vector<vector<double> >& angleParameters,
const vector<vector<int> >& periodicTorsionIndices, const vector<vector<double> >& periodicTorsionParameters,
const vector<vector<int> >& rbTorsionIndices, const vector<vector<double> >& rbTorsionParameters,
const vector<vector<int> >& bonded14Indices, double lj14Scale, double coulomb14Scale,
const vector<set<int> >& exclusions, const vector<vector<double> >& nonbondedParameters,
NonbondedMethod nonbondedMethod, double nonbondedCutoff, double periodicBoxSize[3] ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookCalcNonbondedForceKernel::initialize";
// ---------------------------------------------------------------------------------------
FILE* log = getLog();
_numberOfAtoms = nonbondedParameters.size();
// ---------------------------------------------------------------------------------------
// bonded
if( _brookBonded ){
delete _brookBonded;
}
_brookBonded = new BrookBonded();
_brookBonded->setLog( log );
_brookBonded->setup( _numberOfAtoms,
bondIndices, bondParameters,
angleIndices, angleParameters,
periodicTorsionIndices, periodicTorsionParameters,
rbTorsionIndices, rbTorsionParameters,
bonded14Indices, nonbondedParameters,
lj14Scale, coulomb14Scale, getPlatform() );
// echo contents
if( log ){
std::string contents = _brookBonded->getContentsString( );
(void) fprintf( log, "%s brookBonded::contents\n%s", methodName.c_str(), contents.c_str() );
(void) fflush( log );
}
// ---------------------------------------------------------------------------------------
// nonbonded
if( _brookNonBonded ){
delete _brookNonBonded;
}
_brookNonBonded = new BrookNonBonded();
_brookNonBonded->setLog( log );
_brookNonBonded->setup( _numberOfAtoms, nonbondedParameters, exclusions, getPlatform() );
// echo contents
if( log ){
std::string contents = _brookNonBonded->getContentsString( );
(void) fprintf( log, "%s brookNonBonded::contents\n%s", methodName.c_str(), contents.c_str() );
(void) fflush( log );
}
// ---------------------------------------------------------------------------------------
// used for calculating energy
/*
_referenceCalcNonbondedForceKernel = new ReferenceCalcNonbondedForceKernel( getName(), getPlatform() );
_referenceCalcNonbondedForceKernel->initialize( bondIndices, bondParameters,
angleIndices, angleParameters,
periodicTorsionIndices, periodicTorsionParameters,
rbTorsionIndices, rbTorsionParameters,
bonded14Indices, lj14Scale, coulomb14Scale,
exclusions, nonbondedParameters,
nonbondedMethod, nonbondedCutoff, periodicBoxSize );
*/
_refForceField = new NonbondedForce( _numberOfAtoms, bondIndices.size(), angleIndices.size(),
periodicTorsionIndices.size(), rbTorsionIndices.size() );
// bonds
vector<vector<int> >::const_iterator bondI_it = bondIndices.begin();
vector<vector<double> >::const_iterator bondP_it = bondParameters.begin();
for( unsigned int ii = 0; ii < bondIndices.size(); ii++, bondI_it++, bondP_it++ ){
const vector<int> bondInd = *bondI_it;
const vector<double> bondPrm = *bondP_it;
_refForceField->setBondParameters( ii, bondInd[0], bondInd[1], bondPrm[0], bondPrm[1] );
}
// angles
vector<vector<int> >::const_iterator angleI_it = angleIndices.begin();
vector<vector<double> >::const_iterator angleP_it = angleParameters.begin();
for( unsigned int ii = 0; ii < angleIndices.size(); ii++, angleI_it++, angleP_it++ ){
const vector<int> angleInd = *angleI_it;
const vector<double> anglePrm = *angleP_it;
_refForceField->setAngleParameters( ii, angleInd[0], angleInd[1], angleInd[2], anglePrm[0], anglePrm[1] );
}
// periodicTorsions
vector<vector<int> >::const_iterator periodicTorsionI_it = periodicTorsionIndices.begin();
vector<vector<double> >::const_iterator periodicTorsionP_it = periodicTorsionParameters.begin();
for( unsigned int ii = 0; ii < periodicTorsionIndices.size(); ii++, periodicTorsionI_it++, periodicTorsionP_it++ ){
const vector<int> periodicTorsionInd = *periodicTorsionI_it;
const vector<double> periodicTorsionPrm = *periodicTorsionP_it;
_refForceField->setPeriodicTorsionParameters( ii, periodicTorsionInd[0], periodicTorsionInd[1], periodicTorsionInd[2], periodicTorsionInd[3],
(int) (periodicTorsionPrm[2] + 0.001), periodicTorsionPrm[1], periodicTorsionPrm[0] );
/*
printf( "PeriodicTor: [%d %d %d %d] [%.5e %.5e %.5e]\n", periodicTorsionInd[0], periodicTorsionInd[1], periodicTorsionInd[2], periodicTorsionInd[3],
periodicTorsionPrm[2], periodicTorsionPrm[1], periodicTorsionPrm[0] ); fflush( stdout );
*/
}
// rbTorsions
vector<vector<int> >::const_iterator rbTorsionI_it = rbTorsionIndices.begin();
vector<vector<double> >::const_iterator rbTorsionP_it = rbTorsionParameters.begin();
for( unsigned int ii = 0; ii < rbTorsionIndices.size(); ii++, rbTorsionI_it++, rbTorsionP_it++ ){
const vector<int> rbTorsionInd = *rbTorsionI_it;
const vector<double> rbTorsionPrm = *rbTorsionP_it;
_refForceField->setRBTorsionParameters( ii, rbTorsionInd[0], rbTorsionInd[1], rbTorsionInd[2], rbTorsionInd[3],
rbTorsionPrm[0], rbTorsionPrm[1], rbTorsionPrm[2], rbTorsionPrm[3],
rbTorsionPrm[4], rbTorsionPrm[5] );
/*
printf( "RbTor: [%d %d %d %d] [%.5e %.5e %.5e %.5e %.5e %.5e]\n", rbTorsionInd[0], rbTorsionInd[1], rbTorsionInd[2], rbTorsionInd[3],
rbTorsionPrm[0], rbTorsionPrm[1], rbTorsionPrm[2], rbTorsionPrm[3], rbTorsionPrm[4], rbTorsionPrm[5] ); fflush( stdout );
*/
}
// nonbonded
for( unsigned int ii = 0; ii < nonbondedParameters.size(); ii++ ){
vector<double> nonbondedParameterVector
= nonbondedParameters[ii];
double c6 = nonbondedParameterVector[1];
double c12 = nonbondedParameterVector[2];
double charge = nonbondedParameterVector[0];
// int index, double charge, double radius, double depth
_refForceField->setAtomParameters( ii, charge, c6, c12 );
}
// ---------------------------------------------------------------------------------------
return;
}
/**
* Execute the kernel to calculate the bonded & nonbonded forces
*
* @param positions stream of type Double3 containing the position (x, y, z) of each atom
* @param forces stream of type Double3 containing the force (x, y, z) on each atom. On entry, this contains the forces that
* have been calculated so far. The kernel should add its own forces to the values already in the stream.
*/
void BrookCalcNonbondedForceKernel::executeForces( const Stream& positions, Stream& forces ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookCalcNonbondedForceKernel::executeForces";
static const int I_Stream = 0;
static const int J_Stream = 1;
static const int K_Stream = 2;
static const int L_Stream = 3;
static const int PrintOn = 0;
static const int MaxErrorMessages = 2;
static int ErrorMessages = 0;
static const float4 dummyParameters( 0.0, 0.0, 0.0, 0.0 );
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
const BrookStreamImpl& positionStreamC = dynamic_cast<const BrookStreamImpl&> (positions.getImpl());
BrookStreamImpl& positionStream = const_cast<BrookStreamImpl&> (positionStreamC);
BrookStreamImpl& forceStream = dynamic_cast<BrookStreamImpl&> (forces.getImpl());
// nonbonded forces
// added charge stream to knbforce_CDLJ4
// libs generated from ~/src/gmxgpu-nsqOpenMM
BrookFloatStreamInternal** nonbondedForceStreams = _brookNonBonded->getForceStreams();
float epsfac = 138.935485f;
knbforce_CDLJ4(
(float) _brookNonBonded->getNumberOfAtoms(),
(float) _brookNonBonded->getAtomSizeCeiling(),
(float) _brookNonBonded->getDuplicationFactor(),
(float) _brookNonBonded->getAtomStreamHeight( ),
(float) _brookNonBonded->getAtomStreamWidth( ),
(float) _brookNonBonded->getJStreamWidth( ),
(float) _brookNonBonded->getPartialForceStreamWidth( ),
epsfac,
dummyParameters,
positionStream.getBrookStream(),
_brookNonBonded->getChargeStream()->getBrookStream(),
_brookNonBonded->getOuterVdwStream()->getBrookStream(),
_brookNonBonded->getInnerSigmaStream()->getBrookStream(),
_brookNonBonded->getInnerEpsilonStream()->getBrookStream(),
_brookNonBonded->getExclusionStream()->getBrookStream(),
nonbondedForceStreams[0]->getBrookStream(),
nonbondedForceStreams[1]->getBrookStream(),
nonbondedForceStreams[2]->getBrookStream(),
nonbondedForceStreams[3]->getBrookStream()
);
/*
float zerof = 0.0f;
nonbondedForceStreams[0]->fillWithValue( &zerof );
nonbondedForceStreams[1]->fillWithValue( &zerof );
nonbondedForceStreams[2]->fillWithValue( &zerof );
nonbondedForceStreams[3]->fillWithValue( &zerof );
*/
// diagnostics
if( 1 && PrintOn ){
(void) fprintf( getLog(), "\nPost knbforce_CDLJ4: atoms=%6d ceiling=%3d dupFac=%3d", _brookNonBonded->getNumberOfAtoms(),
_brookNonBonded->getAtomSizeCeiling(),
_brookNonBonded->getDuplicationFactor() );
(void) fprintf( getLog(), "\n hght=%6d width=%3d jWid=%3d", _brookNonBonded->getAtomStreamHeight( ),
_brookNonBonded->getAtomStreamWidth( ),
_brookNonBonded->getJStreamWidth( ) );
(void) fprintf( getLog(), "\n pFrc=%6d eps=%12.5e\n", _brookNonBonded->getPartialForceStreamWidth( ), epsfac );
(void) fprintf( getLog(), "\nOuterVdwStreamd\n" );
_brookNonBonded->getOuterVdwStream()->printToFile( getLog() );
(void) fprintf( getLog(), "\nInnerSigmaStream\n" );
_brookNonBonded->getInnerSigmaStream()->printToFile( getLog() );
(void) fprintf( getLog(), "\nInnerEpsilonStream\n" );
_brookNonBonded->getInnerEpsilonStream()->printToFile( getLog() );
(void) fprintf( getLog(), "\nExclusionStream\n" );
_brookNonBonded->getExclusionStream()->printToFile( getLog() );
(void) fprintf( getLog(), "\nChargeStream\n" );
_brookNonBonded->getChargeStream()->printToFile( getLog() );
for( int ii = 0; ii < 4; ii++ ){
(void) fprintf( getLog(), "\nForce stream %d\n", ii );
nonbondedForceStreams[ii]->printToFile( getLog() );
}
}
// ---------------------------------------------------------------------------------------
// gather forces
kMergeFloat3_4_nobranch( (float) _brookNonBonded->getDuplicationFactor(),
(float) _brookNonBonded->getAtomStreamWidth(),
(float) _brookNonBonded->getPartialForceStreamWidth(),
(float) _brookNonBonded->getNumberOfAtoms(),
(float) _brookNonBonded->getAtomSizeCeiling(),
(float) _brookNonBonded->getOuterLoopUnroll(),
nonbondedForceStreams[0]->getBrookStream(),
nonbondedForceStreams[1]->getBrookStream(),
nonbondedForceStreams[2]->getBrookStream(),
nonbondedForceStreams[3]->getBrookStream(),
forceStream.getBrookStream() );
// diagnostics
if( 0 && PrintOn ){
(void) fprintf( getLog(), "\nNB forces" );
BrookStreamInternal* brookStreamInternalF = forceStream.getBrookStreamImpl();
brookStreamInternalF->printToFile( getLog() );
}
// ---------------------------------------------------------------------------------------
// bonded
epsfac = (float) (_brookBonded->getLJ_14Scale()*_brookBonded->getCoulombFactor());
float width = (float) (_brookBonded->getInverseMapStreamWidth());
// bonded forces
BrookFloatStreamInternal** bondedParameters = _brookBonded->getBondedParameterStreams();
BrookFloatStreamInternal** bondedForceStreams = _brookBonded->getBondedForceStreams();
BrookFloatStreamInternal** inverseStreamMaps[4];
inverseStreamMaps[0] = _brookBonded->getInverseStreamMapsStreams( 0 );
inverseStreamMaps[1] = _brookBonded->getInverseStreamMapsStreams( 1 );
inverseStreamMaps[2] = _brookBonded->getInverseStreamMapsStreams( 2 );
inverseStreamMaps[3] = _brookBonded->getInverseStreamMapsStreams( 3 );
kbonded_CDLJ( epsfac,
(float) bondedForceStreams[0]->getStreamWidth(),
dummyParameters,
positionStream.getBrookStream(),
_brookBonded->getChargeStream()->getBrookStream(),
_brookBonded->getAtomIndicesStream()->getBrookStream(),
bondedParameters[0]->getBrookStream(),
bondedParameters[1]->getBrookStream(),
bondedParameters[2]->getBrookStream(),
bondedParameters[3]->getBrookStream(),
bondedParameters[4]->getBrookStream(),
bondedForceStreams[0]->getBrookStream(),
bondedForceStreams[1]->getBrookStream(),
bondedForceStreams[2]->getBrookStream(),
bondedForceStreams[3]->getBrookStream() );
// diagnostics
if( 1 && PrintOn ){
int countPrintInvMap[4] = { 3, 5, 2, 4 };
(void) fprintf( getLog(), "\nPost kbonded_CDLJ: epsFac=%.6f %.6f %.6f", epsfac, _brookBonded->getLJ_14Scale(), _brookBonded->getCoulombFactor());
(void) fprintf( getLog(), "\nAtom indices stream\n" );
_brookBonded->getAtomIndicesStream()->printToFile( getLog() );
(void) fprintf( getLog(), "\nCharge stream\n" );
_brookBonded->getChargeStream()->printToFile( getLog() );
for( int ii = 0; ii < 5; ii++ ){
(void) fprintf( getLog(), "\nParam stream %d\n", ii );
bondedParameters[ii]->printToFile( getLog() );
}
for( int ii = 0; ii < 4; ii++ ){
(void) fprintf( getLog(), "\nForce stream %d\n", ii );
bondedForceStreams[ii]->printToFile( getLog() );
}
/*
(void) fprintf( getLog(), "\nNB1 forces" );
BrookStreamInternal* brookStreamInternalF = forceStream.getBrookStreamImpl();
brookStreamInternalF->printToFile( getLog() );
*/
(void) fprintf( getLog(), "\nInverse map streams -- K_Stream cnt=%d\n", _brookBonded->getInverseMapStreamCount( K_Stream ) );
for( int ii = 0; ii < 4; ii++ ){
for( int jj = 0; jj < countPrintInvMap[ii]; jj++ ){
(void) fprintf( getLog(), "\n Inverse map streams index=%d %d\n", ii, jj );
inverseStreamMaps[ii][jj]->printToFile( getLog() );
}
}
}
// gather forces
if( _brookBonded->getInverseMapStreamCount( I_Stream ) == 3 && _brookBonded->getInverseMapStreamCount( K_Stream ) == 3 ){
kinvmap_gather3_3( width,
inverseStreamMaps[I_Stream][0]->getBrookStream(),
inverseStreamMaps[I_Stream][1]->getBrookStream(),
inverseStreamMaps[I_Stream][2]->getBrookStream(),
bondedForceStreams[I_Stream]->getBrookStream(),
inverseStreamMaps[K_Stream][0]->getBrookStream(),
inverseStreamMaps[K_Stream][1]->getBrookStream(),
inverseStreamMaps[K_Stream][2]->getBrookStream(),
bondedForceStreams[K_Stream]->getBrookStream(),
forceStream.getBrookStream(), forceStream.getBrookStream() );
} else if( _brookBonded->getInverseMapStreamCount( I_Stream ) == 3 && _brookBonded->getInverseMapStreamCount( K_Stream ) == 4 ){
kinvmap_gather3_4( width,
inverseStreamMaps[I_Stream][0]->getBrookStream(),
inverseStreamMaps[I_Stream][1]->getBrookStream(),
inverseStreamMaps[I_Stream][2]->getBrookStream(),
bondedForceStreams[I_Stream]->getBrookStream(),
inverseStreamMaps[K_Stream][0]->getBrookStream(),
inverseStreamMaps[K_Stream][1]->getBrookStream(),
inverseStreamMaps[K_Stream][2]->getBrookStream(),
inverseStreamMaps[K_Stream][3]->getBrookStream(),
bondedForceStreams[K_Stream]->getBrookStream(),
forceStream.getBrookStream(), forceStream.getBrookStream() );
} else if( _brookBonded->getInverseMapStreamCount( I_Stream ) == 3 && _brookBonded->getInverseMapStreamCount( K_Stream ) == 5 ){
kinvmap_gather3_5( width,
inverseStreamMaps[I_Stream][0]->getBrookStream(),
inverseStreamMaps[I_Stream][1]->getBrookStream(),
inverseStreamMaps[I_Stream][2]->getBrookStream(),
bondedForceStreams[I_Stream]->getBrookStream(),
inverseStreamMaps[K_Stream][0]->getBrookStream(),
inverseStreamMaps[K_Stream][1]->getBrookStream(),
inverseStreamMaps[K_Stream][2]->getBrookStream(),
inverseStreamMaps[K_Stream][3]->getBrookStream(),
inverseStreamMaps[K_Stream][4]->getBrookStream(),
bondedForceStreams[K_Stream]->getBrookStream(),
forceStream.getBrookStream(), forceStream.getBrookStream() );
} else {
// case not handled -- throw an exception
if( _brookBonded->getLog() && ErrorMessages++ < MaxErrorMessages ){
(void) fprintf( _brookBonded->getLog(), "%s case: I-map=%d K-map=%d -- not handled.\n",
methodName.c_str(), _brookBonded->getInverseMapStreamCount( I_Stream ),
_brookBonded->getInverseMapStreamCount( K_Stream ) );
(void) fflush( _brookBonded->getLog() );
}
kinvmap_gather3_3( width,
inverseStreamMaps[I_Stream][0]->getBrookStream(),
inverseStreamMaps[I_Stream][1]->getBrookStream(),
inverseStreamMaps[I_Stream][2]->getBrookStream(),
bondedForceStreams[I_Stream]->getBrookStream(),
inverseStreamMaps[K_Stream][0]->getBrookStream(),
inverseStreamMaps[K_Stream][1]->getBrookStream(),
inverseStreamMaps[K_Stream][2]->getBrookStream(),
bondedForceStreams[K_Stream]->getBrookStream(),
forceStream.getBrookStream(), forceStream.getBrookStream() );
/*
std::stringstream message;
message << methodName << "I-maps=" << _brookBonded->getInverseMapStreamCount( I_Stream ) << " and " <<
"K-maps=" << _brookBonded->getInverseMapStreamCount( K_Stream ) << " not handled.";
throw OpenMMException( message.str() );
*/
}
// diagnostics
if( 0 && PrintOn ){
(void) fprintf( getLog(), "\nPost 3_4/3_5 && NB forces" );
BrookStreamInternal* brookStreamInternalF = forceStream.getBrookStreamImpl();
brookStreamInternalF->printToFile( getLog() );
}
if( _brookBonded->getInverseMapStreamCount( J_Stream ) == 5 && _brookBonded->getInverseMapStreamCount( L_Stream ) == 2 ){
kinvmap_gather5_2( width,
inverseStreamMaps[J_Stream][0]->getBrookStream(),
inverseStreamMaps[J_Stream][1]->getBrookStream(),
inverseStreamMaps[J_Stream][2]->getBrookStream(),
inverseStreamMaps[J_Stream][3]->getBrookStream(),
inverseStreamMaps[J_Stream][4]->getBrookStream(),
bondedForceStreams[J_Stream]->getBrookStream(),
inverseStreamMaps[L_Stream][0]->getBrookStream(),
inverseStreamMaps[L_Stream][1]->getBrookStream(),
bondedForceStreams[L_Stream]->getBrookStream(),
forceStream.getBrookStream(), forceStream.getBrookStream() );
} else {
// case not handled -- throw an exception
if( _brookBonded->getLog() && ErrorMessages++ < MaxErrorMessages ){
(void) fprintf( _brookBonded->getLog(), "%s case: J-map=%d L-map=%d -- not handled.\n",
methodName.c_str(), _brookBonded->getInverseMapStreamCount( J_Stream ),
_brookBonded->getInverseMapStreamCount( L_Stream ) );
(void) fflush( _brookBonded->getLog() );
}
kinvmap_gather5_2( width,
inverseStreamMaps[J_Stream][0]->getBrookStream(),
inverseStreamMaps[J_Stream][1]->getBrookStream(),
inverseStreamMaps[J_Stream][2]->getBrookStream(),
inverseStreamMaps[J_Stream][3]->getBrookStream(),
inverseStreamMaps[J_Stream][4]->getBrookStream(),
bondedForceStreams[J_Stream]->getBrookStream(),
inverseStreamMaps[L_Stream][0]->getBrookStream(),
inverseStreamMaps[L_Stream][1]->getBrookStream(),
bondedForceStreams[L_Stream]->getBrookStream(),
forceStream.getBrookStream(), forceStream.getBrookStream() );
/*
std::stringstream message;
message << methodName << "J-maps=" << _brookBonded->getInverseMapStreamCount( J_Stream ) << " and " <<
"L-maps=" << _brookBonded->getInverseMapStreamCount( L_Stream ) << " not handled.";
throw OpenMMException( message.str() );
*/
}
// diagnostics
if( 1 && PrintOn ){
(void) fprintf( getLog(), "\nFinal NB & bonded forces" );
BrookStreamInternal* brookStreamInternalF = forceStream.getBrookStreamImpl();
brookStreamInternalF->printToFile( getLog() );
/*
void* dataV = brookStreamInternalF->getData(1);
float* data = (float*) dataV;
(void) fprintf( getLog(), "\nFinal NB & bonded forces RAW\n" );
for( int ii = 0; ii < _brookNonBonded->getNumberOfAtoms()*3; ii += 3 ){
(void) fprintf( getLog(), "%d [%.6e %.6e %.6e]\n", ii, data[ii], data[ii+1], data[ii+2] );
}
*/
}
// ---------------------------------------------------------------------------------------
}
/**
* Execute the kernel to calculate the energy.
*
* @param positions atom positions
*
* @return potential energy due to the NonbondedForce
* Currently always return 0.0 since energies not calculated on gpu
*
*/
double BrookCalcNonbondedForceKernel::executeEnergy( const Stream& atomPositions ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcNonbondedForceKernel::executeEnergy";
// ---------------------------------------------------------------------------------------
const BrookStreamImpl& positionStreamC = dynamic_cast<const BrookStreamImpl&> (atomPositions.getImpl());
BrookStreamImpl& positionStream = const_cast<BrookStreamImpl&> (positionStreamC);
BrookOpenMMFloat* positionsF = (BrookOpenMMFloat*) positionStream.getData();
OpenMMContext* context = getReferenceOpenMMContext( atomPositions.getSize() );
vector<Vec3> positions( positionStream.getSize() );
int index = 0;
for( int ii = 0; ii < positionStream.getSize(); ii++, index += 3 ){
positions[ii] = Vec3( positionsF[index], positionsF[index+1], positionsF[index+2] );
}
context->setPositions(positions);
State state = context->getState( State::Energy );
double energy = state.getPotentialEnergy();
// (void) fprintf( stdout, "BrookCalcNonbondedForceKernel::executeEnergy E=%.5e\n", energy ); fflush( stdout );
return energy;
}
/**
* Get reference Context
*
* @param numberOfAtoms number of atoms
*
* @return OpenMMContext
*
*/
OpenMMContext* BrookCalcNonbondedForceKernel::getReferenceOpenMMContext( int numberOfAtoms ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcNonbondedForceKernel::getReferenceOpenMMContext";
// ---------------------------------------------------------------------------------------
if( _refOpenMMContext == NULL ){
_referencePlatform = new ReferencePlatform();
_refSystem = new System( numberOfAtoms, 0 );
_refVerletIntegrator = new VerletIntegrator( 0.01 );
_refSystem->addForce( _refForceField );
_refOpenMMContext = new OpenMMContext( *_refSystem, *_refVerletIntegrator, *_referencePlatform );
}
return _refOpenMMContext;
}
/**
* Execute the kernel to calculate the energy.
*
* @param positions atom positions
*
* @return potential energy due to the NonbondedForce
* Currently always return 0.0 since energies not calculated on gpu
*
*/
double BrookCalcNonbondedForceKernel::executeEnergyOld( const Stream& atomPositions ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcNonbondedForceKernel::executeEnergy";
// ---------------------------------------------------------------------------------------
const BrookStreamImpl& positionStreamC = dynamic_cast<const BrookStreamImpl&> (atomPositions.getImpl());
BrookStreamImpl& positionStream = const_cast<BrookStreamImpl&> (positionStreamC);
BrookOpenMMFloat* positionsF = (BrookOpenMMFloat*) positionStream.getData();
ReferencePlatform refPlatform;
System system( atomPositions.getSize(), 0);
VerletIntegrator integrator( 0.01 );
system.addForce( _refForceField );
OpenMMContext context( system, integrator, refPlatform );
vector<Vec3> positions( positionStream.getSize() );
int index = 0;
for( int ii = 0; ii < positionStream.getSize(); ii++, index += 3 ){
positions[ii] = Vec3( positionsF[index], positionsF[index+1], positionsF[index+2] );
}
context.setPositions(positions);
State state = context.getState( State::Energy );
double energy = state.getPotentialEnergy();
//delete forceField;
// (void) fprintf( stdout, "BrookCalcNonbondedForceKernel::executeEnergy E=%.5e\n", energy ); fflush( stdout );
return energy;
}
...@@ -44,7 +44,7 @@ using namespace std; ...@@ -44,7 +44,7 @@ using namespace std;
// bonded streams // bonded streams
const std::string BrookCommon::BondedAtomIndicesStream = "BondedAtomIndicesStream"; const std::string BrookCommon::BondedParticleIndicesStream = "BondedParticleIndicesStream";
const std::string BrookCommon::BondedParametersStream = "BondedParametersStream"; const std::string BrookCommon::BondedParametersStream = "BondedParametersStream";
const std::string BrookCommon::UnrolledForceStream = "UnrolledForceStream"; const std::string BrookCommon::UnrolledForceStream = "UnrolledForceStream";
const std::string BrookCommon::BondedChargeStream = "BondedChargeStream"; const std::string BrookCommon::BondedChargeStream = "BondedChargeStream";
...@@ -61,9 +61,9 @@ const std::string BrookCommon::PartialForceStream ...@@ -61,9 +61,9 @@ const std::string BrookCommon::PartialForceStream
// OBC Gbsa streams // OBC Gbsa streams
const std::string BrookCommon::ObcAtomicRadiiStream = "ObcAtomicRadiiStream"; const std::string BrookCommon::ObcParticleRadiiStream = "ObcParticleRadiiStream";
const std::string BrookCommon::ObcScaledAtomicRadiiStream = "ObcScaledAtomicRadiiStream"; const std::string BrookCommon::ObcScaledParticleRadiiStream = "ObcScaledParticleRadiiStream";
const std::string BrookCommon::ObcAtomicRadiiWithDielectricOffsetStream = "ObcAtomicRadiiWithDielectricOffsetStream"; const std::string BrookCommon::ObcParticleRadiiWithDielectricOffsetStream = "ObcParticleRadiiWithDielectricOffsetStream";
const std::string BrookCommon::ObcBornRadiiStream = "ObcBornRadiiStream"; const std::string BrookCommon::ObcBornRadiiStream = "ObcBornRadiiStream";
const std::string BrookCommon::ObcBornRadii2Stream = "ObcBornRadii2Stream"; const std::string BrookCommon::ObcBornRadii2Stream = "ObcBornRadii2Stream";
const std::string BrookCommon::ObcIntermediateForceStream = "ObcIntermediateForceStream"; const std::string BrookCommon::ObcIntermediateForceStream = "ObcIntermediateForceStream";
...@@ -81,8 +81,8 @@ const std::string BrookCommon::InverseMassStream ...@@ -81,8 +81,8 @@ const std::string BrookCommon::InverseMassStream
// Shake streams // Shake streams
const std::string BrookCommon::ShakeAtomIndicesStream = "ShakeAtomIndicesStream"; const std::string BrookCommon::ShakeParticleIndicesStream = "ShakeParticleIndicesStream";
const std::string BrookCommon::ShakeAtomParameterStream = "ShakeAtomParameterStream"; const std::string BrookCommon::ShakeParticleParameterStream = "ShakeParticleParameterStream";
const std::string BrookCommon::ShakeXCons0Stream = "ShakeXCons0Stream"; const std::string BrookCommon::ShakeXCons0Stream = "ShakeXCons0Stream";
const std::string BrookCommon::ShakeXCons1Stream = "ShakeXCons1Stream"; const std::string BrookCommon::ShakeXCons1Stream = "ShakeXCons1Stream";
const std::string BrookCommon::ShakeXCons2Stream = "ShakeXCons2Stream"; const std::string BrookCommon::ShakeXCons2Stream = "ShakeXCons2Stream";
...@@ -112,15 +112,15 @@ BrookCommon::BrookCommon( ){ ...@@ -112,15 +112,15 @@ BrookCommon::BrookCommon( ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
_numberOfAtoms = 0; _numberOfParticles = 0;
_atomSizeModified = 0; _particleSizeModified = 0;
_atomStreamWidth = -1; _particleStreamWidth = -1;
_atomStreamHeight = -1; _particleStreamHeight = -1;
_atomStreamSize = -1; _particleStreamSize = -1;
_log = NULL; _log = NULL;
_verbosity = 0; _verbosity = 0;
} }
...@@ -141,182 +141,182 @@ BrookCommon::~BrookCommon( ){ ...@@ -141,182 +141,182 @@ BrookCommon::~BrookCommon( ){
} }
/** /**
* Get number of atoms * Get number of particles
* *
* @return number of atoms * @return number of particles
* *
*/ */
int BrookCommon::getNumberOfAtoms( void ) const { int BrookCommon::getNumberOfParticles( void ) const {
return _numberOfAtoms; return _numberOfParticles;
} }
/** /**
* Get number of atoms * Get number of particles
* *
* @param numberOfAtoms number of atoms * @param numberOfParticles number of particles
* @return number of atoms * @return number of particles
* *
*/ */
int BrookCommon::setNumberOfAtoms( int numberOfAtoms ){ int BrookCommon::setNumberOfParticles( int numberOfParticles ){
if( numberOfAtoms != _numberOfAtoms ){ if( numberOfParticles != _numberOfParticles ){
_atomSizeModified = numberOfAtoms; _particleSizeModified = numberOfParticles;
} }
_numberOfAtoms = numberOfAtoms; _numberOfParticles = numberOfParticles;
return _numberOfAtoms; return _numberOfParticles;
} }
/** /**
* Get atom stream width * Get particle stream width
* *
* @param platform platform * @param platform platform
* *
* @return atom stream width * @return particle stream width
* *
*/ */
int BrookCommon::getAtomStreamWidth( const Platform& platform ){ int BrookCommon::getParticleStreamWidth( const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamWidth"; // static const std::string methodName = "BrookCommon::getParticleStreamWidth";
// static const int debug = 1; // static const int debug = 1;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// get atom stream width // get particle stream width
if( _atomStreamWidth < 0 ){ if( _particleStreamWidth < 0 ){
_getAtomStreamDimensions( platform ); _getParticleStreamDimensions( platform );
} }
return _atomStreamWidth; return _particleStreamWidth;
} }
/** /**
* Get atom stream width * Get particle stream width
* *
* @return atom stream width * @return particle stream width
* *
*/ */
int BrookCommon::getAtomStreamWidth( void ) const { int BrookCommon::getParticleStreamWidth( void ) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamWidth"; // static const std::string methodName = "BrookCommon::getParticleStreamWidth";
// static const int debug = 1; // static const int debug = 1;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
return _atomStreamWidth; return _particleStreamWidth;
} }
/** /**
* Get atom stream height * Get particle stream height
* *
* @param platform platform * @param platform platform
* *
* @return atom stream height * @return particle stream height
* *
*/ */
int BrookCommon::getAtomStreamHeight( const Platform& platform ){ int BrookCommon::getParticleStreamHeight( const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamHeight"; // static const std::string methodName = "BrookCommon::getParticleStreamHeight";
// static const int debug = 1; // static const int debug = 1;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// get atom stream height // get particle stream height
if( _atomStreamHeight < 0 ){ if( _particleStreamHeight < 0 ){
_getAtomStreamDimensions( platform ); _getParticleStreamDimensions( platform );
} }
return _atomStreamHeight; return _particleStreamHeight;
} }
/** /**
* Get atom stream height * Get particle stream height
* *
* @return atom stream height * @return particle stream height
* *
*/ */
int BrookCommon::getAtomStreamHeight( void ) const { int BrookCommon::getParticleStreamHeight( void ) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamHeight"; // static const std::string methodName = "BrookCommon::getParticleStreamHeight";
// static const int debug = 1; // static const int debug = 1;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
return _atomStreamHeight; return _particleStreamHeight;
} }
/** /**
* Get atom stream size * Get particle stream size
* *
* @param platform platform * @param platform platform
* *
* @return atom stream size * @return particle stream size
* *
*/ */
int BrookCommon::getAtomStreamSize( const Platform& platform ){ int BrookCommon::getParticleStreamSize( const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamSize"; // static const std::string methodName = "BrookCommon::getParticleStreamSize";
// static const int debug = 1; // static const int debug = 1;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// get atom stream size // get particle stream size
if( _atomStreamSize < 0 ){ if( _particleStreamSize < 0 ){
_getAtomStreamDimensions( platform ); _getParticleStreamDimensions( platform );
} }
return _atomStreamSize; return _particleStreamSize;
} }
/** /**
* Get atom stream size * Get particle stream size
* *
* @return atom stream size * @return particle stream size
* *
*/ */
int BrookCommon::getAtomStreamSize( void ) const { int BrookCommon::getParticleStreamSize( void ) const {
return _atomStreamSize; return _particleStreamSize;
} }
/** /**
* Get atom stream dimensions * Get particle stream dimensions
* *
* @param platform platform * @param platform platform
* *
*/ */
void BrookCommon::_getAtomStreamDimensions( const Platform& platform ){ void BrookCommon::_getParticleStreamDimensions( const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::_getAtomStreamDimensions"; // static const std::string methodName = "BrookCommon::_getParticleStreamDimensions";
// static const int debug = 1; // static const int debug = 1;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// get atom stream size // get particle stream size
const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform); const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
const BrookStreamFactory& brookStreamFactory = dynamic_cast<const BrookStreamFactory&> (platform.getDefaultStreamFactory() ); const BrookStreamFactory& brookStreamFactory = dynamic_cast<const BrookStreamFactory&> (platform.getDefaultStreamFactory() );
_atomStreamWidth = brookStreamFactory.getDefaultAtomStreamWidth(); _particleStreamWidth = brookStreamFactory.getDefaultParticleStreamWidth();
_atomStreamSize = brookPlatform.getStreamSize( getNumberOfAtoms(), _atomStreamWidth, NULL ); _particleStreamSize = brookPlatform.getStreamSize( getNumberOfParticles(), _particleStreamWidth, NULL );
_atomStreamHeight = (int) ( ((float) _atomStreamSize)/( (float) _atomStreamWidth) + 0.001); _particleStreamHeight = (int) ( ((float) _particleStreamSize)/( (float) _particleStreamWidth) + 0.001);
return; return;
} }
......
...@@ -59,7 +59,7 @@ class BrookCommon { ...@@ -59,7 +59,7 @@ class BrookCommon {
// bonded stream names // bonded stream names
static const std::string BondedAtomIndicesStream; static const std::string BondedParticleIndicesStream;
static const std::string BondedParametersStream; static const std::string BondedParametersStream;
static const std::string UnrolledForceStream; static const std::string UnrolledForceStream;
static const std::string BondedChargeStream; static const std::string BondedChargeStream;
...@@ -76,9 +76,9 @@ class BrookCommon { ...@@ -76,9 +76,9 @@ class BrookCommon {
// OBC Gbsa streams // OBC Gbsa streams
static const std::string ObcAtomicRadiiStream; static const std::string ObcParticleRadiiStream;
static const std::string ObcScaledAtomicRadiiStream; static const std::string ObcScaledParticleRadiiStream;
static const std::string ObcAtomicRadiiWithDielectricOffsetStream; static const std::string ObcParticleRadiiWithDielectricOffsetStream;
static const std::string ObcBornRadiiStream; static const std::string ObcBornRadiiStream;
static const std::string ObcBornRadii2Stream; static const std::string ObcBornRadii2Stream;
static const std::string ObcIntermediateForceStream; static const std::string ObcIntermediateForceStream;
...@@ -96,8 +96,8 @@ class BrookCommon { ...@@ -96,8 +96,8 @@ class BrookCommon {
// Shake streams // Shake streams
static const std::string ShakeAtomIndicesStream; static const std::string ShakeParticleIndicesStream;
static const std::string ShakeAtomParameterStream; static const std::string ShakeParticleParameterStream;
static const std::string ShakeXCons0Stream; static const std::string ShakeXCons0Stream;
static const std::string ShakeXCons1Stream; static const std::string ShakeXCons1Stream;
static const std::string ShakeXCons2Stream; static const std::string ShakeXCons2Stream;
...@@ -130,76 +130,76 @@ class BrookCommon { ...@@ -130,76 +130,76 @@ class BrookCommon {
~BrookCommon(); ~BrookCommon();
/** /**
* Return number of atoms * Return number of particles
* *
* @return number of atoms * @return number of particles
* *
*/ */
int getNumberOfAtoms( void ) const; int getNumberOfParticles( void ) const;
/** /**
* Get atom ceiling parameter * Get particle ceiling parameter
* *
* @return atom ceiling parameter * @return particle ceiling parameter
* *
*/ */
int getAtomSizeCeiling( void ) const; int getParticleSizeCeiling( void ) const;
/** /**
* Get atom stream width * Get particle stream width
* *
* @param platform platform reference * @param platform platform reference
* *
* @return atom stream width * @return particle stream width
*/ */
int getAtomStreamWidth( const Platform& platform ); int getParticleStreamWidth( const Platform& platform );
/** /**
* Get atom stream width * Get particle stream width
* *
* @return atom stream width * @return particle stream width
*/ */
int getAtomStreamWidth( void ) const; int getParticleStreamWidth( void ) const;
/** /**
* Get atom stream height * Get particle stream height
* *
* @param platform platform reference * @param platform platform reference
* *
* @return atom stream height * @return particle stream height
*/ */
int getAtomStreamHeight( const Platform& platform ); int getParticleStreamHeight( const Platform& platform );
/** /**
* Get atom stream height * Get particle stream height
* *
* @return atom stream height * @return particle stream height
*/ */
int getAtomStreamHeight( void ) const; int getParticleStreamHeight( void ) const;
/** /**
* Get atom stream size * Get particle stream size
* *
* @param platform platform reference * @param platform platform reference
* *
* @return atom stream size * @return particle stream size
*/ */
int getAtomStreamSize( const Platform& platform ); int getParticleStreamSize( const Platform& platform );
/** /**
* Get atom stream size * Get particle stream size
* *
* @return atom stream size * @return particle stream size
*/ */
int getAtomStreamSize( void ) const; int getParticleStreamSize( void ) const;
/** /**
* Set log file reference * Set log file reference
...@@ -314,19 +314,19 @@ class BrookCommon { ...@@ -314,19 +314,19 @@ class BrookCommon {
protected: protected:
// number of atoms // number of particles
int _numberOfAtoms; int _numberOfParticles;
// atom stream dimensions // particle stream dimensions
int _atomStreamWidth; int _particleStreamWidth;
int _atomStreamHeight; int _particleStreamHeight;
int _atomStreamSize; int _particleStreamSize;
// atom size mod // particle size mod
int _atomSizeModified; int _particleSizeModified;
// log file reference // log file reference
...@@ -337,22 +337,22 @@ class BrookCommon { ...@@ -337,22 +337,22 @@ class BrookCommon {
int _verbosity; int _verbosity;
/** /**
* Set number of atoms * Set number of particles
* *
* @param numberOfAtoms number of atoms * @param numberOfParticles number of particles
* *
*/ */
int setNumberOfAtoms( int numberOfAtoms ); int setNumberOfParticles( int numberOfParticles );
/** /**
* Get atom stream dimensions * Get particle stream dimensions
* *
* @param platform platform * @param platform platform
* *
*/ */
void _getAtomStreamDimensions( const Platform& platform ); void _getParticleStreamDimensions( const Platform& platform );
/* /*
* Get line * Get line
......
...@@ -46,6 +46,8 @@ using namespace OpenMM; ...@@ -46,6 +46,8 @@ using namespace OpenMM;
* @param inputStreamWidth stream width * @param inputStreamWidth stream width
* @param inputDefaultDangleValue default dangle value * @param inputDefaultDangleValue default dangle value
* *
* @throw exception if stream type not recognized or stream width < 1
*
*/ */
BrookFloatStreamInternal::BrookFloatStreamInternal( const std::string& name, int size, int streamWidth, BrookStreamInternal::DataType type, BrookFloatStreamInternal::BrookFloatStreamInternal( const std::string& name, int size, int streamWidth, BrookStreamInternal::DataType type,
...@@ -278,6 +280,18 @@ void BrookFloatStreamInternal::loadFromArray( const void* array, BrookStreamInte ...@@ -278,6 +280,18 @@ void BrookFloatStreamInternal::loadFromArray( const void* array, BrookStreamInte
_aStream.read( _data ); _aStream.read( _data );
} }
/**
* Save data to input array
*
* @param array a pointer to the start of the array. The array is assumed to have the same length as this stream,
* and to contain elements of the correct _data type for this stream. If the stream has a compound _data type, all
* the values should be packed into a single array: all the values for the first element, followed by all the values
* for the next element, etc.
*
* @throw exception if baseType not float, double, or integer
*
*/
void BrookFloatStreamInternal::saveToArray( void* array ){ void BrookFloatStreamInternal::saveToArray( void* array ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -571,3 +585,53 @@ void* BrookFloatStreamInternal::getDataArray( void ){ ...@@ -571,3 +585,53 @@ void* BrookFloatStreamInternal::getDataArray( void ){
return new float[totalSize]; return new float[totalSize];
} }
/**
* BrookFloatStreamInternal constructor
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int BrookFloatStreamInternal::sumByDimension( int stopIndex, double* sum ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookFloatStreamInternal::sumByDimension";
// ---------------------------------------------------------------------------------------
if( stopIndex > getSize() ){
std::stringstream message;
message << methodName << " stream=" << getName() << " input topIndex" << stopIndex << " is too large: stream size=" << getSize();
throw OpenMMException( message.str() );
}
// get _data from GPU
_aStream.write( _data );
int width = getWidth();
int widthM1 = getWidth() - 1;
stopIndex *= width;
for( int ii = 0; ii < width; ii++ ){
sum[ii] = 0.0;
}
int index = 0;
for( int ii = 0; ii < stopIndex; ii++ ){
sum[index] += (double) _data[ii];
if( index == widthM1 ){
index = 0;
} else {
index++;
}
}
return DefaultReturnValue;
}
...@@ -159,6 +159,19 @@ class BrookFloatStreamInternal : public BrookStreamInternal { ...@@ -159,6 +159,19 @@ class BrookFloatStreamInternal : public BrookStreamInternal {
const std::string getContentsString( int level = 0 ) const; const std::string getContentsString( int level = 0 ) const;
/**
* Sum over stream dimensions
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int sumByDimension( int stopIndex, double* sum );
private: private:
BrookOpenMMFloat _defaultDangleValue; BrookOpenMMFloat _defaultDangleValue;
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "BrookPlatform.h" #include "BrookPlatform.h"
#include "OpenMMException.h" #include "OpenMMException.h"
#include "BrookStreamImpl.h" #include "BrookStreamImpl.h"
#include "gpu/kgbsa.h"
#include "gpu/kforce.h"
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
...@@ -51,7 +53,7 @@ BrookGbsa::BrookGbsa( ){ ...@@ -51,7 +53,7 @@ BrookGbsa::BrookGbsa( ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
_atomSizeCeiling = -1; _particleSizeCeiling = -1;
_outerUnroll = 4; _outerUnroll = 4;
_innerUnroll = 4; _innerUnroll = 4;
...@@ -59,9 +61,9 @@ BrookGbsa::BrookGbsa( ){ ...@@ -59,9 +61,9 @@ BrookGbsa::BrookGbsa( ){
_partialForceStreamHeight = -1; _partialForceStreamHeight = -1;
_partialForceStreamSize = -1; _partialForceStreamSize = -1;
_gbsaAtomStreamWidth = -1; _gbsaParticleStreamWidth = -1;
_gbsaAtomStreamHeight = -1; _gbsaParticleStreamHeight = -1;
_gbsaAtomStreamSize = -1; _gbsaParticleStreamSize = -1;
_duplicationFactor = 4; _duplicationFactor = 4;
...@@ -200,37 +202,37 @@ float BrookGbsa::getDielectricOffset( void ) const { ...@@ -200,37 +202,37 @@ float BrookGbsa::getDielectricOffset( void ) const {
int BrookGbsa::setOuterLoopUnroll( int outerUnroll ){ int BrookGbsa::setOuterLoopUnroll( int outerUnroll ){
if( outerUnroll != _outerUnroll ){ if( outerUnroll != _outerUnroll ){
_atomSizeCeiling = -1; _particleSizeCeiling = -1;
} }
_outerUnroll = _outerUnroll; _outerUnroll = _outerUnroll;
return _outerUnroll; return _outerUnroll;
} }
/** /**
* Get atom ceiling parameter * Get particle ceiling parameter
* *
* @return atom ceiling parameter * @return particle ceiling parameter
* *
*/ */
int BrookGbsa::getAtomSizeCeiling( void ) const { int BrookGbsa::getParticleSizeCeiling( void ) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookGbsa::getAtomSizeCeiling"; //static const std::string methodName = "BrookGbsa::getParticleSizeCeiling";
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
if( _atomSizeCeiling < 0 ){ if( _particleSizeCeiling < 0 ){
BrookGbsa* localThis = const_cast<BrookGbsa* const>(this); BrookGbsa* localThis = const_cast<BrookGbsa* const>(this);
localThis->_atomSizeCeiling = localThis->getNumberOfAtoms() % localThis->getOuterLoopUnroll(); localThis->_particleSizeCeiling = localThis->getNumberOfParticles() % localThis->getOuterLoopUnroll();
if( localThis->_atomSizeCeiling ){ if( localThis->_particleSizeCeiling ){
localThis->_atomSizeCeiling = localThis->getOuterLoopUnroll() - localThis->_atomSizeCeiling; localThis->_particleSizeCeiling = localThis->getOuterLoopUnroll() - localThis->_particleSizeCeiling;
} }
localThis->_atomSizeCeiling += localThis->getNumberOfAtoms(); localThis->_particleSizeCeiling += localThis->getNumberOfParticles();
} }
return _atomSizeCeiling; return _particleSizeCeiling;
} }
/** /**
...@@ -293,68 +295,68 @@ int BrookGbsa::getPartialForceStreamSize( void ) const { ...@@ -293,68 +295,68 @@ int BrookGbsa::getPartialForceStreamSize( void ) const {
} }
/** /**
* Get Atom stream size * Get Particle stream size
* *
* @return Atom stream size * @return Particle stream size
* *
*/ */
int BrookGbsa::getGbsaAtomStreamSize( void ) const { int BrookGbsa::getGbsaParticleStreamSize( void ) const {
return _gbsaAtomStreamSize; return _gbsaParticleStreamSize;
} }
/** /**
* Get atom stream width * Get particle stream width
* *
* @return atom stream width * @return particle stream width
* *
*/ */
int BrookGbsa::getGbsaAtomStreamWidth( void ) const { int BrookGbsa::getGbsaParticleStreamWidth( void ) const {
return _gbsaAtomStreamWidth; return _gbsaParticleStreamWidth;
} }
/** /**
* Get atom stream height * Get particle stream height
* *
* @return atom stream height * @return particle stream height
*/ */
int BrookGbsa::getGbsaAtomStreamHeight( void ) const { int BrookGbsa::getGbsaParticleStreamHeight( void ) const {
return _gbsaAtomStreamHeight; return _gbsaParticleStreamHeight;
} }
/** /**
* Get Obc atomic radii stream * Get Obc particle radii stream
* *
* @return Obc atomic radii stream * @return Obc particle radii stream
* *
*/ */
BrookFloatStreamInternal* BrookGbsa::getObcAtomicRadii( void ) const { BrookFloatStreamInternal* BrookGbsa::getObcParticleRadii( void ) const {
return _gbsaStreams[ObcAtomicRadiiStream]; return _gbsaStreams[ObcParticleRadiiStream];
} }
/** /**
* Get Obc scaled atomic radii stream * Get Obc scaled particle radii stream
* *
* @return Obc scaled atomic radii stream * @return Obc scaled particle radii stream
* *
*/ */
BrookFloatStreamInternal* BrookGbsa::getObcScaledAtomicRadii( void ) const { BrookFloatStreamInternal* BrookGbsa::getObcScaledParticleRadii( void ) const {
return _gbsaStreams[ObcScaledAtomicRadiiStream]; return _gbsaStreams[ObcScaledParticleRadiiStream];
} }
/** /**
* Get Obc atomic radii w/ dielectric offset * Get Obc particle radii w/ dielectric offset
* *
* @return Obc atomic radii w/ dielectric offset * @return Obc particle radii w/ dielectric offset
* *
*/ */
BrookFloatStreamInternal* BrookGbsa::getObcAtomicRadiiWithDielectricOffset( void ) const { BrookFloatStreamInternal* BrookGbsa::getObcParticleRadiiWithDielectricOffset( void ) const {
return _gbsaStreams[ObcAtomicRadiiWithDielectricOffsetStream]; return _gbsaStreams[ObcParticleRadiiWithDielectricOffsetStream];
} }
/** /**
...@@ -457,15 +459,15 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){ ...@@ -457,15 +459,15 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
// load coordinates into RealOpenMM 2d array // load coordinates into RealOpenMM 2d array
int numberOfAtoms = getNumberOfAtoms(); int numberOfParticles = getNumberOfParticles();
RealOpenMM** atomCoordinates = new RealOpenMM*[numberOfAtoms]; RealOpenMM** particleCoordinates = new RealOpenMM*[numberOfParticles];
RealOpenMM* atomCoordinatesBlk = new RealOpenMM[3*numberOfAtoms]; RealOpenMM* particleCoordinatesBlk = new RealOpenMM[3*numberOfParticles];
// Born radii array size needs to match stream size since it will // Born radii array size needs to match stream size since it will
// be written down to board // be written down to board
int streamSize = getGbsaAtomStreamSize(); int streamSize = getGbsaParticleStreamSize();
RealOpenMM* bornRadii = new RealOpenMM[streamSize]; RealOpenMM* bornRadii = new RealOpenMM[streamSize];
memset( bornRadii, 0, sizeof( RealOpenMM )*streamSize ); memset( bornRadii, 0, sizeof( RealOpenMM )*streamSize );
...@@ -473,30 +475,30 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){ ...@@ -473,30 +475,30 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
memset( obcChain, 0, sizeof( RealOpenMM )*streamSize ); memset( obcChain, 0, sizeof( RealOpenMM )*streamSize );
int index = 0; int index = 0;
RealOpenMM* atomCoordinatesBlkPtr = atomCoordinatesBlk; RealOpenMM* particleCoordinatesBlkPtr = particleCoordinatesBlk;
for( int ii = 0; ii < numberOfAtoms; ii++ ){ for( int ii = 0; ii < numberOfParticles; ii++ ){
atomCoordinates[ii] = atomCoordinatesBlkPtr; particleCoordinates[ii] = particleCoordinatesBlkPtr;
atomCoordinatesBlkPtr += 3; particleCoordinatesBlkPtr += 3;
atomCoordinates[ii][0] = coordinates[index++]; particleCoordinates[ii][0] = coordinates[index++];
atomCoordinates[ii][1] = coordinates[index++]; particleCoordinates[ii][1] = coordinates[index++];
atomCoordinates[ii][2] = coordinates[index++]; particleCoordinates[ii][2] = coordinates[index++];
} }
// calculate Born radii // calculate Born radii
_cpuObc->computeBornRadii( atomCoordinates, bornRadii, obcChain ); _cpuObc->computeBornRadii( particleCoordinates, bornRadii, obcChain );
// diagnostics // diagnostics
if( PrintOn && getLog() ){ if( PrintOn && getLog() ){
(void) fprintf( getLog(), "\n%s: atms=%d\n", methodName.c_str(), numberOfAtoms ); (void) fprintf( getLog(), "\n%s: atms=%d\n", methodName.c_str(), numberOfParticles );
for( int ii = 0; ii < numberOfAtoms; ii++ ){ for( int ii = 0; ii < numberOfParticles; ii++ ){
(void) fprintf( getLog(), "%d coord=[%.5e %.5e %.5e] bR=%.5e obcChain=%.6e\n", ii, (void) fprintf( getLog(), "%d coord=[%.5e %.5e %.5e] bR=%.5e obcChain=%.6e\n", ii,
atomCoordinates[ii][0], atomCoordinates[ii][1], atomCoordinates[ii][2], bornRadii[ii], obcChain[ii] ); particleCoordinates[ii][0], particleCoordinates[ii][1], particleCoordinates[ii][2], bornRadii[ii], obcChain[ii] );
} }
} }
...@@ -508,8 +510,8 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){ ...@@ -508,8 +510,8 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
// free memory // free memory
delete[] atomCoordinatesBlk; delete[] particleCoordinatesBlk;
delete[] atomCoordinates; delete[] particleCoordinates;
delete[] bornRadii; delete[] bornRadii;
delete[] obcChain; delete[] obcChain;
...@@ -519,14 +521,14 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){ ...@@ -519,14 +521,14 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
/** /**
* Initialize stream dimensions * Initialize stream dimensions
* *
* @param numberOfAtoms number of atoms * @param numberOfParticles number of particles
* @param platform platform * @param platform platform
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
*/ */
int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platform ){ int BrookGbsa::initializeStreamSizes( int numberOfParticles, const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -534,9 +536,9 @@ int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platfor ...@@ -534,9 +536,9 @@ int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platfor
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
_gbsaAtomStreamSize = getAtomStreamSize( platform ); _gbsaParticleStreamSize = getParticleStreamSize( platform );
_gbsaAtomStreamWidth = getAtomStreamWidth( platform ); _gbsaParticleStreamWidth = getParticleStreamWidth( platform );
_gbsaAtomStreamHeight = getAtomStreamHeight( platform ); _gbsaParticleStreamHeight = getParticleStreamHeight( platform );
int innerUnroll = getInnerLoopUnroll(); int innerUnroll = getInnerLoopUnroll();
if( innerUnroll < 1 ){ if( innerUnroll < 1 ){
...@@ -553,7 +555,7 @@ int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platfor ...@@ -553,7 +555,7 @@ int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platfor
return ErrorReturnValue; return ErrorReturnValue;
} }
_partialForceStreamSize = _gbsaAtomStreamSize*getDuplicationFactor()/innerUnroll; _partialForceStreamSize = _gbsaParticleStreamSize*getDuplicationFactor()/innerUnroll;
_partialForceStreamHeight = _partialForceStreamSize/_partialForceStreamWidth; _partialForceStreamHeight = _partialForceStreamSize/_partialForceStreamWidth;
_partialForceStreamHeight += ( (_partialForceStreamSize % _partialForceStreamWidth) ? 1 : 0); _partialForceStreamHeight += ( (_partialForceStreamSize % _partialForceStreamWidth) ? 1 : 0);
_partialForceStreamSize = _partialForceStreamHeight*_partialForceStreamWidth; _partialForceStreamSize = _partialForceStreamHeight*_partialForceStreamWidth;
...@@ -579,49 +581,49 @@ int BrookGbsa::initializeStreams( const Platform& platform ){ ...@@ -579,49 +581,49 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
int gbsaAtomStreamSize = getGbsaAtomStreamSize(); int gbsaParticleStreamSize = getGbsaParticleStreamSize();
int gbsaAtomStreamWidth = getGbsaAtomStreamWidth(); int gbsaParticleStreamWidth = getGbsaParticleStreamWidth();
// atomic radii & charge // particle radii & charge
_gbsaStreams[ObcAtomicRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcAtomicRadiiStream, _gbsaStreams[ObcParticleRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcParticleRadiiStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth, gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue ); BrookStreamInternal::Float2, dangleValue );
// scaled atomic radii // scaled particle radii
_gbsaStreams[ObcScaledAtomicRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcScaledAtomicRadiiStream, _gbsaStreams[ObcScaledParticleRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcScaledParticleRadiiStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth, gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue ); BrookStreamInternal::Float2, dangleValue );
// atomic radii w/ DielectricOffset // particle radii w/ DielectricOffset
_gbsaStreams[ObcAtomicRadiiWithDielectricOffsetStream] = new BrookFloatStreamInternal( BrookCommon::ObcAtomicRadiiWithDielectricOffsetStream, _gbsaStreams[ObcParticleRadiiWithDielectricOffsetStream] = new BrookFloatStreamInternal( BrookCommon::ObcParticleRadiiWithDielectricOffsetStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth, gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue ); BrookStreamInternal::Float, dangleValue );
// Born radii // Born radii
_gbsaStreams[ObcBornRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcBornRadiiStream, _gbsaStreams[ObcBornRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcBornRadiiStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth, gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue ); BrookStreamInternal::Float, dangleValue );
// Born2 radii // Born2 radii
_gbsaStreams[ObcBornRadii2Stream] = new BrookFloatStreamInternal( BrookCommon::ObcBornRadii2Stream, _gbsaStreams[ObcBornRadii2Stream] = new BrookFloatStreamInternal( BrookCommon::ObcBornRadii2Stream,
gbsaAtomStreamSize, gbsaAtomStreamWidth, gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue ); BrookStreamInternal::Float, dangleValue );
// IntermediateForce // IntermediateForce
_gbsaStreams[ObcIntermediateForceStream] = new BrookFloatStreamInternal( BrookCommon::ObcIntermediateForceStream, _gbsaStreams[ObcIntermediateForceStream] = new BrookFloatStreamInternal( BrookCommon::ObcIntermediateForceStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth, gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float4, dangleValue ); BrookStreamInternal::Float4, dangleValue );
// Obc chain // Obc chain
_gbsaStreams[ObcChainStream] = new BrookFloatStreamInternal( BrookCommon::ObcChainStream, _gbsaStreams[ObcChainStream] = new BrookFloatStreamInternal( BrookCommon::ObcChainStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth, gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue ); BrookStreamInternal::Float, dangleValue );
// partial force streams // partial force streams
...@@ -640,9 +642,9 @@ int BrookGbsa::initializeStreams( const Platform& platform ){ ...@@ -640,9 +642,9 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
/* /*
* Setup of Gbsa parameters * Setup of Gbsa parameters
* *
* @param atomParameters vector of OBC parameters [atomI][0=charge] * @param particleParameters vector of OBC parameters [particleI][0=charge]
* [atomI][1=radius] * [particleI][1=radius]
* [atomI][2=scaling factor] * [particleI][2=scaling factor]
* @param solventDielectric solvent dielectric * @param solventDielectric solvent dielectric
* @param soluteDielectric solute dielectric * @param soluteDielectric solute dielectric
* @param platform Brook platform * @param platform Brook platform
...@@ -651,44 +653,44 @@ int BrookGbsa::initializeStreams( const Platform& platform ){ ...@@ -651,44 +653,44 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
* *
* */ * */
int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParameters, int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfParticleParameters,
double solventDielectric, double soluteDielectric, const Platform& platform ){ double solventDielectric, double soluteDielectric, const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
static const int atomParametersSize = 3; static const int particleParametersSize = 3;
static const int maxErrors = 20; static const int maxErrors = 20;
static const std::string methodName = "BrookGbsa::setup"; static const std::string methodName = "BrookGbsa::setup";
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
int numberOfAtoms = (int) vectorOfAtomParameters.size(); int numberOfParticles = (int) vectorOfParticleParameters.size();
setNumberOfAtoms( numberOfAtoms ); setNumberOfParticles( numberOfParticles );
_solventDielectric = solventDielectric; _solventDielectric = solventDielectric;
_soluteDielectric = soluteDielectric; _soluteDielectric = soluteDielectric;
// initialize stream sizes and then Brook streams // initialize stream sizes and then Brook streams
initializeStreamSizes( numberOfAtoms, platform ); initializeStreamSizes( numberOfParticles, platform );
initializeStreams( platform ); initializeStreams( platform );
int atomStreamSize = getGbsaAtomStreamSize(); int particleStreamSize = getGbsaParticleStreamSize();
BrookOpenMMFloat* radiiAndCharge = new BrookOpenMMFloat[atomStreamSize*2]; BrookOpenMMFloat* radiiAndCharge = new BrookOpenMMFloat[particleStreamSize*2];
BrookOpenMMFloat* scaledRadiiAndOffset = new BrookOpenMMFloat[atomStreamSize*2]; BrookOpenMMFloat* scaledRadiiAndOffset = new BrookOpenMMFloat[particleStreamSize*2];
memset( radiiAndCharge, 0, atomStreamSize*2*sizeof( BrookOpenMMFloat ) ); memset( radiiAndCharge, 0, particleStreamSize*2*sizeof( BrookOpenMMFloat ) );
memset( scaledRadiiAndOffset, 0, atomStreamSize*2*sizeof( BrookOpenMMFloat ) ); memset( scaledRadiiAndOffset, 0, particleStreamSize*2*sizeof( BrookOpenMMFloat ) );
_charges = new RealOpenMM[atomStreamSize]; _charges = new RealOpenMM[particleStreamSize];
// used by CpuObc to calculate initial Born radii // used by CpuObc to calculate initial Born radii
vector<RealOpenMM> atomicRadii(numberOfAtoms); vector<RealOpenMM> particleRadii(numberOfParticles);
vector<RealOpenMM> scaleFactors(numberOfAtoms); vector<RealOpenMM> scaleFactors(numberOfParticles);
float dielectricOffset = getDielectricOffset(); float dielectricOffset = getDielectricOffset();
// loop over atom parameters // loop over particle parameters
// track any errors and then throw exception // track any errors and then throw exception
// check parameter vector is right size // check parameter vector is right size
// set parameter entries or board and arrays used by CpuObc // set parameter entries or board and arrays used by CpuObc
...@@ -700,22 +702,22 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam ...@@ -700,22 +702,22 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
typedef std::vector< std::vector<double> > VectorOfDoubleVectors; typedef std::vector< std::vector<double> > VectorOfDoubleVectors;
typedef VectorOfDoubleVectors::const_iterator VectorOfDoubleVectorsCI; typedef VectorOfDoubleVectors::const_iterator VectorOfDoubleVectorsCI;
for( VectorOfDoubleVectorsCI ii = vectorOfAtomParameters.begin(); ii != vectorOfAtomParameters.end(); ii++ ){ for( VectorOfDoubleVectorsCI ii = vectorOfParticleParameters.begin(); ii != vectorOfParticleParameters.end(); ii++ ){
std::vector<double> atomParameters = *ii; std::vector<double> particleParameters = *ii;
if( atomParameters.size() != atomParametersSize && errors < maxErrors ){ if( particleParameters.size() != particleParametersSize && errors < maxErrors ){
message << methodName << " parameter size=" << atomParameters.size() << " for parameter vector index=" << vectorIndex << " is less than expected.\n"; message << methodName << " parameter size=" << particleParameters.size() << " for parameter vector index=" << vectorIndex << " is less than expected.\n";
errors++; errors++;
} else { } else {
double charge = atomParameters[0]; double charge = particleParameters[0];
double radius = atomParameters[1]; double radius = particleParameters[1];
double scalingFactor = atomParameters[2]; double scalingFactor = particleParameters[2];
int streamIndex = 2*vectorIndex; int streamIndex = 2*vectorIndex;
atomicRadii[vectorIndex] = static_cast<RealOpenMM> (radius); particleRadii[vectorIndex] = static_cast<RealOpenMM> (radius);
scaleFactors[vectorIndex] = static_cast<RealOpenMM> (scalingFactor); scaleFactors[vectorIndex] = static_cast<RealOpenMM> (scalingFactor);
_charges[vectorIndex] = static_cast<RealOpenMM> (charge); _charges[vectorIndex] = static_cast<RealOpenMM> (charge);
...@@ -741,16 +743,16 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam ...@@ -741,16 +743,16 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
// load streams // load streams
_gbsaStreams[ObcAtomicRadiiStream]->loadFromArray( radiiAndCharge ); _gbsaStreams[ObcParticleRadiiStream]->loadFromArray( radiiAndCharge );
_gbsaStreams[ObcScaledAtomicRadiiStream]->loadFromArray( scaledRadiiAndOffset ); _gbsaStreams[ObcScaledParticleRadiiStream]->loadFromArray( scaledRadiiAndOffset );
delete[] radiiAndCharge; delete[] radiiAndCharge;
delete[] scaledRadiiAndOffset; delete[] scaledRadiiAndOffset;
// setup for Born radii calculation // setup for Born radii calculation
ObcParameters* obcParameters = new ObcParameters( numberOfAtoms, ObcParameters::ObcTypeII ); ObcParameters* obcParameters = new ObcParameters( numberOfParticles, ObcParameters::ObcTypeII );
obcParameters->setAtomicRadii( atomicRadii); obcParameters->setAtomicRadii( particleRadii);
obcParameters->setScaledRadiusFactors( scaleFactors ); obcParameters->setScaledRadiusFactors( scaleFactors );
obcParameters->setSolventDielectric( static_cast<RealOpenMM>(solventDielectric) ); obcParameters->setSolventDielectric( static_cast<RealOpenMM>(solventDielectric) );
...@@ -765,14 +767,14 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam ...@@ -765,14 +767,14 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
/* /*
* Setup of stream dimensions for partial force streams * Setup of stream dimensions for partial force streams
* *
* @param atomStreamSize atom stream size * @param particleStreamSize particle stream size
* @param atomStreamWidth atom stream width * @param particleStreamWidth particle stream width
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
* */ * */
int BrookGbsa::initializePartialForceStreamSize( int atomStreamSize, int atomStreamWidth ){ int BrookGbsa::initializePartialForceStreamSize( int particleStreamSize, int particleStreamWidth ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -796,7 +798,7 @@ int BrookGbsa::initializePartialForceStreamSize( int atomStreamSize, int atomStr ...@@ -796,7 +798,7 @@ int BrookGbsa::initializePartialForceStreamSize( int atomStreamSize, int atomStr
return ErrorReturnValue; return ErrorReturnValue;
} }
_partialForceStreamSize = atomStreamSize*getDuplicationFactor()/innerUnroll; _partialForceStreamSize = particleStreamSize*getDuplicationFactor()/innerUnroll;
_partialForceStreamHeight = _partialForceStreamSize/_partialForceStreamWidth; _partialForceStreamHeight = _partialForceStreamSize/_partialForceStreamWidth;
_partialForceStreamHeight += ( (_partialForceStreamSize % _partialForceStreamWidth) ? 1 : 0); _partialForceStreamHeight += ( (_partialForceStreamSize % _partialForceStreamWidth) ? 1 : 0);
...@@ -837,8 +839,8 @@ std::string BrookGbsa::getContentsString( int level ) const { ...@@ -837,8 +839,8 @@ std::string BrookGbsa::getContentsString( int level ) const {
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) ); #define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );
#endif #endif
(void) LOCAL_SPRINTF( value, "%d", getNumberOfAtoms() ); (void) LOCAL_SPRINTF( value, "%d", getNumberOfParticles() );
message << _getLine( tab, "Number of atoms:", value ); message << _getLine( tab, "Number of particles:", value );
(void) LOCAL_SPRINTF( value, "%d", getNumberOfForceStreams() ); (void) LOCAL_SPRINTF( value, "%d", getNumberOfForceStreams() );
message << _getLine( tab, "Number of force streams:", value ); message << _getLine( tab, "Number of force streams:", value );
...@@ -852,17 +854,17 @@ std::string BrookGbsa::getContentsString( int level ) const { ...@@ -852,17 +854,17 @@ std::string BrookGbsa::getContentsString( int level ) const {
(void) LOCAL_SPRINTF( value, "%d", getOuterLoopUnroll() ) (void) LOCAL_SPRINTF( value, "%d", getOuterLoopUnroll() )
message << _getLine( tab, "Outer loop unroll:", value ); message << _getLine( tab, "Outer loop unroll:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomSizeCeiling() ); (void) LOCAL_SPRINTF( value, "%d", getParticleSizeCeiling() );
message << _getLine( tab, "Atom ceiling:", value ); message << _getLine( tab, "Particle ceiling:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamWidth() ); (void) LOCAL_SPRINTF( value, "%d", getParticleStreamWidth() );
message << _getLine( tab, "Atom stream width:", value ); message << _getLine( tab, "Particle stream width:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamHeight() ); (void) LOCAL_SPRINTF( value, "%d", getParticleStreamHeight() );
message << _getLine( tab, "Atom stream height:", value ); message << _getLine( tab, "Particle stream height:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamSize() ); (void) LOCAL_SPRINTF( value, "%d", getParticleStreamSize() );
message << _getLine( tab, "Atom stream size:", value ); message << _getLine( tab, "Particle stream size:", value );
(void) LOCAL_SPRINTF( value, "%d", getPartialForceStreamWidth() ); (void) LOCAL_SPRINTF( value, "%d", getPartialForceStreamWidth() );
message << _getLine( tab, "Partial force stream width:", value ); message << _getLine( tab, "Partial force stream width:", value );
...@@ -905,7 +907,7 @@ std::string BrookGbsa::getContentsString( int level ) const { ...@@ -905,7 +907,7 @@ std::string BrookGbsa::getContentsString( int level ) const {
/* /*
* Calculate OBC energy * Calculate OBC energy
* *
* @param atomPositions atom positions * @param particlePositions particle positions
* @return energy * @return energy
* *
...@@ -913,7 +915,7 @@ std::string BrookGbsa::getContentsString( int level ) const { ...@@ -913,7 +915,7 @@ std::string BrookGbsa::getContentsString( int level ) const {
* *
* */ * */
double BrookGbsa::getEnergy( const Stream& atomPositions ){ double BrookGbsa::getEnergy( const Stream& particlePositions ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -937,7 +939,7 @@ double BrookGbsa::getEnergy( const Stream& atomPositions ){ ...@@ -937,7 +939,7 @@ double BrookGbsa::getEnergy( const Stream& atomPositions ){
return ErrorReturnValue; return ErrorReturnValue;
} }
const BrookStreamImpl& positionStreamC = dynamic_cast<const BrookStreamImpl&> (atomPositions.getImpl()); const BrookStreamImpl& positionStreamC = dynamic_cast<const BrookStreamImpl&> (particlePositions.getImpl());
BrookStreamImpl& positionStream = const_cast<BrookStreamImpl&> (positionStreamC); BrookStreamImpl& positionStream = const_cast<BrookStreamImpl&> (positionStreamC);
BrookOpenMMFloat* positionsF = (BrookOpenMMFloat*) positionStream.getData(); BrookOpenMMFloat* positionsF = (BrookOpenMMFloat*) positionStream.getData();
...@@ -951,3 +953,277 @@ double BrookGbsa::getEnergy( const Stream& atomPositions ){ ...@@ -951,3 +953,277 @@ double BrookGbsa::getEnergy( const Stream& atomPositions ){
return _cpuObc->getEnergy(); return _cpuObc->getEnergy();
} }
/**
* Compute forces
*
*/
void BrookGbsa::computeForces( BrookStreamImpl& positionStream, BrookStreamImpl& forceStream ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookGbsa::executeForces";
static const int PrintOn = 0;
float mergeNonObcForces = 1.0f;
float kcalMolTokJNM = -0.4184f;
// ---------------------------------------------------------------------------------------
float includeAceTerm = (float) (includeAce());
BrookFloatStreamInternal** gbsaForceStreams = getForceStreams();
// calculate Born radii
(void) fprintf( getLog(), "\nPost kCalculateBornRadii: obcParticleRadiiWithDielectricOffset & obcScaledParticleRadii not set correctly!!!!!\n" );
kCalculateBornRadii( (float) getNumberOfParticles(),
(float) getParticleSizeCeiling(),
(float) getDuplicationFactor(),
(float) getParticleStreamWidth( ),
(float) getPartialForceStreamWidth( ),
positionStream.getBrookStream(),
getObcParticleRadii()->getBrookStream(),
getObcScaledParticleRadii()->getBrookStream(),
// NOTE: obcParticleRadiiWithDielectricOffset & obcScaledParticleRadii may be wrong!! or br files need editing
// gpuObc->getBrookStreamWrapperAtIndex( GpuObc::obcParticleRadiiWithDielectricOffset )->getStream(),
// gpuObc->getBrookStreamWrapperAtIndex( GpuObc::obcScaledParticleRadii )->getStream(),
gbsaForceStreams[0]->getBrookStream() );
kPostCalculateBornRadii_nobranch(
(float) getDuplicationFactor(),
(float) getParticleStreamWidth( ),
(float) getPartialForceStreamWidth( ),
(float) getNumberOfParticles(),
(float) getParticleSizeCeiling(),
(float) getInnerLoopUnroll(),
kcalMolTokJNM,
(float) mergeNonObcForces,
gbsaForceStreams[0]->getBrookStream(),
getObcParticleRadii()->getBrookStream(),
getObcBornRadii()->getBrookStream(),
getObcChain()->getBrookStream() );
// ---------------------------------------------------------------------------------------
// seecond major loop
kObcLoop1( (float) getNumberOfParticles(),
(float) getParticleSizeCeiling(),
(float) getDuplicationFactor(),
(float) getParticleStreamWidth( ),
(float) getPartialForceStreamWidth( ),
getSoluteDielectric(),
getSolventDielectric(),
includeAceTerm,
positionStream.getBrookStream(),
getObcBornRadii()->getBrookStream(),
getObcParticleRadii()->getBrookStream(),
gbsaForceStreams[0]->getBrookStream(),
gbsaForceStreams[1]->getBrookStream(),
gbsaForceStreams[2]->getBrookStream(),
gbsaForceStreams[3]->getBrookStream()
);
// ---------------------------------------------------------------------------------------
// diagnostics
if( 1 && PrintOn && getLog() ){
(void) fprintf( getLog(), "\nPost kObcLoop1: atms=%d ceil=%d dup=%d particleStrW=%3d prtlF=%3d diel=%.3f %.3f ACE=%.1f\n",
getNumberOfParticles(),
getParticleSizeCeiling(),
getDuplicationFactor(),
getParticleStreamWidth( ),
getPartialForceStreamWidth( ),
getSoluteDielectric(),
getSolventDielectric(), includeAceTerm );
BrookStreamInternal* brookStreamInternalPos = positionStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nPositionStream\n" );
brookStreamInternalPos->printToFile( getLog() );
(void) fprintf( getLog(), "\nBornR\n" );
getObcBornRadii()->printToFile( getLog() );
(void) fprintf( getLog(), "\nParticleR\n" );
getObcParticleRadii()->printToFile( getLog() );
(void) fprintf( getLog(), "\nForceStreams output\n" );
for( int ii = 0; ii < 4; ii++ ){
gbsaForceStreams[ii]->printToFile( getLog() );
}
}
// ---------------------------------------------------------------------------------------
// gather for first loop
kPostObcLoop1_nobranch(
(float) getDuplicationFactor(),
(float) getParticleStreamWidth( ),
(float) getPartialForceStreamWidth( ),
(float) getNumberOfParticles(),
(float) getParticleSizeCeiling(),
(float) getInnerLoopUnroll(),
gbsaForceStreams[0]->getBrookStream(),
gbsaForceStreams[1]->getBrookStream(),
gbsaForceStreams[2]->getBrookStream(),
gbsaForceStreams[3]->getBrookStream(),
getObcChain()->getBrookStream(),
getObcBornRadii()->getBrookStream(),
getObcIntermediateForce()->getBrookStream(),
getObcBornRadii2()->getBrookStream() );
// ---------------------------------------------------------------------------------------
// diagnostics
if( PrintOn && getLog()){
(void) fprintf( getLog(), "\nPost kPostObcLoop1_nobranch: dup=%d aStrW=%d pStrW=%d no.atms=%3d ceil=%3d Unroll=%1d\n",
getDuplicationFactor(),
getParticleStreamWidth( ),
getPartialForceStreamWidth( ),
getNumberOfParticles(),
getParticleSizeCeiling(),
getInnerLoopUnroll() );
(void) fprintf( getLog(), "\nForceStreams\n" );
for( int ii = 0; ii < 4; ii++ ){
gbsaForceStreams[ii]->printToFile( getLog() );
}
(void) fprintf( getLog(), "\nObcChain\n" );
getObcChain()->printToFile( getLog() );
(void) fprintf( getLog(), "\nBornR\n" );
getObcBornRadii()->printToFile( getLog() );
// output
(void) fprintf( getLog(), "\nObcIntermediateForce output\n" );
getObcIntermediateForce()->printToFile( getLog() );
// output
(void) fprintf( getLog(), "\nObcBornRadii2 output\n" );
getObcBornRadii2()->printToFile( getLog() );
}
// ---------------------------------------------------------------------------------------
// second major loop
(void) fprintf( getLog(), "\nkObcLoop2 messed up see /home/friedrim/src/openmmWork/trunk/OpenMM/platforms/brook/src/gpu/kObcBaseD2.br\n" );
kObcLoop2( (float) getNumberOfParticles(),
(float) getParticleSizeCeiling(),
(float) getDuplicationFactor(),
(float) getParticleStreamWidth( ),
(float) getPartialForceStreamWidth( ),
positionStream.getBrookStream(),
getObcScaledParticleRadii()->getBrookStream(),
getObcBornRadii2()->getBrookStream(),
getObcBornRadii2()->getBrookStream(),
gbsaForceStreams[0]->getBrookStream(),
gbsaForceStreams[1]->getBrookStream(),
gbsaForceStreams[2]->getBrookStream(),
gbsaForceStreams[3]->getBrookStream()
);
// ---------------------------------------------------------------------------------------
// diagnostics
if( PrintOn && getLog() ){
(void) fprintf( getLog(), "\nPost kObcLoop2: no.atms=%5d ceil=%3d dup=%3d strW=%3d pStrW=%3d\n",
getNumberOfParticles(),
getParticleSizeCeiling(),
getDuplicationFactor(),
getParticleStreamWidth( ),
getPartialForceStreamWidth( ) );
BrookStreamInternal* brookStreamInternalPos = positionStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nPositionStream\n" );
brookStreamInternalPos->printToFile( getLog() );
(void) fprintf( getLog(), "\nObcScaledParticleRadii\n" );
getObcScaledParticleRadii()->printToFile( getLog() );
(void) fprintf( getLog(), "\ngetObcBornRadii2\n" );
getObcBornRadii2()->printToFile( getLog() );
(void) fprintf( getLog(), "\nForceStreams\n" );
for( int ii = 0; ii < 4; ii++ ){
gbsaForceStreams[ii]->printToFile( getLog() );
}
}
// ---------------------------------------------------------------------------------------
// gather for second loop
kPostObcLoop2_nobranch(
(float) getDuplicationFactor(),
(float) getParticleStreamWidth( ),
(float) getPartialForceStreamWidth( ),
(float) getNumberOfParticles(),
(float) getParticleSizeCeiling(),
(float) getInnerLoopUnroll(),
kcalMolTokJNM,
mergeNonObcForces,
getObcIntermediateForce()->getBrookStream(),
forceStream.getBrookStream(),
gbsaForceStreams[0]->getBrookStream(),
gbsaForceStreams[1]->getBrookStream(),
gbsaForceStreams[2]->getBrookStream(),
gbsaForceStreams[3]->getBrookStream(),
getObcParticleRadii()->getBrookStream(),
getObcBornRadii()->getBrookStream(),
getObcChain()->getBrookStream(),
forceStream.getBrookStream()
);
// ---------------------------------------------------------------------------------------
// diagnostics
if( PrintOn && getLog() ){
(void) fprintf( getLog(), "\nPost kPostObcLoop2_nobranch: atms=%d ceil=%d dup=%d particleStrW=%3d prtlF=%3d diel=%.3f %.3f ACE=%.1f\n",
getNumberOfParticles(),
getParticleSizeCeiling(),
getDuplicationFactor(),
getParticleStreamWidth( ),
getPartialForceStreamWidth( ),
getSoluteDielectric(),
getSolventDielectric(), includeAceTerm );
(void) fprintf( getLog(), "\nPartialForceStreams\n" );
for( int ii = 0; ii < 4; ii++ ){
gbsaForceStreams[ii]->printToFile( getLog() );
}
BrookStreamInternal* brookStreamInternalF = forceStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nForceStream\n" );
brookStreamInternalF->printToFile( getLog() );
(void) fprintf( getLog(), "\nChain\n" );
getObcChain()->printToFile( getLog() );
(void) fprintf( getLog(), "\nBornR\n" );
getObcBornRadii()->printToFile( getLog() );
}
// ---------------------------------------------------------------------------------------
}
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <vector> #include <vector>
#include <set> #include <set>
#include "BrookFloatStreamInternal.h" #include "BrookStreamImpl.h"
#include "BrookPlatform.h" #include "BrookPlatform.h"
#include "BrookCommon.h" #include "BrookCommon.h"
#include "../../../platforms/reference/src/gbsa/CpuObc.h" #include "../../../platforms/reference/src/gbsa/CpuObc.h"
...@@ -85,13 +85,13 @@ class BrookGbsa : public BrookCommon { ...@@ -85,13 +85,13 @@ class BrookGbsa : public BrookCommon {
int getDuplicationFactor( void ) const; int getDuplicationFactor( void ) const;
/** /**
* Get atom ceiling parameter * Get particle ceiling parameter
* *
* @return atom ceiling parameter * @return particle ceiling parameter
* *
*/ */
int getAtomSizeCeiling( void ) const; int getParticleSizeCeiling( void ) const;
/** /**
* Get outer loop unroll * Get outer loop unroll
...@@ -154,28 +154,28 @@ class BrookGbsa : public BrookCommon { ...@@ -154,28 +154,28 @@ class BrookGbsa : public BrookCommon {
int getPartialForceStreamSize( void ) const; int getPartialForceStreamSize( void ) const;
/** /**
* Get Gbsa atom stream width * Get Gbsa particle stream width
* *
* @return atom stream width * @return particle stream width
*/ */
int getGbsaAtomStreamWidth( void ) const; int getGbsaParticleStreamWidth( void ) const;
/** /**
* Get Gbsa atom stream height * Get Gbsa particle stream height
* *
* @return atom stream height * @return particle stream height
*/ */
int getGbsaAtomStreamHeight( void ) const; int getGbsaParticleStreamHeight( void ) const;
/** /**
* Get Gbsa atom stream size * Get Gbsa particle stream size
* *
* @return atom stream size * @return particle stream size
*/ */
int getGbsaAtomStreamSize( void ) const; int getGbsaParticleStreamSize( void ) const;
/** /**
* Get solute dielectric * Get solute dielectric
...@@ -202,31 +202,31 @@ class BrookGbsa : public BrookCommon { ...@@ -202,31 +202,31 @@ class BrookGbsa : public BrookCommon {
float getDielectricOffset( void ) const; float getDielectricOffset( void ) const;
/** /**
* Get atomic radii * Get particle radii
* *
* @return atomic radii stream * @return particle radii stream
* *
*/ */
BrookFloatStreamInternal* getObcAtomicRadii( void ) const; BrookFloatStreamInternal* getObcParticleRadii( void ) const;
/** /**
* Get scaled atomic radii * Get scaled particle radii
* *
* @return scaled atomic radii stream * @return scaled particle radii stream
* *
*/ */
BrookFloatStreamInternal* getObcScaledAtomicRadii( void ) const; BrookFloatStreamInternal* getObcScaledParticleRadii( void ) const;
/** /**
* Get atomic radii w/ dielectric offset * Get particle radii w/ dielectric offset
* *
* @return atomic radii w/ dielectric offset stream * @return particle radii w/ dielectric offset stream
* *
*/ */
BrookFloatStreamInternal* getObcAtomicRadiiWithDielectricOffset( void ) const; BrookFloatStreamInternal* getObcParticleRadiiWithDielectricOffset( void ) const;
/** /**
* Get Born radii stream * Get Born radii stream
...@@ -312,9 +312,9 @@ class BrookGbsa : public BrookCommon { ...@@ -312,9 +312,9 @@ class BrookGbsa : public BrookCommon {
/* /*
* Setup of Gbsa parameters * Setup of Gbsa parameters
* *
* @param atomParameters vector of OBC parameters [atomI][0=charge] * @param particleParameters vector of OBC parameters [particleI][0=charge]
* [atomI][1=radius] * [particleI][1=radius]
* [atomI][2=scaling factor] * [particleI][2=scaling factor]
* @param solventDielectric solvent dielectric * @param solventDielectric solvent dielectric
* @param soluteDielectric solute dielectric * @param soluteDielectric solute dielectric
* @param platform Brook platform * @param platform Brook platform
...@@ -323,7 +323,7 @@ class BrookGbsa : public BrookCommon { ...@@ -323,7 +323,7 @@ class BrookGbsa : public BrookCommon {
* *
* */ * */
int setup( const std::vector<std::vector<double> >& atomParameters, int setup( const std::vector<std::vector<double> >& particleParameters,
double solventDielectric, double soluteDielectric, const Platform& platform ); double solventDielectric, double soluteDielectric, const Platform& platform );
/* /*
...@@ -340,7 +340,7 @@ class BrookGbsa : public BrookCommon { ...@@ -340,7 +340,7 @@ class BrookGbsa : public BrookCommon {
/* /*
* Calculate energy * Calculate energy
* *
* @param atomPositions atom positions * @param particlePositions particle positions
* @return energy * @return energy
* *
...@@ -348,7 +348,14 @@ class BrookGbsa : public BrookCommon { ...@@ -348,7 +348,14 @@ class BrookGbsa : public BrookCommon {
* *
* */ * */
double getEnergy( const Stream& atomPositions ); double getEnergy( const Stream& particlePositions );
/**
* Compute forces
*
*/
void computeForces( BrookStreamImpl& positionStream, BrookStreamImpl& forceStream );
private: private:
...@@ -359,9 +366,9 @@ class BrookGbsa : public BrookCommon { ...@@ -359,9 +366,9 @@ class BrookGbsa : public BrookCommon {
// streams indices // streams indices
enum { enum {
ObcAtomicRadiiStream, ObcParticleRadiiStream,
ObcScaledAtomicRadiiStream, ObcScaledParticleRadiiStream,
ObcAtomicRadiiWithDielectricOffsetStream, ObcParticleRadiiWithDielectricOffsetStream,
ObcBornRadiiStream, ObcBornRadiiStream,
ObcBornRadii2Stream, ObcBornRadii2Stream,
ObcIntermediateForceStream, ObcIntermediateForceStream,
...@@ -369,9 +376,9 @@ class BrookGbsa : public BrookCommon { ...@@ -369,9 +376,9 @@ class BrookGbsa : public BrookCommon {
LastStreamIndex LastStreamIndex
}; };
// atom ceiling // particle ceiling
int _atomSizeCeiling; int _particleSizeCeiling;
// unroll in i/j dimensions // unroll in i/j dimensions
...@@ -392,11 +399,11 @@ class BrookGbsa : public BrookCommon { ...@@ -392,11 +399,11 @@ class BrookGbsa : public BrookCommon {
int _partialForceStreamHeight; int _partialForceStreamHeight;
int _partialForceStreamSize; int _partialForceStreamSize;
// Atom stream dimensions // Particle stream dimensions
int _gbsaAtomStreamWidth; int _gbsaParticleStreamWidth;
int _gbsaAtomStreamHeight; int _gbsaParticleStreamHeight;
int _gbsaAtomStreamSize; int _gbsaParticleStreamSize;
// dielectrics // dielectrics
...@@ -414,7 +421,7 @@ class BrookGbsa : public BrookCommon { ...@@ -414,7 +421,7 @@ class BrookGbsa : public BrookCommon {
int _bornRadiiInitialized; int _bornRadiiInitialized;
// atom charges // particle charges
RealOpenMM* _charges; RealOpenMM* _charges;
...@@ -425,26 +432,26 @@ class BrookGbsa : public BrookCommon { ...@@ -425,26 +432,26 @@ class BrookGbsa : public BrookCommon {
/* /*
* Setup of stream dimensions * Setup of stream dimensions
* *
* @param atomStreamSize atom stream size * @param particleStreamSize particle stream size
* @param atomStreamWidth atom stream width * @param particleStreamWidth particle stream width
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
* */ * */
int initializeStreamSizes( int atomStreamSize, int atomStreamWidth ); int initializeStreamSizes( int particleStreamSize, int particleStreamWidth );
/** /**
* Initialize stream dimensions * Initialize stream dimensions
* *
* @param numberOfAtoms number of atoms * @param numberOfParticles number of particles
* @param platform platform * @param platform platform
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
*/ */
int initializeStreamSizes( int numberOfAtoms, const Platform& platform ); int initializeStreamSizes( int numberOfParticles, const Platform& platform );
/** /**
* Initialize stream dimensions and streams * Initialize stream dimensions and streams
...@@ -460,14 +467,14 @@ class BrookGbsa : public BrookCommon { ...@@ -460,14 +467,14 @@ class BrookGbsa : public BrookCommon {
/* /*
* Setup of stream dimensions for partial force streams * Setup of stream dimensions for partial force streams
* *
* @param atomStreamSize atom stream size * @param particleStreamSize particle stream size
* @param atomStreamWidth atom stream width * @param particleStreamWidth particle stream width
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
* */ * */
int initializePartialForceStreamSize( int atomStreamSize, int atomStreamWidth ); int initializePartialForceStreamSize( int particleStreamSize, int particleStreamWidth );
}; };
......
...@@ -338,4 +338,52 @@ const std::string BrookIntStreamInternal::getContentsString( int level ) const { ...@@ -338,4 +338,52 @@ const std::string BrookIntStreamInternal::getContentsString( int level ) const {
return message.str(); return message.str();
} }
/**
* BrookFloatStreamInternal constructor
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int BrookIntStreamInternal::sumByDimension( int stopIndex, double* sum ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookIntStreamInternal::sumByDimension";
// ---------------------------------------------------------------------------------------
if( stopIndex > getSize() ){
std::stringstream message;
message << methodName << " stream=" << getName() << " input topIndex" << stopIndex << " is too large: stream size=" << getSize();
throw OpenMMException( message.str() );
}
// get _data from GPU
_aStream.write( _data );
int width = getWidth();
int widthM1 = getWidth() - 1;
stopIndex *= width;
for( int ii = 0; ii < width; ii++ ){
sum[ii] = 0.0;
}
int index = 0;
for( int ii = 0; ii < stopIndex; ii++ ){
sum[index] += (double) _data[ii];
if( index == widthM1 ){
index = 0;
} else {
index++;
}
}
return DefaultReturnValue;
}
...@@ -154,6 +154,19 @@ public: ...@@ -154,6 +154,19 @@ public:
const std::string getContentsString( int level = 0 ) const; const std::string getContentsString( int level = 0 ) const;
/**
* BrookFloatStreamInternal constructor
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int sumByDimension( int stopIndex, double* sum );
private: private:
int _dangleValue; int _dangleValue;
......
...@@ -80,9 +80,9 @@ BrookIntegrateBrownianStepKernel::~BrookIntegrateBrownianStepKernel( ){ ...@@ -80,9 +80,9 @@ BrookIntegrateBrownianStepKernel::~BrookIntegrateBrownianStepKernel( ){
/** /**
* Initialize the kernel, setting up all parameters related to integrator. * Initialize the kernel, setting up all parameters related to integrator.
* *
* @param masses the mass of each atom * @param masses the mass of each particle
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained * @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms * @param constraintLengths the required distance between each pair of constrained particles
* *
*/ */
...@@ -112,9 +112,9 @@ void BrookIntegrateBrownianStepKernel::initialize( const vector<double>& masses, ...@@ -112,9 +112,9 @@ void BrookIntegrateBrownianStepKernel::initialize( const vector<double>& masses,
/** /**
* Execute kernel * Execute kernel
* *
* @param positions atom coordinates * @param positions particle coordinates
* @param velocities atom velocities * @param velocities particle velocities
* @param forces atom forces * @param forces particle forces
* @param temperature heat bath temperature * @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath * @param friction friction coefficient coupling the system to the heat bath
* @param stepSize integration step size * @param stepSize integration step size
......
...@@ -72,9 +72,9 @@ class BrookIntegrateBrownianStepKernel : public IntegrateBrownianStepKernel { ...@@ -72,9 +72,9 @@ class BrookIntegrateBrownianStepKernel : public IntegrateBrownianStepKernel {
/** /**
* Initialize the kernel, setting up all parameters related to integrator. * Initialize the kernel, setting up all parameters related to integrator.
* *
* @param masses atom masses * @param masses particle masses
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained * @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained atoms * @param constraintLengths required distance between each pair of constrained particles
*/ */
void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices, void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
......
...@@ -80,9 +80,9 @@ BrookIntegrateLangevinStepKernel::~BrookIntegrateLangevinStepKernel( ){ ...@@ -80,9 +80,9 @@ BrookIntegrateLangevinStepKernel::~BrookIntegrateLangevinStepKernel( ){
/** /**
* Initialize the kernel, setting up all parameters related to integrator. * Initialize the kernel, setting up all parameters related to integrator.
* *
* @param masses the mass of each atom * @param masses the mass of each particle
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained * @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms * @param constraintLengths the required distance between each pair of constrained particles
* *
*/ */
...@@ -112,9 +112,9 @@ void BrookIntegrateLangevinStepKernel::initialize( const vector<double>& masses, ...@@ -112,9 +112,9 @@ void BrookIntegrateLangevinStepKernel::initialize( const vector<double>& masses,
/** /**
* Execute kernel * Execute kernel
* *
* @param positions atom coordinates * @param positions particle coordinates
* @param velocities atom velocities * @param velocities particle velocities
* @param forces atom forces * @param forces particle forces
* @param temperature heat bath temperature * @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath * @param friction friction coefficient coupling the system to the heat bath
* @param stepSize integration step size * @param stepSize integration step size
......
...@@ -72,9 +72,9 @@ class BrookIntegrateLangevinStepKernel : public IntegrateLangevinStepKernel { ...@@ -72,9 +72,9 @@ class BrookIntegrateLangevinStepKernel : public IntegrateLangevinStepKernel {
/** /**
* Initialize the kernel, setting up all parameters related to integrator. * Initialize the kernel, setting up all parameters related to integrator.
* *
* @param masses atom masses * @param masses particle masses
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained * @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained atoms * @param constraintLengths required distance between each pair of constrained particles
*/ */
void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices, void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
......
...@@ -77,9 +77,9 @@ BrookIntegrateVerletStepKernel::~BrookIntegrateVerletStepKernel( ){ ...@@ -77,9 +77,9 @@ BrookIntegrateVerletStepKernel::~BrookIntegrateVerletStepKernel( ){
/** /**
* Initialize the kernel, setting up all parameters related to integrator. * Initialize the kernel, setting up all parameters related to integrator.
* *
* @param masses the mass of each atom * @param masses the mass of each particle
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained * @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms * @param constraintLengths the required distance between each pair of constrained particles
* *
*/ */
...@@ -104,9 +104,9 @@ void BrookIntegrateVerletStepKernel::initialize( const vector<double>& masses, ...@@ -104,9 +104,9 @@ void BrookIntegrateVerletStepKernel::initialize( const vector<double>& masses,
/** /**
* Execute kernel * Execute kernel
* *
* @param positions atom coordinates * @param positions particle coordinates
* @param velocities atom velocities * @param velocities particle velocities
* @param forces atom forces * @param forces particle forces
* @param stepSize integration step size * @param stepSize integration step size
* *
*/ */
......
...@@ -66,9 +66,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel { ...@@ -66,9 +66,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
/** /**
* Initialize the kernel, setting up all parameters related to integrator. * Initialize the kernel, setting up all parameters related to integrator.
* *
* @param masses the mass of each atom * @param masses the mass of each particle
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained * @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms * @param constraintLengths the required distance between each pair of constrained particles
* *
*/ */
void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices, void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
...@@ -76,9 +76,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel { ...@@ -76,9 +76,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
/** /**
* Execute kernel * Execute kernel
* *
* @param positions atom coordinates * @param positions particle coordinates
* @param velocities atom velocities * @param velocities particle velocities
* @param forces atom forces * @param forces particle forces
* @param stepSize integration step size * @param stepSize integration step size
* *
*/ */
......
...@@ -30,13 +30,15 @@ ...@@ -30,13 +30,15 @@
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include "BrookKernelFactory.h" #include "BrookKernelFactory.h"
#include "BrookCalcHarmonicAngleForceKernel.h"
#include "BrookCalcNonbondedForceKernel.h" #include "BrookCalcNonbondedForceKernel.h"
#include "BrookIntegrateLangevinStepKernel.h" #include "BrookIntegrateLangevinStepKernel.h"
#include "BrookIntegrateVerletStepKernel.h" #include "BrookIntegrateVerletStepKernel.h"
#include "BrookIntegrateBrownianStepKernel.h" #include "BrookIntegrateBrownianStepKernel.h"
#include "BrookCalcKineticEnergyKernel.h" #include "BrookCalcKineticEnergyKernel.h"
#include "BrookCalcGBSAOBCForceKernel.h" //#include "BrookCalcGBSAOBCForceKernel.h"
#include "BrookRemoveCMMotionKernel.h" #include "BrookRemoveCMMotionKernel.h"
#include "internal/OpenMMContextImpl.h"
using namespace OpenMM; using namespace OpenMM;
...@@ -48,52 +50,78 @@ KernelImpl* BrookKernelFactory::createKernelImpl( std::string name, const Platfo ...@@ -48,52 +50,78 @@ KernelImpl* BrookKernelFactory::createKernelImpl( std::string name, const Platfo
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// StandardMM OpenMMBrookInterface& openMMBrookInterface = *static_cast<OpenMMBrookInterface*>(context.getPlatformData());
if( name == CalcNonbondedForceKernel::Name() ){ // harmonic bonds
return new BrookCalcNonbondedForceKernel( name, platform ); if( name == CalcHarmonicBondForceKernel::Name() ){
// return new BrookCalcHarmonicBondForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// angle bonds
} else if( name == CalcHarmonicAngleForceKernel::Name() ){
return new BrookCalcHarmonicAngleForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// periodic torsion bonds
} else if( name == CalcPeriodicTorsionForceKernel::Name() ){
// return new BrookCalcPeriodicTorsionForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// RB torsion bonds
} else if( name == CalcRBTorsionForceKernel::Name() ){
// return new BrookCalcRBTorsionForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// nonbonded
} else if( name == CalcNonbondedForceKernel::Name() ){
// return new BrookCalcNonbondedForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// GBSA OBC // GBSA OBC
} else if( name == CalcGBSAOBCForceKernel::Name() ){ } else if( name == CalcGBSAOBCForceKernel::Name() ){
return new BrookCalcGBSAOBCForceKernel(name, platform); // return new BrookCalcGBSAOBCForceFieldKernel( name, platform, openMMBrookInterface, context.getSystem() );
// Verlet integrator // Verlet integrator
} else if( name == IntegrateVerletStepKernel::Name() ){ } else if( name == IntegrateVerletStepKernel::Name() ){
return new BrookIntegrateVerletStepKernel( name, platform ); // return new BrookIntegrateVerletStepKernel( name, platform, openMMBrookInterface );
// Brownian integrator // Brownian integrator
} else if( name == IntegrateBrownianStepKernel::Name() ){ } else if( name == IntegrateBrownianStepKernel::Name() ){
return new BrookIntegrateBrownianStepKernel( name, platform ); // return new BrookIntegrateBrownianStepKernel( name, platform, openMMBrookInterface );
// Andersen thermostat // Andersen thermostat
} else if( name == ApplyAndersenThermostatKernel::Name() ){ } else if( name == ApplyAndersenThermostatKernel::Name() ){
// return new BrookIntegrateAndersenThermostatKernel( name, platform ); // return new BrookIntegrateAndersenThermostatKernel( name, platform, openMMBrookInterface );
// Langevin integrator // Langevin integrator
} else if( name == IntegrateLangevinStepKernel::Name() ){ } else if( name == IntegrateLangevinStepKernel::Name() ){
return new BrookIntegrateLangevinStepKernel( name, platform ); // return new BrookIntegrateLangevinStepKernel( name, platform, openMMBrookInterface );
// Remove com // Remove com
} else if( name == RemoveCMMotionKernel::Name() ){ } else if( name == RemoveCMMotionKernel::Name() ){
return new BrookRemoveCMMotionKernel( name, platform ); // return new BrookRemoveCMMotionKernel( name, platform, openMMBrookInterface );
// KE calculator // KE calculator
} else if( name == CalcKineticEnergyKernel::Name() ){ } else if( name == CalcKineticEnergyKernel::Name() ){
return new BrookCalcKineticEnergyKernel( name, platform ); // return new BrookCalcKineticEnergyKernel( name, platform, openMMBrookInterface );
} }
(void) fprintf( stderr, "createKernelImpl: name=<%s> not found.", methodName.c_str(), name.c_str() ); (void) fprintf( stderr, "createKernelImpl: name=<%s> not found.", methodName.c_str(), name.c_str() );
......
...@@ -63,13 +63,13 @@ BrookLangevinDynamics::BrookLangevinDynamics( ){ ...@@ -63,13 +63,13 @@ BrookLangevinDynamics::BrookLangevinDynamics( ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
_numberOfAtoms = -1; _numberOfParticles = -1;
// mark stream dimension variables as unset // mark stream dimension variables as unset
_sdAtomStreamWidth = -1; _sdParticleStreamWidth = -1;
_sdAtomStreamHeight = -1; _sdParticleStreamHeight = -1;
_sdAtomStreamSize = -1; _sdParticleStreamSize = -1;
for( int ii = 0; ii < LastStreamIndex; ii++ ){ for( int ii = 0; ii < LastStreamIndex; ii++ ){
_sdStreams[ii] = NULL; _sdStreams[ii] = NULL;
...@@ -352,9 +352,9 @@ int BrookLangevinDynamics::updateParameters( double temperature, double friction ...@@ -352,9 +352,9 @@ int BrookLangevinDynamics::updateParameters( double temperature, double friction
/** /**
* Update * Update
* *
* @param positions atom positions * @param positions particle positions
* @param velocities atom velocities * @param velocities particle velocities
* @param forces atom forces * @param forces particle forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference * @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference * @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
* *
...@@ -414,7 +414,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -414,7 +414,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// first integration step // first integration step
kupdate_sd1_fix1( kupdate_sd1_fix1(
(float) getLangevinDynamicsAtomStreamWidth(), (float) getLangevinDynamicsParticleStreamWidth(),
(float) brookRandomNumberGenerator.getRandomNumberStreamWidth(), (float) brookRandomNumberGenerator.getRandomNumberStreamWidth(),
(float) brookRandomNumberGenerator.getRvStreamOffset(), (float) brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[EM], derivedParameters[EM],
...@@ -436,9 +436,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -436,9 +436,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// diagnostics // diagnostics
if( PrintOn ){ if( PrintOn ){
(void) fprintf( getLog(), "\nPost kupdate_sd1_fix1: atomStrW=%3d rngStrW=%3d rngOff=%5d " (void) fprintf( getLog(), "\nPost kupdate_sd1_fix1: particleStrW=%3d rngStrW=%3d rngOff=%5d "
"EM=%12.5e Sd1pc[]=[%12.5e %12.5e %12.5e]", "EM=%12.5e Sd1pc[]=[%12.5e %12.5e %12.5e]",
getLangevinDynamicsAtomStreamWidth(), getLangevinDynamicsParticleStreamWidth(),
brookRandomNumberGenerator.getRandomNumberStreamWidth(), brookRandomNumberGenerator.getRandomNumberStreamWidth(),
brookRandomNumberGenerator.getRvStreamOffset(), brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[EM], derivedParameters[Sd1pc1], derivedParameters[Sd1pc2], derivedParameters[Sd1pc3] ); derivedParameters[EM], derivedParameters[Sd1pc1], derivedParameters[Sd1pc2], derivedParameters[Sd1pc3] );
...@@ -481,20 +481,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -481,20 +481,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// advance random number cursor // advance random number cursor
brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfAtoms() ); brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfParticles() );
// first Shake step // first Shake step
if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){ if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){
kshakeh_fix1( kshakeh_fix1(
10.0f, 10.0f,
(float) getLangevinDynamicsAtomStreamWidth(), (float) getLangevinDynamicsParticleStreamWidth(),
brookShakeAlgorithm.getInverseHydrogenMass(), brookShakeAlgorithm.getInverseHydrogenMass(),
omega, omega,
brookShakeAlgorithm.getShakeAtomIndicesStream()->getBrookStream(), brookShakeAlgorithm.getShakeParticleIndicesStream()->getBrookStream(),
positionStream.getBrookStream(), positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(), getXPrimeStream()->getBrookStream(),
brookShakeAlgorithm.getShakeAtomParameterStream()->getBrookStream(), brookShakeAlgorithm.getShakeParticleParameterStream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(), brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(), brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(), brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(),
...@@ -503,7 +503,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -503,7 +503,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// first Shake gather // first Shake gather
kshakeh_update1_fix1( kshakeh_update1_fix1(
(float) getLangevinDynamicsAtomStreamWidth(), (float) getLangevinDynamicsParticleStreamWidth(),
derivedParameters[Sd2pc1], derivedParameters[Sd2pc1],
brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(), brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(),
positionStream.getBrookStream(), positionStream.getBrookStream(),
...@@ -519,7 +519,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -519,7 +519,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// second integration step // second integration step
kupdate_sd2_fix1( kupdate_sd2_fix1(
(float) getLangevinDynamicsAtomStreamWidth(), (float) getLangevinDynamicsParticleStreamWidth(),
(float) brookRandomNumberGenerator.getRandomNumberStreamWidth(), (float) brookRandomNumberGenerator.getRandomNumberStreamWidth(),
(float) brookRandomNumberGenerator.getRvStreamOffset(), (float) brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[Sd2pc1], derivedParameters[Sd2pc1],
...@@ -538,9 +538,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -538,9 +538,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// diagnostics // diagnostics
if( PrintOn ){ if( PrintOn ){
(void) fprintf( getLog(), "\nPost kupdate_sd2_fix1: atomStrW=%3d rngStrW=%3d rngOff=%5d " (void) fprintf( getLog(), "\nPost kupdate_sd2_fix1: particleStrW=%3d rngStrW=%3d rngOff=%5d "
"Sd2pc[]=[%12.5e %12.5e]", "Sd2pc[]=[%12.5e %12.5e]",
getLangevinDynamicsAtomStreamWidth(), getLangevinDynamicsParticleStreamWidth(),
brookRandomNumberGenerator.getRandomNumberStreamWidth(), brookRandomNumberGenerator.getRandomNumberStreamWidth(),
brookRandomNumberGenerator.getRvStreamOffset(), brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[Sd2pc1], derivedParameters[Sd2pc2] ); derivedParameters[Sd2pc1], derivedParameters[Sd2pc2] );
...@@ -574,20 +574,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -574,20 +574,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// advance random number cursor // advance random number cursor
brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfAtoms() ); brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfParticles() );
// second Shake step // second Shake step
if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){ if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){
kshakeh_fix1( kshakeh_fix1(
10.0f, 10.0f,
(float) getLangevinDynamicsAtomStreamWidth(), (float) getLangevinDynamicsParticleStreamWidth(),
brookShakeAlgorithm.getInverseHydrogenMass(), brookShakeAlgorithm.getInverseHydrogenMass(),
omega, omega,
brookShakeAlgorithm.getShakeAtomIndicesStream()->getBrookStream(), brookShakeAlgorithm.getShakeParticleIndicesStream()->getBrookStream(),
positionStream.getBrookStream(), positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(), getXPrimeStream()->getBrookStream(),
brookShakeAlgorithm.getShakeAtomParameterStream()->getBrookStream(), brookShakeAlgorithm.getShakeParticleParameterStream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(), brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(), brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(), brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(),
...@@ -596,7 +596,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities, ...@@ -596,7 +596,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// second Shake gather // second Shake gather
kshakeh_update2_fix1( kshakeh_update2_fix1(
(float) getLangevinDynamicsAtomStreamWidth(), (float) getLangevinDynamicsParticleStreamWidth(),
brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(), brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(),
positionStream.getBrookStream(), positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(), getXPrimeStream()->getBrookStream(),
...@@ -635,35 +635,35 @@ const BrookOpenMMFloat* BrookLangevinDynamics::getDerivedParameters( void ) cons ...@@ -635,35 +635,35 @@ const BrookOpenMMFloat* BrookLangevinDynamics::getDerivedParameters( void ) cons
} }
/** /**
* Get Atom stream size * Get Particle stream size
* *
* @return Atom stream size * @return Particle stream size
* *
*/ */
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamSize( void ) const { int BrookLangevinDynamics::getLangevinDynamicsParticleStreamSize( void ) const {
return _sdAtomStreamSize; return _sdParticleStreamSize;
} }
/** /**
* Get atom stream width * Get particle stream width
* *
* @return atom stream width * @return particle stream width
* *
*/ */
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamWidth( void ) const { int BrookLangevinDynamics::getLangevinDynamicsParticleStreamWidth( void ) const {
return _sdAtomStreamWidth; return _sdParticleStreamWidth;
} }
/** /**
* Get atom stream height * Get particle stream height
* *
* @return atom stream height * @return particle stream height
*/ */
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamHeight( void ) const { int BrookLangevinDynamics::getLangevinDynamicsParticleStreamHeight( void ) const {
return _sdAtomStreamHeight; return _sdParticleStreamHeight;
} }
/** /**
...@@ -746,14 +746,14 @@ BrookFloatStreamInternal* BrookLangevinDynamics::getInverseMassStream( void ) co ...@@ -746,14 +746,14 @@ BrookFloatStreamInternal* BrookLangevinDynamics::getInverseMassStream( void ) co
/** /**
* Initialize stream dimensions * Initialize stream dimensions
* *
* @param numberOfAtoms number of atoms * @param numberOfParticles number of particles
* @param platform platform * @param platform platform
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
*/ */
int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Platform& platform ){ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfParticles, const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -761,9 +761,9 @@ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Plat ...@@ -761,9 +761,9 @@ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Plat
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
_sdAtomStreamSize = getAtomStreamSize( platform ); _sdParticleStreamSize = getParticleStreamSize( platform );
_sdAtomStreamWidth = getAtomStreamWidth( platform ); _sdParticleStreamWidth = getParticleStreamWidth( platform );
_sdAtomStreamHeight = getAtomStreamHeight( platform ); _sdParticleStreamHeight = getParticleStreamHeight( platform );
return DefaultReturnValue; return DefaultReturnValue;
} }
...@@ -771,7 +771,7 @@ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Plat ...@@ -771,7 +771,7 @@ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Plat
/** /**
* Initialize stream dimensions * Initialize stream dimensions
* *
* @param numberOfAtoms number of atoms * @param numberOfParticles number of particles
* @param platform platform * @param platform platform
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
...@@ -886,35 +886,35 @@ int BrookLangevinDynamics::_initializeStreams( const Platform& platform ){ ...@@ -886,35 +886,35 @@ int BrookLangevinDynamics::_initializeStreams( const Platform& platform ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
int sdAtomStreamSize = getLangevinDynamicsAtomStreamSize(); int sdParticleStreamSize = getLangevinDynamicsParticleStreamSize();
int sdAtomStreamWidth = getLangevinDynamicsAtomStreamWidth(); int sdParticleStreamWidth = getLangevinDynamicsParticleStreamWidth();
_sdStreams[SDPC1Stream] = new BrookFloatStreamInternal( BrookCommon::SDPC1Stream, _sdStreams[SDPC1Stream] = new BrookFloatStreamInternal( BrookCommon::SDPC1Stream,
sdAtomStreamSize, sdAtomStreamWidth, sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue ); BrookStreamInternal::Float2, dangleValue );
_sdStreams[SDPC2Stream] = new BrookFloatStreamInternal( BrookCommon::SDPC2Stream, _sdStreams[SDPC2Stream] = new BrookFloatStreamInternal( BrookCommon::SDPC2Stream,
sdAtomStreamSize, sdAtomStreamWidth, sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue ); BrookStreamInternal::Float2, dangleValue );
_sdStreams[SD2XStream] = new BrookFloatStreamInternal( BrookCommon::SD2XStream, _sdStreams[SD2XStream] = new BrookFloatStreamInternal( BrookCommon::SD2XStream,
sdAtomStreamSize, sdAtomStreamWidth, sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue ); BrookStreamInternal::Float3, dangleValue );
_sdStreams[SD1VStream] = new BrookFloatStreamInternal( BrookCommon::SD1VStream, _sdStreams[SD1VStream] = new BrookFloatStreamInternal( BrookCommon::SD1VStream,
sdAtomStreamSize, sdAtomStreamWidth, sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue ); BrookStreamInternal::Float3, dangleValue );
_sdStreams[VPrimeStream] = new BrookFloatStreamInternal( BrookCommon::VPrimeStream, _sdStreams[VPrimeStream] = new BrookFloatStreamInternal( BrookCommon::VPrimeStream,
sdAtomStreamSize, sdAtomStreamWidth, sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue ); BrookStreamInternal::Float3, dangleValue );
_sdStreams[XPrimeStream] = new BrookFloatStreamInternal( BrookCommon::XPrimeStream, _sdStreams[XPrimeStream] = new BrookFloatStreamInternal( BrookCommon::XPrimeStream,
sdAtomStreamSize, sdAtomStreamWidth, sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue ); BrookStreamInternal::Float3, dangleValue );
_sdStreams[InverseMassStream] = new BrookFloatStreamInternal( BrookCommon::InverseMassStream, _sdStreams[InverseMassStream] = new BrookFloatStreamInternal( BrookCommon::InverseMassStream,
sdAtomStreamSize, sdAtomStreamWidth, sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float, dangleValue ); BrookStreamInternal::Float, dangleValue );
return DefaultReturnValue; return DefaultReturnValue;
...@@ -935,20 +935,20 @@ int BrookLangevinDynamics::_updateSdStreams( void ){ ...@@ -935,20 +935,20 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
int sdAtomStreamSize = getLangevinDynamicsAtomStreamSize(); int sdParticleStreamSize = getLangevinDynamicsParticleStreamSize();
BrookOpenMMFloat* sdpc[2]; BrookOpenMMFloat* sdpc[2];
for( int ii = 0; ii < 2; ii++ ){ for( int ii = 0; ii < 2; ii++ ){
sdpc[ii] = new BrookOpenMMFloat[2*sdAtomStreamSize]; sdpc[ii] = new BrookOpenMMFloat[2*sdParticleStreamSize];
memset( sdpc[ii], 0, 2*sdAtomStreamSize*sizeof( BrookOpenMMFloat ) ); memset( sdpc[ii], 0, 2*sdParticleStreamSize*sizeof( BrookOpenMMFloat ) );
} }
BrookOpenMMFloat* inverseMass = new BrookOpenMMFloat[sdAtomStreamSize]; BrookOpenMMFloat* inverseMass = new BrookOpenMMFloat[sdParticleStreamSize];
memset( inverseMass, 0, sdAtomStreamSize*sizeof( BrookOpenMMFloat ) ); memset( inverseMass, 0, sdParticleStreamSize*sizeof( BrookOpenMMFloat ) );
const BrookOpenMMFloat* derivedParameters = getDerivedParameters( ); const BrookOpenMMFloat* derivedParameters = getDerivedParameters( );
int numberOfAtoms = getNumberOfAtoms(); int numberOfParticles = getNumberOfParticles();
int index = 0; int index = 0;
for( int ii = 0; ii < numberOfAtoms; ii++, index += 2 ){ for( int ii = 0; ii < numberOfParticles; ii++, index += 2 ){
sdpc[0][index] = _inverseSqrtMasses[ii]*( static_cast<BrookOpenMMFloat> (derivedParameters[Yv]) ); sdpc[0][index] = _inverseSqrtMasses[ii]*( static_cast<BrookOpenMMFloat> (derivedParameters[Yv]) );
sdpc[0][index+1] = _inverseSqrtMasses[ii]*( static_cast<BrookOpenMMFloat> (derivedParameters[V]) ); sdpc[0][index+1] = _inverseSqrtMasses[ii]*( static_cast<BrookOpenMMFloat> (derivedParameters[V]) );
...@@ -971,13 +971,13 @@ int BrookLangevinDynamics::_updateSdStreams( void ){ ...@@ -971,13 +971,13 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
// initialize SD2X // initialize SD2X
BrookOpenMMFloat* sd2x = new BrookOpenMMFloat[3*sdAtomStreamSize]; BrookOpenMMFloat* sd2x = new BrookOpenMMFloat[3*sdParticleStreamSize];
//SimTKOpenMMUtilities::setRandomNumberSeed( (uint32_t) getRandomNumberSeed() ); //SimTKOpenMMUtilities::setRandomNumberSeed( (uint32_t) getRandomNumberSeed() );
memset( sd2x, 0, 3*sdAtomStreamSize*sizeof( BrookOpenMMFloat ) ); memset( sd2x, 0, 3*sdParticleStreamSize*sizeof( BrookOpenMMFloat ) );
index = 0; index = 0;
for( int ii = 0; ii < numberOfAtoms; ii++, index += 3 ){ for( int ii = 0; ii < numberOfParticles; ii++, index += 3 ){
sd2x[index] = _inverseSqrtMasses[ii]*derivedParameters[X]*( static_cast<BrookOpenMMFloat> (SimTKOpenMMUtilities::getNormallyDistributedRandomNumber()) ); sd2x[index] = _inverseSqrtMasses[ii]*derivedParameters[X]*( static_cast<BrookOpenMMFloat> (SimTKOpenMMUtilities::getNormallyDistributedRandomNumber()) );
sd2x[index+1] = _inverseSqrtMasses[ii]*derivedParameters[X]*( static_cast<BrookOpenMMFloat> (SimTKOpenMMUtilities::getNormallyDistributedRandomNumber()) ); sd2x[index+1] = _inverseSqrtMasses[ii]*derivedParameters[X]*( static_cast<BrookOpenMMFloat> (SimTKOpenMMUtilities::getNormallyDistributedRandomNumber()) );
sd2x[index+2] = _inverseSqrtMasses[ii]*derivedParameters[X]*( static_cast<BrookOpenMMFloat> (SimTKOpenMMUtilities::getNormallyDistributedRandomNumber()) ); sd2x[index+2] = _inverseSqrtMasses[ii]*derivedParameters[X]*( static_cast<BrookOpenMMFloat> (SimTKOpenMMUtilities::getNormallyDistributedRandomNumber()) );
...@@ -994,7 +994,7 @@ int BrookLangevinDynamics::_updateSdStreams( void ){ ...@@ -994,7 +994,7 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
/** /**
* Set masses * Set masses
* *
* @param masses atomic masses * @param masses particle masses
* *
*/ */
...@@ -1046,12 +1046,12 @@ int BrookLangevinDynamics::setup( const std::vector<double>& masses, const Platf ...@@ -1046,12 +1046,12 @@ int BrookLangevinDynamics::setup( const std::vector<double>& masses, const Platf
const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform); const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
setLog( brookPlatform.getLog() ); setLog( brookPlatform.getLog() );
int numberOfAtoms = (int) masses.size(); int numberOfParticles = (int) masses.size();
setNumberOfAtoms( numberOfAtoms ); setNumberOfParticles( numberOfParticles );
// set stream sizes and then create streams // set stream sizes and then create streams
_initializeStreamSizes( numberOfAtoms, platform ); _initializeStreamSizes( numberOfParticles, platform );
_initializeStreams( platform ); _initializeStreams( platform );
_setInverseSqrtMasses( masses ); _setInverseSqrtMasses( masses );
...@@ -1090,17 +1090,17 @@ std::string BrookLangevinDynamics::getContentsString( int level ) const { ...@@ -1090,17 +1090,17 @@ std::string BrookLangevinDynamics::getContentsString( int level ) const {
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) ); #define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );
#endif #endif
(void) LOCAL_SPRINTF( value, "%d", getNumberOfAtoms() ); (void) LOCAL_SPRINTF( value, "%d", getNumberOfParticles() );
message << _getLine( tab, "Number of atoms:", value ); message << _getLine( tab, "Number of particles:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamWidth() ); (void) LOCAL_SPRINTF( value, "%d", getParticleStreamWidth() );
message << _getLine( tab, "Atom stream width:", value ); message << _getLine( tab, "Particle stream width:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamHeight() ); (void) LOCAL_SPRINTF( value, "%d", getParticleStreamHeight() );
message << _getLine( tab, "Atom stream height:", value ); message << _getLine( tab, "Particle stream height:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamSize() ); (void) LOCAL_SPRINTF( value, "%d", getParticleStreamSize() );
message << _getLine( tab, "Atom stream size:", value ); message << _getLine( tab, "Particle stream size:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getTau() ); (void) LOCAL_SPRINTF( value, "%.5f", getTau() );
message << _getLine( tab, "Tau:", value ); message << _getLine( tab, "Tau:", value );
......
...@@ -110,28 +110,28 @@ class BrookLangevinDynamics : public BrookCommon { ...@@ -110,28 +110,28 @@ class BrookLangevinDynamics : public BrookCommon {
const BrookOpenMMFloat* getDerivedParameters( void ) const; const BrookOpenMMFloat* getDerivedParameters( void ) const;
/** /**
* Get LangevinDynamics atom stream width * Get LangevinDynamics particle stream width
* *
* @return atom stream width * @return particle stream width
*/ */
int getLangevinDynamicsAtomStreamWidth( void ) const; int getLangevinDynamicsParticleStreamWidth( void ) const;
/** /**
* Get LangevinDynamics atom stream height * Get LangevinDynamics particle stream height
* *
* @return atom stream height * @return particle stream height
*/ */
int getLangevinDynamicsAtomStreamHeight( void ) const; int getLangevinDynamicsParticleStreamHeight( void ) const;
/** /**
* Get LangevinDynamics atom stream size * Get LangevinDynamics particle stream size
* *
* @return atom stream size * @return particle stream size
*/ */
int getLangevinDynamicsAtomStreamSize( void ) const; int getLangevinDynamicsParticleStreamSize( void ) const;
/** /**
* Update parameters * Update parameters
...@@ -149,9 +149,9 @@ class BrookLangevinDynamics : public BrookCommon { ...@@ -149,9 +149,9 @@ class BrookLangevinDynamics : public BrookCommon {
/** /**
* Update * Update
* *
* @param positions atom positions * @param positions particle positions
* @param velocities atom velocities * @param velocities particle velocities
* @param forces atom forces * @param forces particle forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference * @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference * @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
* *
...@@ -174,7 +174,7 @@ class BrookLangevinDynamics : public BrookCommon { ...@@ -174,7 +174,7 @@ class BrookLangevinDynamics : public BrookCommon {
/* /*
* Setup of LangevinDynamics parameters * Setup of LangevinDynamics parameters
* *
* @param masses atom masses * @param masses particle masses
* @param platform Brook platform * @param platform Brook platform
* *
* @return ErrorReturnValue value if error, else DefaultReturnValue * @return ErrorReturnValue value if error, else DefaultReturnValue
...@@ -285,11 +285,11 @@ class BrookLangevinDynamics : public BrookCommon { ...@@ -285,11 +285,11 @@ class BrookLangevinDynamics : public BrookCommon {
BrookOpenMMFloat _temperature; BrookOpenMMFloat _temperature;
BrookOpenMMFloat _stepSize; BrookOpenMMFloat _stepSize;
// Atom stream dimensions // Particle stream dimensions
int _sdAtomStreamWidth; int _sdParticleStreamWidth;
int _sdAtomStreamHeight; int _sdParticleStreamHeight;
int _sdAtomStreamSize; int _sdParticleStreamSize;
/** /**
* Get derived parameter string * Get derived parameter string
...@@ -374,26 +374,26 @@ class BrookLangevinDynamics : public BrookCommon { ...@@ -374,26 +374,26 @@ class BrookLangevinDynamics : public BrookCommon {
/* /*
* Setup of stream dimensions * Setup of stream dimensions
* *
* @param atomStreamSize atom stream size * @param particleStreamSize particle stream size
* @param atomStreamWidth atom stream width * @param particleStreamWidth particle stream width
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
* */ * */
int _initializeStreamSizes( int atomStreamSize, int atomStreamWidth ); int _initializeStreamSizes( int particleStreamSize, int particleStreamWidth );
/** /**
* Initialize stream dimensions * Initialize stream dimensions
* *
* @param numberOfAtoms number of atoms * @param numberOfParticles number of particles
* @param platform platform * @param platform platform
* *
* @return ErrorReturnValue if error, else DefaultReturnValue * @return ErrorReturnValue if error, else DefaultReturnValue
* *
*/ */
int _initializeStreamSizes( int numberOfAtoms, const Platform& platform ); int _initializeStreamSizes( int numberOfParticles, const Platform& platform );
/** /**
* Initialize stream dimensions and streams * Initialize stream dimensions and streams
...@@ -409,7 +409,7 @@ class BrookLangevinDynamics : public BrookCommon { ...@@ -409,7 +409,7 @@ class BrookLangevinDynamics : public BrookCommon {
/** /**
* Set masses * Set masses
* *
* @param masses atomic masses * @param masses particle masses
* *
*/ */
......
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