"platforms/cpu/vscode:/vscode.git/clone" did not exist on "074e3cd9aa627441411232b94a08a6e9c4373f0c"
Commit 170e493a authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Added Brownian dynamics code (including kernels); renamed StochasticDynamics LangevinDynamics

Added license to kernel and kernel include files
parent d3614c8b
/* -------------------------------------------------------------------------- *
* 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: 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 <sstream>
#include "BrookBrownianDynamics.h"
#include "BrookPlatform.h"
#include "OpenMMException.h"
#include "BrookStreamImpl.h"
#include "gpu/kshakeh.h"
#include "gpu/kupdatebd.h"
#include "gpu/kcommon.h"
// use random number generator
#include "../../reference/src/SimTKUtilities/SimTKOpenMMUtilities.h"
#include "../../reference/src/SimTKUtilities/SimTKOpenMMRealType.h"
using namespace OpenMM;
using namespace std;
/**
*
* Constructor
*
*/
BrookBrownianDynamics::BrookBrownianDynamics( ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::BrookBrownianDynamics";
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
BrookOpenMMFloat one = (BrookOpenMMFloat) 1.0;
BrookOpenMMFloat oneMinus = (BrookOpenMMFloat) -1.0;
// ---------------------------------------------------------------------------------------
_numberOfAtoms = -1;
// mark stream dimension variables as unset
_bdAtomStreamWidth = -1;
_bdAtomStreamHeight = -1;
_bdAtomStreamSize = -1;
for( int ii = 0; ii < LastStreamIndex; ii++ ){
_streams[ii] = NULL;
}
_temperature = oneMinus;
_stepSize = oneMinus;
_tau = oneMinus;
_noiseAmplitude = zero;
_forceScale = zero;
// setup inverse sqrt masses
_inverseSqrtMasses = NULL;
// set randomNumber seed
_randomNumberSeed = 1393;
//_randomNumberSeed = randomNumberSeed ? randomNumberSeed : 1393;
//SimTKOpenMMUtilities::setRandomNumberSeed( randomNumberSeed );
}
/**
* Destructor
*
*/
BrookBrownianDynamics::~BrookBrownianDynamics( ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::~BrookBrownianDynamics";
// ---------------------------------------------------------------------------------------
for( int ii = 0; ii < LastStreamIndex; ii++ ){
delete _streams[ii];
}
delete[] _inverseSqrtMasses;
}
/**
* Get tau
*
* @return tau
*
*/
BrookOpenMMFloat BrookBrownianDynamics::getTau( void ) const {
return _tau;
}
/**
* Get friction
*
* @return friction
*
*/
BrookOpenMMFloat BrookBrownianDynamics::getFriction( void ) const {
static const BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
static const BrookOpenMMFloat one = (BrookOpenMMFloat) 1.0;
return ( (_tau == zero) ? zero : (one/_tau) );
}
/**
* Get temperature
*
* @return temperature
*
*/
BrookOpenMMFloat BrookBrownianDynamics::getTemperature( void ) const {
return _temperature;
}
/**
* Get stepSize
*
* @return stepSize
*
*/
BrookOpenMMFloat BrookBrownianDynamics::getStepSize( void ) const {
return _stepSize;
}
/**
* Get force scale
*
* @return force scale
*
*/
BrookOpenMMFloat BrookBrownianDynamics::getForceScale( void ) const {
return _forceScale;
}
/**
* Get noise amplitude
*
* @return noise amplitude
*
*/
BrookOpenMMFloat BrookBrownianDynamics::getNoiseAmplitude( void ) const {
return _noiseAmplitude;
}
/**
* Set tau
*
* @param tau new tau value
*
* @return DefaultReturnValue
*
*/
int BrookBrownianDynamics::_setTau( BrookOpenMMFloat tau ){
_tau = tau;
_setNoiseAmplitude();
_setForceScale();
return DefaultReturnValue;
}
/**
* Set friction = 1/tau
*
* @param friction new friction value
*
* @return DefaultReturnValue
*
*/
int BrookBrownianDynamics::_setFriction( BrookOpenMMFloat friction ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_setFriction";
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
BrookOpenMMFloat one = (BrookOpenMMFloat) 1.0;
// ---------------------------------------------------------------------------------------
_tau = (BrookOpenMMFloat) ( (friction != zero) ? one/friction : zero);
_setNoiseAmplitude();
_setForceScale();
return DefaultReturnValue;
}
/**
* Set temperature
*
* @parameter temperature
*
* @return DefaultReturnValue
*
*/
int BrookBrownianDynamics::_setTemperature( BrookOpenMMFloat temperature ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_setTemperature";
// ---------------------------------------------------------------------------------------
_temperature = temperature;
_setNoiseAmplitude();
return DefaultReturnValue;
}
/**
* Set stepSize
*
* @param stepSize
*
* @return DefaultReturnValue
*
* @throw OpenMMException, if stepSize <= 0
*
*/
int BrookBrownianDynamics::_setStepSize( BrookOpenMMFloat stepSize ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookBrownianDynamics::_setStepSize";
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
BrookOpenMMFloat two = (BrookOpenMMFloat) 2.0;
// ---------------------------------------------------------------------------------------
if( stepSize <= zero ){
std::stringstream message;
message << methodName << " step size=" << stepSize << " is invalid.";
throw OpenMMException( message.str() );
}
_stepSize = stepSize;
_setNoiseAmplitude();
_setForceScale();
return DefaultReturnValue;
}
/**
* Set noise amplitude
*
* @return DefaultReturnValue
*
*/
int BrookBrownianDynamics::_setNoiseAmplitude( void ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_setNoiseAmplitude";
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
BrookOpenMMFloat two = (BrookOpenMMFloat) 2.0;
// ---------------------------------------------------------------------------------------
_noiseAmplitude = _temperature*_stepSize*_tau;
// skip sqrt if value is negative -- presumably not all values updated
if( _noiseAmplitude > zero ){
RealOpenMM intermediate = (RealOpenMM) BOLTZ*( (RealOpenMM) (two*_noiseAmplitude) );
_noiseAmplitude = (BrookOpenMMFloat) SQRT( intermediate );
}
return DefaultReturnValue;
}
/**
* Set force scale
*
* @return DefaultReturnValue
*
*/
int BrookBrownianDynamics::_setForceScale( void ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_setForceScale";
// ---------------------------------------------------------------------------------------
_forceScale = _stepSize*_tau;
return DefaultReturnValue;
}
/**
* Update parameters -- only way parameters can be set
*
* @param temperature temperature
* @param friction friction
* @param step size step size
*
* @return solute dielectric
*
*/
int BrookBrownianDynamics::updateParameters( double temperature, double friction, double stepSize ){
// ---------------------------------------------------------------------------------------
static int showUpdate = 1;
static int maxShowUpdate = 3;
static const char* methodName = "\nBrookBrownianDynamics::updateParameters";
// ---------------------------------------------------------------------------------------
_setStepSize( (BrookOpenMMFloat) stepSize );
_setFriction( (BrookOpenMMFloat) friction );
//_setTau( (BrookOpenMMFloat) friction );
_setTemperature( (BrookOpenMMFloat) temperature );
_updateStreams( );
// show update
if( showUpdate && getLog() && (showUpdate++ < maxShowUpdate) ){
std::string contents = getContentsString( );
(void) fprintf( getLog(), "%s contents\n%s", methodName, contents.c_str() );
(void) fflush( getLog() );
}
return DefaultReturnValue;
};
/**
* Update
*
* @param positions atom positions
* @param velocities atom velocities
* @param forces atom forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
*
* @return DefaultReturnValue
*
*/
int BrookBrownianDynamics::update( Stream& positions, Stream& velocities,
const Stream& forces,
BrookShakeAlgorithm& brookShakeAlgorithm,
BrookRandomNumberGenerator& brookRandomNumberGenerator ){
// ---------------------------------------------------------------------------------------
// unused Shake parameter
float omega = 1.0f;
float one = 1.0f;
static const char* methodName = "\nBrookBrownianDynamics::update";
static const int PrintOn = 0;
// ---------------------------------------------------------------------------------------
BrookStreamImpl& positionStream = dynamic_cast<BrookStreamImpl&> (positions.getImpl());
BrookStreamImpl& velocityStream = dynamic_cast<BrookStreamImpl&> (velocities.getImpl());
const BrookStreamImpl& forceStreamC = dynamic_cast<const BrookStreamImpl&> (forces.getImpl());
BrookStreamImpl& forceStream = const_cast<BrookStreamImpl&> (forceStreamC);
if( (1 || PrintOn) && getLog() ){
static int showAux = 1;
if( PrintOn ){
(void) fprintf( getLog(), "%s shake=%d\n", methodName, brookShakeAlgorithm.getNumberOfConstraints() );
(void) fflush( getLog() );
}
// show update
if( showAux ){
showAux = 0;
std::string contents = brookRandomNumberGenerator.getContentsString( );
(void) fprintf( getLog(), "%s RNG contents\n%s", methodName, contents.c_str() );
// brookRandomNumberGenerator.getRandomNumberStream( brookRandomNumberGenerator.getRvStreamIndex() )->printToFile( getLog() );
contents = brookShakeAlgorithm.getContentsString( );
(void) fprintf( getLog(), "%s Shake contents\n%s", methodName, contents.c_str() );
(void) fflush( getLog() );
}
}
// integration step -- deltas returned in XPrime
kintegrate_bd(
(float) getBrownianDynamicsAtomStreamWidth(),
(float) brookRandomNumberGenerator.getRandomNumberStreamWidth(),
(float) brookRandomNumberGenerator.getRvStreamOffset(),
getForceScale(), getNoiseAmplitude(),
brookRandomNumberGenerator.getRandomNumberStream( brookRandomNumberGenerator.getRvStreamIndex() )->getBrookStream(),
positionStream.getBrookStream(), forceStream.getBrookStream(),
getXPrimeStream()->getBrookStream() );
// diagnostics
if( PrintOn ){
(void) fprintf( getLog(), "\nPost kintegrate_bd: %d rngStrW=%3d rngOff=%5d "
"ForceScale=%12.5e NoiseAmplitude=%12.5e\n",
getBrownianDynamicsAtomStreamWidth(),
brookRandomNumberGenerator.getRandomNumberStreamWidth(),
brookRandomNumberGenerator.getRvStreamOffset(),
getForceScale(), getNoiseAmplitude() );
// (void) fprintf( getLog(), "\nInverseMassStream\n" );
//getInverseMassStream()->printToFile( getLog() );
//StreamImpl& positionStreamImpl = positionStream.getImpl();
//const BrookStreamImpl brookPositions = dynamic_cast<BrookStreamImpl&> (positionStreamImpl);
BrookStreamInternal* brookStreamInternalPos = positionStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nPositionStream\n" );
brookStreamInternalPos->printToFile( getLog() );
(void) fprintf( getLog(), "\nForceStream\n" );
BrookStreamInternal* brookStreamInternalF = forceStream.getBrookStreamImpl();
brookStreamInternalF->printToFile( getLog() );
(void) fprintf( getLog(), "\nXPrimeStream\n" );
getXPrimeStream()->printToFile( getLog() );
(void) fprintf( getLog(), "\nRvStreamIndex=%d\n", brookRandomNumberGenerator.getRvStreamIndex() );
// brookRandomNumberGenerator.getRandomNumberStream( brookRandomNumberGenerator.getRvStreamIndex() )->printToFile( getLog() );
}
// advance random number cursor
brookRandomNumberGenerator.advanceGVCursor( getNumberOfAtoms() );
// Shake
if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){
kshakeh_fix1(
10.0f,
(float) getBrownianDynamicsAtomStreamWidth(),
brookShakeAlgorithm.getInverseHydrogenMass(),
omega,
brookShakeAlgorithm.getShakeAtomIndicesStream()->getBrookStream(),
positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(),
brookShakeAlgorithm.getShakeAtomParameterStream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons3Stream()->getBrookStream() );
// second Shake gather
kshakeh_update2_fix1(
(float) getBrownianDynamicsAtomStreamWidth(),
brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(),
positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons0Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons1Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons2Stream()->getBrookStream(),
brookShakeAlgorithm.getShakeXCons3Stream()->getBrookStream(),
positionStream.getBrookStream() );
// diagnostics
if( PrintOn ){
(void) fprintf( getLog(), "\nPost kupdate_bd:\n" );
BrookStreamInternal* brookStreamInternalPos = positionStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nPositionStream\n" );
brookStreamInternalPos->printToFile( getLog() );
(void) fprintf( getLog(), "\nXPrimeStream\n" );
getXPrimeStream()->printToFile( getLog() );
BrookStreamInternal* brookStreamInternalVel = velocityStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nVelocityStream\n" );
brookStreamInternalVel->printToFile( getLog() );
}
} else {
// update step
float velocityScale = (float) (one/getStepSize());
kupdate_bd2( velocityScale, getXPrimeStream()->getBrookStream(),
positionStream.getBrookStream(), velocityStream.getBrookStream(), positionStream.getBrookStream() );
// diagnostics
if( PrintOn ){
(void) fprintf( getLog(), "\nPost kupdate_bd2: velocityScale=%12.5e\n", velocityScale );
(void) fprintf( getLog(), "\nXPrimeStream\n" );
getXPrimeStream()->printToFile( getLog() );
BrookStreamInternal* brookStreamInternalPos = positionStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nPositionStream\n" );
brookStreamInternalPos->printToFile( getLog() );
BrookStreamInternal* brookStreamInternalVel = velocityStream.getBrookStreamImpl();
(void) fprintf( getLog(), "\nVelocityStream\n" );
brookStreamInternalVel->printToFile( getLog() );
}
}
return DefaultReturnValue;
};
/**
* Get Atom stream size
*
* @return Atom stream size
*
*/
int BrookBrownianDynamics::getBrownianDynamicsAtomStreamSize( void ) const {
return _bdAtomStreamSize;
}
/**
* Get atom stream width
*
* @return atom stream width
*
*/
int BrookBrownianDynamics::getBrownianDynamicsAtomStreamWidth( void ) const {
return _bdAtomStreamWidth;
}
/**
* Get atom stream height
*
* @return atom stream height
*/
int BrookBrownianDynamics::getBrownianDynamicsAtomStreamHeight( void ) const {
return _bdAtomStreamHeight;
}
/**
* Get XPrime stream
*
* @return Xprime stream
*
*/
BrookFloatStreamInternal* BrookBrownianDynamics::getXPrimeStream( void ) const {
return _streams[XPrimeStream];
}
/**
* Get InverseMass stream
*
* @return inverse mass stream
*
*/
BrookFloatStreamInternal* BrookBrownianDynamics::getInverseMassStream( void ) const {
return _streams[InverseMassStream];
}
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int BrookBrownianDynamics::_initializeStreamSizes( int numberOfAtoms, const Platform& platform ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_initializeStreamSizes";
// ---------------------------------------------------------------------------------------
_bdAtomStreamSize = getAtomStreamSize( platform );
_bdAtomStreamWidth = getAtomStreamWidth( platform );
_bdAtomStreamHeight = getAtomStreamHeight( platform );
return DefaultReturnValue;
}
/**
* Initialize streams
*
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int BrookBrownianDynamics::_initializeStreams( const Platform& platform ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_initializeStreams";
BrookOpenMMFloat dangleValue = (BrookOpenMMFloat) 0.0;
// ---------------------------------------------------------------------------------------
int sdAtomStreamSize = getBrownianDynamicsAtomStreamSize();
int sdAtomStreamWidth = getBrownianDynamicsAtomStreamWidth();
_streams[VPrimeStream] = new BrookFloatStreamInternal( BrookCommon::VPrimeStream,
sdAtomStreamSize, sdAtomStreamWidth,
BrookStreamInternal::Float3, dangleValue );
_streams[XPrimeStream] = new BrookFloatStreamInternal( BrookCommon::XPrimeStream,
sdAtomStreamSize, sdAtomStreamWidth,
BrookStreamInternal::Float3, dangleValue );
_streams[InverseMassStream] = new BrookFloatStreamInternal( BrookCommon::InverseMassStream,
sdAtomStreamSize, sdAtomStreamWidth,
BrookStreamInternal::Float, dangleValue );
return DefaultReturnValue;
}
/**
* Update streams -- called after parameters change
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int BrookBrownianDynamics::_updateStreams( void ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_updateStreams";
// ---------------------------------------------------------------------------------------
//int atomStreamSize = getBrownianDynamicsAtomStreamSize();
return DefaultReturnValue;
}
/**
* Set masses
*
* @param masses atomic masses
*
*/
int BrookBrownianDynamics::_setInverseSqrtMasses( const std::vector<double>& masses ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookBrownianDynamics::_setInverseSqrtMasses";
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
BrookOpenMMFloat one = (BrookOpenMMFloat) 1.0;
// ---------------------------------------------------------------------------------------
// setup inverse sqrt masses
_inverseSqrtMasses = new BrookOpenMMFloat[masses.size()];
int index = 0;
for( std::vector<double>::const_iterator ii = masses.begin(); ii != masses.end(); ii++, index++ ){
if( *ii != 0.0 ){
BrookOpenMMFloat value = static_cast<BrookOpenMMFloat>(*ii);
_inverseSqrtMasses[index] = ( SQRT( one/value ) );
} else {
_inverseSqrtMasses[index] = zero;
}
}
return DefaultReturnValue;
}
/*
* Setup of BrownianDynamics parameters
*
* @param masses masses
* @param platform Brook platform
*
* @return nonzero value if error
*
* */
int BrookBrownianDynamics::setup( const std::vector<double>& masses, const Platform& platform ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookBrownianDynamics::setup";
// ---------------------------------------------------------------------------------------
const BrookPlatform brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
setLog( brookPlatform.getLog() );
int numberOfAtoms = (int) masses.size();
setNumberOfAtoms( numberOfAtoms );
// set stream sizes and then create streams
_initializeStreamSizes( numberOfAtoms, platform );
_initializeStreams( platform );
_setInverseSqrtMasses( masses );
return DefaultReturnValue;
}
/*
* Get contents of object
*
* @param level level of dump
*
* @return string containing contents
*
* */
std::string BrookBrownianDynamics::getContentsString( int level ) const {
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookBrownianDynamics::getContentsString";
static const unsigned int MAX_LINE_CHARS = 256;
char value[MAX_LINE_CHARS];
static const char* Set = "Set";
static const char* NotSet = "Not set";
// ---------------------------------------------------------------------------------------
std::stringstream message;
std::string tab = " ";
#ifdef WIN32
#define LOCAL_SPRINTF(a,b,c) sprintf_s( (a), MAX_LINE_CHARS, (b), (c) );
#else
#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", getAtomStreamWidth() );
message << _getLine( tab, "Atom stream width:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamHeight() );
message << _getLine( tab, "Atom stream height:", value );
(void) LOCAL_SPRINTF( value, "%d", getAtomStreamSize() );
message << _getLine( tab, "Atom stream size:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getTau() );
message << _getLine( tab, "Tau:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getTemperature() );
message << _getLine( tab, "Temperature:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getStepSize() );
message << _getLine( tab, "Step size:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getForceScale() );
message << _getLine( tab, "Force scale:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getNoiseAmplitude() );
message << _getLine( tab, "Noise amplitude:", value );
(void) LOCAL_SPRINTF( value, "%.5f", getTemperature() );
message << _getLine( tab, "Temperature:", value );
message << _getLine( tab, "Log:", (getLog() ? Set : NotSet) );
for( int ii = 0; ii < LastStreamIndex; ii++ ){
message << std::endl;
if( _streams[ii] ){
message << _streams[ii]->getContentsString( );
}
}
#undef LOCAL_SPRINTF
return message.str();
}
#ifndef OPENMM_BROOK_BROWNIAN_DYNAMCIS_H_
#define OPENMM_BROOK_BROWNIAN_DYNAMCIS_H_
/* -------------------------------------------------------------------------- *
* 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 <vector>
#include <set>
#include "BrookFloatStreamInternal.h"
#include "BrookShakeAlgorithm.h"
#include "BrookRandomNumberGenerator.h"
#include "BrookPlatform.h"
#include "BrookCommon.h"
namespace OpenMM {
/**
*
* Encapsulates stochastic dynamics algorithm
*
*/
class BrookBrownianDynamics : public BrookCommon {
public:
/**
* Constructor
*
*/
BrookBrownianDynamics( );
/**
* Destructor
*
*/
~BrookBrownianDynamics();
/**
* Get tau
*
* @return tau
*/
BrookOpenMMFloat getTau( void ) const;
/**
* Get friction
*
* @return friction
*/
BrookOpenMMFloat getFriction( void ) const;
/**
* Get temperature
*
* @return temperature
*/
BrookOpenMMFloat getTemperature( void ) const;
/**
* Get step size
*
* @return step size
*/
BrookOpenMMFloat getStepSize( void ) const;
/**
* Get noise amplitude
*
* @return noise amplitude
*/
BrookOpenMMFloat getNoiseAmplitude( void ) const;
/**
* Get force scale
*
* @return force scale
*/
BrookOpenMMFloat getForceScale( void ) const;
/**
* Get BrownianDynamics atom stream width
*
* @return atom stream width
*/
int getBrownianDynamicsAtomStreamWidth( void ) const;
/**
* Get BrownianDynamics atom stream height
*
* @return atom stream height
*/
int getBrownianDynamicsAtomStreamHeight( void ) const;
/**
* Get BrownianDynamics atom stream size
*
* @return atom stream size
*/
int getBrownianDynamicsAtomStreamSize( void ) const;
/**
* Update parameters
*
* @param temperature temperature
* @param friction friction
* @param step size step size
*
* @return DefaultReturnValue
*
*/
int updateParameters( double temperature, double friction, double stepSize );
/**
* Update
*
* @param positions atom positions
* @param velocities atom velocities
* @param forces atom forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
*
* @return DefaultReturnValue
*
*/
int update( Stream& positions, Stream& velocities,
const Stream& forces, BrookShakeAlgorithm& brookShakeAlgorithm,
BrookRandomNumberGenerator& brookRandomNumberGenerator );
/**
* Get array of BrownianDynamics streams
*
* @return array ofstreams
*
*/
BrookFloatStreamInternal** getStreams( void );
/*
* Setup of BrownianDynamics parameters
*
* @param masses atom masses
* @param platform Brook platform
*
* @return ErrorReturnValue value if error, else DefaultReturnValue
*
* */
int setup( const std::vector<double>& masses, const Platform& platform );
/*
* Get contents of object
*
* @param level of dump
*
* @return string containing contents
*
* */
std::string getContentsString( int level = 0 ) const;
/**
* Get X-prime stream
*
* @return X-prime stream
*
*/
BrookFloatStreamInternal* getXPrimeStream( void ) const;
/**
* Get inverse sqrt masses
*
* @return inverse sqrt masses stream
*
*/
BrookFloatStreamInternal* getInverseMassStream( void ) const;
private:
// streams indices
enum BrookBrownianDynamicsStreams {
VPrimeStream,
XPrimeStream,
InverseMassStream,
LastStreamIndex
};
// randomNumberSeed
unsigned int _randomNumberSeed;
BrookOpenMMFloat _tau;
BrookOpenMMFloat _temperature;
BrookOpenMMFloat _stepSize;
BrookOpenMMFloat _forceScale;
BrookOpenMMFloat _noiseAmplitude;
// Atom stream dimensions
int _bdAtomStreamWidth;
int _bdAtomStreamHeight;
int _bdAtomStreamSize;
/*
* Update streams
*
* @return DefaultReturn
*
*/
int _updateStreams( void );
// inverse sqrt masses
BrookOpenMMFloat* _inverseSqrtMasses;
// internal streams
BrookFloatStreamInternal* _streams[LastStreamIndex];
/**
* Set tau
*
* @param tau new tau value
*
* @return DefaultReturn
*
*/
int _setTau( BrookOpenMMFloat tau );
/**
* Set friction = 1/tau
*
* @param friction new friction value
*
* @return DefaultReturn
*
*/
int _setFriction( BrookOpenMMFloat friction );
/**
* Set temperature
*
* @parameter temperature
*
* @return DefaultReturn
*
*/
int _setTemperature( BrookOpenMMFloat temperature );
/**
* Set stepSize
*
* @param stepSize
*
* @return DefaultReturn
*
*/
int _setStepSize( BrookOpenMMFloat stepSize );
/**
* Set force scale
*
* @return DefaultReturn
*
*/
int _setForceScale( void );
/**
* Set noise amplitude
*
* @return DefaultReturn
*
*/
int _setNoiseAmplitude( void );
/*
* Setup of stream dimensions
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int _initializeStreamSizes( int atomStreamSize, int atomStreamWidth );
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int _initializeStreamSizes( int numberOfAtoms, const Platform& platform );
/**
* Initialize stream dimensions and streams
*
* @param platform platform
*
* @return nonzero value if error
*
*/
int _initializeStreams( const Platform& platform );
/**
* Set masses
*
* @param masses atomic masses
*
*/
int _setInverseSqrtMasses( const std::vector<double>& masses );
};
} // namespace OpenMM
#endif /* OPENMM_BROOK_BROWNIAN_DYNAMCIS_H_ */
/* -------------------------------------------------------------------------- *
* 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 *
* 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 "BrookIntegrateBrownianStepKernel.h"
#include "BrookStreamInternal.h"
using namespace OpenMM;
using namespace std;
/**
* BrookIntegrateBrownianStepKernel constructor
*
* @param name name of the stream to create
* @param platform platform
*
*/
BrookIntegrateBrownianStepKernel::BrookIntegrateBrownianStepKernel( std::string name, const Platform& platform ) :
IntegrateBrownianStepKernel( name, platform ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookIntegrateBrownianStepKernel::BrookIntegrateBrownianStepKernel";
// ---------------------------------------------------------------------------------------
_brookBrownianDynamics = NULL;
_brookShakeAlgorithm = NULL;
_brookRandomNumberGenerator = NULL;
}
/**
* BrookIntegrateVerletStepKernel destructor
*
*/
BrookIntegrateBrownianStepKernel::~BrookIntegrateBrownianStepKernel( ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookIntegrateBrownianStepKernel::~BrookIntegrateBrownianStepKernel";
// ---------------------------------------------------------------------------------------
delete _brookBrownianDynamics;
delete _brookShakeAlgorithm;
delete _brookRandomNumberGenerator;
}
/**
* 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
*
*/
void BrookIntegrateBrownianStepKernel::initialize( const vector<double>& masses,
const vector<vector<int> >& constraintIndices,
const vector<double>& constraintLengths ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookIntegrateBrownianStepKernel::initialize";
// ---------------------------------------------------------------------------------------
_brookBrownianDynamics = new BrookBrownianDynamics( );
_brookBrownianDynamics->setup( masses, getPlatform() );
_brookShakeAlgorithm = new BrookShakeAlgorithm( );
_brookShakeAlgorithm->setup( masses, constraintIndices, constraintLengths, getPlatform() );
// assert( (_brookShakeAlgorithm->getNumberOfConstraints() > 0) );
_brookRandomNumberGenerator = new BrookRandomNumberGenerator( );
_brookRandomNumberGenerator->setup( (int) masses.size(), getPlatform() );
_brookRandomNumberGenerator->setVerbosity( 1 );
}
/**
* Execute kernel
*
* @param positions atom coordinates
* @param velocities atom velocities
* @param forces atom forces
* @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath
* @param stepSize integration step size
*
*/
void BrookIntegrateBrownianStepKernel::execute( Stream& positions, Stream& velocities,
const Stream& forces, double temperature,
double friction, double stepSize ){
// ---------------------------------------------------------------------------------------
double epsilon = 1.0e-04;
static const std::string methodName = "BrookIntegrateBrownianStepKernel::execute";
// ---------------------------------------------------------------------------------------
// first time through initialize _brookBrownianDynamics
// for each subsequent call, check if parameters need to be updated due to a change
// in T, gamma, or the step size
// take step
double differences[3];
differences[0] = temperature - (double) _brookBrownianDynamics->getTemperature();
differences[1] = friction - (double) _brookBrownianDynamics->getFriction();
differences[2] = stepSize - (double) _brookBrownianDynamics->getStepSize();
if( fabs( differences[0] ) > epsilon || fabs( differences[1] ) > epsilon || fabs( differences[2] ) > epsilon ){
//printf( "%s calling updateParameters\n", methodName.c_str() );
_brookBrownianDynamics->updateParameters( temperature, friction, stepSize );
} else {
//printf( "%s NOT calling updateParameters\n", methodName.c_str() );
}
_brookBrownianDynamics->update( positions, velocities, forces, *_brookShakeAlgorithm, *_brookRandomNumberGenerator );
}
#ifndef OPENMM_BROOK_INTEGRATE_BROWNIAN_STEP_KERNEL_H_
#define OPENMM_BROOK_INTEGRATE_BROWNIAN_STEP_KERNEL_H_
/* -------------------------------------------------------------------------- *
* 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 "kernels.h"
#include "BrookBrownianDynamics.h"
#include "BrookShakeAlgorithm.h"
#include "BrookRandomNumberGenerator.h"
namespace OpenMM {
/**
* This is the base class of Float and Double streams in the Brook Platform.
*/
class BrookIntegrateBrownianStepKernel : public IntegrateBrownianStepKernel {
public:
// return values
static const int DefaultReturnValue = 0;
static const int ErrorReturnValue = -1;
/**
* BrookIntegrateBrownianStepKernel constructor
*
* @param name name of the stream to create
* @param platform platform
*
*/
BrookIntegrateBrownianStepKernel( std::string name, const Platform& platform );
/**
* BrookIntegrateBrownianStepKernel destructor
*
*/
~BrookIntegrateBrownianStepKernel();
/**
* 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
*/
void initialize( const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
const std::vector<double>& constraintLengths );
/**
* Execute kernel
*
* @param positions coordinates
* @param velocities velocities
* @param forces forces
* @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath
* @param stepSize step size
*
*/
void execute( Stream& positions, Stream& velocities, const Stream& forces, double temperature, double friction, double stepSize );
protected:
BrookBrownianDynamics* _brookBrownianDynamics;
BrookShakeAlgorithm* _brookShakeAlgorithm;
BrookRandomNumberGenerator* _brookRandomNumberGenerator;
};
} // namespace OpenMM
#endif /* OPENMM_BROOK_INTEGRATE_BROWNIAN_STEP_KERNEL_H_ */
......@@ -52,7 +52,7 @@ BrookIntegrateLangevinStepKernel::BrookIntegrateLangevinStepKernel( std::string
// ---------------------------------------------------------------------------------------
_brookStochasticDynamics = NULL;
_brookLangevinDynamics = NULL;
_brookShakeAlgorithm = NULL;
_brookRandomNumberGenerator = NULL;
......@@ -71,7 +71,7 @@ BrookIntegrateLangevinStepKernel::~BrookIntegrateLangevinStepKernel( ){
// ---------------------------------------------------------------------------------------
delete _brookStochasticDynamics;
delete _brookLangevinDynamics;
delete _brookShakeAlgorithm;
delete _brookRandomNumberGenerator;
......@@ -96,8 +96,8 @@ void BrookIntegrateLangevinStepKernel::initialize( const vector<double>& masses,
// ---------------------------------------------------------------------------------------
_brookStochasticDynamics = new BrookStochasticDynamics( );
_brookStochasticDynamics->setup( masses, getPlatform() );
_brookLangevinDynamics = new BrookLangevinDynamics( );
_brookLangevinDynamics->setup( masses, getPlatform() );
_brookShakeAlgorithm = new BrookShakeAlgorithm( );
_brookShakeAlgorithm->setup( masses, constraintIndices, constraintLengths, getPlatform() );
......@@ -132,7 +132,7 @@ void BrookIntegrateLangevinStepKernel::execute( Stream& positions, Stream& veloc
// ---------------------------------------------------------------------------------------
// first time through initialize _brookStochasticDynamics
// first time through initialize _brookLangevinDynamics
// for each subsequent call, check if parameters need to be updated due to a change
// in T, gamma, or the step size
......@@ -140,16 +140,16 @@ void BrookIntegrateLangevinStepKernel::execute( Stream& positions, Stream& veloc
// take step
double differences[3];
differences[0] = temperature - (double) _brookStochasticDynamics->getTemperature();
differences[1] = friction - (double) _brookStochasticDynamics->getFriction();
differences[2] = stepSize - (double) _brookStochasticDynamics->getStepSize();
differences[0] = temperature - (double) _brookLangevinDynamics->getTemperature();
differences[1] = friction - (double) _brookLangevinDynamics->getFriction();
differences[2] = stepSize - (double) _brookLangevinDynamics->getStepSize();
if( fabs( differences[0] ) > epsilon || fabs( differences[1] ) > epsilon || fabs( differences[2] ) > epsilon ){
//printf( "%s calling updateParameters\n", methodName.c_str() );
_brookStochasticDynamics->updateParameters( temperature, friction, stepSize );
_brookLangevinDynamics->updateParameters( temperature, friction, stepSize );
} else {
//printf( "%s NOT calling updateParameters\n", methodName.c_str() );
}
_brookStochasticDynamics->update( positions, velocities, forces, *_brookShakeAlgorithm, *_brookRandomNumberGenerator );
_brookLangevinDynamics->update( positions, velocities, forces, *_brookShakeAlgorithm, *_brookRandomNumberGenerator );
}
......@@ -33,7 +33,7 @@
* -------------------------------------------------------------------------- */
#include "kernels.h"
#include "BrookStochasticDynamics.h"
#include "BrookLangevinDynamics.h"
#include "BrookShakeAlgorithm.h"
#include "BrookRandomNumberGenerator.h"
......@@ -95,7 +95,7 @@ class BrookIntegrateLangevinStepKernel : public IntegrateLangevinStepKernel {
protected:
BrookStochasticDynamics* _brookStochasticDynamics;
BrookLangevinDynamics* _brookLangevinDynamics;
BrookShakeAlgorithm* _brookShakeAlgorithm;
BrookRandomNumberGenerator* _brookRandomNumberGenerator;
......
......@@ -33,6 +33,7 @@
#include "BrookCalcStandardMMForceFieldKernel.h"
#include "BrookIntegrateLangevinStepKernel.h"
#include "BrookIntegrateVerletStepKernel.h"
#include "BrookIntegrateBrownianStepKernel.h"
#include "BrookCalcKineticEnergyKernel.h"
#include "BrookCalcGBSAOBCForceFieldKernel.h"
#include "BrookRemoveCMMotionKernel.h"
......@@ -69,7 +70,7 @@ KernelImpl* BrookKernelFactory::createKernelImpl( std::string name, const Platfo
} else if( name == IntegrateBrownianStepKernel::Name() ){
// return new BrookIntegrateBrownianStepKernel( name, platform );
return new BrookIntegrateBrownianStepKernel( name, platform );
// Andersen thermostat
......
......@@ -30,7 +30,7 @@
* -------------------------------------------------------------------------- */
#include <sstream>
#include "BrookStochasticDynamics.h"
#include "BrookLangevinDynamics.h"
#include "BrookPlatform.h"
#include "OpenMMException.h"
#include "BrookStreamImpl.h"
......@@ -51,11 +51,11 @@ using namespace std;
*
*/
BrookStochasticDynamics::BrookStochasticDynamics( ){
BrookLangevinDynamics::BrookLangevinDynamics( ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookStochasticDynamics::BrookStochasticDynamics";
//static const std::string methodName = "BrookLangevinDynamics::BrookLangevinDynamics";
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
BrookOpenMMFloat one = (BrookOpenMMFloat) 1.0;
......@@ -100,11 +100,11 @@ BrookStochasticDynamics::BrookStochasticDynamics( ){
*
*/
BrookStochasticDynamics::~BrookStochasticDynamics( ){
BrookLangevinDynamics::~BrookLangevinDynamics( ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookStochasticDynamics::~BrookStochasticDynamics";
//static const std::string methodName = "BrookLangevinDynamics::~BrookLangevinDynamics";
// ---------------------------------------------------------------------------------------
......@@ -123,7 +123,7 @@ BrookStochasticDynamics::~BrookStochasticDynamics( ){
*
*/
BrookOpenMMFloat BrookStochasticDynamics::getTau( void ) const {
BrookOpenMMFloat BrookLangevinDynamics::getTau( void ) const {
return _tau;
}
......@@ -134,7 +134,7 @@ BrookOpenMMFloat BrookStochasticDynamics::getTau( void ) const {
*
*/
BrookOpenMMFloat BrookStochasticDynamics::getFriction( void ) const {
BrookOpenMMFloat BrookLangevinDynamics::getFriction( void ) const {
static const BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
static const BrookOpenMMFloat one = (BrookOpenMMFloat) 1.0;
return ( (_tau == zero) ? zero : (one/_tau) );
......@@ -147,7 +147,7 @@ BrookOpenMMFloat BrookStochasticDynamics::getFriction( void ) const {
*
*/
BrookOpenMMFloat BrookStochasticDynamics::getTemperature( void ) const {
BrookOpenMMFloat BrookLangevinDynamics::getTemperature( void ) const {
return _temperature;
}
......@@ -158,7 +158,7 @@ BrookOpenMMFloat BrookStochasticDynamics::getTemperature( void ) const {
*
*/
BrookOpenMMFloat BrookStochasticDynamics::getStepSize( void ) const {
BrookOpenMMFloat BrookLangevinDynamics::getStepSize( void ) const {
return _stepSize;
}
......@@ -171,7 +171,7 @@ BrookOpenMMFloat BrookStochasticDynamics::getStepSize( void ) const {
*
*/
int BrookStochasticDynamics::_setTau( BrookOpenMMFloat tau ){
int BrookLangevinDynamics::_setTau( BrookOpenMMFloat tau ){
_tau = tau;
return DefaultReturnValue;
}
......@@ -185,7 +185,7 @@ int BrookStochasticDynamics::_setTau( BrookOpenMMFloat tau ){
*
*/
int BrookStochasticDynamics::_setFriction( BrookOpenMMFloat friction ){
int BrookLangevinDynamics::_setFriction( BrookOpenMMFloat friction ){
_tau = (BrookOpenMMFloat) ( (friction != 0.0) ? 1.0/friction : 0.0);
return DefaultReturnValue;
}
......@@ -199,7 +199,7 @@ int BrookStochasticDynamics::_setFriction( BrookOpenMMFloat friction ){
*
*/
int BrookStochasticDynamics::_setTemperature( BrookOpenMMFloat temperature ){
int BrookLangevinDynamics::_setTemperature( BrookOpenMMFloat temperature ){
_temperature = temperature;
return DefaultReturnValue;
}
......@@ -213,7 +213,7 @@ int BrookStochasticDynamics::_setTemperature( BrookOpenMMFloat temperature ){
*
*/
int BrookStochasticDynamics::_setStepSize( BrookOpenMMFloat stepSize ){
int BrookLangevinDynamics::_setStepSize( BrookOpenMMFloat stepSize ){
_stepSize = stepSize;
return DefaultReturnValue;
}
......@@ -227,11 +227,11 @@ int BrookStochasticDynamics::_setStepSize( BrookOpenMMFloat stepSize ){
*
*/
int BrookStochasticDynamics::_updateDerivedParameters( void ){
int BrookLangevinDynamics::_updateDerivedParameters( void ){
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nBrookStochasticDynamics::_updateDerivedParameters";
static const char* methodName = "\nBrookLangevinDynamics::_updateDerivedParameters";
static const BrookOpenMMFloat zero = 0.0;
static const BrookOpenMMFloat one = 1.0;
......@@ -318,13 +318,13 @@ int BrookStochasticDynamics::_updateDerivedParameters( void ){
*
*/
int BrookStochasticDynamics::updateParameters( double temperature, double friction, double stepSize ){
int BrookLangevinDynamics::updateParameters( double temperature, double friction, double stepSize ){
// ---------------------------------------------------------------------------------------
static int showUpdate = 1;
static int maxShowUpdate = 3;
static const char* methodName = "\nBrookStochasticDynamics::updateParameters";
static const char* methodName = "\nBrookLangevinDynamics::updateParameters";
// ---------------------------------------------------------------------------------------
......@@ -362,7 +362,7 @@ int BrookStochasticDynamics::updateParameters( double temperature, double fricti
*
*/
int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
const Stream& forces,
BrookShakeAlgorithm& brookShakeAlgorithm,
BrookRandomNumberGenerator& brookRandomNumberGenerator ){
......@@ -373,7 +373,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
float omega = 1.0f;
static const char* methodName = "\nBrookStochasticDynamics::update";
static const char* methodName = "\nBrookLangevinDynamics::update";
static const int PrintOn = 0;
......@@ -414,7 +414,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
// first integration step
kupdate_sd1_fix1(
(float) getStochasticDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsAtomStreamWidth(),
(float) brookRandomNumberGenerator.getRandomNumberStreamWidth(),
(float) brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[EM],
......@@ -438,7 +438,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
if( PrintOn ){
(void) fprintf( getLog(), "\nPost kupdate_sd1_fix1: atomStrW=%3d rngStrW=%3d rngOff=%5d "
"EM=%12.5e Sd1pc[]=[%12.5e %12.5e %12.5e]",
getStochasticDynamicsAtomStreamWidth(),
getLangevinDynamicsAtomStreamWidth(),
brookRandomNumberGenerator.getRandomNumberStreamWidth(),
brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[EM], derivedParameters[Sd1pc1], derivedParameters[Sd1pc2], derivedParameters[Sd1pc3] );
......@@ -488,7 +488,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){
kshakeh_fix1(
10.0f,
(float) getStochasticDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsAtomStreamWidth(),
brookShakeAlgorithm.getInverseHydrogenMass(),
omega,
brookShakeAlgorithm.getShakeAtomIndicesStream()->getBrookStream(),
......@@ -503,7 +503,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
// first Shake gather
kshakeh_update1_fix1(
(float) getStochasticDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsAtomStreamWidth(),
derivedParameters[Sd2pc1],
brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(),
positionStream.getBrookStream(),
......@@ -519,7 +519,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
// second integration step
kupdate_sd2_fix1(
(float) getStochasticDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsAtomStreamWidth(),
(float) brookRandomNumberGenerator.getRandomNumberStreamWidth(),
(float) brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[Sd2pc1],
......@@ -540,7 +540,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
if( PrintOn ){
(void) fprintf( getLog(), "\nPost kupdate_sd2_fix1: atomStrW=%3d rngStrW=%3d rngOff=%5d "
"Sd2pc[]=[%12.5e %12.5e]",
getStochasticDynamicsAtomStreamWidth(),
getLangevinDynamicsAtomStreamWidth(),
brookRandomNumberGenerator.getRandomNumberStreamWidth(),
brookRandomNumberGenerator.getRvStreamOffset(),
derivedParameters[Sd2pc1], derivedParameters[Sd2pc2] );
......@@ -581,7 +581,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
if( brookShakeAlgorithm.getNumberOfConstraints() > 0 ){
kshakeh_fix1(
10.0f,
(float) getStochasticDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsAtomStreamWidth(),
brookShakeAlgorithm.getInverseHydrogenMass(),
omega,
brookShakeAlgorithm.getShakeAtomIndicesStream()->getBrookStream(),
......@@ -596,7 +596,7 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
// second Shake gather
kshakeh_update2_fix1(
(float) getStochasticDynamicsAtomStreamWidth(),
(float) getLangevinDynamicsAtomStreamWidth(),
brookShakeAlgorithm.getShakeInverseMapStream()->getBrookStream(),
positionStream.getBrookStream(),
getXPrimeStream()->getBrookStream(),
......@@ -623,11 +623,11 @@ int BrookStochasticDynamics::update( Stream& positions, Stream& velocities,
*
*/
const BrookOpenMMFloat* BrookStochasticDynamics::getDerivedParameters( void ) const {
const BrookOpenMMFloat* BrookLangevinDynamics::getDerivedParameters( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nBrookStochasticDynamics::getDerivedParameters";
// static const char* methodName = "\nBrookLangevinDynamics::getDerivedParameters";
// ---------------------------------------------------------------------------------------
......@@ -641,7 +641,7 @@ const BrookOpenMMFloat* BrookStochasticDynamics::getDerivedParameters( void ) co
*
*/
int BrookStochasticDynamics::getStochasticDynamicsAtomStreamSize( void ) const {
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamSize( void ) const {
return _sdAtomStreamSize;
}
......@@ -652,7 +652,7 @@ int BrookStochasticDynamics::getStochasticDynamicsAtomStreamSize( void ) const {
*
*/
int BrookStochasticDynamics::getStochasticDynamicsAtomStreamWidth( void ) const {
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamWidth( void ) const {
return _sdAtomStreamWidth;
}
......@@ -662,7 +662,7 @@ int BrookStochasticDynamics::getStochasticDynamicsAtomStreamWidth( void ) const
* @return atom stream height
*/
int BrookStochasticDynamics::getStochasticDynamicsAtomStreamHeight( void ) const {
int BrookLangevinDynamics::getLangevinDynamicsAtomStreamHeight( void ) const {
return _sdAtomStreamHeight;
}
......@@ -673,7 +673,7 @@ int BrookStochasticDynamics::getStochasticDynamicsAtomStreamHeight( void ) const
*
*/
BrookFloatStreamInternal* BrookStochasticDynamics::getSDPC1Stream( void ) const {
BrookFloatStreamInternal* BrookLangevinDynamics::getSDPC1Stream( void ) const {
return _sdStreams[SDPC1Stream];
}
......@@ -684,7 +684,7 @@ BrookFloatStreamInternal* BrookStochasticDynamics::getSDPC1Stream( void ) const
*
*/
BrookFloatStreamInternal* BrookStochasticDynamics::getSDPC2Stream( void ) const {
BrookFloatStreamInternal* BrookLangevinDynamics::getSDPC2Stream( void ) const {
return _sdStreams[SDPC2Stream];
}
......@@ -695,7 +695,7 @@ BrookFloatStreamInternal* BrookStochasticDynamics::getSDPC2Stream( void ) const
*
*/
BrookFloatStreamInternal* BrookStochasticDynamics::getSD2XStream( void ) const {
BrookFloatStreamInternal* BrookLangevinDynamics::getSD2XStream( void ) const {
return _sdStreams[SD2XStream];
}
......@@ -706,7 +706,7 @@ BrookFloatStreamInternal* BrookStochasticDynamics::getSD2XStream( void ) const {
*
*/
BrookFloatStreamInternal* BrookStochasticDynamics::getSD1VStream( void ) const {
BrookFloatStreamInternal* BrookLangevinDynamics::getSD1VStream( void ) const {
return _sdStreams[SD1VStream];
}
......@@ -717,7 +717,7 @@ BrookFloatStreamInternal* BrookStochasticDynamics::getSD1VStream( void ) const {
*
*/
BrookFloatStreamInternal* BrookStochasticDynamics::getVPrimeStream( void ) const {
BrookFloatStreamInternal* BrookLangevinDynamics::getVPrimeStream( void ) const {
return _sdStreams[VPrimeStream];
}
......@@ -728,7 +728,7 @@ BrookFloatStreamInternal* BrookStochasticDynamics::getVPrimeStream( void ) const
*
*/
BrookFloatStreamInternal* BrookStochasticDynamics::getXPrimeStream( void ) const {
BrookFloatStreamInternal* BrookLangevinDynamics::getXPrimeStream( void ) const {
return _sdStreams[XPrimeStream];
}
......@@ -739,7 +739,7 @@ BrookFloatStreamInternal* BrookStochasticDynamics::getXPrimeStream( void ) const
*
*/
BrookFloatStreamInternal* BrookStochasticDynamics::getInverseMassStream( void ) const {
BrookFloatStreamInternal* BrookLangevinDynamics::getInverseMassStream( void ) const {
return _sdStreams[InverseMassStream];
}
......@@ -753,11 +753,11 @@ BrookFloatStreamInternal* BrookStochasticDynamics::getInverseMassStream( void )
*
*/
int BrookStochasticDynamics::_initializeStreamSizes( int numberOfAtoms, const Platform& platform ){
int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Platform& platform ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookStochasticDynamics::_initializeStreamSizes";
//static const std::string methodName = "BrookLangevinDynamics::_initializeStreamSizes";
// ---------------------------------------------------------------------------------------
......@@ -778,12 +778,12 @@ int BrookStochasticDynamics::_initializeStreamSizes( int numberOfAtoms, const Pl
*
*/
//std::string BrookStochasticDynamics::_getDerivedParametersString( BrookStochasticDynamics::DerivedParameters derivedParametersIndex ) const {
std::string BrookStochasticDynamics::_getDerivedParametersString( int derivedParametersIndex ) const {
//std::string BrookLangevinDynamics::_getDerivedParametersString( BrookLangevinDynamics::DerivedParameters derivedParametersIndex ) const {
std::string BrookLangevinDynamics::_getDerivedParametersString( int derivedParametersIndex ) const {
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookStochasticDynamics::_getDerivedParametersString";
//static const std::string methodName = "BrookLangevinDynamics::_getDerivedParametersString";
// ---------------------------------------------------------------------------------------
......@@ -876,18 +876,18 @@ std::string BrookStochasticDynamics::_getDerivedParametersString( int derivedPar
*
*/
int BrookStochasticDynamics::_initializeStreams( const Platform& platform ){
int BrookLangevinDynamics::_initializeStreams( const Platform& platform ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookStochasticDynamics::_initializeStreams";
//static const std::string methodName = "BrookLangevinDynamics::_initializeStreams";
BrookOpenMMFloat dangleValue = (BrookOpenMMFloat) 0.0;
// ---------------------------------------------------------------------------------------
int sdAtomStreamSize = getStochasticDynamicsAtomStreamSize();
int sdAtomStreamWidth = getStochasticDynamicsAtomStreamWidth();
int sdAtomStreamSize = getLangevinDynamicsAtomStreamSize();
int sdAtomStreamWidth = getLangevinDynamicsAtomStreamWidth();
_sdStreams[SDPC1Stream] = new BrookFloatStreamInternal( BrookCommon::SDPC1Stream,
sdAtomStreamSize, sdAtomStreamWidth,
......@@ -927,15 +927,15 @@ int BrookStochasticDynamics::_initializeStreams( const Platform& platform ){
*
*/
int BrookStochasticDynamics::_updateSdStreams( void ){
int BrookLangevinDynamics::_updateSdStreams( void ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookStochasticDynamics::_updateSdStreams";
static const std::string methodName = "BrookLangevinDynamics::_updateSdStreams";
// ---------------------------------------------------------------------------------------
int sdAtomStreamSize = getStochasticDynamicsAtomStreamSize();
int sdAtomStreamSize = getLangevinDynamicsAtomStreamSize();
BrookOpenMMFloat* sdpc[2];
for( int ii = 0; ii < 2; ii++ ){
......@@ -998,11 +998,11 @@ int BrookStochasticDynamics::_updateSdStreams( void ){
*
*/
int BrookStochasticDynamics::_setInverseSqrtMasses( const std::vector<double>& masses ){
int BrookLangevinDynamics::_setInverseSqrtMasses( const std::vector<double>& masses ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookStochasticDynamics::_setInverseSqrtMasses";
//static const std::string methodName = "BrookLangevinDynamics::_setInverseSqrtMasses";
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
BrookOpenMMFloat one = (BrookOpenMMFloat) 1.0;
......@@ -1026,7 +1026,7 @@ int BrookStochasticDynamics::_setInverseSqrtMasses( const std::vector<double>& m
}
/*
* Setup of StochasticDynamics parameters
* Setup of LangevinDynamics parameters
*
* @param masses masses
* @param platform Brook platform
......@@ -1035,11 +1035,11 @@ int BrookStochasticDynamics::_setInverseSqrtMasses( const std::vector<double>& m
*
* */
int BrookStochasticDynamics::setup( const std::vector<double>& masses, const Platform& platform ){
int BrookLangevinDynamics::setup( const std::vector<double>& masses, const Platform& platform ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookStochasticDynamics::setup";
static const std::string methodName = "BrookLangevinDynamics::setup";
// ---------------------------------------------------------------------------------------
......@@ -1068,11 +1068,11 @@ int BrookStochasticDynamics::setup( const std::vector<double>& masses, const Pla
*
* */
std::string BrookStochasticDynamics::getContentsString( int level ) const {
std::string BrookLangevinDynamics::getContentsString( int level ) const {
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookStochasticDynamics::getContentsString";
static const std::string methodName = "BrookLangevinDynamics::getContentsString";
static const unsigned int MAX_LINE_CHARS = 256;
char value[MAX_LINE_CHARS];
......
#ifndef OPENMM_BROOK_STOCHASTIC_DYNAMCIS_H_
#define OPENMM_BROOK_STOCHASTIC_DYNAMCIS_H_
#ifndef OPENMM_BROOK_LANGEVIN_DYNAMICS_H_
#define OPENMM_BROOK_LANGEVIN_DYNAMICS_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
......@@ -49,7 +49,7 @@ namespace OpenMM {
*
*/
class BrookStochasticDynamics : public BrookCommon {
class BrookLangevinDynamics : public BrookCommon {
public:
......@@ -58,14 +58,14 @@ class BrookStochasticDynamics : public BrookCommon {
*
*/
BrookStochasticDynamics( );
BrookLangevinDynamics( );
/**
* Destructor
*
*/
~BrookStochasticDynamics();
~BrookLangevinDynamics();
/**
* Get tau
......@@ -110,28 +110,28 @@ class BrookStochasticDynamics : public BrookCommon {
const BrookOpenMMFloat* getDerivedParameters( void ) const;
/**
* Get StochasticDynamics atom stream width
* Get LangevinDynamics atom stream width
*
* @return atom stream width
*/
int getStochasticDynamicsAtomStreamWidth( void ) const;
int getLangevinDynamicsAtomStreamWidth( void ) const;
/**
* Get StochasticDynamics atom stream height
* Get LangevinDynamics atom stream height
*
* @return atom stream height
*/
int getStochasticDynamicsAtomStreamHeight( void ) const;
int getLangevinDynamicsAtomStreamHeight( void ) const;
/**
* Get StochasticDynamics atom stream size
* Get LangevinDynamics atom stream size
*
* @return atom stream size
*/
int getStochasticDynamicsAtomStreamSize( void ) const;
int getLangevinDynamicsAtomStreamSize( void ) const;
/**
* Update parameters
......@@ -163,7 +163,7 @@ class BrookStochasticDynamics : public BrookCommon {
const Stream& forces, BrookShakeAlgorithm& brookShakeAlgorithm,
BrookRandomNumberGenerator& brookRandomNumberGenerator );
/**
* Get array of StochasticDynamics streams
* Get array of LangevinDynamics streams
*
* @return array ofstreams
*
......@@ -172,7 +172,7 @@ class BrookStochasticDynamics : public BrookCommon {
BrookFloatStreamInternal** getStreams( void );
/*
* Setup of StochasticDynamics parameters
* Setup of LangevinDynamics parameters
*
* @param masses atom masses
* @param platform Brook platform
......@@ -266,7 +266,7 @@ class BrookStochasticDynamics : public BrookCommon {
// streams indices
enum BrookStochasticDynamicsStreams {
enum BrookLangevinDynamicsStreams {
SDPC1Stream,
SDPC2Stream,
SD2XStream,
......@@ -298,7 +298,7 @@ class BrookStochasticDynamics : public BrookCommon {
*
*/
//std::string _getDerivedParametersString( BrookStochasticDynamics::DerivedParameters ) const;
//std::string _getDerivedParametersString( BrookLangevinDynamics::DerivedParameters ) const;
std::string _getDerivedParametersString( int id ) const;
/**
......@@ -419,4 +419,4 @@ class BrookStochasticDynamics : public BrookCommon {
} // namespace OpenMM
#endif /* OPENMM_BROOK_STOCHASTIC_DYNAMCIS_H_ */
#endif /* OPENMM_BROOK_LANGEVIN_DYNAMICS_H_ */
......@@ -157,7 +157,7 @@ void BrookPlatform::_initializeKernelFactory( void ){
registerKernelFactory( CalcGBSAOBCForceFieldKernel::Name(), factory);
registerKernelFactory( IntegrateVerletStepKernel::Name(), factory);
registerKernelFactory( IntegrateLangevinStepKernel::Name(), factory);
//registerKernelFactory( IntegrateBrownianStepKernel::Name(), factory);
registerKernelFactory( IntegrateBrownianStepKernel::Name(), factory);
//registerKernelFactory( ApplyAndersenThermostatKernel::Name(), factory);
registerKernelFactory( CalcKineticEnergyKernel::Name(), factory);
registerKernelFactory( RemoveCMMotionKernel::Name(), factory);
......
#ifndef __INVMAP_H__
#define __INVMAP_H__
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
/*
* For each atom, calculates the positions at which it's
* forces are to be picked up from and stores the position
......
/****************************************************************
* This file is part of the gpu acceleration library for gromacs.
* Author: Mark Friedrichs
*
* This kernel was developed in collaboration with
*
* Copyright (C) Pande Group, Stanford, 2006
*****************************************************************/
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
kernel void loop2Internal( float3 d1, float3 d2, float3 d3, float3 d4, float4 jAtomicRadiiScaled,
float bornForce, float iAtomicRadii, out float4 de<>, out float4 bornSum<> ){
......
/****************************************************************
* This file is part of the gpu acceleration library for gromacs.
* Author: V. Vishal
* Copyright (C) Pande Group, Stanford, 2006
*****************************************************************/
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
//Harmonic bonds kernel
//Input is a stream of i, j pairs
......
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
/**---------------------------------------------------------------------------------------
......
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
void kCalculateLinearMomentum( ::brook::stream mass, ::brook::stream velocities, ::brook::stream linearMomentum );
void kReduceLinearMomentum( ::brook::stream momentum, ::brook::stream linearMomentum );
......
/****************************************************************
* This file is part of the gpu acceleration library for gromacs.
* Author: V. Vishal
* Copyright (C) Pande Group, Stanford, 2006
*****************************************************************/
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
//Inverse of above
kernel void kgetxyz( float4 instr<>, out float3 outstr<> ) {
......
#ifndef __KCOMMON_H__
#define __KCOMMON_H__
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
void kgetxyz (::brook::stream instr,
::brook::stream outstr);
......
#ifndef __KFORCE_H__
#define __KFORCE_H__
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
//Define a generic force kernel prototype
//To make switching easier to look at
//This should match the kernels from kforce.br
......
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
kernel float4 scalar_force_CDLJ( float4 qq, float epsfac, float4 sig, float4 eps, float4 r2, float4 params ) {
float4 invr, invrsig2, invrsig6;
float4 f;
......
#ifndef __KGBSA_H__
#define __KGBSA_H__
/* -------------------------------------------------------------------------- *
* 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, Chris Bruns *
* 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. *
* -------------------------------------------------------------------------- */
void kMergeFloat4(
const float repfac,
const float atomStrWidth,
......
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