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";
*/
BrookCalcRBTorsionForceKernel::BrookCalcRBTorsionForceKernel( std::string name, const Platform& platform,
OpenMMBrookInterface& openMMBrookInterface, System& system ) :
OpenMMBrookInterface& openMMBrookInterface, System& system ) :
CalcRBTorsionForceKernel( name, platform ), _openMMBrookInterface( openMMBrookInterface ), _system( system ){
// ---------------------------------------------------------------------------------------
......@@ -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();
if( _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++ ){
int particle1, particle2, particle3, particle4;
double c0, c1, c2, c3, c4, c5;
int particles[NumberOfAtomsInBond];
int particles[NumberOfParticlesInBond];
double parameters[NumberOfParametersInBond];
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
}
/**
* Compute forces given atom coordinates
* Compute forces given particle coordinates
*
* @param context OpenMMContextImpl context
*
......
......@@ -72,7 +72,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
/**
* Execute the kernel to calculate the forces.
*
* @param positions atom coordiantes
* @param positions particle coordiantes
* @param forces output forces
*
*/
......@@ -133,7 +133,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
/**
* Get indices/parameters
*
* @return BrookBondParameters containing atom indices/parameters
* @return BrookBondParameters containing particle indices/parameters
*
*/
......@@ -141,7 +141,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
private:
static const int NumberOfAtomsInBond = 4;
static const int NumberOfParticlesInBond = 4;
static const int NumberOfParametersInBond = 6;
// 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;
// bonded streams
const std::string BrookCommon::BondedAtomIndicesStream = "BondedAtomIndicesStream";
const std::string BrookCommon::BondedParticleIndicesStream = "BondedParticleIndicesStream";
const std::string BrookCommon::BondedParametersStream = "BondedParametersStream";
const std::string BrookCommon::UnrolledForceStream = "UnrolledForceStream";
const std::string BrookCommon::BondedChargeStream = "BondedChargeStream";
......@@ -61,9 +61,9 @@ const std::string BrookCommon::PartialForceStream
// OBC Gbsa streams
const std::string BrookCommon::ObcAtomicRadiiStream = "ObcAtomicRadiiStream";
const std::string BrookCommon::ObcScaledAtomicRadiiStream = "ObcScaledAtomicRadiiStream";
const std::string BrookCommon::ObcAtomicRadiiWithDielectricOffsetStream = "ObcAtomicRadiiWithDielectricOffsetStream";
const std::string BrookCommon::ObcParticleRadiiStream = "ObcParticleRadiiStream";
const std::string BrookCommon::ObcScaledParticleRadiiStream = "ObcScaledParticleRadiiStream";
const std::string BrookCommon::ObcParticleRadiiWithDielectricOffsetStream = "ObcParticleRadiiWithDielectricOffsetStream";
const std::string BrookCommon::ObcBornRadiiStream = "ObcBornRadiiStream";
const std::string BrookCommon::ObcBornRadii2Stream = "ObcBornRadii2Stream";
const std::string BrookCommon::ObcIntermediateForceStream = "ObcIntermediateForceStream";
......@@ -81,8 +81,8 @@ const std::string BrookCommon::InverseMassStream
// Shake streams
const std::string BrookCommon::ShakeAtomIndicesStream = "ShakeAtomIndicesStream";
const std::string BrookCommon::ShakeAtomParameterStream = "ShakeAtomParameterStream";
const std::string BrookCommon::ShakeParticleIndicesStream = "ShakeParticleIndicesStream";
const std::string BrookCommon::ShakeParticleParameterStream = "ShakeParticleParameterStream";
const std::string BrookCommon::ShakeXCons0Stream = "ShakeXCons0Stream";
const std::string BrookCommon::ShakeXCons1Stream = "ShakeXCons1Stream";
const std::string BrookCommon::ShakeXCons2Stream = "ShakeXCons2Stream";
......@@ -112,15 +112,15 @@ BrookCommon::BrookCommon( ){
// ---------------------------------------------------------------------------------------
_numberOfAtoms = 0;
_atomSizeModified = 0;
_numberOfParticles = 0;
_particleSizeModified = 0;
_atomStreamWidth = -1;
_atomStreamHeight = -1;
_atomStreamSize = -1;
_particleStreamWidth = -1;
_particleStreamHeight = -1;
_particleStreamSize = -1;
_log = NULL;
_verbosity = 0;
_log = NULL;
_verbosity = 0;
}
......@@ -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 {
return _numberOfAtoms;
int BrookCommon::getNumberOfParticles( void ) const {
return _numberOfParticles;
}
/**
* Get number of atoms
* Get number of particles
*
* @param numberOfAtoms number of atoms
* @return number of atoms
* @param numberOfParticles number of particles
* @return number of particles
*
*/
int BrookCommon::setNumberOfAtoms( int numberOfAtoms ){
if( numberOfAtoms != _numberOfAtoms ){
_atomSizeModified = numberOfAtoms;
int BrookCommon::setNumberOfParticles( int numberOfParticles ){
if( numberOfParticles != _numberOfParticles ){
_particleSizeModified = numberOfParticles;
}
_numberOfAtoms = numberOfAtoms;
return _numberOfAtoms;
_numberOfParticles = numberOfParticles;
return _numberOfParticles;
}
/**
* Get atom stream width
* Get particle stream width
*
* @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;
// ---------------------------------------------------------------------------------------
// get atom stream width
// get particle stream width
if( _atomStreamWidth < 0 ){
_getAtomStreamDimensions( platform );
if( _particleStreamWidth < 0 ){
_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;
// ---------------------------------------------------------------------------------------
return _atomStreamWidth;
return _particleStreamWidth;
}
/**
* Get atom stream height
* Get particle stream height
*
* @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;
// ---------------------------------------------------------------------------------------
// get atom stream height
// get particle stream height
if( _atomStreamHeight < 0 ){
_getAtomStreamDimensions( platform );
if( _particleStreamHeight < 0 ){
_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;
// ---------------------------------------------------------------------------------------
return _atomStreamHeight;
return _particleStreamHeight;
}
/**
* Get atom stream size
* Get particle stream size
*
* @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;
// ---------------------------------------------------------------------------------------
// get atom stream size
// get particle stream size
if( _atomStreamSize < 0 ){
_getAtomStreamDimensions( platform );
if( _particleStreamSize < 0 ){
_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 {
return _atomStreamSize;
int BrookCommon::getParticleStreamSize( void ) const {
return _particleStreamSize;
}
/**
* Get atom stream dimensions
* Get particle stream dimensions
*
* @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;
// ---------------------------------------------------------------------------------------
// get atom stream size
// get particle stream size
const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
const BrookStreamFactory& brookStreamFactory = dynamic_cast<const BrookStreamFactory&> (platform.getDefaultStreamFactory() );
_atomStreamWidth = brookStreamFactory.getDefaultAtomStreamWidth();
_atomStreamSize = brookPlatform.getStreamSize( getNumberOfAtoms(), _atomStreamWidth, NULL );
_atomStreamHeight = (int) ( ((float) _atomStreamSize)/( (float) _atomStreamWidth) + 0.001);
_particleStreamWidth = brookStreamFactory.getDefaultParticleStreamWidth();
_particleStreamSize = brookPlatform.getStreamSize( getNumberOfParticles(), _particleStreamWidth, NULL );
_particleStreamHeight = (int) ( ((float) _particleStreamSize)/( (float) _particleStreamWidth) + 0.001);
return;
}
......
......@@ -59,7 +59,7 @@ class BrookCommon {
// bonded stream names
static const std::string BondedAtomIndicesStream;
static const std::string BondedParticleIndicesStream;
static const std::string BondedParametersStream;
static const std::string UnrolledForceStream;
static const std::string BondedChargeStream;
......@@ -76,9 +76,9 @@ class BrookCommon {
// OBC Gbsa streams
static const std::string ObcAtomicRadiiStream;
static const std::string ObcScaledAtomicRadiiStream;
static const std::string ObcAtomicRadiiWithDielectricOffsetStream;
static const std::string ObcParticleRadiiStream;
static const std::string ObcScaledParticleRadiiStream;
static const std::string ObcParticleRadiiWithDielectricOffsetStream;
static const std::string ObcBornRadiiStream;
static const std::string ObcBornRadii2Stream;
static const std::string ObcIntermediateForceStream;
......@@ -96,8 +96,8 @@ class BrookCommon {
// Shake streams
static const std::string ShakeAtomIndicesStream;
static const std::string ShakeAtomParameterStream;
static const std::string ShakeParticleIndicesStream;
static const std::string ShakeParticleParameterStream;
static const std::string ShakeXCons0Stream;
static const std::string ShakeXCons1Stream;
static const std::string ShakeXCons2Stream;
......@@ -130,76 +130,76 @@ class 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
*
* @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
*
* @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
*
* @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
......@@ -314,19 +314,19 @@ class BrookCommon {
protected:
// number of atoms
// number of particles
int _numberOfAtoms;
int _numberOfParticles;
// atom stream dimensions
// particle stream dimensions
int _atomStreamWidth;
int _atomStreamHeight;
int _atomStreamSize;
int _particleStreamWidth;
int _particleStreamHeight;
int _particleStreamSize;
// atom size mod
// particle size mod
int _atomSizeModified;
int _particleSizeModified;
// log file reference
......@@ -337,22 +337,22 @@ class BrookCommon {
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
*
*/
void _getAtomStreamDimensions( const Platform& platform );
void _getParticleStreamDimensions( const Platform& platform );
/*
* Get line
......
......@@ -46,6 +46,8 @@ using namespace OpenMM;
* @param inputStreamWidth stream width
* @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,
......@@ -278,6 +280,18 @@ void BrookFloatStreamInternal::loadFromArray( const void* array, BrookStreamInte
_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 ){
// ---------------------------------------------------------------------------------------
......@@ -571,3 +585,53 @@ void* BrookFloatStreamInternal::getDataArray( void ){
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 {
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:
BrookOpenMMFloat _defaultDangleValue;
......
......@@ -34,6 +34,8 @@
#include "BrookPlatform.h"
#include "OpenMMException.h"
#include "BrookStreamImpl.h"
#include "gpu/kgbsa.h"
#include "gpu/kforce.h"
using namespace OpenMM;
using namespace std;
......@@ -51,7 +53,7 @@ BrookGbsa::BrookGbsa( ){
// ---------------------------------------------------------------------------------------
_atomSizeCeiling = -1;
_particleSizeCeiling = -1;
_outerUnroll = 4;
_innerUnroll = 4;
......@@ -59,9 +61,9 @@ BrookGbsa::BrookGbsa( ){
_partialForceStreamHeight = -1;
_partialForceStreamSize = -1;
_gbsaAtomStreamWidth = -1;
_gbsaAtomStreamHeight = -1;
_gbsaAtomStreamSize = -1;
_gbsaParticleStreamWidth = -1;
_gbsaParticleStreamHeight = -1;
_gbsaParticleStreamSize = -1;
_duplicationFactor = 4;
......@@ -200,37 +202,37 @@ float BrookGbsa::getDielectricOffset( void ) const {
int BrookGbsa::setOuterLoopUnroll( int outerUnroll ){
if( outerUnroll != _outerUnroll ){
_atomSizeCeiling = -1;
_particleSizeCeiling = -1;
}
_outerUnroll = _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);
localThis->_atomSizeCeiling = localThis->getNumberOfAtoms() % localThis->getOuterLoopUnroll();
if( localThis->_atomSizeCeiling ){
localThis->_atomSizeCeiling = localThis->getOuterLoopUnroll() - localThis->_atomSizeCeiling;
localThis->_particleSizeCeiling = localThis->getNumberOfParticles() % localThis->getOuterLoopUnroll();
if( localThis->_particleSizeCeiling ){
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 {
}
/**
* Get Atom stream size
* Get Particle stream size
*
* @return Atom stream size
* @return Particle stream size
*
*/
int BrookGbsa::getGbsaAtomStreamSize( void ) const {
return _gbsaAtomStreamSize;
int BrookGbsa::getGbsaParticleStreamSize( void ) const {
return _gbsaParticleStreamSize;
}
/**
* Get atom stream width
* Get particle stream width
*
* @return atom stream width
* @return particle stream width
*
*/
int BrookGbsa::getGbsaAtomStreamWidth( void ) const {
return _gbsaAtomStreamWidth;
int BrookGbsa::getGbsaParticleStreamWidth( void ) const {
return _gbsaParticleStreamWidth;
}
/**
* Get atom stream height
* Get particle stream height
*
* @return atom stream height
* @return particle stream height
*/
int BrookGbsa::getGbsaAtomStreamHeight( void ) const {
return _gbsaAtomStreamHeight;
int BrookGbsa::getGbsaParticleStreamHeight( void ) const {
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 {
return _gbsaStreams[ObcAtomicRadiiStream];
BrookFloatStreamInternal* BrookGbsa::getObcParticleRadii( void ) const {
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 {
return _gbsaStreams[ObcScaledAtomicRadiiStream];
BrookFloatStreamInternal* BrookGbsa::getObcScaledParticleRadii( void ) const {
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 {
return _gbsaStreams[ObcAtomicRadiiWithDielectricOffsetStream];
BrookFloatStreamInternal* BrookGbsa::getObcParticleRadiiWithDielectricOffset( void ) const {
return _gbsaStreams[ObcParticleRadiiWithDielectricOffsetStream];
}
/**
......@@ -457,15 +459,15 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
// load coordinates into RealOpenMM 2d array
int numberOfAtoms = getNumberOfAtoms();
int numberOfParticles = getNumberOfParticles();
RealOpenMM** atomCoordinates = new RealOpenMM*[numberOfAtoms];
RealOpenMM* atomCoordinatesBlk = new RealOpenMM[3*numberOfAtoms];
RealOpenMM** particleCoordinates = new RealOpenMM*[numberOfParticles];
RealOpenMM* particleCoordinatesBlk = new RealOpenMM[3*numberOfParticles];
// Born radii array size needs to match stream size since it will
// be written down to board
int streamSize = getGbsaAtomStreamSize();
int streamSize = getGbsaParticleStreamSize();
RealOpenMM* bornRadii = new RealOpenMM[streamSize];
memset( bornRadii, 0, sizeof( RealOpenMM )*streamSize );
......@@ -473,30 +475,30 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
memset( obcChain, 0, sizeof( RealOpenMM )*streamSize );
int index = 0;
RealOpenMM* atomCoordinatesBlkPtr = atomCoordinatesBlk;
for( int ii = 0; ii < numberOfAtoms; ii++ ){
RealOpenMM* particleCoordinatesBlkPtr = particleCoordinatesBlk;
for( int ii = 0; ii < numberOfParticles; ii++ ){
atomCoordinates[ii] = atomCoordinatesBlkPtr;
atomCoordinatesBlkPtr += 3;
particleCoordinates[ii] = particleCoordinatesBlkPtr;
particleCoordinatesBlkPtr += 3;
atomCoordinates[ii][0] = coordinates[index++];
atomCoordinates[ii][1] = coordinates[index++];
atomCoordinates[ii][2] = coordinates[index++];
particleCoordinates[ii][0] = coordinates[index++];
particleCoordinates[ii][1] = coordinates[index++];
particleCoordinates[ii][2] = coordinates[index++];
}
// calculate Born radii
_cpuObc->computeBornRadii( atomCoordinates, bornRadii, obcChain );
_cpuObc->computeBornRadii( particleCoordinates, bornRadii, obcChain );
// diagnostics
if( PrintOn && getLog() ){
(void) fprintf( getLog(), "\n%s: atms=%d\n", methodName.c_str(), numberOfAtoms );
for( int ii = 0; ii < numberOfAtoms; ii++ ){
(void) fprintf( getLog(), "\n%s: atms=%d\n", methodName.c_str(), numberOfParticles );
for( int ii = 0; ii < numberOfParticles; 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 ){
// free memory
delete[] atomCoordinatesBlk;
delete[] atomCoordinates;
delete[] particleCoordinatesBlk;
delete[] particleCoordinates;
delete[] bornRadii;
delete[] obcChain;
......@@ -519,14 +521,14 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param numberOfParticles number of particles
* @param platform platform
*
* @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
// ---------------------------------------------------------------------------------------
_gbsaAtomStreamSize = getAtomStreamSize( platform );
_gbsaAtomStreamWidth = getAtomStreamWidth( platform );
_gbsaAtomStreamHeight = getAtomStreamHeight( platform );
_gbsaParticleStreamSize = getParticleStreamSize( platform );
_gbsaParticleStreamWidth = getParticleStreamWidth( platform );
_gbsaParticleStreamHeight = getParticleStreamHeight( platform );
int innerUnroll = getInnerLoopUnroll();
if( innerUnroll < 1 ){
......@@ -553,7 +555,7 @@ int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platfor
return ErrorReturnValue;
}
_partialForceStreamSize = _gbsaAtomStreamSize*getDuplicationFactor()/innerUnroll;
_partialForceStreamSize = _gbsaParticleStreamSize*getDuplicationFactor()/innerUnroll;
_partialForceStreamHeight = _partialForceStreamSize/_partialForceStreamWidth;
_partialForceStreamHeight += ( (_partialForceStreamSize % _partialForceStreamWidth) ? 1 : 0);
_partialForceStreamSize = _partialForceStreamHeight*_partialForceStreamWidth;
......@@ -579,49 +581,49 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
// ---------------------------------------------------------------------------------------
int gbsaAtomStreamSize = getGbsaAtomStreamSize();
int gbsaAtomStreamWidth = getGbsaAtomStreamWidth();
int gbsaParticleStreamSize = getGbsaParticleStreamSize();
int gbsaParticleStreamWidth = getGbsaParticleStreamWidth();
// atomic radii & charge
// particle radii & charge
_gbsaStreams[ObcAtomicRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcAtomicRadiiStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth,
_gbsaStreams[ObcParticleRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcParticleRadiiStream,
gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue );
// scaled atomic radii
// scaled particle radii
_gbsaStreams[ObcScaledAtomicRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcScaledAtomicRadiiStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth,
_gbsaStreams[ObcScaledParticleRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcScaledParticleRadiiStream,
gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue );
// atomic radii w/ DielectricOffset
// particle radii w/ DielectricOffset
_gbsaStreams[ObcAtomicRadiiWithDielectricOffsetStream] = new BrookFloatStreamInternal( BrookCommon::ObcAtomicRadiiWithDielectricOffsetStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth,
_gbsaStreams[ObcParticleRadiiWithDielectricOffsetStream] = new BrookFloatStreamInternal( BrookCommon::ObcParticleRadiiWithDielectricOffsetStream,
gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue );
// Born radii
_gbsaStreams[ObcBornRadiiStream] = new BrookFloatStreamInternal( BrookCommon::ObcBornRadiiStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth,
gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue );
// Born2 radii
_gbsaStreams[ObcBornRadii2Stream] = new BrookFloatStreamInternal( BrookCommon::ObcBornRadii2Stream,
gbsaAtomStreamSize, gbsaAtomStreamWidth,
gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue );
// IntermediateForce
_gbsaStreams[ObcIntermediateForceStream] = new BrookFloatStreamInternal( BrookCommon::ObcIntermediateForceStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth,
gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float4, dangleValue );
// Obc chain
_gbsaStreams[ObcChainStream] = new BrookFloatStreamInternal( BrookCommon::ObcChainStream,
gbsaAtomStreamSize, gbsaAtomStreamWidth,
gbsaParticleStreamSize, gbsaParticleStreamWidth,
BrookStreamInternal::Float, dangleValue );
// partial force streams
......@@ -640,9 +642,9 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
/*
* Setup of Gbsa parameters
*
* @param atomParameters vector of OBC parameters [atomI][0=charge]
* [atomI][1=radius]
* [atomI][2=scaling factor]
* @param particleParameters vector of OBC parameters [particleI][0=charge]
* [particleI][1=radius]
* [particleI][2=scaling factor]
* @param solventDielectric solvent dielectric
* @param soluteDielectric solute dielectric
* @param platform Brook 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 ){
// ---------------------------------------------------------------------------------------
static const int atomParametersSize = 3;
static const int particleParametersSize = 3;
static const int maxErrors = 20;
static const std::string methodName = "BrookGbsa::setup";
// ---------------------------------------------------------------------------------------
int numberOfAtoms = (int) vectorOfAtomParameters.size();
setNumberOfAtoms( numberOfAtoms );
int numberOfParticles = (int) vectorOfParticleParameters.size();
setNumberOfParticles( numberOfParticles );
_solventDielectric = solventDielectric;
_soluteDielectric = soluteDielectric;
// initialize stream sizes and then Brook streams
initializeStreamSizes( numberOfAtoms, platform );
initializeStreamSizes( numberOfParticles, platform );
initializeStreams( platform );
int atomStreamSize = getGbsaAtomStreamSize();
BrookOpenMMFloat* radiiAndCharge = new BrookOpenMMFloat[atomStreamSize*2];
BrookOpenMMFloat* scaledRadiiAndOffset = new BrookOpenMMFloat[atomStreamSize*2];
memset( radiiAndCharge, 0, atomStreamSize*2*sizeof( BrookOpenMMFloat ) );
memset( scaledRadiiAndOffset, 0, atomStreamSize*2*sizeof( BrookOpenMMFloat ) );
int particleStreamSize = getGbsaParticleStreamSize();
BrookOpenMMFloat* radiiAndCharge = new BrookOpenMMFloat[particleStreamSize*2];
BrookOpenMMFloat* scaledRadiiAndOffset = new BrookOpenMMFloat[particleStreamSize*2];
memset( radiiAndCharge, 0, particleStreamSize*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
vector<RealOpenMM> atomicRadii(numberOfAtoms);
vector<RealOpenMM> scaleFactors(numberOfAtoms);
vector<RealOpenMM> particleRadii(numberOfParticles);
vector<RealOpenMM> scaleFactors(numberOfParticles);
float dielectricOffset = getDielectricOffset();
// loop over atom parameters
// loop over particle parameters
// track any errors and then throw exception
// check parameter vector is right size
// set parameter entries or board and arrays used by CpuObc
......@@ -700,22 +702,22 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
typedef std::vector< std::vector<double> > VectorOfDoubleVectors;
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 ){
message << methodName << " parameter size=" << atomParameters.size() << " for parameter vector index=" << vectorIndex << " is less than expected.\n";
if( particleParameters.size() != particleParametersSize && errors < maxErrors ){
message << methodName << " parameter size=" << particleParameters.size() << " for parameter vector index=" << vectorIndex << " is less than expected.\n";
errors++;
} else {
double charge = atomParameters[0];
double radius = atomParameters[1];
double scalingFactor = atomParameters[2];
double charge = particleParameters[0];
double radius = particleParameters[1];
double scalingFactor = particleParameters[2];
int streamIndex = 2*vectorIndex;
atomicRadii[vectorIndex] = static_cast<RealOpenMM> (radius);
particleRadii[vectorIndex] = static_cast<RealOpenMM> (radius);
scaleFactors[vectorIndex] = static_cast<RealOpenMM> (scalingFactor);
_charges[vectorIndex] = static_cast<RealOpenMM> (charge);
......@@ -741,16 +743,16 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
// load streams
_gbsaStreams[ObcAtomicRadiiStream]->loadFromArray( radiiAndCharge );
_gbsaStreams[ObcScaledAtomicRadiiStream]->loadFromArray( scaledRadiiAndOffset );
_gbsaStreams[ObcParticleRadiiStream]->loadFromArray( radiiAndCharge );
_gbsaStreams[ObcScaledParticleRadiiStream]->loadFromArray( scaledRadiiAndOffset );
delete[] radiiAndCharge;
delete[] scaledRadiiAndOffset;
// setup for Born radii calculation
ObcParameters* obcParameters = new ObcParameters( numberOfAtoms, ObcParameters::ObcTypeII );
obcParameters->setAtomicRadii( atomicRadii);
ObcParameters* obcParameters = new ObcParameters( numberOfParticles, ObcParameters::ObcTypeII );
obcParameters->setAtomicRadii( particleRadii);
obcParameters->setScaledRadiusFactors( scaleFactors );
obcParameters->setSolventDielectric( static_cast<RealOpenMM>(solventDielectric) );
......@@ -765,14 +767,14 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
/*
* Setup of stream dimensions for partial force streams
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
* @param particleStreamSize particle stream size
* @param particleStreamWidth particle stream width
*
* @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
return ErrorReturnValue;
}
_partialForceStreamSize = atomStreamSize*getDuplicationFactor()/innerUnroll;
_partialForceStreamSize = particleStreamSize*getDuplicationFactor()/innerUnroll;
_partialForceStreamHeight = _partialForceStreamSize/_partialForceStreamWidth;
_partialForceStreamHeight += ( (_partialForceStreamSize % _partialForceStreamWidth) ? 1 : 0);
......@@ -837,8 +839,8 @@ std::string BrookGbsa::getContentsString( int level ) const {
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );
#endif
(void) LOCAL_SPRINTF( value, "%d", getNumberOfAtoms() );
message << _getLine( tab, "Number of atoms:", value );
(void) LOCAL_SPRINTF( value, "%d", getNumberOfParticles() );
message << _getLine( tab, "Number of particles:", value );
(void) LOCAL_SPRINTF( value, "%d", getNumberOfForceStreams() );
message << _getLine( tab, "Number of force streams:", value );
......@@ -852,17 +854,17 @@ std::string BrookGbsa::getContentsString( int level ) const {
(void) LOCAL_SPRINTF( value, "%d", getOuterLoopUnroll() )
message << _getLine( tab, "Outer loop unroll:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomSizeCeiling() );
message << _getLine( tab, "Atom ceiling:", value );
(void) LOCAL_SPRINTF( value, "%d", getParticleSizeCeiling() );
message << _getLine( tab, "Particle ceiling:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamWidth() );
message << _getLine( tab, "Atom stream width:", value );
(void) LOCAL_SPRINTF( value, "%d", getParticleStreamWidth() );
message << _getLine( tab, "Particle stream width:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamHeight() );
message << _getLine( tab, "Atom stream height:", value );
(void) LOCAL_SPRINTF( value, "%d", getParticleStreamHeight() );
message << _getLine( tab, "Particle stream height:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamSize() );
message << _getLine( tab, "Atom stream size:", value );
(void) LOCAL_SPRINTF( value, "%d", getParticleStreamSize() );
message << _getLine( tab, "Particle stream size:", value );
(void) LOCAL_SPRINTF( value, "%d", getPartialForceStreamWidth() );
message << _getLine( tab, "Partial force stream width:", value );
......@@ -905,7 +907,7 @@ std::string BrookGbsa::getContentsString( int level ) const {
/*
* Calculate OBC energy
*
* @param atomPositions atom positions
* @param particlePositions particle positions
* @return energy
*
......@@ -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 ){
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);
BrookOpenMMFloat* positionsF = (BrookOpenMMFloat*) positionStream.getData();
......@@ -951,3 +953,277 @@ double BrookGbsa::getEnergy( const Stream& atomPositions ){
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 @@
#include <vector>
#include <set>
#include "BrookFloatStreamInternal.h"
#include "BrookStreamImpl.h"
#include "BrookPlatform.h"
#include "BrookCommon.h"
#include "../../../platforms/reference/src/gbsa/CpuObc.h"
......@@ -85,13 +85,13 @@ class BrookGbsa : public BrookCommon {
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
......@@ -154,28 +154,28 @@ class BrookGbsa : public BrookCommon {
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
......@@ -202,31 +202,31 @@ class BrookGbsa : public BrookCommon {
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
......@@ -312,9 +312,9 @@ class BrookGbsa : public BrookCommon {
/*
* Setup of Gbsa parameters
*
* @param atomParameters vector of OBC parameters [atomI][0=charge]
* [atomI][1=radius]
* [atomI][2=scaling factor]
* @param particleParameters vector of OBC parameters [particleI][0=charge]
* [particleI][1=radius]
* [particleI][2=scaling factor]
* @param solventDielectric solvent dielectric
* @param soluteDielectric solute dielectric
* @param platform Brook platform
......@@ -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 );
/*
......@@ -340,7 +340,7 @@ class BrookGbsa : public BrookCommon {
/*
* Calculate energy
*
* @param atomPositions atom positions
* @param particlePositions particle positions
* @return energy
*
......@@ -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:
......@@ -359,9 +366,9 @@ class BrookGbsa : public BrookCommon {
// streams indices
enum {
ObcAtomicRadiiStream,
ObcScaledAtomicRadiiStream,
ObcAtomicRadiiWithDielectricOffsetStream,
ObcParticleRadiiStream,
ObcScaledParticleRadiiStream,
ObcParticleRadiiWithDielectricOffsetStream,
ObcBornRadiiStream,
ObcBornRadii2Stream,
ObcIntermediateForceStream,
......@@ -369,9 +376,9 @@ class BrookGbsa : public BrookCommon {
LastStreamIndex
};
// atom ceiling
// particle ceiling
int _atomSizeCeiling;
int _particleSizeCeiling;
// unroll in i/j dimensions
......@@ -392,11 +399,11 @@ class BrookGbsa : public BrookCommon {
int _partialForceStreamHeight;
int _partialForceStreamSize;
// Atom stream dimensions
// Particle stream dimensions
int _gbsaAtomStreamWidth;
int _gbsaAtomStreamHeight;
int _gbsaAtomStreamSize;
int _gbsaParticleStreamWidth;
int _gbsaParticleStreamHeight;
int _gbsaParticleStreamSize;
// dielectrics
......@@ -414,7 +421,7 @@ class BrookGbsa : public BrookCommon {
int _bornRadiiInitialized;
// atom charges
// particle charges
RealOpenMM* _charges;
......@@ -425,26 +432,26 @@ class BrookGbsa : public BrookCommon {
/*
* Setup of stream dimensions
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
* @param particleStreamSize particle stream size
* @param particleStreamWidth particle stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int initializeStreamSizes( int atomStreamSize, int atomStreamWidth );
int initializeStreamSizes( int particleStreamSize, int particleStreamWidth );
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param numberOfParticles number of particles
* @param platform platform
*
* @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
......@@ -460,14 +467,14 @@ class BrookGbsa : public BrookCommon {
/*
* Setup of stream dimensions for partial force streams
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
* @param particleStreamSize particle stream size
* @param particleStreamWidth particle stream width
*
* @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 {
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:
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:
int _dangleValue;
......
......@@ -80,9 +80,9 @@ BrookIntegrateBrownianStepKernel::~BrookIntegrateBrownianStepKernel( ){
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each atom
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms
* @param masses the mass of each particle
* @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 particles
*
*/
......@@ -112,9 +112,9 @@ void BrookIntegrateBrownianStepKernel::initialize( const vector<double>& masses,
/**
* Execute kernel
*
* @param positions atom coordinates
* @param velocities atom velocities
* @param forces atom forces
* @param positions particle coordinates
* @param velocities particle velocities
* @param forces particle forces
* @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath
* @param stepSize integration step size
......
......@@ -72,9 +72,9 @@ class BrookIntegrateBrownianStepKernel : public IntegrateBrownianStepKernel {
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses atom masses
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained atoms
* @param masses particle masses
* @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained particles
*/
void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
......
......@@ -80,9 +80,9 @@ BrookIntegrateLangevinStepKernel::~BrookIntegrateLangevinStepKernel( ){
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each atom
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms
* @param masses the mass of each particle
* @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 particles
*
*/
......@@ -112,9 +112,9 @@ void BrookIntegrateLangevinStepKernel::initialize( const vector<double>& masses,
/**
* Execute kernel
*
* @param positions atom coordinates
* @param velocities atom velocities
* @param forces atom forces
* @param positions particle coordinates
* @param velocities particle velocities
* @param forces particle forces
* @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath
* @param stepSize integration step size
......
......@@ -72,9 +72,9 @@ class BrookIntegrateLangevinStepKernel : public IntegrateLangevinStepKernel {
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses atom masses
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained atoms
* @param masses particle masses
* @param constraintIndices each element contains the indices of two particles whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained particles
*/
void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
......
......@@ -77,9 +77,9 @@ BrookIntegrateVerletStepKernel::~BrookIntegrateVerletStepKernel( ){
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each atom
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms
* @param masses the mass of each particle
* @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 particles
*
*/
......@@ -104,9 +104,9 @@ void BrookIntegrateVerletStepKernel::initialize( const vector<double>& masses,
/**
* Execute kernel
*
* @param positions atom coordinates
* @param velocities atom velocities
* @param forces atom forces
* @param positions particle coordinates
* @param velocities particle velocities
* @param forces particle forces
* @param stepSize integration step size
*
*/
......
......@@ -66,9 +66,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each atom
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms
* @param masses the mass of each particle
* @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 particles
*
*/
void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
......@@ -76,9 +76,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
/**
* Execute kernel
*
* @param positions atom coordinates
* @param velocities atom velocities
* @param forces atom forces
* @param positions particle coordinates
* @param velocities particle velocities
* @param forces particle forces
* @param stepSize integration step size
*
*/
......
......@@ -30,13 +30,15 @@
* -------------------------------------------------------------------------- */
#include "BrookKernelFactory.h"
#include "BrookCalcHarmonicAngleForceKernel.h"
#include "BrookCalcNonbondedForceKernel.h"
#include "BrookIntegrateLangevinStepKernel.h"
#include "BrookIntegrateVerletStepKernel.h"
#include "BrookIntegrateBrownianStepKernel.h"
#include "BrookCalcKineticEnergyKernel.h"
#include "BrookCalcGBSAOBCForceKernel.h"
//#include "BrookCalcGBSAOBCForceKernel.h"
#include "BrookRemoveCMMotionKernel.h"
#include "internal/OpenMMContextImpl.h"
using namespace OpenMM;
......@@ -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
} else if( name == CalcGBSAOBCForceKernel::Name() ){
return new BrookCalcGBSAOBCForceKernel(name, platform);
// return new BrookCalcGBSAOBCForceFieldKernel( name, platform, openMMBrookInterface, context.getSystem() );
// Verlet integrator
} else if( name == IntegrateVerletStepKernel::Name() ){
return new BrookIntegrateVerletStepKernel( name, platform );
// return new BrookIntegrateVerletStepKernel( name, platform, openMMBrookInterface );
// Brownian integrator
} else if( name == IntegrateBrownianStepKernel::Name() ){
return new BrookIntegrateBrownianStepKernel( name, platform );
// return new BrookIntegrateBrownianStepKernel( name, platform, openMMBrookInterface );
// Andersen thermostat
} else if( name == ApplyAndersenThermostatKernel::Name() ){
// return new BrookIntegrateAndersenThermostatKernel( name, platform );
// return new BrookIntegrateAndersenThermostatKernel( name, platform, openMMBrookInterface );
// Langevin integrator
} else if( name == IntegrateLangevinStepKernel::Name() ){
return new BrookIntegrateLangevinStepKernel( name, platform );
// return new BrookIntegrateLangevinStepKernel( name, platform, openMMBrookInterface );
// Remove com
} else if( name == RemoveCMMotionKernel::Name() ){
return new BrookRemoveCMMotionKernel( name, platform );
// return new BrookRemoveCMMotionKernel( name, platform, openMMBrookInterface );
// KE calculator
} 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() );
......
......@@ -63,13 +63,13 @@ BrookLangevinDynamics::BrookLangevinDynamics( ){
// ---------------------------------------------------------------------------------------
_numberOfAtoms = -1;
_numberOfParticles = -1;
// mark stream dimension variables as unset
_sdAtomStreamWidth = -1;
_sdAtomStreamHeight = -1;
_sdAtomStreamSize = -1;
_sdParticleStreamWidth = -1;
_sdParticleStreamHeight = -1;
_sdParticleStreamSize = -1;
for( int ii = 0; ii < LastStreamIndex; ii++ ){
_sdStreams[ii] = NULL;
......@@ -352,9 +352,9 @@ int BrookLangevinDynamics::updateParameters( double temperature, double friction
/**
* Update
*
* @param positions atom positions
* @param velocities atom velocities
* @param forces atom forces
* @param positions particle positions
* @param velocities particle velocities
* @param forces particle forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
*
......@@ -414,7 +414,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// first integration step
kupdate_sd1_fix1(
(float) getLangevinDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsParticleStreamWidth(),
(float) brookRandomNumberGenerator.getRandomNumberStreamWidth(),
(float) brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[EM],
......@@ -436,9 +436,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// diagnostics
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]",
getLangevinDynamicsAtomStreamWidth(),
getLangevinDynamicsParticleStreamWidth(),
brookRandomNumberGenerator.getRandomNumberStreamWidth(),
brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[EM], derivedParameters[Sd1pc1], derivedParameters[Sd1pc2], derivedParameters[Sd1pc3] );
......@@ -481,20 +481,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// advance random number cursor
brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfAtoms() );
brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfParticles() );
// first Shake step
if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){
kshakeh_fix1(
10.0f,
(float) getLangevinDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsParticleStreamWidth(),
brookShakeAlgorithm.getInverseHydrogenMass(),
omega,
brookShakeAlgorithm.getShakeAtomIndicesStream()->getBrookStream(),
brookShakeAlgorithm.getShakeParticleIndicesStream()->getBrookStream(),
positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(),
brookShakeAlgorithm.getShakeAtomParameterStream()->getBrookStream(),
brookShakeAlgorithm.getShakeParticleParameterStream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(),
......@@ -503,7 +503,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// first Shake gather
kshakeh_update1_fix1(
(float) getLangevinDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsParticleStreamWidth(),
derivedParameters[Sd2pc1],
brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(),
positionStream.getBrookStream(),
......@@ -519,7 +519,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// second integration step
kupdate_sd2_fix1(
(float) getLangevinDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsParticleStreamWidth(),
(float) brookRandomNumberGenerator.getRandomNumberStreamWidth(),
(float) brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[Sd2pc1],
......@@ -538,9 +538,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// diagnostics
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]",
getLangevinDynamicsAtomStreamWidth(),
getLangevinDynamicsParticleStreamWidth(),
brookRandomNumberGenerator.getRandomNumberStreamWidth(),
brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[Sd2pc1], derivedParameters[Sd2pc2] );
......@@ -574,20 +574,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// advance random number cursor
brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfAtoms() );
brookRandomNumberGenerator.advanceGVCursor( 2*getNumberOfParticles() );
// second Shake step
if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){
kshakeh_fix1(
10.0f,
(float) getLangevinDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsParticleStreamWidth(),
brookShakeAlgorithm.getInverseHydrogenMass(),
omega,
brookShakeAlgorithm.getShakeAtomIndicesStream()->getBrookStream(),
brookShakeAlgorithm.getShakeParticleIndicesStream()->getBrookStream(),
positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(),
brookShakeAlgorithm.getShakeAtomParameterStream()->getBrookStream(),
brookShakeAlgorithm.getShakeParticleParameterStream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(),
......@@ -596,7 +596,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// second Shake gather
kshakeh_update2_fix1(
(float) getLangevinDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsParticleStreamWidth(),
brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(),
positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(),
......@@ -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 {
return _sdAtomStreamSize;
int BrookLangevinDynamics::getLangevinDynamicsParticleStreamSize( void ) const {
return _sdParticleStreamSize;
}
/**
* Get atom stream width
* Get particle stream width
*
* @return atom stream width
* @return particle stream width
*
*/
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamWidth( void ) const {
return _sdAtomStreamWidth;
int BrookLangevinDynamics::getLangevinDynamicsParticleStreamWidth( void ) const {
return _sdParticleStreamWidth;
}
/**
* Get atom stream height
* Get particle stream height
*
* @return atom stream height
* @return particle stream height
*/
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamHeight( void ) const {
return _sdAtomStreamHeight;
int BrookLangevinDynamics::getLangevinDynamicsParticleStreamHeight( void ) const {
return _sdParticleStreamHeight;
}
/**
......@@ -746,14 +746,14 @@ BrookFloatStreamInternal* BrookLangevinDynamics::getInverseMassStream( void ) co
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param numberOfParticles number of particles
* @param platform platform
*
* @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
// ---------------------------------------------------------------------------------------
_sdAtomStreamSize = getAtomStreamSize( platform );
_sdAtomStreamWidth = getAtomStreamWidth( platform );
_sdAtomStreamHeight = getAtomStreamHeight( platform );
_sdParticleStreamSize = getParticleStreamSize( platform );
_sdParticleStreamWidth = getParticleStreamWidth( platform );
_sdParticleStreamHeight = getParticleStreamHeight( platform );
return DefaultReturnValue;
}
......@@ -771,7 +771,7 @@ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Plat
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param numberOfParticles number of particles
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
......@@ -886,35 +886,35 @@ int BrookLangevinDynamics::_initializeStreams( const Platform& platform ){
// ---------------------------------------------------------------------------------------
int sdAtomStreamSize = getLangevinDynamicsAtomStreamSize();
int sdAtomStreamWidth = getLangevinDynamicsAtomStreamWidth();
int sdParticleStreamSize = getLangevinDynamicsParticleStreamSize();
int sdParticleStreamWidth = getLangevinDynamicsParticleStreamWidth();
_sdStreams[SDPC1Stream] = new BrookFloatStreamInternal( BrookCommon::SDPC1Stream,
sdAtomStreamSize, sdAtomStreamWidth,
sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue );
_sdStreams[SDPC2Stream] = new BrookFloatStreamInternal( BrookCommon::SDPC2Stream,
sdAtomStreamSize, sdAtomStreamWidth,
sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float2, dangleValue );
_sdStreams[SD2XStream] = new BrookFloatStreamInternal( BrookCommon::SD2XStream,
sdAtomStreamSize, sdAtomStreamWidth,
sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue );
_sdStreams[SD1VStream] = new BrookFloatStreamInternal( BrookCommon::SD1VStream,
sdAtomStreamSize, sdAtomStreamWidth,
sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue );
_sdStreams[VPrimeStream] = new BrookFloatStreamInternal( BrookCommon::VPrimeStream,
sdAtomStreamSize, sdAtomStreamWidth,
sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue );
_sdStreams[XPrimeStream] = new BrookFloatStreamInternal( BrookCommon::XPrimeStream,
sdAtomStreamSize, sdAtomStreamWidth,
sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float3, dangleValue );
_sdStreams[InverseMassStream] = new BrookFloatStreamInternal( BrookCommon::InverseMassStream,
sdAtomStreamSize, sdAtomStreamWidth,
sdParticleStreamSize, sdParticleStreamWidth,
BrookStreamInternal::Float, dangleValue );
return DefaultReturnValue;
......@@ -935,20 +935,20 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
// ---------------------------------------------------------------------------------------
int sdAtomStreamSize = getLangevinDynamicsAtomStreamSize();
int sdParticleStreamSize = getLangevinDynamicsParticleStreamSize();
BrookOpenMMFloat* sdpc[2];
for( int ii = 0; ii < 2; ii++ ){
sdpc[ii] = new BrookOpenMMFloat[2*sdAtomStreamSize];
memset( sdpc[ii], 0, 2*sdAtomStreamSize*sizeof( BrookOpenMMFloat ) );
sdpc[ii] = new BrookOpenMMFloat[2*sdParticleStreamSize];
memset( sdpc[ii], 0, 2*sdParticleStreamSize*sizeof( BrookOpenMMFloat ) );
}
BrookOpenMMFloat* inverseMass = new BrookOpenMMFloat[sdAtomStreamSize];
memset( inverseMass, 0, sdAtomStreamSize*sizeof( BrookOpenMMFloat ) );
BrookOpenMMFloat* inverseMass = new BrookOpenMMFloat[sdParticleStreamSize];
memset( inverseMass, 0, sdParticleStreamSize*sizeof( BrookOpenMMFloat ) );
const BrookOpenMMFloat* derivedParameters = getDerivedParameters( );
int numberOfAtoms = getNumberOfAtoms();
int numberOfParticles = getNumberOfParticles();
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+1] = _inverseSqrtMasses[ii]*( static_cast<BrookOpenMMFloat> (derivedParameters[V]) );
......@@ -971,13 +971,13 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
// initialize SD2X
BrookOpenMMFloat* sd2x = new BrookOpenMMFloat[3*sdAtomStreamSize];
BrookOpenMMFloat* sd2x = new BrookOpenMMFloat[3*sdParticleStreamSize];
//SimTKOpenMMUtilities::setRandomNumberSeed( (uint32_t) getRandomNumberSeed() );
memset( sd2x, 0, 3*sdAtomStreamSize*sizeof( BrookOpenMMFloat ) );
memset( sd2x, 0, 3*sdParticleStreamSize*sizeof( BrookOpenMMFloat ) );
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+1] = _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 ){
/**
* Set masses
*
* @param masses atomic masses
* @param masses particle masses
*
*/
......@@ -1046,12 +1046,12 @@ int BrookLangevinDynamics::setup( const std::vector<double>& masses, const Platf
const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
setLog( brookPlatform.getLog() );
int numberOfAtoms = (int) masses.size();
setNumberOfAtoms( numberOfAtoms );
int numberOfParticles = (int) masses.size();
setNumberOfParticles( numberOfParticles );
// set stream sizes and then create streams
_initializeStreamSizes( numberOfAtoms, platform );
_initializeStreamSizes( numberOfParticles, platform );
_initializeStreams( platform );
_setInverseSqrtMasses( masses );
......@@ -1090,17 +1090,17 @@ std::string BrookLangevinDynamics::getContentsString( int level ) const {
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );
#endif
(void) LOCAL_SPRINTF( value, "%d", getNumberOfAtoms() );
message << _getLine( tab, "Number of atoms:", value );
(void) LOCAL_SPRINTF( value, "%d", getNumberOfParticles() );
message << _getLine( tab, "Number of particles:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamWidth() );
message << _getLine( tab, "Atom stream width:", value );
(void) LOCAL_SPRINTF( value, "%d", getParticleStreamWidth() );
message << _getLine( tab, "Particle stream width:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamHeight() );
message << _getLine( tab, "Atom stream height:", value );
(void) LOCAL_SPRINTF( value, "%d", getParticleStreamHeight() );
message << _getLine( tab, "Particle stream height:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamSize() );
message << _getLine( tab, "Atom stream size:", value );
(void) LOCAL_SPRINTF( value, "%d", getParticleStreamSize() );
message << _getLine( tab, "Particle stream size:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getTau() );
message << _getLine( tab, "Tau:", value );
......
......@@ -110,28 +110,28 @@ class BrookLangevinDynamics : public BrookCommon {
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
......@@ -149,9 +149,9 @@ class BrookLangevinDynamics : public BrookCommon {
/**
* Update
*
* @param positions atom positions
* @param velocities atom velocities
* @param forces atom forces
* @param positions particle positions
* @param velocities particle velocities
* @param forces particle forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
*
......@@ -174,7 +174,7 @@ class BrookLangevinDynamics : public BrookCommon {
/*
* Setup of LangevinDynamics parameters
*
* @param masses atom masses
* @param masses particle masses
* @param platform Brook platform
*
* @return ErrorReturnValue value if error, else DefaultReturnValue
......@@ -285,11 +285,11 @@ class BrookLangevinDynamics : public BrookCommon {
BrookOpenMMFloat _temperature;
BrookOpenMMFloat _stepSize;
// Atom stream dimensions
// Particle stream dimensions
int _sdAtomStreamWidth;
int _sdAtomStreamHeight;
int _sdAtomStreamSize;
int _sdParticleStreamWidth;
int _sdParticleStreamHeight;
int _sdParticleStreamSize;
/**
* Get derived parameter string
......@@ -374,26 +374,26 @@ class BrookLangevinDynamics : public BrookCommon {
/*
* Setup of stream dimensions
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
* @param particleStreamSize particle stream size
* @param particleStreamWidth particle stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int _initializeStreamSizes( int atomStreamSize, int atomStreamWidth );
int _initializeStreamSizes( int particleStreamSize, int particleStreamWidth );
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param numberOfParticles number of particles
* @param platform platform
*
* @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
......@@ -409,7 +409,7 @@ class BrookLangevinDynamics : public BrookCommon {
/**
* 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