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
c1df0025
Commit
c1df0025
authored
Jan 22, 2020
by
Andy Simmonett
Browse files
Reduce threshold for DrudeForce test in mixed/single precision
parent
ecbd2066
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
plugins/drude/tests/TestDrudeForce.h
plugins/drude/tests/TestDrudeForce.h
+6
-2
No files found.
plugins/drude/tests/TestDrudeForce.h
View file @
c1df0025
...
@@ -43,6 +43,8 @@
...
@@ -43,6 +43,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
bool
doublePrecision
=
false
;
void
validateForce
(
System
&
system
,
vector
<
Vec3
>&
positions
,
double
expectedEnergy
)
{
void
validateForce
(
System
&
system
,
vector
<
Vec3
>&
positions
,
double
expectedEnergy
)
{
// Given a System containing a Drude force, check that its energy has the expected value.
// Given a System containing a Drude force, check that its energy has the expected value.
...
@@ -54,7 +56,8 @@ void validateForce(System& system, vector<Vec3>& positions, double expectedEnerg
...
@@ -54,7 +56,8 @@ void validateForce(System& system, vector<Vec3>& positions, double expectedEnerg
// Try moving each particle along each axis, and see if the energy changes by the correct amount.
// Try moving each particle along each axis, and see if the energy changes by the correct amount.
double
offset
=
1e-3
;
double
offset
=
doublePrecision
?
1e-3
:
1e-2
;
const
double
TOL
=
doublePrecision
?
1e-5
:
5e-4
;
for
(
int
i
=
0
;
i
<
system
.
getNumParticles
();
i
++
)
for
(
int
i
=
0
;
i
<
system
.
getNumParticles
();
i
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
vector
<
Vec3
>
offsetPos
=
positions
;
vector
<
Vec3
>
offsetPos
=
positions
;
...
@@ -64,7 +67,7 @@ void validateForce(System& system, vector<Vec3>& positions, double expectedEnerg
...
@@ -64,7 +67,7 @@ void validateForce(System& system, vector<Vec3>& positions, double expectedEnerg
offsetPos
[
i
][
j
]
=
positions
[
i
][
j
]
+
offset
;
offsetPos
[
i
][
j
]
=
positions
[
i
][
j
]
+
offset
;
context
.
setPositions
(
offsetPos
);
context
.
setPositions
(
offsetPos
);
double
e2
=
context
.
getState
(
State
::
Energy
|
State
::
Forces
).
getPotentialEnergy
();
double
e2
=
context
.
getState
(
State
::
Energy
|
State
::
Forces
).
getPotentialEnergy
();
ASSERT_EQUAL_TOL
(
state
.
getForces
()[
i
][
j
],
(
e1
-
e2
)
/
(
2
*
offset
),
1e-5
);
ASSERT_EQUAL_TOL
(
state
.
getForces
()[
i
][
j
],
(
e1
-
e2
)
/
(
2
*
offset
),
TOL
);
}
}
}
}
...
@@ -193,6 +196,7 @@ void runPlatformTests();
...
@@ -193,6 +196,7 @@ void runPlatformTests();
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
try
{
setupKernels
(
argc
,
argv
);
setupKernels
(
argc
,
argv
);
if
(
argc
>
0
&&
std
::
string
(
argv
[
1
])
==
"double"
)
doublePrecision
=
true
;
testSingleParticle
();
testSingleParticle
();
testAnisotropicParticle
();
testAnisotropicParticle
();
testThole
();
testThole
();
...
...
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