Commit 1c938ceb authored by Jason Swails's avatar Jason Swails
Browse files

Merge branch 'master' into amber-switching

 Conflicts:
	wrappers/python/simtk/openmm/app/amberprmtopfile.py

In fixing the merge conflict, I went ahead and fixed up the switchDistance logic
to match what I did in CharmmPsfFile.
parents a1113e7b 167ae8a0
language: python
python:
- "2.7_with_system_site_packages"
- "3.4"
sudo: false
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libpcre3
- libpcre3-dev
- gromacs
- doxygen
- python-numpy
- python-scipy
- libfftw3-dev
matrix:
include:
- sudo: required
env: ==CPU_OPENCL==
OPENCL=true
CUDA=false
CC=gcc
CXX=g++
CMAKE_FLAGS="
-OPENMM_BUILD_OPENCL_LIB=ON
-DOPENMM_BUILD_OPENCL_TESTS=ON
-DOPENMM_BUILD_STATIC_LIB=OFF
-DOPENMM_BUILD_CPU_LIB=OFF
-DOPENMM_BUILD_REFERENCE_TESTS=OFF
-DOPENMM_BUILD_SERIALIZATION_TESTS=OFF
-DOPENMM_BUILD_PME_PLUGIN=OFF
-DOPENMM_BUILD_AMOEBA_PLUGIN=OFF
-DOPENMM_BUILD_PYTHON_WRAPPERS=OFF
-DOPENMM_BUILD_C_AND_FORTRAN_WRAPPERS=OFF
-DOPENMM_BUILD_EXAMPLES=OFF"
addons: {apt: {packages: []}}
env:
matrix:
- OPENMM_BUILD_STATIC_LIB="OFF"
- OPENMM_BUILD_STATIC_LIB="ON"
- sudo: required
env: ==CUDA_COMPILE==
CUDA=true
OPENCL=false
CUDA_VERSION="7.0-28"
CMAKE_FLAGS="
-DOPENMM_BUILD_CUDA_TESTS=OFF
-DOPENMM_BUILD_OPENCL_TESTS=OFF
-DOPENMM_BUILD_PYTHON_WRAPPERS=OFF
-DOPENMM_BUILD_REFERENCE_TESTS=OFF
-DOPENMM_BUILD_SERIALIZATION_TESTS=OFF
-DOPENMM_BUILD_C_AND_FORTRAN_WRAPPERS=OFF
-DOPENMM_BUILD_EXAMPLES=OFF
-DOPENCL_LIBRARY=/usr/local/cuda-7.0/lib64/libOpenCL.so"
addons: {apt: {packages: []}}
- language: objective-c
os: osx
env: ==OSX==
OPENCL=false
CUDA=false
CMAKE_FLAGS="
-DOPENMM_BUILD_OPENCL_TESTS=OFF
-DSWIG_EXECUTABLE=/usr/local/Cellar/swig/3.0.2/bin/swig"
addons: {apt: {packages: []}}
- sudo: false
python: 2.7_with_system_site_packages
env: ==STATIC_LIB==
OPENCL=false
CUDA=false
CC=clang
CXX=clang++
CMAKE_FLAGS="-DOPENMM_BUILD_STATIC_LIB=ON"
- sudo: false
python: 2.7_with_system_site_packages
env: ==PYTNON_2==
OPENCL=false
CUDA=false
CC=clang
CXX=clang++
DOCS_DEPLOY=true
CMAKE_FLAGS=""
- sudo: false
python: 3.4
env: ==PYTHON_3==
OPENCL=false
CUDA=false
CC=gcc
CXX=g++
CMAKE_FLAGS=""
before_install:
- export CC=clang
- export CXX=clang++
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew install doxygen swig fftw;
sudo easy_install pytest;
fi
- if [[ "$OPENCL" == "true" ]]; then
sudo apt-get -yq update > /dev/null 2>&1 ;
sudo apt-get install -qq fglrx=2:8.960-0ubuntu1 opencl-headers;
fi
# Install swig for Python wrappers. However, testing CUDA and OpenCL, we
# skip the Python wrapper for speed. We're not using anaconda python,
# but this is a fast way to get an apparently functional precompiled
# build of swig that's more modern than what's in apt.
- if [[ "$OPENCL" == "false" && "$CUDA" == "false" && "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://anaconda.org/omnia/swig/3.0.7/download/linux-64/swig-3.0.7-0.tar.bz2;
mkdir $HOME/swig;
tar -xjvf swig-3.0.7-0.tar.bz2 -C $HOME/swig;
export PATH=$HOME/swig/bin:$PATH;
export SWIG_LIB=$HOME/swig/share/swig/3.0.7;
fi
- wget https://anaconda.org/anaconda/swig/3.0.2/download/linux-64/swig-3.0.2-0.tar.bz2
- mkdir $HOME/swig
- tar -xjvf swig-3.0.2-0.tar.bz2 -C $HOME/swig
- export PATH=$HOME/swig/bin:$PATH
- export SWIG_LIB=$HOME/swig/share/swig/3.0.2
- if [[ "$CUDA" == "true" ]]; then
wget "http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_${CUDA_VERSION}_amd64.deb";
sudo dpkg -i cuda-repo-ubuntu1204_${CUDA_VERSION}_amd64.deb;
sudo apt-get update -qq;
export CUDA_APT=${CUDA_VERSION%-*};
export CUDA_APT=${CUDA_APT/./-};
sudo apt-get install -y cuda-drivers cuda-core-${CUDA_APT} cuda-cudart-dev-${CUDA_APT} cuda-cufft-dev-${CUDA_APT};
sudo apt-get clean;
export CUDA_HOME=/usr/local/cuda-${CUDA_VERSION%%-*};
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH};
export PATH=${CUDA_HOME}/bin:${PATH};
fi
script:
- cmake -DCMAKE_INSTALL_PREFIX=$HOME/OpenMM -DOPENMM_BUILD_STATIC_LIB=$OPENMM_BUILD_STATIC_LIB .
- make -j2
- CTEST_STOP_TIME=$(python -c "from datetime import datetime, timedelta; import sys; sys.stdout.write((datetime.now() + timedelta(minutes=25)).strftime('%H:%M:%S'))")
- cmake . $CMAKE_FLAGS -DCMAKE_INSTALL_PREFIX=$HOME/OpenMM
- make -j2 install
- make PythonInstall
- # Run the testInstallation script
- python -m simtk.testInstallation
- if [[ "$OPENCL" == "true" ]]; then ./TestOpenCLDeviceQuery; fi
- if [[ "$OPENCL" == "false" && "$CUDA" == "false" ]]; then
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
sudo make PythonInstall;
else
make PythonInstall;
fi;
python -m simtk.testInstallation;
(cd python/tests && py.test -v *);
fi
- # run all of the tests, making sure failures at this stage don't cause travis failures
- ctest -j2 || true
- ctest -j2 --output-on-failure --schedule-random --stop-time $CTEST_STOP_TIME || true
- # get a list of all of the failed tests into this stupid ctest format
- python -c "import os; fn = os.path.join('Testing', 'Temporary', 'LastTestsFailed.log'); os.path.exists(fn) or exit(0); failed = [line.split(':')[0] for line in open(fn)]; print(','.join(x+','+x for x in failed))" > FailedTests.log
- # rerun all of the failed tests
- if [ -s Testing/Temporary/LastTestsFailed.log ]; then ctest -I FailedTests.log; fi;
- # run the python tests too
- cd python/tests
- # nosetests -vv --processes=-1 --process-timeout=200
- # nosetests -vv
- py.test -v *
- cd -
- if [ -s Testing/Temporary/LastTestsFailed.log ]; then
ctest -I FailedTests.log;
fi
- if [[ ! -z "${DOCS_DEPLOY}" && "${DOCS_DEPLOY}" = "true" ]]; then
pip install sphinx numpydoc;
make DoxygenApiDocs PythonApiDocs;
mkdir -p api-docs;
mv api-python api-docs;
mv api-c++ api-docs;
fi
deploy:
- provider: s3
access_key_id:
secure: "AjE3nuj6kVuf21mOf0aZydW/3S/uCWsaoXC/huRxkxrmsNlnHBNGHZ9N48san1IxZAQM5pyaf7Yo9gkHur9obgq+e3lNgGvPp2mfkNXtLYcLJ46JF4kYliAtutjLWskrLg25Gu3xzF4EQkqSe0Le/oWldWWbTgvvH+KRq/vTHzI="
secret_access_key:
secure: "ISDQNSG2t0666PULtffo4wsKLFdu622EzuZxmiTxvLkjQGQlqm5+qn1Gd5UMLk7Ts2E0psdnmSrf6LVVCfrrQO/hcZHiJw3ZslMPDBBlRr8Epwdldn98ULhVoyQKtjXjCPzroa2UZCl1RFs4Nwb/VdDlI490XV0Lp4Woj1AT8tY="
bucket: "docs.openmm.org"
skip_cleanup: true
region: us-west-1
local_dir: api-docs/
upload_dir: development
on:
branch: master
condition: '! -z "${DOCS_DEPLOY}" && "${DOCS_DEPLOY}" = "true"'
......@@ -65,6 +65,11 @@ ELSE(WIN32)
ENDIF(NOT OPENMM_INSTALL_PREFIX)
ENDIF(WIN32)
IF(WIN32)
ADD_DEFINITIONS(-DWIN32)
ENDIF(WIN32)
# Include CPU-Features for Android
IF (ANDROID)
INCLUDE_DIRECTORIES(${ANDROID_NDK}/sources/cpufeatures)
......@@ -82,7 +87,7 @@ ENDIF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
# 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 . openmmapi olla libraries/jama libraries/quern libraries/lepton libraries/sfmt libraries/lbfgs libraries/hilbert libraries/csha1 platforms/reference serialization libraries/validate libraries/irrxml libraries/vecmath)
SET(OPENMM_SOURCE_SUBDIRS . openmmapi olla libraries/jama libraries/quern libraries/lepton libraries/sfmt libraries/lbfgs libraries/hilbert libraries/csha1 platforms/reference serialization libraries/irrxml libraries/vecmath)
IF(WIN32)
SET(OPENMM_SOURCE_SUBDIRS ${OPENMM_SOURCE_SUBDIRS} libraries/pthreads)
ELSE(WIN32)
......@@ -109,6 +114,7 @@ ELSE( CMAKE_SIZEOF_VOID_P EQUAL 8 )
SET( LIB64 )
ENDIF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
IF (APPLE AND (NOT PNACL))
# Build 64 bit binaries compatible with OS X 10.7
IF (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
......@@ -117,6 +123,14 @@ IF (APPLE AND (NOT PNACL))
IF (NOT CMAKE_OSX_ARCHITECTURES)
SET (CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "The processor architectures to build for" FORCE)
ENDIF (NOT CMAKE_OSX_ARCHITECTURES)
IF (NOT CMAKE_OSX_SYSROOT)
EXECUTE_PROCESS(COMMAND "xcrun" "--show-sdk-path" OUTPUT_VARIABLE XCRUN_OSX_SYSROOT RESULT_VARIABLE XCRUN_OSX_SYSROOT_STATUS OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (XCRUN_OSX_SYSROOT_STATUS EQUAL 0)
SET (CMAKE_OSX_SYSROOT "${XCRUN_OSX_SYSROOT}" CACHE STRING "SDK Path" FORCE)
ENDIF (XCRUN_OSX_SYSROOT_STATUS EQUAL 0)
UNSET(XCRUN_OSX_SYSROOT)
UNSET(XCRUN_OSX_SYSROOT_STATUS)
ENDIF (NOT CMAKE_OSX_SYSROOT)
# Improve the linking behavior of Mac libraries
SET (CMAKE_INSTALL_NAME_DIR "@rpath")
......@@ -302,14 +316,14 @@ ENDIF (MSVC)
IF(OPENMM_BUILD_SHARED_LIB)
ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DOPENMM_VALIDATE_BUILDING_SHARED_LIBRARY -DPTHREAD_BUILDING_SHARED_LIBRARY")
SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DPTHREAD_BUILDING_SHARED_LIBRARY")
ENDIF(OPENMM_BUILD_SHARED_LIB)
SET(OPENMM_BUILD_STATIC_LIB OFF CACHE BOOL "Whether to build static OpenMM libraries")
IF(OPENMM_BUILD_STATIC_LIB)
ADD_LIBRARY(${STATIC_TARGET} STATIC ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
SET(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_USE_STATIC_LIBRARIES -DLEPTON_USE_STATIC_LIBRARIES -DPTW32_STATIC_LIB")
SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_BUILDING_STATIC_LIBRARY -DOPENMMM_VALIDATE_BUILDING_STATIC_LIBRARY -DOPENMM_VALIDATE_BUILDING_STATIC_LIBRARY -DPTHREAD_BUILDING_STATIC_LIBRARY")
SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_BUILDING_STATIC_LIBRARY -DPTHREAD_BUILDING_STATIC_LIBRARY")
ENDIF(OPENMM_BUILD_STATIC_LIB)
IF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS)
......@@ -341,9 +355,14 @@ ENDIF(DL_LIBRARY)
IF(BUILD_TESTING)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/tests)
ADD_SUBDIRECTORY(platforms/reference/tests)
ENDIF(BUILD_TESTING)
set(OPENMM_BUILD_REFERENCE_TESTS TRUE CACHE BOOL "Whether to build Reference platform test cases")
MARK_AS_ADVANCED(OPENMM_BUILD_REFERENCE_TESTS)
IF(BUILD_TESTING AND OPENMM_BUILD_REFERENCE_TESTS)
ADD_SUBDIRECTORY(platforms/reference/tests)
ENDIF(BUILD_TESTING AND OPENMM_BUILD_REFERENCE_TESTS)
# Which hardware platforms to build
# A bit of tedium because we are using custom FindCUDA files that happen to work...
......
......@@ -20,7 +20,7 @@ install:
- "set PATH=C:\\fftw;%PATH%"
# Download and install some OpenMM build dependencies (doxygen, swig)
- choco install -y doxygen.portable swig
- choco install -y doxygen.portable swig > null
# Set CMake options
- ps: $env:CMAKE_FLAGS='-DOPENMM_BUILD_PME_PLUGIN=ON -DFFTW_LIBRARY=C:/fftw/libfftw3f-3.lib -DFFTW_INCLUDES=C:/fftw -DCMAKE_BUILD_TYPE=Release -DOPENMM_BUILD_EXAMPLES=OFF -DCMAKE_CXX_FLAGS_RELEASE="/MD /Od /Ob0 /D NDEBUG"'
......
......@@ -1125,6 +1125,13 @@ perform integration on a modified potential energy surface to allow much faster
sampling of conformations. For details on how to use them, consult the API
documentation.
Compound Integrator
-------------------
The :class:`CompoundIntegrator` class is useful for cases where you want to use
multiple integration algorithms within a single simulation. It allows you to
create multiple integrators, then switch back and forth between them. For
details on how to use it, consult the API documentation.
Temperature Coupling
====================
......@@ -1843,7 +1850,7 @@ The :code:`<ForceField>` tag contains the following children:
* Zero or more tags defining specific forces
The order of these tags does not matter. They are described in details below.
The order of these tags does not matter. They are described in detail below.
<AtomTypes>
===========
......@@ -1882,12 +1889,12 @@ The residue template definitions look like this:
<Atom name="HH33" type="710"/>
<Atom name="C" type="712"/>
<Atom name="O" type="713"/>
<Bond from="0" to="1"/>
<Bond from="1" to="2"/>
<Bond from="1" to="3"/>
<Bond from="1" to="4"/>
<Bond from="4" to="5"/>
<ExternalBond from="4"/>
<Bond atomName1="HH31" atomName2="CH3"/>
<Bond atomName1="CH3" atomName2="HH32"/>
<Bond atomName1="CH3" atomName2="HH33"/>
<Bond atomName1="CH3" atomName2="C"/>
<Bond atomName1="C" atomName2="O"/>
<ExternalBond atomName="C"/>
</Residue>
<Residue name="ALA">
...
......@@ -1901,12 +1908,16 @@ contains the following tags:
* An :code:`<Atom>` tag for each atom in the residue. This specifies the
name of the atom and its atom type.
* A :code:`<Bond>` tag for each pair of atoms that are bonded to each
other. The :code:`to` and :code:`from` attributes are the indices of
the two bonded atoms (starting from 0) in the order they were listed. For
example, :code:`<Bond from="1" to="3"/>` describes a bond between atom CH3
and atom HH33.
other. The :code:`atomName1` and :code:`atomName2` attributes are the names
of the two bonded atoms. (Some older force fields use the alternate tags
:code:`to` and :code:`from` to specify the atoms by index instead of name.
This is still supported for backward compatibility, but specifying atoms by
name is recommended, since it makes the residue definition much easier to
understand.)
* An :code:`<ExternalBond>` tag for each atom that will be bonded to an
atom of a different residue.
atom of a different residue. :code:`atomName` is the name of the atom.
(Alternatively, the deprecated :code:`from` tag may indicate the atom by
index instead of name.)
The :code:`<Residue>` tag may also contain :code:`<VirtualSite>` tags,
......@@ -1919,26 +1930,32 @@ as in the following example:
<Atom name="H1" type="tip4pew-H"/>
<Atom name="H2" type="tip4pew-H"/>
<Atom name="M" type="tip4pew-M"/>
<VirtualSite type="average3" index="3" atom1="0" atom2="1" atom3="2"
<VirtualSite type="average3" siteName="M" atomName1="O" atomName2="H1" atomName3="H2"
weight1="0.786646558" weight2="0.106676721" weight3="0.106676721"/>
<Bond from="0" to="1"/>
<Bond from="0" to="2"/>
<Bond atomName1="O" atomName2="H1"/>
<Bond atomName1="O" atomName2="H2"/>
</Residue>
Each :code:`<VirtualSite>` tag indicates an atom in the residue that should
be represented with a virtual site. The :code:`type` attribute may equal
:code:`"average2"`\ , :code:`"average3"`\ , or :code:`"outOfPlane"`\ , which
correspond to the TwoParticleAverageSite, ThreeParticleAverageSite, and
OutOfPlaneSite classes respectively. The :code:`index` attribute gives the
index (starting from 0) of the atom to represent with a virtual site. The atoms
it is calculated based on are specified by :code:`atom1`\ , :code:`atom2`\ ,
and (for virtual site classes that involve three atoms) :code:`atom3`\ . The
remaining attributes are specific to the virtual site class, and specify the
:code:`"average2"`\ , :code:`"average3"`\ , :code:`"outOfPlane"`\ , or
:code:`"localCoords"`\ , which correspond to the TwoParticleAverageSite, ThreeParticleAverageSite,
OutOfPlaneSite, and LocalCoordinatesSite classes respectively. The :code:`siteName`
attribute gives the name of the atom to represent with a virtual site. The atoms
it is calculated based on are specified by :code:`atomName1`\ , :code:`atomName2`\ ,
and (for virtual site classes that involve three atoms) :code:`atomName3`\ .
(Some old force fields use the deprecated tags :code:`index`, :code:`atom1`,
:code:`atom2`, and :code:`atom3` to refer to them by index instead of name.)
The remaining attributes are specific to the virtual site class, and specify the
parameters for calculating the site position. For a TwoParticleAverageSite,
they are :code:`weight1` and :code:`weight2`\ . For a
ThreeParticleAverageSite, they are :code:`weight1`\ , :code:`weight2`\ , and
\ :code:`weight3`\ . For an OutOfPlaneSite, they are :code:`weight12`\ ,
:code:`weight13`\ , and :code:`weightCross`\ .
:code:`weight13`\ , and :code:`weightCross`\ . For a LocalCoordinatesSite, they
are :code:`wo1`\ , :code:`wo2`\ , :code:`wo3`\ , :code:`wx1`\ , :code:`wx2`\ ,
:code:`wx3`\ , :code:`wy1`\ , :code:`wy2`\ , :code:`wy3`\ , :code:`p1`\ ,
:code:`p2`\ , and :code:`p3`\ .
<HarmonicBondForce>
......@@ -2496,8 +2513,9 @@ The following operators are supported: + (add), - (subtract), * (multiply), /
The following standard functions are supported: sqrt, exp, log, sin, cos, sec,
csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs,
step. step(x) = 0 if x < 0, 1 otherwise. Some custom forces allow additional
functions to be defined from tabulated values.
floor, ceil, step, delta, select. step(x) = 0 if x < 0, 1 otherwise.
delta(x) = 1 if x is 0, 0 otherwise. select(x,y,z) = z if x = 0, y otherwise.
Some custom forces allow additional functions to be defined from tabulated values.
Numbers may be given in either decimal or exponential form. All of the
following are valid numbers: 5, -3.1, 1e6, and 3.12e-2.
......@@ -2521,8 +2539,8 @@ values. All uses of a value must appear *before* that value’s definition.
.. _tabulated-functions:
TabulatedFunctions
==================
Tabulated Functions
===================
Some forces, such as CustomNonbondedForce and CustomGBForce, allow you to define
tabulated functions. To define a function, include a :code:`<Function>` tag inside the
......@@ -2569,6 +2587,47 @@ successive values separated by white space. See the API documentation for more
details.
Residue Template Parameters
===========================
In forces that use an :code:`<Atom>` tag to define parameters for atom types or
classes, there is an alternate mechanism you can also use: defining those
parameter values in the residue template. This is useful for situations that
come up in certain force fields. For example, :code:`NonbondedForce` and
:code:`GBSAOBCForce` each have a :code:`charge` attribute. If you only have to
define the charge of each atom type once, that is more convenient and avoids
potential bugs. Also, many force fields have a different charge for each atom
type, but Lennard-Jones parameters that are the same for all types in a class.
It would be preferable not to have to repeat those parameter values many times
over.
When writing a residue template, you can add arbitrary additional attributes
to each :code:`<Atom>` tag. For example, you might include a :code:`charge`
attribute as follows:
.. code-block:: xml
<Atom name="CA" type="53" charge="0.0381"/>
When writing the tag for a force, you can then include a
:code:`<UseAttributeFromResidue>` tag inside it. This indicates that a
specified attribute should be taken from the residue template. Finally, you
simply omit that attribute in the force's own :code:`<Atom>` tags. For example:
.. code-block:: xml
<NonbondedForce coulomb14scale="0.833333" lj14scale="0.5">
<UseAttributeFromResidue name="charge"/>
<Atom class="CX" sigma="0.339966950842" epsilon="0.4577296"/>
...
</NonbondedForce>
Notice that the :code:`charge` attribute is missing, and that the parameters
are specified by class, not by type. This means that sigma and epsilon only
need to be specified once for each class. The atom charges, which are different
for each type, are taken from the residue template instead.
Using Multiple Files
********************
......
......@@ -4,7 +4,7 @@ from simtk.unit import *
from sys import stdout
gro = GromacsGroFile('input.gro')
top = GromacsTopFile('input.top', periodicBoxVectors=gro.getPeriodicBoxVectors(), includeDir='/usr/local/gromacs/share/gromacs/top')
top = GromacsTopFile('input.top', periodicBoxVectors=gro.getPeriodicBoxVectors())
system = top.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=HBonds)
integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds)
simulation = Simulation(top.topology, system, integrator)
......
......@@ -121,6 +121,9 @@
#endif
#if _MSC_VER >= 1900
#include <ctime>
#else
/* Windows doesn't have this, so declare it ourselves. */
struct timespec
{
......@@ -128,6 +131,7 @@ struct timespec
long long tv_sec;
long long tv_nsec;
};
#endif
typedef struct _pthread_cleanup _pthread_cleanup;
struct _pthread_cleanup
......
#ifndef VALIDATE_OPENMM_H_
#define VALIDATE_OPENMM_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: Mark Friedrichs *
* 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.h"
#include "../../../platforms/reference/include/ReferencePlatform.h"
#include "openmm/Context.h"
#include "openmm/System.h"
#include "ValidateWindowsIncludes.h"
// free-energy plugin includes
//#define INCLUDE_FREE_ENERGY_PLUGIN
#ifdef INCLUDE_FREE_ENERGY_PLUGIN
#include "../../../plugins/freeEnergy/openmmapi/include/OpenMMFreeEnergy.h"
#include "../../../plugins/freeEnergy/openmmapi/include/openmm/freeEnergyKernels.h"
//#include "../../../plugins/freeEnergy/platforms/reference/include/ReferenceFreeEnergyPlatform.h"
#include "../../../plugins/freeEnergy/platforms/reference/include/ReferenceFreeEnergyKernelFactory.h"
#endif
#include <sstream>
#include <typeinfo>
#include <limits>
#include <cstdlib>
#include <cstring>
#include <cstdio>
namespace OpenMM {
typedef std::map< std::string, int > StringIntMap;
typedef StringIntMap::iterator StringIntMapI;
typedef StringIntMap::const_iterator StringIntMapCI;
typedef std::map< std::string, double > StringDoubleMap;
typedef StringDoubleMap::iterator StringDoubleMapI;
typedef StringDoubleMap::const_iterator StringDoubleMapCI;
typedef std::map< std::string, unsigned int > StringUIntMap;
typedef StringUIntMap::iterator StringUIntMapI;
typedef StringUIntMap::const_iterator StringUIntMapCI;
typedef std::vector< std::string > StringVector;
typedef StringVector::iterator StringVectorI;
typedef StringVector::const_iterator StringVectorCI;
typedef std::vector< int > IntVector;
typedef IntVector::iterator IntVectorI;
typedef IntVector::const_iterator IntVectorCI;
typedef std::map< std::string, std::vector<std::string> > StringStringVectorMap;
typedef StringStringVectorMap::iterator StringStringVectorMapI;
typedef StringStringVectorMap::const_iterator StringStringVectorMapCI;
/**
* Base class w/ common functionality
*/
class ValidateOpenMM {
public:
ValidateOpenMM();
~ValidateOpenMM();
// force names
static const std::string HARMONIC_BOND_FORCE;
static const std::string HARMONIC_ANGLE_FORCE;
static const std::string PERIODIC_TORSION_FORCE;
static const std::string RB_TORSION_FORCE;
static const std::string NB_FORCE;
static const std::string NB_SOFTCORE_FORCE;
static const std::string NB_EXCEPTION_FORCE;
static const std::string NB_EXCEPTION_SOFTCORE_FORCE;
static const std::string GBSA_OBC_FORCE;
static const std::string GBSA_OBC_SOFTCORE_FORCE;
static const std::string GBVI_FORCE;
static const std::string GBVI_SOFTCORE_FORCE;
static const std::string CM_MOTION_REMOVER;
static const std::string ANDERSEN_THERMOSTAT;
static const std::string CUSTOM_BOND_FORCE;
static const std::string CUSTOM_EXTERNAL_FORCE;
static const std::string CUSTOM_NONBONDED_FORCE;
/**
* Return true if input number is nan or infinity
*
* @param number number to test
*
* @return true if number is nan or infinity
*/
static int isNanOrInfinity( double number );
/**
* Get force name
*
* @param force OpenMM system force
*
* @return force name or "NA" if force is not recognized
*/
std::string getForceName(const Force& force ) const;
/**
* Copy force
*
* @param force OpenMM system force to copy
*
* @return force or NULL if not recognized
*/
Force* copyForce(const Force& force) const;
/**
* Get copy of input system, but omit forces
*
* @param systemToCopy system to copy
*
* @return copy of system but w/o forces
*/
System* copySystemExcludingForces( const System& systemToCopy ) const;
/**
*
* Set the velocities/positions of context2 to those of context1
*
* @param context1 context1
* @param context2 context2
*
* @return 0
*/
void synchContexts( const Context& context1, Context& context2 ) const;
/**
*
* Get log FILE* reference
*
* @return log
*
*/
FILE* getLog() const;
/**
*
* Set log FILE* reference
*
* @param log log
*
*/
void OPENMM_VALIDATE_EXPORT setLog( FILE* log );
/**---------------------------------------------------------------------------------------
Copy constraints
@param systemToCopy system whose constraints are to be copied
@param system system to add constraints to
@param log log file pointer -- may be NULL
--------------------------------------------------------------------------------------- */
void copyConstraints( const System& systemToCopy, System* system, FILE* log = NULL ) const;
/**---------------------------------------------------------------------------------------
Get force dependencies
@param forceName force to check if there exist any dependencies
@param returnVector vector of forces the input force is dependent on (example: GBSAOBC force requires Nonbonded force since
on Cuda platofrm they are computed in same loop and hence are inseparable)
--------------------------------------------------------------------------------------- */
void getForceDependencies( std::string forceName, StringVector& returnVector ) const;
/**
* Write masses to parameter file
*
* @param filePtr file to write masses to
* @param system write masses in system
*/
void writeMasses( FILE* filePtr, const System& system ) const;
/**
* Write constraints to parameter file
*
* @param filePtr file to write constraints to
* @param system write constraints in system
*
*/
void writeConstraints( FILE* filePtr, const System& system ) const;
/**
* Write harmonicBondForce parameters to file
*
* @param filePtr file to write forces to
* @param harmonicBondForce write harmonicBondForce parameters
*
*/
void writeHarmonicBondForce( FILE* filePtr, const HarmonicBondForce& harmonicBondForce ) const;
/**
* Write harmonicAngleForce parameters to file
*
* @param filePtr file to write forces to
* @param harmonicAngleForce write harmonicAngleForce parameters
*
*/
void writeHarmonicAngleForce( FILE* filePtr, const HarmonicAngleForce& harmonicAngleForce ) const;
/**
* Write rbTorsionForce parameters to file
*
* @param filePtr file to write forces to
* @param rbTorsionForce write rbTorsionForce parameters
*
*/
void writeRbTorsionForce( FILE* filePtr, const RBTorsionForce& rbTorsionForce ) const;
/**
* Write periodicTorsionForce parameters to file
*
* @param filePtr file to write forces to
* @param periodicTorsionForce write periodicTorsionForce parameters
*
*/
void writePeriodicTorsionForce( FILE* filePtr, const PeriodicTorsionForce& periodicTorsionForce ) const;
/**
* Write nonbonded parameters to file
*
* @param filePtr file to write forces to
* @param nonbondedForce write nonbondedForce parameters
*
*/
void writeNonbondedForce( FILE* filePtr, const NonbondedForce & nonbondedForce ) const;
/**
* Write GBSAOBCForce parameters to file
*
* @param filePtr file to write forces to
* @param gbsaObcForce write gbsaObcForce parameters
*
*/
void writeGbsaObcForce( FILE* filePtr, const GBSAOBCForce& gbsaObcForce ) const;
/**
* Write GBSA GB/VI Force parameters to file
*
* @param filePtr file to write forces to
* @param gbviObcForce write gbviObcForce parameters
*
*/
void writeGBVIForce( FILE* filePtr, const GBVIForce& gbviForce ) const;
#ifdef INCLUDE_FREE_ENERGY_PLUGIN
/**
* Write nonbonded softcore parameters to file
*
* @param filePtr file to write forces to
* @param nonbondedForce write nonbondedForce parameters
*/
void writeNonbondedSoftcoreForce( FILE* filePtr, const NonbondedSoftcoreForce & nonbondedSoftcoreForce ) const;
/**
* Write GBSAOBCSoftcoreForce parameters to file
*
* @param filePtr file to write forces to
* @param gbsaObcForce write gbsaObcForce parameters
*
*/
void writeGbsaObcSoftcoreForce( FILE* filePtr, const GBSAOBCSoftcoreForce& gbsaObcForce ) const;
/**
* Write GBSA GB/VI softcore force parameters to file
*
* @param filePtr file to write forces to
* @param gbviObcForce write gbviObcForce parameters
*
*/
void writeGBVISoftcoreForce( FILE* filePtr, const GBVISoftcoreForce& gbviSoftcoreForce ) const;
#endif
/**
* Write coordinates, velocities, ... to file
*
* @param filePtr file to write Vec3 entries to
* @param vect3Array write array of Vec3
*
*/
void writeVec3( FILE* filePtr, const std::vector<Vec3>& vect3Array ) const;
/**
* Write context info to file (positions, velocities, forces, energies)
*
* @param filePtr file to write entries to
* @param context write context positions, velocities, forces, energies to file
*
*/
void writeContext( FILE* filePtr, const Context& context ) const;
/**
* Write integrator
*
* @param filePtr file to write integrator info to
* @param integrator write integrator info (time step, seed, ... as applicable)
*
*/
void writeIntegrator( FILE* filePtr, const Integrator& integrator ) const;
/**
* Write parameter file
* @param context context whose entries are to be written to file
* @param parameterFileName file name
*
*/
void writeParameterFile( const Context& context, const std::string& parameterFileName ) const;
private:
FILE* _log;
// map of force dependencies (e.g., GBSAObc requires NB force on CudaPlatform)
StringStringVectorMap _forceDependencies;
};
} // namespace OpenMM
#endif /*VALIDATE_OPENMM_H_*/
#ifndef VALIDATE_OPENMM_FORCES_H_
#define VALIDATE_OPENMM_FORCES_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: Mark Friedrichs *
* 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 "ValidateOpenMM.h"
namespace OpenMM {
typedef std::map< int, int > MapIntInt;
typedef MapIntInt::iterator MapIntIntI;
typedef MapIntInt::const_iterator MapIntIntCI;
// Helper class for ValidateOpenMMForces class used to store force results and facitilitate comparisons of
// resulting forces
class ForceValidationResult {
public:
ForceValidationResult(const Context& context1, const Context& context2, StringUIntMap& forceNamesMap);
~ForceValidationResult();
/**
* Get potential energy at specified platform index (0 || 1)
*
* @return potential energy for spercifed platform
*
* @throws OpenMMException if energyIndex is not 0 or 1
*/
double getPotentialEnergy(int energyIndex) const;
/**
* Get array of forces at specified platform index (0 || 1)
*
* @return array of force norms
*
* @throws OpenMMException if forceIndex is not 0 or 1
*/
std::vector<double> getForceNorms(int forceIndex) const;
/**
* Get array of forces at platform index (0 || 1)
*
* @return force array
*
* @throws OpenMMException if forceIndex is not 0 or 1
*/
std::vector<Vec3> getForces(int forceIndex) const;
/**
* Get maximum delta in force norm
*
* @param maxIndex return atom index of entry with maximum delta norm (optional)
*
* @return max delta in norm of forces
*/
double getMaxDeltaForceNorm(int* maxIndex = NULL) const;
/**
* Get maximum relative delta in force norm
*
* @param maxIndex return atom index of entry w/ maximum relative delta norm (optional)
*
* @return max relative delta in norm of forces
*/
double getMaxRelativeDeltaForceNorm(int* maxIndex = NULL) const;
/**
* Get maximum dot product between forces
*
* @param maxIndex return atom index of entry w/ maximum dot product between forces (optional)
*
* @return max dot product between forces
*/
double getMaxDotProduct(int* maxIndex = NULL) const;
/**
* Get name of force associated w/ computed results
*
* @return force name(s); if more than one force active in computation,
* then names are concatenated and separated by '::' (e.g., 'NB_FORCE::GBSA_OBC_FORCE')
*/
std::string getForceName() const;
/**
* Get platform name
*
* @param index index of platform (0 or 1)
*
* @return platform name
*
* @throws OpenMMException if index is not 0 or 1
*/
std::string getPlatformName(int index) const;
/**
* Register index of two entries that differ by a specified tolerance
*
* @param index inconsistent index
*
*/
void registerInconsistentForceIndex(int index, int value = 1);
/**
* Clear list of entries that differ by a specified tolerance
*
*/
void clearInconsistentForceIndexList();
/**
* Get list of entries that differ by a specified tolerance
*
*/
void getInconsistentForceIndexList(std::vector<int>& inconsistentIndices) const;
/**
* Get number of entries in inconsistent index list
*
*/
int getNumberOfInconsistentForceEntries() const;
/**
* Return true if nans were detected
*
* @return true if nans were detected
*/
int nansDetected() const;
/**
* Determine if force norms are valid
*
* @param tolerance tolerance
*/
void compareForceNorms(double tolerance);
/**
* Determine if forces are valid
*
* @param tolerance tolerance
*/
void compareForces(double tolerance);
private:
// computed potential energies and forces fror two platforms
double _potentialEnergies[2];
std::vector<Vec3> _forces[2];
// platform and force names
std::string _platforms[2];
std::vector<std::string> _forceNames;
// force norms and stat entries
std::vector<double> _norms[2];
std::vector<double> _normStatVectors[2];
// map of indicies w/ inconsistent force entries
std::map<int, int> _inconsistentForceIndicies;
// if set, then nans detected
int _nansDetected;
/**
* Calculate norms of vectors
*
*/
void _calculateNorms();
/**
* Calculate norms of specified vector
*
*/
void _calculateNormOfForceVector(int forceIndex);
// stat indices
static const int STAT_AVG = 0;
static const int STAT_STD = 1;
static const int STAT_MIN = 2;
static const int STAT_ID1 = 3;
static const int STAT_MAX = 4;
static const int STAT_ID2 = 5;
static const int STAT_CNT = 6;
static const int STAT_END = 7;
/**
* Find vector stats
*
*/
void _findStatsForDouble(const std::vector<double>& array, std::vector<double>& statVector) const;
};
// Class used to compare forces/potential energies on two platforms
class ValidateOpenMMForces : public ValidateOpenMM {
public:
OPENMM_VALIDATE_EXPORT ValidateOpenMMForces();
OPENMM_VALIDATE_EXPORT ~ValidateOpenMMForces();
/**
* Validate force/energy by comparing the results between the forces/energies computed on user-provided context platform
* with Reference platform
*
* @param context context reference
* @param summaryString output summary string of results of comparison (optional)
*
* @return number of inconsistent entries
*/
int OPENMM_VALIDATE_EXPORT compareWithReferencePlatform(Context& context, std::string* summaryString = NULL);
/**
* Validate force/energy by comparing the results between the forces/energies computed on two different platforms
*
* @param context context reference
* @param compareForces indices of force to be tested
* @param platform1 first platform to compute forces
* @param platform2 second platform to compute forces
*
* @return ForceValidationResult reference containing results of force/energy computations
* on the two input platforms
*/
ForceValidationResult* compareForce(Context& context, std::vector<int>& compareForces,
Platform& platform1, Platform& platform2) const;
/**
* Compare individual forces by comparing calculations across two platforms (platform associated w/ input context and
* comparisonPlatform)
*
* @param context context reference
* @param platform comparsion platform reference
* @param forceValidationResults output vector of ForceValidationResult ptrs (user is responsible for deleting
* individual ForceValidationResult objects)
*/
void compareOpenMMForces(Context& context, Platform& comparisonPlatform, std::vector<ForceValidationResult*>& forceValidationResults) const;
/**
* Determine if results are consistent
*
* @param forceValidationResults vector of ForceValidationResult ptrs to check if forces are consistent
*/
void checkForInconsistentForceEntries(std::vector<ForceValidationResult*>& forceValidationResults) const;
/**
* Get total number of force entries that are inconsistent
*
* @param forceValidationResults vector of ForceValidationResult ptrs to check if forces are consistent
*/
int getTotalNumberOfInconsistentForceEntries(std::vector<ForceValidationResult*>& forceValidationResults) const;
/**
* Get summary string of results
*
* @param forceValidationResults vector of ForceValidationResult ptrs
*/
std::string getSummary(std::vector<ForceValidationResult*>& forceValidationResults) const;
/**
* Set force tolerance
*
* @param tolerance force tolerance
*/
void setForceTolerance(double tolerance);
/**
* Get force tolerance
*
* @return force tolerance
*/
double getForceTolerance() const;
/*
* Get force tolerance for specified force
*
* @param forceName name of force
*
* @return force tolerance
*
* */
double getForceTolerance(const std::string& forceName) const;
/*
* Get max errors to print in summary string
*
* @return max errors to print
*
* */
int getMaxErrorsToPrint() const;
/*
* Set max errors to print in summary string
*
* @param maxErrorsToPrint max errors to print
*
* */
void setMaxErrorsToPrint(int maxErrorsToPrint);
/*
* Return true if force is not to be validated (Andersen thermostat, CM motion remover, ...)
*
* @param forceName force name
*
* @return true if force is not currently validated
**/
int isExcludedForce(std::string forceName) const;
private:
// initialize class entries
void _initialize();
/*
* Format output line
*
* @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;
std::vector<ForceValidationResult*> _forceValidationResults;
// max errors to print
int _maxErrorsToPrint;
// tolerence
double _forceTolerance;
// map of force tolerances to type (name)
StringDoubleMap _forceTolerances;
// forces to be excluded from validation
StringIntMap _forcesToBeExcluded;
};
} // namespace OpenMM
#endif /*VALIDATE_OPENMM_FORCES_H_*/
#ifndef OPENMM_VALIDATE_WINDOW_INCLUDE_H_
#define OPENMM_VALIDATE_WINDOW_INCLUDE_H_
/*
* Shared libraries are messy in Visual Studio. We have to distinguish three
* cases:
* (1) this header is being used to build the OpenMMValidate shared library
* (dllexport)
* (2) this header is being used by a *client* of the OpenMMValidate shared
* library (dllimport)
* (3) we are building the OpenMMValidate static library, or the client is
* being compiled with the expectation of linking with the
* OpenMMValidate static library (nothing special needed)
* In the CMake script for building this library, we define one of the symbols
* OpenMMValidate_BUILDING_{SHARED|STATIC}_LIBRARY
* Client code normally has no special symbol defined, in which case we'll
* assume it wants to use the shared library. However, if the client defines
* the symbol OPENMM_VALIDATE_USE_STATIC_LIBRARIES we'll suppress the dllimport so
* that the client code can be linked with static libraries. Note that
* the client symbol is not library dependent, while the library symbols
* affect only the OpenMMValidate library, meaning that other libraries can
* be clients of this one. However, we are assuming all-static or all-shared.
*/
#ifdef _MSC_VER
// We don't want to hear about how sprintf is "unsafe".
#pragma warning(disable:4996)
#if defined(OPENMM_VALIDATE_BUILDING_SHARED_LIBRARY)
#define OPENMM_VALIDATE_EXPORT __declspec(dllexport)
// Keep MS VC++ quiet about lack of dll export of private members.
#pragma warning(disable:4251)
#elif defined(OPENMM_VALIDATE_BUILDING_STATIC_LIBRARY) || defined(OPENMM_VALIDATE_USE_STATIC_LIBRARIES)
#define OPENMM_VALIDATE_EXPORT
#else
#define OPENMM_VALIDATE_EXPORT __declspec(dllimport) // i.e., a client of a shared library
#endif
#else
#define OPENMM_VALIDATE_EXPORT // Linux, Mac
#endif
#endif // OPENMM_VALIDATE_WINDOW_INCLUDE_H_
This diff is collapsed.
This diff is collapsed.
......@@ -48,7 +48,6 @@
#include "openmm/CustomManyParticleForce.h"
#include "openmm/CustomTorsionForce.h"
#include "openmm/GBSAOBCForce.h"
#include "openmm/GBVIForce.h"
#include "openmm/HarmonicAngleForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/KernelImpl.h"
......@@ -667,35 +666,6 @@ public:
virtual void copyParametersToContext(ContextImpl& context, const GBSAOBCForce& force) = 0;
};
/**
* This kernel is invoked by GBVIForce to calculate the forces acting on the system and the energy of the system.
*/
class CalcGBVIForceKernel : public KernelImpl {
public:
static std::string Name() {
return "CalcGBVIForce";
}
CalcGBVIForceKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
}
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the GBVIForce this kernel will be used for
* @param scaledRadii scaled radii
*/
virtual void initialize(const System& system, const GBVIForce& force, const std::vector<double>& scaledRadii) = 0;
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
virtual double execute(ContextImpl& context, bool includeForces, bool includeEnergy) = 0;
};
/**
* This kernel is invoked by CustomGBForce to calculate the forces acting on the system and the energy of the system.
*/
......
......@@ -36,6 +36,7 @@
#include "openmm/BrownianIntegrator.h"
#include "openmm/CMAPTorsionForce.h"
#include "openmm/CMMotionRemover.h"
#include "openmm/CompoundIntegrator.h"
#include "openmm/CustomBondForce.h"
#include "openmm/CustomCentroidBondForce.h"
#include "openmm/CustomCompoundBondForce.h"
......@@ -49,7 +50,6 @@
#include "openmm/CustomNonbondedForce.h"
#include "openmm/Force.h"
#include "openmm/GBSAOBCForce.h"
#include "openmm/GBVIForce.h"
#include "openmm/HarmonicAngleForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/Integrator.h"
......
......@@ -85,8 +85,8 @@ public:
* Get the energy values of a map.
*
* @param index the index of the map for which to get energy values
* @param size the size of the map along each dimension
* @param energy the energy values for the map. This must be of length size*size.
* @param[out] size the size of the map along each dimension
* @param[out] energy the energy values for the map. This must be of length size*size.
* The element energy[i+size*j] contains the energy when the first
* torsion angle equals i*2*PI/size and the second torsion angle
* equals j*2*PI/size.
......@@ -122,15 +122,15 @@ public:
* Get the force field parameters for a CMAP torsion term.
*
* @param index the index of the torsion for which to get parameters
* @param map the index of the map to use for this term
* @param a1 the index of the first particle forming the first torsion
* @param a2 the index of the second particle forming the first torsion
* @param a3 the index of the third particle forming the first torsion
* @param a4 the index of the fourth particle forming the first torsion
* @param b1 the index of the first particle forming the second torsion
* @param b2 the index of the second particle forming the second torsion
* @param b3 the index of the third particle forming the second torsion
* @param b4 the index of the fourth particle forming the second torsion
* @param[out] map the index of the map to use for this term
* @param[out] a1 the index of the first particle forming the first torsion
* @param[out] a2 the index of the second particle forming the first torsion
* @param[out] a3 the index of the third particle forming the first torsion
* @param[out] a4 the index of the fourth particle forming the first torsion
* @param[out] b1 the index of the first particle forming the second torsion
* @param[out] b2 the index of the second particle forming the second torsion
* @param[out] b3 the index of the third particle forming the second torsion
* @param[out] b4 the index of the fourth particle forming the second torsion
*/
void getTorsionParameters(int index, int& map, int& a1, int& a2, int& a3, int& a4, int& b1, int& b2, int& b3, int& b4) const;
/**
......
#ifndef OPENMM_COMPOUNDINTEGRATOR_H_
#define OPENMM_COMPOUNDINTEGRATOR_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) 2015 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "Integrator.h"
#include "openmm/Kernel.h"
#include "internal/windowsExport.h"
namespace OpenMM {
/**
* This class allows you to use multiple integration algorithms within a single simulation,
* switching back and forth between them. To use it, create whatever other Integrators
* you need, then add all of them to a CustomIntegrator:
*
* <tt><pre>
* CompoundIntegrator compoundIntegrator;
* compoundIntegrator.addIntegrator(new VerletIntegrator(0.001));
* compoundIntegrator.addIntegrator(new LangevinIntegrator(300.0, 1.0, 0.001));
* </pre></tt>
*
* Next create a Context, specifying the CompoundIntegrator as the Integrator to use for
* the Context:
*
* <tt><pre>
* Context context(system, compoundIntegrator);
* </pre></tt>
*
* Finally, call setCurrentIntegrator() to set which Integrator is active. That one will
* be used for all calls to step() until the next time you change it.
*
* <tt><pre>
* compoundIntegrator.setCurrentIntegrator(0);
* compoundIntegrator.step(1000); // Take 1000 steps of Verlet dynamics
* compoundIntegrator.setCurrentIntegrator(1);
* compoundIntegrator.step(1000); // Take 1000 steps of Langevin dynamics
* </pre></tt>
*
* When switching between integrators, it is important to make sure they are compatible with
* each other, and that they will interpret the positions and velocities in the same way.
* Remember that leapfrog style integrators assume the positions and velocities are offset
* from each other by half a time step. When switching between a leapfrog and non-leapfrog
* integrator, you must first adjust the velocities to avoid introducing error. This is also
* true when switching between two leapfrog integrators that use different step sizes,
* since they will interpret the velocities as corresponding to different times.
*/
class OPENMM_EXPORT CompoundIntegrator : public Integrator {
public:
/**
* Create a CompoundIntegrator.
*/
explicit CompoundIntegrator();
~CompoundIntegrator();
/**
* Get the number of Integrators that have been added to this CompoundIntegrator.
*/
int getNumIntegrators() const;
/**
* Add an Integrator to this CompoundIntegrator. The Integrator object should have
* been created on the heap with the "new" operator. The CompoundIntegrator takes over
* ownership of it, and deletes it when the CompoundIntegrator itself is deleted.
* All Integrators must be added before the Context is created.
*
* @param integrator the Integrator to add
* @return the index of the Integrator that was added
*/
int addIntegrator(Integrator* integrator);
/**
* Get a reference to one of the Integrators that have been added to this CompoundIntegrator.
*
* @param index the index of the Integrator to get
*/
Integrator& getIntegrator(int index);
/**
* Get a const reference to one of the Integrators that have been added to this CompoundIntegrator.
*
* @param index the index of the Integrator to get
*/
const Integrator& getIntegrator(int index) const;
/**
* Get the index of the current Integrator.
*/
int getCurrentIntegrator() const;
/**
* Set the current Integrator.
*
* @param index the index of the Integrator to use
*/
void setCurrentIntegrator(int index);
/**
* Get the size of each time step, in picoseconds. This method calls getStepSize() on
* whichever Integrator has been set as current.
*
* @return the step size, measured in ps
*/
double getStepSize() const;
/**
* Set the size of each time step, in picoseconds. This method calls setStepSize() on
* whichever Integrator has been set as current.
*
* @param size the step size, measured in ps
*/
void setStepSize(double size);
/**
* Get the distance tolerance within which constraints are maintained, as a fraction of the constrained distance.
* This method calls getConstraintTolerance() on whichever Integrator has been set as current.
*/
double getConstraintTolerance() const;
/**
* Set the distance tolerance within which constraints are maintained, as a fraction of the constrained distance.
* This method calls setConstraintTolerance() on whichever Integrator has been set as current.
*/
void setConstraintTolerance(double tol);
/**
* Advance a simulation through time by taking a series of time steps. This method
* calls step() on whichever Integrator has been set as current.
*
* @param steps the number of time steps to take
*/
void step(int steps);
protected:
/**
* This will be called by the Context when it is created. It informs the Integrator
* of what context it will be integrating, and gives it a chance to do any necessary initialization.
* It will also get called again if the application calls reinitialize() on the Context.
*
* The implementation calls initialize() on each Integrator that has been added to this CompoundIntegrator.
*/
void initialize(ContextImpl& context);
/**
* This will be called by the Context when it is destroyed to let the Integrator do any necessary
* cleanup. It will also get called again if the application calls reinitialize() on the Context.
*
* The implementation calls cleanup() on each Integrator that has been added to this CompoundIntegrator.
*/
void cleanup();
/**
* Get the names of all Kernels used by this Integrator.
*
* The implementation returns the union of all kernel names required by all Integrators that have been added.
*/
std::vector<std::string> getKernelNames();
/**
* Compute the kinetic energy of the system at the current time.
*
* The implementation calls computeKineticEnergy() on whichever Integrator has been set as current.
*/
double computeKineticEnergy();
private:
int currentIntegrator;
std::vector<Integrator*> integrators;
};
} // namespace OpenMM
#endif /*OPENMM_COMPOUNDINTEGRATOR_H_*/
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2013 Stanford University and the Authors. *
* Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -165,6 +165,11 @@ public:
* @param randomSeed the random number seed to use when selecting velocities
*/
void setVelocitiesToTemperature(double temperature, int randomSeed=osrngseed());
/**
* Get all adjustable parameters that have been defined by Force objects in the System, along
* with their current values.
*/
const std::map<std::string, double>& getParameters() const;
/**
* Get the value of an adjustable parameter defined by a Force object in the System.
*
......
......@@ -159,7 +159,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -176,10 +176,10 @@ public:
* Get the force field parameters for an angle term.
*
* @param index the index of the angle for which to get parameters
* @param particle1 the index of the first particle connected by the angle
* @param particle2 the index of the second particle connected by the angle
* @param particle3 the index of the third particle connected by the angle
* @param parameters the list of parameters for the angle
* @param[out] particle1 the index of the first particle connected by the angle
* @param[out] particle2 the index of the second particle connected by the angle
* @param[out] particle3 the index of the third particle connected by the angle
* @param[out] parameters the list of parameters for the angle
*/
void getAngleParameters(int index, int& particle1, int& particle2, int& particle3, std::vector<double>& parameters) const;
/**
......
......@@ -159,7 +159,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -175,9 +175,9 @@ public:
* Get the force field parameters for a bond term.
*
* @param index the index of the bond for which to get parameters
* @param particle1 the index of the first particle connected by the bond
* @param particle2 the index of the second particle connected by the bond
* @param parameters the list of parameters for the bond
* @param[out] particle1 the index of the first particle connected by the bond
* @param[out] particle2 the index of the second particle connected by the bond
* @param[out] parameters the list of parameters for the bond
*/
void getBondParameters(int index, int& particle1, int& particle2, std::vector<double>& parameters) const;
/**
......
......@@ -226,7 +226,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -242,8 +242,8 @@ public:
* Get the properties of a group.
*
* @param index the index of the group to get
* @param particles the indices of the particles in the group
* @param weights the weight used for each particle when computing the center position.
* @param[out] particles the indices of the particles in the group
* @param[out] weights the weight used for each particle when computing the center position.
* If no weights were specified, this vector will be empty indicating that particle
* masses should be used as weights.
*/
......@@ -269,8 +269,8 @@ public:
* Get the properties of a bond.
*
* @param index the index of the bond to get
* @param groups the indices of the groups in the bond
* @param parameters the list of per-bond parameter values for the bond
* @param[out] groups the indices of the groups in the bond
* @param[out] parameters the list of per-bond parameter values for the bond
*/
void getBondParameters(int index, std::vector<int>& groups, std::vector<double>& parameters) const;
/**
......
......@@ -209,7 +209,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -224,8 +224,8 @@ public:
* Get the properties of a bond.
*
* @param index the index of the bond to get
* @param particles the indices of the particles in the bond
* @param parameters the list of per-bond parameter values for the bond
* @param[out] particles the indices of the particles in the bond
* @param[out] parameters the list of per-bond parameter values for the bond
*/
void getBondParameters(int index, std::vector<int>& particles, std::vector<double>& parameters) const;
/**
......
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