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
542ee547
Commit
542ee547
authored
Mar 03, 2014
by
peastman
Browse files
Added System::getNumDegreesOfFreedom()
parent
b16bec99
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
6 deletions
+20
-6
openmmapi/include/openmm/System.h
openmmapi/include/openmm/System.h
+6
-0
openmmapi/src/System.cpp
openmmapi/src/System.cpp
+8
-0
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
+1
-1
platforms/cuda/tests/TestCudaRandom.cpp
platforms/cuda/tests/TestCudaRandom.cpp
+1
-1
platforms/opencl/tests/TestOpenCLAndersenThermostat.cpp
platforms/opencl/tests/TestOpenCLAndersenThermostat.cpp
+1
-1
platforms/opencl/tests/TestOpenCLRandom.cpp
platforms/opencl/tests/TestOpenCLRandom.cpp
+1
-1
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
...forms/reference/tests/TestReferenceAndersenThermostat.cpp
+1
-1
platforms/reference/tests/TestReferenceRandom.cpp
platforms/reference/tests/TestReferenceRandom.cpp
+1
-1
No files found.
openmmapi/include/openmm/System.h
View file @
542ee547
...
...
@@ -224,6 +224,12 @@ public:
* @param c the vector defining the third edge of the periodic box
*/
void
setDefaultPeriodicBoxVectors
(
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
);
/**
* Get the total number of degrees of freedom in this system. This is equal to
* 3*(number of massive particles)-(number of constraints), where massive particles
* are ones whose mass does not equal zero.
*/
int
getNumDegreesOfFreedom
()
const
;
private:
class
ConstraintInfo
;
Vec3
periodicBoxVectors
[
3
];
...
...
openmmapi/src/System.cpp
View file @
542ee547
...
...
@@ -119,3 +119,11 @@ void System::setDefaultPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Ve
periodicBoxVectors
[
1
]
=
b
;
periodicBoxVectors
[
2
]
=
c
;
}
int
System
::
getNumDegreesOfFreedom
()
const
{
int
numMassiveParticles
=
0
;
for
(
int
i
=
0
;
i
<
(
int
)
masses
.
size
();
i
++
)
if
(
masses
[
i
]
!=
0.0
)
numMassiveParticles
++
;
return
3
*
numMassiveParticles
-
constraints
.
size
();
}
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
View file @
542ee547
...
...
@@ -138,7 +138,7 @@ void testConstraints() {
integrator
.
step
(
1
);
}
ke
/=
numSteps
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
()
)
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
system
.
getNumDegreesOfFreedom
(
)
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
...
...
platforms/cuda/tests/TestCudaRandom.cpp
View file @
542ee547
...
...
@@ -128,7 +128,7 @@ void testRandomVelocities() {
Vec3
v
=
state
.
getVelocities
()[
i
];
ke
+=
0.5
*
system
.
getParticleMass
(
i
)
*
v
.
dot
(
v
);
}
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
()
)
*
BOLTZ
*
temperture
;
double
expected
=
0.5
*
system
.
getNumDegreesOfFreedom
(
)
*
BOLTZ
*
temperture
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
4
/
sqrt
((
double
)
numParticles
));
}
...
...
platforms/opencl/tests/TestOpenCLAndersenThermostat.cpp
View file @
542ee547
...
...
@@ -138,7 +138,7 @@ void testConstraints() {
integrator
.
step
(
1
);
}
ke
/=
numSteps
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
()
)
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
system
.
getNumDegreesOfFreedom
(
)
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
...
...
platforms/opencl/tests/TestOpenCLRandom.cpp
View file @
542ee547
...
...
@@ -126,7 +126,7 @@ void testRandomVelocities() {
Vec3
v
=
state
.
getVelocities
()[
i
];
ke
+=
0.5
*
system
.
getParticleMass
(
i
)
*
v
.
dot
(
v
);
}
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
()
)
*
BOLTZ
*
temperture
;
double
expected
=
0.5
*
system
.
getNumDegreesOfFreedom
(
)
*
BOLTZ
*
temperture
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
4
/
sqrt
((
double
)
numParticles
));
}
...
...
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
View file @
542ee547
...
...
@@ -138,7 +138,7 @@ void testConstraints() {
integrator
.
step
(
1
);
}
ke
/=
numSteps
;
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
()
)
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
system
.
getNumDegreesOfFreedom
(
)
*
BOLTZ
*
temp
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
0.1
);
}
...
...
platforms/reference/tests/TestReferenceRandom.cpp
View file @
542ee547
...
...
@@ -108,7 +108,7 @@ void testRandomVelocities() {
Vec3
v
=
state
.
getVelocities
()[
i
];
ke
+=
0.5
*
system
.
getParticleMass
(
i
)
*
v
.
dot
(
v
);
}
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
()
)
*
BOLTZ
*
temperture
;
double
expected
=
0.5
*
system
.
getNumDegreesOfFreedom
(
)
*
BOLTZ
*
temperture
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
4
/
sqrt
((
double
)
numParticles
));
}
...
...
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