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
1595bb7b
"platforms/opencl/vscode:/vscode.git/clone" did not exist on "79ed6274f7750201c08dbc66da29c0890bae0ec6"
Commit
1595bb7b
authored
Feb 18, 2012
by
Peter Eastman
Browse files
getState() can specify which force groups to use
parent
1878512f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
3 deletions
+31
-3
openmmapi/include/openmm/Context.h
openmmapi/include/openmm/Context.h
+3
-1
openmmapi/src/Context.cpp
openmmapi/src/Context.cpp
+2
-2
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
+13
-0
platforms/reference/tests/TestReferenceCustomIntegrator.cpp
platforms/reference/tests/TestReferenceCustomIntegrator.cpp
+13
-0
No files found.
openmmapi/include/openmm/Context.h
View file @
1595bb7b
...
@@ -123,8 +123,10 @@ public:
...
@@ -123,8 +123,10 @@ public:
* @param enforcePeriodicBox if false, the position of each particle will be whatever position
* @param enforcePeriodicBox if false, the position of each particle will be whatever position
* is stored in the Context, regardless of periodic boundary conditions. If true, particle
* is stored in the Context, regardless of periodic boundary conditions. If true, particle
* positions will be translated so the center of every molecule lies in the same periodic box.
* positions will be translated so the center of every molecule lies in the same periodic box.
* @param groups a set of bit flags for which force groups to include when computing forces
* and energies. Group i will be included if (groups&(1<<i)) != 0. The default value includes all groups.
*/
*/
State
getState
(
int
types
,
bool
enforcePeriodicBox
=
false
)
const
;
State
getState
(
int
types
,
bool
enforcePeriodicBox
=
false
,
int
groups
=
0xFFFFFFFF
)
const
;
/**
/**
* Set the current time of the simulation (in picoseconds).
* Set the current time of the simulation (in picoseconds).
*/
*/
...
...
openmmapi/src/Context.cpp
View file @
1595bb7b
...
@@ -78,7 +78,7 @@ Platform& Context::getPlatform() {
...
@@ -78,7 +78,7 @@ Platform& Context::getPlatform() {
return
impl
->
getPlatform
();
return
impl
->
getPlatform
();
}
}
State
Context
::
getState
(
int
types
,
bool
enforcePeriodicBox
)
const
{
State
Context
::
getState
(
int
types
,
bool
enforcePeriodicBox
,
int
groups
)
const
{
State
state
(
impl
->
getTime
(),
impl
->
getSystem
().
getNumParticles
(),
types
);
State
state
(
impl
->
getTime
(),
impl
->
getSystem
().
getNumParticles
(),
types
);
Vec3
periodicBoxSize
[
3
];
Vec3
periodicBoxSize
[
3
];
impl
->
getPeriodicBoxVectors
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
]);
impl
->
getPeriodicBoxVectors
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
]);
...
@@ -86,7 +86,7 @@ State Context::getState(int types, bool enforcePeriodicBox) const {
...
@@ -86,7 +86,7 @@ State Context::getState(int types, bool enforcePeriodicBox) const {
bool
includeForces
=
types
&
State
::
Forces
;
bool
includeForces
=
types
&
State
::
Forces
;
bool
includeEnergy
=
types
&
State
::
Energy
;
bool
includeEnergy
=
types
&
State
::
Energy
;
if
(
includeForces
||
includeEnergy
)
{
if
(
includeForces
||
includeEnergy
)
{
double
energy
=
impl
->
calcForcesAndEnergy
(
includeForces
,
includeEnergy
);
double
energy
=
impl
->
calcForcesAndEnergy
(
includeForces
,
includeEnergy
,
groups
);
if
(
includeEnergy
)
if
(
includeEnergy
)
state
.
setEnergy
(
impl
->
calcKineticEnergy
(),
energy
);
state
.
setEnergy
(
impl
->
calcKineticEnergy
(),
energy
);
if
(
includeForces
)
if
(
includeForces
)
...
...
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
View file @
1595bb7b
...
@@ -568,6 +568,19 @@ void testForceGroups() {
...
@@ -568,6 +568,19 @@ void testForceGroups() {
ASSERT_EQUAL_VEC
(
Vec3
(
138.935456
*
0.2
*
0.2
/
4.0
,
0
,
0
),
f2
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
Vec3
(
138.935456
*
0.2
*
0.2
/
4.0
,
0
,
0
),
f2
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
0
]
+
f2
[
0
],
f
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
0
]
+
f2
[
0
],
f
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
1
]
+
f2
[
1
],
f
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
1
]
+
f2
[
1
],
f
[
1
],
1e-5
);
// Make sure they also match the values returned by the Context.
vector
<
Vec3
>
c
,
c1
,
c2
;
c
=
context
.
getState
(
State
::
Forces
,
false
).
getForces
();
c1
=
context
.
getState
(
State
::
Forces
,
false
,
2
).
getForces
();
c2
=
context
.
getState
(
State
::
Forces
,
false
,
4
).
getForces
();
ASSERT_EQUAL_VEC
(
f
[
0
],
c
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f
[
1
],
c
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
0
],
c1
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
1
],
c1
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f2
[
0
],
c2
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f2
[
1
],
c2
[
1
],
1e-5
);
}
}
/**
/**
...
...
platforms/reference/tests/TestReferenceCustomIntegrator.cpp
View file @
1595bb7b
...
@@ -553,6 +553,19 @@ void testForceGroups() {
...
@@ -553,6 +553,19 @@ void testForceGroups() {
ASSERT_EQUAL_VEC
(
Vec3
(
138.935456
*
0.2
*
0.2
/
4.0
,
0
,
0
),
f2
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
Vec3
(
138.935456
*
0.2
*
0.2
/
4.0
,
0
,
0
),
f2
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
0
]
+
f2
[
0
],
f
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
0
]
+
f2
[
0
],
f
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
1
]
+
f2
[
1
],
f
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
1
]
+
f2
[
1
],
f
[
1
],
1e-5
);
// Make sure they also match the values returned by the Context.
vector
<
Vec3
>
c
,
c1
,
c2
;
c
=
context
.
getState
(
State
::
Forces
,
false
).
getForces
();
c1
=
context
.
getState
(
State
::
Forces
,
false
,
2
).
getForces
();
c2
=
context
.
getState
(
State
::
Forces
,
false
,
4
).
getForces
();
ASSERT_EQUAL_VEC
(
f
[
0
],
c
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f
[
1
],
c
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
0
],
c1
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f1
[
1
],
c1
[
1
],
1e-5
);
ASSERT_EQUAL_VEC
(
f2
[
0
],
c2
[
0
],
1e-5
);
ASSERT_EQUAL_VEC
(
f2
[
1
],
c2
[
1
],
1e-5
);
}
}
/**
/**
...
...
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