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
29e3fa57
Commit
29e3fa57
authored
Apr 17, 2009
by
Peter Eastman
Browse files
Redesigned the API for specifying exclusions and 1-4 interactions.
parent
afd06645
Changes
34
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
236 additions
and
325 deletions
+236
-325
platforms/cuda/tests/TestCudaNonbondedForce.cpp
platforms/cuda/tests/TestCudaNonbondedForce.cpp
+68
-48
platforms/cuda/tests/TestCudaSettle.cpp
platforms/cuda/tests/TestCudaSettle.cpp
+4
-4
platforms/cuda/tests/TestCudaVerletIntegrator.cpp
platforms/cuda/tests/TestCudaVerletIntegrator.cpp
+2
-2
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+20
-3
platforms/reference/src/ReferenceKernels.h
platforms/reference/src/ReferenceKernels.h
+1
-4
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
...forms/reference/tests/TestReferenceAndersenThermostat.cpp
+4
-4
platforms/reference/tests/TestReferenceBrownianIntegrator.cpp
...forms/reference/tests/TestReferenceBrownianIntegrator.cpp
+4
-4
platforms/reference/tests/TestReferenceCMMotionRemover.cpp
platforms/reference/tests/TestReferenceCMMotionRemover.cpp
+2
-2
platforms/reference/tests/TestReferenceEwald.cpp
platforms/reference/tests/TestReferenceEwald.cpp
+3
-3
platforms/reference/tests/TestReferenceGBSAOBCForce.cpp
platforms/reference/tests/TestReferenceGBSAOBCForce.cpp
+3
-3
platforms/reference/tests/TestReferenceLangevinIntegrator.cpp
...forms/reference/tests/TestReferenceLangevinIntegrator.cpp
+6
-6
platforms/reference/tests/TestReferenceNonbondedForce.cpp
platforms/reference/tests/TestReferenceNonbondedForce.cpp
+61
-39
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
+2
-2
tests/TestFindExclusions.cpp
tests/TestFindExclusions.cpp
+56
-201
No files found.
platforms/cuda/tests/TestCudaNonbondedForce.cpp
View file @
29e3fa57
...
@@ -58,9 +58,9 @@ void testCoulomb() {
...
@@ -58,9 +58,9 @@ void testCoulomb() {
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
2
,
0
);
System
system
(
2
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
forceField
->
set
Particle
Parameters
(
0
,
0.5
,
1
,
0
);
forceField
->
add
Particle
(
0.5
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
-
1.5
,
1
,
0
);
forceField
->
add
Particle
(
-
1.5
,
1
,
0
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
vector
<
Vec3
>
positions
(
2
);
...
@@ -79,9 +79,9 @@ void testLJ() {
...
@@ -79,9 +79,9 @@ void testLJ() {
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
2
,
0
);
System
system
(
2
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
forceField
->
set
Particle
Parameters
(
0
,
0
,
1.2
,
1
);
forceField
->
add
Particle
(
0
,
1.2
,
1
);
forceField
->
set
Particle
Parameters
(
1
,
0
,
1.4
,
2
);
forceField
->
add
Particle
(
0
,
1.4
,
2
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
vector
<
Vec3
>
positions
(
2
);
...
@@ -102,13 +102,25 @@ void testExclusionsAnd14() {
...
@@ -102,13 +102,25 @@ void testExclusionsAnd14() {
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
5
,
0
);
System
system
(
5
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
4
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
bonds
->
setBondParameters
(
1
,
1
,
2
,
1
,
0
);
nonbonded
->
addParticle
(
0
,
1.5
,
0
);
bonds
->
setBondParameters
(
2
,
2
,
3
,
1
,
0
);
vector
<
pair
<
int
,
int
>
>
bonds
;
bonds
->
setBondParameters
(
3
,
3
,
4
,
1
,
0
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
system
.
addForce
(
bonds
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
1
,
2
));
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
5
,
2
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
2
,
3
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
3
,
4
));
nonbonded
->
createExceptionsFromBonds
(
bonds
,
0.0
,
0.0
);
int
first14
,
second14
;
for
(
int
i
=
0
;
i
<
nonbonded
->
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
nonbonded
->
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
if
((
particle1
==
0
&&
particle2
==
3
)
||
(
particle1
==
3
&&
particle2
==
0
))
first14
=
i
;
if
((
particle1
==
1
&&
particle2
==
4
)
||
(
particle1
==
4
&&
particle2
==
1
))
second14
=
i
;
}
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
for
(
int
i
=
1
;
i
<
5
;
++
i
)
{
for
(
int
i
=
1
;
i
<
5
;
++
i
)
{
...
@@ -122,8 +134,8 @@ void testExclusionsAnd14() {
...
@@ -122,8 +134,8 @@ void testExclusionsAnd14() {
}
}
nonbonded
->
setParticleParameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
...
@@ -149,8 +161,8 @@ void testExclusionsAnd14() {
...
@@ -149,8 +161,8 @@ void testExclusionsAnd14() {
nonbonded
->
setParticleParameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
OpenMMContext
context2
(
system
,
integrator
,
platform
);
OpenMMContext
context2
(
system
,
integrator
,
platform
);
context2
.
setPositions
(
positions
);
context2
.
setPositions
(
positions
);
state
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
state
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -175,10 +187,10 @@ void testCutoff() {
...
@@ -175,10 +187,10 @@ void testCutoff() {
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
3
,
0
);
System
system
(
3
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
3
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
forceField
->
set
Particle
Parameters
(
0
,
1.0
,
1
,
0
);
forceField
->
add
Particle
(
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
1.0
,
1
,
0
);
forceField
->
add
Particle
(
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
2
,
1.0
,
1
,
0
);
forceField
->
add
Particle
(
1.0
,
1
,
0
);
forceField
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
forceField
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
const
double
cutoff
=
2.9
;
const
double
cutoff
=
2.9
;
forceField
->
setCutoffDistance
(
cutoff
);
forceField
->
setCutoffDistance
(
cutoff
);
...
@@ -208,18 +220,28 @@ void testCutoff14() {
...
@@ -208,18 +220,28 @@ void testCutoff14() {
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
5
,
0
);
System
system
(
5
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
4
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
bonds
->
setBondParameters
(
1
,
1
,
2
,
1
,
0
);
bonds
->
setBondParameters
(
2
,
2
,
3
,
1
,
0
);
bonds
->
setBondParameters
(
3
,
3
,
4
,
1
,
0
);
system
.
addForce
(
bonds
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
5
,
2
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
0
,
1.5
,
0.0
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.
0
);
nonbonded
->
addParticle
(
0
,
1.5
,
0
);
const
double
cutoff
=
3.5
;
const
double
cutoff
=
3.5
;
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
vector
<
pair
<
int
,
int
>
>
bonds
;
bonds
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
1
,
2
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
2
,
3
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
3
,
4
));
nonbonded
->
createExceptionsFromBonds
(
bonds
,
0.0
,
0.0
);
int
first14
,
second14
;
for
(
int
i
=
0
;
i
<
nonbonded
->
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
nonbonded
->
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
if
((
particle1
==
0
&&
particle2
==
3
)
||
(
particle1
==
3
&&
particle2
==
0
))
first14
=
i
;
if
((
particle1
==
1
&&
particle2
==
4
)
||
(
particle1
==
4
&&
particle2
==
1
))
second14
=
i
;
}
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
5
);
vector
<
Vec3
>
positions
(
5
);
...
@@ -236,8 +258,8 @@ void testCutoff14() {
...
@@ -236,8 +258,8 @@ void testCutoff14() {
for
(
int
j
=
1
;
j
<
5
;
++
j
)
for
(
int
j
=
1
;
j
<
5
;
++
j
)
nonbonded
->
setParticleParameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -264,8 +286,8 @@ void testCutoff14() {
...
@@ -264,8 +286,8 @@ void testCutoff14() {
const
double
q
=
0.7
;
const
double
q
=
0.7
;
nonbonded
->
setParticleParameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
i
==
3
?
q
*
q
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
i
==
3
?
q
*
q
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -293,13 +315,11 @@ void testPeriodic() {
...
@@ -293,13 +315,11 @@ void testPeriodic() {
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
3
,
0
);
System
system
(
3
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
1
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
nonbonded
->
addParticle
(
1.0
,
1
,
0
);
system
.
addForce
(
bonds
);
nonbonded
->
addParticle
(
1.0
,
1
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
3
,
0
);
nonbonded
->
addParticle
(
1.0
,
1
,
0
);
nonbonded
->
setParticleParameters
(
0
,
1.0
,
1
,
0
);
nonbonded
->
addException
(
0
,
1
,
0.0
,
1.0
,
0.0
);
nonbonded
->
setParticleParameters
(
1
,
1.0
,
1
,
0
);
nonbonded
->
setParticleParameters
(
2
,
1.0
,
1
,
0
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
const
double
cutoff
=
2.0
;
const
double
cutoff
=
2.0
;
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
...
@@ -333,19 +353,19 @@ void testLargeSystem() {
...
@@ -333,19 +353,19 @@ void testLargeSystem() {
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
(
numParticles
,
0
);
System
system
(
numParticles
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
numMolecules
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
numMolecules
);
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
velocities
(
numParticles
);
vector
<
Vec3
>
velocities
(
numParticles
);
init_gen_rand
(
0
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
if
(
i
<
numMolecules
/
2
)
{
if
(
i
<
numMolecules
/
2
)
{
nonbonded
->
set
Particle
Parameters
(
2
*
i
,
1.0
,
0.2
,
0.1
);
nonbonded
->
add
Particle
(
1.0
,
0.2
,
0.1
);
nonbonded
->
set
Particle
Parameters
(
2
*
i
+
1
,
1.0
,
0.1
,
0.1
);
nonbonded
->
add
Particle
(
1.0
,
0.1
,
0.1
);
}
}
else
{
else
{
nonbonded
->
set
Particle
Parameters
(
2
*
i
,
1.0
,
0.2
,
0.2
);
nonbonded
->
add
Particle
(
1.0
,
0.2
,
0.2
);
nonbonded
->
set
Particle
Parameters
(
2
*
i
+
1
,
1.0
,
0.1
,
0.2
);
nonbonded
->
add
Particle
(
1.0
,
0.1
,
0.2
);
}
}
positions
[
2
*
i
]
=
Vec3
(
boxSize
*
genrand_real2
(),
boxSize
*
genrand_real2
(),
boxSize
*
genrand_real2
());
positions
[
2
*
i
]
=
Vec3
(
boxSize
*
genrand_real2
(),
boxSize
*
genrand_real2
(),
boxSize
*
genrand_real2
());
positions
[
2
*
i
+
1
]
=
Vec3
(
positions
[
2
*
i
][
0
]
+
1.0
,
positions
[
2
*
i
][
1
],
positions
[
2
*
i
][
2
]);
positions
[
2
*
i
+
1
]
=
Vec3
(
positions
[
2
*
i
][
0
]
+
1.0
,
positions
[
2
*
i
][
1
],
positions
[
2
*
i
][
2
]);
...
@@ -405,11 +425,11 @@ void testBlockInteractions(bool periodic) {
...
@@ -405,11 +425,11 @@ void testBlockInteractions(bool periodic) {
CudaPlatform
cuda
;
CudaPlatform
cuda
;
System
system
(
numParticles
,
0
);
System
system
(
numParticles
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
init_gen_rand
(
0
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
nonbonded
->
set
Particle
Parameters
(
i
,
1.0
,
0.2
,
0.2
);
nonbonded
->
add
Particle
(
1.0
,
0.2
,
0.2
);
positions
[
i
]
=
Vec3
(
boxSize
*
(
3
*
genrand_real2
()
-
1
),
boxSize
*
(
3
*
genrand_real2
()
-
1
),
boxSize
*
(
3
*
genrand_real2
()
-
1
));
positions
[
i
]
=
Vec3
(
boxSize
*
(
3
*
genrand_real2
()
-
1
),
boxSize
*
(
3
*
genrand_real2
()
-
1
),
boxSize
*
(
3
*
genrand_real2
()
-
1
));
}
}
nonbonded
->
setNonbondedMethod
(
periodic
?
NonbondedForce
::
CutoffPeriodic
:
NonbondedForce
::
CutoffNonPeriodic
);
nonbonded
->
setNonbondedMethod
(
periodic
?
NonbondedForce
::
CutoffPeriodic
:
NonbondedForce
::
CutoffNonPeriodic
);
...
...
platforms/cuda/tests/TestCudaSettle.cpp
View file @
29e3fa57
...
@@ -56,14 +56,14 @@ void testConstraints() {
...
@@ -56,14 +56,14 @@ void testConstraints() {
System
system
(
numParticles
,
numConstraints
);
System
system
(
numParticles
,
numConstraints
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.001
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.001
);
integrator
.
setConstraintTolerance
(
1e-5
);
integrator
.
setConstraintTolerance
(
1e-5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numMolecules
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numMolecules
;
++
i
)
{
system
.
setParticleMass
(
i
*
3
,
16.0
);
system
.
setParticleMass
(
i
*
3
,
16.0
);
system
.
setParticleMass
(
i
*
3
+
1
,
1.0
);
system
.
setParticleMass
(
i
*
3
+
1
,
1.0
);
system
.
setParticleMass
(
i
*
3
+
2
,
1.0
);
system
.
setParticleMass
(
i
*
3
+
2
,
1.0
);
forceField
->
set
Particle
Parameters
(
i
*
3
,
-
0.82
,
0.317
,
0.65
);
forceField
->
add
Particle
(
-
0.82
,
0.317
,
0.65
);
forceField
->
set
Particle
Parameters
(
i
*
3
+
1
,
0.41
,
1.0
,
0.0
);
forceField
->
add
Particle
(
0.41
,
1.0
,
0.0
);
forceField
->
set
Particle
Parameters
(
i
*
3
+
2
,
0.41
,
1.0
,
0.0
);
forceField
->
add
Particle
(
0.41
,
1.0
,
0.0
);
system
.
setConstraintParameters
(
i
*
3
,
i
*
3
,
i
*
3
+
1
,
0.1
);
system
.
setConstraintParameters
(
i
*
3
,
i
*
3
,
i
*
3
+
1
,
0.1
);
system
.
setConstraintParameters
(
i
*
3
+
1
,
i
*
3
,
i
*
3
+
2
,
0.1
);
system
.
setConstraintParameters
(
i
*
3
+
1
,
i
*
3
,
i
*
3
+
2
,
0.1
);
system
.
setConstraintParameters
(
i
*
3
+
2
,
i
*
3
+
1
,
i
*
3
+
2
,
0.163
);
system
.
setConstraintParameters
(
i
*
3
+
2
,
i
*
3
+
1
,
i
*
3
+
2
,
0.163
);
...
...
platforms/cuda/tests/TestCudaVerletIntegrator.cpp
View file @
29e3fa57
...
@@ -93,10 +93,10 @@ void testConstraints() {
...
@@ -93,10 +93,10 @@ void testConstraints() {
System
system
(
numParticles
,
numConstraints
);
System
system
(
numParticles
,
numConstraints
);
VerletIntegrator
integrator
(
0.001
);
VerletIntegrator
integrator
(
0.001
);
integrator
.
setConstraintTolerance
(
1e-5
);
integrator
.
setConstraintTolerance
(
1e-5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
10.0
);
system
.
setParticleMass
(
i
,
10.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
}
system
.
setConstraintParameters
(
0
,
0
,
1
,
1.0
);
system
.
setConstraintParameters
(
0
,
0
,
1
,
1.0
);
system
.
setConstraintParameters
(
1
,
1
,
2
,
1.0
);
system
.
setConstraintParameters
(
1
,
1
,
2
,
1.0
);
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
29e3fa57
...
@@ -306,9 +306,26 @@ ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() {
...
@@ -306,9 +306,26 @@ ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() {
delete
neighborList
;
delete
neighborList
;
}
}
void
ReferenceCalcNonbondedForceKernel
::
initialize
(
const
System
&
system
,
const
NonbondedForce
&
force
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
)
{
void
ReferenceCalcNonbondedForceKernel
::
initialize
(
const
System
&
system
,
const
NonbondedForce
&
force
)
{
// Identify which exceptions are 1-4 interactions.
numParticles
=
force
.
getNumParticles
();
numParticles
=
force
.
getNumParticles
();
num14
=
force
.
getNumNonbonded14
();
exclusions
.
resize
(
numParticles
);
vector
<
int
>
nb14s
;
for
(
int
i
=
0
;
i
<
force
.
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
force
.
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
exclusions
[
particle1
].
insert
(
particle2
);
exclusions
[
particle2
].
insert
(
particle1
);
if
(
chargeProd
!=
0.0
||
epsilon
!=
0.0
)
nb14s
.
push_back
(
i
);
}
// Build the arrays.
num14
=
nb14s
.
size
();
bonded14IndexArray
=
allocateIntArray
(
num14
,
2
);
bonded14IndexArray
=
allocateIntArray
(
num14
,
2
);
bonded14ParamArray
=
allocateRealArray
(
num14
,
3
);
bonded14ParamArray
=
allocateRealArray
(
num14
,
3
);
particleParamArray
=
allocateRealArray
(
numParticles
,
3
);
particleParamArray
=
allocateRealArray
(
numParticles
,
3
);
...
@@ -332,7 +349,7 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
...
@@ -332,7 +349,7 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
for
(
int
i
=
0
;
i
<
num14
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num14
;
++
i
)
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
charge
,
radius
,
depth
;
double
charge
,
radius
,
depth
;
force
.
get
Nonbonded14
Parameters
(
i
,
particle1
,
particle2
,
charge
,
radius
,
depth
);
force
.
get
Exception
Parameters
(
nb14s
[
i
]
,
particle1
,
particle2
,
charge
,
radius
,
depth
);
bonded14IndexArray
[
i
][
0
]
=
particle1
;
bonded14IndexArray
[
i
][
0
]
=
particle1
;
bonded14IndexArray
[
i
][
1
]
=
particle2
;
bonded14IndexArray
[
i
][
1
]
=
particle2
;
bonded14ParamArray
[
i
][
0
]
=
static_cast
<
RealOpenMM
>
(
radius
);
bonded14ParamArray
[
i
][
0
]
=
static_cast
<
RealOpenMM
>
(
radius
);
...
...
platforms/reference/src/ReferenceKernels.h
View file @
29e3fa57
...
@@ -216,11 +216,8 @@ public:
...
@@ -216,11 +216,8 @@ public:
*
*
* @param system the System this kernel will be applied to
* @param system the System this kernel will be applied to
* @param force the NonbondedForce this kernel will be used for
* @param force the NonbondedForce this kernel will be used for
* @param exclusions the i'th element lists the indices of all particles with which the i'th particle should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation.
*/
*/
void
initialize
(
const
System
&
system
,
const
NonbondedForce
&
force
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
);
void
initialize
(
const
System
&
system
,
const
NonbondedForce
&
force
);
/**
/**
* Execute the kernel to calculate the forces.
* Execute the kernel to calculate the forces.
*
*
...
...
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
View file @
29e3fa57
...
@@ -55,10 +55,10 @@ void testTemperature() {
...
@@ -55,10 +55,10 @@ void testTemperature() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
numParticles
,
0
);
System
system
(
numParticles
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
2.0
);
system
.
setParticleMass
(
i
,
2.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
AndersenThermostat
*
thermstat
=
new
AndersenThermostat
(
temp
,
collisionFreq
);
AndersenThermostat
*
thermstat
=
new
AndersenThermostat
(
temp
,
collisionFreq
);
...
@@ -93,10 +93,10 @@ void testRandomSeed() {
...
@@ -93,10 +93,10 @@ void testRandomSeed() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
numParticles
,
0
);
System
system
(
numParticles
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
2.0
);
system
.
setParticleMass
(
i
,
2.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
AndersenThermostat
*
thermostat
=
new
AndersenThermostat
(
temp
,
collisionFreq
);
AndersenThermostat
*
thermostat
=
new
AndersenThermostat
(
temp
,
collisionFreq
);
...
...
platforms/reference/tests/TestReferenceBrownianIntegrator.cpp
View file @
29e3fa57
...
@@ -129,10 +129,10 @@ void testConstraints() {
...
@@ -129,10 +129,10 @@ void testConstraints() {
System
system
(
numParticles
,
numParticles
-
1
);
System
system
(
numParticles
,
numParticles
-
1
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
integrator
.
setConstraintTolerance
(
1e-5
);
integrator
.
setConstraintTolerance
(
1e-5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
10.0
);
system
.
setParticleMass
(
i
,
10.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
}
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
++
i
)
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
...
@@ -169,10 +169,10 @@ void testRandomSeed() {
...
@@ -169,10 +169,10 @@ void testRandomSeed() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
numParticles
,
0
);
System
system
(
numParticles
,
0
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
2.0
);
system
.
setParticleMass
(
i
,
2.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
...
...
platforms/reference/tests/TestReferenceCMMotionRemover.cpp
View file @
29e3fa57
...
@@ -69,10 +69,10 @@ void testMotionRemoval() {
...
@@ -69,10 +69,10 @@ void testMotionRemoval() {
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
1
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
1
);
bonds
->
setBondParameters
(
0
,
2
,
3
,
2.0
,
0.5
);
bonds
->
setBondParameters
(
0
,
2
,
3
,
2.0
,
0.5
);
system
.
addForce
(
bonds
);
system
.
addForce
(
bonds
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
i
+
1
);
system
.
setParticleMass
(
i
,
i
+
1
);
nonbonded
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
nonbonded
->
add
Particle
(
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
CMMotionRemover
*
remover
=
new
CMMotionRemover
();
CMMotionRemover
*
remover
=
new
CMMotionRemover
();
...
...
platforms/reference/tests/TestReferenceEwald.cpp
View file @
29e3fa57
...
@@ -53,9 +53,9 @@ void testEwald() {
...
@@ -53,9 +53,9 @@ void testEwald() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
2
,
0
);
System
system
(
2
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
nonbonded
->
set
Particle
Parameters
(
0
,
1.0
,
1
,
0
);
nonbonded
->
add
Particle
(
1.0
,
1
,
0
);
nonbonded
->
set
Particle
Parameters
(
1
,
-
1.0
,
1
,
0
);
nonbonded
->
add
Particle
(
-
1.0
,
1
,
0
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
Ewald
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
Ewald
);
const
double
cutoff
=
2.0
;
const
double
cutoff
=
2.0
;
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
...
...
platforms/reference/tests/TestReferenceGBSAOBCForce.cpp
View file @
29e3fa57
...
@@ -76,11 +76,11 @@ void testCutoffAndPeriodic() {
...
@@ -76,11 +76,11 @@ void testCutoffAndPeriodic() {
System
system
(
2
,
0
);
System
system
(
2
,
0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
(
2
);
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
(
2
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
gbsa
->
setParticleParameters
(
0
,
-
1
,
0.15
,
1
);
gbsa
->
setParticleParameters
(
0
,
-
1
,
0.15
,
1
);
nonbonded
->
set
Particle
Parameters
(
0
,
-
1
,
1
,
0
);
nonbonded
->
add
Particle
(
-
1
,
1
,
0
);
gbsa
->
setParticleParameters
(
1
,
1
,
0.15
,
1
);
gbsa
->
setParticleParameters
(
1
,
1
,
0.15
,
1
);
nonbonded
->
set
Particle
Parameters
(
1
,
1
,
1
,
0
);
nonbonded
->
add
Particle
(
1
,
1
,
0
);
const
double
cutoffDistance
=
3.0
;
const
double
cutoffDistance
=
3.0
;
const
double
boxSize
=
10.0
;
const
double
boxSize
=
10.0
;
nonbonded
->
setCutoffDistance
(
cutoffDistance
);
nonbonded
->
setCutoffDistance
(
cutoffDistance
);
...
...
platforms/reference/tests/TestReferenceLangevinIntegrator.cpp
View file @
29e3fa57
...
@@ -100,10 +100,10 @@ void testTemperature() {
...
@@ -100,10 +100,10 @@ void testTemperature() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
numParticles
,
0
);
System
system
(
numParticles
,
0
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
2.0
);
system
.
setParticleMass
(
i
,
2.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
...
@@ -136,10 +136,10 @@ void testConstraints() {
...
@@ -136,10 +136,10 @@ void testConstraints() {
System
system
(
numParticles
,
numParticles
-
1
);
System
system
(
numParticles
,
numParticles
-
1
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
integrator
.
setConstraintTolerance
(
1e-5
);
integrator
.
setConstraintTolerance
(
1e-5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
10.0
);
system
.
setParticleMass
(
i
,
10.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
}
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
++
i
)
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
...
@@ -176,10 +176,10 @@ void testRandomSeed() {
...
@@ -176,10 +176,10 @@ void testRandomSeed() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
numParticles
,
0
);
System
system
(
numParticles
,
0
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
2.0
);
system
.
setParticleMass
(
i
,
2.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
...
...
platforms/reference/tests/TestReferenceNonbondedForce.cpp
View file @
29e3fa57
...
@@ -53,9 +53,9 @@ void testCoulomb() {
...
@@ -53,9 +53,9 @@ void testCoulomb() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
2
,
0
);
System
system
(
2
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
forceField
->
set
Particle
Parameters
(
0
,
0.5
,
1
,
0
);
forceField
->
add
Particle
(
0.5
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
-
1.5
,
1
,
0
);
forceField
->
add
Particle
(
-
1.5
,
1
,
0
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
vector
<
Vec3
>
positions
(
2
);
...
@@ -74,9 +74,9 @@ void testLJ() {
...
@@ -74,9 +74,9 @@ void testLJ() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
2
,
0
);
System
system
(
2
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
forceField
->
set
Particle
Parameters
(
0
,
0
,
1.2
,
1
);
forceField
->
add
Particle
(
0
,
1.2
,
1
);
forceField
->
set
Particle
Parameters
(
1
,
0
,
1.4
,
2
);
forceField
->
add
Particle
(
0
,
1.4
,
2
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
vector
<
Vec3
>
positions
(
2
);
...
@@ -97,13 +97,25 @@ void testExclusionsAnd14() {
...
@@ -97,13 +97,25 @@ void testExclusionsAnd14() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
5
,
0
);
System
system
(
5
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
4
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
for
(
int
i
=
0
;
i
<
5
;
i
++
)
bonds
->
setBondParameters
(
1
,
1
,
2
,
1
,
0
);
nonbonded
->
addParticle
(
0
,
1.5
,
0
);
bonds
->
setBondParameters
(
2
,
2
,
3
,
1
,
0
);
vector
<
pair
<
int
,
int
>
>
bonds
;
bonds
->
setBondParameters
(
3
,
3
,
4
,
1
,
0
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
system
.
addForce
(
bonds
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
1
,
2
));
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
5
,
2
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
2
,
3
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
3
,
4
));
nonbonded
->
createExceptionsFromBonds
(
bonds
,
0.0
,
0.0
);
int
first14
,
second14
;
for
(
int
i
=
0
;
i
<
nonbonded
->
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
nonbonded
->
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
if
((
particle1
==
0
&&
particle2
==
3
)
||
(
particle1
==
3
&&
particle2
==
0
))
first14
=
i
;
if
((
particle1
==
1
&&
particle2
==
4
)
||
(
particle1
==
4
&&
particle2
==
1
))
second14
=
i
;
}
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
for
(
int
i
=
1
;
i
<
5
;
++
i
)
{
for
(
int
i
=
1
;
i
<
5
;
++
i
)
{
...
@@ -118,8 +130,8 @@ void testExclusionsAnd14() {
...
@@ -118,8 +130,8 @@ void testExclusionsAnd14() {
}
}
nonbonded
->
setParticleParameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
...
@@ -145,8 +157,8 @@ void testExclusionsAnd14() {
...
@@ -145,8 +157,8 @@ void testExclusionsAnd14() {
nonbonded
->
setParticleParameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -171,10 +183,10 @@ void testCutoff() {
...
@@ -171,10 +183,10 @@ void testCutoff() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
3
,
0
);
System
system
(
3
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
3
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
forceField
->
set
Particle
Parameters
(
0
,
1.0
,
1
,
0
);
forceField
->
add
Particle
(
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
1.0
,
1
,
0
);
forceField
->
add
Particle
(
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
2
,
1.0
,
1
,
0
);
forceField
->
add
Particle
(
1.0
,
1
,
0
);
forceField
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
forceField
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
const
double
cutoff
=
2.9
;
const
double
cutoff
=
2.9
;
forceField
->
setCutoffDistance
(
cutoff
);
forceField
->
setCutoffDistance
(
cutoff
);
...
@@ -204,16 +216,28 @@ void testCutoff14() {
...
@@ -204,16 +216,28 @@ void testCutoff14() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
5
,
0
);
System
system
(
5
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
4
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
for
(
int
i
=
0
;
i
<
5
;
i
++
)
bonds
->
setBondParameters
(
1
,
1
,
2
,
1
,
0
);
nonbonded
->
addParticle
(
0
,
1.5
,
0
);
bonds
->
setBondParameters
(
2
,
2
,
3
,
1
,
0
);
bonds
->
setBondParameters
(
3
,
3
,
4
,
1
,
0
);
system
.
addForce
(
bonds
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
5
,
2
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
const
double
cutoff
=
3.5
;
const
double
cutoff
=
3.5
;
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
vector
<
pair
<
int
,
int
>
>
bonds
;
bonds
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
1
,
2
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
2
,
3
));
bonds
.
push_back
(
pair
<
int
,
int
>
(
3
,
4
));
nonbonded
->
createExceptionsFromBonds
(
bonds
,
0.0
,
0.0
);
int
first14
,
second14
;
for
(
int
i
=
0
;
i
<
nonbonded
->
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
nonbonded
->
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
if
((
particle1
==
0
&&
particle2
==
3
)
||
(
particle1
==
3
&&
particle2
==
0
))
first14
=
i
;
if
((
particle1
==
1
&&
particle2
==
4
)
||
(
particle1
==
4
&&
particle2
==
1
))
second14
=
i
;
}
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
5
);
vector
<
Vec3
>
positions
(
5
);
...
@@ -230,8 +254,8 @@ void testCutoff14() {
...
@@ -230,8 +254,8 @@ void testCutoff14() {
for
(
int
j
=
1
;
j
<
5
;
++
j
)
for
(
int
j
=
1
;
j
<
5
;
++
j
)
nonbonded
->
setParticleParameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setParticleParameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -258,8 +282,8 @@ void testCutoff14() {
...
@@ -258,8 +282,8 @@ void testCutoff14() {
const
double
q
=
0.7
;
const
double
q
=
0.7
;
nonbonded
->
setParticleParameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
0
,
0
,
3
,
i
==
3
?
q
*
q
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
first14
,
0
,
3
,
i
==
3
?
q
*
q
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
set
Nonbonded14
Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
set
Exception
Parameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
context
.
reinitialize
();
context
.
reinitialize
();
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -287,13 +311,11 @@ void testPeriodic() {
...
@@ -287,13 +311,11 @@ void testPeriodic() {
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
3
,
0
);
System
system
(
3
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
1
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
nonbonded
->
addParticle
(
1.0
,
1
,
0
);
system
.
addForce
(
bonds
);
nonbonded
->
addParticle
(
1.0
,
1
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
3
,
0
);
nonbonded
->
addParticle
(
1.0
,
1
,
0
);
nonbonded
->
setParticleParameters
(
0
,
1.0
,
1
,
0
);
nonbonded
->
addException
(
0
,
1
,
0.0
,
1.0
,
0.0
);
nonbonded
->
setParticleParameters
(
1
,
1.0
,
1
,
0
);
nonbonded
->
setParticleParameters
(
2
,
1.0
,
1
,
0
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
const
double
cutoff
=
2.0
;
const
double
cutoff
=
2.0
;
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
...
...
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
View file @
29e3fa57
...
@@ -92,10 +92,10 @@ void testConstraints() {
...
@@ -92,10 +92,10 @@ void testConstraints() {
System
system
(
numParticles
,
numParticles
-
1
);
System
system
(
numParticles
,
numParticles
-
1
);
VerletIntegrator
integrator
(
0.002
);
VerletIntegrator
integrator
(
0.002
);
integrator
.
setConstraintTolerance
(
1e-5
);
integrator
.
setConstraintTolerance
(
1e-5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
numParticles
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
setParticleMass
(
i
,
10.0
);
system
.
setParticleMass
(
i
,
10.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
forceField
->
add
Particle
(
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
}
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
++
i
)
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
...
...
tests/TestFindExclusions.cpp
View file @
29e3fa57
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2009
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
/**
/**
* This tests the
findExclusion
s() method of NonbondedForce
Impl
, which identifies pairs of atoms
* This tests the
createExceptionsFromBond
s() method of NonbondedForce, which identifies pairs of atoms
* whose nonbonded atoms are either excluded or decreased. The test system is a chain with branches:
* whose nonbonded atoms are either excluded or decreased. The test system is a chain with branches:
*
*
* 1 3 5 7 9 11 13 15 17 19
* 1 3 5 7 9 11 13 15 17 19
...
@@ -39,19 +39,8 @@
...
@@ -39,19 +39,8 @@
*/
*/
#include "AssertionUtilities.h"
#include "AssertionUtilities.h"
#include "Kernel.h"
#include "KernelFactory.h"
#include "OpenMMContext.h"
#include "Platform.h"
#include "NonbondedForce.h"
#include "NonbondedForce.h"
#include "Stream.h"
#include "StreamFactory.h"
#include "System.h"
#include "VerletIntegrator.h"
#include "kernels.h"
#include <algorithm>
#include <iostream>
#include <iostream>
#include <iterator>
#include <set>
#include <set>
#include <vector>
#include <vector>
...
@@ -64,207 +53,73 @@ static const int NUM_ATOMS = 20;
...
@@ -64,207 +53,73 @@ static const int NUM_ATOMS = 20;
* Add a pair of atoms to the list of exclusions.
* Add a pair of atoms to the list of exclusions.
*/
*/
void
addAtomsToExclusions
(
int
atom1
,
int
atom2
,
vector
<
set
<
int
>
>&
exclusions
)
{
void
addAtomsToExclusions
(
int
atom1
,
int
atom2
,
vector
<
set
<
int
>
>&
exclusions
,
int
&
totalExclusions
)
{
if
(
atom2
<
NUM_ATOMS
)
{
if
(
atom2
<
NUM_ATOMS
)
{
exclusions
[
atom1
].
insert
(
atom2
);
exclusions
[
atom1
].
insert
(
atom2
);
exclusions
[
atom2
].
insert
(
atom1
);
exclusions
[
atom2
].
insert
(
atom1
);
totalExclusions
++
;
}
}
}
}
/**
int
main
()
{
* Verify that the exclusions are what we expect.
try
{
*/
NonbondedForce
nonbonded
;
vector
<
pair
<
int
,
int
>
>
bonds
;
void
verifyExclusions
(
const
vector
<
set
<
int
>
>&
exclusions
)
{
for
(
int
i
=
0
;
i
<
NUM_ATOMS
;
i
++
)
vector
<
set
<
int
>
>
expected
(
NUM_ATOMS
);
nonbonded
.
addParticle
(
1.0
,
1.0
,
2.0
);
for
(
int
i
=
0
;
i
<
NUM_ATOMS
;
i
+=
2
)
{
// loop over all main-chain atoms (even numbered atoms)
addAtomsToExclusions
(
i
,
i
+
1
,
expected
);
for
(
int
i
=
0
;
i
<
NUM_ATOMS
-
1
;
i
+=
2
)
addAtomsToExclusions
(
i
,
i
+
2
,
expected
);
{
addAtomsToExclusions
(
i
,
i
+
3
,
expected
);
// side-chain bonds
addAtomsToExclusions
(
i
,
i
+
4
,
expected
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
i
,
i
+
1
));
addAtomsToExclusions
(
i
,
i
+
5
,
expected
);
// main-chain bonds
addAtomsToExclusions
(
i
,
i
+
6
,
expected
);
if
(
i
<
NUM_ATOMS
-
2
)
// penultimate atom (NUM_ATOMS-2) has no subsequent main-chain atom
addAtomsToExclusions
(
i
+
1
,
i
+
2
,
expected
);
bonds
.
push_back
(
pair
<
int
,
int
>
(
i
,
i
+
2
));
addAtomsToExclusions
(
i
+
1
,
i
+
3
,
expected
);
addAtomsToExclusions
(
i
+
1
,
i
+
4
,
expected
);
}
ASSERT_EQUAL
(
expected
.
size
(),
exclusions
.
size
());
for
(
int
i
=
0
;
i
<
NUM_ATOMS
;
++
i
)
{
ASSERT_EQUAL
(
expected
[
i
].
size
(),
exclusions
[
i
].
size
());
vector
<
int
>
intersection
(
0
);
insert_iterator
<
vector
<
int
>
>
inserter
(
intersection
,
intersection
.
begin
());
set_intersection
(
exclusions
[
i
].
begin
(),
exclusions
[
i
].
end
(),
expected
[
i
].
begin
(),
expected
[
i
].
end
(),
inserter
);
ASSERT_EQUAL
(
expected
[
i
].
size
(),
intersection
.
size
());
}
}
}
nonbonded
.
createExceptionsFromBonds
(
bonds
,
0.2
,
0.4
);
/**
* Add a pair of atoms to the list of 1-4 pairs.
*/
void
addAtomsTo14List
(
int
atom1
,
int
atom2
,
set
<
pair
<
int
,
int
>
>&
bonded14Indices
)
{
// Build lists of the expected exclusions and 1-4s.
if
(
atom2
<
NUM_ATOMS
)
bonded14Indices
.
insert
(
pair
<
int
,
int
>
(
atom1
,
atom2
));
}
/**
vector
<
set
<
int
>
>
expectedExclusions
(
NUM_ATOMS
);
* Verify that the 1-4 pairs are what we expect.
int
totalExclusions
=
0
;
*/
void
verify14
(
const
vector
<
vector
<
int
>
>&
bonded14Indices
)
{
set
<
pair
<
int
,
int
>
>
expected
,
found
;
for
(
int
i
=
0
;
i
<
NUM_ATOMS
;
i
+=
2
)
{
for
(
int
i
=
0
;
i
<
NUM_ATOMS
;
i
+=
2
)
{
addAtomsTo14List
(
i
,
i
+
5
,
expected
);
addAtomsToExclusions
(
i
,
i
+
1
,
expectedExclusions
,
totalExclusions
);
addAtomsTo14List
(
i
,
i
+
6
,
expected
);
addAtomsToExclusions
(
i
,
i
+
2
,
expectedExclusions
,
totalExclusions
);
addAtomsTo14List
(
i
+
1
,
i
+
3
,
expected
);
addAtomsToExclusions
(
i
,
i
+
3
,
expectedExclusions
,
totalExclusions
);
addAtomsTo14List
(
i
+
1
,
i
+
4
,
expected
);
addAtomsToExclusions
(
i
,
i
+
4
,
expectedExclusions
,
totalExclusions
);
}
addAtomsToExclusions
(
i
+
1
,
i
+
2
,
expectedExclusions
,
totalExclusions
);
ASSERT_EQUAL
(
expected
.
size
(),
bonded14Indices
.
size
());
}
for
(
size_t
i
=
0
;
i
<
bonded14Indices
.
size
();
++
i
)
{
vector
<
set
<
int
>
>
expected14
(
NUM_ATOMS
);
int
atom1
=
bonded14Indices
[
i
][
0
];
int
total14
=
0
;
int
atom2
=
bonded14Indices
[
i
][
1
];
for
(
int
i
=
0
;
i
<
NUM_ATOMS
;
i
+=
2
)
{
found
.
insert
(
pair
<
int
,
int
>
(
min
(
atom1
,
atom2
),
max
(
atom1
,
atom2
)));
addAtomsToExclusions
(
i
,
i
+
5
,
expected14
,
total14
);
}
addAtomsToExclusions
(
i
,
i
+
6
,
expected14
,
total14
);
vector
<
pair
<
int
,
int
>
>
intersection
(
0
);
addAtomsToExclusions
(
i
+
1
,
i
+
3
,
expected14
,
total14
);
insert_iterator
<
vector
<
pair
<
int
,
int
>
>
>
inserter
(
intersection
,
intersection
.
begin
());
addAtomsToExclusions
(
i
+
1
,
i
+
4
,
expected14
,
total14
);
set_intersection
(
expected
.
begin
(),
expected
.
end
(),
found
.
begin
(),
found
.
end
(),
inserter
);
ASSERT_EQUAL
(
expected
.
size
(),
intersection
.
size
());
}
/**
* The following classes define a Platform whose job is to check whether the correct values were passed
* to the initialize() methods.
*/
class
DummyBondedKernel
:
public
CalcHarmonicBondForceKernel
{
public:
DummyBondedKernel
(
string
name
,
const
Platform
&
platform
)
:
CalcHarmonicBondForceKernel
(
name
,
platform
)
{
}
void
initialize
(
const
System
&
system
,
const
HarmonicBondForce
&
force
)
{
}
void
executeForces
(
OpenMMContextImpl
&
context
)
{
}
double
executeEnergy
(
OpenMMContextImpl
&
context
)
{
return
0.0
;
}
};
class
DummyNonbondedKernel
:
public
CalcNonbondedForceKernel
{
public:
DummyNonbondedKernel
(
string
name
,
const
Platform
&
platform
)
:
CalcNonbondedForceKernel
(
name
,
platform
)
{
}
void
initialize
(
const
System
&
system
,
const
NonbondedForce
&
force
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
)
{
verifyExclusions
(
exclusions
);
// verify14(bonded14Indices);
}
void
executeForces
(
OpenMMContextImpl
&
context
)
{
}
double
executeEnergy
(
OpenMMContextImpl
&
context
)
{
return
0.0
;
}
};
class
DummyIntegratorKernel
:
public
IntegrateVerletStepKernel
{
public:
DummyIntegratorKernel
(
string
name
,
const
Platform
&
platform
)
:
IntegrateVerletStepKernel
(
name
,
platform
)
{
}
void
initialize
(
const
System
&
system
,
const
VerletIntegrator
&
integrator
)
{
}
void
execute
(
OpenMMContextImpl
&
context
,
const
VerletIntegrator
&
integrator
)
{
}
};
class
DummyKEKernel
:
public
CalcKineticEnergyKernel
{
public:
DummyKEKernel
(
string
name
,
const
Platform
&
platform
)
:
CalcKineticEnergyKernel
(
name
,
platform
)
{
}
void
initialize
(
const
System
&
system
)
{
}
double
execute
(
OpenMMContextImpl
&
context
)
{
return
0.0
;
}
}
};
class
DummyStreamImpl
:
public
StreamImpl
{
// Compare them to the exceptions that were generated.
public:
DummyStreamImpl
(
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
)
:
StreamImpl
(
name
,
size
,
type
,
platform
)
{
}
void
loadFromArray
(
const
void
*
array
)
{
}
void
saveToArray
(
void
*
array
)
{
}
void
fillWithValue
(
void
*
value
)
{
}
};
class
DummyKernelFactory
:
public
KernelFactory
{
ASSERT_EQUAL
(
totalExclusions
+
total14
,
nonbonded
.
getNumExceptions
());
public:
for
(
int
i
=
0
;
i
<
nonbonded
.
getNumExceptions
();
i
++
)
{
KernelImpl
*
createKernelImpl
(
string
name
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
{
int
particle1
,
particle2
;
if
(
name
==
CalcHarmonicBondForceKernel
::
Name
())
double
chargeProd
,
sigma
,
epsilon
;
return
new
DummyBondedKernel
(
name
,
platform
);
nonbonded
.
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
if
(
name
==
CalcNonbondedForceKernel
::
Name
())
if
(
chargeProd
==
0
)
{
return
new
DummyNonbondedKernel
(
name
,
platform
);
// This is an exclusion.
if
(
name
==
IntegrateVerletStepKernel
::
Name
())
return
new
DummyIntegratorKernel
(
name
,
platform
);
if
(
name
==
CalcKineticEnergyKernel
::
Name
())
return
new
DummyKEKernel
(
name
,
platform
);
return
0
;
}
};
class
DummyStreamFactory
:
public
StreamFactory
{
ASSERT_EQUAL
(
0.0
,
epsilon
);
public:
ASSERT
(
expectedExclusions
[
particle1
].
find
(
particle2
)
!=
expectedExclusions
[
particle2
].
end
());
StreamImpl
*
createStreamImpl
(
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
{
return
new
DummyStreamImpl
(
name
,
size
,
type
,
platform
);
}
}
};
else
{
// This is a 1-4.
class
DummyPlatform
:
public
Platform
{
ASSERT_EQUAL_TOL
(
0.2
,
chargeProd
,
1e-10
);
public:
ASSERT_EQUAL_TOL
(
1.0
,
sigma
,
1e-10
);
DummyPlatform
()
{
ASSERT_EQUAL_TOL
(
0.8
,
epsilon
,
1e-10
);
registerKernelFactory
(
CalcHarmonicBondForceKernel
::
Name
(),
new
DummyKernelFactory
());
ASSERT
(
expected14
[
particle1
].
find
(
particle2
)
!=
expected14
[
particle2
].
end
());
registerKernelFactory
(
CalcNonbondedForceKernel
::
Name
(),
new
DummyKernelFactory
());
registerKernelFactory
(
IntegrateVerletStepKernel
::
Name
(),
new
DummyKernelFactory
());
registerKernelFactory
(
CalcKineticEnergyKernel
::
Name
(),
new
DummyKernelFactory
());
}
}
string
getName
()
const
{
return
"Dummy"
;
}
}
double
getSpeed
()
const
{
return
1.0
;
}
bool
supportsDoublePrecision
()
const
{
return
true
;
}
const
StreamFactory
&
getDefaultStreamFactory
()
const
{
return
streamFactory
;
}
private:
DummyStreamFactory
streamFactory
;
};
int
main
()
{
try
{
DummyPlatform
platform
;
System
system
(
NUM_ATOMS
,
0
);
VerletIntegrator
integrator
(
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
NUM_ATOMS
-
1
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
NUM_ATOMS
,
0
);
// loop over all main-chain atoms (even numbered atoms)
for
(
int
i
=
0
;
i
<
NUM_ATOMS
-
1
;
i
+=
2
)
{
// side-chain bonds
bonds
->
setBondParameters
(
i
,
i
,
i
+
1
,
1.0
,
1.0
);
// main-chain bonds
if
(
i
<
NUM_ATOMS
-
2
)
// penultimate atom (NUM_ATOMS-2) has no subsequent main-chain atom
bonds
->
setBondParameters
(
i
+
1
,
i
,
i
+
2
,
1.0
,
1.0
);
}
system
.
addForce
(
bonds
);
system
.
addForce
(
nonbonded
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
Prev
1
2
Next
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