"platforms/cuda/tests/TestCudaCMMotionRemover.cpp" did not exist on "85da5e0f9018719e95350c76b483a2160c84d9d3"
Commit 4d5051b6 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Bonded & Nonbonded classes

parent 9b08b9b5
This diff is collapsed.
#ifndef BrookBonded_H_
#define BrookBonded_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 "BrookFloatStreamImpl.h"
#include "BrookIntStreamImpl.h"
#include "BrookPlatform.h"
#include "BrookCommon.h"
#include "OpenMMContext.h"
namespace OpenMM {
/**
* This kernel is invoked by StandardMMForceField to calculate the forces acting on the system.
*/
class BrookBonded : public BrookCommon {
public:
static const int DefaultReturnValue = 0;
static const int ErrorReturnValue = -1;
BrookBonded( );
~BrookBonded();
/**
* 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 nonbondedParameters the nonbonded force parameters (charge, sigma, epsilon) for each atom
* @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 log log reference
*
* @return nonzero value if error
*
*/
int setup( int numberOfAtoms,
const std::vector<std::vector<int> >& bondIndices, const std::vector<std::vector<double> >& bondParameters,
const std::vector<std::vector<int> >& angleIndices, const std::vector<std::vector<double> >& angleParameters,
const std::vector<std::vector<int> >& periodicTorsionIndices, const std::vector<std::vector<double> >& periodicTorsionParameters,
const std::vector<std::vector<int> >& rbTorsionIndices, const std::vector<std::vector<double> >& rbTorsionParameters,
const std::vector<std::vector<int> >& bonded14Indices, const std::vector<std::vector<double> >& nonbondedParameters,
double lj14Scale, double coulomb14Scale, const BrookPlatform& platform );
/**
* Return number of parameter streams
*
* @return number of parameter streams
*
*/
int getNumberOfParameterStreams( void ) const;
/**
* Return number of force streams
*
* @return number of force streams
*
*/
int getNumberOfForceStreams( void ) const;
/**
* Return stream count for specifed index (i, j, k, l)
*
* @return stream count for specifed index
*
* @throw throws OpenMMException if index out of range
*/
int getInverseMapStreamCount( int index ) const;
/**
* Return max stream count
*
* @return max stream count
*/
int getMaxInverseMapStreamCount( void ) const;
/**
* Return Brook stream handle
*
* @return
*/
BrookFloatStreamImpl* getBrookAtomIndices( void ) const;
/**
* Get LJ 14 scale factor
*
* @return LJ 14 scaling (fudge) factor
*
*/
BrookOpenMMFloat getLJ_14Scale( void ) const;
/**
* Get Coulomb factor
*
* @return Coulomb factor
*
*/
BrookOpenMMFloat getCoulombFactor( void ) const;
/**
* Get bonded atom indices stream
*
* @return atom indices stream
*
*/
BrookFloatStreamImpl* getAtomIndicesStream( void ) const;
/**
* Get array of bonded parameter streams
*
* @return array of bonded parameter streams
*
*/
BrookFloatStreamImpl** getBondedParameterStreams( void );
/**
* Get array of force streams
*
* @return array
*
*/
BrookFloatStreamImpl** getBondedForceStreams( void );
/**
* Get array of inverse map streams
*
* @param index array index
*
* @return array inverse map streams
*
*/
BrookFloatStreamImpl** getInverseStreamMapsStreams( int index );
/**
* Return true if force[index] stream is set
*
* @param index into force stream
* @return true if index is valid && force[index] stream is set; else false
*
*/
int isForceStreamSet( int index ) const;
/**
* Return true if paramsterSet[index] stream is set
*
* @param index into parameter stream
*
* @return true if index is valid && paramsterSet[index] stream is set; else false
*
*/
int isParameterStreamSet( int index ) const;
/**
* Return string showing if all inverse map streams are set
*
* @param index into inverse map stream array
*
* @return informative string
*
*/
std::string checkInverseMapStream( int index ) const;
/*
* Get contents of object
*
*
* @param level level of dump
*
* @return string containing contents
*
* */
std::string getContents( int level ) const;
private:
static const int NumberOfParameterStreams = 5;
static const int NumberOfForceStreams = 4;
static const int MaxNumberOfInverseMaps = 9;
enum { StreamI, StreamJ, StreamK, StreamL, StreamMax };
// inverse map stream width
int _invMapStreamWidth;
// actual max number of inverse maps
int _maxNumberOfInverseMaps;
// scale factors for 1-4 ixn
BrookOpenMMFloat _ljScale;
BrookOpenMMFloat _coulombFactor;
// streams
BrookFloatStreamImpl* _atomIndicesStream;
BrookFloatStreamImpl* _bondedParameters[NumberOfParameterStreams];
BrookFloatStreamImpl* _bondedForceStreams[NumberOfForceStreams];
BrookFloatStreamImpl* _chargeStream;
BrookFloatStreamImpl* _inverseStreamMaps[NumberOfForceStreams][MaxNumberOfInverseMaps];
int _maxInverseMapStreamCount[NumberOfForceStreams];
int _inverseMapStreamCount[NumberOfForceStreams];
// helper methods in setup of parameters
void flipQuartet( int ibonded, int *atoms );
int matchTorsion( int i, int j, int k, int l, int nbondeds, int *atoms );
int matchAngle( int i, int j, int k, int nbondeds, int *atoms, int *flag );
int matchBond( int i, int j, int nbondeds, int *atoms, int *flag );
int matchPair( int i, int j, int nbondeds, int *atoms );
/**
* Setup Ryckaert-Bellemans parameters/atom indices
*
* @param nbondeds number of bonded entries
* @param atoms array of atom indices
* @param params arrays of bond parameters
* @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
*
* @return nonzero value if error
*
*/
int addRBDihedrals( int *nbondeds, int *atoms, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& rbTorsionIndices,
const std::vector<std::vector<double> >& rbTorsionParameters );
/**
* Setup periodic torsion parameters/atom indices
*
* @param nbondeds number of bonded entries
* @param atoms array of atom indices
* @param params arrays of bond parameters
* @param periodicTorsionIndices the four atoms connected by each periodic torsion term
* @param periodicTorsionParameters the force parameters (k, phase, periodicity) for each periodic torsion term
*
* @return nonzero value if error
*
*/
int addPDihedrals( int *nbondeds, int *atoms, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& periodicTorsionIndices,
const std::vector<std::vector<double> >& periodicTorsionParameters );
/**
* Setup angle bond parameters/atom indices
*
* @param nbondeds number of bonded entries
* @param atoms array of atom indices
* @param params arrays of bond parameters
* @param angleIndices the angle bond atom indices
* @param angleParameters the angle parameters (angle in radians, force constant)
*
* @return nonzero value if error
*
*/
int addAngles( int *nbondeds, int *atoms, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& angleIndices,
const std::vector<std::vector<double> >& angleParameters );
/**
* Setup harmonic bond parameters/atom indices
*
* @param nbondeds number of bonded entries
* @param atoms array of atom indices
* @param params arrays of bond parameters
* @param bondIndices two harmonic bond atom indices
* @param bondParameters the force parameters (distance, k)
*
* @return nonzero value if error
*
*/
int addBonds( int *nbondeds, int *atoms, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& bondIndices,
const std::vector<std::vector<double> >& bondParameters );
/**
* Setup LJ/Coulomb 1-4 parameters/atom indices
*
* @param nbondeds number of bonded entries
* @param atoms array of atom indices
* @param params arrays of bond parameters
* @param charges array of charges
* @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 nonbondedParameters the nonbonded force parameters (charge, sigma, epsilon) for each atom
* @param lj14Scale the factor by which van der Waals interactions should be reduced for bonded 1-4 pairs
*
* @return nonzero value if error
*
*/
int addPairs( int *nbondeds, int *atoms, BrookOpenMMFloat* params[], BrookOpenMMFloat* charges,
const std::vector<std::vector<int> >& bonded14Indices, const std::vector<std::vector<double> >& nonbondedParameters,
double lj14Scale, double coulombScale );
/**
* Create and load inverse maps for bonded ixns
*
* @param nbondeds number of bonded entries
* @param natoms number of atoms
* @param atoms arrays of atom indices (atoms[numberOfBonds][4])
* @param platform BrookPlatform reference
* @param log log file reference (optional)
*
* @return nonzero value if error
*
*/
int loadInvMaps( int nbondeds, int natoms, int *atoms, const BrookPlatform& platform );
/**
* Get inverse amp stream width
*
* @return stream width
*
*/
int getInvMapStreamWidth( void ) const;
/**
* Validate inverse map count
*
* @param index index to check (1-4)
* @param count count for index
*
* @return -1 if count invalid
*
* @tthrow OpenMMException exeception if count invalid
*
*/
int validateInverseMapStreamCount( int index, int count ) const;
};
} // namespace OpenMM
#endif /*OPENMM_BROOKKERNELS_H_*/
This diff is collapsed.
#ifndef BrookNonBonded_H_
#define BrookNonBonded_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 "BrookFloatStreamImpl.h"
#include "BrookIntStreamImpl.h"
#include "BrookPlatform.h"
#include "BrookCommon.h"
namespace OpenMM {
/**
* This kernel is invoked by StandardMMForceField to calculate the forces acting on the system.
*/
class BrookNonBonded : public BrookCommon {
public:
// return values
static const int DefaultReturnValue = 0;
static const int ErrorReturnValue = -1;
BrookNonBonded( );
~BrookNonBonded();
/**
* Return number of force streams
*
* @return number of force streams
*
*/
int getNumberOfForceStreams( void ) const;
/**
* Get duplication factor
*
* @return duplication factor
*
*/
int getDuplicationFactor( void ) const;
/**
* Get atom ceiling parameter
*
* @return atom ceiling parameter
*
*/
int getAtomSizeCeiling( void ) const;
/**
* Get outer loop unroll
*
* @return outer loop unroll (fixed value)
*
*/
int getOuterLoopUnroll( void ) const;
/**
* Set outer loop unroll
*
* @param outer loop unroll (fixed value)
*
* @return updated outer loop unroll (fixed value)
*
*/
int setOuterLoopUnroll( int outerUnroll );
/**
* Return unrolling for inner loops
*
* @return outer loop unrolling
*/
int getInnerLoopUnroll( void ) const;
/**
* Get j-stream width
*
* @param platform platform reference
*
* @return j-stream width
*/
int getJStreamWidth( const Platform& platform );
/**
* Get j-stream width
*
* @return j-stream width
*/
int getJStreamWidth( void ) const;
/**
* Get j-stream height
*
* @param platform platform reference
*
* @return j-stream height
*/
int getJStreamHeight( const Platform& platform );
/**
* Get j-stream height
*
* @return j-stream height
*/
int getJStreamHeight( void ) const;
/**
* Get j-stream size
*
* @param platform platform reference
*
* @return j-stream size
*/
int getJStreamSize( const Platform& platform );
/**
* Get j-stream size
*
* @return j-stream size
*/
int getJStreamSize( void ) const;
/**
* Get partial force stream width
*
* @param platform platform reference
*
* @return partial force stream width
*/
int getPartialForceStreamWidth( const Platform& platform );
/**
* Get partial force stream width
*
* @return partial force stream width
*/
int getPartialForceStreamWidth( void ) const;
/**
* Get partial force stream height
*
* @param platform platform reference
*
* @return partial force stream height
*/
int getPartialForceStreamHeight( const Platform& platform );
/**
* Get partial force stream height
*
* @return partial force stream height
*/
int getPartialForceStreamHeight( void ) const;
/**
* Get partial force stream size
*
* @param platform platform reference
*
* @return partial force stream size
*/
int getPartialForceStreamSize( const Platform& platform );
/**
* Get partial force stream size
*
* @return partial force stream size
*/
int getPartialForceStreamSize( void ) const;
/**
* Get partial force stream size
*
* @return partial force stream size
*/
/**
* Get exclusion stream width
*
* @return exclusion stream width
*/
int getExclusionStreamWidth( void ) const;
/**
* Get exclusion stream size
*
* @return exclusion stream size
*/
int getExclusionStreamSize( void ) const;
/**
* Get exclusion stream
*
* @return exclusion stream
*
*/
BrookFloatStreamImpl* getExclusionStream( void ) const;
/**
* Get vdw stream
*
* @return vdw stream
*
*/
BrookFloatStreamImpl* getVdwStream( void ) const;
/**
* Get charge stream
*
* @return charge stream
*
*/
BrookFloatStreamImpl* getChargeStream( void ) const;
/**
* Get sigma-eps stream
*
* @return sigma-eps stream
*
*/
BrookFloatStreamImpl* getSigmaStream( void ) const;
/**
* Get epsilon stream
*
* @return epsilon stream
*
*/
BrookFloatStreamImpl* getEpsilonStream( void ) const;
/**
* Get force streams
*
* @return force streams
*
*/
BrookFloatStreamImpl** getForceStreams( void );
/**
* Return true if force[index] stream is set
*
* @return true if index is valid && force[index] stream is set; else false
*
*/
int isForceStreamSet( int index ) const;
/*
* Setup of nonbonded ixns
*
* @param numberOfAtoms number of atoms
* @param nonbondedParameters vector of nonbonded parameters [atomI][0=c6]
* [atomI][1=c12]
* [atomI][2=charge]
* @param platform Brook platform
* @param log optional Log file reference
*
* @return nonzero value if error
* */
int setup( int numberOfAtoms, const std::vector<std::vector<double> >& nonbondedParameters,
const std::vector<std::set<int> >& exclusions, const BrookPlatform& platform );
/*
* Get contents of object
*
* @param level of dump
*
* @return string containing contents
*
* */
std::string getContents( int level ) const;
private:
// fixed number of force streams
static const int NumberOfForceStreams = 4;
// atom ceiling
int _atomSizeCeiling;
// unroll in i/j dimensions
int _outerUnroll;
int _innerUnroll;
// duplication factor
int _duplicationFactor;
// force stream width
int _partialForceStreamWidth;
int _partialForceStreamHeight;
int _partialForceStreamSize;
// exclusions stream dimensions
int _exclusionStreamWidth;
int _exclusionStreamHeight;
int _exclusionStreamSize;
// j-stream dimensions
int _jStreamWidth;
int _jStreamHeight;
int _jStreamSize;
// streams
BrookFloatStreamImpl* _exclusionStream;
BrookFloatStreamImpl* _vdwStream;
BrookFloatStreamImpl* _chargeStream;
BrookFloatStreamImpl* _sigmaStream;
BrookFloatStreamImpl* _epsilonStream;
BrookFloatStreamImpl* _nonbondedForceStreams[NumberOfForceStreams];
/**
* Initialize exclusion stream dimensions and stream
*
* @param platform platform
*
* @return nonzero value if error
*
*/
int initializeExclusionStream( const Platform& platform );
/**
* Set exclusion (4x4)
*
* @param i atom i index
* @param j atom j index
* @param exclusionStreamWidth exclusion stream width
* @param exclusion array of packed exclusions
*
* @return nonzero value if error
*
*/
int setExclusion( int i, int j, int exclusionStreamWidth, BrookOpenMMFloat* exclusion );
/**
* Initialize exclusions
*
* @param exclusions vector of sets containing exclusions (1 set entry for every atom)
* @param platform platform
*
* @return nonzero value if error
*
*/
int initializeExclusions( const std::vector<std::set<int> >& exclusionsVector, const Platform& platform );
/**
* Initialize stream dimensions and streams
*
* @param platform platform
*
* @return nonzero value if error
*
*/
int initializeStreams( int numberOfAtoms, const Platform& platform );
/**
* Set sigma & epsilon given c6 & c12 (geometric rule)
*
* @param c6 vdw c6
* @param c12 vdw c12
* @param sigma massaged sigma
* @param epsilon massaged epsilon
*
* @return nonzero value if error
*
*/
int setSigmaEpsilon( double c6, double c12, double* sigma , double* epsilon );
/**
* Initialize vdw & charge
*
* @param exclusions vector of sets containing exclusions (1 set entry for every atom)
* @param platform platform
*
* @return nonzero value if error
*
*/
int initializeVdwAndCharge( const std::vector<std::vector<double> >& nonbondedParameters, const Platform& platform );
};
} // namespace OpenMM
#endif /*OPENMM_BROOKKERNELS_H_*/
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