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
4a30156a
"vscode:/vscode.git/clone" did not exist on "ecc7e011efcc895bb8d45043ce5f120ffde97762"
Commit
4a30156a
authored
May 27, 2020
by
peastman
Browse files
Added Integrator.setIntegrationForceGroups()
parent
f902295b
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
212 additions
and
14 deletions
+212
-14
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
+2
-1
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernels.cpp
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernels.cpp
+2
-1
plugins/rpmd/platforms/reference/src/ReferenceRpmdKernels.cpp
...ins/rpmd/platforms/reference/src/ReferenceRpmdKernels.cpp
+2
-1
tests/TestCustomIntegrator.h
tests/TestCustomIntegrator.h
+9
-4
tests/TestLangevinIntegrator.h
tests/TestLangevinIntegrator.h
+28
-1
tests/TestLangevinMiddleIntegrator.h
tests/TestLangevinMiddleIntegrator.h
+28
-1
tests/TestLocalEnergyMinimizer.h
tests/TestLocalEnergyMinimizer.h
+30
-1
tests/TestNoseHooverIntegrator.h
tests/TestNoseHooverIntegrator.h
+27
-1
tests/TestVariableLangevinIntegrator.h
tests/TestVariableLangevinIntegrator.h
+28
-1
tests/TestVariableVerletIntegrator.h
tests/TestVariableVerletIntegrator.h
+28
-1
tests/TestVerletIntegrator.h
tests/TestVerletIntegrator.h
+28
-1
No files found.
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2011-20
18
Stanford University and the Authors. *
* Portions copyright (c) 2011-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -123,6 +123,7 @@ void CudaIntegrateRPMDStepKernel::initialize(const System& system, const RPMDInt
groupsNotContracted
-=
1
<<
group
;
}
}
groupsNotContracted
&=
integrator
.
getIntegrationForceGroups
();
if
(
maxContractedCopies
>
0
)
{
contractedForces
.
initialize
<
long
long
>
(
cu
,
maxContractedCopies
*
paddedParticles
*
3
,
"rpmdContractedForces"
);
contractedPositions
.
initialize
(
cu
,
maxContractedCopies
*
paddedParticles
,
elementSize
,
"rpmdContractedPositions"
);
...
...
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernels.cpp
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2011-20
18
Stanford University and the Authors. *
* Portions copyright (c) 2011-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -103,6 +103,7 @@ void OpenCLIntegrateRPMDStepKernel::initialize(const System& system, const RPMDI
groupsNotContracted
-=
1
<<
group
;
}
}
groupsNotContracted
&=
integrator
.
getIntegrationForceGroups
();
if
(
maxContractedCopies
>
0
)
{
contractedForces
.
initialize
(
cl
,
maxContractedCopies
*
paddedParticles
,
forceElementSize
,
"rpmdContractedForces"
);
contractedPositions
.
initialize
(
cl
,
maxContractedCopies
*
paddedParticles
,
elementSize
,
"rpmdContractedPositions"
);
...
...
plugins/rpmd/platforms/reference/src/ReferenceRpmdKernels.cpp
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2011-20
13
Stanford University and the Authors. *
* Portions copyright (c) 2011-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -99,6 +99,7 @@ void ReferenceIntegrateRPMDStepKernel::initialize(const System& system, const RP
groupsNotContracted
-=
1
<<
group
;
}
}
groupsNotContracted
&=
integrator
.
getIntegrationForceGroups
();
// Create workspace for doing contractions.
...
...
tests/TestCustomIntegrator.h
View file @
4a30156a
...
...
@@ -597,6 +597,7 @@ void testForceGroups() {
integrator
.
addComputeGlobal
(
"oute"
,
"energy"
);
integrator
.
addComputeGlobal
(
"oute1"
,
"energy1"
);
integrator
.
addComputeGlobal
(
"oute2"
,
"energy2"
);
integrator
.
setIntegrationForceGroups
((
1
<<
1
)
+
(
1
<<
2
));
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
bonds
->
addBond
(
0
,
1
,
1.5
,
1.1
);
bonds
->
setForceGroup
(
1
);
...
...
@@ -606,6 +607,10 @@ void testForceGroups() {
nb
->
addParticle
(
0.2
,
1
,
0
);
nb
->
setForceGroup
(
2
);
system
.
addForce
(
nb
);
CustomExternalForce
*
external
=
new
CustomExternalForce
(
"x"
);
external
->
addParticle
(
0
);
external
->
setForceGroup
(
3
);
system
.
addForce
(
external
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
positions
[
0
]
=
Vec3
(
-
1
,
0
,
0
);
...
...
@@ -633,13 +638,13 @@ void testForceGroups() {
// Make sure they also match the values returned by the Context.
State
s
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
false
);
State
s
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
false
,
6
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
false
,
2
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
false
,
4
);
vector
<
Vec3
>
c
,
c1
,
c2
;
c
=
context
.
getState
(
State
::
Forces
,
false
)
.
getForces
();
c1
=
context
.
getState
(
State
::
Forces
,
false
,
2
)
.
getForces
();
c2
=
context
.
getState
(
State
::
Forces
,
false
,
4
)
.
getForces
();
c
=
s
.
getForces
();
c1
=
s1
.
getForces
();
c2
=
s2
.
getForces
();
ASSERT_EQUAL_VEC
(
f
[
0
],
c
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f
[
1
],
c
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
0
],
c1
[
0
],
1e-5
);
...
...
tests/TestLangevinIntegrator.h
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-20
16
Stanford University and the Authors. *
* Portions copyright (c) 2008-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -31,6 +31,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/System.h"
...
...
@@ -286,6 +287,31 @@ void testInitialTemperature() {
ASSERT_USUALLY_EQUAL_TOL
(
targetTemperature
,
temperature
,
0.01
);
}
void
testForceGroups
()
{
System
system
;
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
1.0
,
0.01
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
CustomExternalForce
*
f1
=
new
CustomExternalForce
(
"x"
);
f1
->
addParticle
(
0
);
f1
->
setForceGroup
(
1
);
CustomExternalForce
*
f2
=
new
CustomExternalForce
(
"y"
);
f2
->
addParticle
(
0
);
f2
->
setForceGroup
(
2
);
system
.
addForce
(
f1
);
system
.
addForce
(
f2
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
vector
<
Vec3
>
(
1
));
// Take one step and verify that the position was updated based only on f1.
integrator
.
step
(
1
);
Vec3
pos
=
context
.
getState
(
State
::
Positions
).
getPositions
()[
0
];
ASSERT
(
pos
[
0
]
<
0
);
ASSERT
(
pos
[
1
]
==
0
);
ASSERT
(
pos
[
2
]
==
0
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -297,6 +323,7 @@ int main(int argc, char* argv[]) {
testConstrainedMasslessParticles
();
testRandomSeed
();
testInitialTemperature
();
testForceGroups
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestLangevinMiddleIntegrator.h
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-20
19
Stanford University and the Authors. *
* Portions copyright (c) 2008-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -31,6 +31,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/System.h"
...
...
@@ -289,6 +290,31 @@ void testInitialTemperature() {
ASSERT_USUALLY_EQUAL_TOL
(
targetTemperature
,
temperature
,
0.01
);
}
void
testForceGroups
()
{
System
system
;
system
.
addParticle
(
1.0
);
LangevinMiddleIntegrator
integrator
(
0.0
,
1.0
,
0.01
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
CustomExternalForce
*
f1
=
new
CustomExternalForce
(
"x"
);
f1
->
addParticle
(
0
);
f1
->
setForceGroup
(
1
);
CustomExternalForce
*
f2
=
new
CustomExternalForce
(
"y"
);
f2
->
addParticle
(
0
);
f2
->
setForceGroup
(
2
);
system
.
addForce
(
f1
);
system
.
addForce
(
f2
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
vector
<
Vec3
>
(
1
));
// Take one step and verify that the position was updated based only on f1.
integrator
.
step
(
1
);
Vec3
pos
=
context
.
getState
(
State
::
Positions
).
getPositions
()[
0
];
ASSERT
(
pos
[
0
]
<
0
);
ASSERT
(
pos
[
1
]
==
0
);
ASSERT
(
pos
[
2
]
==
0
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -300,6 +326,7 @@ int main(int argc, char* argv[]) {
testConstrainedMasslessParticles
();
testRandomSeed
();
testInitialTemperature
();
testForceGroups
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestLocalEnergyMinimizer.h
View file @
4a30156a
...
...
@@ -7,7 +7,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-20
18
Stanford University and the Authors. *
* Portions copyright (c) 2010-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -231,6 +231,34 @@ void testLargeForces() {
ASSERT
(
maxdist
<
10.0
);
}
void
testForceGroups
()
{
// Create a system with two forces, only one of which is in the standard
// integration force groups.
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
HarmonicBondForce
*
bonds1
=
new
HarmonicBondForce
();
HarmonicBondForce
*
bonds2
=
new
HarmonicBondForce
();
system
.
addForce
(
bonds1
);
system
.
addForce
(
bonds2
);
bonds1
->
addBond
(
0
,
1
,
2.0
,
1
);
bonds2
->
addBond
(
0
,
1
,
4.0
,
1
);
bonds1
->
setForceGroup
(
1
);
bonds2
->
setForceGroup
(
2
);
// Minimize it and check that the bond has the correct length.
VerletIntegrator
integrator
(
0.01
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
({
Vec3
(
0
,
0
,
0
),
Vec3
(
5
,
0
,
0
)});
LocalEnergyMinimizer
::
minimize
(
context
,
1e-5
);
State
state
=
context
.
getState
(
State
::
Positions
);
Vec3
delta
=
state
.
getPositions
()[
0
]
-
state
.
getPositions
()[
1
];
ASSERT_EQUAL_TOL
(
2.0
,
sqrt
(
delta
.
dot
(
delta
)),
1e-4
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -240,6 +268,7 @@ int main(int argc, char* argv[]) {
testLargeSystem
();
testVirtualSites
();
testLargeForces
();
testForceGroups
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestNoseHooverIntegrator.h
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2019 Stanford University and the Authors.
*
* Portions copyright (c) 2019
-2020
Stanford University and the Authors. *
* Authors: Andreas Krämer and Andrew C. Simmonett *
* Contributors: *
* *
...
...
@@ -510,6 +510,31 @@ void testAPIChangeNumParticles() {
}
void
testForceGroups
()
{
System
system
;
system
.
addParticle
(
1.0
);
NoseHooverIntegrator
integrator
(
1
,
1.0
,
0.001
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
CustomExternalForce
*
f1
=
new
CustomExternalForce
(
"x"
);
f1
->
addParticle
(
0
);
f1
->
setForceGroup
(
1
);
CustomExternalForce
*
f2
=
new
CustomExternalForce
(
"y"
);
f2
->
addParticle
(
0
);
f2
->
setForceGroup
(
2
);
system
.
addForce
(
f1
);
system
.
addForce
(
f2
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
vector
<
Vec3
>
(
1
));
// Take one step and verify that the position was updated based only on f1.
integrator
.
step
(
1
);
Vec3
pos
=
context
.
getState
(
State
::
Positions
).
getPositions
()[
0
];
ASSERT
(
pos
[
0
]
<
0
);
ASSERT
(
pos
[
1
]
==
0
);
ASSERT
(
pos
[
2
]
==
0
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -528,6 +553,7 @@ int main(int argc, char* argv[]) {
constrain
=
false
;
testDimerBox
(
constrain
);
constrain
=
true
;
testDimerBox
(
constrain
);
testCheckpoints
();
testForceGroups
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestVariableLangevinIntegrator.h
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-20
16
Stanford University and the Authors. *
* Portions copyright (c) 2008-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -31,6 +31,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/System.h"
...
...
@@ -358,6 +359,31 @@ void testInitialTemperature() {
ASSERT_USUALLY_EQUAL_TOL
(
targetTemperature
,
temperature
,
0.01
);
}
void
testForceGroups
()
{
System
system
;
system
.
addParticle
(
1.0
);
VariableLangevinIntegrator
integrator
(
0.0
,
1.0
,
1e-5
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
CustomExternalForce
*
f1
=
new
CustomExternalForce
(
"x"
);
f1
->
addParticle
(
0
);
f1
->
setForceGroup
(
1
);
CustomExternalForce
*
f2
=
new
CustomExternalForce
(
"y"
);
f2
->
addParticle
(
0
);
f2
->
setForceGroup
(
2
);
system
.
addForce
(
f1
);
system
.
addForce
(
f2
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
vector
<
Vec3
>
(
1
));
// Take one step and verify that the position was updated based only on f1.
integrator
.
step
(
1
);
Vec3
pos
=
context
.
getState
(
State
::
Positions
).
getPositions
()[
0
];
ASSERT
(
pos
[
0
]
<
0
);
ASSERT
(
pos
[
1
]
==
0
);
ASSERT
(
pos
[
2
]
==
0
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -370,6 +396,7 @@ int main(int argc, char* argv[]) {
testRandomSeed
();
testArgonBox
();
testInitialTemperature
();
testForceGroups
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestVariableVerletIntegrator.h
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-20
15
Stanford University and the Authors. *
* Portions copyright (c) 2008-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -31,6 +31,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/System.h"
...
...
@@ -337,6 +338,31 @@ void testInitialTemperature() {
ASSERT_USUALLY_EQUAL_TOL
(
targetTemperature
,
temperature
,
0.01
);
}
void
testForceGroups
()
{
System
system
;
system
.
addParticle
(
1.0
);
VariableVerletIntegrator
integrator
(
0.001
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
CustomExternalForce
*
f1
=
new
CustomExternalForce
(
"x"
);
f1
->
addParticle
(
0
);
f1
->
setForceGroup
(
1
);
CustomExternalForce
*
f2
=
new
CustomExternalForce
(
"y"
);
f2
->
addParticle
(
0
);
f2
->
setForceGroup
(
2
);
system
.
addForce
(
f1
);
system
.
addForce
(
f2
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
vector
<
Vec3
>
(
1
));
// Take one step and verify that the position was updated based only on f1.
integrator
.
step
(
1
);
Vec3
pos
=
context
.
getState
(
State
::
Positions
).
getPositions
()[
0
];
ASSERT
(
pos
[
0
]
<
0
);
ASSERT
(
pos
[
1
]
==
0
);
ASSERT
(
pos
[
2
]
==
0
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -348,6 +374,7 @@ int main(int argc, char* argv[]) {
testConstrainedMasslessParticles
();
testArgonBox
();
testInitialTemperature
();
testForceGroups
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestVerletIntegrator.h
View file @
4a30156a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-20
15
Stanford University and the Authors. *
* Portions copyright (c) 2008-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -31,6 +31,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/System.h"
...
...
@@ -254,6 +255,31 @@ void testInitialTemperature() {
ASSERT_USUALLY_EQUAL_TOL
(
targetTemperature
,
temperature
,
0.01
);
}
void
testForceGroups
()
{
System
system
;
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
CustomExternalForce
*
f1
=
new
CustomExternalForce
(
"x"
);
f1
->
addParticle
(
0
);
f1
->
setForceGroup
(
1
);
CustomExternalForce
*
f2
=
new
CustomExternalForce
(
"y"
);
f2
->
addParticle
(
0
);
f2
->
setForceGroup
(
2
);
system
.
addForce
(
f1
);
system
.
addForce
(
f2
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
vector
<
Vec3
>
(
1
));
// Take one step and verify that the position was updated based only on f1.
integrator
.
step
(
1
);
Vec3
pos
=
context
.
getState
(
State
::
Positions
).
getPositions
()[
0
];
ASSERT
(
pos
[
0
]
<
0
);
ASSERT
(
pos
[
1
]
==
0
);
ASSERT
(
pos
[
2
]
==
0
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -264,6 +290,7 @@ int main(int argc, char* argv[]) {
testConstrainedClusters
();
testConstrainedMasslessParticles
();
testInitialTemperature
();
testForceGroups
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
Prev
1
2
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