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
3db6b8ee
Commit
3db6b8ee
authored
Feb 07, 2015
by
Jason Swails
Browse files
Merge branch 'master' into gbn-chk
parents
5d8e92ff
3a80b0f1
Changes
121
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
202 additions
and
74 deletions
+202
-74
docs-source/usersguide/theory.rst
docs-source/usersguide/theory.rst
+55
-0
libraries/lepton/include/lepton/windowsIncludes.h
libraries/lepton/include/lepton/windowsIncludes.h
+4
-4
libraries/lepton/src/CompiledExpression.cpp
libraries/lepton/src/CompiledExpression.cpp
+2
-2
olla/include/openmm/kernels.h
olla/include/openmm/kernels.h
+5
-5
openmmapi/include/openmm/Context.h
openmmapi/include/openmm/Context.h
+3
-2
openmmapi/include/openmm/System.h
openmmapi/include/openmm/System.h
+3
-5
openmmapi/include/openmm/internal/ContextImpl.h
openmmapi/include/openmm/internal/ContextImpl.h
+3
-5
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+5
-4
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
+3
-1
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
+3
-1
openmmapi/src/NonbondedForceImpl.cpp
openmmapi/src/NonbondedForceImpl.cpp
+3
-1
openmmapi/src/System.cpp
openmmapi/src/System.cpp
+5
-4
platforms/cpu/include/CpuCustomManyParticleForce.h
platforms/cpu/include/CpuCustomManyParticleForce.h
+6
-4
platforms/cpu/include/CpuCustomNonbondedForce.h
platforms/cpu/include/CpuCustomNonbondedForce.h
+6
-3
platforms/cpu/include/CpuNeighborList.h
platforms/cpu/include/CpuNeighborList.h
+4
-3
platforms/cpu/include/CpuNonbondedForce.h
platforms/cpu/include/CpuNonbondedForce.h
+6
-3
platforms/cpu/include/CpuNonbondedForceVec4.h
platforms/cpu/include/CpuNonbondedForceVec4.h
+14
-1
platforms/cpu/include/CpuNonbondedForceVec8.h
platforms/cpu/include/CpuNonbondedForceVec8.h
+14
-1
platforms/cpu/src/CpuCustomManyParticleForce.cpp
platforms/cpu/src/CpuCustomManyParticleForce.cpp
+30
-14
platforms/cpu/src/CpuCustomNonbondedForce.cpp
platforms/cpu/src/CpuCustomNonbondedForce.cpp
+28
-11
No files found.
docs-source/usersguide/theory.rst
View file @
3db6b8ee
...
@@ -1261,6 +1261,61 @@ Other Features
...
@@ -1261,6 +1261,61 @@ Other Features
##############
##############
Periodic Boundary Conditions
****************************
Many Force objects support periodic boundary conditions. They act as if space
were tiled with infinitely repeating copies of the system, then compute the
forces acting on a single copy based on the infinite periodic copies. In most
(but not all) cases, they apply a cutoff so that each particle only interacts
with a single copy of each other particle.
OpenMM supports triclinic periodic boxes. This means the periodicity is defined
by three vectors, :math:`\mathbf{a}`\ , :math:`\mathbf{b}`\ , and
:math:`\mathbf{c}`\ . Given a particle position, the infinite periodic copies
of that particle are generated by adding vectors of the form
:math:`i \mathbf{a}+j \mathbf{b}+k \mathbf{c}`\ , where :math:`i`\ ,
:math:`j`\ , and :math:`k` are arbitrary integers.
The periodic box vectors must be chosen to satisfy certain requirements.
Roughly speaking, :math:`\mathbf{a}`\ , :math:`\mathbf{b}`\ , and
:math:`\mathbf{c}` need to "mostly" correspond to the x, y, and z axes. They
must have the form
.. math::
\mathbf{a} = (a_x, 0, 0)
\mathbf{b} = (b_x, b_y, 0)
\mathbf{c} = (c_x, c_y, c_z)
It is always possible to put the box vectors into this form by rotating the
system until :math:`\mathbf{a}` is parallel to x and :math:`\mathbf{b}` lies in
the xy plane.
Furthermore, they must obey the following constraints:
.. math::
a_x > 0, b_y > 0, c_z > 0
a_x \ge 2 |b_x|
a_x \ge 2 |c_x|
b_y \ge 2 |c_y|
This effectively requires the box vectors to be specified in a particular
reduced form. By forming combinations of box vectors (a process known as
"lattice reduction"), it is always possible to put them in this form without
changing the periodic system they represent.
These requirements have an important consequence: the periodic unit cell can
always be treated as an axis-aligned rectangular box of size
:math:`(a_x, b_y, c_z)`\ . The remaining non-zero elements of the box vectors
cause the repeating copies of the system to be staggered relative to each other,
but they do not affect the shape or size of each copy. The volume of the unit
cell is simply given by :math:`a_x b_y c_z`\ .
LocalEnergyMinimizer
LocalEnergyMinimizer
********************
********************
...
...
libraries/lepton/include/lepton/windowsIncludes.h
View file @
3db6b8ee
...
@@ -25,14 +25,14 @@
...
@@ -25,14 +25,14 @@
#ifdef _MSC_VER
#ifdef _MSC_VER
// We don't want to hear about how sprintf is "unsafe".
// We don't want to hear about how sprintf is "unsafe".
#pragma warning(disable:4996)
#pragma warning(disable:4996)
// Keep MS VC++ quiet about lack of dll export of private members.
#pragma warning(disable:4251)
#if defined(LEPTON_BUILDING_SHARED_LIBRARY)
#if defined(LEPTON_BUILDING_SHARED_LIBRARY)
#define LEPTON_EXPORT __declspec(dllexport)
#define LEPTON_EXPORT __declspec(dllexport)
// Keep MS VC++ quiet about lack of dll export of private members.
#pragma warning(disable:4251)
#elif defined(LEPTON_BUILDING_STATIC_LIBRARY) || defined(LEPTON_USE_STATIC_LIBRARIES)
#elif defined(LEPTON_BUILDING_STATIC_LIBRARY) || defined(LEPTON_USE_STATIC_LIBRARIES)
#define LEPTON_EXPORT
#define LEPTON_EXPORT
#else
#else
#define LEPTON_EXPORT __declspec(dllimport) // i.e., a client of a shared library
#define LEPTON_EXPORT __declspec(dllimport) // i.e., a client of a shared library
#endif
#endif
#else
#else
#define LEPTON_EXPORT // Linux, Mac
#define LEPTON_EXPORT // Linux, Mac
...
...
libraries/lepton/src/CompiledExpression.cpp
View file @
3db6b8ee
...
@@ -121,7 +121,7 @@ void CompiledExpression::compileExpression(const ExpressionTreeNode& node, vecto
...
@@ -121,7 +121,7 @@ void CompiledExpression::compileExpression(const ExpressionTreeNode& node, vecto
arguments
[
stepIndex
]
=
args
;
arguments
[
stepIndex
]
=
args
;
}
}
}
}
temps
.
push_back
(
make_pair
(
node
,
workspace
.
size
()));
temps
.
push_back
(
make_pair
(
node
,
(
int
)
workspace
.
size
()));
workspace
.
push_back
(
0.0
);
workspace
.
push_back
(
0.0
);
}
}
...
@@ -368,4 +368,4 @@ void CompiledExpression::generateSingleArgCall(X86Compiler& c, X86XmmVar& dest,
...
@@ -368,4 +368,4 @@ void CompiledExpression::generateSingleArgCall(X86Compiler& c, X86XmmVar& dest,
call
->
setArg
(
0
,
arg
);
call
->
setArg
(
0
,
arg
);
call
->
setRet
(
0
,
dest
);
call
->
setRet
(
0
,
dest
);
}
}
#endif
#endif
\ No newline at end of file
olla/include/openmm/kernels.h
View file @
3db6b8ee
...
@@ -1223,12 +1223,12 @@ public:
...
@@ -1223,12 +1223,12 @@ public:
virtual
void
initialize
(
int
gridx
,
int
gridy
,
int
gridz
,
int
numParticles
,
double
alpha
)
=
0
;
virtual
void
initialize
(
int
gridx
,
int
gridy
,
int
gridz
,
int
numParticles
,
double
alpha
)
=
0
;
/**
/**
* Begin computing the force and energy.
* Begin computing the force and energy.
*
*
* @param io an object that coordinates data transfer
* @param io
an object that coordinates data transfer
* @param periodicBox
Size the size of
the periodic box (measured in nm)
* @param periodicBox
Vectors the vectors defining
the periodic box (measured in nm)
* @param includeEnergy true if potential energy should be computed
* @param includeEnergy
true if potential energy should be computed
*/
*/
virtual
void
beginComputation
(
IO
&
io
,
Vec3
periodicBox
Size
,
bool
includeEnergy
)
=
0
;
virtual
void
beginComputation
(
IO
&
io
,
const
Vec3
*
periodicBox
Vectors
,
bool
includeEnergy
)
=
0
;
/**
/**
* Finish computing the force and energy.
* Finish computing the force and energy.
*
*
...
...
openmmapi/include/openmm/Context.h
View file @
3db6b8ee
...
@@ -182,8 +182,9 @@ public:
...
@@ -182,8 +182,9 @@ public:
* Set the vectors defining the axes of the periodic box (measured in nm). They will affect
* Set the vectors defining the axes of the periodic box (measured in nm). They will affect
* any Force that uses periodic boundary conditions.
* any Force that uses periodic boundary conditions.
*
*
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the
* Triclinic boxes are supported, but the vectors must satisfy certain requirements. In particular,
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
* a must point in the x direction, b must point "mostly" in the y direction, and c must point "mostly"
* in the z direction. See the documentation for details.
*
*
* @param a the vector defining the first edge of the periodic box
* @param a the vector defining the first edge of the periodic box
* @param b the vector defining the second edge of the periodic box
* @param b the vector defining the second edge of the periodic box
...
...
openmmapi/include/openmm/System.h
View file @
3db6b8ee
...
@@ -203,9 +203,6 @@ public:
...
@@ -203,9 +203,6 @@ public:
* created Context will have its box vectors set to these. They will affect
* created Context will have its box vectors set to these. They will affect
* any Force added to the System that uses periodic boundary conditions.
* any Force added to the System that uses periodic boundary conditions.
*
*
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
*
* @param a on exit, this contains the vector defining the first edge of the periodic box
* @param a on exit, this contains the vector defining the first edge of the periodic box
* @param b on exit, this contains the vector defining the second edge of the periodic box
* @param b on exit, this contains the vector defining the second edge of the periodic box
* @param c on exit, this contains the vector defining the third edge of the periodic box
* @param c on exit, this contains the vector defining the third edge of the periodic box
...
@@ -216,8 +213,9 @@ public:
...
@@ -216,8 +213,9 @@ public:
* created Context will have its box vectors set to these. They will affect
* created Context will have its box vectors set to these. They will affect
* any Force added to the System that uses periodic boundary conditions.
* any Force added to the System that uses periodic boundary conditions.
*
*
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the
* Triclinic boxes are supported, but the vectors must satisfy certain requirements. In particular,
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
* a must point in the x direction, b must point "mostly" in the y direction, and c must point "mostly"
* in the z direction. See the documentation for details.
*
*
* @param a the vector defining the first edge of the periodic box
* @param a the vector defining the first edge of the periodic box
* @param b the vector defining the second edge of the periodic box
* @param b the vector defining the second edge of the periodic box
...
...
openmmapi/include/openmm/internal/ContextImpl.h
View file @
3db6b8ee
...
@@ -142,9 +142,6 @@ public:
...
@@ -142,9 +142,6 @@ public:
* Get the vectors defining the axes of the periodic box (measured in nm). They will affect
* Get the vectors defining the axes of the periodic box (measured in nm). They will affect
* any Force that uses periodic boundary conditions.
* any Force that uses periodic boundary conditions.
*
*
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
*
* @param a the vector defining the first edge of the periodic box
* @param a the vector defining the first edge of the periodic box
* @param b the vector defining the second edge of the periodic box
* @param b the vector defining the second edge of the periodic box
* @param c the vector defining the third edge of the periodic box
* @param c the vector defining the third edge of the periodic box
...
@@ -154,8 +151,9 @@ public:
...
@@ -154,8 +151,9 @@ public:
* Set the vectors defining the axes of the periodic box (measured in nm). They will affect
* Set the vectors defining the axes of the periodic box (measured in nm). They will affect
* any Force that uses periodic boundary conditions.
* any Force that uses periodic boundary conditions.
*
*
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the
* Triclinic boxes are supported, but the vectors must satisfy certain requirements. In particular,
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
* a must point in the x direction, b must point "mostly" in the y direction, and c must point "mostly"
* in the z direction. See the documentation for details.
*
*
* @param a the vector defining the first edge of the periodic box
* @param a the vector defining the first edge of the periodic box
* @param b the vector defining the second edge of the periodic box
* @param b the vector defining the second edge of the periodic box
...
...
openmmapi/src/ContextImpl.cpp
View file @
3db6b8ee
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "openmm/VirtualSite.h"
#include "openmm/VirtualSite.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include <algorithm>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iostream>
#include <map>
#include <map>
#include <utility>
#include <utility>
...
@@ -235,10 +236,10 @@ void ContextImpl::getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) {
...
@@ -235,10 +236,10 @@ void ContextImpl::getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) {
void
ContextImpl
::
setPeriodicBoxVectors
(
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
{
void
ContextImpl
::
setPeriodicBoxVectors
(
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
{
if
(
a
[
1
]
!=
0.0
||
a
[
2
]
!=
0.0
)
if
(
a
[
1
]
!=
0.0
||
a
[
2
]
!=
0.0
)
throw
OpenMMException
(
"First periodic box vector must be parallel to x."
);
throw
OpenMMException
(
"First periodic box vector must be parallel to x."
);
if
(
b
[
0
]
!=
0.0
||
b
[
2
]
!=
0.0
)
if
(
b
[
2
]
!=
0.0
)
throw
OpenMMException
(
"Second periodic box vector must be
parallel to y
."
);
throw
OpenMMException
(
"Second periodic box vector must be
in the x-y plane
."
);
if
(
c
[
0
]
!
=
0.0
||
c
[
1
]
!
=
0.0
)
if
(
a
[
0
]
<=
0.0
||
b
[
1
]
<
=
0.0
||
c
[
2
]
<
=
0.0
||
a
[
0
]
<
2
*
fabs
(
b
[
0
])
||
a
[
0
]
<
2
*
fabs
(
c
[
0
])
||
b
[
1
]
<
2
*
fabs
(
c
[
1
])
)
throw
OpenMMException
(
"
Third p
eriodic box vector must be
parallel to z
."
);
throw
OpenMMException
(
"
P
eriodic box vector
s
must be
in reduced form
."
);
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
setPeriodicBoxVectors
(
*
this
,
a
,
b
,
c
);
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
setPeriodicBoxVectors
(
*
this
,
a
,
b
,
c
);
}
}
...
...
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
View file @
3db6b8ee
...
@@ -112,7 +112,9 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
...
@@ -112,7 +112,9 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
Vec3
lengthScale
(
1.0
,
1.0
,
1.0
);
Vec3
lengthScale
(
1.0
,
1.0
,
1.0
);
lengthScale
[
axis
]
=
newVolume
/
volume
;
lengthScale
[
axis
]
=
newVolume
/
volume
;
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
scaleCoordinates
(
context
,
lengthScale
[
0
],
lengthScale
[
1
],
lengthScale
[
2
]);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
scaleCoordinates
(
context
,
lengthScale
[
0
],
lengthScale
[
1
],
lengthScale
[
2
]);
context
.
getOwner
().
setPeriodicBoxVectors
(
box
[
0
]
*
lengthScale
[
0
],
box
[
1
]
*
lengthScale
[
1
],
box
[
2
]
*
lengthScale
[
2
]);
context
.
getOwner
().
setPeriodicBoxVectors
(
Vec3
(
box
[
0
][
0
]
*
lengthScale
[
0
],
box
[
0
][
1
]
*
lengthScale
[
1
],
box
[
0
][
2
]
*
lengthScale
[
2
]),
Vec3
(
box
[
1
][
0
]
*
lengthScale
[
0
],
box
[
1
][
1
]
*
lengthScale
[
1
],
box
[
1
][
2
]
*
lengthScale
[
2
]),
Vec3
(
box
[
2
][
0
]
*
lengthScale
[
0
],
box
[
2
][
1
]
*
lengthScale
[
1
],
box
[
2
][
2
]
*
lengthScale
[
2
]));
// Compute the energy of the modified system.
// Compute the energy of the modified system.
...
...
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
View file @
3db6b8ee
...
@@ -113,7 +113,9 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
...
@@ -113,7 +113,9 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
}
}
double
deltaArea
=
box
[
0
][
0
]
*
lengthScale
[
0
]
*
box
[
1
][
1
]
*
lengthScale
[
1
]
-
box
[
0
][
0
]
*
box
[
1
][
1
];
double
deltaArea
=
box
[
0
][
0
]
*
lengthScale
[
0
]
*
box
[
1
][
1
]
*
lengthScale
[
1
]
-
box
[
0
][
0
]
*
box
[
1
][
1
];
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
scaleCoordinates
(
context
,
lengthScale
[
0
],
lengthScale
[
1
],
lengthScale
[
2
]);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
scaleCoordinates
(
context
,
lengthScale
[
0
],
lengthScale
[
1
],
lengthScale
[
2
]);
context
.
getOwner
().
setPeriodicBoxVectors
(
box
[
0
]
*
lengthScale
[
0
],
box
[
1
]
*
lengthScale
[
1
],
box
[
2
]
*
lengthScale
[
2
]);
context
.
getOwner
().
setPeriodicBoxVectors
(
Vec3
(
box
[
0
][
0
]
*
lengthScale
[
0
],
box
[
0
][
1
]
*
lengthScale
[
1
],
box
[
0
][
2
]
*
lengthScale
[
2
]),
Vec3
(
box
[
1
][
0
]
*
lengthScale
[
0
],
box
[
1
][
1
]
*
lengthScale
[
1
],
box
[
1
][
2
]
*
lengthScale
[
2
]),
Vec3
(
box
[
2
][
0
]
*
lengthScale
[
0
],
box
[
2
][
1
]
*
lengthScale
[
1
],
box
[
2
][
2
]
*
lengthScale
[
2
]));
// Compute the energy of the modified system.
// Compute the energy of the modified system.
...
...
openmmapi/src/NonbondedForceImpl.cpp
View file @
3db6b8ee
...
@@ -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
4
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
5
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -98,6 +98,8 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
...
@@ -98,6 +98,8 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
double
cutoff
=
owner
.
getCutoffDistance
();
double
cutoff
=
owner
.
getCutoffDistance
();
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
throw
OpenMMException
(
"NonbondedForce: The cutoff distance cannot be greater than half the periodic box size."
);
throw
OpenMMException
(
"NonbondedForce: The cutoff distance cannot be greater than half the periodic box size."
);
if
(
owner
.
getNonbondedMethod
()
==
NonbondedForce
::
Ewald
&&
(
boxVectors
[
1
][
0
]
!=
0.0
||
boxVectors
[
2
][
0
]
!=
0.0
||
boxVectors
[
2
][
1
]
!=
0
))
throw
OpenMMException
(
"NonbondedForce: Ewald is not supported with non-rectangular boxes. Use PME instead."
);
}
}
kernel
.
getAs
<
CalcNonbondedForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcNonbondedForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
}
...
...
openmmapi/src/System.cpp
View file @
3db6b8ee
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "openmm/System.h"
#include "openmm/System.h"
#include "openmm/VirtualSite.h"
#include "openmm/VirtualSite.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/internal/AssertionUtilities.h"
#include <cmath>
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
@@ -111,10 +112,10 @@ void System::getDefaultPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const {
...
@@ -111,10 +112,10 @@ void System::getDefaultPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const {
void
System
::
setDefaultPeriodicBoxVectors
(
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
{
void
System
::
setDefaultPeriodicBoxVectors
(
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
{
if
(
a
[
1
]
!=
0.0
||
a
[
2
]
!=
0.0
)
if
(
a
[
1
]
!=
0.0
||
a
[
2
]
!=
0.0
)
throw
OpenMMException
(
"First periodic box vector must be parallel to x."
);
throw
OpenMMException
(
"First periodic box vector must be parallel to x."
);
if
(
b
[
0
]
!=
0.0
||
b
[
2
]
!=
0.0
)
if
(
b
[
2
]
!=
0.0
)
throw
OpenMMException
(
"Second periodic box vector must be
parallel to y
."
);
throw
OpenMMException
(
"Second periodic box vector must be
in the x-y plane
."
);
if
(
c
[
0
]
!
=
0.0
||
c
[
1
]
!
=
0.0
)
if
(
a
[
0
]
<=
0.0
||
b
[
1
]
<
=
0.0
||
c
[
2
]
<
=
0.0
||
a
[
0
]
<
2
*
fabs
(
b
[
0
])
||
a
[
0
]
<
2
*
fabs
(
c
[
0
])
||
b
[
1
]
<
2
*
fabs
(
c
[
1
])
)
throw
OpenMMException
(
"
Third p
eriodic box vector must be
parallel to z
."
);
throw
OpenMMException
(
"
P
eriodic box vector
s
must be
in reduced form
."
);
periodicBoxVectors
[
0
]
=
a
;
periodicBoxVectors
[
0
]
=
a
;
periodicBoxVectors
[
1
]
=
b
;
periodicBoxVectors
[
1
]
=
b
;
periodicBoxVectors
[
2
]
=
c
;
periodicBoxVectors
[
2
]
=
c
;
...
...
platforms/cpu/include/CpuCustomManyParticleForce.h
View file @
3db6b8ee
...
@@ -51,9 +51,11 @@ private:
...
@@ -51,9 +51,11 @@ private:
class
ComputeForceTask
;
class
ComputeForceTask
;
class
ThreadData
;
class
ThreadData
;
int
numParticles
,
numParticlesPerSet
,
numPerParticleParameters
,
numTypes
;
int
numParticles
,
numParticlesPerSet
,
numPerParticleParameters
,
numTypes
;
bool
useCutoff
,
usePeriodic
,
centralParticleMode
;
bool
useCutoff
,
usePeriodic
,
triclinic
,
centralParticleMode
;
RealOpenMM
cutoffDistance
;
RealOpenMM
cutoffDistance
;
RealOpenMM
periodicBoxSize
[
3
];
float
recipBoxSize
[
3
];
RealVec
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
CpuNeighborList
*
neighborList
;
CpuNeighborList
*
neighborList
;
ThreadPool
&
threads
;
ThreadPool
&
threads
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
...
@@ -138,9 +140,9 @@ public:
...
@@ -138,9 +140,9 @@ public:
* already been set, and the smallest side of the periodic box is at least twice the cutoff
* already been set, and the smallest side of the periodic box is at least twice the cutoff
* distance.
* distance.
*
*
* @param
boxSize the X, Y, and Z widths of
the periodic box
* @param
periodicBoxVectors the vectors defining
the periodic box
*/
*/
void
setPeriodic
(
OpenMM
::
RealVec
&
boxSize
);
void
setPeriodic
(
RealVec
*
periodicBoxVectors
);
/**
/**
* Calculate the interaction.
* Calculate the interaction.
...
...
platforms/cpu/include/CpuCustomNonbondedForce.h
View file @
3db6b8ee
...
@@ -95,11 +95,11 @@ class CpuCustomNonbondedForce {
...
@@ -95,11 +95,11 @@ class CpuCustomNonbondedForce {
already been set, and the smallest side of the periodic box is at least twice the cutoff
already been set, and the smallest side of the periodic box is at least twice the cutoff
distance.
distance.
@param
boxSize the X, Y, and Z widths of
the periodic box
@param
periodicBoxVectors the vectors defining
the periodic box
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
&
boxSize
);
void
setPeriodic
(
RealVec
*
periodicBoxVectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -127,8 +127,11 @@ private:
...
@@ -127,8 +127,11 @@ private:
bool
cutoff
;
bool
cutoff
;
bool
useSwitch
;
bool
useSwitch
;
bool
periodic
;
bool
periodic
;
bool
triclinic
;
const
CpuNeighborList
*
neighborList
;
const
CpuNeighborList
*
neighborList
;
RealOpenMM
periodicBoxSize
[
3
];
float
recipBoxSize
[
3
];
RealVec
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
RealOpenMM
cutoffDistance
,
switchingDistance
;
RealOpenMM
cutoffDistance
,
switchingDistance
;
ThreadPool
&
threads
;
ThreadPool
&
threads
;
const
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
const
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
...
...
platforms/cpu/include/CpuNeighborList.h
View file @
3db6b8ee
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "AlignedArray.h"
#include "AlignedArray.h"
#include "RealVec.h"
#include "windowsExportCpu.h"
#include "windowsExportCpu.h"
#include "openmm/internal/ThreadPool.h"
#include "openmm/internal/ThreadPool.h"
#include <set>
#include <set>
...
@@ -40,14 +41,14 @@
...
@@ -40,14 +41,14 @@
#include <vector>
#include <vector>
namespace
OpenMM
{
namespace
OpenMM
{
class
OPENMM_EXPORT_CPU
CpuNeighborList
{
class
OPENMM_EXPORT_CPU
CpuNeighborList
{
public:
public:
class
ThreadTask
;
class
ThreadTask
;
class
Voxels
;
class
Voxels
;
CpuNeighborList
(
int
blockSize
);
CpuNeighborList
(
int
blockSize
);
void
computeNeighborList
(
int
numAtoms
,
const
AlignedArray
<
float
>&
atomLocations
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
void
computeNeighborList
(
int
numAtoms
,
const
AlignedArray
<
float
>&
atomLocations
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
const
float
*
periodicBox
Size
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
const
RealVec
*
periodicBox
Vectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
int
getNumBlocks
()
const
;
int
getNumBlocks
()
const
;
const
std
::
vector
<
int
>&
getSortedAtoms
()
const
;
const
std
::
vector
<
int
>&
getSortedAtoms
()
const
;
const
std
::
vector
<
int
>&
getBlockNeighbors
(
int
blockIndex
)
const
;
const
std
::
vector
<
int
>&
getBlockNeighbors
(
int
blockIndex
)
const
;
...
@@ -68,7 +69,7 @@ private:
...
@@ -68,7 +69,7 @@ private:
Voxels
*
voxels
;
Voxels
*
voxels
;
const
std
::
vector
<
std
::
set
<
int
>
>*
exclusions
;
const
std
::
vector
<
std
::
set
<
int
>
>*
exclusions
;
const
float
*
atomLocations
;
const
float
*
atomLocations
;
const
float
*
periodicBox
Size
;
RealVec
periodicBox
Vectors
[
3
]
;
int
numAtoms
;
int
numAtoms
;
bool
usePeriodic
;
bool
usePeriodic
;
float
maxDistance
;
float
maxDistance
;
...
...
platforms/cpu/include/CpuNonbondedForce.h
View file @
3db6b8ee
...
@@ -83,11 +83,11 @@ class CpuNonbondedForce {
...
@@ -83,11 +83,11 @@ class CpuNonbondedForce {
already been set, and the smallest side of the periodic box is at least twice the cutoff
already been set, and the smallest side of the periodic box is at least twice the cutoff
distance.
distance.
@param
boxSize the X, Y, and Z widths of
the periodic box
@param
periodicBoxVectors the vectors defining
the periodic box
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
float
*
periodicBox
Size
);
void
setPeriodic
(
RealVec
*
periodicBox
Vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -161,11 +161,14 @@ protected:
...
@@ -161,11 +161,14 @@ protected:
bool
cutoff
;
bool
cutoff
;
bool
useSwitch
;
bool
useSwitch
;
bool
periodic
;
bool
periodic
;
bool
triclinic
;
bool
ewald
;
bool
ewald
;
bool
pme
;
bool
pme
;
bool
tableIsValid
;
bool
tableIsValid
;
const
CpuNeighborList
*
neighborList
;
const
CpuNeighborList
*
neighborList
;
float
periodicBoxSize
[
3
];
float
recipBoxSize
[
3
];
RealVec
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
float
cutoffDistance
,
switchingDistance
;
float
cutoffDistance
,
switchingDistance
;
float
krf
,
crf
;
float
krf
,
crf
;
float
alphaEwald
;
float
alphaEwald
;
...
...
platforms/cpu/include/CpuNonbondedForceVec4.h
View file @
3db6b8ee
/* Portions copyright (c) 2006-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
4
Stanford University and Simbios.
* Contributors: Pande Group
* Contributors: Pande Group
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -52,6 +52,12 @@ protected:
...
@@ -52,6 +52,12 @@ protected:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
calculateBlockIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
void
calculateBlockIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
* Templatized implementation of calculateBlockIxn.
*/
template
<
bool
TRICLINIC
>
void
calculateBlockIxnImpl
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -65,10 +71,17 @@ protected:
...
@@ -65,10 +71,17 @@ protected:
void
calculateBlockEwaldIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
void
calculateBlockEwaldIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
* Templatized implementation of calculateBlockEwaldIxn.
*/
template
<
bool
TRICLINIC
>
void
calculateBlockEwaldIxnImpl
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
* Compute the displacement and squared distance between a collection of points, optionally using
* Compute the displacement and squared distance between a collection of points, optionally using
* periodic boundary conditions.
* periodic boundary conditions.
*/
*/
template
<
bool
TRICLINIC
>
void
getDeltaR
(
const
float
*
posI
,
const
fvec4
&
x
,
const
fvec4
&
y
,
const
fvec4
&
z
,
fvec4
&
dx
,
fvec4
&
dy
,
fvec4
&
dz
,
fvec4
&
r2
,
bool
periodic
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
;
void
getDeltaR
(
const
float
*
posI
,
const
fvec4
&
x
,
const
fvec4
&
y
,
const
fvec4
&
z
,
fvec4
&
dx
,
fvec4
&
dy
,
fvec4
&
dz
,
fvec4
&
r2
,
bool
periodic
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
;
/**
/**
...
...
platforms/cpu/include/CpuNonbondedForceVec8.h
View file @
3db6b8ee
/* Portions copyright (c) 2006-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
4
Stanford University and Simbios.
* Contributors: Pande Group
* Contributors: Pande Group
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -51,6 +51,12 @@ protected:
...
@@ -51,6 +51,12 @@ protected:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
calculateBlockIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
void
calculateBlockIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
* Templatized implementation of calculateBlockIxn.
*/
template
<
bool
TRICLINIC
>
void
calculateBlockIxnImpl
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -64,10 +70,17 @@ protected:
...
@@ -64,10 +70,17 @@ protected:
void
calculateBlockEwaldIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
void
calculateBlockEwaldIxn
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
* Templatized implementation of calculateBlockEwaldIxn.
*/
template
<
bool
TRICLINIC
>
void
calculateBlockEwaldIxnImpl
(
int
blockIndex
,
float
*
forces
,
double
*
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
* Compute the displacement and squared distance between a collection of points, optionally using
* Compute the displacement and squared distance between a collection of points, optionally using
* periodic boundary conditions.
* periodic boundary conditions.
*/
*/
template
<
bool
TRICLINIC
>
void
getDeltaR
(
const
float
*
posI
,
const
fvec8
&
x
,
const
fvec8
&
y
,
const
fvec8
&
z
,
fvec8
&
dx
,
fvec8
&
dy
,
fvec8
&
dz
,
fvec8
&
r2
,
bool
periodic
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
;
void
getDeltaR
(
const
float
*
posI
,
const
fvec8
&
x
,
const
fvec8
&
y
,
const
fvec8
&
z
,
fvec8
&
dx
,
fvec8
&
dy
,
fvec8
&
dz
,
fvec8
&
r2
,
bool
periodic
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
;
/**
/**
...
...
platforms/cpu/src/CpuCustomManyParticleForce.cpp
View file @
3db6b8ee
...
@@ -122,8 +122,7 @@ void CpuCustomManyParticleForce::calculateIxn(AlignedArray<float>& posq, RealOpe
...
@@ -122,8 +122,7 @@ void CpuCustomManyParticleForce::calculateIxn(AlignedArray<float>& posq, RealOpe
particleNeighbors
.
resize
(
numParticles
);
particleNeighbors
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
particleNeighbors
[
i
].
clear
();
particleNeighbors
[
i
].
clear
();
float
boxSizeFloat
[]
=
{(
float
)
periodicBoxSize
[
0
],
(
float
)
periodicBoxSize
[
1
],
(
float
)
periodicBoxSize
[
2
]};
neighborList
->
computeNeighborList
(
numParticles
,
posq
,
exclusions
,
periodicBoxVectors
,
usePeriodic
,
cutoffDistance
,
threads
);
neighborList
->
computeNeighborList
(
numParticles
,
posq
,
exclusions
,
boxSizeFloat
,
usePeriodic
,
cutoffDistance
,
threads
);
for
(
int
blockIndex
=
0
;
blockIndex
<
neighborList
->
getNumBlocks
();
blockIndex
++
)
{
for
(
int
blockIndex
=
0
;
blockIndex
<
neighborList
->
getNumBlocks
();
blockIndex
++
)
{
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
char
>&
exclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
const
vector
<
char
>&
exclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
...
@@ -159,8 +158,8 @@ void CpuCustomManyParticleForce::calculateIxn(AlignedArray<float>& posq, RealOpe
...
@@ -159,8 +158,8 @@ void CpuCustomManyParticleForce::calculateIxn(AlignedArray<float>& posq, RealOpe
void
CpuCustomManyParticleForce
::
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
)
{
void
CpuCustomManyParticleForce
::
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
)
{
vector
<
int
>
particleIndices
(
numParticlesPerSet
);
vector
<
int
>
particleIndices
(
numParticlesPerSet
);
fvec4
boxSize
(
periodicBox
Size
[
0
],
periodicBox
Size
[
1
],
periodicBox
Size
[
2
],
0
);
fvec4
boxSize
(
periodicBox
Vectors
[
0
]
[
0
],
periodicBox
Vectors
[
1
]
[
1
],
periodicBox
Vectors
[
2
]
[
2
],
0
);
fvec4
invBoxSize
(
(
1
/
periodic
BoxSize
[
0
]
)
,
(
1
/
periodic
BoxSize
[
1
]
)
,
(
1
/
periodic
BoxSize
[
2
]
)
,
0
);
fvec4
invBoxSize
(
recip
BoxSize
[
0
],
recip
BoxSize
[
1
],
recip
BoxSize
[
2
],
0
);
float
*
forces
=
&
(
*
threadForce
)[
threadIndex
][
0
];
float
*
forces
=
&
(
*
threadForce
)[
threadIndex
][
0
];
ThreadData
&
data
=
*
threadData
[
threadIndex
];
ThreadData
&
data
=
*
threadData
[
threadIndex
];
data
.
energy
=
0
;
data
.
energy
=
0
;
...
@@ -201,15 +200,25 @@ void CpuCustomManyParticleForce::setUseCutoff(RealOpenMM distance) {
...
@@ -201,15 +200,25 @@ void CpuCustomManyParticleForce::setUseCutoff(RealOpenMM distance) {
neighborList
=
new
CpuNeighborList
(
4
);
neighborList
=
new
CpuNeighborList
(
4
);
}
}
void
CpuCustomManyParticleForce
::
setPeriodic
(
RealVec
&
boxSize
)
{
void
CpuCustomManyParticleForce
::
setPeriodic
(
RealVec
*
periodicBoxVectors
)
{
assert
(
useC
utoff
);
assert
(
c
utoff
);
assert
(
boxSize
[
0
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
0
]
[
0
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
1
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
1
]
[
1
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
2
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
2
]
[
2
]
>=
2.0
*
cutoffDistance
);
usePeriodic
=
true
;
usePeriodic
=
true
;
periodicBoxSize
[
0
]
=
boxSize
[
0
];
this
->
periodicBoxVectors
[
0
]
=
periodicBoxVectors
[
0
];
periodicBoxSize
[
1
]
=
boxSize
[
1
];
this
->
periodicBoxVectors
[
1
]
=
periodicBoxVectors
[
1
];
periodicBoxSize
[
2
]
=
boxSize
[
2
];
this
->
periodicBoxVectors
[
2
]
=
periodicBoxVectors
[
2
];
recipBoxSize
[
0
]
=
(
float
)
(
1.0
/
periodicBoxVectors
[
0
][
0
]);
recipBoxSize
[
1
]
=
(
float
)
(
1.0
/
periodicBoxVectors
[
1
][
1
]);
recipBoxSize
[
2
]
=
(
float
)
(
1.0
/
periodicBoxVectors
[
2
][
2
]);
periodicBoxVec4
.
resize
(
3
);
periodicBoxVec4
[
0
]
=
fvec4
(
periodicBoxVectors
[
0
][
0
],
periodicBoxVectors
[
0
][
1
],
periodicBoxVectors
[
0
][
2
],
0
);
periodicBoxVec4
[
1
]
=
fvec4
(
periodicBoxVectors
[
1
][
0
],
periodicBoxVectors
[
1
][
1
],
periodicBoxVectors
[
1
][
2
],
0
);
periodicBoxVec4
[
2
]
=
fvec4
(
periodicBoxVectors
[
2
][
0
],
periodicBoxVectors
[
2
][
1
],
periodicBoxVectors
[
2
][
2
],
0
);
triclinic
=
(
periodicBoxVectors
[
0
][
1
]
!=
0.0
||
periodicBoxVectors
[
0
][
2
]
!=
0.0
||
periodicBoxVectors
[
1
][
0
]
!=
0.0
||
periodicBoxVectors
[
1
][
2
]
!=
0.0
||
periodicBoxVectors
[
2
][
0
]
!=
0.0
||
periodicBoxVectors
[
2
][
1
]
!=
0.0
);
}
}
void
CpuCustomManyParticleForce
::
loopOverInteractions
(
vector
<
int
>&
availableParticles
,
vector
<
int
>&
particleSet
,
int
loopIndex
,
int
startIndex
,
void
CpuCustomManyParticleForce
::
loopOverInteractions
(
vector
<
int
>&
availableParticles
,
vector
<
int
>&
particleSet
,
int
loopIndex
,
int
startIndex
,
...
@@ -394,8 +403,15 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, RealO
...
@@ -394,8 +403,15 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, RealO
void
CpuCustomManyParticleForce
::
computeDelta
(
const
fvec4
&
posI
,
const
fvec4
&
posJ
,
fvec4
&
deltaR
,
float
&
r2
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
{
void
CpuCustomManyParticleForce
::
computeDelta
(
const
fvec4
&
posI
,
const
fvec4
&
posJ
,
fvec4
&
deltaR
,
float
&
r2
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
{
deltaR
=
posJ
-
posI
;
deltaR
=
posJ
-
posI
;
if
(
usePeriodic
)
{
if
(
usePeriodic
)
{
fvec4
base
=
round
(
deltaR
*
invBoxSize
)
*
boxSize
;
if
(
triclinic
)
{
deltaR
=
deltaR
-
base
;
deltaR
-=
periodicBoxVec4
[
2
]
*
floorf
(
deltaR
[
2
]
*
recipBoxSize
[
2
]
+
0.5
f
);
deltaR
-=
periodicBoxVec4
[
1
]
*
floorf
(
deltaR
[
1
]
*
recipBoxSize
[
1
]
+
0.5
f
);
deltaR
-=
periodicBoxVec4
[
0
]
*
floorf
(
deltaR
[
0
]
*
recipBoxSize
[
0
]
+
0.5
f
);
}
else
{
fvec4
base
=
round
(
deltaR
*
invBoxSize
)
*
boxSize
;
deltaR
=
deltaR
-
base
;
}
}
}
r2
=
dot3
(
deltaR
,
deltaR
);
r2
=
dot3
(
deltaR
,
deltaR
);
}
}
...
...
platforms/cpu/src/CpuCustomNonbondedForce.cpp
View file @
3db6b8ee
...
@@ -98,15 +98,25 @@ void CpuCustomNonbondedForce::setUseSwitchingFunction(RealOpenMM distance) {
...
@@ -98,15 +98,25 @@ void CpuCustomNonbondedForce::setUseSwitchingFunction(RealOpenMM distance) {
switchingDistance
=
distance
;
switchingDistance
=
distance
;
}
}
void
CpuCustomNonbondedForce
::
setPeriodic
(
RealVec
&
boxSize
)
{
void
CpuCustomNonbondedForce
::
setPeriodic
(
RealVec
*
periodicBoxVectors
)
{
assert
(
cutoff
);
assert
(
cutoff
);
assert
(
boxSize
[
0
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
0
]
[
0
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
1
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
1
]
[
1
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
2
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
2
]
[
2
]
>=
2.0
*
cutoffDistance
);
periodic
=
true
;
periodic
=
true
;
periodicBoxSize
[
0
]
=
boxSize
[
0
];
this
->
periodicBoxVectors
[
0
]
=
periodicBoxVectors
[
0
];
periodicBoxSize
[
1
]
=
boxSize
[
1
];
this
->
periodicBoxVectors
[
1
]
=
periodicBoxVectors
[
1
];
periodicBoxSize
[
2
]
=
boxSize
[
2
];
this
->
periodicBoxVectors
[
2
]
=
periodicBoxVectors
[
2
];
recipBoxSize
[
0
]
=
(
float
)
(
1.0
/
periodicBoxVectors
[
0
][
0
]);
recipBoxSize
[
1
]
=
(
float
)
(
1.0
/
periodicBoxVectors
[
1
][
1
]);
recipBoxSize
[
2
]
=
(
float
)
(
1.0
/
periodicBoxVectors
[
2
][
2
]);
periodicBoxVec4
.
resize
(
3
);
periodicBoxVec4
[
0
]
=
fvec4
(
periodicBoxVectors
[
0
][
0
],
periodicBoxVectors
[
0
][
1
],
periodicBoxVectors
[
0
][
2
],
0
);
periodicBoxVec4
[
1
]
=
fvec4
(
periodicBoxVectors
[
1
][
0
],
periodicBoxVectors
[
1
][
1
],
periodicBoxVectors
[
1
][
2
],
0
);
periodicBoxVec4
[
2
]
=
fvec4
(
periodicBoxVectors
[
2
][
0
],
periodicBoxVectors
[
2
][
1
],
periodicBoxVectors
[
2
][
2
],
0
);
triclinic
=
(
periodicBoxVectors
[
0
][
1
]
!=
0.0
||
periodicBoxVectors
[
0
][
2
]
!=
0.0
||
periodicBoxVectors
[
1
][
0
]
!=
0.0
||
periodicBoxVectors
[
1
][
2
]
!=
0.0
||
periodicBoxVectors
[
2
][
0
]
!=
0.0
||
periodicBoxVectors
[
2
][
1
]
!=
0.0
);
}
}
...
@@ -155,8 +165,8 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
...
@@ -155,8 +165,8 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
ReferenceForce
::
setVariable
(
ReferenceForce
::
getVariablePointer
(
data
.
energyExpression
,
iter
->
first
),
iter
->
second
);
ReferenceForce
::
setVariable
(
ReferenceForce
::
getVariablePointer
(
data
.
energyExpression
,
iter
->
first
),
iter
->
second
);
ReferenceForce
::
setVariable
(
ReferenceForce
::
getVariablePointer
(
data
.
forceExpression
,
iter
->
first
),
iter
->
second
);
ReferenceForce
::
setVariable
(
ReferenceForce
::
getVariablePointer
(
data
.
forceExpression
,
iter
->
first
),
iter
->
second
);
}
}
fvec4
boxSize
(
periodicBox
Size
[
0
],
periodicBox
Size
[
1
],
periodicBox
Size
[
2
],
0
);
fvec4
boxSize
(
periodicBox
Vectors
[
0
]
[
0
],
periodicBox
Vectors
[
1
]
[
1
],
periodicBox
Vectors
[
2
]
[
2
],
0
);
fvec4
invBoxSize
(
(
1
/
periodic
BoxSize
[
0
]
)
,
(
1
/
periodic
BoxSize
[
1
]
)
,
(
1
/
periodic
BoxSize
[
2
]
)
,
0
);
fvec4
invBoxSize
(
recip
BoxSize
[
0
],
recip
BoxSize
[
1
],
recip
BoxSize
[
2
],
0
);
if
(
groupInteractions
.
size
()
>
0
)
{
if
(
groupInteractions
.
size
()
>
0
)
{
// The user has specified interaction groups, so compute only the requested interactions.
// The user has specified interaction groups, so compute only the requested interactions.
...
@@ -266,8 +276,15 @@ void CpuCustomNonbondedForce::calculateOneIxn(int ii, int jj, ThreadData& data,
...
@@ -266,8 +276,15 @@ void CpuCustomNonbondedForce::calculateOneIxn(int ii, int jj, ThreadData& data,
void
CpuCustomNonbondedForce
::
getDeltaR
(
const
fvec4
&
posI
,
const
fvec4
&
posJ
,
fvec4
&
deltaR
,
float
&
r2
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
{
void
CpuCustomNonbondedForce
::
getDeltaR
(
const
fvec4
&
posI
,
const
fvec4
&
posJ
,
fvec4
&
deltaR
,
float
&
r2
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
const
{
deltaR
=
posJ
-
posI
;
deltaR
=
posJ
-
posI
;
if
(
periodic
)
{
if
(
periodic
)
{
fvec4
base
=
round
(
deltaR
*
invBoxSize
)
*
boxSize
;
if
(
triclinic
)
{
deltaR
=
deltaR
-
base
;
deltaR
-=
periodicBoxVec4
[
2
]
*
floorf
(
deltaR
[
2
]
*
recipBoxSize
[
2
]
+
0.5
f
);
deltaR
-=
periodicBoxVec4
[
1
]
*
floorf
(
deltaR
[
1
]
*
recipBoxSize
[
1
]
+
0.5
f
);
deltaR
-=
periodicBoxVec4
[
0
]
*
floorf
(
deltaR
[
0
]
*
recipBoxSize
[
0
]
+
0.5
f
);
}
else
{
fvec4
base
=
round
(
deltaR
*
invBoxSize
)
*
boxSize
;
deltaR
=
deltaR
-
base
;
}
}
}
r2
=
dot3
(
deltaR
,
deltaR
);
r2
=
dot3
(
deltaR
,
deltaR
);
}
}
Prev
1
2
3
4
5
…
7
Next
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