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
2e9c418a
Commit
2e9c418a
authored
May 05, 2016
by
peastman
Browse files
Merge branch 'master' into gayberne
parents
8f532e31
a4d327f5
Changes
254
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
336 additions
and
26 deletions
+336
-26
serialization/tests/TestSerializeCMAPTorsion.cpp
serialization/tests/TestSerializeCMAPTorsion.cpp
+3
-1
serialization/tests/TestSerializeCustomAngleForce.cpp
serialization/tests/TestSerializeCustomAngleForce.cpp
+3
-1
serialization/tests/TestSerializeCustomBondForce.cpp
serialization/tests/TestSerializeCustomBondForce.cpp
+3
-1
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
+3
-1
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
+3
-1
serialization/tests/TestSerializeCustomTorsionForce.cpp
serialization/tests/TestSerializeCustomTorsionForce.cpp
+3
-1
serialization/tests/TestSerializeHarmonicAngleForce.cpp
serialization/tests/TestSerializeHarmonicAngleForce.cpp
+3
-1
serialization/tests/TestSerializeHarmonicBondForce.cpp
serialization/tests/TestSerializeHarmonicBondForce.cpp
+3
-1
serialization/tests/TestSerializeMonteCarloAnisotropicBarostat.cpp
...tion/tests/TestSerializeMonteCarloAnisotropicBarostat.cpp
+2
-2
serialization/tests/TestSerializeMonteCarloBarostat.cpp
serialization/tests/TestSerializeMonteCarloBarostat.cpp
+2
-2
serialization/tests/TestSerializeMonteCarloMembraneBarostat.cpp
...ization/tests/TestSerializeMonteCarloMembraneBarostat.cpp
+2
-2
serialization/tests/TestSerializePeriodicTorsionForce.cpp
serialization/tests/TestSerializePeriodicTorsionForce.cpp
+3
-1
serialization/tests/TestSerializeRBTorsionForce.cpp
serialization/tests/TestSerializeRBTorsionForce.cpp
+3
-1
tests/TestCMAPTorsionForce.h
tests/TestCMAPTorsionForce.h
+57
-1
tests/TestCustomAngleForce.h
tests/TestCustomAngleForce.h
+38
-1
tests/TestCustomBondForce.h
tests/TestCustomBondForce.h
+31
-0
tests/TestCustomCentroidBondForce.h
tests/TestCustomCentroidBondForce.h
+58
-1
tests/TestCustomCompoundBondForce.h
tests/TestCustomCompoundBondForce.h
+80
-3
tests/TestCustomIntegrator.h
tests/TestCustomIntegrator.h
+4
-4
tests/TestCustomNonbondedForce.h
tests/TestCustomNonbondedForce.h
+32
-0
No files found.
serialization/tests/TestSerializeCMAPTorsion.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -55,6 +55,7 @@ void testSerialization() {
force
.
addTorsion
(
0
,
0
,
2
,
3
,
4
,
5
,
6
,
7
,
8
);
force
.
addTorsion
(
1
,
2
,
3
,
4
,
7
,
1
,
2
,
3
,
4
);
force
.
addTorsion
(
1
,
5
,
1
,
2
,
3
,
2
,
3
,
4
,
8
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -66,6 +67,7 @@ void testSerialization() {
CMAPTorsionForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumMaps
(),
force2
.
getNumMaps
());
for
(
int
i
=
0
;
i
<
force
.
getNumMaps
();
i
++
)
{
int
size1
,
size2
;
...
...
serialization/tests/TestSerializeCustomAngleForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -53,6 +53,7 @@ void testSerialization() {
force
.
addAngle
(
4
,
0
,
1
,
params
);
params
[
0
]
=
2.1
;
force
.
addAngle
(
3
,
7
,
6
,
params
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumAngles
(),
force2
.
getNumAngles
());
for
(
int
i
=
0
;
i
<
force
.
getNumAngles
();
i
++
)
{
int
a1
,
a2
,
b1
,
b2
,
c1
,
c2
;
...
...
serialization/tests/TestSerializeCustomBondForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -53,6 +53,7 @@ void testSerialization() {
force
.
addBond
(
4
,
0
,
params
);
params
[
0
]
=
2.1
;
force
.
addBond
(
3
,
7
,
params
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumBonds
(),
force2
.
getNumBonds
());
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
int
a1
,
a2
,
b1
,
b2
;
...
...
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -77,6 +77,7 @@ void testSerialization() {
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addTabulatedFunction
(
"f"
,
new
Continuous1DFunction
(
values
,
0.5
,
1.5
));
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -98,6 +99,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumGroups
(),
force2
.
getNumGroups
());
for
(
int
i
=
0
;
i
<
force
.
getNumGroups
();
i
++
)
{
vector
<
int
>
particles1
,
particles2
;
...
...
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -67,6 +67,7 @@ void testSerialization() {
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addTabulatedFunction
(
"f"
,
new
Continuous1DFunction
(
values
,
0.5
,
1.5
));
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -88,6 +89,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumBonds
(),
force2
.
getNumBonds
());
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
vector
<
int
>
particles1
,
particles2
;
...
...
serialization/tests/TestSerializeCustomTorsionForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -53,6 +53,7 @@ void testSerialization() {
force
.
addTorsion
(
4
,
0
,
1
,
5
,
params
);
params
[
0
]
=
2.1
;
force
.
addTorsion
(
3
,
7
,
6
,
8
,
params
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumTorsions
(),
force2
.
getNumTorsions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
a1
,
a2
,
b1
,
b2
,
c1
,
c2
,
d1
,
d2
;
...
...
serialization/tests/TestSerializeHarmonicAngleForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -47,6 +47,7 @@ void testSerialization() {
force
.
addAngle
(
0
,
2
,
3
,
2.0
,
2.1
);
force
.
addAngle
(
2
,
3
,
4
,
3.0
,
2.2
);
force
.
addAngle
(
5
,
1
,
2
,
4.0
,
2.3
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -58,6 +59,7 @@ void testSerialization() {
HarmonicAngleForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumAngles
(),
force2
.
getNumAngles
());
for
(
int
i
=
0
;
i
<
force
.
getNumAngles
();
i
++
)
{
int
a1
,
a2
,
a3
,
b1
,
b2
,
b3
;
...
...
serialization/tests/TestSerializeHarmonicBondForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -47,6 +47,7 @@ void testSerialization() {
force
.
addBond
(
0
,
2
,
2.0
,
2.1
);
force
.
addBond
(
2
,
3
,
3.0
,
2.2
);
force
.
addBond
(
5
,
1
,
4.0
,
2.3
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -58,6 +59,7 @@ void testSerialization() {
HarmonicBondForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumBonds
(),
force2
.
getNumBonds
());
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
int
a1
,
a2
,
b1
,
b2
;
...
...
serialization/tests/TestSerializeMonteCarloAnisotropicBarostat.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -56,7 +56,7 @@ void testSerialization() {
MonteCarloAnisotropicBarostat
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL_VEC
(
force
.
getDefaultPressure
(),
force2
.
getDefaultPressure
(),
0.0
);
ASSERT_EQUAL
(
force
.
getTemperature
(),
force2
.
getTemperature
());
ASSERT_EQUAL
(
force
.
get
Default
Temperature
(),
force2
.
get
Default
Temperature
());
ASSERT_EQUAL
(
force
.
getScaleX
(),
force2
.
getScaleX
());
ASSERT_EQUAL
(
force
.
getScaleY
(),
force2
.
getScaleY
());
ASSERT_EQUAL
(
force
.
getScaleZ
(),
force2
.
getScaleZ
());
...
...
serialization/tests/TestSerializeMonteCarloBarostat.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -56,7 +56,7 @@ void testSerialization() {
MonteCarloBarostat
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
getDefaultPressure
(),
force2
.
getDefaultPressure
());
ASSERT_EQUAL
(
force
.
getTemperature
(),
force2
.
getTemperature
());
ASSERT_EQUAL
(
force
.
get
Default
Temperature
(),
force2
.
get
Default
Temperature
());
ASSERT_EQUAL
(
force
.
getFrequency
(),
force2
.
getFrequency
());
ASSERT_EQUAL
(
force
.
getRandomNumberSeed
(),
force2
.
getRandomNumberSeed
());
}
...
...
serialization/tests/TestSerializeMonteCarloMembraneBarostat.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -57,7 +57,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
getDefaultPressure
(),
force2
.
getDefaultPressure
());
ASSERT_EQUAL
(
force
.
getDefaultSurfaceTension
(),
force2
.
getDefaultSurfaceTension
());
ASSERT_EQUAL
(
force
.
getTemperature
(),
force2
.
getTemperature
());
ASSERT_EQUAL
(
force
.
get
Default
Temperature
(),
force2
.
get
Default
Temperature
());
ASSERT_EQUAL
(
force
.
getXYMode
(),
force2
.
getXYMode
());
ASSERT_EQUAL
(
force
.
getZMode
(),
force2
.
getZMode
());
ASSERT_EQUAL
(
force
.
getFrequency
(),
force2
.
getFrequency
());
...
...
serialization/tests/TestSerializePeriodicTorsionForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -47,6 +47,7 @@ void testSerialization() {
force
.
addTorsion
(
0
,
2
,
3
,
4
,
2
,
2.0
,
2.1
);
force
.
addTorsion
(
2
,
3
,
4
,
7
,
1
,
3.0
,
2.2
);
force
.
addTorsion
(
5
,
1
,
2
,
3
,
3
,
4.0
,
2.3
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -58,6 +59,7 @@ void testSerialization() {
PeriodicTorsionForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumTorsions
(),
force2
.
getNumTorsions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
a1
,
a2
,
a3
,
a4
,
b1
,
b2
,
b3
,
b4
,
perioda
,
periodb
;
...
...
serialization/tests/TestSerializeRBTorsionForce.cpp
View file @
2e9c418a
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
force
.
addTorsion
(
0
,
1
,
2
,
3
,
0.1
,
0.2
,
0.3
,
0.4
,
0.5
,
0.6
);
force
.
addTorsion
(
0
,
2
,
3
,
4
,
0.2
,
0.3
,
0.4
,
0.5
,
0.6
,
0.7
);
force
.
addTorsion
(
2
,
3
,
4
,
7
,
-
1
,
-
2
,
-
3
,
1.1
,
2.2
,
3.3
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -57,6 +58,7 @@ void testSerialization() {
RBTorsionForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumTorsions
(),
force2
.
getNumTorsions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
a1
,
a2
,
a3
,
a4
,
b1
,
b2
,
b3
,
b4
;
...
...
tests/TestCMAPTorsionForce.h
View file @
2e9c418a
...
...
@@ -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) 2010-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -158,6 +158,61 @@ void testChangingParameters() {
ASSERT_EQUAL_TOL
(
2
-
20
*
sin
(
M_PI
/
4
),
energy
,
1e-5
);
}
void
testPeriodic
()
{
const
int
mapSize
=
36
;
// Create two systems that use periodic boundary conditions: one with a pair
// of periodic torsions, and one with a CMAP torsion that approximates the same force.
System
system1
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
system1
.
addParticle
(
1.0
);
PeriodicTorsionForce
*
periodic
=
new
PeriodicTorsionForce
();
periodic
->
addTorsion
(
0
,
1
,
2
,
3
,
2
,
M_PI
/
4
,
1.5
);
periodic
->
addTorsion
(
1
,
2
,
3
,
4
,
3
,
M_PI
/
3
,
2.0
);
periodic
->
setUsesPeriodicBoundaryConditions
(
true
);
system1
.
addForce
(
periodic
);
System
system2
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
system2
.
addParticle
(
1.0
);
CMAPTorsionForce
*
cmap
=
new
CMAPTorsionForce
();
vector
<
double
>
mapEnergy
(
mapSize
*
mapSize
);
for
(
int
i
=
0
;
i
<
mapSize
;
i
++
)
{
double
angle1
=
i
*
2
*
M_PI
/
mapSize
;
double
energy1
=
1.5
*
(
1
+
cos
(
2
*
angle1
-
M_PI
/
4
));
for
(
int
j
=
0
;
j
<
mapSize
;
j
++
)
{
double
angle2
=
j
*
2
*
M_PI
/
mapSize
;
double
energy2
=
2.0
*
(
1
+
cos
(
3
*
angle2
-
M_PI
/
3
));
mapEnergy
[
i
+
j
*
mapSize
]
=
energy1
+
energy2
;
}
}
cmap
->
addMap
(
mapSize
,
mapEnergy
);
cmap
->
addTorsion
(
0
,
0
,
1
,
2
,
3
,
1
,
2
,
3
,
4
);
cmap
->
setUsesPeriodicBoundaryConditions
(
true
);
system2
.
addForce
(
cmap
);
// Set the atoms in various positions, and verify that both systems give equal forces and energy.
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
5
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
c1
(
system1
,
integrator1
,
platform
);
Context
c2
(
system2
,
integrator2
,
platform
);
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
positions
[
j
]
=
Vec3
(
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
));
c1
.
setPositions
(
positions
);
c2
.
setPositions
(
positions
);
State
s1
=
c1
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
s2
=
c2
.
getState
(
State
::
Forces
|
State
::
Energy
);
for
(
int
i
=
0
;
i
<
system1
.
getNumParticles
();
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
0.05
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-3
);
}
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -165,6 +220,7 @@ int main(int argc, char* argv[]) {
initializeTests
(
argc
,
argv
);
testCMAPTorsions
();
testChangingParameters
();
testPeriodic
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestCustomAngleForce.h
View file @
2e9c418a
...
...
@@ -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-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -29,6 +29,9 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#ifdef WIN32
#define _USE_MATH_DEFINES // Needed to get M_PI
#endif
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomAngleForce.h"
...
...
@@ -145,6 +148,39 @@ void testIllegalVariable() {
ASSERT
(
threwException
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
1.5
,
0
),
Vec3
(
0
,
0
,
3
));
VerletIntegrator
integrator
(
0.01
);
CustomAngleForce
*
angles
=
new
CustomAngleForce
(
"0.5*k*(theta-theta0)^2"
);
angles
->
addPerAngleParameter
(
"theta0"
);
angles
->
addPerAngleParameter
(
"k"
);
vector
<
double
>
parameters
(
2
);
parameters
[
0
]
=
M_PI
/
3
;
parameters
[
1
]
=
1.1
;
angles
->
addAngle
(
0
,
1
,
2
,
parameters
);
angles
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
angles
);
angles
->
setUsesPeriodicBoundaryConditions
(
true
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
3
);
positions
[
0
]
=
Vec3
(
0
,
1
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
positions
[
2
]
=
Vec3
(
1
,
0
,
0
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces
=
state
.
getForces
();
double
torque
=
1.1
*
M_PI
/
6
;
ASSERT_EQUAL_VEC
(
Vec3
(
2
*
torque
,
0
,
0
),
forces
[
0
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
-
torque
,
0
),
forces
[
2
],
TOL
);
ASSERT_EQUAL_TOL
(
0.5
*
1.1
*
(
M_PI
/
6
)
*
(
M_PI
/
6
),
state
.
getPotentialEnergy
(),
TOL
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -152,6 +188,7 @@ int main(int argc, char* argv[]) {
initializeTests
(
argc
,
argv
);
testAngles
();
testIllegalVariable
();
testPeriodic
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestCustomBondForce.h
View file @
2e9c418a
...
...
@@ -148,6 +148,36 @@ void testIllegalVariable() {
ASSERT
(
threwException
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
VerletIntegrator
integrator
(
0.01
);
CustomBondForce
*
forceField
=
new
CustomBondForce
(
"scale*k*(r-r0)^2"
);
forceField
->
addPerBondParameter
(
"r0"
);
forceField
->
addPerBondParameter
(
"k"
);
forceField
->
addGlobalParameter
(
"scale"
,
0.5
);
vector
<
double
>
parameters
(
2
);
parameters
[
0
]
=
1.9
;
parameters
[
1
]
=
0.8
;
forceField
->
addBond
(
0
,
1
,
parameters
);
forceField
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
forceField
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
positions
[
0
]
=
Vec3
(
0
,
2
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces
=
state
.
getForces
();
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
-
0.8
*
0.9
,
0
),
forces
[
0
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0.8
*
0.9
,
0
),
forces
[
1
],
TOL
);
ASSERT_EQUAL_TOL
(
0.5
*
0.8
*
0.9
*
0.9
,
state
.
getPotentialEnergy
(),
TOL
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -156,6 +186,7 @@ int main(int argc, char* argv[]) {
testBonds
();
testManyParameters
();
testIllegalVariable
();
testPeriodic
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestCustomCentroidBondForce.h
View file @
2e9c418a
...
...
@@ -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) 2015 Stanford University and the Authors.
*
* Portions copyright (c) 2015
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -277,6 +277,62 @@ void testIllegalVariable() {
ASSERT
(
threwException
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
3.0
);
system
.
addParticle
(
4.0
);
system
.
addParticle
(
5.0
);
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
2
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
CustomCentroidBondForce
*
force
=
new
CustomCentroidBondForce
(
2
,
"k*distance(g1,g2)^2"
);
force
->
addPerBondParameter
(
"k"
);
vector
<
int
>
particles1
;
particles1
.
push_back
(
0
);
particles1
.
push_back
(
1
);
vector
<
int
>
particles2
;
particles2
.
push_back
(
2
);
particles2
.
push_back
(
3
);
particles2
.
push_back
(
4
);
force
->
addGroup
(
particles1
);
force
->
addGroup
(
particles2
);
vector
<
int
>
groups
;
groups
.
push_back
(
0
);
groups
.
push_back
(
1
);
vector
<
double
>
parameters
;
parameters
.
push_back
(
1.0
);
force
->
addBond
(
groups
,
parameters
);
force
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
force
);
// The center of mass of group 0 is (1.5, 0, 0).
vector
<
Vec3
>
positions
(
5
);
positions
[
0
]
=
Vec3
(
2.5
,
0
,
0
);
positions
[
1
]
=
Vec3
(
1
,
0
,
0
);
// The center of mass of group 1 is (-1, 0, 0).
positions
[
2
]
=
Vec3
(
-
6
,
0
,
0
);
positions
[
3
]
=
Vec3
(
-
1
,
0
,
0
);
positions
[
4
]
=
Vec3
(
2
,
0
,
0
);
// Check the forces and energy.
VerletIntegrator
integrator
(
0.01
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
0.5
*
0.5
,
state
.
getPotentialEnergy
(),
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
-
2
*
0.5
*
(
1.0
/
3.0
),
0
,
0
),
state
.
getForces
()[
0
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
-
2
*
0.5
*
(
2.0
/
3.0
),
0
,
0
),
state
.
getForces
()[
1
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
2
*
0.5
*
(
3.0
/
12.0
),
0
,
0
),
state
.
getForces
()[
2
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
2
*
0.5
*
(
4.0
/
12.0
),
0
,
0
),
state
.
getForces
()[
3
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
2
*
0.5
*
(
5.0
/
12.0
),
0
,
0
),
state
.
getForces
()[
4
],
TOL
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -286,6 +342,7 @@ int main(int argc, char* argv[]) {
testComplexFunction
();
testCustomWeights
();
testIllegalVariable
();
testPeriodic
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestCustomCompoundBondForce.h
View file @
2e9c418a
...
...
@@ -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) 2012-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2012-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -215,8 +215,8 @@ void testContinuous3DFunction() {
const
int
zsize
=
12
;
const
double
xmin
=
0.4
;
const
double
xmax
=
1.1
;
const
double
ymin
=
0
.0
;
const
double
ymax
=
0
.9
;
const
double
ymin
=
2
.0
;
const
double
ymax
=
2
.9
;
const
double
zmin
=
0.2
;
const
double
zmax
=
1.3
;
System
system
;
...
...
@@ -330,6 +330,82 @@ void testIllegalVariable() {
ASSERT
(
threwException
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
customSystem
;
customSystem
.
addParticle
(
1.0
);
customSystem
.
addParticle
(
1.0
);
customSystem
.
addParticle
(
1.0
);
customSystem
.
addParticle
(
1.0
);
customSystem
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
CustomCompoundBondForce
*
custom
=
new
CustomCompoundBondForce
(
4
,
"0.5*kb*((distance(p1,p2)-b0)^2+(distance(p2,p3)-b0)^2)+0.5*ka*(angle(p2,p3,p4)-a0)^2+kt*(1+cos(dihedral(p1,p2,p3,p4)-t0))"
);
custom
->
addPerBondParameter
(
"kb"
);
custom
->
addPerBondParameter
(
"ka"
);
custom
->
addPerBondParameter
(
"kt"
);
custom
->
addPerBondParameter
(
"b0"
);
custom
->
addPerBondParameter
(
"a0"
);
custom
->
addPerBondParameter
(
"t0"
);
vector
<
int
>
particles
(
4
);
particles
[
0
]
=
0
;
particles
[
1
]
=
1
;
particles
[
2
]
=
3
;
particles
[
3
]
=
2
;
vector
<
double
>
parameters
(
6
);
parameters
[
0
]
=
1.5
;
parameters
[
1
]
=
0.8
;
parameters
[
2
]
=
0.6
;
parameters
[
3
]
=
1.1
;
parameters
[
4
]
=
2.9
;
parameters
[
5
]
=
1.3
;
custom
->
addBond
(
particles
,
parameters
);
custom
->
setUsesPeriodicBoundaryConditions
(
true
);
customSystem
.
addForce
(
custom
);
// Create an identical system using standard forces.
System
standardSystem
;
standardSystem
.
addParticle
(
1.0
);
standardSystem
.
addParticle
(
1.0
);
standardSystem
.
addParticle
(
1.0
);
standardSystem
.
addParticle
(
1.0
);
standardSystem
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
bonds
->
addBond
(
0
,
1
,
1.1
,
1.5
);
bonds
->
addBond
(
1
,
3
,
1.1
,
1.5
);
bonds
->
setUsesPeriodicBoundaryConditions
(
true
);
standardSystem
.
addForce
(
bonds
);
HarmonicAngleForce
*
angles
=
new
HarmonicAngleForce
();
angles
->
addAngle
(
1
,
3
,
2
,
2.9
,
0.8
);
angles
->
setUsesPeriodicBoundaryConditions
(
true
);
standardSystem
.
addForce
(
angles
);
PeriodicTorsionForce
*
torsions
=
new
PeriodicTorsionForce
();
torsions
->
addTorsion
(
0
,
1
,
3
,
2
,
1
,
1.3
,
0.6
);
torsions
->
setUsesPeriodicBoundaryConditions
(
true
);
standardSystem
.
addForce
(
torsions
);
// Set the atoms in various positions, and verify that both systems give identical forces and energy.
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
c1
(
customSystem
,
integrator1
,
platform
);
Context
c2
(
standardSystem
,
integrator2
,
platform
);
vector
<
Vec3
>
positions
(
4
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
positions
[
j
]
=
Vec3
(
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
));
c1
.
setPositions
(
positions
);
c2
.
setPositions
(
positions
);
State
s1
=
c1
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
s2
=
c2
.
getState
(
State
::
Forces
|
State
::
Energy
);
for
(
int
i
=
0
;
i
<
customSystem
.
getNumParticles
();
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
TOL
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
TOL
);
}
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -341,6 +417,7 @@ int main(int argc, char* argv[]) {
testContinuous3DFunction
();
testMultipleBonds
();
testIllegalVariable
();
testPeriodic
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
tests/TestCustomIntegrator.h
View file @
2e9c418a
...
...
@@ -391,21 +391,21 @@ void testSum() {
}
CustomIntegrator
integrator
(
0.005
);
integrator
.
addGlobalVariable
(
"ke"
,
0
);
integrator
.
addGlobalVariable
(
"
kecopy
"
,
0
);
integrator
.
addGlobalVariable
(
"
temp
"
,
0
);
integrator
.
addComputePerDof
(
"v"
,
"v+dt*f/m"
);
integrator
.
addComputePerDof
(
"x"
,
"x+dt*v"
);
integrator
.
addComputeSum
(
"ke"
,
"m*v*v/2"
);
integrator
.
addComputeGlobal
(
"
kecopy
"
,
"ke"
);
integrator
.
addComputeGlobal
(
"
temp
"
,
"ke
+dt
"
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
// See if the sum is being computed correctly.
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
integrator
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Energy
);
ASSERT_EQUAL_TOL
(
state
.
getKineticEnergy
(),
integrator
.
getGlobalVariable
(
0
),
1e-5
);
ASSERT_EQUAL
(
integrator
.
getGlobalVariable
(
0
),
integrator
.
getGlobalVariable
(
1
));
integrator
.
step
(
1
);
ASSERT_EQUAL_TOL
(
integrator
.
getGlobalVariable
(
0
)
+
integrator
.
getStepSize
(),
integrator
.
getGlobalVariable
(
1
),
1e-5
);
}
}
...
...
tests/TestCustomNonbondedForce.h
View file @
2e9c418a
...
...
@@ -937,6 +937,37 @@ void testInteractionGroupLongRangeCorrection() {
ASSERT_EQUAL_TOL
(
expected
,
energy2
-
energy1
,
1e-4
);
}
void
testInteractionGroupTabulatedFunction
()
{
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
CustomNonbondedForce
*
forceField
=
new
CustomNonbondedForce
(
"fn(r-1)+1"
);
set
<
int
>
set1
,
set2
;
set1
.
insert
(
0
);
set2
.
insert
(
1
);
forceField
->
addInteractionGroup
(
set1
,
set2
);
forceField
->
addParticle
(
vector
<
double
>
());
forceField
->
addParticle
(
vector
<
double
>
());
vector
<
double
>
table
;
for
(
int
i
=
0
;
i
<
21
;
i
++
)
table
.
push_back
(
sin
(
0.25
*
i
));
forceField
->
addTabulatedFunction
(
"fn"
,
new
Discrete1DFunction
(
table
));
system
.
addForce
(
forceField
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
positions
[
0
]
=
Vec3
(
0
,
0
,
0
);
for
(
int
i
=
0
;
i
<
(
int
)
table
.
size
();
i
++
)
{
positions
[
1
]
=
Vec3
(
i
+
1
,
0
,
0
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces
=
state
.
getForces
();
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0
,
0
),
forces
[
0
],
1e-6
);
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0
,
0
),
forces
[
1
],
1e-6
);
ASSERT_EQUAL_TOL
(
table
[
i
]
+
1.0
,
state
.
getPotentialEnergy
(),
1e-6
);
}
}
void
testMultipleCutoffs
()
{
System
system
;
system
.
addParticle
(
1.0
);
...
...
@@ -1033,6 +1064,7 @@ int main(int argc, char* argv[]) {
testInteractionGroups
();
testLargeInteractionGroup
();
testInteractionGroupLongRangeCorrection
();
testInteractionGroupTabulatedFunction
();
testMultipleCutoffs
();
testIllegalVariable
();
runPlatformTests
();
...
...
Prev
1
…
8
9
10
11
12
13
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