Commit 6ccf6169 authored by Peter Eastman's avatar Peter Eastman
Browse files

Removed Brook platform

parent 82e0bd2f
......@@ -329,11 +329,6 @@ MARK_AS_ADVANCED(CUDA_VERBOSE_BUILD)
MARK_AS_ADVANCED(CUDA_BUILD_CUBIN)
MARK_AS_ADVANCED(CUDA_BUILD_EMULATION)
SET(OPENMM_BUILD_BROOK_LIB OFF CACHE BOOL "Build OpenMMBrook library for ATI GPUs")
IF(OPENMM_BUILD_BROOK_LIB)
ADD_SUBDIRECTORY(platforms/brook)
ENDIF(OPENMM_BUILD_BROOK_LIB)
IF(NOT cmv EQUAL "2.4")
FIND_PACKAGE(OpenCL QUIET)
ENDIF(NOT cmv EQUAL "2.4")
......
#----------------------------------------------------
# OpenMM Brook Platform
#
# Creates OpenMM library, base name=OpenMM_Brook.
# Default libraries are shared & optimized. Variants
# are created for static (_static) and debug (_d).
#
# Windows:
# OpenMM_Brook[_d].dll
# OpenMM_Brook[_d].lib
# OpenMM_BROOK_static[_d].lib
# Unix:
# libOpenMM_Brook[_d].so
# libOpenMM_BROOK_static[_d].a
#----------------------------------------------------
SUBDIRS (tests)
# include static brook
SET(INCLUDE_BROOK_STATIC 1)
# logging
SET(LOG TRUE)
IF(LOG)
SET(LOG_FILE "CMakeLog.txt" )
FILE( WRITE ${LOG_FILE} "In Brook Cmake\n")
ENDIF(LOG)
# ----------------------------------------------------------------------------
IF(LOG)
MACRO(LOG_DIR LOG_FILE DIR_LIST DIRS1 )
FILE( APPEND ${LOG_FILE} "\n${DIR_LIST}\n")
FOREACH(currentFile ${ARGN})
FILE( APPEND ${LOG_FILE} " ${currentFile}\n" )
ENDFOREACH(currentFile)
ENDMACRO(LOG_DIR)
LOG_DIR( ${LOG_FILE} "API_INCLUDE_DIRS" ${API_INCLUDE_DIRS} )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# The source is organized into subdirectories, but we handle them all from
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET(OPENMM_SOURCE_SUBDIRS .)
# Collect up information about the version of the OpenMM library we're building
# and make it available to the code so it can be built into the binaries.
SET(OpenMM_BROOK_LIBRARY_NAME OpenMM_Brook)
SET(SHARED_BROOK_TARGET ${OpenMM_BROOK_LIBRARY_NAME})
SET(STATIC_BROOK_TARGET ${OpenMM_BROOK_LIBRARY_NAME}_static)
# Ensure that debug libraries have "_d" appended to their names.
# CMake gets this right on Windows automatically with this definition.
IF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
SET(CMAKE_DEBUG_POSTFIX "_d" CACHE INTERNAL "" FORCE)
ENDIF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
# But on Unix or Cygwin we have to add the suffix manually
IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET(SHARED_BROOK_TARGET ${SHARED_BROOK_TARGET}_d)
SET(STATIC_BROOK_TARGET ${STATIC_BROOK_TARGET}_d)
ENDIF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
# These are all the places to search for header files which are
# to be part of the API.
SET(API_INCLUDE_DIRS) # start empty
FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS})
# append
SET(API_INCLUDE_DIRS ${API_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include
${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include/internal)
ENDFOREACH(subdir)
# We'll need both *relative* path names, starting with their API_INCLUDE_DIRS,
# and absolute pathnames.
SET(API_REL_INCLUDE_FILES) # start these out empty
SET(API_ABS_INCLUDE_FILES)
FOREACH(dir ${API_INCLUDE_DIRS})
FILE(GLOB fullpaths ${dir}/*.h) # returns full pathnames
SET(API_ABS_INCLUDE_FILES ${API_ABS_INCLUDE_FILES} ${fullpaths})
FOREACH(pathname ${fullpaths})
GET_FILENAME_COMPONENT(filename ${pathname} NAME)
SET(API_REL_INCLUDE_FILES ${API_REL_INCLUDE_FILES} ${dir}/${filename})
ENDFOREACH(pathname)
ENDFOREACH(dir)
# ----------------------------------------------------------------------------
IF(LOG)
LOG_DIR( ${LOG_FILE} "API_ABS_INCLUDE_FILES" ${API_ABS_INCLUDE_FILES} )
LOG_DIR( ${LOG_FILE} "API_REL_INCLUDE_FILES" ${API_REL_INCLUDE_FILES} )
LOG_DIR( ${LOG_FILE} "CMAKE_CURRENT_SOURCE_DIR" ${CMAKE_CURRENT_SOURCE_DIR} )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# collect cpp source files
SET(SOURCE_FILES) # empty
SET(SOURCE_INCLUDE_FILES)
# SET( CMAKE_CURRENT_SOURCE_DIR /home/friedrim/src/openmm/trunk/OpenMM/platforms/brook )
FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS})
FILE(GLOB src_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*/*.cpp)
FILE(GLOB incl_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.h)
SET(SOURCE_FILES ${SOURCE_FILES} ${src_files}) #append
SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files})
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include)
ENDFOREACH(subdir)
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
# ----------------------------------------------------------------------------
IF(LOG)
LOG_DIR( ${LOG_FILE} "BROOK_SOURCE_FILES" ${SOURCE_FILES} )
LOG_DIR( ${LOG_FILE} "SOURCE_INCLUDE_FILES" ${SOURCE_INCLUDE_FILES} )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# Brook setup
# MESSAGE("CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" )
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/brook-cmake/FindBrook.cmake)
INCLUDE_DIRECTORIES(${BROOK_INCLUDE_DIR})
LINK_DIRECTORIES(${${BROOK_brook_LIBRARY}})
# get *br files
FILE(GLOB BROOK_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/kernels/*.br)
FILE(GLOB BROOK_INCLUDE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/kernels/*.h)
FILE( APPEND ${LOG_FILE} "BROOK_SRC_FILES=${BROOK_SRC_FILES}\n" )
# ----------------------------------------------------------------------------
IF(LOG)
# LOG_DIR( ${LOG_FILE} "Brook src" ${BROOK_SRC_FILES} )
# LOG_DIR( ${LOG_FILE} "Brook include" ${BROOK_INCLUDE_FILES} )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# create Brook custom rules
SET(BROOK_CPP_FILES)
FOREACH(brookFile ${BROOK_SRC_FILES})
BROOK_FILE( ${brookFile} )
ENDFOREACH(brookFile)
# ----------------------------------------------------------------------------
IF(LOG)
# LOG_DIR( ${LOG_FILE} "Brook cpp" ${BROOK_CPP_FILES} )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# BROOK_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
ADD_LIBRARY(${SHARED_BROOK_TARGET} SHARED ${BROOK_CPP_FILES} ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} )
SET_TARGET_PROPERTIES(${SHARED_BROOK_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY")
IF(INCLUDE_BROOK_STATIC)
SET( BROOK_STATIC_COMPILE_FLAG "-DOPENMM_BUILDING_STATIC_LIBRARY -DOPENMM_USE_STATIC_LIBRARIES")
ADD_LIBRARY(${STATIC_BROOK_TARGET} STATIC ${BROOK_CPP_FILES} ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} )
SET_TARGET_PROPERTIES(${STATIC_BROOK_TARGET} PROPERTIES COMPILE_FLAGS ${BROOK_STATIC_COMPILE_FLAG})
ENDIF(INCLUDE_BROOK_STATIC)
# ----------------------------------------------------------------------------
IF(LOG)
FILE( APPEND ${LOG_FILE} "\nSTATIC_BROOK_TARGET=${STATIC_BROOK_TARGET} OPENMM_LIBRARY_NAME=${OPENMM_LIBRARY_NAME}\n" )
FILE( APPEND ${LOG_FILE} "SHARED_BROOK_TARGET=${SHARED_BROOK_TARGET} SHARED_TARGET=${SHARED_TARGET} STATIC_TARGET=${STATIC_TARGET}\n" )
FILE( APPEND ${LOG_FILE} "PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} BROOK_LIB_PATH=${BROOK_LIB_PATH}\n" )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# shared
# TARGET_LINK_LIBRARIES(${SHARED_BROOK_TARGET} debug ${OPENMM_LIBRARY_NAME}_d optimized ${OPENMM_LIBRARY_NAME})
TARGET_LINK_LIBRARIES(${SHARED_BROOK_TARGET} ${SHARED_TARGET})
# the line below does not work for some reason
# using the following 3 lines in its place until understand more fully source of problem
# TARGET_LINK_LIBRARIES(${SHARED_BROOK_TARGET} debug brook_d optimized brook)
SET(BrookLib ${BROOK_LIB_PATH}/brook.lib)
SET(BrookDebugLib ${BROOK_LIB_PATH}/brook_d.lib)
TARGET_LINK_LIBRARIES(${SHARED_BROOK_TARGET} debug ${BrookDebugLib} optimized ${BrookLib})
LINK_DIRECTORIES(${SHARED_BROOK_TARGET} ${BROOK_LIB_PATH})
LINK_DIRECTORIES(${SHARED_BROOK_TARGET} ${PROJECT_BINARY_DIR})
# ----------------------------------------------------------------------------
#static
IF(INCLUDE_BROOK_STATIC)
TARGET_LINK_LIBRARIES(${STATIC_BROOK_TARGET} debug ${OPENMM_LIBRARY_NAME}_static_d optimized ${OPENMM_LIBRARY_NAME}_static)
TARGET_LINK_LIBRARIES(${STATIC_BROOK_TARGET} debug brook_d optimized brook)
TARGET_LINK_LIBRARIES(${STATIC_BROOK_TARGET} ${STATIC_TARGET})
LINK_DIRECTORIES(${STATIC_BROOK_TARGET} ${BROOK_LIB_PATH})
ENDIF(INCLUDE_BROOK_STATIC)
# ----------------------------------------------------------------------------
#install
IF(INCLUDE_BROOK_STATIC)
INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${STATIC_BROOK_TARGET})
ENDIF(INCLUDE_BROOK_STATIC)
INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${SHARED_BROOK_TARGET})
# - Look for the BrookGPU streaming extension to C language
#
# BROOK_FILE : .BR -> .CPP
# BROOK_INCLUDE_DIR : Include directory for Brook.hpp
# BROOK_C[XX]FLAGS : Flags needed to compile the produced CPP file
# BROOK_LIBRARIES : All needed libraries, including OpenGL for OGL backend
#
# Used internally :
# BROOK_CC : Location of BRCC
# BROOK_xxx_LIBRARY : Location of the various libraries used by brook
#
# ----------------------------------------------------------------------------
# Call find twice, so BROOKROOT takes precedence, but system path is a fallback
FIND_PATH(BROOK_INCLUDE_DIR brook/brook.hpp $ENV{BROOKROOT}/sdk/include NO_DEFAULT_PATH)
FIND_PATH(BROOK_INCLUDE_DIR brook/brook.hpp)
SET(BROOK_CXXFLAGS "-I${BROOK_INCLUDE_DIR}")
SET(BROOK_CFLAGS "${BROOK_CXXFLAGS}")
# Call find twice, so BROOKROOT takes precedence, but system path is a fallback
FIND_PROGRAM(BROOK_CC brcc $ENV{BROOKROOT}/sdk/bin NO_DEFAULT_PATH)
FIND_PROGRAM(BROOK_CC brcc)
# Search for all libraries
# - both BASE and RUNTIME TARGETS
# ----------------------------------------------------------------------------
FIND_LIBRARY(BROOK_brook_LIBRARY
NAMES
brook
brook_d
PATHS
$ENV{BROOKROOT}/sdk/lib)
# if found, add to list
IF (BROOK_brook_LIBRARY)
SET(BROOK_LIBRARIES ${BROOK_LIBRARIES} ${BROOK_brook_LIBRARY})
ENDIF (BROOK_brook_LIBRARY)
# all individual libs are advanced settings
MARK_AS_ADVANCED(BROOK_brook_LIBRARY)
# ----------------------------------------------------------------------------
IF(LOG)
FILE( APPEND ${LOG_FILE} "\nIn FindBrook.cmake\n" )
FILE( APPEND ${LOG_FILE} "BROOK_INCLUDE_DIR=${BROOK_INCLUDE_DIR}\n" )
FILE( APPEND ${LOG_FILE} "BROOK_CC=${BROOK_CC}\n" )
FILE( APPEND ${LOG_FILE} "BROOK_brook_LIBRARY=${BROOK_brook_LIBRARY}\n" )
FILE( APPEND ${LOG_FILE} "BROOKROOT=<$ENV{BROOKROOT}>\n" )
FILE( APPEND ${LOG_FILE} "sub_lib=<${sub_lib}>\n" )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# check if includes and main lib are here
# IF (BROOK_INCLUDE_DIR AND BROOK_brook_LIBRARY AND BROOK_CC)
SET(BROOK_FOUND TRUE)
GET_FILENAME_COMPONENT(BROOK_LIB_PATH "${BROOK_brook_LIBRARY}" PATH)
# ----------------------------------------------------------------------------
IF(LOG)
FILE( APPEND ${LOG_FILE} "BROOK_LIB_PATH=${BROOK_LIB_PATH}\n" )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# Implementation to allow interpreting/compiling Brook files
MACRO(BROOK_FILE FILENAME)
IF(LOG)
FILE( APPEND ${LOG_FILE} "1 In BROOK_FILE: ${FILENAME}\n" )
ENDIF(LOG)
# split input names
GET_FILENAME_COMPONENT(PATH "${FILENAME}" PATH)
GET_FILENAME_COMPONENT(HEAD "${FILENAME}" NAME_WE) # without trailing ".BR"
# File names
SET(OUTPATH "${CMAKE_CURRENT_BINARY_DIR}/src/kernels")
SET(BROOK_PREFIX "${OUTPATH}/${HEAD}")
SET(OUTFILE "${BROOK_PREFIX}.cpp") # file produced by Brook
# SET(INFILE "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}") # canonical input name
SET(INFILE "${FILENAME}") # canonical input name
# ----------------------------------------------------------------------------
IF(LOG)
FILE( APPEND ${LOG_FILE} "In BROOK_FILE: ${FILENAME} FILENAME\n" )
FILE( APPEND ${LOG_FILE} " Path=${PATH} HEAD=${HEAD}\n" )
FILE( APPEND ${LOG_FILE} " OUTPATH=${OUTPATH}\n BROOK_PREFIX=${BROOK_PREFIX}\n" )
FILE( APPEND ${LOG_FILE} " OUTFILE=${OUTFILE}\n INFILE=${INFILE}\n\n" )
ENDIF(LOG)
# ----------------------------------------------------------------------------
# create output path, if it does not exist
IF(NOT EXISTS "${OUTPATH}")
FILE(MAKE_DIRECTORY "${OUTPATH}")
ENDIF(NOT EXISTS "${OUTPATH}")
# Run Brook
ADD_CUSTOM_COMMAND(
OUTPUT "${OUTFILE}"
COMMAND "${BROOK_CC}"
ARGS "-o${BROOK_PREFIX}"
"${INFILE}"
DEPENDS "${INFILE}" )
# Flag file as generated
SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
# accumulate Brook cpp files
SET(BROOK_CPP_FILES ${BROOK_CPP_FILES} ${OUTFILE})
ENDMACRO(BROOK_FILE)
# ELSE (BROOK_INCLUDE_DIR AND BROOK_brook_LIBRARY AND BROOK_CC)
# SET(BROOK_FOUND FALSE)
#ENDIF (BROOK_INCLUDE_DIR AND BROOK_brook_LIBRARY AND BROOK_CC)
# Some verbosity
IF (NOT BROOK_FOUND)
IF (BROOK_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find BROOK" )
ENDIF (BROOK_FIND_REQUIRED)
ENDIF (NOT BROOK_FOUND)
# ----------------------------------------------------------------------------
IF(LOG)
FILE( APPEND ${LOG_FILE} "BROOK_FOUND=<${BROOK_FOUND}>\n" )
FILE( APPEND ${LOG_FILE} "\nLeaving FindBrook.cmake\n" )
ENDIF(LOG)
# ----------------------------------------------------------------------------
#ifndef OPENMM_BROOKKERNELFACTORY_H_
#define OPENMM_BROOKKERNELFACTORY_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 "openmm/KernelFactory.h"
namespace OpenMM {
/**
* This KernelFactory creates all kernels for BrookPlatform.
*/
class BrookKernelFactory : public KernelFactory {
public:
KernelImpl* createKernelImpl( std::string name, const Platform& platform, ContextImpl& context ) const;
};
} // namespace OpenMM
#endif /*OPENMM_BROOKKERNELFACTORY_H_*/
#ifndef OPENMM_BROOKPLATFORM_H_
#define OPENMM_BROOKPLATFORM_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. *
* -------------------------------------------------------------------------- */
// default float size for Brook
#define BrookOpenMMFloat float
#include "openmm/Platform.h"
#include "BrookStreamFactory.h"
namespace OpenMM {
class KernelImpl;
class OpenMMBrookInterface;
class BrookPlatformData {
public:
/**
* Constructor
*
*/
BrookPlatformData( void );
/**
* Destructor
*
*/
~BrookPlatformData( void );
/**
* Get _removeCOM flag
*
* @return _removeCOM
*
*/
int removeCOM( void ) const;
/**
* Get _useOBC flag
*
* @return _useOBC
*
*/
int useOBC( void ) const;
/**
* Get _hasBonds flag
*
* @return _hasBonds
*
*/
int hasBonds( void ) const;
/**
* Get _hasAngles
*
* @return _hasAngles
*
*/
int hasAngles( void ) const;
/**
* Get _hasPeriodicTorsions
*
* @return _hasPeriodicTorsions
*
*/
int hasPeriodicTorsions( void ) const;
/**
* Get _hasRB
*
* @return _hasRB
*
*/
int hasRB( void ) const;
/**
* Get _hasNonbonded
*
* @return _hasNonbonded
*
*/
int hasNonbonded( void ) const;
/**
* Get _cmMotionFrequency
*
* @return _cmMotionFrequency
*
*/
int cmMotionFrequency( void ) const;
private:
int _removeCOM;
int _useOBC;
int _hasBonds;
int _hasAngles;
int _hasPeriodicTorsions;
int _hasRB;
int _hasNonbonded;
int _cmMotionFrequency;
};
/**
* This Platform subclass uses the Brook implementations of all the OpenMM kernels.
*/
class OPENMM_EXPORT BrookPlatform : public Platform {
public:
// return values
static const int DefaultReturnValue = 0;
static const int DefaultErrorValue = -1;
/**
* BrookPlatform constructor
*
*/
BrookPlatform();
/**
* BrookPlatform constructor
*
* @param defaultParticleStreamWidth stream width
* @param runtime Brook runtime (cal/cpu)
* @param log log file reference
*
*/
BrookPlatform( int particleStreamWdith, const std::string& runtime, FILE* log = NULL );
/**
* BrookPlatform destructor
*
*/
~BrookPlatform();
/**
* Return platform name
*
* @return "Brook"
*/
const std::string& getName() const;
/**
* Return platform speed
*
* @return speed
*/
double getSpeed( void ) const;
/**
* Return true if BrookPlatform supports double precison
*
* @return true if BrookPlatform supports double precison
*/
// w/ FAH bool is redefined as int; causes problem w/ Platform::bool supportsDoublePrecision() const;
#define bool bool
bool supportsDoublePrecision( void ) const;
/**
* Return default Brook stream factory
*
* @return Brook stream factory
*/
const StreamFactory& getDefaultStreamFactory( void ) const;
/**
* Get the runtime
*
* @return runtime
*/
std::string getRuntime( void );
/**
* Get stream height and size given minimum number of elements in stream
*
* @param size input size of stream
* @param width width of stream
* @param height output height of stream (may be NULL)
*
* @return stream size (=streamWidth*height)
*/
static int getStreamSize( int size, int streamWidth, int* outputHeight );
/**
* Get default stream width
*
* @return default stream width
*/
int getParticleStreamWidth( void ) const;
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int setLog( FILE* log );
/*
* Get contents of object
*
* @param level of dump
*
* @return string containing contents
*
* */
std::string getContents( int level ) const;
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE* getLog( void ) const;
/**
* This is called whenever a new Context is created. It gives the Platform a chance to initialize
* the context and store platform-specific data in it.
*/
void contextCreated( ContextImpl& context ) const;
/**
* This is called whenever a Context is deleted. It gives the Platform a chance to clean up
* any platform-specific data that was stored in it.
*/
void contextDestroyed( ContextImpl& context ) const;
/**
* Get minSuggestedThreads
*/
int getMinSuggestedThreads( void ) const;
/**
* Get duplicationFactor
*/
int getDuplicationFactor( int numberOfParticles ) const;
private:
// log file reference
FILE* _log;
// default stream factory
BrookStreamFactory _defaultStreamFactory;
// default stream width
static const int DefaultParticleStreamWidth = 32;
// particle streamwidth
int _particleStreamWidth;
// Brook runtime
std::string _runtime;
// min suggested threads
int _minSuggestedThreads;
/**
* Initialize kernel factory
*
*/
void _initializeKernelFactory( void );
/**
* Set & validate runtime
*
* @param runtime Brook runtime (cal/cpu)
*
* @throws exception if runtime is invalid
*/
void _setBrookRuntime( const std::string& runtime );
};
} // namespace OpenMM
#endif /*OPENMM_BROOKPLATFORM_H_*/
#ifndef OPENMM_BROOKSTREAMFACTORY_H_
#define OPENMM_BROOKSTREAMFACTORY_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 "openmm/StreamFactory.h"
#include "openmm/Platform.h"
namespace OpenMM {
/**
* This StreamFactory creates all streams for BrookPlatform.
*/
class OPENMM_EXPORT BrookStreamFactory : public StreamFactory {
public:
/**
* BrookStreamFactory constructor
*
*/
BrookStreamFactory( );
/**
* BrookStreamFactory destructor
*
*/
~BrookStreamFactory( );
// 'external' streams
static const std::string ParticlePositions;
static const std::string ParticleVelocities;
static const std::string ParticleForces;
/**
* Create StreamImpl
*
* @param name stream name
* @param size stream size
* @param type data type (float, float2, ...)
* @param platform platform reference
* @param context context (currently ignored)
*
* @return StreamImpl
*/
StreamImpl* createStreamImpl( std::string name, int size, Stream::DataType type, const Platform& platform, ContextImpl& context ) const;
/**
* Create StreamImpl
*
* @param name stream name
* @param size stream size
* @param type data type (float, float2, ...)
* @param platform platform reference
*
* @return StreamImpl
*/
StreamImpl* createStreamImpl( std::string name, int size, Stream::DataType type, const Platform& platform ) const;
/**
* Get particle stream width
*
* @return particle stream width
*
*
*/
int getDefaultParticleStreamWidth( void ) const;
/**
* Set particle stream width
*
* @param particleStreamWidth particle stream width
*
* @return DefaultReturnValue
*
* @throw OpenMMException if particleStreamWidth < 1
*
*/
int setDefaultParticleStreamWidth( int particleStreamWidth );
/**
* Get randomNumber stream width
*
* @return randomNumber stream width
*
*
*/
int getDefaultRandomNumberStreamWidth( void ) const;
/**
* Set randomNumber stream width
*
* @param randomNumberStreamWidth randomNumber stream width
*
* @return DefaultReturnValue
*
* @throw OpenMMException if randomNumberStreamWidth < 1
*
*/
int setDefaultRandomNumberStreamWidth( int randomNumberStreamWidth );
/**
* Get randomNumber stream size
*
* @return randomNumber stream size
*
*
*/
int getDefaultRandomNumberStreamSize( void ) const;
/**
* Set randomNumber stream size
*
* @param randomNumberStreamSize randomNumber stream size
*
* @return DefaultReturnValue
*
* @throw OpenMMException if randomNumberStreamSize < 1
*
*/
int setDefaultRandomNumberStreamSize( int randomNumberStreamSize );
/**
* Get default dangle value
*
* @return default dangle value
*
*/
double getDefaultDangleValue( void ) const;
/**
* Set default dangle value
*
* @param DefaultDangleValue default dangle value
*
* @return DefaultReturnValue
*
*/
int setDefaultDangleValue( double defaultDangleValue );
private:
static const int DefaultStreamParticleWidth = 32;
static const int DefaultStreamRandomNumberWidth = 1024;
static const int DefaultStreamRandomNumberSize = 1024*1024;
static const double DefaultDangleValue;
static const int DefaultReturnValue = 0;
static const int ErrorReturnValue = -1;
int _defaultParticleStreamWidth;
int _defaultStreamRandomNumberWidth;
int _defaultStreamRandomNumberSize;
double _defaultDangleValue;
};
} // namespace OpenMM
#endif /*OPENMM_BROOKSTREAMFACTORY_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) 2009 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Mike Houston *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include <sstream>
#include "BrookBondParameters.h"
#include "openmm/OpenMMException.h"
using namespace OpenMM;
using namespace std;
/**
* BrookBondParameters constructor
*
* @param bondName bond name
* @param numberOfParticlesInBond no. of particles in each bond
* @param numberOfParametersInBond no. of parameters in each bond
* @param numberOfBonds no. of bonds
* @param log optional log reference
*
*/
BrookBondParameters::BrookBondParameters( std::string bondName, int numberOfParticlesInBond,
int numberOfParametersInBond, int numberOfBonds, FILE* log = NULL ) :
_bondName( bondName ), _numberOfParticlesInBond( numberOfParticlesInBond ),
_numberOfParametersInBond( numberOfParametersInBond ), _numberOfBonds( numberOfBonds ), _log( log ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookBondParameters::BrookBondParameters";
// ---------------------------------------------------------------------------------------
// allocate memory for particle indices/parameters
_bondParameters.resize( numberOfBonds );
_particleIndices.resize( numberOfBonds );
}
/**
* BrookBondParameters destructor
*
*/
BrookBondParameters::~BrookBondParameters( ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookBondParameters::BrookBondParameters";
// ---------------------------------------------------------------------------------------
}
/**
* Get particle indices
*
* @return particle indices
*
*/
const std::vector<std::vector<int>>& BrookBondParameters::getParticleIndices( void ) const {
return _particleIndices;
}
/**
* Get bond parameters
*
* @return parameters
*
*/
const std::vector<std::vector<double>>& BrookBondParameters::getBondParameters( void ) const {
return _bondParameters;
}
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE* BrookBondParameters::getLog( void ) const {
return _log;
}
/**
* Get bond name
*
* @return bond name
*
*/
std::string BrookBondParameters::getBondName( void ) const {
return _bondName;
}
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int BrookBondParameters::setLog( FILE* log ){
_log = log;
return DefaultReturnValue;
}
/**
* Get number of bonds
*
* @return numberOfBonds
*
*/
int BrookBondParameters::getNumberOfBonds( void ) const {
return _numberOfBonds;
}
/**
* Get number of particles in bond
*
* @return numberOfParticlesInBond
*
*/
int BrookBondParameters::getNumberOfParticlesInBond( void ) const {
return _numberOfParticlesInBond;
}
/**
* Get number of parameters in bond
*
* @return numberOfParametersInBond
*
*/
int BrookBondParameters::getNumberOfParametersInBond( void ) const {
return _numberOfParametersInBond;
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param bondIndex bond index to be set
* @param particleIndices indices of particles (dimension=numberOfParticlesInBond)
* @param bondParameters bond parameters (dimension=numberOfParametersInBond)
*
* @return DefaultReturnValue
*
* @throw OpenMMException exeception if bond index is invalid
*
*/
int BrookBondParameters::setBond( int bondIndex, int* particleIndices, double* bondParameters ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookBondParameters::setBond";
FILE* log = getLog();
// ---------------------------------------------------------------------------------------
// validate bond index
if( bondIndex < 0 ){
std::stringstream message;
message << methodName << "BondIndex=" << bondIndex << " is < 0.";
throw OpenMMException( message.str() );
}
if( bondIndex >= getNumberOfBonds() ){
std::stringstream message;
message << methodName << "BondIndex=" << bondIndex << " is >= " << getNumberOfBonds() << ".";
throw OpenMMException( message.str() );
}
// load'em up
int numberOfParticlesInBond = getNumberOfParticlesInBond();
for( int ii = 0; ii < numberOfParticlesInBond; ii++ ){
_particleIndices[bondIndex].push_back( particleIndices[ii] );
}
int numberOfParametersInBond = getNumberOfParametersInBond();
for( int ii = 0; ii < numberOfParametersInBond; ii++ ){
//fprintf( stderr, "Param %s %d %e\n", getBondName().c_str(), ii, bondParameters[ii] );
_bondParameters[bondIndex].push_back( bondParameters[ii] );
}
// ---------------------------------------------------------------------------------------
return DefaultReturnValue;
}
/*
* Format line
*
* @param tab tab
* @param description description
* @param value value
*
* @return string containing contents
*
* */
std::string BrookBondParameters::_getLine( const std::string& tab,
const std::string& description,
const std::string& value ) const {
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookStreamInternal::_getLine";
static const unsigned int MAX_LINE_CHARS = 256;
char line[MAX_LINE_CHARS];
// ---------------------------------------------------------------------------------------
std::stringstream message;
memset( line, ' ', MAX_LINE_CHARS );
#ifdef _MSC_VER
(void) sprintf_s( line, MAX_LINE_CHARS, "%s %-40s %s", tab.c_str(), description.c_str(), value.c_str() );
#else
(void) sprintf( line, "%s %-40s %s", tab.c_str(), description.c_str(), value.c_str() );
#endif
message << std::string( line ) << std::endl;
return message.str();
}
/*
* Get contents of object
*
* @param level level of dump
*
* @return string containing contents
*
* */
std::string BrookBondParameters::getContentsString( int level ) const {
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookBondParameters::getContentsString";
static const unsigned int MAX_LINE_CHARS = 1024;
char value[MAX_LINE_CHARS];
static const char* Set = "Set";
static const char* NotSet = "Not set";
// ---------------------------------------------------------------------------------------
std::stringstream message;
std::string tab = " ";
#ifdef _MSC_VER
#define LOCAL_SPRINTF(a,b,c) sprintf_s( (a), MAX_LINE_CHARS, (b), (c) );
#define LOCAL_2_SPRINTF(a,b,c,d) sprintf_s( (a), MAX_LINE_CHARS, (b), (c), (d) );
#else
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );
#define LOCAL_2_SPRINTF(a,b,c,d) sprintf( (a), (b), (c), (d) );
#endif
(void) LOCAL_SPRINTF( value, "%s", getBondName().c_str() );
message << _getLine( tab, "Bond name:", value );
(void) LOCAL_SPRINTF( value, "%d", getNumberOfBonds() );
message << _getLine( tab, "Number of bonds:", value );
(void) LOCAL_SPRINTF( value, "%d", getNumberOfParticlesInBond() );
message << _getLine( tab, "Particles/bond:", value );
(void) LOCAL_SPRINTF( value, "%d", getNumberOfParametersInBond() );
message << _getLine( tab, "Parameters/bond:", value );
message << "Bonds:" << std::endl;
for( int ii = 0; ii < getNumberOfBonds(); ii++ ){
const static size_t descriptionSz = 1024;
char description[1024];
char buffer[1024];
(void) LOCAL_SPRINTF( description, "%6d [", ii );
#ifdef _MSC_VER
// particle indices
for( int jj = 0; jj < getNumberOfParticlesInBond(); jj++ ){
(void) LOCAL_SPRINTF( buffer, "%6d ", _particleIndices[ii][jj] );
(void) strcat_s( description, descriptionSz, buffer );
}
(void) strcat_s( description, descriptionSz, "] [" );
// parameters
for( int jj = 0; jj < getNumberOfParametersInBond(); jj++ ){
(void) LOCAL_SPRINTF( buffer, "%18.10e ", _bondParameters[ii][jj] );
(void) strcat_s( description, descriptionSz, buffer );
}
(void) strcat_s( description, descriptionSz, "]" );
#else
// particle indices
for( int jj = 0; jj < getNumberOfParticlesInBond(); jj++ ){
(void) LOCAL_SPRINTF( buffer, "%6d ", _particleIndices[ii][jj] );
(void) strcat( description, buffer );
}
(void) strcat( description, "] [" );
// parameters
for( int jj = 0; jj < getNumberOfParametersInBond(); jj++ ){
(void) LOCAL_SPRINTF( buffer, "%18.10e ", _bondParameters[ii][jj] );
(void) strcat( description, buffer );
}
(void) strcat( description, "]" );
#endif
message << _getLine( tab, "", description );
}
#undef LOCAL_SPRINTF
#undef LOCAL_2_SPRINTF
return message.str();
}
#ifndef OPENMM_BROOK_BOND_PARAMETERS_H_
#define OPENMM_BROOK_BOND_PARAMETERS_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) 2009 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Mike Houston *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include <vector>
namespace OpenMM {
/**
* Container for bond parameters
*/
class BrookBondParameters {
public:
// return values
static const int DefaultReturnValue = 0;
static const int ErrorReturnValue = -1;
/**
* BrookBondParameters constructor
*
* @param bondName bond name
* @param numberOfParticlesInBond no. of particles in each bond
* @param numberOfParametersInBond no. of parameters in each bond
* @param numberOfBonds no. of bonds
* @param log optional log reference
*
*/
BrookBondParameters( std::string bondName, int numberOfParticlesInBond, int numberOfParametersInBond, int numberOfBonds, FILE* log );
~BrookBondParameters();
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int setLog( FILE* log );
/*
* Get contents of object
*
* @param level of dump
*
* @return string containing contents
*
* */
std::string getContents( int level ) const;
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE* getLog( void ) const;
/**
* Set bond info
*
* @param bondIndex index of bond
* @param particleIndices array of particle indices
* @param bondParameters array of bond parameters
*
* @return DefaultReturnValue
*
* @throw OpenMMException exeception if bond index is invalid
*
*/
int setBond( int bondIndex, int* particleIndices, double* bondParameters );
/**
* Get bond name
*
* @return bond name
*
*/
std::string getBondName( void ) const;
/**
* Set bond name
*
* @param bondName bond name
*
* @return DefaultReturnValue
*
*/
//int setBondName( std::string bondName );
/**
* Get NumberOfParticlesInBond
*
* @return NumberOfParticlesInBond
*
*/
int getNumberOfParticlesInBond( void ) const;
/**
* Get NumberOfParametersInBond
*
* @return NumberOfParametersInBond
*
*/
int getNumberOfParametersInBond( void ) const;
/**
* Get NumberOfBonds
*
* @return NumberOfBonds
*
*/
int getNumberOfBonds( void ) const;
/**
* Get particle indices
*
* @return particle indices
*
*/
const std::vector<std::vector<int>>& getParticleIndices( void ) const;
/**
* Get parameters
*
* @return parameters
*
*/
const std::vector<std::vector<double>>& getBondParameters( void ) const;
/*
* Get contents of object
*
*
* @param level level of dump
*
* @return string containing contents
*
* */
std::string getContentsString( int level = 0 ) const;
private:
// log file reference
FILE* _log;
// bond name
std::string _bondName;
// number of bonds
int _numberOfBonds;
int _numberOfParticlesInBond;
int _numberOfParametersInBond;
// particle indices and parameters
std::vector<std::vector<int>> _particleIndices;
std::vector<std::vector<double>> _bondParameters;
/*
* Get contents of object
*
* @param tab tab
* @param description description
* @param value value
*
* @return string containing contents
*
* */
std::string _getLine( const std::string& tab, const std::string& description,
const std::string& value ) const;
};
} // namespace OpenMM
#endif /* OPENMM_BROOK_BOND_PARAMETERS_H_ */
This diff is collapsed.
#ifndef OPENMM_BROOK_BONDED_H_
#define OPENMM_BROOK_BONDED_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) 2009 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Mike Houston *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include <vector>
#include "BrookStreamImpl.h"
#include "BrookCommon.h"
#include "openmm/Context.h"
#include "BrookBondParameters.h"
namespace OpenMM {
/**
* Calculate Brook bonded forces
*/
class BrookBonded : public BrookCommon {
public:
/**
*
* BrookBonded constructor
*
*/
BrookBonded( );
/**
*
* BrookBonded desstructor
*
*/
~BrookBonded( );
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param numberOfParticles numberOfParticles
* @param harmonicBondBrookBondParameters force parameters (length, k) for each bond term
* @param harmonicAngleBrookBondParameters force parameters (angle, k) for each angle term
* @param periodicTorsionBrookBondParameters force parameters (k, phase, periodicity) for each periodic torsion term
* @param rbTorsionBrookBondParameters coefficients (in order of increasing powers) for each Ryckaert-Bellemans torsion term
* @param nonBonded14ForceParameters nonbonded 14 force parameters (charge, sigma, epsilon) for each particle
* @param particleStreamWidth stream width
* @param particleStreamSize stream size
*
* @return nonzero value if error
*
*/
int setup( int numberOfParticles,
BrookBondParameters* harmonicBondBrookBondParameters,
BrookBondParameters* harmonicAngleBrookBondParameters,
BrookBondParameters* periodicTorsionBrookBondParameters,
BrookBondParameters* rbTorsionBrookBondParameters,
BrookBondParameters* nonBonded14ForceParameters, int particleStreamWidth, int particleStreamSize );
/**
* Get inverse map stream width
*
* @return stream width
*
*/
int getInverseMapStreamWidth( void ) const;
/**
* 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 max stream count for specified index
*
* @param index index of force stream
*
* @return max stream count
*
*/
int getMaxInverseMapStreamCount( int index ) const;
/**
* Return Brook stream handle
*
* @return
*/
BrookFloatStreamInternal* getBrookParticleIndices( void ) const;
/**
* Get Coulomb factor
*
* @return Coulomb factor
*
*/
BrookOpenMMFloat getCoulombFactor( void ) const;
/**
* Get bonded particle indices stream
*
* @return particle indices stream
*
*/
BrookFloatStreamInternal* getParticleIndicesStream( void ) const;
/**
* Get bonded charge stream
*
* @return charge stream
*
*/
BrookFloatStreamInternal* getChargeStream( void ) const;
/**
* Get array of bonded parameter streams
*
* @return array of bonded parameter streams
*
*/
BrookFloatStreamInternal** getBondedParameterStreams( void );
/**
* Get array of force streams
*
* @return array
*
*/
BrookFloatStreamInternal** getBondedForceStreams( void );
/**
* Get array of inverse map streams
*
* @param index array index
*
* @return array inverse map streams
*
*/
BrookFloatStreamInternal** 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 getContentsString( int level = 0 ) const;
/**
* Compute forces
*
*/
void computeForces( BrookStreamImpl& positionStream, BrookStreamImpl& forceStream );
/**
* Return SetupCompleted flag
*
* @return SetupCompleted flag
*/
int isSetupCompleted( void ) const;
/**
* Set SetupCompleted flag
*
* @param SetupCompleted flag
*
* @return SetupCompleted flag
*/
int setupCompleted( int isSetupCompleted );
private:
static const int NumberOfParameterStreams = 5;
static const int NumberOfForceStreams = 4;
static const int MaxNumberOfInverseMaps = 9;
enum { StreamI, StreamJ, StreamK, StreamL, StreamMax };
int _setupCompleted;
// inverse map stream width
int _inverseMapStreamWidth;
// actual max number of inverse maps
int _maxNumberOfInverseMaps;
// scale factors for 1-4 ixn
BrookOpenMMFloat _coulombFactor;
// streams
BrookFloatStreamInternal* _particleIndicesStream;
BrookFloatStreamInternal* _bondedParameters[NumberOfParameterStreams];
BrookFloatStreamInternal* _bondedForceStreams[NumberOfForceStreams];
BrookFloatStreamInternal* _chargeStream;
BrookFloatStreamInternal* _inverseStreamMaps[NumberOfForceStreams][MaxNumberOfInverseMaps];
int _maxInverseMapStreamCount[NumberOfForceStreams];
int _inverseMapStreamCount[NumberOfForceStreams];
// helper methods in setup of parameters
void _flipQuartet( int ibonded, int *particles );
int _matchTorsion( int i, int j, int k, int l, int nbondeds, int *particles );
int _matchAngle( int i, int j, int k, int nbondeds, int *particles, int *flag );
int _matchBond( int i, int j, int nbondeds, int *particles, int *flag );
int _matchPair( int i, int j, int nbondeds, int *particles );
/**
* Setup Ryckaert-Bellemans parameters/particle indices
*
* @param nbondeds number of bonded entries
* @param particles array of particle indices
* @param params arrays of bond parameters
* @param rbTorsionIndices the four particles 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 _addRBTorsions( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& rbTorsionIndices,
const std::vector<std::vector<double> >& rbTorsionParameters );
/**
* Setup periodic torsion parameters/particle indices
*
* @param nbondeds number of bonded entries
* @param particles array of particle indices
* @param params arrays of bond parameters
* @param periodicTorsionIndices the four particles 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 _addPTorsions( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& periodicTorsionIndices,
const std::vector<std::vector<double> >& periodicTorsionParameters );
/**
* Setup angle bond parameters/particle indices
*
* @param nbondeds number of bonded entries
* @param particles array of particle indices
* @param params arrays of bond parameters
* @param angleIndices the angle bond particle indices
* @param angleParameters the angle parameters (angle in radians, force constant)
*
* @return nonzero value if error
*
*/
int _addAngles( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& angleIndices,
const std::vector<std::vector<double> >& angleParameters );
/**
* Setup harmonic bond parameters/particle indices
*
* @param nbondeds number of bonded entries
* @param particles array of particle indices
* @param params arrays of bond parameters
* @param bondIndices two harmonic bond particle indices
* @param bondParameters the force parameters (distance, k)
*
* @return nonzero value if error
*
*/
int _addBonds( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& bondIndices,
const std::vector<std::vector<double> >& bondParameters );
/**
* Setup LJ/Coulomb 1-4 parameters/particle indices
*
* @param nbondeds number of bonded entries
* @param particles array of particle indices
* @param params arrays of bond parameters
* @param charges array of charges
* @param bonded14Indices each element contains the indices of two particles 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 particle
*
* @return nonzero value if error
*
*/
int _addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* params[], BrookOpenMMFloat* charges,
const std::vector<std::vector<int> >& bonded14Indices, const std::vector<std::vector<double> >& nonbondedParameters );
/**
* Create and load inverse maps for bonded ixns
*
* @param nbondeds number of bonded entries
* @param nparticles number of particles
* @param particles arrays of particle indices (particles[numberOfBonds][4])
* @param platform BrookPlatform reference
* @param log log file reference (optional)
*
* @return nonzero value if error
*
*/
//int loadInvMaps( int nbondeds, int nparticles, int *particles, const BrookPlatform& platform );
int _loadInvMaps( int nbondeds, int nparticles, int *particles, int particleStreamWidth, int particleStreamSize );
/**
* 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;
/*
* Helper functions for building inverse maps for
* torsions, impropers and angles.
*
* For each particle, calculates the positions at which it's
* forces are to be picked up from and stores the position
* in the appropriate index.
*
* Input: number of torsions, the particle indices, and a flag indicating
* whether we're doing i(0), j(1), k(2) or l(3)
* Output: an array of counts per particle
* arrays of inversemaps
* nimaps - the number of invmaps actually used.
*
* @param posflag 0-niparticles-1
* @param niparticles 3 for angles, 4 for torsions, impropers
* @param nints number of interactions
* @param nparticles number of particles
* @param *particles gromacs interaction list
* @param nmaps maximum number of inverse maps
* @param counts[] output counts of how many places each particle occurs
* @param *invmaps[] output array of nmaps inverse maps
* @param *nimaps, output max number of inverse maps actually used
*
* @return DefaultReturnValue, unless error in which case exits w/ OpenMM exception
*
**/
int _gpuCalcInvMap( int posflag, int niparticles, int nints, int nparticles,
int *particles, int nmaps, int counts[], float4 *invmaps[], int *nimaps );
void _gpuPrintInvMaps( int nmaps, int nparticles, int counts[], float4 *invmap[], FILE* logFile );
/*
* We are still plagued by kernel call overheads. This is for a big fat
* merged inverse gather kernel:
* Since we have 32 bit floats, we have 23 bits of mantissa or the largest
* integer we can represent is 2^23. So it should be quite safe to add
* 100000 * n to the index where n is the stream in which we should do the
* lookup. This assumes that nints < 100000, preferably nints << 100000
* which should always be true
*
**/
int _gpuCalcInvMap_merged( int nints, int nparticles, int *particles, int nmaps, int counts[], float4 *invmaps[], int *nimaps );
/*
* Repacks the invmap streams for more efficient access in the
* merged inverse gather kernel
*
* buf should be nimaps * nparticles large.
*
**/
int _gpuRepackInvMap_merged( int nparticles, int nmaps, int *counts, float4 *invmaps[], float4 *buf );
};
} // namespace OpenMM
#endif /* OPENMM_BROOK_BONDED_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) 2009 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Mike Houston *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "openmm/OpenMMException.h"
#include "BrookStreamImpl.h"
#include "BrookCalcGBSAOBCForceKernel.h"
#include "kernels/kgbsa.h"
#include "kernels/kforce.h"
#include <cmath>
#include <limits>
#include <sstream>
using namespace OpenMM;
using namespace std;
/**
* BrookCalcGBSAOBCForceKernel constructor
*
* @param name kernel name
* @param platform platform
* @param OpenMMBrookInterface OpenMM-Brook interface
* @param System System reference
*
*/
BrookCalcGBSAOBCForceKernel::BrookCalcGBSAOBCForceKernel( std::string name, const Platform& platform, OpenMMBrookInterface& openMMBrookInterface, System& system ) :
CalcGBSAOBCForceKernel( name, platform ), _openMMBrookInterface( openMMBrookInterface ), _system( system ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcGBSAOBCForceKernel::BrookCalcGBSAOBCForceKernel";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
_numberOfParticles = 0;
_log = NULL;
const BrookPlatform& brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
if( brookPlatform.getLog() != NULL ){
setLog( brookPlatform.getLog() );
}
_openMMBrookInterface.setNumberOfParticles( system.getNumParticles() );
}
/**
* BrookCalcGBSAOBCForceKernel destructor
*
*/
BrookCalcGBSAOBCForceKernel::~BrookCalcGBSAOBCForceKernel( ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcGBSAOBCForceKernel::BrookCalcGBSAOBCForceKernel";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
}
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE* BrookCalcGBSAOBCForceKernel::getLog( void ) const {
return _log;
}
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int BrookCalcGBSAOBCForceKernel::setLog( FILE* log ){
_log = log;
return BrookCommon::DefaultReturnValue;
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param system system this kernel will be applied to
* @param force GBSAOBCForce this kernel will be used for
*
*/
void BrookCalcGBSAOBCForceKernel::initialize( const System& system, const GBSAOBCForce& force ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookCalcGBSAOBCForceKernel::initialize";
int printOn = 0;
FILE* log;
// ---------------------------------------------------------------------------------------
if( printOn && getLog() ){
log = getLog();
} else {
printOn = 0;
}
// ---------------------------------------------------------------------------------------
BrookGbsa& brookGbsa = _openMMBrookInterface.getBrookGbsa();
// get parameters from force object
// and initialize brookGbsa
_numberOfParticles = system.getNumParticles();
std::vector<std::vector<double> > particleParameters( _numberOfParticles );
for( int ii = 0; ii < _numberOfParticles; ii++ ){
double charge, radius, scalingFactor;
force.getParticleParameters( ii, charge, radius, scalingFactor );
particleParameters[ii].push_back( charge );
particleParameters[ii].push_back( radius );
particleParameters[ii].push_back( scalingFactor );
}
brookGbsa.setup( particleParameters, force.getSolventDielectric(), force.getSoluteDielectric(), getPlatform() );
brookGbsa.setIsActive( 1 );
_openMMBrookInterface.setTriggerForceKernel( this );
_openMMBrookInterface.setTriggerEnergyKernel( this );
if( printOn ){
std::string contents = brookGbsa.getContentsString( );
(void) fprintf( log, "%s brookGbsa::contents\n%s", methodName.c_str(), contents.c_str() );
(void) fflush( log );
}
// ---------------------------------------------------------------------------------------
}
/**
* Compute forces given particle coordinates
*
* @param context ContextImpl context
*
*/
void BrookCalcGBSAOBCForceKernel::executeForces( ContextImpl& context ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcGBSAOBCForceKernel::executeForces";
// ---------------------------------------------------------------------------------------
if( _openMMBrookInterface.getTriggerForceKernel() == this ){
_openMMBrookInterface.computeForces( context );
}
}
/**
* Execute the kernel to calculate the OBC energy
*
* @param context ContextImpl context
*
* @return energy
*
*/
double BrookCalcGBSAOBCForceKernel::executeEnergy( ContextImpl& context ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcGBSAOBCForceKernel::executeEnergy";
// ---------------------------------------------------------------------------------------
if( _openMMBrookInterface.getTriggerEnergyKernel() == this ){
return (double) _openMMBrookInterface.computeEnergy( context, _system );
} else {
return 0.0;
}
}
#ifndef OPENMM_BROOK_CALC_GBSAOBC_FORCE_KERNEL_H_
#define OPENMM_BROOK_CALC_GBSAOBC_FORCE_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) 2009 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Mike Houston *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "openmm/kernels.h"
#include "../../reference/src/SimTKUtilities/SimTKOpenMMRealType.h"
#include "BrookGbsa.h"
#include "OpenMMBrookInterface.h"
namespace OpenMM {
/**
* This kernel is invoked to calculate the OBC forces acting on the system.
*/
class BrookCalcGBSAOBCForceKernel : public CalcGBSAOBCForceKernel {
public:
/**
* BrookCalcGBSAOBCForceKernel constructor
*/
BrookCalcGBSAOBCForceKernel( std::string name, const Platform& platform, OpenMMBrookInterface& openMMBrookInterface, System& system );
/**
* BrookCalcGBSAOBCForceKernel destructor
*/
~BrookCalcGBSAOBCForceKernel();
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param system system this kernel will be applied to
* @param force GBSAOBCForce this kernel will be used for
*
*/
void initialize( const System& system, const GBSAOBCForce& force );
/**
* Execute the kernel to calculate the forces.
*
* @param positions particle coordiantes
* @param forces output forces
*
*/
void executeForces( ContextImpl& context );
/**
* Execute the kernel to calculate the energy.
*
* @param positions particle positions
*
* @return potential energy due to the NonbondedForce
* Currently always return 0.0 since energies not calculated on gpu
*
*/
double executeEnergy( ContextImpl& context );
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int setLog( FILE* log );
/*
* Get contents of object
*
* @param level of dump
*
* @return string containing contents
*
* */
std::string getContents( int level ) const;
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE* getLog( void ) const;
/**
* Get Brook GBSA reference
*
* @return Brook GBSA reference
*
*/
BrookGbsa& getBrookGbsa( void ) const;
private:
// log file reference
FILE* _log;
// number of particles
int _numberOfParticles;
// interface
OpenMMBrookInterface& _openMMBrookInterface;
// System reference
System& _system;
};
} // namespace OpenMM
#endif /* OPENMM_BROOK_CALC_GBSAOBC_FORCE_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) 2009 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Mike Houston *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "openmm/OpenMMException.h"
#include "BrookCalcHarmonicAngleForceKernel.h"
#include <sstream>
using namespace OpenMM;
using namespace std;
const std::string BrookCalcHarmonicAngleForceKernel::BondName = "HarmonicAngle";
/**
* BrookCalcHarmonicAngleForceKernel constructor
*
* @param name kernel name
* @param platform platform
* @param OpenMMBrookInterface OpenMM-Brook interface
* @param System System reference
*
*/
BrookCalcHarmonicAngleForceKernel::BrookCalcHarmonicAngleForceKernel( std::string name, const Platform& platform,
OpenMMBrookInterface& openMMBrookInterface, System& system ) :
CalcHarmonicAngleForceKernel( name, platform ), _openMMBrookInterface( openMMBrookInterface ), _system( system ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcHarmonicAngleForceKernel::BrookCalcHarmonicAngleForceKernel";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
_brookBondParameters = NULL;
_log = NULL;
const BrookPlatform& brookPlatform = dynamic_cast<const BrookPlatform&> (platform);
if( brookPlatform.getLog() != NULL ){
setLog( brookPlatform.getLog() );
}
_openMMBrookInterface.setNumberOfParticles( system.getNumParticles() );
}
/**
* BrookCalcHarmonicAngleForceKernel destructor
*
*/
BrookCalcHarmonicAngleForceKernel::~BrookCalcHarmonicAngleForceKernel( ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcHarmonicAngleForceKernel::BrookCalcHarmonicAngleForceKernel";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
delete _brookBondParameters;
}
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE* BrookCalcHarmonicAngleForceKernel::getLog( void ) const {
return _log;
}
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int BrookCalcHarmonicAngleForceKernel::setLog( FILE* log ){
_log = log;
return BrookCommon::DefaultReturnValue;
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param system System reference
* @param force HarmonicAngleForce reference
*
*/
void BrookCalcHarmonicAngleForceKernel::initialize( const System& system, const HarmonicAngleForce& force ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "BrookCalcHarmonicAngleForceKernel::initialize";
// ---------------------------------------------------------------------------------------
FILE* log = getLog();
// ---------------------------------------------------------------------------------------
// create _brookBondParameters object containing particle indices/parameters
int numberOfBonds = force.getNumAngles();
if( _brookBondParameters ){
delete _brookBondParameters;
}
_brookBondParameters = new BrookBondParameters( BrookCalcHarmonicAngleForceKernel::BondName, NumberOfParticlesInBond, NumberOfParametersInBond, numberOfBonds, getLog() );
for( int ii = 0; ii < numberOfBonds; ii++ ){
int particle1, particle2, particle3;
double angle, k;
int particles[NumberOfParticlesInBond];
double parameters[NumberOfParametersInBond];
force.getAngleParameters( ii, particle1, particle2, particle3, angle, k );
particles[0] = particle1;
particles[1] = particle2;
particles[2] = particle3;
parameters[0] = angle;
parameters[1] = k;
_brookBondParameters->setBond( ii, particles, parameters );
}
_openMMBrookInterface.setHarmonicAngleForceParameters( _brookBondParameters );
_openMMBrookInterface.setTriggerForceKernel( this );
_openMMBrookInterface.setTriggerEnergyKernel( this );
if( log ){
std::string contents = _brookBondParameters->getContentsString( );
(void) fprintf( log, "%s brookGbsa::contents\n%s", methodName.c_str(), contents.c_str() );
(void) fflush( log );
}
// ---------------------------------------------------------------------------------------
}
/**
* Compute forces given particle coordinates
*
* @param context ContextImpl context
*
*/
void BrookCalcHarmonicAngleForceKernel::executeForces( ContextImpl& context ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcHarmonicAngleForceKernel::executeForces";
// ---------------------------------------------------------------------------------------
if( _openMMBrookInterface.getTriggerForceKernel() == this ){
_openMMBrookInterface.computeForces( context );
}
return;
// ---------------------------------------------------------------------------------------
}
/**
* Execute the kernel to calculate the energy
*
* @param context ContextImpl context
*
* @return potential energy
*
*/
double BrookCalcHarmonicAngleForceKernel::executeEnergy( ContextImpl& context ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcHarmonicAngleForceKernel::executeEnergy";
// ---------------------------------------------------------------------------------------
if( _openMMBrookInterface.getTriggerEnergyKernel() == this ){
return (double) _openMMBrookInterface.computeEnergy( context, _system );
} else {
return 0.0;
}
}
This diff is collapsed.
This diff is collapsed.
#ifndef OPENMM_BROOK_CALC_KINETIC_ENERGY_KERNEL_H_
#define OPENMM_BROOK_CALC_KINETIC_ENERGY_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) 2009 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Mike Houston *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "openmm/kernels.h"
#include "BrookFloatStreamInternal.h"
#include "OpenMMBrookInterface.h"
#include "BrookVelocityCenterOfMassRemoval.h"
namespace OpenMM {
/**
* Brook class for calculating kinetic energy
*/
class BrookCalcKineticEnergyKernel : public CalcKineticEnergyKernel {
public:
/**
* BrookCalcKineticEnergyKernel constructor
*
* @param name name of the stream to create
* @param platform platform
* @param OpenMMBrookInterface OpenMM-Brook interface
* @param System System reference
*/
BrookCalcKineticEnergyKernel( std::string name, const Platform& platform, OpenMMBrookInterface& openMMBrookInterface, System& system );
/**
* BrookCalcKineticEnergyKernel destructor
*
*/
~BrookCalcKineticEnergyKernel();
/**
* Initialize the kernel
*
* @param system System reference
*
*/
void initialize( const System& system );
/**
* Execute the kernel.
*
* @param context ContextImpl reference
*
*/
double execute( ContextImpl& context );
private:
int _numberOfParticles;
// masses
BrookOpenMMFloat* _masses;
// interface
OpenMMBrookInterface& _openMMBrookInterface;
// System reference
System& _system;
BrookVelocityCenterOfMassRemoval* _brookVelocityCenterOfMassRemoval;
};
} // namespace OpenMM
#endif /* OPENMM_BROOK_CALC_KINETIC_ENERGY_KERNEL_H_ */
This diff is collapsed.
This diff is collapsed.
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