"vscode:/vscode.git/clone" did not exist on "36e904d032e52e0feceae5a97181dd6aa1df8df0"
Commit 19d2885a authored by Lee-Ping's avatar Lee-Ping
Browse files

Merge github.com:SimTk/openmm

parents 99ef4344 57a6768e
This diff is collapsed.
This diff is collapsed.
...@@ -33,7 +33,9 @@ FOREACH(EX_ROOT ${CPP_EXAMPLES}) ...@@ -33,7 +33,9 @@ FOREACH(EX_ROOT ${CPP_EXAMPLES})
ADD_EXECUTABLE(${EX_ROOT} ${EX_ROOT}.cpp) ADD_EXECUTABLE(${EX_ROOT} ${EX_ROOT}.cpp)
SET_TARGET_PROPERTIES(${EX_ROOT} SET_TARGET_PROPERTIES(${EX_ROOT}
PROPERTIES PROPERTIES
PROJECT_LABEL "Example - ${EX_ROOT}") PROJECT_LABEL "Example - ${EX_ROOT}"
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}"
COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(${EX_ROOT} ${SHARED_TARGET}) TARGET_LINK_LIBRARIES(${EX_ROOT} ${SHARED_TARGET})
ENDIF (BUILD_TESTING_SHARED) ENDIF (BUILD_TESTING_SHARED)
...@@ -43,8 +45,9 @@ FOREACH(EX_ROOT ${CPP_EXAMPLES}) ...@@ -43,8 +45,9 @@ FOREACH(EX_ROOT ${CPP_EXAMPLES})
ADD_EXECUTABLE(${EX_STATIC} ${EX_ROOT}.cpp) ADD_EXECUTABLE(${EX_STATIC} ${EX_ROOT}.cpp)
SET_TARGET_PROPERTIES(${EX_STATIC} SET_TARGET_PROPERTIES(${EX_STATIC}
PROPERTIES PROPERTIES
COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES" PROJECT_LABEL "Example - ${EX_STATIC}"
PROJECT_LABEL "Example - ${EX_STATIC}") LINK_FLAGS "${EXTRA_COMPILE_FLAGS}"
COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_USE_STATIC_LIBRARIES")
TARGET_LINK_LIBRARIES(${EX_STATIC} ${STATIC_TARGET}) TARGET_LINK_LIBRARIES(${EX_STATIC} ${STATIC_TARGET})
ENDIF (BUILD_TESTING_STATIC) ENDIF (BUILD_TESTING_STATIC)
...@@ -64,7 +67,9 @@ IF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS) ...@@ -64,7 +67,9 @@ IF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS)
ADD_EXECUTABLE(${EX_ROOT} ${EX_ROOT}.c Empty.cpp) ADD_EXECUTABLE(${EX_ROOT} ${EX_ROOT}.c Empty.cpp)
SET_TARGET_PROPERTIES(${EX_ROOT} SET_TARGET_PROPERTIES(${EX_ROOT}
PROPERTIES PROPERTIES
PROJECT_LABEL "Example C - ${EX_ROOT}") PROJECT_LABEL "Example C - ${EX_ROOT}"
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}"
COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(${EX_ROOT} ${SHARED_TARGET}) TARGET_LINK_LIBRARIES(${EX_ROOT} ${SHARED_TARGET})
ADD_DEPENDENCIES(${EX_ROOT} ApiWrappers) ADD_DEPENDENCIES(${EX_ROOT} ApiWrappers)
ENDIF (BUILD_TESTING_SHARED) ENDIF (BUILD_TESTING_SHARED)
...@@ -77,8 +82,9 @@ IF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS) ...@@ -77,8 +82,9 @@ IF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS)
ADD_EXECUTABLE(${EX_STATIC} ${EX_ROOT}.c Empty.cpp) ADD_EXECUTABLE(${EX_STATIC} ${EX_ROOT}.c Empty.cpp)
SET_TARGET_PROPERTIES(${EX_STATIC} SET_TARGET_PROPERTIES(${EX_STATIC}
PROPERTIES PROPERTIES
COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES" PROJECT_LABEL "Example C - ${EX_STATIC}"
PROJECT_LABEL "Example C - ${EX_STATIC}") LINK_FLAGS "${EXTRA_COMPILE_FLAGS}"
COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_USE_STATIC_LIBRARIES")
TARGET_LINK_LIBRARIES(${EX_STATIC} ${STATIC_TARGET}) TARGET_LINK_LIBRARIES(${EX_STATIC} ${STATIC_TARGET})
ADD_DEPENDENCIES(${EX_STATIC} ApiWrappers) ADD_DEPENDENCIES(${EX_STATIC} ApiWrappers)
ENDIF (BUILD_TESTING_STATIC) ENDIF (BUILD_TESTING_STATIC)
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
! other visualization tool to produce an animation of the resulting trajectory. ! other visualization tool to produce an animation of the resulting trajectory.
! ----------------------------------------------------------------------------- ! -----------------------------------------------------------------------------
INCLUDE 'OpenMMFortranModule.f90'
PROGRAM HelloArgon PROGRAM HelloArgon
use OpenMM; implicit none use OpenMM; implicit none
type(OpenMM_System) system type(OpenMM_System) system
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
! interface module. ! interface module.
! ------------------------------------------------------------------------------ ! ------------------------------------------------------------------------------
INCLUDE 'OpenMMFortranModule.f90'
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! ATOM, FORCE FIELD, AND SIMULATION PARAMETERS ! ATOM, FORCE FIELD, AND SIMULATION PARAMETERS
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
......
...@@ -56,11 +56,11 @@ HelloSodiumChlorideInC: HelloSodiumChlorideInC.c ...@@ -56,11 +56,11 @@ HelloSodiumChlorideInC: HelloSodiumChlorideInC.c
HelloArgonInFortran: HelloArgonInFortran.f90 openmm.mod HelloArgonInFortran: HelloArgonInFortran.f90 openmm.mod
gfortran $(FFLAGS) HelloArgonInFortran.f90 \ gfortran $(FFLAGS) HelloArgonInFortran.f90 \
-L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloArgonInFortran -I$(INCLUDE_DIR) -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloArgonInFortran
HelloSodiumChlorideInFortran: HelloSodiumChlorideInFortran.f90 openmm.mod HelloSodiumChlorideInFortran: HelloSodiumChlorideInFortran.f90 openmm.mod
gfortran $(FFLAGS) HelloSodiumChlorideInFortran.f90 \ gfortran $(FFLAGS) HelloSodiumChlorideInFortran.f90 \
-L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloSodiumChlorideInFortran -I$(INCLUDE_DIR) -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloSodiumChlorideInFortran
# Build Fortran 95 Module file # Build Fortran 95 Module file
......
from __future__ import print_function
import simtk.openmm.app as app
import simtk.openmm as mm
import simtk.unit as unit
import sys
from datetime import datetime
from optparse import OptionParser
def timeIntegration(context, steps):
"""Integrate a Context for a specified number of steps, then return how many seconds it took."""
context.getIntegrator().step(5) # Make sure everything is fully initialized
context.getState(getEnergy=True)
start = datetime.now()
context.getIntegrator().step(steps)
context.getState(getEnergy=True)
end = datetime.now()
elapsed = end -start
return elapsed.seconds + elapsed.microseconds*1e-6
def runOneTest(testName, options):
"""Perform a single benchmarking simulation."""
explicit = (testName in ('rf', 'pme', 'amoebapme'))
amoeba = (testName in ('amoebagk', 'amoebapme'))
hydrogenMass = None
print()
if amoeba:
print('Test: %s (epsilon=%g)' % (testName, options.epsilon))
elif testName == 'pme':
print('Test: pme (cutoff=%g)' % options.cutoff)
else:
print('Test: %s' % testName)
platform = mm.Platform.getPlatformByName(options.platform)
# Create the System.
if amoeba:
constraints = None
epsilon = float(options.epsilon)
if epsilon == 0:
polarization = 'direct'
else:
polarization = 'mutual'
if explicit:
ff = app.ForceField('amoeba2009.xml')
pdb = app.PDBFile('5dfr_solv-cube_equil.pdb')
cutoff = 0.7*unit.nanometers
vdwCutoff = 0.9*unit.nanometers
system = ff.createSystem(pdb.topology, nonbondedMethod=app.PME, nonbondedCutoff=cutoff, vdwCutoff=vdwCutoff, constraints=constraints, ewaldErrorTolerance=0.00075, mutualInducedTargetEpsilon=epsilon, polarization=polarization)
else:
ff = app.ForceField('amoeba2009.xml', 'amoeba2009_gk.xml')
pdb = app.PDBFile('5dfr_minimized.pdb')
cutoff = 2.0*unit.nanometers
vdwCutoff = 1.2*unit.nanometers
system = ff.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, constraints=constraints, mutualInducedTargetEpsilon=epsilon, polarization=polarization)
dt = 0.001*unit.picoseconds
else:
if explicit:
ff = app.ForceField('amber99sb.xml', 'tip3p.xml')
pdb = app.PDBFile('5dfr_solv-cube_equil.pdb')
if testName == 'pme':
method = app.PME
cutoff = options.cutoff
else:
method = app.CutoffPeriodic
cutoff = 1*unit.nanometers
else:
ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml')
pdb = app.PDBFile('5dfr_minimized.pdb')
method = app.CutoffNonPeriodic
cutoff = 2*unit.nanometers
if options.heavy:
dt = 0.005*unit.picoseconds
constraints = app.AllBonds
hydrogenMass = 4*unit.amu
else:
dt = 0.002*unit.picoseconds
constraints = app.HBonds
hydrogenMass = None
system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass)
print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds))
properties = {}
if options.device is not None:
if platform.getName() == 'CUDA':
properties['CudaDeviceIndex'] = options.device
elif platform.getName() == 'OpenCL':
properties['OpenCLDeviceIndex'] = options.device
if options.precision is not None:
if platform.getName() == 'CUDA':
properties['CudaPrecision'] = options.precision
elif platform.getName() == 'OpenCL':
properties['OpenCLPrecision'] = options.precision
# Run the simulation.
integ = mm.LangevinIntegrator(300*unit.kelvin, 91*(1/unit.picoseconds), dt)
integ.setConstraintTolerance(1e-5)
if len(properties) > 0:
context = mm.Context(system, integ, platform, properties)
else:
context = mm.Context(system, integ, platform)
context.setPositions(pdb.positions)
context.setVelocitiesToTemperature(300*unit.kelvin)
steps = 20
while True:
time = timeIntegration(context, steps)
if time >= 0.5*options.seconds:
break
if time < 0.5:
steps = int(steps*1.0/time) # Integrate enough steps to get a reasonable estimate for how many we'll need.
else:
steps = int(steps*options.seconds/time)
print('Integrated %d steps in %g seconds' % (steps, time))
print('%g ns/day' % (dt*steps*86400/time).value_in_unit(unit.nanoseconds))
# Parse the command line options.
parser = OptionParser()
platformNames = [mm.Platform.getPlatform(i).getName() for i in range(mm.Platform.getNumPlatforms())]
parser.add_option('--platform', dest='platform', choices=platformNames, help='name of the platform to benchmark')
parser.add_option('--test', dest='test', choices=('gbsa', 'rf', 'pme', 'amoebagk', 'amoebapme'), help='the test to perform: gbsa, rf, pme, amoebagk, or amoebapme [default: all]')
parser.add_option('--pme-cutoff', default='0.9', dest='cutoff', type='float', help='direct space cutoff for PME in nm [default: 0.9]')
parser.add_option('--seconds', default='60', dest='seconds', type='float', help='target simulation length in seconds [default: 60]')
parser.add_option('--mutual-epsilon', default='1e-4', dest='epsilon', type='float', help='mutual induced epsilon for AMOEBA [default: 1e-4]')
parser.add_option('--heavy-hydrogens', action='store_true', default=False, dest='heavy', help='repartition mass to allow a larger time step')
parser.add_option('--device', default=None, dest='device', help='device index for CUDA or OpenCL')
parser.add_option('--precision', default='single', dest='precision', choices=('single', 'mixed', 'double'), help='precision mode for CUDA or OpenCL: single, mixed, or double [default: single]')
(options, args) = parser.parse_args()
if len(args) > 0:
parser.error('Unknown argument: '+args[0])
if options.platform is None:
parser.error('No platform specified')
print('Platform:', options.platform)
if options.platform in ('CUDA', 'OpenCL'):
print('Precision:', options.precision)
if options.device is not None:
print('Device:', options.device)
# Run the simulations.
if options.test is None:
for test in ('gbsa', 'rf', 'pme', 'amoebagk', 'amoebapme'):
try:
runOneTest(test, options)
except Exception as ex:
print('Test failed: %s' % ex.message)
else:
runOneTest(options.test, options)
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <sstream> #include <sstream>
#include <algorithm>
namespace Lepton { namespace Lepton {
......
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
#define LEPTON_MSVC_ERFC_H_ #define LEPTON_MSVC_ERFC_H_
/* /*
* At least up to version 8 (VC++ 2005), Microsoft does not support the * Up to version 11 (VC++ 2012), Microsoft does not support the
* standard C99 erf() and erfc() functions. For now we're including these * standard C99 erf() and erfc() functions so we have to fake them here.
* definitions for an MSVC compilation; if these are added later then * These were added in version 12 (VC++ 2013), which sets _MSC_VER=1800
* the #ifdef below should change to compare _MSC_VER with a particular * (VC11 has _MSC_VER=1700).
* version level.
*/ */
#ifdef _MSC_VER #if defined(_MSC_VER)
#define M_PI 3.14159265358979323846264338327950288
#if _MSC_VER <= 1700 // 1700 is VC11, 1800 is VC12
/*************************** /***************************
* erf.cpp * erf.cpp
* author: Steve Strand * author: Steve Strand
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <cmath> #include <cmath>
#define M_PI 3.14159265358979323846264338327950288
static const double rel_error= 1E-12; //calculate 12 significant figures static const double rel_error= 1E-12; //calculate 12 significant figures
//you can adjust rel_error to trade off between accuracy and speed //you can adjust rel_error to trade off between accuracy and speed
//but don't ask for > 15 figures (assuming usual 52 bit mantissa in a double) //but don't ask for > 15 figures (assuming usual 52 bit mantissa in a double)
...@@ -83,6 +81,7 @@ static double erfc(double x) ...@@ -83,6 +81,7 @@ static double erfc(double x)
return one_sqrtpi*exp(-x*x)*q2; return one_sqrtpi*exp(-x*x)*q2;
} }
#endif // _MSC_VER <= 1700
#endif // _MSC_VER #endif // _MSC_VER
#endif // LEPTON_MSVC_ERFC_H_ #endif // LEPTON_MSVC_ERFC_H_
...@@ -90,8 +90,10 @@ namespace OpenMM_SFMT { ...@@ -90,8 +90,10 @@ namespace OpenMM_SFMT {
class SFMTData { class SFMTData {
public: public:
/** Possibly incorrectly aligned memory for internal state array */
char baseData[(N+1)*sizeof(w128_t)];
/** the 128-bit internal state array */ /** the 128-bit internal state array */
w128_t sfmt[N]; w128_t* sfmt;
/** the 32bit integer pointer to the 128-bit internal state array */ /** the 32bit integer pointer to the 128-bit internal state array */
uint32_t *psfmt32; uint32_t *psfmt32;
#if !defined(BIG_ENDIAN64) || defined(ONLY64) #if !defined(BIG_ENDIAN64) || defined(ONLY64)
...@@ -106,6 +108,9 @@ public: ...@@ -106,6 +108,9 @@ public:
/** a parity check vector which certificate the period of 2^{MEXP} */ /** a parity check vector which certificate the period of 2^{MEXP} */
uint32_t parity[4]; uint32_t parity[4];
SFMTData() { SFMTData() {
char* offsetData = baseData+15;
offsetData -= (long long)offsetData&0xF;
sfmt = (w128_t*) offsetData;
psfmt32 = &sfmt[0].u[0]; psfmt32 = &sfmt[0].u[0];
#if !defined(BIG_ENDIAN64) || defined(ONLY64) #if !defined(BIG_ENDIAN64) || defined(ONLY64)
psfmt64 = (uint64_t *)&sfmt[0].u[0]; psfmt64 = (uint64_t *)&sfmt[0].u[0];
......
...@@ -88,7 +88,12 @@ const string& Platform::getPropertyDefaultValue(const string& property) const { ...@@ -88,7 +88,12 @@ const string& Platform::getPropertyDefaultValue(const string& property) const {
} }
void Platform::setPropertyDefaultValue(const string& property, const string& value) { void Platform::setPropertyDefaultValue(const string& property, const string& value) {
for (int i = 0; i < (int) platformProperties.size(); i++)
if (platformProperties[i] == property) {
defaultProperties[property] = value; defaultProperties[property] = value;
return;
}
throw OpenMMException("setPropertyDefaultValue: Illegal property name");
} }
void Platform::contextCreated(ContextImpl& context, const map<string, string>& properties) const { void Platform::contextCreated(ContextImpl& context, const map<string, string>& properties) const {
......
...@@ -69,5 +69,6 @@ ...@@ -69,5 +69,6 @@
#include "openmm/VerletIntegrator.h" #include "openmm/VerletIntegrator.h"
#include "openmm/VirtualSite.h" #include "openmm/VirtualSite.h"
#include "openmm/Platform.h" #include "openmm/Platform.h"
#include "openmm/serialization/XmlSerializer.h"
#endif /*OPENMM_H_*/ #endif /*OPENMM_H_*/
...@@ -74,6 +74,15 @@ public: ...@@ -74,6 +74,15 @@ public:
double getDefaultTemperature() const { double getDefaultTemperature() const {
return defaultTemp; return defaultTemp;
} }
/**
* Set the default temperature of the heat bath. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param temperature the default temperature of the heat bath (in Kelvin)
*/
void setDefaultTemperature(double temperature) {
defaultTemp = temperature;
}
/** /**
* Get the default collision frequency (in 1/ps). * Get the default collision frequency (in 1/ps).
* *
...@@ -82,6 +91,15 @@ public: ...@@ -82,6 +91,15 @@ public:
double getDefaultCollisionFrequency() const { double getDefaultCollisionFrequency() const {
return defaultFreq; return defaultFreq;
} }
/**
* Set the default collision frequency. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param frequency the default collision frequency (in 1/ps)
*/
void setDefaultCollisionFrequency(double frequency) {
defaultFreq = frequency;
}
/** /**
* Get the random number seed. See setRandomNumberSeed() for details. * Get the random number seed. See setRandomNumberSeed() for details.
*/ */
......
...@@ -100,6 +100,15 @@ public: ...@@ -100,6 +100,15 @@ public:
const Vec3& getDefaultPressure() const { const Vec3& getDefaultPressure() const {
return defaultPressure; return defaultPressure;
} }
/**
* Set the default pressure acting on the system. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param pressure the default pressure acting on the system, measured in bar.
*/
void setDefaultPressure(const Vec3& pressure) {
defaultPressure = pressure;
}
/** /**
* Get whether to allow the X dimension of the periodic box to change size. * Get whether to allow the X dimension of the periodic box to change size.
*/ */
......
...@@ -74,6 +74,15 @@ public: ...@@ -74,6 +74,15 @@ public:
double getDefaultPressure() const { double getDefaultPressure() const {
return defaultPressure; return defaultPressure;
} }
/**
* Set the default pressure acting on the system. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param pressure the default pressure acting on the system, measured in bar.
*/
void setDefaultPressure(double pressure) {
defaultPressure = pressure;
}
/** /**
* Get the frequency (in time steps) at which Monte Carlo pressure changes should be attempted. If this is set to * Get the frequency (in time steps) at which Monte Carlo pressure changes should be attempted. If this is set to
* 0, the barostat is disabled. * 0, the barostat is disabled.
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "Vec3.h" #include "Vec3.h"
#include <map> #include <map>
#include <string>
#include <vector> #include <vector>
#include "internal/windowsExport.h" #include "internal/windowsExport.h"
......
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
#define OPENMM_MSVC_ERFC_H_ #define OPENMM_MSVC_ERFC_H_
/* /*
* At least up to version 8 (VC++ 2005), Microsoft does not support the * Up to version 11 (VC++ 2012), Microsoft does not support the
* standard C99 erf() and erfc() functions. For now we're including these * standard C99 erf() and erfc() functions so we have to fake them here.
* definitions for an MSVC compilation; if these are added later then * These were added in version 12 (VC++ 2013), which sets _MSC_VER=1800
* the #ifdef below should change to compare _MSC_VER with a particular * (VC11 has _MSC_VER=1700).
* version level.
*/ */
#ifdef _MSC_VER #if defined(_MSC_VER)
#define M_PI 3.14159265358979323846264338327950288
#if _MSC_VER <= 1700 // 1700 is VC11, 1800 is VC12
/*************************** /***************************
* erf.cpp * erf.cpp
* author: Steve Strand * author: Steve Strand
...@@ -81,6 +81,7 @@ static double erfc(double x) ...@@ -81,6 +81,7 @@ static double erfc(double x)
return one_sqrtpi*exp(-x*x)*q2; return one_sqrtpi*exp(-x*x)*q2;
} }
#endif // _MSC_VER <= 1700
#endif // _MSC_VER #endif // _MSC_VER
#endif // OPENMM_MSVC_ERFC_H_ #endif // OPENMM_MSVC_ERFC_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