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
0529f325
Commit
0529f325
authored
Apr 02, 2013
by
Peter Eastman
Browse files
Modified some stochastic test cases to fail less often
parent
8e995a20
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
42 deletions
+51
-42
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
+10
-8
platforms/cuda/tests/TestCudaVariableLangevinIntegrator.cpp
platforms/cuda/tests/TestCudaVariableLangevinIntegrator.cpp
+7
-6
platforms/opencl/tests/TestOpenCLAndersenThermostat.cpp
platforms/opencl/tests/TestOpenCLAndersenThermostat.cpp
+10
-8
platforms/opencl/tests/TestOpenCLVariableLangevinIntegrator.cpp
...rms/opencl/tests/TestOpenCLVariableLangevinIntegrator.cpp
+7
-6
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
...forms/reference/tests/TestReferenceAndersenThermostat.cpp
+10
-8
platforms/reference/tests/TestReferenceVariableLangevinIntegrator.cpp
...ference/tests/TestReferenceVariableLangevinIntegrator.cpp
+7
-6
No files found.
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
View file @
0529f325
...
@@ -54,9 +54,9 @@ void testTemperature() {
...
@@ -54,9 +54,9 @@ void testTemperature() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
10
000
;
const
int
numSteps
=
5
000
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.00
5
);
VerletIntegrator
integrator
(
0.00
3
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -70,6 +70,7 @@ void testTemperature() {
...
@@ -70,6 +70,7 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
...
@@ -81,20 +82,20 @@ void testTemperature() {
...
@@ -81,20 +82,20 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numSteps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numSteps
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
integrator
.
step
(
1
);
integrator
.
step
(
1
0
);
}
}
ke
/=
numSteps
;
ke
/=
numSteps
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
6
/
std
::
sqrt
((
double
)
numSteps
)
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
void
testConstraints
()
{
void
testConstraints
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
1
0
000
;
const
int
numSteps
=
1
5
000
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.00
5
);
VerletIntegrator
integrator
(
0.00
4
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -122,10 +123,11 @@ void testConstraints() {
...
@@ -122,10 +123,11 @@ void testConstraints() {
positions
[
6
]
=
Vec3
(
0
,
1
,
1
);
positions
[
6
]
=
Vec3
(
0
,
1
,
1
);
positions
[
7
]
=
Vec3
(
0
,
0
,
1
);
positions
[
7
]
=
Vec3
(
0
,
0
,
1
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
integrator
.
step
(
10
000
);
integrator
.
step
(
5
000
);
// Now run it for a while and see if the temperature is correct.
// Now run it for a while and see if the temperature is correct.
...
@@ -137,7 +139,7 @@ void testConstraints() {
...
@@ -137,7 +139,7 @@ void testConstraints() {
}
}
ke
/=
numSteps
;
ke
/=
numSteps
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
())
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
())
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
6
/
std
::
sqrt
((
double
)
numSteps
)
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
void
testRandomSeed
()
{
void
testRandomSeed
()
{
...
...
platforms/cuda/tests/TestCudaVariableLangevinIntegrator.cpp
View file @
0529f325
...
@@ -99,7 +99,7 @@ void testTemperature() {
...
@@ -99,7 +99,7 @@ void testTemperature() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
System
system
;
System
system
;
VariableLangevinIntegrator
integrator
(
temp
,
5.0
,
1
e-
4
);
VariableLangevinIntegrator
integrator
(
temp
,
5.0
,
5
e-
5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -111,20 +111,21 @@ void testTemperature() {
...
@@ -111,20 +111,21 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
integrator
.
step
(
10
000
);
integrator
.
step
(
5
000
);
// Now run it for a while and see if the temperature is correct.
// Now run it for a while and see if the temperature is correct.
double
ke
=
0.0
;
double
ke
=
0.0
;
for
(
int
i
=
0
;
i
<
1
000
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
000
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
integrator
.
step
(
5
);
integrator
.
step
(
5
);
}
}
ke
/=
1
000
;
ke
/=
5
000
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
...
@@ -276,13 +277,13 @@ void testArgonBox() {
...
@@ -276,13 +277,13 @@ void testArgonBox() {
// Make sure the temperature is correct.
// Make sure the temperature is correct.
double
ke
=
0.0
;
double
ke
=
0.0
;
for
(
int
i
=
0
;
i
<
4
00
;
++
i
)
{
for
(
int
i
=
0
;
i
<
20
00
;
++
i
)
{
double
t
=
2.0
+
0.01
*
(
i
+
1
);
double
t
=
2.0
+
0.01
*
(
i
+
1
);
integrator
.
stepTo
(
t
);
integrator
.
stepTo
(
t
);
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
}
}
ke
/=
4
00
;
ke
/=
20
00
;
double
expected
=
1.5
*
numParticles
*
BOLTZ
*
temp
;
double
expected
=
1.5
*
numParticles
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.01
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.01
);
}
}
...
...
platforms/opencl/tests/TestOpenCLAndersenThermostat.cpp
View file @
0529f325
...
@@ -54,9 +54,9 @@ void testTemperature() {
...
@@ -54,9 +54,9 @@ void testTemperature() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
10
000
;
const
int
numSteps
=
5
000
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.00
5
);
VerletIntegrator
integrator
(
0.00
3
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -70,6 +70,7 @@ void testTemperature() {
...
@@ -70,6 +70,7 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
...
@@ -81,20 +82,20 @@ void testTemperature() {
...
@@ -81,20 +82,20 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numSteps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numSteps
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
integrator
.
step
(
1
);
integrator
.
step
(
1
0
);
}
}
ke
/=
numSteps
;
ke
/=
numSteps
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
6
/
std
::
sqrt
((
double
)
numSteps
)
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
void
testConstraints
()
{
void
testConstraints
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
1
0
000
;
const
int
numSteps
=
1
5
000
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.00
5
);
VerletIntegrator
integrator
(
0.00
4
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -122,10 +123,11 @@ void testConstraints() {
...
@@ -122,10 +123,11 @@ void testConstraints() {
positions
[
6
]
=
Vec3
(
0
,
1
,
1
);
positions
[
6
]
=
Vec3
(
0
,
1
,
1
);
positions
[
7
]
=
Vec3
(
0
,
0
,
1
);
positions
[
7
]
=
Vec3
(
0
,
0
,
1
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
integrator
.
step
(
10
000
);
integrator
.
step
(
5
000
);
// Now run it for a while and see if the temperature is correct.
// Now run it for a while and see if the temperature is correct.
...
@@ -137,7 +139,7 @@ void testConstraints() {
...
@@ -137,7 +139,7 @@ void testConstraints() {
}
}
ke
/=
numSteps
;
ke
/=
numSteps
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
())
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
())
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
6
/
std
::
sqrt
((
double
)
numSteps
)
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
void
testRandomSeed
()
{
void
testRandomSeed
()
{
...
...
platforms/opencl/tests/TestOpenCLVariableLangevinIntegrator.cpp
View file @
0529f325
...
@@ -99,7 +99,7 @@ void testTemperature() {
...
@@ -99,7 +99,7 @@ void testTemperature() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
System
system
;
System
system
;
VariableLangevinIntegrator
integrator
(
temp
,
5.0
,
1
e-
4
);
VariableLangevinIntegrator
integrator
(
temp
,
5.0
,
5
e-
5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -111,20 +111,21 @@ void testTemperature() {
...
@@ -111,20 +111,21 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
integrator
.
step
(
10
000
);
integrator
.
step
(
5
000
);
// Now run it for a while and see if the temperature is correct.
// Now run it for a while and see if the temperature is correct.
double
ke
=
0.0
;
double
ke
=
0.0
;
for
(
int
i
=
0
;
i
<
1
000
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
000
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
integrator
.
step
(
5
);
integrator
.
step
(
5
);
}
}
ke
/=
1
000
;
ke
/=
5
000
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
...
@@ -276,13 +277,13 @@ void testArgonBox() {
...
@@ -276,13 +277,13 @@ void testArgonBox() {
// Make sure the temperature is correct.
// Make sure the temperature is correct.
double
ke
=
0.0
;
double
ke
=
0.0
;
for
(
int
i
=
0
;
i
<
4
00
;
++
i
)
{
for
(
int
i
=
0
;
i
<
20
00
;
++
i
)
{
double
t
=
2.0
+
0.01
*
(
i
+
1
);
double
t
=
2.0
+
0.01
*
(
i
+
1
);
integrator
.
stepTo
(
t
);
integrator
.
stepTo
(
t
);
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
}
}
ke
/=
4
00
;
ke
/=
20
00
;
double
expected
=
1.5
*
numParticles
*
BOLTZ
*
temp
;
double
expected
=
1.5
*
numParticles
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.01
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.01
);
}
}
...
...
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
View file @
0529f325
...
@@ -52,10 +52,10 @@ void testTemperature() {
...
@@ -52,10 +52,10 @@ void testTemperature() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
10
000
;
const
int
numSteps
=
5
000
;
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.00
5
);
VerletIntegrator
integrator
(
0.00
3
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -69,6 +69,7 @@ void testTemperature() {
...
@@ -69,6 +69,7 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
...
@@ -80,21 +81,21 @@ void testTemperature() {
...
@@ -80,21 +81,21 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numSteps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numSteps
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
integrator
.
step
(
1
);
integrator
.
step
(
1
0
);
}
}
ke
/=
numSteps
;
ke
/=
numSteps
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
6
/
std
::
sqrt
((
double
)
numSteps
)
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
void
testConstraints
()
{
void
testConstraints
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
1
0
000
;
const
int
numSteps
=
1
5
000
;
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.00
5
);
VerletIntegrator
integrator
(
0.00
4
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -122,10 +123,11 @@ void testConstraints() {
...
@@ -122,10 +123,11 @@ void testConstraints() {
positions
[
6
]
=
Vec3
(
0
,
1
,
1
);
positions
[
6
]
=
Vec3
(
0
,
1
,
1
);
positions
[
7
]
=
Vec3
(
0
,
0
,
1
);
positions
[
7
]
=
Vec3
(
0
,
0
,
1
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
integrator
.
step
(
10
000
);
integrator
.
step
(
5
000
);
// Now run it for a while and see if the temperature is correct.
// Now run it for a while and see if the temperature is correct.
...
@@ -137,7 +139,7 @@ void testConstraints() {
...
@@ -137,7 +139,7 @@ void testConstraints() {
}
}
ke
/=
numSteps
;
ke
/=
numSteps
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
())
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
())
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
6
/
std
::
sqrt
((
double
)
numSteps
)
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
void
testRandomSeed
()
{
void
testRandomSeed
()
{
...
...
platforms/reference/tests/TestReferenceVariableLangevinIntegrator.cpp
View file @
0529f325
...
@@ -99,7 +99,7 @@ void testTemperature() {
...
@@ -99,7 +99,7 @@ void testTemperature() {
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
;
System
system
;
VariableLangevinIntegrator
integrator
(
temp
,
5.0
,
1
e-
4
);
VariableLangevinIntegrator
integrator
(
temp
,
5.0
,
5
e-
5
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -111,20 +111,21 @@ void testTemperature() {
...
@@ -111,20 +111,21 @@ void testTemperature() {
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temp
);
// Let it equilibrate.
// Let it equilibrate.
integrator
.
step
(
10
000
);
integrator
.
step
(
5
000
);
// Now run it for a while and see if the temperature is correct.
// Now run it for a while and see if the temperature is correct.
double
ke
=
0.0
;
double
ke
=
0.0
;
for
(
int
i
=
0
;
i
<
1
000
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
000
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
integrator
.
step
(
5
);
integrator
.
step
(
5
);
}
}
ke
/=
1
000
;
ke
/=
5
000
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
numParticles
*
3
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
}
...
@@ -279,13 +280,13 @@ void testArgonBox() {
...
@@ -279,13 +280,13 @@ void testArgonBox() {
// Make sure the temperature is correct.
// Make sure the temperature is correct.
double
ke
=
0.0
;
double
ke
=
0.0
;
for
(
int
i
=
0
;
i
<
4
00
;
++
i
)
{
for
(
int
i
=
0
;
i
<
20
00
;
++
i
)
{
double
t
=
2.0
+
0.01
*
(
i
+
1
);
double
t
=
2.0
+
0.01
*
(
i
+
1
);
integrator
.
stepTo
(
t
);
integrator
.
stepTo
(
t
);
State
state
=
context
.
getState
(
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Energy
);
ke
+=
state
.
getKineticEnergy
();
ke
+=
state
.
getKineticEnergy
();
}
}
ke
/=
4
00
;
ke
/=
20
00
;
double
expected
=
1.5
*
numParticles
*
BOLTZ
*
temp
;
double
expected
=
1.5
*
numParticles
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.01
);
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.01
);
}
}
...
...
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