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
6463111f
Commit
6463111f
authored
Nov 23, 2015
by
peastman
Browse files
Fixed bug in getState() when enforcing periodic boundary conditions
parent
b20c20fe
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
openmmapi/src/Context.cpp
openmmapi/src/Context.cpp
+3
-3
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
+3
-3
tests/TestEnforcePeriodicBox.cpp
tests/TestEnforcePeriodicBox.cpp
+11
-2
No files found.
openmmapi/src/Context.cpp
View file @
6463111f
...
...
@@ -115,9 +115,9 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
// Find the displacement to move it into the first periodic box.
Vec3
diff
;
diff
-
=
periodicBoxSize
[
0
]
*
static_cast
<
int
>
(
center
[
0
]
/
periodicBoxSize
[
0
][
0
]);
diff
-
=
periodicBoxSize
[
1
]
*
static_cast
<
int
>
(
center
[
1
]
/
periodicBoxSize
[
1
][
1
]);
diff
-
=
periodicBoxSize
[
2
]
*
static_cast
<
int
>
(
center
[
2
]
/
periodicBoxSize
[
2
][
2
]);
diff
+
=
periodicBoxSize
[
2
]
*
floor
(
center
[
2
]
/
periodicBoxSize
[
2
][
2
]);
diff
+
=
periodicBoxSize
[
1
]
*
floor
(
(
center
[
1
]
-
diff
[
1
])
/
periodicBoxSize
[
1
][
1
]);
diff
+
=
periodicBoxSize
[
0
]
*
floor
((
center
[
0
]
-
diff
[
0
])
/
periodicBoxSize
[
0
][
0
]);
// Translate all the particles in the molecule.
for
(
int
j
=
0
;
j
<
(
int
)
molecules
[
i
].
size
();
j
++
)
{
...
...
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
View file @
6463111f
...
...
@@ -129,9 +129,9 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
// Find the displacement to move it into the first periodic box.
Vec3
diff
;
diff
-
=
periodicBoxSize
[
0
]
*
static_cast
<
int
>
(
center
[
0
]
/
periodicBoxSize
[
0
][
0
]);
diff
-
=
periodicBoxSize
[
1
]
*
static_cast
<
int
>
(
center
[
1
]
/
periodicBoxSize
[
1
][
1
]);
diff
-
=
periodicBoxSize
[
2
]
*
static_cast
<
int
>
(
center
[
2
]
/
periodicBoxSize
[
2
][
2
]);
diff
+
=
periodicBoxSize
[
2
]
*
floor
(
center
[
2
]
/
periodicBoxSize
[
2
][
2
]);
diff
+
=
periodicBoxSize
[
1
]
*
floor
(
(
center
[
1
]
-
diff
[
1
])
/
periodicBoxSize
[
1
][
1
]);
diff
+
=
periodicBoxSize
[
0
]
*
floor
((
center
[
0
]
-
diff
[
0
])
/
periodicBoxSize
[
0
][
0
]);
// Translate all the particles in the molecule.
for
(
int
j
=
0
;
j
<
(
int
)
molecules
[
i
].
size
();
j
++
)
{
...
...
tests/TestEnforcePeriodicBox.cpp
View file @
6463111f
...
...
@@ -41,7 +41,7 @@ using namespace OpenMM;
using
namespace
std
;
void
testTruncatedOctahedron
()
{
const
int
numMolecules
=
5
;
const
int
numMolecules
=
5
0
;
const
int
numParticles
=
numMolecules
*
2
;
const
float
cutoff
=
2.0
;
Vec3
a
(
6.7929
,
0
,
0
);
...
...
@@ -63,7 +63,7 @@ void testTruncatedOctahedron() {
system
.
addParticle
(
1.0
);
force
->
addParticle
(
-
1
,
0.2
,
0.2
);
force
->
addParticle
(
1
,
0.2
,
0.2
);
positions
[
2
*
i
]
=
a
*
genrand_real2
(
sfmt
)
+
b
*
genrand_real2
(
sfmt
)
+
c
*
genrand_real2
(
sfmt
);
positions
[
2
*
i
]
=
a
*
(
5
*
genrand_real2
(
sfmt
)
-
2
)
+
b
*
(
5
*
genrand_real2
(
sfmt
)
-
2
)
+
c
*
(
5
*
genrand_real2
(
sfmt
)
-
2
)
;
positions
[
2
*
i
+
1
]
=
positions
[
2
*
i
]
+
Vec3
(
1.0
,
0.0
,
0.0
);
system
.
addConstraint
(
2
*
i
,
2
*
i
+
1
,
1.0
);
}
...
...
@@ -73,6 +73,15 @@ void testTruncatedOctahedron() {
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
context
.
setPositions
(
positions
);
State
initialState
=
context
.
getState
(
State
::
Positions
|
State
::
Energy
,
true
);
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
Vec3
center
=
(
initialState
.
getPositions
()[
2
*
i
]
+
initialState
.
getPositions
()[
2
*
i
+
1
])
*
0.5
;
ASSERT
(
center
[
0
]
>=
0.0
);
ASSERT
(
center
[
1
]
>=
0.0
);
ASSERT
(
center
[
2
]
>=
0.0
);
ASSERT
(
center
[
0
]
<=
a
[
0
]);
ASSERT
(
center
[
1
]
<=
b
[
1
]);
ASSERT
(
center
[
2
]
<=
c
[
2
]);
}
double
initialEnergy
=
initialState
.
getPotentialEnergy
();
context
.
setState
(
initialState
);
...
...
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