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
cc6a0ac8
Commit
cc6a0ac8
authored
Jan 22, 2020
by
Andy Simmonett
Browse files
Fix precision issues in Drude tests
parent
012f6eb4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
plugins/drude/tests/TestDrudeForce.h
plugins/drude/tests/TestDrudeForce.h
+11
-6
plugins/drude/tests/TestDrudeSCFIntegrator.h
plugins/drude/tests/TestDrudeSCFIntegrator.h
+10
-1
No files found.
plugins/drude/tests/TestDrudeForce.h
View file @
cc6a0ac8
...
...
@@ -32,6 +32,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/NonbondedForce.h"
#include "openmm/OpenMMException.h"
#include "openmm/Platform.h"
#include "openmm/System.h"
#include "openmm/VerletIntegrator.h"
...
...
@@ -43,8 +44,6 @@
using
namespace
OpenMM
;
using
namespace
std
;
bool
doublePrecision
=
false
;
void
validateForce
(
System
&
system
,
vector
<
Vec3
>&
positions
,
double
expectedEnergy
)
{
// Given a System containing a Drude force, check that its energy has the expected value.
...
...
@@ -55,9 +54,16 @@ void validateForce(System& system, vector<Vec3>& positions, double expectedEnerg
ASSERT_EQUAL_TOL
(
expectedEnergy
,
state
.
getPotentialEnergy
(),
1e-5
);
// Try moving each particle along each axis, and see if the energy changes by the correct amount.
double
offset
=
doublePrecision
?
1e-3
:
1e-2
;
const
double
TOL
=
doublePrecision
?
1e-5
:
5e-4
;
double
offset
=
1e-3
;
double
TOL
=
1e-5
;
try
{
if
(
platform
.
getPropertyValue
(
context
,
"Precision"
)
!=
"double"
)
{
offset
=
1e-2
;
TOL
=
5e-4
;
}
}
catch
(
OpenMMException
)
{
// The defaults above are for double precision, which is assumed in this case
}
for
(
int
i
=
0
;
i
<
system
.
getNumParticles
();
i
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
vector
<
Vec3
>
offsetPos
=
positions
;
...
...
@@ -196,7 +202,6 @@ void runPlatformTests();
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
setupKernels
(
argc
,
argv
);
if
(
argc
>
0
&&
std
::
string
(
argv
[
1
])
==
"double"
)
doublePrecision
=
true
;
testSingleParticle
();
testAnisotropicParticle
();
testThole
();
...
...
plugins/drude/tests/TestDrudeSCFIntegrator.h
View file @
cc6a0ac8
...
...
@@ -36,6 +36,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/NonbondedForce.h"
#include "openmm/OpenMMException.h"
#include "openmm/Platform.h"
#include "openmm/System.h"
#include "openmm/VirtualSite.h"
...
...
@@ -106,6 +107,14 @@ void testWater() {
State
state
=
context
.
getState
(
State
::
Energy
);
double
initialEnergy
;
int
numSteps
=
1000
;
double
maxNorm
=
1.0
;
try
{
if
(
platform
.
getPropertyValue
(
context
,
"Precision"
)
!=
"double"
)
{
maxNorm
=
5.0
;
}
}
catch
(
OpenMMException
)
{
// The defaults above are for double precision, which is assumed in this case
}
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
integ
.
step
(
1
);
state
=
context
.
getState
(
State
::
Energy
|
State
::
Forces
);
...
...
@@ -118,7 +127,7 @@ void testWater() {
for
(
int
j
=
1
;
j
<
(
int
)
force
.
size
();
j
+=
5
)
norm
+=
sqrt
(
force
[
j
].
dot
(
force
[
j
]));
norm
=
(
norm
/
numMolecules
);
ASSERT
(
norm
<
1.0
);
ASSERT
(
norm
<
maxNorm
);
}
}
...
...
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