Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
588a4c9d
"plugins/drude/vscode:/vscode.git/clone" did not exist on "512328b211a505e2cb0930246326aa8b19b6b3bb"
Commit
588a4c9d
authored
Dec 10, 2013
by
peastman
Browse files
Merged changes from main branch
parents
bbf3de23
ff6af025
Changes
77
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
220 additions
and
239 deletions
+220
-239
platforms/cpu/tests/TestCpuSettle.cpp
platforms/cpu/tests/TestCpuSettle.cpp
+116
-0
platforms/cuda/sharedTarget/CMakeLists.txt
platforms/cuda/sharedTarget/CMakeLists.txt
+4
-2
platforms/cuda/tests/CMakeLists.txt
platforms/cuda/tests/CMakeLists.txt
+3
-1
platforms/opencl/sharedTarget/CMakeLists.txt
platforms/opencl/sharedTarget/CMakeLists.txt
+1
-1
platforms/opencl/tests/CMakeLists.txt
platforms/opencl/tests/CMakeLists.txt
+3
-4
platforms/reference/include/ReferenceBrownianDynamics.h
platforms/reference/include/ReferenceBrownianDynamics.h
+2
-1
platforms/reference/include/ReferenceCCMAAlgorithm.h
platforms/reference/include/ReferenceCCMAAlgorithm.h
+6
-16
platforms/reference/include/ReferenceConstraintAlgorithm.h
platforms/reference/include/ReferenceConstraintAlgorithm.h
+4
-12
platforms/reference/include/ReferenceConstraints.h
platforms/reference/include/ReferenceConstraints.h
+8
-19
platforms/reference/include/ReferenceCustomDynamics.h
platforms/reference/include/ReferenceCustomDynamics.h
+2
-1
platforms/reference/include/ReferenceDynamics.h
platforms/reference/include/ReferenceDynamics.h
+2
-1
platforms/reference/include/ReferenceKernels.h
platforms/reference/include/ReferenceKernels.h
+7
-23
platforms/reference/include/ReferencePlatform.h
platforms/reference/include/ReferencePlatform.h
+3
-1
platforms/reference/include/ReferenceSETTLEAlgorithm.h
platforms/reference/include/ReferenceSETTLEAlgorithm.h
+17
-10
platforms/reference/include/ReferenceStochasticDynamics.h
platforms/reference/include/ReferenceStochasticDynamics.h
+2
-1
platforms/reference/include/ReferenceVariableStochasticDynamics.h
...s/reference/include/ReferenceVariableStochasticDynamics.h
+2
-1
platforms/reference/include/ReferenceVariableVerletDynamics.h
...forms/reference/include/ReferenceVariableVerletDynamics.h
+2
-1
platforms/reference/include/ReferenceVerletDynamics.h
platforms/reference/include/ReferenceVerletDynamics.h
+2
-1
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+29
-141
platforms/reference/src/ReferencePlatform.cpp
platforms/reference/src/ReferencePlatform.cpp
+5
-2
No files found.
platforms/cpu/tests/TestCpuSettle.cpp
0 → 100644
View file @
588a4c9d
/* -------------------------------------------------------------------------- *
* 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-2013 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. *
* -------------------------------------------------------------------------- */
/**
* This tests the CPU implementation of the SETTLE algorithm.
*/
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "CpuPlatform.h"
#include "openmm/NonbondedForce.h"
#include "openmm/System.h"
#include "openmm/LangevinIntegrator.h"
#include "sfmt/SFMT.h"
#include <iostream>
#include <vector>
using
namespace
OpenMM
;
using
namespace
std
;
void
testConstraints
()
{
const
int
numMolecules
=
10
;
const
int
numParticles
=
numMolecules
*
3
;
const
int
numConstraints
=
numMolecules
*
3
;
const
double
temp
=
100.0
;
CpuPlatform
platform
;
System
system
;
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.001
);
integrator
.
setConstraintTolerance
(
1e-5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numMolecules
;
++
i
)
{
system
.
addParticle
(
16.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
forceField
->
addParticle
(
-
0.82
,
0.317
,
0.65
);
forceField
->
addParticle
(
0.41
,
1.0
,
0.0
);
forceField
->
addParticle
(
0.41
,
1.0
,
0.0
);
system
.
addConstraint
(
i
*
3
,
i
*
3
+
1
,
0.1
);
system
.
addConstraint
(
i
*
3
,
i
*
3
+
2
,
0.1
);
system
.
addConstraint
(
i
*
3
+
1
,
i
*
3
+
2
,
0.163
);
}
system
.
addForce
(
forceField
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
velocities
(
numParticles
);
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
for
(
int
i
=
0
;
i
<
numMolecules
;
++
i
)
{
positions
[
i
*
3
]
=
Vec3
((
i
%
4
)
*
0.4
,
(
i
/
4
)
*
0.4
,
0
);
positions
[
i
*
3
+
1
]
=
positions
[
i
*
3
]
+
Vec3
(
0.1
,
0
,
0
);
positions
[
i
*
3
+
2
]
=
positions
[
i
*
3
]
+
Vec3
(
-
0.03333
,
0.09428
,
0
);
velocities
[
i
*
3
]
=
Vec3
(
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
);
velocities
[
i
*
3
+
1
]
=
Vec3
(
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
);
velocities
[
i
*
3
+
2
]
=
Vec3
(
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
);
}
context
.
setPositions
(
positions
);
context
.
setVelocities
(
velocities
);
// Simulate it and see whether the constraints remain satisfied.
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
integrator
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Positions
|
State
::
Forces
);
for
(
int
j
=
0
;
j
<
numConstraints
;
++
j
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
j
,
particle1
,
particle2
,
distance
);
Vec3
p1
=
state
.
getPositions
()[
particle1
];
Vec3
p2
=
state
.
getPositions
()[
particle2
];
double
dist
=
std
::
sqrt
((
p1
[
0
]
-
p2
[
0
])
*
(
p1
[
0
]
-
p2
[
0
])
+
(
p1
[
1
]
-
p2
[
1
])
*
(
p1
[
1
]
-
p2
[
1
])
+
(
p1
[
2
]
-
p2
[
2
])
*
(
p1
[
2
]
-
p2
[
2
]));
ASSERT_EQUAL_TOL
(
distance
,
dist
,
1e-5
);
}
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
testConstraints
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
platforms/cuda/sharedTarget/CMakeLists.txt
View file @
588a4c9d
...
@@ -19,9 +19,11 @@ ELSE (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
...
@@ -19,9 +19,11 @@ ELSE (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
MAIN_OPENMM_LIB
}
${
CUDA_CUDA_LIBRARY
}
${
CUDA_cufft_LIBRARY
}
${
PTHREADS_LIB
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
MAIN_OPENMM_LIB
}
${
CUDA_CUDA_LIBRARY
}
${
CUDA_cufft_LIBRARY
}
${
PTHREADS_LIB
}
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_CUDA_BUILDING_SHARED_LIBRARY"
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_CUDA_BUILDING_SHARED_LIBRARY"
)
IF
(
APPLE
)
IF
(
APPLE
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES LINK_FLAGS
"-F/Library/Frameworks -framework CUDA"
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-F/Library/Frameworks -framework CUDA"
)
ELSE
(
APPLE
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
)
ENDIF
(
APPLE
)
ENDIF
(
APPLE
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
SHARED_TARGET
}
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
SHARED_TARGET
}
)
platforms/cuda/tests/CMakeLists.txt
View file @
588a4c9d
...
@@ -26,7 +26,9 @@ FOREACH(TEST_PROG ${TEST_PROGS})
...
@@ -26,7 +26,9 @@ FOREACH(TEST_PROG ${TEST_PROGS})
ADD_EXECUTABLE
(
${
TEST_ROOT
}
${
TEST_PROG
}
)
ADD_EXECUTABLE
(
${
TEST_ROOT
}
${
TEST_PROG
}
)
TARGET_LINK_LIBRARIES
(
${
TEST_ROOT
}
${
SHARED_TARGET
}
)
TARGET_LINK_LIBRARIES
(
${
TEST_ROOT
}
${
SHARED_TARGET
}
)
IF
(
APPLE
)
IF
(
APPLE
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES LINK_FLAGS
"-F/Library/Frameworks -framework CUDA"
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-F/Library/Frameworks -framework CUDA"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
)
ELSE
(
APPLE
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
)
ENDIF
(
APPLE
)
ENDIF
(
APPLE
)
IF
(
${
TEST_ROOT
}
STREQUAL
"TestCUDAGBSAOBCForce2"
)
IF
(
${
TEST_ROOT
}
STREQUAL
"TestCUDAGBSAOBCForce2"
)
...
...
platforms/opencl/sharedTarget/CMakeLists.txt
View file @
588a4c9d
...
@@ -19,6 +19,6 @@ ELSE (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
...
@@ -19,6 +19,6 @@ ELSE (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
MAIN_OPENMM_LIB
}
${
OPENCL_LIBRARIES
}
${
PTHREADS_LIB
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
MAIN_OPENMM_LIB
}
${
OPENCL_LIBRARIES
}
${
PTHREADS_LIB
}
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES
COMPILE_FLAGS
"
-msse2 -DOPENMM_OPENCL_BUILDING_SHARED_LIBRARY"
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES
LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-msse2 -DOPENMM_OPENCL_BUILDING_SHARED_LIBRARY"
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
SHARED_TARGET
}
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
SHARED_TARGET
}
)
platforms/opencl/tests/CMakeLists.txt
View file @
588a4c9d
...
@@ -25,6 +25,7 @@ FOREACH(TEST_PROG ${TEST_PROGS})
...
@@ -25,6 +25,7 @@ FOREACH(TEST_PROG ${TEST_PROGS})
# Link with shared library
# Link with shared library
ADD_EXECUTABLE
(
${
TEST_ROOT
}
${
TEST_PROG
}
)
ADD_EXECUTABLE
(
${
TEST_ROOT
}
${
TEST_PROG
}
)
TARGET_LINK_LIBRARIES
(
${
TEST_ROOT
}
${
SHARED_TARGET
}
)
TARGET_LINK_LIBRARIES
(
${
TEST_ROOT
}
${
SHARED_TARGET
}
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
)
IF
(
${
TEST_ROOT
}
STREQUAL
"TestOpenCLGBSAOBCForce2"
)
IF
(
${
TEST_ROOT
}
STREQUAL
"TestOpenCLGBSAOBCForce2"
)
...
@@ -39,13 +40,13 @@ FOREACH(TEST_PROG ${TEST_PROGS})
...
@@ -39,13 +40,13 @@ FOREACH(TEST_PROG ${TEST_PROGS})
SET
(
NONBOND_TEST
"TestOpenCLNonbondedForce2"
)
SET
(
NONBOND_TEST
"TestOpenCLNonbondedForce2"
)
ADD_EXECUTABLE
(
${
NONBOND_TEST
}
${
TEST_PROG
}
)
ADD_EXECUTABLE
(
${
NONBOND_TEST
}
${
TEST_PROG
}
)
SET_TARGET_PROPERTIES
(
${
NONBOND_TEST
}
PROPERTIES
COMPILE_FLAGS
"-msse2
${
NONBOND_DEFINE_STRING
}
"
)
SET_TARGET_PROPERTIES
(
${
NONBOND_TEST
}
PROPERTIES
LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
${
NONBOND_DEFINE_STRING
}
"
)
ADD_TEST
(
${
NONBOND_TEST
}
${
EXECUTABLE_OUTPUT_PATH
}
/
${
NONBOND_TEST
}
)
ADD_TEST
(
${
NONBOND_TEST
}
${
EXECUTABLE_OUTPUT_PATH
}
/
${
NONBOND_TEST
}
)
# OBC
# OBC
SET
(
DEFINE_STRING
"
${
DEFINE_STRING
}
-DIMPLICIT_SOLVENT=1"
)
SET
(
DEFINE_STRING
"
${
DEFINE_STRING
}
-DIMPLICIT_SOLVENT=1"
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES
COMPILE_FLAGS
"-msse2
${
DEFINE_STRING
}
"
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES
LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
${
DEFINE_STRING
}
"
)
IF
(
INCLUDE_SERIALIZATION
)
IF
(
INCLUDE_SERIALIZATION
)
TARGET_LINK_LIBRARIES
(
${
NONBOND_TEST
}
${
SHARED_TARGET
}
${
SHARED_OPENMM_SERIALIZATION
}
)
TARGET_LINK_LIBRARIES
(
${
NONBOND_TEST
}
${
SHARED_TARGET
}
${
SHARED_OPENMM_SERIALIZATION
}
)
...
@@ -54,8 +55,6 @@ FOREACH(TEST_PROG ${TEST_PROGS})
...
@@ -54,8 +55,6 @@ FOREACH(TEST_PROG ${TEST_PROGS})
TARGET_LINK_LIBRARIES
(
${
NONBOND_TEST
}
${
SHARED_TARGET
}
)
TARGET_LINK_LIBRARIES
(
${
NONBOND_TEST
}
${
SHARED_TARGET
}
)
ENDIF
(
INCLUDE_SERIALIZATION
)
ENDIF
(
INCLUDE_SERIALIZATION
)
ELSE
(
${
TEST_ROOT
}
STREQUAL
"TestOpenCLGBSAOBCForce2"
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES COMPILE_FLAGS -msse2
)
ENDIF
(
${
TEST_ROOT
}
STREQUAL
"TestOpenCLGBSAOBCForce2"
)
ENDIF
(
${
TEST_ROOT
}
STREQUAL
"TestOpenCLGBSAOBCForce2"
)
ADD_TEST
(
${
TEST_ROOT
}
Single
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
single
)
ADD_TEST
(
${
TEST_ROOT
}
Single
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
single
)
IF
(
OPENMM_BUILD_OPENCL_DOUBLE_PRECISION_TESTS
)
IF
(
OPENMM_BUILD_OPENCL_DOUBLE_PRECISION_TESTS
)
...
...
platforms/reference/include/ReferenceBrownianDynamics.h
View file @
588a4c9d
...
@@ -79,11 +79,12 @@ class ReferenceBrownianDynamics : public ReferenceDynamics {
...
@@ -79,11 +79,12 @@ class ReferenceBrownianDynamics : public ReferenceDynamics {
@param velocities velocities
@param velocities velocities
@param forces forces
@param forces forces
@param masses atom masses
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
};
};
...
...
platforms/reference/include/ReferenceCCMAAlgorithm.h
View file @
588a4c9d
...
@@ -37,7 +37,6 @@ class OPENMM_EXPORT ReferenceCCMAAlgorithm : public ReferenceConstraintAlgorithm
...
@@ -37,7 +37,6 @@ class OPENMM_EXPORT ReferenceCCMAAlgorithm : public ReferenceConstraintAlgorithm
protected:
protected:
int
_maximumNumberOfIterations
;
int
_maximumNumberOfIterations
;
RealOpenMM
_tolerance
;
int
_numberOfConstraints
;
int
_numberOfConstraints
;
std
::
vector
<
std
::
pair
<
int
,
int
>
>
_atomIndices
;
std
::
vector
<
std
::
pair
<
int
,
int
>
>
_atomIndices
;
...
@@ -53,7 +52,7 @@ protected:
...
@@ -53,7 +52,7 @@ protected:
private:
private:
void
applyConstraints
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
applyConstraints
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
bool
constrainingVelocities
);
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
bool
constrainingVelocities
,
RealOpenMM
tolerance
);
public:
public:
class
AngleInfo
;
class
AngleInfo
;
...
@@ -67,9 +66,8 @@ public:
...
@@ -67,9 +66,8 @@ public:
* @param distance distances for constraints
* @param distance distances for constraints
* @param masses atom masses
* @param masses atom masses
* @param angles angle force field terms
* @param angles angle force field terms
* @param tolerance constraint tolerance
*/
*/
ReferenceCCMAAlgorithm
(
int
numberOfAtoms
,
int
numberOfConstraints
,
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>&
atomIndices
,
const
std
::
vector
<
RealOpenMM
>&
distance
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
vector
<
AngleInfo
>&
angles
,
RealOpenMM
tolerance
);
ReferenceCCMAAlgorithm
(
int
numberOfAtoms
,
int
numberOfConstraints
,
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>&
atomIndices
,
const
std
::
vector
<
RealOpenMM
>&
distance
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
vector
<
AngleInfo
>&
angles
);
~
ReferenceCCMAAlgorithm
(
);
~
ReferenceCCMAAlgorithm
(
);
...
@@ -88,25 +86,16 @@ public:
...
@@ -88,25 +86,16 @@ public:
*/
*/
void
setMaximumNumberOfIterations
(
int
maximumNumberOfIterations
);
void
setMaximumNumberOfIterations
(
int
maximumNumberOfIterations
);
/**
* Get the constraint tolerance.
*/
RealOpenMM
getTolerance
(
void
)
const
;
/**
* Set the constraint tolerance.
*/
void
setTolerance
(
RealOpenMM
tolerance
);
/**
/**
* Apply the constraint algorithm.
* Apply the constraint algorithm.
*
*
* @param atomCoordinates the original atom coordinates
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
/**
/**
* Apply the constraint algorithm to velocities.
* Apply the constraint algorithm to velocities.
...
@@ -114,9 +103,10 @@ public:
...
@@ -114,9 +103,10 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
};
};
class
ReferenceCCMAAlgorithm
::
AngleInfo
class
ReferenceCCMAAlgorithm
::
AngleInfo
...
...
platforms/reference/include/ReferenceConstraintAlgorithm.h
View file @
588a4c9d
...
@@ -36,25 +36,16 @@ public:
...
@@ -36,25 +36,16 @@ public:
virtual
~
ReferenceConstraintAlgorithm
()
{};
virtual
~
ReferenceConstraintAlgorithm
()
{};
/**
* Get the constraint tolerance.
*/
virtual
RealOpenMM
getTolerance
()
const
=
0
;
/**
* Set the constraint tolerance.
*/
virtual
void
setTolerance
(
RealOpenMM
tolerance
)
=
0
;
/**
/**
* Apply the constraint algorithm.
* Apply the constraint algorithm.
*
*
* @param atomCoordinates the original atom coordinates
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
virtual
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
virtual
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
)
=
0
;
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
)
=
0
;
/**
/**
* Apply the constraint algorithm to velocities.
* Apply the constraint algorithm to velocities.
...
@@ -62,9 +53,10 @@ public:
...
@@ -62,9 +53,10 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
virtual
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
virtual
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
)
=
0
;
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
)
=
0
;
};
};
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceConstraints.h
View file @
588a4c9d
...
@@ -33,8 +33,6 @@
...
@@ -33,8 +33,6 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "ReferenceConstraintAlgorithm.h"
#include "ReferenceConstraintAlgorithm.h"
#include "ReferenceCCMAAlgorithm.h"
#include "ReferenceSETTLEAlgorithm.h"
#include "openmm/System.h"
#include "openmm/System.h"
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -46,17 +44,8 @@ namespace OpenMM {
...
@@ -46,17 +44,8 @@ namespace OpenMM {
*/
*/
class
OPENMM_EXPORT
ReferenceConstraints
:
public
ReferenceConstraintAlgorithm
{
class
OPENMM_EXPORT
ReferenceConstraints
:
public
ReferenceConstraintAlgorithm
{
public:
public:
ReferenceConstraints
(
const
System
&
system
,
RealOpenMM
tolerance
);
ReferenceConstraints
(
const
System
&
system
);
~
ReferenceConstraints
();
virtual
~
ReferenceConstraints
();
/**
* Get the constraint tolerance.
*/
RealOpenMM
getTolerance
()
const
;
/**
* Set the constraint tolerance.
*/
void
setTolerance
(
RealOpenMM
tolerance
);
/**
/**
* Apply the constraint algorithm.
* Apply the constraint algorithm.
...
@@ -64,8 +53,9 @@ public:
...
@@ -64,8 +53,9 @@ public:
* @param atomCoordinates the original atom coordinates
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
/**
/**
* Apply the constraint algorithm to velocities.
* Apply the constraint algorithm to velocities.
...
@@ -73,12 +63,11 @@ public:
...
@@ -73,12 +63,11 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
private:
ReferenceConstraintAlgorithm
*
ccma
;
RealOpenMM
tolerance
;
ReferenceConstraintAlgorithm
*
settle
;
ReferenceCCMAAlgorithm
*
ccma
;
ReferenceSETTLEAlgorithm
*
settle
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/reference/include/ReferenceCustomDynamics.h
View file @
588a4c9d
...
@@ -92,12 +92,13 @@ public:
...
@@ -92,12 +92,13 @@ public:
@param globals a map containing values of global variables
@param globals a map containing values of global variables
@param perDof the values of per-DOF variables
@param perDof the values of per-DOF variables
@param forcesAreValid whether the current forces are valid or need to be recomputed
@param forcesAreValid whether the current forces are valid or need to be recomputed
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
update
(
OpenMM
::
ContextImpl
&
context
,
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
update
(
OpenMM
::
ContextImpl
&
context
,
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
map
<
std
::
string
,
RealOpenMM
>&
globals
,
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>&
perDof
,
bool
&
forcesAreValid
);
std
::
map
<
std
::
string
,
RealOpenMM
>&
globals
,
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>&
perDof
,
bool
&
forcesAreValid
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceDynamics.h
View file @
588a4c9d
...
@@ -145,11 +145,12 @@ class OPENMM_EXPORT ReferenceDynamics {
...
@@ -145,11 +145,12 @@ class OPENMM_EXPORT ReferenceDynamics {
@param velocities velocities
@param velocities velocities
@param forces forces
@param forces forces
@param masses atom masses
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
virtual
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
virtual
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceKernels.h
View file @
588a4c9d
...
@@ -191,7 +191,7 @@ private:
...
@@ -191,7 +191,7 @@ private:
class
ReferenceApplyConstraintsKernel
:
public
ApplyConstraintsKernel
{
class
ReferenceApplyConstraintsKernel
:
public
ApplyConstraintsKernel
{
public:
public:
ReferenceApplyConstraintsKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
ReferenceApplyConstraintsKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
ApplyConstraintsKernel
(
name
,
platform
),
data
(
data
)
,
constraints
(
0
)
{
ApplyConstraintsKernel
(
name
,
platform
),
data
(
data
)
{
}
}
~
ReferenceApplyConstraintsKernel
();
~
ReferenceApplyConstraintsKernel
();
/**
/**
...
@@ -216,12 +216,8 @@ public:
...
@@ -216,12 +216,8 @@ public:
void
applyToVelocities
(
ContextImpl
&
context
,
double
tol
);
void
applyToVelocities
(
ContextImpl
&
context
,
double
tol
);
private:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferencePlatform
::
PlatformData
&
data
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
inverseMasses
;
std
::
vector
<
RealOpenMM
>
inverseMasses
;
std
::
vector
<
std
::
pair
<
int
,
int
>
>
constraintIndices
;
std
::
vector
<
RealOpenMM
>
constraintDistances
;
int
numConstraints
;
};
};
/**
/**
...
@@ -871,7 +867,7 @@ private:
...
@@ -871,7 +867,7 @@ private:
class
ReferenceIntegrateVerletStepKernel
:
public
IntegrateVerletStepKernel
{
class
ReferenceIntegrateVerletStepKernel
:
public
IntegrateVerletStepKernel
{
public:
public:
ReferenceIntegrateVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVerletStepKernel
(
name
,
platform
),
ReferenceIntegrateVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVerletStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
}
~
ReferenceIntegrateVerletStepKernel
();
~
ReferenceIntegrateVerletStepKernel
();
/**
/**
...
@@ -898,9 +894,7 @@ public:
...
@@ -898,9 +894,7 @@ public:
private:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferencePlatform
::
PlatformData
&
data
;
ReferenceVerletDynamics
*
dynamics
;
ReferenceVerletDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevStepSize
;
double
prevStepSize
;
};
};
...
@@ -910,7 +904,7 @@ private:
...
@@ -910,7 +904,7 @@ private:
class
ReferenceIntegrateLangevinStepKernel
:
public
IntegrateLangevinStepKernel
{
class
ReferenceIntegrateLangevinStepKernel
:
public
IntegrateLangevinStepKernel
{
public:
public:
ReferenceIntegrateLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateLangevinStepKernel
(
name
,
platform
),
ReferenceIntegrateLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateLangevinStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
}
~
ReferenceIntegrateLangevinStepKernel
();
~
ReferenceIntegrateLangevinStepKernel
();
/**
/**
...
@@ -937,9 +931,7 @@ public:
...
@@ -937,9 +931,7 @@ public:
private:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferencePlatform
::
PlatformData
&
data
;
ReferenceStochasticDynamics
*
dynamics
;
ReferenceStochasticDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
};
};
...
@@ -949,7 +941,7 @@ private:
...
@@ -949,7 +941,7 @@ private:
class
ReferenceIntegrateBrownianStepKernel
:
public
IntegrateBrownianStepKernel
{
class
ReferenceIntegrateBrownianStepKernel
:
public
IntegrateBrownianStepKernel
{
public:
public:
ReferenceIntegrateBrownianStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateBrownianStepKernel
(
name
,
platform
),
ReferenceIntegrateBrownianStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateBrownianStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
}
~
ReferenceIntegrateBrownianStepKernel
();
~
ReferenceIntegrateBrownianStepKernel
();
/**
/**
...
@@ -976,9 +968,7 @@ public:
...
@@ -976,9 +968,7 @@ public:
private:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferencePlatform
::
PlatformData
&
data
;
ReferenceBrownianDynamics
*
dynamics
;
ReferenceBrownianDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
};
};
...
@@ -988,7 +978,7 @@ private:
...
@@ -988,7 +978,7 @@ private:
class
ReferenceIntegrateVariableLangevinStepKernel
:
public
IntegrateVariableLangevinStepKernel
{
class
ReferenceIntegrateVariableLangevinStepKernel
:
public
IntegrateVariableLangevinStepKernel
{
public:
public:
ReferenceIntegrateVariableLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVariableLangevinStepKernel
(
name
,
platform
),
ReferenceIntegrateVariableLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVariableLangevinStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
}
~
ReferenceIntegrateVariableLangevinStepKernel
();
~
ReferenceIntegrateVariableLangevinStepKernel
();
/**
/**
...
@@ -1017,9 +1007,7 @@ public:
...
@@ -1017,9 +1007,7 @@ public:
private:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferencePlatform
::
PlatformData
&
data
;
ReferenceVariableStochasticDynamics
*
dynamics
;
ReferenceVariableStochasticDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevTemp
,
prevFriction
,
prevErrorTol
;
double
prevTemp
,
prevFriction
,
prevErrorTol
;
};
};
...
@@ -1029,7 +1017,7 @@ private:
...
@@ -1029,7 +1017,7 @@ private:
class
ReferenceIntegrateVariableVerletStepKernel
:
public
IntegrateVariableVerletStepKernel
{
class
ReferenceIntegrateVariableVerletStepKernel
:
public
IntegrateVariableVerletStepKernel
{
public:
public:
ReferenceIntegrateVariableVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVariableVerletStepKernel
(
name
,
platform
),
ReferenceIntegrateVariableVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVariableVerletStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
}
~
ReferenceIntegrateVariableVerletStepKernel
();
~
ReferenceIntegrateVariableVerletStepKernel
();
/**
/**
...
@@ -1058,9 +1046,7 @@ public:
...
@@ -1058,9 +1046,7 @@ public:
private:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferencePlatform
::
PlatformData
&
data
;
ReferenceVariableVerletDynamics
*
dynamics
;
ReferenceVariableVerletDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevErrorTol
;
double
prevErrorTol
;
};
};
...
@@ -1070,7 +1056,7 @@ private:
...
@@ -1070,7 +1056,7 @@ private:
class
ReferenceIntegrateCustomStepKernel
:
public
IntegrateCustomStepKernel
{
class
ReferenceIntegrateCustomStepKernel
:
public
IntegrateCustomStepKernel
{
public:
public:
ReferenceIntegrateCustomStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateCustomStepKernel
(
name
,
platform
),
ReferenceIntegrateCustomStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateCustomStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
}
~
ReferenceIntegrateCustomStepKernel
();
~
ReferenceIntegrateCustomStepKernel
();
/**
/**
...
@@ -1135,10 +1121,8 @@ public:
...
@@ -1135,10 +1121,8 @@ public:
private:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferencePlatform
::
PlatformData
&
data
;
ReferenceCustomDynamics
*
dynamics
;
ReferenceCustomDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
,
globalValues
;
std
::
vector
<
RealOpenMM
>
masses
,
globalValues
;
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>
perDofValues
;
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>
perDofValues
;
int
numConstraints
;
};
};
/**
/**
...
...
platforms/reference/include/ReferencePlatform.h
View file @
588a4c9d
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "openmm/Platform.h"
#include "openmm/Platform.h"
#include "openmm/System.h"
#include "openmm/internal/windowsExport.h"
#include "openmm/internal/windowsExport.h"
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -57,7 +58,7 @@ public:
...
@@ -57,7 +58,7 @@ public:
class
ReferencePlatform
::
PlatformData
{
class
ReferencePlatform
::
PlatformData
{
public:
public:
PlatformData
(
int
numParticles
);
PlatformData
(
const
System
&
system
);
~
PlatformData
();
~
PlatformData
();
int
numParticles
,
stepCount
;
int
numParticles
,
stepCount
;
double
time
;
double
time
;
...
@@ -65,6 +66,7 @@ public:
...
@@ -65,6 +66,7 @@ public:
void
*
velocities
;
void
*
velocities
;
void
*
forces
;
void
*
forces
;
void
*
periodicBoxSize
;
void
*
periodicBoxSize
;
void
*
constraints
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/reference/include/ReferenceSETTLEAlgorithm.h
View file @
588a4c9d
...
@@ -44,25 +44,32 @@ namespace OpenMM {
...
@@ -44,25 +44,32 @@ namespace OpenMM {
class
OPENMM_EXPORT
ReferenceSETTLEAlgorithm
:
public
ReferenceConstraintAlgorithm
{
class
OPENMM_EXPORT
ReferenceSETTLEAlgorithm
:
public
ReferenceConstraintAlgorithm
{
public:
public:
ReferenceSETTLEAlgorithm
(
const
std
::
vector
<
int
>&
atom1
,
const
std
::
vector
<
int
>&
atom2
,
const
std
::
vector
<
int
>&
atom3
,
ReferenceSETTLEAlgorithm
(
const
std
::
vector
<
int
>&
atom1
,
const
std
::
vector
<
int
>&
atom2
,
const
std
::
vector
<
int
>&
atom3
,
const
std
::
vector
<
RealOpenMM
>&
distance1
,
const
std
::
vector
<
RealOpenMM
>&
distance2
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
const
std
::
vector
<
RealOpenMM
>&
distance1
,
const
std
::
vector
<
RealOpenMM
>&
distance2
,
std
::
vector
<
RealOpenMM
>&
masses
);
/**
/**
* Get the
constraint tolerance
.
* Get the
number of clusters
.
*/
*/
RealOpenMM
getTolerance
()
const
;
int
getNumClusters
()
const
;
/**
/**
* Set the constraint tolerance.
* Get the parameters describing one cluster.
*
* @param index the index of the cluster to get
* @param atom1 the index of the first atom in the cluster
* @param atom2 the index of the second atom in the cluster
* @param atom3 the index of the third atom in the cluster
* @param distance1 the distance between atoms 1 and 2
* @param distance2 the distance between atoms 2 and 3
*/
*/
void
setTolerance
(
RealOpenMM
tolerance
);
void
getClusterParameters
(
int
index
,
int
&
atom1
,
int
&
atom2
,
int
&
atom3
,
RealOpenMM
&
distance1
,
RealOpenMM
&
distance2
)
const
;
/**
/**
* Apply the constraint algorithm.
* Apply the constraint algorithm.
*
*
* @param atomCoordinates the original atom coordinates
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
/**
/**
* Apply the constraint algorithm to velocities.
* Apply the constraint algorithm to velocities.
...
@@ -70,10 +77,10 @@ public:
...
@@ -70,10 +77,10 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
*/
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
private:
private:
RealOpenMM
tolerance
;
std
::
vector
<
int
>
atom1
;
std
::
vector
<
int
>
atom1
;
std
::
vector
<
int
>
atom2
;
std
::
vector
<
int
>
atom2
;
std
::
vector
<
int
>
atom3
;
std
::
vector
<
int
>
atom3
;
...
...
platforms/reference/include/ReferenceStochasticDynamics.h
View file @
588a4c9d
...
@@ -79,11 +79,12 @@ class ReferenceStochasticDynamics : public ReferenceDynamics {
...
@@ -79,11 +79,12 @@ class ReferenceStochasticDynamics : public ReferenceDynamics {
@param velocities velocities
@param velocities velocities
@param forces forces
@param forces forces
@param masses atom masses
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceVariableStochasticDynamics.h
View file @
588a4c9d
...
@@ -98,11 +98,12 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
...
@@ -98,11 +98,12 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
@param forces forces
@param forces forces
@param masses atom masses
@param masses atom masses
@param maxStepSize maximum time step
@param maxStepSize maximum time step
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceVariableVerletDynamics.h
View file @
588a4c9d
...
@@ -86,11 +86,12 @@ class ReferenceVariableVerletDynamics : public ReferenceDynamics {
...
@@ -86,11 +86,12 @@ class ReferenceVariableVerletDynamics : public ReferenceDynamics {
@param forces forces
@param forces forces
@param masses atom masses
@param masses atom masses
@param maxStepSize maximum time step
@param maxStepSize maximum time step
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
,
RealOpenMM
tolerance
);
};
};
...
...
platforms/reference/include/ReferenceVerletDynamics.h
View file @
588a4c9d
...
@@ -68,11 +68,12 @@ class ReferenceVerletDynamics : public ReferenceDynamics {
...
@@ -68,11 +68,12 @@ class ReferenceVerletDynamics : public ReferenceDynamics {
@param velocities velocities
@param velocities velocities
@param forces forces
@param forces forces
@param masses atom masses
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
};
};
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
588a4c9d
...
@@ -133,11 +133,16 @@ static RealVec& extractBoxSize(ContextImpl& context) {
...
@@ -133,11 +133,16 @@ static RealVec& extractBoxSize(ContextImpl& context) {
return
*
(
RealVec
*
)
data
->
periodicBoxSize
;
return
*
(
RealVec
*
)
data
->
periodicBoxSize
;
}
}
static
ReferenceConstraints
&
extractConstraints
(
ContextImpl
&
context
)
{
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
return
*
(
ReferenceConstraints
*
)
data
->
constraints
;
}
/**
/**
* Compute the kinetic energy of the system, possibly shifting the velocities in time to account
* Compute the kinetic energy of the system, possibly shifting the velocities in time to account
* for a leapfrog integrator.
* for a leapfrog integrator.
*/
*/
static
double
computeShiftedKineticEnergy
(
ContextImpl
&
context
,
vector
<
double
>&
masses
,
double
timeShift
,
ReferenceConstraintAlgorithm
*
constraints
)
{
static
double
computeShiftedKineticEnergy
(
ContextImpl
&
context
,
vector
<
double
>&
masses
,
double
timeShift
)
{
vector
<
RealVec
>&
posData
=
extractPositions
(
context
);
vector
<
RealVec
>&
posData
=
extractPositions
(
context
);
vector
<
RealVec
>&
velData
=
extractVelocities
(
context
);
vector
<
RealVec
>&
velData
=
extractVelocities
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
...
@@ -155,13 +160,10 @@ static double computeShiftedKineticEnergy(ContextImpl& context, vector<double>&
...
@@ -155,13 +160,10 @@ static double computeShiftedKineticEnergy(ContextImpl& context, vector<double>&
// Apply constraints to them.
// Apply constraints to them.
if
(
constraints
!=
NULL
)
{
vector
<
double
>
inverseMasses
(
numParticles
);
vector
<
double
>
inverseMasses
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
inverseMasses
[
i
]
=
(
masses
[
i
]
==
0
?
0
:
1
/
masses
[
i
]);
inverseMasses
[
i
]
=
(
masses
[
i
]
==
0
?
0
:
1
/
masses
[
i
]);
extractConstraints
(
context
).
applyToVelocities
(
posData
,
shiftedVel
,
inverseMasses
,
1e-4
);
constraints
->
setTolerance
(
1e-4
);
constraints
->
applyToVelocities
(
posData
,
shiftedVel
,
inverseMasses
);
}
// Compute the kinetic energy.
// Compute the kinetic energy.
...
@@ -302,39 +304,21 @@ void ReferenceApplyConstraintsKernel::initialize(const System& system) {
...
@@ -302,39 +304,21 @@ void ReferenceApplyConstraintsKernel::initialize(const System& system) {
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
inverseMasses
[
i
]
=
1.0
/
masses
[
i
];
inverseMasses
[
i
]
=
1.0
/
masses
[
i
];
}
}
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
}
}
ReferenceApplyConstraintsKernel
::~
ReferenceApplyConstraintsKernel
()
{
ReferenceApplyConstraintsKernel
::~
ReferenceApplyConstraintsKernel
()
{
if
(
constraints
)
delete
constraints
;
}
}
void
ReferenceApplyConstraintsKernel
::
apply
(
ContextImpl
&
context
,
double
tol
)
{
void
ReferenceApplyConstraintsKernel
::
apply
(
ContextImpl
&
context
,
double
tol
)
{
if
(
constraints
==
NULL
)
constraints
=
new
ReferenceConstraints
(
context
.
getSystem
(),
(
RealOpenMM
)
tol
);
vector
<
RealVec
>&
positions
=
extractPositions
(
context
);
vector
<
RealVec
>&
positions
=
extractPositions
(
context
);
constraints
->
setTolerance
(
tol
);
extractConstraints
(
context
).
apply
(
positions
,
positions
,
inverseMasses
,
tol
);
constraints
->
apply
(
positions
,
positions
,
inverseMasses
);
ReferenceVirtualSites
::
computePositions
(
context
.
getSystem
(),
positions
);
ReferenceVirtualSites
::
computePositions
(
context
.
getSystem
(),
positions
);
}
}
void
ReferenceApplyConstraintsKernel
::
applyToVelocities
(
ContextImpl
&
context
,
double
tol
)
{
void
ReferenceApplyConstraintsKernel
::
applyToVelocities
(
ContextImpl
&
context
,
double
tol
)
{
if
(
constraints
==
NULL
)
constraints
=
new
ReferenceConstraints
(
context
.
getSystem
(),
(
RealOpenMM
)
tol
);
vector
<
RealVec
>&
positions
=
extractPositions
(
context
);
vector
<
RealVec
>&
positions
=
extractPositions
(
context
);
vector
<
RealVec
>&
velocities
=
extractVelocities
(
context
);
vector
<
RealVec
>&
velocities
=
extractVelocities
(
context
);
constraints
->
setTolerance
(
tol
);
extractConstraints
(
context
).
applyToVelocities
(
positions
,
velocities
,
inverseMasses
,
tol
);
constraints
->
applyToVelocities
(
positions
,
velocities
,
inverseMasses
);
}
}
void
ReferenceVirtualSitesKernel
::
initialize
(
const
System
&
system
)
{
void
ReferenceVirtualSitesKernel
::
initialize
(
const
System
&
system
)
{
...
@@ -1686,8 +1670,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context
...
@@ -1686,8 +1670,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context
ReferenceIntegrateVerletStepKernel
::~
ReferenceIntegrateVerletStepKernel
()
{
ReferenceIntegrateVerletStepKernel
::~
ReferenceIntegrateVerletStepKernel
()
{
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
}
void
ReferenceIntegrateVerletStepKernel
::
initialize
(
const
System
&
system
,
const
VerletIntegrator
&
integrator
)
{
void
ReferenceIntegrateVerletStepKernel
::
initialize
(
const
System
&
system
,
const
VerletIntegrator
&
integrator
)
{
...
@@ -1695,19 +1677,6 @@ void ReferenceIntegrateVerletStepKernel::initialize(const System& system, const
...
@@ -1695,19 +1677,6 @@ void ReferenceIntegrateVerletStepKernel::initialize(const System& system, const
masses
.
resize
(
numParticles
);
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
}
void
ReferenceIntegrateVerletStepKernel
::
execute
(
ContextImpl
&
context
,
const
VerletIntegrator
&
integrator
)
{
void
ReferenceIntegrateVerletStepKernel
::
execute
(
ContextImpl
&
context
,
const
VerletIntegrator
&
integrator
)
{
...
@@ -1721,24 +1690,21 @@ void ReferenceIntegrateVerletStepKernel::execute(ContextImpl& context, const Ver
...
@@ -1721,24 +1690,21 @@ void ReferenceIntegrateVerletStepKernel::execute(ContextImpl& context, const Ver
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
dynamics
=
new
ReferenceVerletDynamics
(
context
.
getSystem
().
getNumParticles
(),
static_cast
<
RealOpenMM
>
(
stepSize
)
);
dynamics
=
new
ReferenceVerletDynamics
(
context
.
getSystem
().
getNumParticles
(),
static_cast
<
RealOpenMM
>
(
stepSize
)
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevStepSize
=
stepSize
;
prevStepSize
=
stepSize
;
}
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
);
data
.
time
+=
stepSize
;
data
.
time
+=
stepSize
;
data
.
stepCount
++
;
data
.
stepCount
++
;
}
}
double
ReferenceIntegrateVerletStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VerletIntegrator
&
integrator
)
{
double
ReferenceIntegrateVerletStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VerletIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
}
ReferenceIntegrateLangevinStepKernel
::~
ReferenceIntegrateLangevinStepKernel
()
{
ReferenceIntegrateLangevinStepKernel
::~
ReferenceIntegrateLangevinStepKernel
()
{
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
}
void
ReferenceIntegrateLangevinStepKernel
::
initialize
(
const
System
&
system
,
const
LangevinIntegrator
&
integrator
)
{
void
ReferenceIntegrateLangevinStepKernel
::
initialize
(
const
System
&
system
,
const
LangevinIntegrator
&
integrator
)
{
...
@@ -1746,20 +1712,7 @@ void ReferenceIntegrateLangevinStepKernel::initialize(const System& system, cons
...
@@ -1746,20 +1712,7 @@ void ReferenceIntegrateLangevinStepKernel::initialize(const System& system, cons
masses
.
resize
(
numParticles
);
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
}
void
ReferenceIntegrateLangevinStepKernel
::
execute
(
ContextImpl
&
context
,
const
LangevinIntegrator
&
integrator
)
{
void
ReferenceIntegrateLangevinStepKernel
::
execute
(
ContextImpl
&
context
,
const
LangevinIntegrator
&
integrator
)
{
...
@@ -1780,26 +1733,23 @@ void ReferenceIntegrateLangevinStepKernel::execute(ContextImpl& context, const L
...
@@ -1780,26 +1733,23 @@ void ReferenceIntegrateLangevinStepKernel::execute(ContextImpl& context, const L
static_cast
<
RealOpenMM
>
(
stepSize
),
static_cast
<
RealOpenMM
>
(
stepSize
),
static_cast
<
RealOpenMM
>
(
tau
),
static_cast
<
RealOpenMM
>
(
tau
),
static_cast
<
RealOpenMM
>
(
temperature
)
);
static_cast
<
RealOpenMM
>
(
temperature
)
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevTemp
=
temperature
;
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevFriction
=
friction
;
prevStepSize
=
stepSize
;
prevStepSize
=
stepSize
;
}
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
);
data
.
time
+=
stepSize
;
data
.
time
+=
stepSize
;
data
.
stepCount
++
;
data
.
stepCount
++
;
}
}
double
ReferenceIntegrateLangevinStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
LangevinIntegrator
&
integrator
)
{
double
ReferenceIntegrateLangevinStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
LangevinIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
}
ReferenceIntegrateBrownianStepKernel
::~
ReferenceIntegrateBrownianStepKernel
()
{
ReferenceIntegrateBrownianStepKernel
::~
ReferenceIntegrateBrownianStepKernel
()
{
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
}
void
ReferenceIntegrateBrownianStepKernel
::
initialize
(
const
System
&
system
,
const
BrownianIntegrator
&
integrator
)
{
void
ReferenceIntegrateBrownianStepKernel
::
initialize
(
const
System
&
system
,
const
BrownianIntegrator
&
integrator
)
{
...
@@ -1807,20 +1757,7 @@ void ReferenceIntegrateBrownianStepKernel::initialize(const System& system, cons
...
@@ -1807,20 +1757,7 @@ void ReferenceIntegrateBrownianStepKernel::initialize(const System& system, cons
masses
.
resize
(
numParticles
);
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
}
void
ReferenceIntegrateBrownianStepKernel
::
execute
(
ContextImpl
&
context
,
const
BrownianIntegrator
&
integrator
)
{
void
ReferenceIntegrateBrownianStepKernel
::
execute
(
ContextImpl
&
context
,
const
BrownianIntegrator
&
integrator
)
{
...
@@ -1840,26 +1777,23 @@ void ReferenceIntegrateBrownianStepKernel::execute(ContextImpl& context, const B
...
@@ -1840,26 +1777,23 @@ void ReferenceIntegrateBrownianStepKernel::execute(ContextImpl& context, const B
static_cast
<
RealOpenMM
>
(
stepSize
),
static_cast
<
RealOpenMM
>
(
stepSize
),
static_cast
<
RealOpenMM
>
(
friction
),
static_cast
<
RealOpenMM
>
(
friction
),
static_cast
<
RealOpenMM
>
(
temperature
)
);
static_cast
<
RealOpenMM
>
(
temperature
)
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevTemp
=
temperature
;
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevFriction
=
friction
;
prevStepSize
=
stepSize
;
prevStepSize
=
stepSize
;
}
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
);
data
.
time
+=
stepSize
;
data
.
time
+=
stepSize
;
data
.
stepCount
++
;
data
.
stepCount
++
;
}
}
double
ReferenceIntegrateBrownianStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
BrownianIntegrator
&
integrator
)
{
double
ReferenceIntegrateBrownianStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
BrownianIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0
);
}
}
ReferenceIntegrateVariableLangevinStepKernel
::~
ReferenceIntegrateVariableLangevinStepKernel
()
{
ReferenceIntegrateVariableLangevinStepKernel
::~
ReferenceIntegrateVariableLangevinStepKernel
()
{
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
}
void
ReferenceIntegrateVariableLangevinStepKernel
::
initialize
(
const
System
&
system
,
const
VariableLangevinIntegrator
&
integrator
)
{
void
ReferenceIntegrateVariableLangevinStepKernel
::
initialize
(
const
System
&
system
,
const
VariableLangevinIntegrator
&
integrator
)
{
...
@@ -1867,20 +1801,7 @@ void ReferenceIntegrateVariableLangevinStepKernel::initialize(const System& syst
...
@@ -1867,20 +1801,7 @@ void ReferenceIntegrateVariableLangevinStepKernel::initialize(const System& syst
masses
.
resize
(
numParticles
);
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
}
double
ReferenceIntegrateVariableLangevinStepKernel
::
execute
(
ContextImpl
&
context
,
const
VariableLangevinIntegrator
&
integrator
,
double
maxTime
)
{
double
ReferenceIntegrateVariableLangevinStepKernel
::
execute
(
ContextImpl
&
context
,
const
VariableLangevinIntegrator
&
integrator
,
double
maxTime
)
{
...
@@ -1897,14 +1818,13 @@ double ReferenceIntegrateVariableLangevinStepKernel::execute(ContextImpl& contex
...
@@ -1897,14 +1818,13 @@ double ReferenceIntegrateVariableLangevinStepKernel::execute(ContextImpl& contex
delete
dynamics
;
delete
dynamics
;
RealOpenMM
tau
=
static_cast
<
RealOpenMM
>
(
friction
==
0.0
?
0.0
:
1.0
/
friction
);
RealOpenMM
tau
=
static_cast
<
RealOpenMM
>
(
friction
==
0.0
?
0.0
:
1.0
/
friction
);
dynamics
=
new
ReferenceVariableStochasticDynamics
(
context
.
getSystem
().
getNumParticles
(),
(
RealOpenMM
)
tau
,
(
RealOpenMM
)
temperature
,
(
RealOpenMM
)
errorTol
);
dynamics
=
new
ReferenceVariableStochasticDynamics
(
context
.
getSystem
().
getNumParticles
(),
(
RealOpenMM
)
tau
,
(
RealOpenMM
)
temperature
,
(
RealOpenMM
)
errorTol
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevTemp
=
temperature
;
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevFriction
=
friction
;
prevErrorTol
=
errorTol
;
prevErrorTol
=
errorTol
;
}
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
RealOpenMM
maxStepSize
=
(
RealOpenMM
)
(
maxTime
-
data
.
time
);
RealOpenMM
maxStepSize
=
(
RealOpenMM
)
(
maxTime
-
data
.
time
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
,
integrator
.
getConstraintTolerance
()
);
data
.
time
+=
dynamics
->
getDeltaT
();
data
.
time
+=
dynamics
->
getDeltaT
();
if
(
dynamics
->
getDeltaT
()
==
maxStepSize
)
if
(
dynamics
->
getDeltaT
()
==
maxStepSize
)
data
.
time
=
maxTime
;
// Avoid round-off error
data
.
time
=
maxTime
;
// Avoid round-off error
...
@@ -1913,14 +1833,12 @@ double ReferenceIntegrateVariableLangevinStepKernel::execute(ContextImpl& contex
...
@@ -1913,14 +1833,12 @@ double ReferenceIntegrateVariableLangevinStepKernel::execute(ContextImpl& contex
}
}
double
ReferenceIntegrateVariableLangevinStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VariableLangevinIntegrator
&
integrator
)
{
double
ReferenceIntegrateVariableLangevinStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VariableLangevinIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
}
ReferenceIntegrateVariableVerletStepKernel
::~
ReferenceIntegrateVariableVerletStepKernel
()
{
ReferenceIntegrateVariableVerletStepKernel
::~
ReferenceIntegrateVariableVerletStepKernel
()
{
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
}
void
ReferenceIntegrateVariableVerletStepKernel
::
initialize
(
const
System
&
system
,
const
VariableVerletIntegrator
&
integrator
)
{
void
ReferenceIntegrateVariableVerletStepKernel
::
initialize
(
const
System
&
system
,
const
VariableVerletIntegrator
&
integrator
)
{
...
@@ -1928,19 +1846,6 @@ void ReferenceIntegrateVariableVerletStepKernel::initialize(const System& system
...
@@ -1928,19 +1846,6 @@ void ReferenceIntegrateVariableVerletStepKernel::initialize(const System& system
masses
.
resize
(
numParticles
);
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
}
double
ReferenceIntegrateVariableVerletStepKernel
::
execute
(
ContextImpl
&
context
,
const
VariableVerletIntegrator
&
integrator
,
double
maxTime
)
{
double
ReferenceIntegrateVariableVerletStepKernel
::
execute
(
ContextImpl
&
context
,
const
VariableVerletIntegrator
&
integrator
,
double
maxTime
)
{
...
@@ -1954,12 +1859,11 @@ double ReferenceIntegrateVariableVerletStepKernel::execute(ContextImpl& context,
...
@@ -1954,12 +1859,11 @@ double ReferenceIntegrateVariableVerletStepKernel::execute(ContextImpl& context,
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
dynamics
=
new
ReferenceVariableVerletDynamics
(
context
.
getSystem
().
getNumParticles
(),
(
RealOpenMM
)
errorTol
);
dynamics
=
new
ReferenceVariableVerletDynamics
(
context
.
getSystem
().
getNumParticles
(),
(
RealOpenMM
)
errorTol
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevErrorTol
=
errorTol
;
prevErrorTol
=
errorTol
;
}
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
RealOpenMM
maxStepSize
=
(
RealOpenMM
)
(
maxTime
-
data
.
time
);
RealOpenMM
maxStepSize
=
(
RealOpenMM
)
(
maxTime
-
data
.
time
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
,
integrator
.
getConstraintTolerance
()
);
data
.
time
+=
dynamics
->
getDeltaT
();
data
.
time
+=
dynamics
->
getDeltaT
();
if
(
dynamics
->
getDeltaT
()
==
maxStepSize
)
if
(
dynamics
->
getDeltaT
()
==
maxStepSize
)
data
.
time
=
maxTime
;
// Avoid round-off error
data
.
time
=
maxTime
;
// Avoid round-off error
...
@@ -1968,14 +1872,12 @@ double ReferenceIntegrateVariableVerletStepKernel::execute(ContextImpl& context,
...
@@ -1968,14 +1872,12 @@ double ReferenceIntegrateVariableVerletStepKernel::execute(ContextImpl& context,
}
}
double
ReferenceIntegrateVariableVerletStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VariableVerletIntegrator
&
integrator
)
{
double
ReferenceIntegrateVariableVerletStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VariableVerletIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
}
ReferenceIntegrateCustomStepKernel
::~
ReferenceIntegrateCustomStepKernel
()
{
ReferenceIntegrateCustomStepKernel
::~
ReferenceIntegrateCustomStepKernel
()
{
if
(
dynamics
)
if
(
dynamics
)
delete
dynamics
;
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
}
void
ReferenceIntegrateCustomStepKernel
::
initialize
(
const
System
&
system
,
const
CustomIntegrator
&
integrator
)
{
void
ReferenceIntegrateCustomStepKernel
::
initialize
(
const
System
&
system
,
const
CustomIntegrator
&
integrator
)
{
...
@@ -1983,18 +1885,6 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
...
@@ -1983,18 +1885,6 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
masses
.
resize
(
numParticles
);
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
perDofValues
.
resize
(
integrator
.
getNumPerDofVariables
());
perDofValues
.
resize
(
integrator
.
getNumPerDofVariables
());
for
(
int
i
=
0
;
i
<
(
int
)
perDofValues
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
perDofValues
.
size
();
i
++
)
perDofValues
[
i
].
resize
(
numParticles
);
perDofValues
[
i
].
resize
(
numParticles
);
...
@@ -2003,8 +1893,6 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
...
@@ -2003,8 +1893,6 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
dynamics
=
new
ReferenceCustomDynamics
(
system
.
getNumParticles
(),
integrator
);
dynamics
=
new
ReferenceCustomDynamics
(
system
.
getNumParticles
(),
integrator
);
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
dynamics
->
setReferenceConstraintAlgorithm
(
constraints
);
}
}
void
ReferenceIntegrateCustomStepKernel
::
execute
(
ContextImpl
&
context
,
CustomIntegrator
&
integrator
,
bool
&
forcesAreValid
)
{
void
ReferenceIntegrateCustomStepKernel
::
execute
(
ContextImpl
&
context
,
CustomIntegrator
&
integrator
,
bool
&
forcesAreValid
)
{
...
@@ -2021,8 +1909,8 @@ void ReferenceIntegrateCustomStepKernel::execute(ContextImpl& context, CustomInt
...
@@ -2021,8 +1909,8 @@ void ReferenceIntegrateCustomStepKernel::execute(ContextImpl& context, CustomInt
// Execute the step.
// Execute the step.
constraint
s
->
set
Tol
er
a
nce
(
integrator
.
ge
tConstraint
Tolerance
(
));
dynamic
s
->
set
Ref
er
e
nce
ConstraintAlgorithm
(
&
extrac
tConstraint
s
(
context
));
dynamics
->
update
(
context
,
context
.
getSystem
().
getNumParticles
(),
posData
,
velData
,
forceData
,
masses
,
globals
,
perDofValues
,
forcesAreValid
);
dynamics
->
update
(
context
,
context
.
getSystem
().
getNumParticles
(),
posData
,
velData
,
forceData
,
masses
,
globals
,
perDofValues
,
forcesAreValid
,
integrator
.
getConstraintTolerance
()
);
// Record changed global variables.
// Record changed global variables.
...
...
platforms/reference/src/ReferencePlatform.cpp
View file @
588a4c9d
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "ReferencePlatform.h"
#include "ReferencePlatform.h"
#include "ReferenceConstraints.h"
#include "ReferenceKernelFactory.h"
#include "ReferenceKernelFactory.h"
#include "ReferenceKernels.h"
#include "ReferenceKernels.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
...
@@ -82,7 +83,7 @@ bool ReferencePlatform::supportsDoublePrecision() const {
...
@@ -82,7 +83,7 @@ bool ReferencePlatform::supportsDoublePrecision() const {
}
}
void
ReferencePlatform
::
contextCreated
(
ContextImpl
&
context
,
const
map
<
string
,
string
>&
properties
)
const
{
void
ReferencePlatform
::
contextCreated
(
ContextImpl
&
context
,
const
map
<
string
,
string
>&
properties
)
const
{
context
.
setPlatformData
(
new
PlatformData
(
context
.
getSystem
()
.
getNumParticles
()
));
context
.
setPlatformData
(
new
PlatformData
(
context
.
getSystem
()));
}
}
void
ReferencePlatform
::
contextDestroyed
(
ContextImpl
&
context
)
const
{
void
ReferencePlatform
::
contextDestroyed
(
ContextImpl
&
context
)
const
{
...
@@ -90,11 +91,12 @@ void ReferencePlatform::contextDestroyed(ContextImpl& context) const {
...
@@ -90,11 +91,12 @@ void ReferencePlatform::contextDestroyed(ContextImpl& context) const {
delete
data
;
delete
data
;
}
}
ReferencePlatform
::
PlatformData
::
PlatformData
(
int
numParticles
)
:
time
(
0.0
),
stepCount
(
0
),
numParticles
(
n
umParticles
)
{
ReferencePlatform
::
PlatformData
::
PlatformData
(
const
System
&
system
)
:
time
(
0.0
),
stepCount
(
0
),
numParticles
(
system
.
getN
umParticles
()
)
{
positions
=
new
vector
<
RealVec
>
(
numParticles
);
positions
=
new
vector
<
RealVec
>
(
numParticles
);
velocities
=
new
vector
<
RealVec
>
(
numParticles
);
velocities
=
new
vector
<
RealVec
>
(
numParticles
);
forces
=
new
vector
<
RealVec
>
(
numParticles
);
forces
=
new
vector
<
RealVec
>
(
numParticles
);
periodicBoxSize
=
new
RealVec
();
periodicBoxSize
=
new
RealVec
();
constraints
=
new
ReferenceConstraints
(
system
);
}
}
ReferencePlatform
::
PlatformData
::~
PlatformData
()
{
ReferencePlatform
::
PlatformData
::~
PlatformData
()
{
...
@@ -102,4 +104,5 @@ ReferencePlatform::PlatformData::~PlatformData() {
...
@@ -102,4 +104,5 @@ ReferencePlatform::PlatformData::~PlatformData() {
delete
(
vector
<
RealVec
>*
)
velocities
;
delete
(
vector
<
RealVec
>*
)
velocities
;
delete
(
vector
<
RealVec
>*
)
forces
;
delete
(
vector
<
RealVec
>*
)
forces
;
delete
(
RealVec
*
)
periodicBoxSize
;
delete
(
RealVec
*
)
periodicBoxSize
;
delete
(
ReferenceConstraints
*
)
constraints
;
}
}
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment