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
dd1a959b
Commit
dd1a959b
authored
Jun 21, 2010
by
Peter Eastman
Browse files
Long range dispersion correction is enabled by default
parent
5228a07e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
20 deletions
+19
-20
openmmapi/src/NonbondedForce.cpp
openmmapi/src/NonbondedForce.cpp
+1
-1
openmmapi/src/NonbondedForceImpl.cpp
openmmapi/src/NonbondedForceImpl.cpp
+3
-4
platforms/cuda/tests/TestCudaNonbondedForce.cpp
platforms/cuda/tests/TestCudaNonbondedForce.cpp
+5
-5
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
+5
-5
platforms/reference/tests/TestReferenceNonbondedForce.cpp
platforms/reference/tests/TestReferenceNonbondedForce.cpp
+5
-5
No files found.
openmmapi/src/NonbondedForce.cpp
View file @
dd1a959b
...
@@ -46,7 +46,7 @@ using std::string;
...
@@ -46,7 +46,7 @@ using std::string;
using
std
::
stringstream
;
using
std
::
stringstream
;
using
std
::
vector
;
using
std
::
vector
;
NonbondedForce
::
NonbondedForce
()
:
nonbondedMethod
(
NoCutoff
),
cutoffDistance
(
1.0
),
rfDielectric
(
78.3
),
ewaldErrorTol
(
5e-4
),
useDispersionCorrection
(
fals
e
)
{
NonbondedForce
::
NonbondedForce
()
:
nonbondedMethod
(
NoCutoff
),
cutoffDistance
(
1.0
),
rfDielectric
(
78.3
),
ewaldErrorTol
(
5e-4
),
useDispersionCorrection
(
tru
e
)
{
}
}
NonbondedForce
::
NonbondedMethod
NonbondedForce
::
getNonbondedMethod
()
const
{
NonbondedForce
::
NonbondedMethod
NonbondedForce
::
getNonbondedMethod
()
const
{
...
...
openmmapi/src/NonbondedForceImpl.cpp
View file @
dd1a959b
...
@@ -95,10 +95,6 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
...
@@ -95,10 +95,6 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
throw
OpenMMException
(
"NonbondedForce: The cutoff distance cannot be greater than half the periodic box size."
);
throw
OpenMMException
(
"NonbondedForce: The cutoff distance cannot be greater than half the periodic box size."
);
}
}
else
{
if
(
owner
.
getUseDispersionCorrection
())
throw
OpenMMException
(
"NonbondedForce: Dispersion correction may only be used with periodic boundary conditions."
);
}
dynamic_cast
<
CalcNonbondedForceKernel
&>
(
kernel
.
getImpl
()).
initialize
(
context
.
getSystem
(),
owner
);
dynamic_cast
<
CalcNonbondedForceKernel
&>
(
kernel
.
getImpl
()).
initialize
(
context
.
getSystem
(),
owner
);
}
}
...
@@ -176,6 +172,9 @@ int NonbondedForceImpl::findZero(const NonbondedForceImpl::ErrorFunction& f, int
...
@@ -176,6 +172,9 @@ int NonbondedForceImpl::findZero(const NonbondedForceImpl::ErrorFunction& f, int
}
}
double
NonbondedForceImpl
::
calcDispersionCorrection
(
const
System
&
system
,
const
NonbondedForce
&
force
)
{
double
NonbondedForceImpl
::
calcDispersionCorrection
(
const
System
&
system
,
const
NonbondedForce
&
force
)
{
if
(
force
.
getNonbondedMethod
()
==
NonbondedForce
::
NoCutoff
||
force
.
getNonbondedMethod
()
==
NonbondedForce
::
CutoffNonPeriodic
)
return
0.0
;
// Identify all particle classes (defined by sigma and epsilon), and count the number of
// Identify all particle classes (defined by sigma and epsilon), and count the number of
// particles in each class.
// particles in each class.
...
...
platforms/cuda/tests/TestCudaNonbondedForce.cpp
View file @
dd1a959b
...
@@ -631,14 +631,14 @@ void testDispersionCorrection() {
...
@@ -631,14 +631,14 @@ void testDispersionCorrection() {
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
double
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
double
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
term1
=
(
0.5
*
pow
(
1.1
,
12
)
/
pow
(
cutoff
,
9
))
/
9
;
double
term1
=
(
0.5
*
pow
(
1.1
,
12
)
/
pow
(
cutoff
,
9
))
/
9
;
double
term2
=
(
0.5
*
pow
(
1.1
,
6
)
/
pow
(
cutoff
,
3
))
/
3
;
double
term2
=
(
0.5
*
pow
(
1.1
,
6
)
/
pow
(
cutoff
,
3
))
/
3
;
double
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
double
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
ASSERT_EQUAL_TOL
(
expected
,
energy
2
-
energy
1
,
1e-4
);
ASSERT_EQUAL_TOL
(
expected
,
energy
1
-
energy
2
,
1e-4
);
// Now modify half the particles to be different, and see if it is still correct.
// Now modify half the particles to be different, and see if it is still correct.
...
@@ -648,11 +648,11 @@ void testDispersionCorrection() {
...
@@ -648,11 +648,11 @@ void testDispersionCorrection() {
numType2
++
;
numType2
++
;
}
}
int
numType1
=
numParticles
-
numType2
;
int
numType1
=
numParticles
-
numType2
;
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
...
@@ -667,7 +667,7 @@ void testDispersionCorrection() {
...
@@ -667,7 +667,7 @@ void testDispersionCorrection() {
term1
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term1
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term2
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term2
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
ASSERT_EQUAL_TOL
(
expected
,
energy
2
-
energy
1
,
1e-4
);
ASSERT_EQUAL_TOL
(
expected
,
energy
1
-
energy
2
,
1e-4
);
}
}
int
main
()
{
int
main
()
{
...
...
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
View file @
dd1a959b
...
@@ -636,14 +636,14 @@ void testDispersionCorrection() {
...
@@ -636,14 +636,14 @@ void testDispersionCorrection() {
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
double
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
double
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
term1
=
(
0.5
*
pow
(
1.1
,
12
)
/
pow
(
cutoff
,
9
))
/
9
;
double
term1
=
(
0.5
*
pow
(
1.1
,
12
)
/
pow
(
cutoff
,
9
))
/
9
;
double
term2
=
(
0.5
*
pow
(
1.1
,
6
)
/
pow
(
cutoff
,
3
))
/
3
;
double
term2
=
(
0.5
*
pow
(
1.1
,
6
)
/
pow
(
cutoff
,
3
))
/
3
;
double
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
double
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
ASSERT_EQUAL_TOL
(
expected
,
energy
2
-
energy
1
,
1e-4
);
ASSERT_EQUAL_TOL
(
expected
,
energy
1
-
energy
2
,
1e-4
);
// Now modify half the particles to be different, and see if it is still correct.
// Now modify half the particles to be different, and see if it is still correct.
...
@@ -653,11 +653,11 @@ void testDispersionCorrection() {
...
@@ -653,11 +653,11 @@ void testDispersionCorrection() {
numType2
++
;
numType2
++
;
}
}
int
numType1
=
numParticles
-
numType2
;
int
numType1
=
numParticles
-
numType2
;
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
...
@@ -672,7 +672,7 @@ void testDispersionCorrection() {
...
@@ -672,7 +672,7 @@ void testDispersionCorrection() {
term1
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term1
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term2
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term2
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
ASSERT_EQUAL_TOL
(
expected
,
energy
2
-
energy
1
,
1e-4
);
ASSERT_EQUAL_TOL
(
expected
,
energy
1
-
energy
2
,
1e-4
);
}
}
int
main
()
{
int
main
()
{
...
...
platforms/reference/tests/TestReferenceNonbondedForce.cpp
View file @
dd1a959b
...
@@ -384,14 +384,14 @@ void testDispersionCorrection() {
...
@@ -384,14 +384,14 @@ void testDispersionCorrection() {
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
double
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
double
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
term1
=
(
0.5
*
pow
(
1.1
,
12
)
/
pow
(
cutoff
,
9
))
/
9
;
double
term1
=
(
0.5
*
pow
(
1.1
,
12
)
/
pow
(
cutoff
,
9
))
/
9
;
double
term2
=
(
0.5
*
pow
(
1.1
,
6
)
/
pow
(
cutoff
,
3
))
/
3
;
double
term2
=
(
0.5
*
pow
(
1.1
,
6
)
/
pow
(
cutoff
,
3
))
/
3
;
double
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
double
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
ASSERT_EQUAL_TOL
(
expected
,
energy
2
-
energy
1
,
1e-4
);
ASSERT_EQUAL_TOL
(
expected
,
energy
1
-
energy
2
,
1e-4
);
// Now modify half the particles to be different, and see if it is still correct.
// Now modify half the particles to be different, and see if it is still correct.
...
@@ -401,11 +401,11 @@ void testDispersionCorrection() {
...
@@ -401,11 +401,11 @@ void testDispersionCorrection() {
numType2
++
;
numType2
++
;
}
}
int
numType1
=
numParticles
-
numType2
;
int
numType1
=
numParticles
-
numType2
;
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
energy1
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
nonbonded
->
setUseDispersionCorrection
(
tru
e
);
nonbonded
->
setUseDispersionCorrection
(
fals
e
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
energy2
=
context
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
...
@@ -420,7 +420,7 @@ void testDispersionCorrection() {
...
@@ -420,7 +420,7 @@ void testDispersionCorrection() {
term1
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term1
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term2
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
term2
/=
(
numParticles
*
(
numParticles
+
1
))
/
2
;
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
expected
=
8
*
M_PI
*
numParticles
*
numParticles
*
(
term1
-
term2
)
/
(
boxSize
*
boxSize
*
boxSize
);
ASSERT_EQUAL_TOL
(
expected
,
energy
2
-
energy
1
,
1e-4
);
ASSERT_EQUAL_TOL
(
expected
,
energy
1
-
energy
2
,
1e-4
);
}
}
int
main
()
{
int
main
()
{
...
...
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