Commit 8f017de1 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Modified softcore equation to conform w/ Shirts and Pande, JCP 122:134508, 2005.

Removed cruft from Cmake file
Modified the way platform is specified in TstFreeEnergyCudaUsingParameterFile.cpp
parent 19c403f2
#---------------------------------------------------
# OpenMM FreeEnergy Plugin
#
# Creates OpenMM FreeEnergy plugin library, base name=OpenMM.
# Creates OpenMM FreeEnergy plugin library, base name=OpenMMFreeEnergy.
# Default libraries are shared & optimized. Variants
# are created for static (_static) and debug (_d).
#
# Windows:
# OpenMM[_d].dll
# OpenMM[_d].lib
# OpenMM_static[_d].lib
# OpenMMFreeEnergy[_d].dll
# OpenMMFreeEnergy[_d].lib
# OpenMMFreeEnergy_static[_d].lib
# Unix:
# libOpenMM[_d].so
# libOpenMM_static[_d].a
# libOpenMMFreeEnergy[_d].so
# libOpenMMFreeEnergy_static[_d].a
#----------------------------------------------------
# On Linux it appears that cmake 2.4 does not work with Cuda cmake rules
#CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Does someone at Kitware actually believe that this policy crap
# might actually make cmake LESS brittle?
# (Probably the same genius who came up the endif(allthesamecrap) syntax)
# Older cmake versions do not have cmake_policy command
# Cmake 2.4.5, the default cmake on red hat linux, has the
# cmake_policy command, but it does not work
# "if(POLICY ..." does not work with cmake 2.4.[56] on red hat
# (cmake 2.4.7 is OK)
#if(COMMAND cmake_policy)
# if(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5)
# cmake_policy(SET CMP0003 NEW)
# cmake_policy(SET CMP0005 NEW)
# endif(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5)
# if(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2)
# cmake_policy(SET CMP0011 NEW)
# endif(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2)
#endif(COMMAND cmake_policy)
# Don't create a new project name if this is part of a mega-build from the
# parent directory
#IF( NOT PROJECT_NAME )
# PROJECT (OpenMM)
#ENDIF( NOT PROJECT_NAME )
# Where to install
#IF(${CMAKE_C_COMPILER} MATCHES "gcc")
# IF(NOT OPENMM_INSTALL_PREFIX)
# SET(OPENMM_INSTALL_PREFIX "/usr/local/openmm" CACHE PATH "Where to install OpenMM")
# ENDIF(NOT OPENMM_INSTALL_PREFIX)
#ELSE(${CMAKE_C_COMPILER} MATCHES "gcc")
# IF(NOT OPENMM_INSTALL_PREFIX)
# SET(OPENMM_INSTALL_PREFIX "$ENV{ProgramFiles}/OpenMM" CACHE PATH "Where to install OpenMM")
# ENDIF(NOT OPENMM_INSTALL_PREFIX)
#ENDIF(${CMAKE_C_COMPILER} MATCHES "gcc")
#MARK_AS_ADVANCED(OPENMM_INSTALL_PREFIX)
# It seems that on linux and mac, everything is trying to be installed in /usr/local/openmm
# But if every install target is prefixed with /openmm/, on Windows the install files
# end up in C:/Program Files/OpenMM/openmm/ which is ugly.
# Better to set CMAKE_INSTALL_PREFIX to /usr/local/openmm and leave /openmm/ off the
# install target names. Plus, the user now has the opportunity to install into /usr/local/
# if she so chooses. --cmb
#IF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
# SET(CMAKE_INSTALL_PREFIX ${OPENMM_INSTALL_PREFIX} CACHE PATH "Where to install OpenMM" FORCE)
#ENDIF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
#INCLUDE(Dart)
SET(LOG TRUE)
......@@ -89,43 +40,6 @@ ENDIF(LOG)
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET(OPENMM_FREE_ENERGY_PLUGIN_SOURCE_SUBDIRS . openmmapi platforms/reference)
# The build system will set ARCH64 for 64 bit builds, which require
# use of the lib64/ library directories rather than lib/.
#SET( ARCH64 OFF CACHE BOOL "ON for 64bit builds, OFF for 32bit builds")
#MARK_AS_ADVANCED( ARCH64 )
#IF (ARCH64)
# SET(LIB64 64)
#ELSE (ARCH64)
# SET(LIB64) # nothing
#ENDIF (ARCH64)
#IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# SET( LIB64 64 )
#ELSE( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# SET( LIB64 )
#ENDIF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# Build 32 bit binaries, since CUDA doesn't currently work with 64 bit
#IF (APPLE)
# SET (CMAKE_CXX_FLAGS "-arch i386")
# SET (CMAKE_C_FLAGS "-arch i386")
#ENDIF (APPLE)
#
#IF(UNIX AND NOT CMAKE_BUILD_TYPE)
# SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Debug or Release build" FORCE)
#ENDIF (UNIX AND NOT CMAKE_BUILD_TYPE)
#
#IF (NOT CMAKE_CXX_FLAGS_DEBUG)
# SET(CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING "To use when CMAKE_BUILD_TYPE=Debug" FORCE)
#ENDIF (NOT CMAKE_CXX_FLAGS_DEBUG)
#
#IF (NOT CMAKE_CXX_FLAGS_RELEASE)
# SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING
# "To use when CMAKE_BUILD_TYPE=Release" FORCE)
#ENDIF (NOT CMAKE_CXX_FLAGS_RELEASE)
# 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.
......@@ -134,107 +48,20 @@ SET(OPENMM_FREE_ENERGY_MAJOR_VERSION 1)
SET(OPENMM_FREE_ENERGY_MINOR_VERSION 0)
SET(OPENMM_FREE_ENERGY_BUILD_VERSION 0)
#SET(OPENMM_COPYRIGHT_YEARS "2009")
# underbar separated list of dotted authors, no spaces or commas
#SET(OPENMM_AUTHORS "Peter.Eastman")
# Get the subversion revision number if we can
# It's possible that WIN32 installs use svnversion through cygwin
# so we'll try for both svnversion.exe and svnversion. Note that
# this will result in warnings if all you have is Tortoise without
# Cygwin, and your "about" string will say "unknown" rather than
# providing the SVN version of the source.
#FIND_PROGRAM (SVNVERSION_EXE svnversion.exe
# PATHS "C:/cygwin/bin"
#)
#IF (SVNVERSION_EXE)
# EXEC_PROGRAM (${SVNVERSION_EXE}
# ARGS \"${CMAKE_CURRENT_SOURCE_DIR}\"
# OUTPUT_VARIABLE OPENMM_SVN_REVISION )
#ELSE (SVNVERSION_EXE)
# FIND_PROGRAM (SVNVERSION svnversion)
# IF (SVNVERSION)
# EXEC_PROGRAM (${SVNVERSION}
# ARGS "${CMAKE_CURRENT_SOURCE_DIR}"
# OUTPUT_VARIABLE OPENMM_SVN_REVISION)
# ELSE (SVNVERSION)
# MESSAGE (STATUS
# "Could not find 'svnversion' executable; 'about' will be wrong. (Cygwin provides one on Windows.)"
# )
# SET (OPENMM_SVN_REVISION unknown)
# ENDIF (SVNVERSION)
#ENDIF (SVNVERSION_EXE)
# Remove colon from build version, for easier placement in directory names
#STRING(REPLACE ":" "_" OPENMM_SVN_REVISION ${OPENMM_SVN_REVISION})
ADD_DEFINITIONS(-DOPENMM_FREE_ENERGY_LIBRARY_NAME=${OPENMM_FREE_ENERGY_LIBRARY_NAME}
-DOPENMM_FREE_ENERGY_MAJOR_VERSION=${OPENMM_FREE_ENERGY_MAJOR_VERSION}
-DOPENMM_FREE_ENERGY_MINOR_VERSION=${OPENMM_FREE_ENERGY_MINOR_VERSION}
-DINCLUDE_FREE_ENERGY_PLUGIN
-DOPENMM_FREE_ENERGY_BUILD_VERSION=${OPENMM_FREE_ENERGY_BUILD_VERSION})
# CMake quotes automatically when building Visual Studio projects but we need
# to add them ourselves for Linux or Cygwin. Two cases to avoid duplicate quotes
# in Visual Studio which end up in the binary.
#
#IF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
# SET(NEED_QUOTES FALSE)
#ELSE (${CMAKE_GENERATOR} MATCHES "Visual Studio")
# SET(NEED_QUOTES TRUE)
#ENDIF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
##TODO: doesn't work without quotes in nightly build
#SET(NEED_QUOTES TRUE)
#IF(NEED_QUOTES)
# ADD_DEFINITIONS(-DOPENMM_SVN_REVISION="${OPENMM_SVN_REVISION}"
# -DOPENMM_COPYRIGHT_YEARS="${OPENMM_COPYRIGHT_YEARS}"
# -DOPENMM_AUTHORS="${OPENMM_AUTHORS}")
#ELSE(NEED_QUOTES)
# ADD_DEFINITIONS(-DOPENMM_SVN_REVISION=${OPENMM_SVN_REVISION}
# -DOPENMM_COPYRIGHT_YEARS=${OPENMM_COPYRIGHT_YEARS}
# -DOPENMM_AUTHORS=${OPENMM_AUTHORS})
#ENDIF(NEED_QUOTES)
# -DOPENMM_TYPE has to be defined in the target subdirectories.
# -Dsimbody_EXPORTS defined automatically when Windows DLL build is being done.
# Report the version number to the CMake UI
SET(OPENMM_VERSION
"${OPENMM_MAJOR_VERSION}.${OPENMM_MINOR_VERSION}.${OPENMM_BUILD_VERSION}"
CACHE STRING "This is the version of OpenMM FreeEnergy which will be built." FORCE)
SET(SHARED_FREE_ENERGY_TARGET ${OPENMM_FREE_ENERGY_LIBRARY_NAME})
SET(STATIC_FREE_ENERGY_TARGET ${OPENMM_FREE_ENERGY_LIBRARY_NAME}_static)
## If no one says otherwise, change the executable path to drop into the same binary
## location as the DLLs so that the test cases will use the just-build DLLs.
#IF(NOT EXECUTABLE_OUTPUT_PATH)
# SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}
# CACHE INTERNAL "Single output directory for building all executables.")
#ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
#IF(NOT LIBRARY_OUTPUT_PATH)
# SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}
# CACHE INTERNAL "Single output directory for building all libraries.")
#ENDIF(NOT LIBRARY_OUTPUT_PATH)
#SET(${PROJECT_NAME}_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
#SET(${PROJECT_NAME}_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
# 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_FREE_ENERGY_TARGET ${SHARED_FREE_ENERGY_TARGET}_d)
SET(STATIC_FREE_ENERGY_TARGET ${STATIC_FREE_ENERGY_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_FREE_ENERGY_INCLUDE_DIRS) # start empty
......
......@@ -37,8 +37,7 @@ __device__ float getSoftCoreLJ( float r2, float sig, float eps, float lambdaI,
float r = sqrt(r2);
float lambda = lambdaI < lambdaJ ? lambdaI : lambdaJ;
float lambda2 = lambda*lambda;
eps *= lambda2*lambda2;
eps *= lambda;
// (r/sig)
......
......@@ -3662,56 +3662,6 @@ static int _printIntegratorInfo( Integrator* integrator, FILE* log ){
return DefaultReturnValue;
}
/**---------------------------------------------------------------------------------------
Register forces associated w/ Reference free energy platform
@param referencePlatform reference platform
--------------------------------------------------------------------------------------- */
static void registerFreeEnergyMethodsReferencePlatform( ReferencePlatform& referencePlatform ){
// ---------------------------------------------------------------------------------------
//static const char* methodName = "registerFreeEnergyMethodsReferencePlatform: ";
// ---------------------------------------------------------------------------------------
#ifdef INCLUDE_FREE_ENERGY_PLUGIN
ReferenceFreeEnergyKernelFactory* factory = new ReferenceFreeEnergyKernelFactory();
referencePlatform.registerKernelFactory(CalcNonbondedSoftcoreForceKernel::Name(), factory);
referencePlatform.registerKernelFactory(CalcGBVISoftcoreForceKernel::Name(), factory);
referencePlatform.registerKernelFactory(CalcGBSAOBCSoftcoreForceKernel::Name(), factory);
#endif
}
/**---------------------------------------------------------------------------------------
Register forces associated w/ Cuda free energy platform
@param cudaPlatform cuda platform
--------------------------------------------------------------------------------------- */
static void registerFreeEnergyMethodsCudaPlatform( CudaPlatform& cudaPlatform ){
// ---------------------------------------------------------------------------------------
//static const char* methodName = "registerFreeEnergyMethodsCudaPlatform: ";
// ---------------------------------------------------------------------------------------
#ifdef INCLUDE_FREE_ENERGY_PLUGIN
CudaFreeEnergyKernelFactory* factory = new CudaFreeEnergyKernelFactory();
cudaPlatform.registerKernelFactory(CalcNonbondedSoftcoreForceKernel::Name(), factory);
cudaPlatform.registerKernelFactory(CalcGBVISoftcoreForceKernel::Name(), factory);
cudaPlatform.registerKernelFactory(CalcGBSAOBCSoftcoreForceKernel::Name(), factory);
#endif
}
/**---------------------------------------------------------------------------------------
Set the velocities/positions of context2 to those of context1
......@@ -3769,25 +3719,12 @@ Context* _getContext( System* system, Context* inputContext, Integrator* inputIn
Context* context;
ReferencePlatform referencePlatform;
registerFreeEnergyMethodsReferencePlatform( referencePlatform );
CudaPlatform gpuPlatform;
registerFreeEnergyMethodsCudaPlatform( gpuPlatform );
if( platformName.compare( "ReferencePlatform" ) == 0 ){
context = new Context( *system, *inputIntegrator, referencePlatform );
context = new Context( *system, *inputIntegrator, Platform::getPlatform("Reference") );
} else {
gpuPlatform.setPropertyDefaultValue( "CudaDevice", deviceId );
context = new Context( *system, *inputIntegrator, gpuPlatform );
if( log ){
(void) fprintf( log, "OpenMM Platform: %s\n", context->getPlatform().getName().c_str() ); (void) fflush( log );
const vector<string>& properties = gpuPlatform.getPropertyNames();
for (unsigned int i = 0; i < properties.size(); i++) {
fprintf( log, "%s: %s\n", properties[i].c_str(), gpuPlatform.getPropertyValue(*context, properties[i]).c_str());
}
context = new Context( *system, *inputIntegrator, Platform::getPlatform("Cuda") );
}
}
if( log ){
(void) fprintf( log, "%s Using Platform: %s device=%s\n", idString.c_str(), context->getPlatform().getName().c_str(), deviceId.c_str() );
(void) fflush( log );
......@@ -5030,11 +4967,8 @@ void testReferenceCudaForces( std::string parameterFileName, MapStringInt& force
(void) fflush( log );
}
ReferencePlatform referencePlatform;
registerFreeEnergyMethodsReferencePlatform( referencePlatform );
CudaPlatform cudaPlatform;
registerFreeEnergyMethodsCudaPlatform( cudaPlatform );
Platform& referencePlatform = Platform::getPlatform("Reference");
Platform& cudaPlatform = Platform::getPlatform("Cuda");;
double parameterKineticEnergy, parameterPotentialEnergy;
......@@ -5627,14 +5561,12 @@ void testEnergyForcesConsistent( std::string parameterFileName, MapStringInt& fo
if( platformInclude == 1 ){
CudaPlatform cudaPlatform;
if( log ){
(void) fprintf( log, "%s Testing cuda platform\n", methodName.c_str() );
(void) fflush( log );
}
registerFreeEnergyMethodsCudaPlatform( cudaPlatform );
Platform& cudaPlatform = Platform::getPlatform( "Cuda");;
Context* cudaContext = testSetup( parameterFileName, forceMap, cudaPlatform,
parameterForces2, &parameterKineticEnergy, &parameterPotentialEnergy,
......@@ -5644,8 +5576,7 @@ void testEnergyForcesConsistent( std::string parameterFileName, MapStringInt& fo
} else {
ReferencePlatform referencePlatform;
registerFreeEnergyMethodsReferencePlatform( referencePlatform );
Platform& referencePlatform = Platform::getPlatform( "Reference");
if( log ){
(void) fprintf( log, "%s Testing reference platform\n", methodName.c_str() );
......@@ -5683,9 +5614,7 @@ void testEnergyConservation( std::string parameterFileName, MapStringInt& forceM
(void) fflush( log );
}
//CudaPlatform cudaPlatform;
ReferencePlatform referencePlatform;
registerFreeEnergyMethodsReferencePlatform( referencePlatform );
Platform& referencePlatform = Platform::getPlatform( "Reference");
double parameterKineticEnergy, parameterPotentialEnergy;
......@@ -5854,6 +5783,7 @@ int main( int numberOfArguments, char* argv[] ){
}
std::string parameterFileName = defaultParameterFileName;
std::string pluginDirectoryName = Platform::getDefaultPluginsDirectory();
MapStringInt forceMap;
initializeForceMap( forceMap, 0 );
int logFileNameIndex = -1;
......@@ -5970,6 +5900,7 @@ int main( int numberOfArguments, char* argv[] ){
(void) fprintf( log, "no summary file\n" );
}
(void) fprintf( log, "pluginDirectoryName %s\n", pluginDirectoryName.c_str() );
(void) fprintf( log, "checkEnergyForceConsistent %d\n", checkEnergyForceConsistent );
(void) fprintf( log, "checkEnergyConservation %d\n", checkEnergyConservation );
(void) fprintf( log, "checkInputForces %d\n", checkInputForces );
......@@ -5985,6 +5916,8 @@ int main( int numberOfArguments, char* argv[] ){
(void) fflush( log );
}
Platform::loadPluginsFromDirectory(pluginDirectoryName);
// check forces
if( checkForces ){
......
......@@ -966,8 +966,7 @@ calculateOneLJIxn( one/r, sig, eps, &dEdROrig, &E_Orig );
// soft-core LJ energy = lambda*4*eps*[ 1/{alphaLJ*(1-lambda) + (r/sig)**6}**2 - 1/{alphaLJ*(1-lambda) + (r/sig)**6} ]
eps *= POW( lambda, four );
eps *= lambda;
RealOpenMM sig2 = r/sig;
sig2 *= sig2;
RealOpenMM sig6 = sig2*sig2*sig2;
......
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