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
9a55eeec
"vscode:/vscode.git/clone" did not exist on "138c1c88bcbd6388cbc229c1c547ba69a75d3525"
Commit
9a55eeec
authored
Apr 05, 2013
by
Peter Eastman
Browse files
RPMDIntegrator::getState() applies periodic boundary conditions based on copy 0 (see bug 1833)
parent
4e50d721
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
5 deletions
+60
-5
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
+57
-2
plugins/rpmd/platforms/cuda/tests/TestCudaRpmd.cpp
plugins/rpmd/platforms/cuda/tests/TestCudaRpmd.cpp
+1
-1
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
+1
-1
plugins/rpmd/platforms/reference/tests/TestReferenceRpmd.cpp
plugins/rpmd/platforms/reference/tests/TestReferenceRpmd.cpp
+1
-1
No files found.
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
View file @
9a55eeec
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
3
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "openmm/OpenMMException.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/RpmdKernels.h"
#include "openmm/RpmdKernels.h"
#include <cmath>
#include <ctime>
#include <ctime>
#include <string>
#include <string>
...
@@ -96,7 +97,61 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
...
@@ -96,7 +97,61 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
isFirstStep
=
false
;
isFirstStep
=
false
;
}
}
kernel
.
getAs
<
IntegrateRPMDStepKernel
>
().
copyToContext
(
copy
,
*
context
);
kernel
.
getAs
<
IntegrateRPMDStepKernel
>
().
copyToContext
(
copy
,
*
context
);
return
context
->
getOwner
().
getState
(
types
,
enforcePeriodicBox
,
groups
);
State
state
=
context
->
getOwner
().
getState
(
types
,
enforcePeriodicBox
&&
copy
==
0
,
groups
);
if
(
enforcePeriodicBox
&&
copy
>
0
&&
(
types
&
State
::
Positions
)
!=
0
)
{
// Apply periodic boundary conditions based on copy 0. Otherwise, molecules might end
// up in different places for different copies.
kernel
.
getAs
<
IntegrateRPMDStepKernel
>
().
copyToContext
(
0
,
*
context
);
State
state2
=
context
->
getOwner
().
getState
(
State
::
Positions
,
false
,
groups
);
vector
<
Vec3
>
positions
=
state
.
getPositions
();
const
vector
<
Vec3
>&
refPos
=
state2
.
getPositions
();
const
vector
<
vector
<
int
>
>&
molecules
=
context
->
getMolecules
();
Vec3
periodicBoxSize
[
3
];
state2
.
getPeriodicBoxVectors
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
]);
for
(
int
i
=
0
;
i
<
(
int
)
molecules
.
size
();
i
++
)
{
// Find the molecule center.
Vec3
center
;
for
(
int
j
=
0
;
j
<
(
int
)
molecules
[
i
].
size
();
j
++
)
center
+=
refPos
[
molecules
[
i
][
j
]];
center
*=
1.0
/
molecules
[
i
].
size
();
// Find the displacement to move it into the first periodic box.
int
xcell
=
(
int
)
floor
(
center
[
0
]
/
periodicBoxSize
[
0
][
0
]);
int
ycell
=
(
int
)
floor
(
center
[
1
]
/
periodicBoxSize
[
1
][
1
]);
int
zcell
=
(
int
)
floor
(
center
[
2
]
/
periodicBoxSize
[
2
][
2
]);
double
dx
=
xcell
*
periodicBoxSize
[
0
][
0
];
double
dy
=
ycell
*
periodicBoxSize
[
1
][
1
];
double
dz
=
zcell
*
periodicBoxSize
[
2
][
2
];
// Translate all the particles in the molecule.
for
(
int
j
=
0
;
j
<
(
int
)
molecules
[
i
].
size
();
j
++
)
{
Vec3
&
pos
=
positions
[
molecules
[
i
][
j
]];
pos
[
0
]
-=
dx
;
pos
[
1
]
-=
dy
;
pos
[
2
]
-=
dz
;
}
}
// Construct the new State.
State
::
StateBuilder
builder
(
state
.
getTime
());
builder
.
setPositions
(
positions
);
builder
.
setPeriodicBoxVectors
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
]);
if
(
types
&
State
::
Velocities
)
builder
.
setVelocities
(
state
.
getVelocities
());
if
(
types
&
State
::
Forces
)
builder
.
setForces
(
state
.
getForces
());
if
(
types
&
State
::
Parameters
)
builder
.
setParameters
(
state
.
getParameters
());
if
(
types
&
State
::
Energy
)
builder
.
setEnergy
(
state
.
getKineticEnergy
(),
state
.
getPotentialEnergy
());
state
=
builder
.
getState
();
}
return
state
;
}
}
double
RPMDIntegrator
::
computeKineticEnergy
()
{
double
RPMDIntegrator
::
computeKineticEnergy
()
{
...
...
plugins/rpmd/platforms/cuda/tests/TestCudaRpmd.cpp
View file @
9a55eeec
...
@@ -80,7 +80,7 @@ void testFreeParticles() {
...
@@ -80,7 +80,7 @@ void testFreeParticles() {
integ
.
step
(
1
);
integ
.
step
(
1
);
vector
<
State
>
state
(
numCopies
);
vector
<
State
>
state
(
numCopies
);
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
state
[
j
]
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Velocities
);
state
[
j
]
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Velocities
,
true
);
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
double
rg2
=
0.0
;
double
rg2
=
0.0
;
for
(
int
k
=
0
;
k
<
numCopies
;
k
++
)
{
for
(
int
k
=
0
;
k
<
numCopies
;
k
++
)
{
...
...
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
View file @
9a55eeec
...
@@ -80,7 +80,7 @@ void testFreeParticles() {
...
@@ -80,7 +80,7 @@ void testFreeParticles() {
integ
.
step
(
1
);
integ
.
step
(
1
);
vector
<
State
>
state
(
numCopies
);
vector
<
State
>
state
(
numCopies
);
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
state
[
j
]
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Velocities
);
state
[
j
]
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Velocities
,
true
);
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
double
rg2
=
0.0
;
double
rg2
=
0.0
;
for
(
int
k
=
0
;
k
<
numCopies
;
k
++
)
{
for
(
int
k
=
0
;
k
<
numCopies
;
k
++
)
{
...
...
plugins/rpmd/platforms/reference/tests/TestReferenceRpmd.cpp
View file @
9a55eeec
...
@@ -77,7 +77,7 @@ void testFreeParticles() {
...
@@ -77,7 +77,7 @@ void testFreeParticles() {
integ
.
step
(
1
);
integ
.
step
(
1
);
vector
<
State
>
state
(
numCopies
);
vector
<
State
>
state
(
numCopies
);
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
state
[
j
]
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Velocities
);
state
[
j
]
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Velocities
,
true
);
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
double
rg2
=
0.0
;
double
rg2
=
0.0
;
for
(
int
k
=
0
;
k
<
numCopies
;
k
++
)
{
for
(
int
k
=
0
;
k
<
numCopies
;
k
++
)
{
...
...
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