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
d84d9098
Commit
d84d9098
authored
Jun 02, 2010
by
Peter Eastman
Browse files
Added test cases to verify that CustomTorsionForce returns the angle in the right range
parent
1ace7814
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
5 deletions
+110
-5
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
+35
-0
platforms/opencl/tests/TestOpenCLCustomTorsionForce.cpp
platforms/opencl/tests/TestOpenCLCustomTorsionForce.cpp
+37
-2
platforms/reference/tests/TestReferenceCustomTorsionForce.cpp
...forms/reference/tests/TestReferenceCustomTorsionForce.cpp
+38
-3
No files found.
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
View file @
d84d9098
...
...
@@ -120,9 +120,44 @@ void testTorsions() {
}
}
void
testRange
()
{
CudaPlatform
platform
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
CustomTorsionForce
*
custom
=
new
CustomTorsionForce
(
"theta"
);
custom
->
addTorsion
(
0
,
1
,
2
,
3
,
vector
<
double
>
());
system
.
addForce
(
custom
);
// Set the atoms in various positions, and verify that the angle is always in the expected range.
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
4
);
VerletIntegrator
integrator
(
0.01
);
double
minAngle
=
1000
;
double
maxAngle
=
-
1000
;
Context
context
(
system
,
integrator
,
platform
);
for
(
int
i
=
0
;
i
<
100
;
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
));
context
.
setPositions
(
positions
);
double
angle
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
if
(
angle
<
minAngle
)
minAngle
=
angle
;
if
(
angle
>
maxAngle
)
maxAngle
=
angle
;
}
ASSERT
(
minAngle
>=
-
M_PI
);
ASSERT
(
maxAngle
<=
M_PI
);
}
int
main
()
{
try
{
testTorsions
();
testRange
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
platforms/opencl/tests/TestOpenCLCustomTorsionForce.cpp
View file @
d84d9098
...
...
@@ -95,9 +95,9 @@ void testTorsions() {
vector
<
Vec3
>
positions
(
5
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
Context
c1
(
customSystem
,
integrator1
,
platform
);
Context
c2
(
harmonicSystem
,
integrator2
,
platform
);
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
);
...
...
@@ -110,9 +110,44 @@ void testTorsions() {
}
}
void
testRange
()
{
OpenCLPlatform
platform
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
CustomTorsionForce
*
custom
=
new
CustomTorsionForce
(
"theta"
);
custom
->
addTorsion
(
0
,
1
,
2
,
3
,
vector
<
double
>
());
system
.
addForce
(
custom
);
// Set the atoms in various positions, and verify that the angle is always in the expected range.
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
4
);
VerletIntegrator
integrator
(
0.01
);
double
minAngle
=
1000
;
double
maxAngle
=
-
1000
;
Context
context
(
system
,
integrator
,
platform
);
for
(
int
i
=
0
;
i
<
100
;
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
));
context
.
setPositions
(
positions
);
double
angle
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
if
(
angle
<
minAngle
)
minAngle
=
angle
;
if
(
angle
>
maxAngle
)
maxAngle
=
angle
;
}
ASSERT
(
minAngle
>=
-
M_PI
);
ASSERT
(
maxAngle
<=
M_PI
);
}
int
main
()
{
try
{
testTorsions
();
testRange
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
platforms/reference/tests/TestReferenceCustomTorsionForce.cpp
View file @
d84d9098
...
...
@@ -95,9 +95,9 @@ void testTorsions() {
vector
<
Vec3
>
positions
(
5
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
Context
c1
(
customSystem
,
integrator1
,
platform
);
Context
c2
(
harmonicSystem
,
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
);
...
...
@@ -110,9 +110,44 @@ void testTorsions() {
}
}
void
testRange
()
{
ReferencePlatform
platform
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
CustomTorsionForce
*
custom
=
new
CustomTorsionForce
(
"theta"
);
custom
->
addTorsion
(
0
,
1
,
2
,
3
,
vector
<
double
>
());
system
.
addForce
(
custom
);
// Set the atoms in various positions, and verify that the angle is always in the expected range.
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
4
);
VerletIntegrator
integrator
(
0.01
);
double
minAngle
=
1000
;
double
maxAngle
=
-
1000
;
Context
context
(
system
,
integrator
,
platform
);
for
(
int
i
=
0
;
i
<
100
;
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
));
context
.
setPositions
(
positions
);
double
angle
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
if
(
angle
<
minAngle
)
minAngle
=
angle
;
if
(
angle
>
maxAngle
)
maxAngle
=
angle
;
}
ASSERT
(
minAngle
>=
-
M_PI
);
ASSERT
(
maxAngle
<=
M_PI
);
}
int
main
()
{
try
{
testTorsions
();
testRange
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
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