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
80c69c93
Commit
80c69c93
authored
Mar 12, 2010
by
Mark Friedrichs
Browse files
Added collinear atoms test
parent
18ee451c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
platforms/cuda/tests/TestCudaHarmonicAngleForce.cpp
platforms/cuda/tests/TestCudaHarmonicAngleForce.cpp
+33
-0
No files found.
platforms/cuda/tests/TestCudaHarmonicAngleForce.cpp
View file @
80c69c93
...
@@ -77,9 +77,42 @@ void testAngles() {
...
@@ -77,9 +77,42 @@ void testAngles() {
ASSERT_EQUAL_TOL
(
0.5
*
1.1
*
(
PI_M
/
6
)
*
(
PI_M
/
6
)
+
0.5
*
1.2
*
(
PI_M
/
4
)
*
(
PI_M
/
4
),
state
.
getPotentialEnergy
(),
TOL
);
ASSERT_EQUAL_TOL
(
0.5
*
1.1
*
(
PI_M
/
6
)
*
(
PI_M
/
6
)
+
0.5
*
1.2
*
(
PI_M
/
4
)
*
(
PI_M
/
4
),
state
.
getPotentialEnergy
(),
TOL
);
}
}
void
testCollinear
()
{
CudaPlatform
platform
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
HarmonicAngleForce
*
forceField
=
new
HarmonicAngleForce
();
forceField
->
addAngle
(
0
,
1
,
2
,
M_PI
*
120.
/
180.
,
10.0
);
system
.
addForce
(
forceField
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
3
);
for
(
int
a
=
0
;
a
<
3
;
++
a
)
{
positions
[
a
]
=
OpenMM
::
Vec3
(
0.5
*
a
,
0
,
0
);
// location, nm
}
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces
=
state
.
getForces
();
double
expectedEnergy
=
10.0
*
0.5
*
(
PI_M
/
3.0
)
*
(
PI_M
/
3.0
);
#if 0
{
(void) fprintf( stderr, "testCollinear: E=%12.5f %12.5f\n", state.getPotentialEnergy(), expectedEnergy );
for (int a = 0; a < 3; ++a) {
(void) fprintf( stderr, "%3d F[%12.5f %12.5f %12.5f]\n", a, forces[a][0], forces[a][1], forces[a][2] );
}
}
#endif
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0
,
0
),
forces
[
0
],
TOL
);
ASSERT_EQUAL_TOL
(
expectedEnergy
,
state
.
getPotentialEnergy
(),
TOL
);
}
int
main
()
{
int
main
()
{
try
{
try
{
testAngles
();
testAngles
();
testCollinear
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
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