Commit 0b5d58d7 authored by Charlles Abreu's avatar Charlles Abreu
Browse files

Conflict resolution in TestSplineFilter.cpp

parents 9026dbe7 b0d13582
...@@ -2,9 +2,9 @@ jobs: ...@@ -2,9 +2,9 @@ jobs:
# Configure, build, install, and test job # Configure, build, install, and test job
- job: 'windows_build' - job: 'windows_build'
displayName: 'Windows VS2015' displayName: 'Windows VS2017'
pool: pool:
vmImage: 'vs2015-win2012r2' vmImage: 'vs2017-win2016'
timeoutInMinutes: 360 timeoutInMinutes: 360
variables: variables:
llvm.version: '7.0.1' llvm.version: '7.0.1'
...@@ -54,7 +54,7 @@ jobs: ...@@ -54,7 +54,7 @@ jobs:
# Download OpenCL Headers and build the ICD loader # Download OpenCL Headers and build the ICD loader
- script: | - script: |
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
mkdir opencl mkdir opencl
cd opencl cd opencl
wget https://www.khronos.org/registry/cl/specs/opencl-icd-1.2.11.0.tgz -O opencl-icd-1.2.11.0.tgz wget https://www.khronos.org/registry/cl/specs/opencl-icd-1.2.11.0.tgz -O opencl-icd-1.2.11.0.tgz
...@@ -67,7 +67,9 @@ jobs: ...@@ -67,7 +67,9 @@ jobs:
move .\OpenCL-Headers-master\CL\*.h .\inc\CL\ move .\OpenCL-Headers-master\CL\*.h .\inc\CL\
mkdir lib > $null mkdir lib > $null
cd lib cd lib
cmake -G Ninja .. cmake -G Ninja .. ^
-DCMAKE_CXX_COMPILER=cl.exe ^
-DCMAKE_C_COMPILER=cl.exe
cmake --build . ^ cmake --build . ^
-- -j %NUMBER_OF_PROCESSORS% -- -j %NUMBER_OF_PROCESSORS%
displayName: "Download and install OpenCL" displayName: "Download and install OpenCL"
...@@ -75,12 +77,14 @@ jobs: ...@@ -75,12 +77,14 @@ jobs:
# Configure # Configure
- script: | - script: |
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
mkdir build & cd build mkdir build & cd build
cmake -G Ninja ^ cmake -G Ninja ^
-DOPENCL_INCLUDE_DIR=$(Pipeline.Workspace)/opencl/inc ^ -DOPENCL_INCLUDE_DIR=$(Pipeline.Workspace)/opencl/inc ^
-DOPENCL_LIBRARY=$(Pipeline.Workspace)/opencl/lib/OpenCL.lib ^ -DOPENCL_LIBRARY=$(Pipeline.Workspace)/opencl/lib/OpenCL.lib ^
-DCMAKE_BUILD_TYPE=$(cmake.build.type) ^ -DCMAKE_BUILD_TYPE=$(cmake.build.type) ^
-DCMAKE_CXX_COMPILER=cl.exe ^
-DCMAKE_C_COMPILER=cl.exe ^
-DCMAKE_INSTALL_PREFIX=../install ^ -DCMAKE_INSTALL_PREFIX=../install ^
-DOPENMM_BUILD_EXAMPLES=OFF ^ -DOPENMM_BUILD_EXAMPLES=OFF ^
-DOPENMM_BUILD_OPENCL_TESTS=OFF ^ -DOPENMM_BUILD_OPENCL_TESTS=OFF ^
...@@ -89,7 +93,7 @@ jobs: ...@@ -89,7 +93,7 @@ jobs:
workingDirectory: $(Build.BinariesDirectory) workingDirectory: $(Build.BinariesDirectory)
# Build # Build
- script: | - script: |
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
cmake --build . ^ cmake --build . ^
--config $(cmake.build.type) ^ --config $(cmake.build.type) ^
-- -j %NUMBER_OF_PROCESSORS% -- -j %NUMBER_OF_PROCESSORS%
......
...@@ -3,7 +3,6 @@ language: python ...@@ -3,7 +3,6 @@ language: python
addons: addons:
apt: apt:
packages: packages:
- gromacs
- doxygen - doxygen
- python-numpy - python-numpy
- python-scipy - python-scipy
...@@ -104,6 +103,24 @@ jobs: ...@@ -104,6 +103,24 @@ jobs:
CXX=$CCACHE/g++ CXX=$CCACHE/g++
CMAKE_FLAGS="" CMAKE_FLAGS=""
- sudo: required
dist: bionic
python: "3.8"
name: "PPC"
arch: ppc64le
env: OPENCL=false
CUDA=false
CMAKE_FLAGS=""
- sudo: required
dist: bionic
python: "3.8"
name: "ARM"
arch: arm64
env: OPENCL=false
CUDA=false
CMAKE_FLAGS=""
before_install: before_install:
- START_TIME=$(date +%s) - START_TIME=$(date +%s)
- wget http://anaconda.org/omnia/ccache/3.2.4/download/${TRAVIS_OS_NAME}-64/ccache-3.2.4-0.tar.bz2 - wget http://anaconda.org/omnia/ccache/3.2.4/download/${TRAVIS_OS_NAME}-64/ccache-3.2.4-0.tar.bz2
...@@ -114,10 +131,21 @@ before_install: ...@@ -114,10 +131,21 @@ before_install:
brew install -y https://raw.githubusercontent.com/Homebrew/homebrew-core/5b680fb58fedfb00cd07a7f69f5a621bb9240f3b/Formula/doxygen.rb; brew install -y https://raw.githubusercontent.com/Homebrew/homebrew-core/5b680fb58fedfb00cd07a7f69f5a621bb9240f3b/Formula/doxygen.rb;
sudo pip install -U pytest --ignore-installed six; sudo pip install -U pytest --ignore-installed six;
fi fi
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then # The cmake version installed by apt on ARM and PPC is very old,
CMAKE_URL="http://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz"; # so download a newer version.
mkdir $HOME/cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C $HOME/cmake; - if [[ "${TRAVIS_CPU_ARCH}" == "ppc64le" ]]; then
export PATH=${HOME}/cmake/bin:${PATH}; sudo apt-get install libuv1 rhash libstdc++6;
wget https://anaconda.org/conda-forge/cmake/3.17.0/download/linux-ppc64le/cmake-3.17.0-hfb1cb51_0.tar.bz2;
mkdir $HOME/cmake;
tar -xjvf cmake-3.17.0-hfb1cb51_0.tar.bz2 -C $HOME/cmake;
export PATH=$HOME/cmake/bin:$PATH;
fi
- if [[ "${TRAVIS_CPU_ARCH}" == "arm64" ]]; then
sudo apt-get install libuv1 rhash libstdc++6;
wget https://anaconda.org/conda-forge/cmake/3.17.0/download/linux-aarch64/cmake-3.17.0-h28c56e5_0.tar.bz2;
mkdir $HOME/cmake;
tar -xjvf cmake-3.17.0-h28c56e5_0.tar.bz2 -C $HOME/cmake;
export PATH=$HOME/cmake/bin:$PATH;
fi fi
- if [[ "$OPENCL" == "true" ]]; then - if [[ "$OPENCL" == "true" ]]; then
wget http://s3.amazonaws.com/omnia-ci/AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2; wget http://s3.amazonaws.com/omnia-ci/AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2;
...@@ -132,17 +160,20 @@ before_install: ...@@ -132,17 +160,20 @@ before_install:
${AMDAPPSDK}/bin/x86_64/clinfo; ${AMDAPPSDK}/bin/x86_64/clinfo;
sudo apt-get install -y libgl1-mesa-dev; sudo apt-get install -y libgl1-mesa-dev;
fi fi
# Install SWIG and Cython for Python wrappers. However, testing CUDA and # Install packages needed for Python: SWIG, Cython, and Gromacs (used by some tests).
# OpenCL, we skip the Python wrapper for speed. We're not using anaconda # We do this differently on different platforms. Possibly some of this could be unified.
# python, but this is a fast way to get an apparently functional precompiled - if [[ "$OPENCL" == "false" && "$CUDA" == "false" && "$TRAVIS_OS_NAME" == "linux" && "${TRAVIS_CPU_ARCH}" != "ppc64le" && "${TRAVIS_CPU_ARCH}" != "arm64" ]]; then
# build of swig that's more modern than what's in apt.
- if [[ "$OPENCL" == "false" && "$CUDA" == "false" && "$TRAVIS_OS_NAME" == "linux" ]]; then
wget http://anaconda.org/omnia/swig/3.0.7/download/linux-64/swig-3.0.7-0.tar.bz2; wget http://anaconda.org/omnia/swig/3.0.7/download/linux-64/swig-3.0.7-0.tar.bz2;
mkdir $HOME/swig; mkdir $HOME/swig;
tar -xjvf swig-3.0.7-0.tar.bz2 -C $HOME/swig; tar -xjvf swig-3.0.7-0.tar.bz2 -C $HOME/swig;
export PATH=$HOME/swig/bin:$PATH; export PATH=$HOME/swig/bin:$PATH;
export SWIG_LIB=$HOME/swig/share/swig/3.0.7; export SWIG_LIB=$HOME/swig/share/swig/3.0.7;
pip install cython; pip install cython;
sudo apt-get install gromacs;
fi
- if [[ "${TRAVIS_CPU_ARCH}" == "ppc64le" || "${TRAVIS_CPU_ARCH}" == "arm64" ]]; then
sudo apt-get install swig;
pip install cython;
fi fi
- if [[ "$OPENCL" == "false" && "$CUDA" == "false" && "$TRAVIS_OS_NAME" == "osx" ]]; then - if [[ "$OPENCL" == "false" && "$CUDA" == "false" && "$TRAVIS_OS_NAME" == "osx" ]]; then
wget http://anaconda.org/omnia/swig/3.0.7/download/osx-64/swig-3.0.7-0.tar.bz2; wget http://anaconda.org/omnia/swig/3.0.7/download/osx-64/swig-3.0.7-0.tar.bz2;
......
...@@ -41,11 +41,15 @@ if ("${TARGET_ARCH}" MATCHES "x86_64|i386") ...@@ -41,11 +41,15 @@ if ("${TARGET_ARCH}" MATCHES "x86_64|i386")
endif() endif()
if ("${TARGET_ARCH}" MATCHES "arm") if ("${TARGET_ARCH}" MATCHES "arm")
set(ARM ON) set(ARM ON)
add_compile_definitions(__ARM__=1) if ("${TARGET_ARCH}" MATCHES "armv8")
add_definitions(-D__ARM64__=1)
else()
add_definitions(-D__ARM__=1)
endif()
endif() endif()
if ("${TARGET_ARCH}" MATCHES "ppc") if ("${TARGET_ARCH}" MATCHES "ppc")
set(PPC ON) set(PPC ON)
add_compile_definitions(__PPC__=1) add_definitions(-D__PPC__=1)
endif() endif()
# Where to install # Where to install
......
...@@ -24,19 +24,40 @@ ...@@ -24,19 +24,40 @@
# OF THE POSSIBILITY OF SUCH DAMAGE. # OF THE POSSIBILITY OF SUCH DAMAGE.
# Based on the Qt 5 processor detection code, so should be very accurate # Based on the Qt 5 processor detection code, so should be very accurate
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h # https://github.com/qt/qtbase/blob/9a6a847/src/corelib/global/qprocessordetection.h
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) # Currently handles arm / aarch64 (v5, v6, v7, v8), x86 (32/64), ia64, and ppc (32/64)
# Regarding POWER/PowerPC, just as is noted in the Qt source, # Regarding POWER/PowerPC, just as is noted in the Qt source,
# "There are many more known variants/revisions that we do not handle/detect." # "There are many more known variants/revisions that we do not handle/detect."
set(archdetect_c_code " set(archdetect_c_code "
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) #define _STR(x) #x
#if defined(__ARM_ARCH_7__) \\ #define STR(x) _STR(x)
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || \\
defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)
#if defined(__ARM_ARCH) && __ARM_ARCH > 1
#pragma message \"cmake_ARCH armv\" STR(__ARM_ARCH)
#error
#elif defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM > 1
#pragma message \"cmake_ARCH armv\" STR(__TARGET_ARCH_ARM)
#error
#elif defined(_M_ARM) && _M_ARM > 1
#error cmake_ARCH arm ## __M_ARM
#elif defined(__ARM64_ARCH_8__) \\
|| defined(__aarch64__) \\
|| defined(__ARMv8__) \\
|| defined(__ARMv8_A__) \\
|| defined(_M_ARM64)
#error cmake_ARCH armv8
#elif defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\ || defined(__ARM_ARCH_7A__) \\
|| defined(__ARM_ARCH_7R__) \\ || defined(__ARM_ARCH_7R__) \\
|| defined(__ARM_ARCH_7M__) \\ || defined(__ARM_ARCH_7M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) || defined(__ARM_ARCH_7S__) \\
|| defined(_ARM_ARCH_7) \\
|| defined(__CORE_CORTEXA__)
#error cmake_ARCH armv7 #error cmake_ARCH armv7
#elif defined(__ARM_ARCH_6__) \\ #elif defined(__ARM_ARCH_6__) \\
|| defined(__ARM_ARCH_6J__) \\ || defined(__ARM_ARCH_6J__) \\
...@@ -44,11 +65,10 @@ set(archdetect_c_code " ...@@ -44,11 +65,10 @@ set(archdetect_c_code "
|| defined(__ARM_ARCH_6Z__) \\ || defined(__ARM_ARCH_6Z__) \\
|| defined(__ARM_ARCH_6K__) \\ || defined(__ARM_ARCH_6K__) \\
|| defined(__ARM_ARCH_6ZK__) \\ || defined(__ARM_ARCH_6ZK__) \\
|| defined(__ARM_ARCH_6M__) \\ || defined(__ARM_ARCH_6M__)
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
#error cmake_ARCH armv6 #error cmake_ARCH armv6
#elif defined(__ARM_ARCH_5TEJ__) \\ #elif defined(__ARM_ARCH_5TEJ__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) || defined(__ARM_ARCH_5TE__)
#error cmake_ARCH armv5 #error cmake_ARCH armv5
#else #else
#error cmake_ARCH arm #error cmake_ARCH arm
......
...@@ -272,7 +272,7 @@ removeType = [False]*len(types) ...@@ -272,7 +272,7 @@ removeType = [False]*len(types)
for res in residueAtoms: for res in residueAtoms:
if res not in residueBonds: if res not in residueBonds:
continue continue
atomBonds = [[] for atom in residueAtoms[res]] atomBonds = [[] for _ in residueAtoms[res]]
for bond in residueBonds[res]: for bond in residueBonds[res]:
atomBonds[bond[0]].append(bond[1]) atomBonds[bond[0]].append(bond[1])
atomBonds[bond[1]].append(bond[0]) atomBonds[bond[1]].append(bond[0])
...@@ -361,7 +361,7 @@ for tor in reversed(torsions): ...@@ -361,7 +361,7 @@ for tor in reversed(torsions):
tag = " <Proper class1=\"%s\" class2=\"%s\" class3=\"%s\" class4=\"%s\"" % signature tag = " <Proper class1=\"%s\" class2=\"%s\" class3=\"%s\" class4=\"%s\"" % signature
i = 4 i = 4
while i < len(tor): while i < len(tor):
index = i/3 index = i//3
periodicity = int(float(tor[i+2])) periodicity = int(float(tor[i+2]))
phase = float(tor[i+1])*math.pi/180.0 phase = float(tor[i+1])*math.pi/180.0
k = tor[i]*4.184 k = tor[i]*4.184
...@@ -380,7 +380,7 @@ for tor in reversed(impropers): ...@@ -380,7 +380,7 @@ for tor in reversed(impropers):
tag = " <Improper class1=\"%s\" class2=\"%s\" class3=\"%s\" class4=\"%s\"" % signature tag = " <Improper class1=\"%s\" class2=\"%s\" class3=\"%s\" class4=\"%s\"" % signature
i = 4 i = 4
while i < len(tor): while i < len(tor):
index = i/3 index = i//3
periodicity = int(float(tor[i+2])) periodicity = int(float(tor[i+2]))
phase = float(tor[i+1])*math.pi/180.0 phase = float(tor[i+1])*math.pi/180.0
k = float(tor[i])*4.184 k = float(tor[i])*4.184
......
...@@ -23,7 +23,7 @@ nbfixes = {} ...@@ -23,7 +23,7 @@ nbfixes = {}
def getFieldPairs(fields): def getFieldPairs(fields):
pairs = [] pairs = []
for i in range(len(fields)/2): for i in range(len(fields)//2):
pairs.append((fields[2*i], fields[2*i+1])) pairs.append((fields[2*i], fields[2*i+1]))
return pairs return pairs
...@@ -361,7 +361,7 @@ print(' <CMAPTorsionForce>') ...@@ -361,7 +361,7 @@ print(' <CMAPTorsionForce>')
for values in sorted(uniqueCmaps, key=lambda x: uniqueCmaps[x]): for values in sorted(uniqueCmaps, key=lambda x: uniqueCmaps[x]):
print(' <Map>') print(' <Map>')
size = int(math.sqrt(len(values))) size = int(math.sqrt(len(values)))
shift = size/2 shift = size//2
scale = kilocalories_per_mole.conversion_factor_to(kilojoules_per_mole) scale = kilocalories_per_mole.conversion_factor_to(kilojoules_per_mole)
# Convert the ordering from the one used by CHARMM to the one used by OpenMM. # Convert the ordering from the one used by CHARMM to the one used by OpenMM.
reordered = [0]*len(values) reordered = [0]*len(values)
......
...@@ -1123,6 +1123,13 @@ algorithm\ :cite:`Tuckerman1992`. This allows some forces in the system to be e ...@@ -1123,6 +1123,13 @@ algorithm\ :cite:`Tuckerman1992`. This allows some forces in the system to be e
frequently than others. For details on how to use it, consult the API frequently than others. For details on how to use it, consult the API
documentation. documentation.
Multiple Time Step Langevin Integrator
--------------------------------------
:class:`MTSLangevinIntegrator` is similar to :class:`MTSIntegrator`, but it uses
the Langevin method to perform constant temperature dynamics. For details on
how to use it, consult the API documentation.
Compound Integrator Compound Integrator
------------------- -------------------
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
// NOTE: This file has been changed from the orginal source distribution.
#ifndef __IRR_TYPES_H_INCLUDED__ #ifndef __IRR_TYPES_H_INCLUDED__
#define __IRR_TYPES_H_INCLUDED__ #define __IRR_TYPES_H_INCLUDED__
...@@ -80,7 +82,8 @@ typedef unsigned short wchar_t; ...@@ -80,7 +82,8 @@ typedef unsigned short wchar_t;
//! define a break macro for debugging only in Win32 mode. //! define a break macro for debugging only in Win32 mode.
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG) #if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3} // NOTE: This line has been changed and originally used '_asm int 3' to break into the debugger.
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) { __debugbreak(); }
#else #else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) #define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif #endif
......
...@@ -191,6 +191,9 @@ Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B) ...@@ -191,6 +191,9 @@ Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B)
if (B.dim1() != n) if (B.dim1() != n)
return Array2D<Real>(); return Array2D<Real>();
if (!isspd)
return Arran2D<Real>();
Array2D<Real> X = B.copy(); Array2D<Real> X = B.copy();
int nx = B.dim2(); int nx = B.dim2();
...@@ -224,9 +227,9 @@ Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B) ...@@ -224,9 +227,9 @@ Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B)
// Solve L*y = b; // Solve L*y = b;
for (int j=0; j< nx; j++) for (int k = 0; k < n; k++)
{ {
for (int k = 0; k < n; k++) for (int j=0; j< nx; j++)
{ {
for (int i = 0; i < k; i++) for (int i = 0; i < k; i++)
X[k][j] -= X[i][j]*L_[k][i]; X[k][j] -= X[i][j]*L_[k][i];
...@@ -235,9 +238,9 @@ Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B) ...@@ -235,9 +238,9 @@ Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B)
} }
// Solve L'*X = Y; // Solve L'*X = Y;
for (int j=0; j<nx; j++) for (int k = n-1; k >= 0; k--)
{ {
for (int k = n-1; k >= 0; k--) for (int j=0; j<nx; j++)
{ {
for (int i = k+1; i < n; i++) for (int i = k+1; i < n; i++)
X[k][j] -= X[i][j]*L_[i][k]; X[k][j] -= X[i][j]*L_[i][k];
......
...@@ -663,21 +663,20 @@ class Eigenvalue ...@@ -663,21 +663,20 @@ class Eigenvalue
// Double QR step involving rows l:n and columns m:n // Double QR step involving rows l:n and columns m:n
for (int k = m; k <= n-1; k++) { for (int k = m; k <= n-1; k++) {
int notlast = (k != n-1); bool notlast = (k != n-1);
if (k != m) { if (k != m) {
p = H[k][k-1]; p = H[k][k-1];
q = H[k+1][k-1]; q = H[k+1][k-1];
r = (notlast ? H[k+2][k-1] : 0.0); r = (notlast ? H[k+2][k-1] : 0.0);
x = abs(p) + abs(q) + abs(r); x = abs(p) + abs(q) + abs(r);
if (x != 0.0) { if (x == 0.0) {
p = p / x; continue;
q = q / x;
r = r / x;
} }
p = p / x;
q = q / x;
r = r / x;
} }
if (x == 0.0) {
break;
}
s = sqrt(p * p + q * q + r * r); s = sqrt(p * p + q * q + r * r);
if (p < 0) { if (p < 0) {
s = -s; s = -s;
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
// for min(), max() below // for min(), max() below
#include <cmath> #include <cmath>
// for abs() below // for abs() below
#include <limits>
// for numeric_limits
using namespace TNT; using namespace TNT;
using namespace std; using namespace std;
...@@ -247,6 +249,7 @@ class SVD ...@@ -247,6 +249,7 @@ class SVD
int pp = p-1; int pp = p-1;
int iter = 0; int iter = 0;
Real eps(pow(2.0,-52.0)); Real eps(pow(2.0,-52.0));
Real tiny = numeric_limits<Real>::min();
while (p > 0) { while (p > 0) {
int k=0; int k=0;
int kase=0; int kase=0;
...@@ -267,7 +270,7 @@ class SVD ...@@ -267,7 +270,7 @@ class SVD
if (k == -1) { if (k == -1) {
break; break;
} }
if (abs(e[k]) <= eps*(abs(s[k]) + abs(s[k+1]))) { if (abs(e[k]) <= tiny + eps*(abs(s[k]) + abs(s[k+1]))) {
e[k] = 0.0; e[k] = 0.0;
break; break;
} }
...@@ -282,7 +285,7 @@ class SVD ...@@ -282,7 +285,7 @@ class SVD
} }
Real t( (ks != p ? abs(e[ks]) : 0.) + Real t( (ks != p ? abs(e[ks]) : 0.) +
(ks != k+1 ? abs(e[ks-1]) : 0.)); (ks != k+1 ? abs(e[ks-1]) : 0.));
if (abs(s[ks]) <= eps*t) { if (abs(s[ks]) <= tiny + eps*t) {
s[ks] = 0.0; s[ks] = 0.0;
break; break;
} }
......
...@@ -8,9 +8,13 @@ ...@@ -8,9 +8,13 @@
* (VC11 has _MSC_VER=1700). * (VC11 has _MSC_VER=1700).
*/ */
#if defined(_MSC_VER) #if defined(_MSC_VER) || defined(__MINGW32__)
#if !defined(M_PI)
#define M_PI 3.14159265358979323846264338327950288 #define M_PI 3.14159265358979323846264338327950288
#endif
#endif
#if defined(_MSC_VER)
#if _MSC_VER <= 1700 // 1700 is VC11, 1800 is VC12 #if _MSC_VER <= 1700 // 1700 is VC11, 1800 is VC12
/*************************** /***************************
* erf.cpp * erf.cpp
......
#if defined(__ANDROID__) #if defined(__ARM__) || defined(__ARM64__)
#include "neon_mathfun.h" #include "neon_mathfun.h"
#else #else
#if !defined(__PNACL__) #if !defined(__PNACL__)
......
...@@ -1063,16 +1063,16 @@ public: ...@@ -1063,16 +1063,16 @@ public:
/** /**
* This kernel is invoked by NoseHooverIntegrator to take one time step. * This kernel is invoked by NoseHooverIntegrator to take one time step.
*/ */
class IntegrateVelocityVerletStepKernel : public KernelImpl { class IntegrateNoseHooverStepKernel : public KernelImpl {
public: public:
static std::string Name() { static std::string Name() {
return "IntegrateVelocityVerletStep"; return "IntegrateNoseHooverStep";
} }
IntegrateVelocityVerletStepKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) { IntegrateNoseHooverStepKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
} }
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
* @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
* @param integrator the NoseHooverIntegrator this kernel will be used for * @param integrator the NoseHooverIntegrator this kernel will be used for
*/ */
...@@ -1093,6 +1093,49 @@ public: ...@@ -1093,6 +1093,49 @@ public:
* @param integrator the NoseHooverIntegrator this kernel is being used for * @param integrator the NoseHooverIntegrator this kernel is being used for
*/ */
virtual double computeKineticEnergy(ContextImpl& context, const NoseHooverIntegrator& integrator) = 0; virtual double computeKineticEnergy(ContextImpl& context, const NoseHooverIntegrator& integrator) = 0;
/**
* Execute the kernel that propagates the Nose Hoover chain and determines the velocity scale factor.
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the object describing the chain to be propagated.
* @param kineticEnergy the {center of mass, relative} kineticEnergies of the particles being thermostated by this chain.
* @param timeStep the time step used by the integrator.
* @return the velocity scale factor to apply to the particles associated with this heat bath.
*/
virtual std::pair<double, double> propagateChain(ContextImpl& context, const NoseHooverChain &noseHooverChain, std::pair<double, double> kineticEnergy, double timeStep) = 0;
/**
* Execute the kernal that computes the total (kinetic + potential) heat bath energy.
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the chain whose energy is to be determined.
* @return the total heat bath energy.
*/
virtual double computeHeatBathEnergy(ContextImpl& context, const NoseHooverChain &noseHooverChain) = 0;
/**
* Execute the kernel that computes the kinetic energy for a subset of atoms,
* or the relative kinetic energy of Drude particles with respect to their parent atoms
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the chain whose energy is to be determined.
* @param downloadValue whether the computed value should be downloaded and returned.
*/
virtual std::pair<double, double> computeMaskedKineticEnergy(ContextImpl& context, const NoseHooverChain &noseHooverChain, bool downloadValue) = 0;
/**
* Execute the kernel that scales the velocities of particles associated with a nose hoover chain
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the chain whose energy is to be determined.
* @param scaleFactor the multiplicative factor by which {absolute, relative} velocities are scaled.
*/
virtual void scaleVelocities(ContextImpl& context, const NoseHooverChain &noseHooverChain, std::pair<double, double> scaleFactor) = 0;
/**
* Write the chain states to a checkpoint.
*/
virtual void createCheckpoint(ContextImpl& context, std::ostream& stream) const = 0;
/**
* Load the chain states from a checkpoint.
*/
virtual void loadCheckpoint(ContextImpl& context, std::istream& stream) = 0;
}; };
/** /**
...@@ -1360,58 +1403,6 @@ public: ...@@ -1360,58 +1403,6 @@ public:
virtual void execute(ContextImpl& context) = 0; virtual void execute(ContextImpl& context) = 0;
}; };
/**
* This kernel is invoked by NoseHooverChainThermostat at the beginning and end of each time step
* to update the Nose-Hoover chain.
*/
class NoseHooverChainKernel : public KernelImpl {
public:
static std::string Name() {
return "NoseHooverChain";
}
NoseHooverChainKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
}
/**
* Initialize the kernel.
*/
virtual void initialize() = 0;
/**
* Execute the kernel that propagates the Nose Hoover chain and determines the velocity scale factor.
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the object describing the chain to be propagated.
* @param kineticEnergy the {center of mass, relative} kineticEnergies of the particles being thermostated by this chain.
* @param timeStep the time step used by the integrator.
* @return the velocity scale factor to apply to the particles associated with this heat bath.
*/
virtual std::pair<double, double> propagateChain(ContextImpl& context, const NoseHooverChain &noseHooverChain, std::pair<double, double> kineticEnergy, double timeStep) = 0;
/**
* Execute the kernal that computes the total (kinetic + potential) heat bath energy.
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the chain whose energy is to be determined.
* @return the total heat bath energy.
*/
virtual double computeHeatBathEnergy(ContextImpl& context, const NoseHooverChain &noseHooverChain) = 0;
/**
* Execute the kernel that computes the kinetic energy for a subset of atoms,
* or the relative kinetic energy of Drude particles with respect to their parent atoms
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the chain whose energy is to be determined.
* @param downloadValue whether the computed value should be downloaded and returned.
*/
virtual std::pair<double, double> computeMaskedKineticEnergy(ContextImpl& context, const NoseHooverChain &noseHooverChain, bool downloadValue) = 0;
/**
* Execute the kernel that scales the velocities of particles associated with a nose hoover chain
*
* @param context the context in which to execute this kernel
* @param noseHooverChain the chain whose energy is to be determined.
* @param scaleFactor the multiplicative factor by which {absolute, relative} velocities are scaled.
*/
virtual void scaleVelocities(ContextImpl& context, const NoseHooverChain &noseHooverChain, std::pair<double, double> scaleFactor) = 0;
};
/** /**
* This kernel is invoked by MonteCarloBarostat to adjust the periodic box volume * This kernel is invoked by MonteCarloBarostat to adjust the periodic box volume
*/ */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2015-2016 Stanford University and the Authors. * * Portions copyright (c) 2015-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -194,6 +194,16 @@ protected: ...@@ -194,6 +194,16 @@ protected:
double getVelocityTimeOffset() const { double getVelocityTimeOffset() const {
return getIntegrator(0).getVelocityTimeOffset(); return getIntegrator(0).getVelocityTimeOffset();
} }
/**
* This is called while writing checkpoints. It gives the integrator a chance to write
* its own data.
*/
void createCheckpoint(std::ostream& stream) const;
/**
* This is called while loading a checkpoint. The integrator should read in whatever
* data it wrote in createCheckpoint() and update its internal state accordingly.
*/
void loadCheckpoint(std::istream& stream);
private: private:
int currentIntegrator; int currentIntegrator;
std::vector<Integrator*> integrators; std::vector<Integrator*> integrators;
......
...@@ -668,6 +668,16 @@ protected: ...@@ -668,6 +668,16 @@ protected:
* Get whether computeKineticEnergy() expects forces to have been computed. * Get whether computeKineticEnergy() expects forces to have been computed.
*/ */
bool kineticEnergyRequiresForce() const; bool kineticEnergyRequiresForce() const;
/**
* This is called while writing checkpoints. It gives the integrator a chance to write
* its own data.
*/
void createCheckpoint(std::ostream& stream) const;
/**
* This is called while loading a checkpoint. The integrator should read in whatever
* data it wrote in createCheckpoint() and update its internal state accordingly.
*/
void loadCheckpoint(std::istream& stream);
private: private:
class ComputationInfo; class ComputationInfo;
class FunctionInfo; class FunctionInfo;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "State.h" #include "State.h"
#include "Vec3.h" #include "Vec3.h"
#include <iosfwd>
#include <map> #include <map>
#include <vector> #include <vector>
#include "internal/windowsExport.h" #include "internal/windowsExport.h"
...@@ -151,6 +152,18 @@ protected: ...@@ -151,6 +152,18 @@ protected:
virtual double getVelocityTimeOffset() const { virtual double getVelocityTimeOffset() const {
return 0.0; return 0.0;
} }
/**
* This is called while writing checkpoints. It gives the integrator a chance to write
* its own data. The default implementation does nothing.
*/
virtual void createCheckpoint(std::ostream& stream) const {
}
/**
* This is called while loading a checkpoint. The integrator should read in whatever
* data it wrote in createCheckpoint() and update its internal state accordingly.
*/
virtual void loadCheckpoint(std::istream& stream) {
}
private: private:
double stepSize, constraintTol; double stepSize, constraintTol;
}; };
......
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
* interact with this chain * interact with this chain
* @param chainLength the length of (number of particles in) this heat bath * @param chainLength the length of (number of particles in) this heat bath
* @param numMTS the number of multi time steps used to propagate this chain * @param numMTS the number of multi time steps used to propagate this chain
* @param numYoshidaSuzuki the number of Yoshida Suzuki steps used to propagate this chain (1, 3, or 5). * @param numYoshidaSuzuki the number of Yoshida Suzuki steps used to propagate this chain (1, 3, 5, or 7).
* @param chainID the chain id used to distinguish this Nose-Hoover chain from others that may * @param chainID the chain id used to distinguish this Nose-Hoover chain from others that may
* be used to control a different set of particles, e.g. for Drude oscillators * be used to control a different set of particles, e.g. for Drude oscillators
* @param thermostatedAtoms the list of atoms to be handled by this thermostat * @param thermostatedAtoms the list of atoms to be handled by this thermostat
......
...@@ -45,13 +45,14 @@ namespace OpenMM { ...@@ -45,13 +45,14 @@ namespace OpenMM {
class System; class System;
/** /**
* This is an Integrator which simulates a System using one or more Nose Hoover chain * This is an Integrator which simulates a System using one or more Nose Hoover chain
* thermostats, using the velocity Verlet propagation algorithm. * thermostats, using the "middle" leapfrog propagation algorithm described in
* J. Phys. Chem. A 2019, 123, 6056-6079.
*/ */
class OPENMM_EXPORT NoseHooverIntegrator : public Integrator { class OPENMM_EXPORT NoseHooverIntegrator : public Integrator {
public: public:
/** /**
* Create a NoseHooverIntegrator. This version creates a bare velocity Verlet integrator * Create a NoseHooverIntegrator. This version creates a bare leapfrog integrator
* with no thermostats; any thermostats should be added by calling addThermostat. * with no thermostats; any thermostats should be added by calling addThermostat.
* *
* @param stepSize the step size with which to integrate the system (in picoseconds) * @param stepSize the step size with which to integrate the system (in picoseconds)
...@@ -66,12 +67,12 @@ public: ...@@ -66,12 +67,12 @@ public:
* @param chainLength the number of beads in the Nose-Hoover chain. * @param chainLength the number of beads in the Nose-Hoover chain.
* @param numMTS the number of step in the multiple time step chain propagation algorithm. * @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition * @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition
* used in the chain propagation algorithm (must be 1, 3, or 5). * used in the chain propagation algorithm (must be 1, 3, 5, or 7).
*/ */
explicit NoseHooverIntegrator(double temperature, double collisionFrequency, double stepSize, explicit NoseHooverIntegrator(double temperature, double collisionFrequency, double stepSize,
int chainLength = 3, int numMTS = 3, int numYoshidaSuzuki = 3); int chainLength = 3, int numMTS = 3, int numYoshidaSuzuki = 7);
virtual ~NoseHooverIntegrator(); ~NoseHooverIntegrator();
/** /**
* Advance a simulation through time by taking a series of time steps. * Advance a simulation through time by taking a series of time steps.
* *
...@@ -86,7 +87,7 @@ public: ...@@ -86,7 +87,7 @@ public:
* @param chainLength the number of beads in the Nose-Hoover chain * @param chainLength the number of beads in the Nose-Hoover chain
* @param numMTS the number of step in the multiple time step chain propagation algorithm. * @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition * @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition
* used in the chain propagation algorithm (must be 1, 3, or 5). * used in the chain propagation algorithm (must be 1, 3, 5, or 7).
*/ */
int addThermostat(double temperature, double collisionFrequency, int addThermostat(double temperature, double collisionFrequency,
int chainLength, int numMTS, int numYoshidaSuzuki); int chainLength, int numMTS, int numYoshidaSuzuki);
...@@ -110,13 +111,13 @@ public: ...@@ -110,13 +111,13 @@ public:
* @param chainLength the number of beads in the Nose-Hoover chain. * @param chainLength the number of beads in the Nose-Hoover chain.
* @param numMTS the number of step in the multiple time step chain propagation algorithm. * @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition * @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition
* used in the chain propagation algorithm (must be 1, 3, or 5). * used in the chain propagation algorithm (must be 1, 3, 5, or 7).
*/ */
int addSubsystemThermostat(const std::vector<int>& thermostatedParticles, int addSubsystemThermostat(const std::vector<int>& thermostatedParticles,
const std::vector< std::pair< int, int> >& thermostatedPairs, const std::vector< std::pair< int, int> >& thermostatedPairs,
double temperature, double collisionFrequency, double relativeTemperature, double temperature, double collisionFrequency, double relativeTemperature,
double relativeCollisionFrequency, double relativeCollisionFrequency,
int chainLength = 3, int numMTS = 3, int numYoshidaSuzuki = 3); int chainLength = 3, int numMTS = 3, int numYoshidaSuzuki = 7);
/** /**
* Get the temperature of the i-th chain for controling absolute particle motion (in Kelvin). * Get the temperature of the i-th chain for controling absolute particle motion (in Kelvin).
* *
...@@ -194,18 +195,6 @@ public: ...@@ -194,18 +195,6 @@ public:
* @param chainID the index of the Nose-Hoover chain thermostat (default=0). * @param chainID the index of the Nose-Hoover chain thermostat (default=0).
*/ */
const NoseHooverChain& getThermostat(int chainID=0) const ; const NoseHooverChain& getThermostat(int chainID=0) const ;
/**
* This will be called by the Context when the user modifies aspects of the context state, such
* as positions, velocities, or parameters. This gives the Integrator a chance to discard cached
* information. This is <i>only</i> called when the user modifies information using methods of the Context
* object. It is <i>not</i> called when a ForceImpl object modifies state information in its updateContextState()
* method (unless the ForceImpl calls a Context method to perform the modification).
*
* @param changed this specifies what aspect of the Context was changed
*/
virtual void stateChanged(State::DataType changed) {
if (State::Positions == changed) forcesAreValid = false;
}
/** /**
* Return false, if this integrator was set up with the 'default constructor' that thermostats the whole system, * Return false, if this integrator was set up with the 'default constructor' that thermostats the whole system,
* true otherwise. Required for serialization. * true otherwise. Required for serialization.
...@@ -232,15 +221,6 @@ public: ...@@ -232,15 +221,6 @@ public:
*/ */
const std::vector<std::tuple<int, int, double> > & getAllThermostatedPairs() const { return allPairs; } const std::vector<std::tuple<int, int, double> > & getAllThermostatedPairs() const { return allPairs; }
protected: protected:
/**
* Advance any Nose-Hoover chains associated with this integrator and determine
* scale factor for the velocities.
*
* @param kineticEnergy the {absolute, relative} kinetic energies of the system that the chain is thermostating
* @param chainID id of the Nose-Hoover-Chain
* @return the scale factor to be applied to the velocities of the particles thermostated by the chain.
*/
std::pair<double, double> propagateChain(std::pair<double, double> kineticEnergy, int chainID=0);
/** /**
* This will be called by the Context when it is created. It informs the Integrator * 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. * of what context it will be integrating, and gives it a chance to do any necessary initialization.
...@@ -256,6 +236,18 @@ protected: ...@@ -256,6 +236,18 @@ protected:
* cleanup. It will also get called again if the application calls reinitialize() on the Context. * cleanup. It will also get called again if the application calls reinitialize() on the Context.
*/ */
void cleanup(); void cleanup();
/**
* This will be called by the Context when the user modifies aspects of the context state, such
* as positions, velocities, or parameters. This gives the Integrator a chance to discard cached
* information. This is <i>only</i> called when the user modifies information using methods of the Context
* object. It is <i>not</i> called when a ForceImpl object modifies state information in its updateContextState()
* method (unless the ForceImpl calls a Context method to perform the modification).
*
* @param changed this specifies what aspect of the Context was changed
*/
void stateChanged(State::DataType changed) {
if (State::Positions == changed) forcesAreValid = false;
}
/** /**
* Get the names of all Kernels used by this Integrator. * Get the names of all Kernels used by this Integrator.
*/ */
...@@ -263,17 +255,27 @@ protected: ...@@ -263,17 +255,27 @@ protected:
/** /**
* Compute the kinetic energy of the system at the current time. * Compute the kinetic energy of the system at the current time.
*/ */
virtual double computeKineticEnergy(); double computeKineticEnergy();
/** /**
* Computing kinetic energy for this integrator does not require forces. * Computing kinetic energy for this integrator does not require forces.
*/ */
bool kineticEnergyRequiresForce() const override; bool kineticEnergyRequiresForce() const;
/**
* This is called while writing checkpoints. It gives the integrator a chance to write
* its own data.
*/
void createCheckpoint(std::ostream& stream) const;
/**
* This is called while loading a checkpoint. The integrator should read in whatever
* data it wrote in createCheckpoint() and update its internal state accordingly.
*/
void loadCheckpoint(std::istream& stream);
std::vector<NoseHooverChain> noseHooverChains; std::vector<NoseHooverChain> noseHooverChains;
std::vector<int> allAtoms; std::vector<int> allAtoms;
std::vector<std::tuple<int, int, double> > allPairs; std::vector<std::tuple<int, int, double> > allPairs;
bool forcesAreValid; bool forcesAreValid;
Kernel vvKernel, nhcKernel; Kernel kernel;
bool hasSubsystemThermostats_; bool hasSubsystemThermostats_;
double maxPairDistance_; double maxPairDistance_;
}; };
......
...@@ -93,7 +93,8 @@ static int getNumProcessors() { ...@@ -93,7 +93,8 @@ static int getNumProcessors() {
#ifdef WIN32 #ifdef WIN32
#define cpuid __cpuid #define cpuid __cpuid
#else #else
#if !defined(__ANDROID__) && !defined(__PNACL__) && !defined(__PPC__) #if !defined(__ANDROID__) && !defined(__PNACL__) && !defined(__PPC__) \
&& !defined(__ARM__) && !defined(__ARM64__)
static void cpuid(int cpuInfo[4], int infoType){ static void cpuid(int cpuInfo[4], int infoType){
#ifdef __LP64__ #ifdef __LP64__
__asm__ __volatile__ ( __asm__ __volatile__ (
......
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