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
62c4fd53
Commit
62c4fd53
authored
Oct 22, 2008
by
Peter Eastman
Browse files
Renamed "atoms" to "particles"
parent
ad75a390
Changes
48
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
141 additions
and
141 deletions
+141
-141
platforms/reference/tests/TestReferenceBrownianIntegrator.cpp
...forms/reference/tests/TestReferenceBrownianIntegrator.cpp
+21
-21
platforms/reference/tests/TestReferenceCMMotionRemover.cpp
platforms/reference/tests/TestReferenceCMMotionRemover.cpp
+13
-13
platforms/reference/tests/TestReferenceGBSAOBCForceField.cpp
platforms/reference/tests/TestReferenceGBSAOBCForceField.cpp
+14
-14
platforms/reference/tests/TestReferenceKineticEnergy.cpp
platforms/reference/tests/TestReferenceKineticEnergy.cpp
+1
-1
platforms/reference/tests/TestReferenceLangevinIntegrator.cpp
...forms/reference/tests/TestReferenceLangevinIntegrator.cpp
+22
-22
platforms/reference/tests/TestReferenceNeighborList.cpp
platforms/reference/tests/TestReferenceNeighborList.cpp
+37
-37
platforms/reference/tests/TestReferenceNonbondedForce.cpp
platforms/reference/tests/TestReferenceNonbondedForce.cpp
+20
-20
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
+13
-13
No files found.
platforms/reference/tests/TestReferenceBrownianIntegrator.cpp
View file @
62c4fd53
...
...
@@ -53,8 +53,8 @@ const double TOL = 1e-5;
void
testSingleBond
()
{
ReferencePlatform
platform
;
System
system
(
2
,
0
);
system
.
set
Atom
Mass
(
0
,
2.0
);
system
.
set
Atom
Mass
(
1
,
2.0
);
system
.
set
Particle
Mass
(
0
,
2.0
);
system
.
set
Particle
Mass
(
1
,
2.0
);
double
dt
=
0.01
;
BrownianIntegrator
integrator
(
0
,
0.1
,
dt
);
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
(
1
);
...
...
@@ -85,23 +85,23 @@ void testSingleBond() {
}
void
testTemperature
()
{
const
int
num
Atom
s
=
8
;
const
int
numBonds
=
num
Atom
s
-
1
;
const
int
num
Particle
s
=
8
;
const
int
numBonds
=
num
Particle
s
-
1
;
const
double
temp
=
100.0
;
ReferencePlatform
platform
;
System
system
(
num
Atom
s
,
0
);
System
system
(
num
Particle
s
,
0
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.01
);
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
(
numBonds
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
2.0
);
// forceField->set
Atom
Parameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Particle
Mass
(
i
,
2.0
);
// forceField->set
Particle
Parameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0);
}
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
forceField
->
setBondParameters
(
i
,
i
,
i
+
1
,
1.0
,
i
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
vector
<
Vec3
>
positions
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
positions
[
i
]
=
Vec3
(
i
,
0
,
0
);
context
.
setPositions
(
positions
);
...
...
@@ -123,24 +123,24 @@ void testTemperature() {
}
void
testConstraints
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
double
temp
=
100.0
;
ReferencePlatform
platform
;
System
system
(
num
Atoms
,
numAtom
s
-
1
);
System
system
(
num
Particles
,
numParticle
s
-
1
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Atom
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
10.0
);
forceField
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Particle
Mass
(
i
,
10.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
for
(
int
i
=
0
;
i
<
num
Atom
s
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
-
1
;
++
i
)
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
velocities
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
vector
<
Vec3
>
velocities
(
num
Particle
s
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
positions
[
i
]
=
Vec3
(
i
/
2
,
(
i
+
1
)
/
2
,
0
);
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
}
...
...
@@ -151,7 +151,7 @@ void testConstraints() {
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Positions
);
for
(
int
j
=
0
;
j
<
num
Atom
s
-
1
;
++
j
)
{
for
(
int
j
=
0
;
j
<
num
Particle
s
-
1
;
++
j
)
{
Vec3
p1
=
state
.
getPositions
()[
j
];
Vec3
p2
=
state
.
getPositions
()[
j
+
1
];
double
dist
=
std
::
sqrt
((
p1
[
0
]
-
p2
[
0
])
*
(
p1
[
0
]
-
p2
[
0
])
+
(
p1
[
1
]
-
p2
[
1
])
*
(
p1
[
1
]
-
p2
[
1
])
+
(
p1
[
2
]
-
p2
[
2
])
*
(
p1
[
2
]
-
p2
[
2
]));
...
...
platforms/reference/tests/TestReferenceCMMotionRemover.cpp
View file @
62c4fd53
...
...
@@ -51,37 +51,37 @@ using namespace std;
Vec3
calcCM
(
const
vector
<
Vec3
>&
values
,
System
&
system
)
{
Vec3
cm
;
for
(
int
j
=
0
;
j
<
system
.
getNum
Atom
s
();
++
j
)
{
cm
[
0
]
+=
values
[
j
][
0
]
*
system
.
get
Atom
Mass
(
j
);
cm
[
1
]
+=
values
[
j
][
1
]
*
system
.
get
Atom
Mass
(
j
);
cm
[
2
]
+=
values
[
j
][
2
]
*
system
.
get
Atom
Mass
(
j
);
for
(
int
j
=
0
;
j
<
system
.
getNum
Particle
s
();
++
j
)
{
cm
[
0
]
+=
values
[
j
][
0
]
*
system
.
get
Particle
Mass
(
j
);
cm
[
1
]
+=
values
[
j
][
1
]
*
system
.
get
Particle
Mass
(
j
);
cm
[
2
]
+=
values
[
j
][
2
]
*
system
.
get
Particle
Mass
(
j
);
}
return
cm
;
}
void
testMotionRemoval
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
ReferencePlatform
platform
;
System
system
(
num
Atom
s
,
0
);
System
system
(
num
Particle
s
,
0
);
VerletIntegrator
integrator
(
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
1
);
bonds
->
setBondParameters
(
0
,
2
,
3
,
2.0
,
0.5
);
system
.
addForce
(
bonds
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
num
Atom
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
i
+
1
);
nonbonded
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Particle
Mass
(
i
,
i
+
1
);
nonbonded
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
system
.
addForce
(
nonbonded
);
CMMotionRemover
*
remover
=
new
CMMotionRemover
();
system
.
addForce
(
remover
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
velocities
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
vector
<
Vec3
>
velocities
(
num
Particle
s
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
}
...
...
platforms/reference/tests/TestReferenceGBSAOBCForceField.cpp
View file @
62c4fd53
...
...
@@ -49,13 +49,13 @@ using namespace std;
const
double
TOL
=
1e-5
;
void
testSingle
Atom
()
{
void
testSingle
Particle
()
{
ReferencePlatform
platform
;
System
system
(
1
,
0
);
system
.
set
Atom
Mass
(
0
,
2.0
);
system
.
set
Particle
Mass
(
0
,
2.0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
GBSAOBCForceField
*
forceField
=
new
GBSAOBCForceField
(
1
);
forceField
->
set
Atom
Parameters
(
0
,
0.5
,
0.15
,
1
);
forceField
->
set
Particle
Parameters
(
0
,
0.5
,
0.15
,
1
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
1
);
...
...
@@ -72,20 +72,20 @@ void testSingleAtom() {
void
testForce
()
{
ReferencePlatform
platform
;
const
int
num
Atom
s
=
10
;
System
system
(
num
Atom
s
,
0
);
const
int
num
Particle
s
=
10
;
System
system
(
num
Particle
s
,
0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
GBSAOBCForceField
*
forceField
=
new
GBSAOBCForceField
(
num
Atom
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
forceField
->
set
Atom
Parameters
(
i
,
i
%
2
==
0
?
-
1
:
1
,
0.15
,
1
);
GBSAOBCForceField
*
forceField
=
new
GBSAOBCForceField
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
forceField
->
set
Particle
Parameters
(
i
,
i
%
2
==
0
?
-
1
:
1
,
0.15
,
1
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
// Set random positions for all the
atom
s.
// Set random positions for all the
particle
s.
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
positions
[
i
]
=
Vec3
(
5.0
*
genrand_real2
(),
5.0
*
genrand_real2
(),
5.0
*
genrand_real2
());
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
...
@@ -93,14 +93,14 @@ void testForce() {
// Take a small step in the direction of the energy gradient.
double
norm
=
0.0
;
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
Vec3
f
=
state
.
getForces
()[
i
];
norm
+=
f
[
0
]
*
f
[
0
]
+
f
[
1
]
*
f
[
1
]
+
f
[
2
]
*
f
[
2
];
}
norm
=
std
::
sqrt
(
norm
);
const
double
delta
=
1e-3
;
double
step
=
delta
/
norm
;
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
Vec3
p
=
positions
[
i
];
Vec3
f
=
state
.
getForces
()[
i
];
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
...
...
@@ -115,7 +115,7 @@ void testForce() {
int
main
()
{
try
{
testSingle
Atom
();
testSingle
Particle
();
testForce
();
}
catch
(
const
exception
&
e
)
{
...
...
platforms/reference/tests/TestReferenceKineticEnergy.cpp
View file @
62c4fd53
...
...
@@ -50,7 +50,7 @@ void testCalcKE() {
ReferencePlatform
platform
;
System
system
(
4
,
0
);
for
(
int
i
=
0
;
i
<
4
;
++
i
)
system
.
set
Atom
Mass
(
i
,
i
+
1
);
system
.
set
Particle
Mass
(
i
,
i
+
1
);
VerletIntegrator
integrator
(
0.01
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
velocities
(
4
);
...
...
platforms/reference/tests/TestReferenceLangevinIntegrator.cpp
View file @
62c4fd53
...
...
@@ -53,8 +53,8 @@ const double TOL = 1e-5;
void
testSingleBond
()
{
ReferencePlatform
platform
;
System
system
(
2
,
0
);
system
.
set
Atom
Mass
(
0
,
2.0
);
system
.
set
Atom
Mass
(
1
,
2.0
);
system
.
set
Particle
Mass
(
0
,
2.0
);
system
.
set
Particle
Mass
(
1
,
2.0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
(
1
);
forceField
->
setBondParameters
(
0
,
0
,
1
,
1.5
,
1
);
...
...
@@ -95,20 +95,20 @@ void testSingleBond() {
}
void
testTemperature
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
double
temp
=
100.0
;
ReferencePlatform
platform
;
System
system
(
num
Atom
s
,
0
);
System
system
(
num
Particle
s
,
0
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Atom
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
2.0
);
forceField
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Particle
Mass
(
i
,
2.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
vector
<
Vec3
>
positions
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
...
...
@@ -125,29 +125,29 @@ void testTemperature() {
integrator
.
step
(
1
);
}
ke
/=
1000
;
double
expected
=
0.5
*
num
Atom
s
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
num
Particle
s
*
3
*
BOLTZ
*
temp
;
ASSERT_EQUAL_TOL
(
expected
,
ke
,
3
*
expected
/
std
::
sqrt
(
1000.0
));
}
void
testConstraints
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
double
temp
=
100.0
;
ReferencePlatform
platform
;
System
system
(
num
Atoms
,
numAtom
s
-
1
);
System
system
(
num
Particles
,
numParticle
s
-
1
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Atom
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
10.0
);
forceField
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Particle
Mass
(
i
,
10.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
for
(
int
i
=
0
;
i
<
num
Atom
s
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
-
1
;
++
i
)
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
velocities
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
vector
<
Vec3
>
velocities
(
num
Particle
s
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
positions
[
i
]
=
Vec3
(
i
/
2
,
(
i
+
1
)
/
2
,
0
);
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
}
...
...
@@ -158,7 +158,7 @@ void testConstraints() {
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Positions
);
for
(
int
j
=
0
;
j
<
num
Atom
s
-
1
;
++
j
)
{
for
(
int
j
=
0
;
j
<
num
Particle
s
-
1
;
++
j
)
{
Vec3
p1
=
state
.
getPositions
()[
j
];
Vec3
p2
=
state
.
getPositions
()[
j
+
1
];
double
dist
=
std
::
sqrt
((
p1
[
0
]
-
p2
[
0
])
*
(
p1
[
0
]
-
p2
[
0
])
+
(
p1
[
1
]
-
p2
[
1
])
*
(
p1
[
1
]
-
p2
[
1
])
+
(
p1
[
2
]
-
p2
[
2
])
*
(
p1
[
2
]
-
p2
[
2
]));
...
...
platforms/reference/tests/TestReferenceNeighborList.cpp
View file @
62c4fd53
...
...
@@ -9,35 +9,35 @@ using namespace OpenMM;
void
testNeighborList
()
{
RealOpenMM
*
atom
List
[
2
];
atom
List
[
0
]
=
new
RealOpenMM
[
3
];
atom
List
[
1
]
=
new
RealOpenMM
[
3
];
atom
List
[
2
]
=
new
RealOpenMM
[
3
];
atom
List
[
0
][
0
]
=
13.6
f
;
atom
List
[
0
][
1
]
=
0
;
atom
List
[
0
][
2
]
=
0
;
atom
List
[
1
][
0
]
=
0
;
atom
List
[
1
][
1
]
=
0
;
atom
List
[
1
][
2
]
=
0
;
RealOpenMM
*
particle
List
[
2
];
particle
List
[
0
]
=
new
RealOpenMM
[
3
];
particle
List
[
1
]
=
new
RealOpenMM
[
3
];
particle
List
[
2
]
=
new
RealOpenMM
[
3
];
particle
List
[
0
][
0
]
=
13.6
f
;
particle
List
[
0
][
1
]
=
0
;
particle
List
[
0
][
2
]
=
0
;
particle
List
[
1
][
0
]
=
0
;
particle
List
[
1
][
1
]
=
0
;
particle
List
[
1
][
2
]
=
0
;
vector
<
set
<
int
>
>
exclusions
(
2
);
NeighborList
neighborList
;
computeNeighborListNaive
(
neighborList
,
2
,
atom
List
,
exclusions
,
NULL
,
13.7
,
0.01
);
computeNeighborListNaive
(
neighborList
,
2
,
particle
List
,
exclusions
,
NULL
,
13.7
,
0.01
);
assert
(
neighborList
.
size
()
==
1
);
computeNeighborListNaive
(
neighborList
,
2
,
atom
List
,
exclusions
,
NULL
,
13.5
,
0.01
);
computeNeighborListNaive
(
neighborList
,
2
,
particle
List
,
exclusions
,
NULL
,
13.5
,
0.01
);
assert
(
neighborList
.
size
()
==
0
);
computeNeighborListVoxelHash
(
neighborList
,
2
,
atom
List
,
exclusions
,
NULL
,
13.7
,
0.01
);
computeNeighborListVoxelHash
(
neighborList
,
2
,
particle
List
,
exclusions
,
NULL
,
13.7
,
0.01
);
assert
(
neighborList
.
size
()
==
1
);
computeNeighborListVoxelHash
(
neighborList
,
2
,
atom
List
,
exclusions
,
NULL
,
13.5
,
0.01
);
computeNeighborListVoxelHash
(
neighborList
,
2
,
particle
List
,
exclusions
,
NULL
,
13.5
,
0.01
);
assert
(
neighborList
.
size
()
==
0
);
delete
[]
atom
List
[
0
];
delete
[]
atom
List
[
1
];
delete
[]
atom
List
[
2
];
delete
[]
particle
List
[
0
];
delete
[]
particle
List
[
1
];
delete
[]
particle
List
[
2
];
}
double
periodicDifference
(
double
val1
,
double
val2
,
double
period
)
{
...
...
@@ -53,40 +53,40 @@ double distance2(RealOpenMM* pos1, RealOpenMM* pos2, const RealOpenMM* periodicB
return
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
}
void
verifyNeighborList
(
NeighborList
&
list
,
int
num
Atom
s
,
RealOpenMM
**
positions
,
const
RealOpenMM
*
periodicBoxSize
,
double
cutoff
)
{
void
verifyNeighborList
(
NeighborList
&
list
,
int
num
Particle
s
,
RealOpenMM
**
positions
,
const
RealOpenMM
*
periodicBoxSize
,
double
cutoff
)
{
for
(
int
i
=
0
;
i
<
(
int
)
list
.
size
();
i
++
)
{
int
atom
1
=
list
[
i
].
first
;
int
atom
2
=
list
[
i
].
second
;
ASSERT
(
distance2
(
positions
[
atom
1
],
positions
[
atom
2
],
periodicBoxSize
)
<=
cutoff
*
cutoff
);
int
particle
1
=
list
[
i
].
first
;
int
particle
2
=
list
[
i
].
second
;
ASSERT
(
distance2
(
positions
[
particle
1
],
positions
[
particle
2
],
periodicBoxSize
)
<=
cutoff
*
cutoff
);
}
int
count
=
0
;
for
(
int
i
=
0
;
i
<
num
Atom
s
;
i
++
)
for
(
int
j
=
i
+
1
;
j
<
num
Atom
s
;
j
++
)
for
(
int
i
=
0
;
i
<
num
Particle
s
;
i
++
)
for
(
int
j
=
i
+
1
;
j
<
num
Particle
s
;
j
++
)
if
(
distance2
(
positions
[
i
],
positions
[
j
],
periodicBoxSize
)
<=
cutoff
*
cutoff
)
count
++
;
ASSERT
(
count
==
list
.
size
());
}
void
testPeriodic
()
{
const
int
num
Atom
s
=
100
;
const
int
num
Particle
s
=
100
;
const
double
cutoff
=
3.0
;
const
RealOpenMM
periodicBoxSize
[
3
]
=
{
20.0
,
15.0
,
22.0
};
RealOpenMM
*
atomList
[
numAtom
s
];
RealOpenMM
*
particleList
[
numParticle
s
];
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
i
++
)
{
atom
List
[
i
]
=
new
RealOpenMM
[
3
];
atom
List
[
i
][
0
]
=
(
RealOpenMM
)
(
genrand_real2
()
*
periodicBoxSize
[
0
]
*
3
);
atom
List
[
i
][
1
]
=
(
RealOpenMM
)
(
genrand_real2
()
*
periodicBoxSize
[
1
]
*
3
);
atom
List
[
i
][
2
]
=
(
RealOpenMM
)
(
genrand_real2
()
*
periodicBoxSize
[
2
]
*
3
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
i
++
)
{
particle
List
[
i
]
=
new
RealOpenMM
[
3
];
particle
List
[
i
][
0
]
=
(
RealOpenMM
)
(
genrand_real2
()
*
periodicBoxSize
[
0
]
*
3
);
particle
List
[
i
][
1
]
=
(
RealOpenMM
)
(
genrand_real2
()
*
periodicBoxSize
[
1
]
*
3
);
particle
List
[
i
][
2
]
=
(
RealOpenMM
)
(
genrand_real2
()
*
periodicBoxSize
[
2
]
*
3
);
}
vector
<
set
<
int
>
>
exclusions
(
num
Atom
s
);
vector
<
set
<
int
>
>
exclusions
(
num
Particle
s
);
NeighborList
neighborList
;
computeNeighborListNaive
(
neighborList
,
num
Atoms
,
atom
List
,
exclusions
,
periodicBoxSize
,
cutoff
);
verifyNeighborList
(
neighborList
,
num
Atoms
,
atom
List
,
periodicBoxSize
,
cutoff
);
computeNeighborListVoxelHash
(
neighborList
,
num
Atoms
,
atom
List
,
exclusions
,
periodicBoxSize
,
cutoff
);
verifyNeighborList
(
neighborList
,
num
Atoms
,
atom
List
,
periodicBoxSize
,
cutoff
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
i
++
)
delete
[]
atom
List
[
i
];
computeNeighborListNaive
(
neighborList
,
num
Particles
,
particle
List
,
exclusions
,
periodicBoxSize
,
cutoff
);
verifyNeighborList
(
neighborList
,
num
Particles
,
particle
List
,
periodicBoxSize
,
cutoff
);
computeNeighborListVoxelHash
(
neighborList
,
num
Particles
,
particle
List
,
exclusions
,
periodicBoxSize
,
cutoff
);
verifyNeighborList
(
neighborList
,
num
Particles
,
particle
List
,
periodicBoxSize
,
cutoff
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
i
++
)
delete
[]
particle
List
[
i
];
}
int
main
()
...
...
platforms/reference/tests/TestReferenceNonbondedForce.cpp
View file @
62c4fd53
...
...
@@ -54,8 +54,8 @@ void testCoulomb() {
System
system
(
2
,
0
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
forceField
->
set
Atom
Parameters
(
0
,
0.5
,
1
,
0
);
forceField
->
set
Atom
Parameters
(
1
,
-
1.5
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
0
,
0.5
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
-
1.5
,
1
,
0
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
...
...
@@ -75,8 +75,8 @@ void testLJ() {
System
system
(
2
,
0
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
forceField
->
set
Atom
Parameters
(
0
,
0
,
1.2
,
1
);
forceField
->
set
Atom
Parameters
(
1
,
0
,
1.4
,
2
);
forceField
->
set
Particle
Parameters
(
0
,
0
,
1.2
,
1
);
forceField
->
set
Particle
Parameters
(
1
,
0
,
1.4
,
2
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
...
...
@@ -113,11 +113,11 @@ void testExclusionsAnd14() {
vector
<
Vec3
>
positions
(
5
);
const
double
r
=
1.0
;
for
(
int
j
=
0
;
j
<
5
;
++
j
)
{
nonbonded
->
set
Atom
Parameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
j
,
0
,
1.5
,
0
);
positions
[
j
]
=
Vec3
(
0
,
j
,
0
);
}
nonbonded
->
set
Atom
Parameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
set
Atom
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
...
...
@@ -143,8 +143,8 @@ void testExclusionsAnd14() {
// Test Coulomb forces
nonbonded
->
set
Atom
Parameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
set
Atom
Parameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
context
.
reinitialize
();
...
...
@@ -172,9 +172,9 @@ void testCutoff() {
System
system
(
3
,
0
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
3
,
0
);
forceField
->
set
Atom
Parameters
(
0
,
1.0
,
1
,
0
);
forceField
->
set
Atom
Parameters
(
1
,
1.0
,
1
,
0
);
forceField
->
set
Atom
Parameters
(
2
,
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
0
,
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
2
,
1.0
,
1
,
0
);
forceField
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
const
double
cutoff
=
2.9
;
forceField
->
setCutoffDistance
(
cutoff
);
...
...
@@ -226,10 +226,10 @@ void testCutoff14() {
// Test LJ forces
nonbonded
->
set
Atom
Parameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
0
,
0
,
1.5
,
1
);
for
(
int
j
=
1
;
j
<
5
;
++
j
)
nonbonded
->
set
Atom
Parameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
set
Atom
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
context
.
reinitialize
();
...
...
@@ -256,8 +256,8 @@ void testCutoff14() {
// Test Coulomb forces
const
double
q
=
0.7
;
nonbonded
->
set
Atom
Parameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
set
Atom
Parameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
i
==
3
?
q
*
q
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
context
.
reinitialize
();
...
...
@@ -291,9 +291,9 @@ void testPeriodic() {
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
system
.
addForce
(
bonds
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
3
,
0
);
nonbonded
->
set
Atom
Parameters
(
0
,
1.0
,
1
,
0
);
nonbonded
->
set
Atom
Parameters
(
1
,
1.0
,
1
,
0
);
nonbonded
->
set
Atom
Parameters
(
2
,
1.0
,
1
,
0
);
nonbonded
->
set
Particle
Parameters
(
0
,
1.0
,
1
,
0
);
nonbonded
->
set
Particle
Parameters
(
1
,
1.0
,
1
,
0
);
nonbonded
->
set
Particle
Parameters
(
2
,
1.0
,
1
,
0
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
const
double
cutoff
=
2.0
;
nonbonded
->
setCutoffDistance
(
cutoff
);
...
...
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
View file @
62c4fd53
...
...
@@ -53,8 +53,8 @@ const double TOL = 1e-5;
void
testSingleBond
()
{
ReferencePlatform
platform
;
System
system
(
2
,
0
);
system
.
set
Atom
Mass
(
0
,
2.0
);
system
.
set
Atom
Mass
(
1
,
2.0
);
system
.
set
Particle
Mass
(
0
,
2.0
);
system
.
set
Particle
Mass
(
1
,
2.0
);
VerletIntegrator
integrator
(
0.01
);
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
(
1
);
forceField
->
setBondParameters
(
0
,
0
,
1
,
1.5
,
1
);
...
...
@@ -86,24 +86,24 @@ void testSingleBond() {
}
void
testConstraints
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
double
temp
=
100.0
;
ReferencePlatform
platform
;
System
system
(
num
Atoms
,
numAtom
s
-
1
);
System
system
(
num
Particles
,
numParticle
s
-
1
);
VerletIntegrator
integrator
(
0.002
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Atom
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
10.0
);
forceField
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Particle
Mass
(
i
,
10.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
for
(
int
i
=
0
;
i
<
num
Atom
s
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
-
1
;
++
i
)
system
.
setConstraintParameters
(
i
,
i
,
i
+
1
,
1.0
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
velocities
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
vector
<
Vec3
>
velocities
(
num
Particle
s
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
positions
[
i
]
=
Vec3
(
i
/
2
,
(
i
+
1
)
/
2
,
0
);
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
}
...
...
@@ -115,7 +115,7 @@ void testConstraints() {
double
initialEnergy
=
0.0
;
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Positions
|
State
::
Energy
);
for
(
int
j
=
0
;
j
<
num
Atom
s
-
1
;
++
j
)
{
for
(
int
j
=
0
;
j
<
num
Particle
s
-
1
;
++
j
)
{
Vec3
p1
=
state
.
getPositions
()[
j
];
Vec3
p2
=
state
.
getPositions
()[
j
+
1
];
double
dist
=
std
::
sqrt
((
p1
[
0
]
-
p2
[
0
])
*
(
p1
[
0
]
-
p2
[
0
])
+
(
p1
[
1
]
-
p2
[
1
])
*
(
p1
[
1
]
-
p2
[
1
])
+
(
p1
[
2
]
-
p2
[
2
])
*
(
p1
[
2
]
-
p2
[
2
]));
...
...
Prev
1
2
3
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