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
a783b996
Commit
a783b996
authored
Jan 13, 2017
by
peastman
Browse files
Eliminated RealOpenMM type
parent
9500f3af
Changes
148
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
303 additions
and
313 deletions
+303
-313
docs-source/developerguide/developer.rst
docs-source/developerguide/developer.rst
+0
-10
platforms/cpu/include/CpuBondForce.h
platforms/cpu/include/CpuBondForce.h
+4
-4
platforms/cpu/include/CpuCustomGBForce.h
platforms/cpu/include/CpuCustomGBForce.h
+10
-10
platforms/cpu/include/CpuCustomManyParticleForce.h
platforms/cpu/include/CpuCustomManyParticleForce.h
+8
-8
platforms/cpu/include/CpuCustomNonbondedForce.h
platforms/cpu/include/CpuCustomNonbondedForce.h
+10
-10
platforms/cpu/include/CpuGayBerneForce.h
platforms/cpu/include/CpuGayBerneForce.h
+24
-24
platforms/cpu/include/CpuKernels.h
platforms/cpu/include/CpuKernels.h
+9
-9
platforms/cpu/include/CpuLangevinDynamics.h
platforms/cpu/include/CpuLangevinDynamics.h
+12
-12
platforms/cpu/include/CpuNeighborList.h
platforms/cpu/include/CpuNeighborList.h
+3
-3
platforms/cpu/include/CpuNonbondedForce.h
platforms/cpu/include/CpuNonbondedForce.h
+6
-6
platforms/cpu/include/CpuSETTLE.h
platforms/cpu/include/CpuSETTLE.h
+2
-2
platforms/cpu/src/CpuBondForce.cpp
platforms/cpu/src/CpuBondForce.cpp
+13
-13
platforms/cpu/src/CpuCustomGBForce.cpp
platforms/cpu/src/CpuCustomGBForce.cpp
+9
-9
platforms/cpu/src/CpuCustomManyParticleForce.cpp
platforms/cpu/src/CpuCustomManyParticleForce.cpp
+5
-5
platforms/cpu/src/CpuCustomNonbondedForce.cpp
platforms/cpu/src/CpuCustomNonbondedForce.cpp
+6
-6
platforms/cpu/src/CpuGayBerneForce.cpp
platforms/cpu/src/CpuGayBerneForce.cpp
+68
-68
platforms/cpu/src/CpuKernels.cpp
platforms/cpu/src/CpuKernels.cpp
+88
-88
platforms/cpu/src/CpuLangevinDynamics.cpp
platforms/cpu/src/CpuLangevinDynamics.cpp
+18
-18
platforms/cpu/src/CpuNeighborList.cpp
platforms/cpu/src/CpuNeighborList.cpp
+2
-2
platforms/cpu/src/CpuNonbondedForce.cpp
platforms/cpu/src/CpuNonbondedForce.cpp
+6
-6
No files found.
docs-source/developerguide/developer.rst
View file @
a783b996
...
...
@@ -317,16 +317,6 @@ that is the goal.) When implementing a new feature, it is recommended to create
the reference implementation first, then use that as a model for the versions in
other Platforms.
The reference Platform represents all floating point numbers with the type
RealOpenMM, which is defined in SimTKOpenMMRealType.h. This allows the entire
platform to be compiled in either single or double precision. By default it is
double precision, but it can be changed by modifying one flag at the top of that
file. The same file also defines lots of numerical constants and mathematical
functions, so the correct precision version will always be used. Vector
quantities (positions, velocities, etc.) are represented by RealVec objects.
This class is identical to Vec3, except that its components are of type
RealOpenMM instead of double.
When using the reference Platform, the “platform-specific data” stored in
ContextImpl is of type ReferencePlatform::PlatformData, which is declared in
ReferencePlatform.h. Several of the fields in this class are declared as void*
...
...
platforms/cpu/include/CpuBondForce.h
View file @
a783b996
...
...
@@ -55,13 +55,13 @@ public:
/**
* Compute the forces from all bonds.
*/
void
calculateForce
(
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
void
calculateForce
(
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
/**
* This routine contains the code executed by each thread.
*/
void
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
void
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
private:
bool
canAssignBond
(
int
bond
,
int
thread
,
std
::
vector
<
int
>&
atomThread
);
void
assignBond
(
int
bond
,
int
thread
,
std
::
vector
<
int
>&
atomThread
,
std
::
vector
<
int
>&
bondThread
,
std
::
vector
<
std
::
set
<
int
>
>&
atomBonds
,
std
::
list
<
int
>&
candidateBonds
);
...
...
platforms/cpu/include/CpuCustomGBForce.h
View file @
a783b996
...
...
@@ -60,7 +60,7 @@ private:
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
float
*
posq
;
RealOpenMM
**
atomParameters
;
double
**
atomParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
bool
includeForce
,
includeEnergy
;
...
...
@@ -82,7 +82,7 @@ private:
* @param useExclusions specifies whether to use exclusions
*/
void
calculateParticlePairValue
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
calculateParticlePairValue
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
double
**
atomParameters
,
bool
useExclusions
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
...
...
@@ -96,7 +96,7 @@ private:
* @param atomParameters atomParameters[atomIndex][paramterIndex]
*/
void
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
double
**
atomParameters
,
std
::
vector
<
float
>&
valueArray
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
...
...
@@ -111,7 +111,7 @@ private:
* @param totalEnergy the energy contribution is added to this
*/
void
calculateSingleParticleEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
float
*
forces
,
double
&
totalEnergy
);
void
calculateSingleParticleEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
double
**
atomParameters
,
float
*
forces
,
double
&
totalEnergy
);
/**
* Calculate an energy term that is based on particle pairs
...
...
@@ -126,7 +126,7 @@ private:
* @param totalEnergy the energy contribution is added to this
*/
void
calculateParticlePairEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
calculateParticlePairEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
double
**
atomParameters
,
bool
useExclusions
,
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
...
...
@@ -142,7 +142,7 @@ private:
* @param totalEnergy the energy contribution is added to this
*/
void
calculateOnePairEnergyTerm
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
calculateOnePairEnergyTerm
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
double
**
atomParameters
,
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
...
...
@@ -155,7 +155,7 @@ private:
* @param forces forces on atoms are added to this
*/
void
calculateChainRuleForces
(
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
calculateChainRuleForces
(
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
double
**
atomParameters
,
float
*
forces
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
...
...
@@ -170,7 +170,7 @@ private:
* @param isExcluded specifies whether this is an excluded pair
*/
void
calculateOnePairChainRule
(
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
calculateOnePairChainRule
(
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
double
**
atomParameters
,
float
*
forces
,
bool
isExcluded
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
...
...
@@ -218,7 +218,7 @@ public:
* @param boxSize the X, Y, and Z widths of the periodic box
*/
void
setPeriodic
(
Real
Vec
&
boxSize
);
void
setPeriodic
(
Vec
3
&
boxSize
);
/**
* Calculate custom GB ixn
...
...
@@ -232,7 +232,7 @@ public:
* @param energyParamDerivs derivatives of the energy with respect to global parameters
*/
void
calculateIxn
(
int
numberOfAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
void
calculateIxn
(
int
numberOfAtoms
,
float
*
posq
,
double
**
atomParameters
,
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
);
};
...
...
platforms/cpu/include/CpuCustomManyParticleForce.h
View file @
a783b996
...
...
@@ -52,9 +52,9 @@ private:
class
ThreadData
;
int
numParticles
,
numParticlesPerSet
,
numPerParticleParameters
,
numTypes
;
bool
useCutoff
,
usePeriodic
,
triclinic
,
centralParticleMode
;
RealOpenMM
cutoffDistance
;
double
cutoffDistance
;
float
recipBoxSize
[
3
];
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
CpuNeighborList
*
neighborList
;
ThreadPool
&
threads
;
...
...
@@ -66,7 +66,7 @@ private:
std
::
vector
<
ThreadData
*>
threadData
;
// The following variables are used to make information accessible to the individual threads.
float
*
posq
;
RealOpenMM
**
particleParameters
;
double
**
particleParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
bool
includeForces
,
includeEnergy
;
...
...
@@ -82,7 +82,7 @@ private:
* interaction for each one.
*/
void
loopOverInteractions
(
std
::
vector
<
int
>&
availableParticles
,
std
::
vector
<
int
>&
particleSet
,
int
loopIndex
,
int
startIndex
,
RealOpenMM
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
double
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**---------------------------------------------------------------------------------------
...
...
@@ -105,7 +105,7 @@ private:
* @param boxSize the size of the periodic box
* @param invBoxSize the inverse size of the periodic box
*/
void
calculateOneIxn
(
std
::
vector
<
int
>&
particleSet
,
RealOpenMM
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
void
calculateOneIxn
(
std
::
vector
<
int
>&
particleSet
,
double
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
* Compute the displacement and squared distance between two points, optionally using
...
...
@@ -133,7 +133,7 @@ public:
*
* @param distance the cutoff distance
*/
void
setUseCutoff
(
RealOpenMM
distance
);
void
setUseCutoff
(
double
distance
);
/**
* Set the force to use periodic boundary conditions. This requires that a cutoff has
...
...
@@ -142,7 +142,7 @@ public:
*
* @param periodicBoxVectors the vectors defining the periodic box
*/
void
setPeriodic
(
Real
Vec
*
periodicBoxVectors
);
void
setPeriodic
(
Vec
3
*
periodicBoxVectors
);
/**
* Calculate the interaction.
...
...
@@ -155,7 +155,7 @@ public:
* @param includeEnergy whether to compute energy
* @param energy the total energy is added to this
*/
void
calculateIxn
(
AlignedArray
<
float
>&
posq
,
RealOpenMM
**
particleParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
void
calculateIxn
(
AlignedArray
<
float
>&
posq
,
double
**
particleParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForces
,
bool
includeEnergy
,
double
&
energy
);
};
...
...
platforms/cpu/include/CpuCustomNonbondedForce.h
View file @
a783b996
...
...
@@ -67,7 +67,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */
void
setUseCutoff
(
RealOpenMM
distance
,
const
CpuNeighborList
&
neighbors
);
void
setUseCutoff
(
double
distance
,
const
CpuNeighborList
&
neighbors
);
/**---------------------------------------------------------------------------------------
...
...
@@ -88,7 +88,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */
void
setUseSwitchingFunction
(
RealOpenMM
distance
);
void
setUseSwitchingFunction
(
double
distance
);
/**---------------------------------------------------------------------------------------
...
...
@@ -100,7 +100,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
Real
Vec
*
periodicBoxVectors
);
void
setPeriodic
(
Vec
3
*
periodicBoxVectors
);
/**---------------------------------------------------------------------------------------
...
...
@@ -118,8 +118,8 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */
void
calculatePairIxn
(
int
numberOfAtoms
,
float
*
posq
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
RealOpenMM
*
fixedParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
void
calculatePairIxn
(
int
numberOfAtoms
,
float
*
posq
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
double
**
atomParameters
,
double
*
fixedParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
);
private:
class
ComputeForceTask
;
...
...
@@ -132,9 +132,9 @@ private:
bool
useInteractionGroups
;
const
CpuNeighborList
*
neighborList
;
float
recipBoxSize
[
3
];
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
RealOpenMM
cutoffDistance
,
switchingDistance
;
double
cutoffDistance
,
switchingDistance
;
ThreadPool
&
threads
;
const
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
ThreadData
*>
threadData
;
...
...
@@ -144,8 +144,8 @@ private:
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
float
*
posq
;
Real
Vec
const
*
atomCoordinates
;
RealOpenMM
**
atomParameters
;
Vec
3
const
*
atomCoordinates
;
double
**
atomParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
bool
includeForce
,
includeEnergy
;
...
...
@@ -186,7 +186,7 @@ public:
CompiledExpressionSet
expressionSet
;
std
::
vector
<
double
>
particleParam
;
double
r
;
std
::
vector
<
RealOpenMM
>
energyParamDerivs
;
std
::
vector
<
double
>
energyParamDerivs
;
};
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuGayBerneForce.h
View file @
a783b996
...
...
@@ -36,7 +36,7 @@
#include "openmm/internal/ThreadPool.h"
#include "CpuNeighborList.h"
#include "CpuPlatform.h"
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <set>
#include <utility>
...
...
@@ -62,7 +62,7 @@ public:
* @param data the platform data for the current context
* @return the energy of the interaction
*/
RealOpenMM
calculateForce
(
const
std
::
vector
<
Real
Vec
>&
positions
,
std
::
vector
<
Real
Vec
>&
forces
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
Real
Vec
*
boxVectors
,
CpuPlatform
::
PlatformData
&
data
);
double
calculateForce
(
const
std
::
vector
<
Vec
3
>&
positions
,
std
::
vector
<
Vec
3
>&
forces
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
Vec
3
*
boxVectors
,
CpuPlatform
::
PlatformData
&
data
);
/**
* This routine contains the code executed by each thread.
...
...
@@ -82,43 +82,43 @@ private:
std
::
set
<
std
::
pair
<
int
,
int
>
>
exclusions
;
std
::
vector
<
std
::
set
<
int
>
>
particleExclusions
;
GayBerneForce
::
NonbondedMethod
nonbondedMethod
;
RealOpenMM
cutoffDistance
,
switchingDistance
;
double
cutoffDistance
,
switchingDistance
;
bool
useSwitchingFunction
;
std
::
vector
<
RealOpenMM
>
s
;
std
::
vector
<
double
>
s
;
std
::
vector
<
Matrix
>
A
,
B
,
G
;
std
::
vector
<
double
>
threadEnergy
;
std
::
vector
<
std
::
vector
<
Real
Vec
>
>
threadTorque
;
std
::
vector
<
std
::
vector
<
Vec
3
>
>
threadTorque
;
// The following variables are used to make information accessible to the individual threads.
Real
Vec
const
*
positions
;
Vec
3
const
*
positions
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
Real
Vec
*
boxVectors
;
Vec
3
*
boxVectors
;
void
*
atomicCounter
;
void
computeEllipsoidFrames
(
const
std
::
vector
<
Real
Vec
>&
positions
);
void
computeEllipsoidFrames
(
const
std
::
vector
<
Vec
3
>&
positions
);
void
applyTorques
(
const
std
::
vector
<
Real
Vec
>&
positions
,
std
::
vector
<
Real
Vec
>&
forces
);
void
applyTorques
(
const
std
::
vector
<
Vec
3
>&
positions
,
std
::
vector
<
Vec
3
>&
forces
);
RealOpenMM
computeOneInteraction
(
int
particle1
,
int
particle2
,
RealOpenMM
sigma
,
RealOpenMM
epsilon
,
const
Real
Vec
*
positions
,
float
*
forces
,
std
::
vector
<
Real
Vec
>&
torques
,
const
Real
Vec
*
boxVectors
);
double
computeOneInteraction
(
int
particle1
,
int
particle2
,
double
sigma
,
double
epsilon
,
const
Vec
3
*
positions
,
float
*
forces
,
std
::
vector
<
Vec
3
>&
torques
,
const
Vec
3
*
boxVectors
);
};
struct
CpuGayBerneForce
::
ParticleInfo
{
int
xparticle
,
yparticle
;
RealOpenMM
sigmaOver2
,
sqrtEpsilon
,
rx
,
ry
,
rz
,
ex
,
ey
,
ez
;
double
sigmaOver2
,
sqrtEpsilon
,
rx
,
ry
,
rz
,
ex
,
ey
,
ez
;
bool
isPointParticle
;
};
struct
CpuGayBerneForce
::
ExceptionInfo
{
int
particle1
,
particle2
;
RealOpenMM
sigma
,
epsilon
;
double
sigma
,
epsilon
;
};
struct
CpuGayBerneForce
::
Matrix
{
RealOpenMM
v
[
3
][
3
];
Real
Vec
operator
*
(
const
Real
Vec
&
r
)
{
return
Real
Vec
(
v
[
0
][
0
]
*
r
[
0
]
+
v
[
0
][
1
]
*
r
[
1
]
+
v
[
0
][
2
]
*
r
[
2
],
v
[
1
][
0
]
*
r
[
0
]
+
v
[
1
][
1
]
*
r
[
1
]
+
v
[
1
][
2
]
*
r
[
2
],
v
[
2
][
0
]
*
r
[
0
]
+
v
[
2
][
1
]
*
r
[
1
]
+
v
[
2
][
2
]
*
r
[
2
]);
double
v
[
3
][
3
];
Vec
3
operator
*
(
const
Vec
3
&
r
)
{
return
Vec
3
(
v
[
0
][
0
]
*
r
[
0
]
+
v
[
0
][
1
]
*
r
[
1
]
+
v
[
0
][
2
]
*
r
[
2
],
v
[
1
][
0
]
*
r
[
0
]
+
v
[
1
][
1
]
*
r
[
1
]
+
v
[
1
][
2
]
*
r
[
2
],
v
[
2
][
0
]
*
r
[
0
]
+
v
[
2
][
1
]
*
r
[
1
]
+
v
[
2
][
2
]
*
r
[
2
]);
}
Matrix
operator
+
(
const
Matrix
&
m
)
{
...
...
@@ -129,13 +129,13 @@ struct CpuGayBerneForce::Matrix {
return
result
;
}
RealOpenMM
determinant
()
{
double
determinant
()
{
return
(
v
[
0
][
0
]
*
v
[
1
][
1
]
*
v
[
2
][
2
]
+
v
[
0
][
1
]
*
v
[
1
][
2
]
*
v
[
2
][
0
]
+
v
[
0
][
2
]
*
v
[
1
][
0
]
*
v
[
2
][
1
]
-
v
[
0
][
0
]
*
v
[
1
][
2
]
*
v
[
2
][
1
]
-
v
[
0
][
1
]
*
v
[
1
][
0
]
*
v
[
2
][
2
]
-
v
[
0
][
2
]
*
v
[
1
][
1
]
*
v
[
2
][
0
]);
}
Matrix
inverse
()
{
RealOpenMM
invDet
=
1
/
determinant
();
double
invDet
=
1
/
determinant
();
Matrix
result
;
result
.
v
[
0
][
0
]
=
invDet
*
(
v
[
1
][
1
]
*
v
[
2
][
2
]
-
v
[
1
][
2
]
*
v
[
2
][
1
]);
result
.
v
[
1
][
0
]
=
-
invDet
*
(
v
[
1
][
0
]
*
v
[
2
][
2
]
-
v
[
1
][
2
]
*
v
[
2
][
0
]);
...
...
@@ -150,10 +150,10 @@ struct CpuGayBerneForce::Matrix {
}
};
static
Real
Vec
operator
*
(
const
Real
Vec
&
r
,
CpuGayBerneForce
::
Matrix
&
m
)
{
return
Real
Vec
(
m
.
v
[
0
][
0
]
*
r
[
0
]
+
m
.
v
[
1
][
0
]
*
r
[
1
]
+
m
.
v
[
2
][
0
]
*
r
[
2
],
m
.
v
[
0
][
1
]
*
r
[
0
]
+
m
.
v
[
1
][
1
]
*
r
[
1
]
+
m
.
v
[
2
][
1
]
*
r
[
2
],
m
.
v
[
0
][
2
]
*
r
[
0
]
+
m
.
v
[
1
][
2
]
*
r
[
1
]
+
m
.
v
[
2
][
2
]
*
r
[
2
]);
static
Vec
3
operator
*
(
const
Vec
3
&
r
,
CpuGayBerneForce
::
Matrix
&
m
)
{
return
Vec
3
(
m
.
v
[
0
][
0
]
*
r
[
0
]
+
m
.
v
[
1
][
0
]
*
r
[
1
]
+
m
.
v
[
2
][
0
]
*
r
[
2
],
m
.
v
[
0
][
1
]
*
r
[
0
]
+
m
.
v
[
1
][
1
]
*
r
[
1
]
+
m
.
v
[
2
][
1
]
*
r
[
2
],
m
.
v
[
0
][
2
]
*
r
[
0
]
+
m
.
v
[
1
][
2
]
*
r
[
1
]
+
m
.
v
[
2
][
2
]
*
r
[
2
]);
}
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuKernels.h
View file @
a783b996
...
...
@@ -91,7 +91,7 @@ public:
private:
CpuPlatform
::
PlatformData
&
data
;
Kernel
referenceKernel
;
std
::
vector
<
Real
Vec
>
lastPositions
;
std
::
vector
<
Vec
3
>
lastPositions
;
};
/**
...
...
@@ -130,7 +130,7 @@ private:
CpuPlatform
::
PlatformData
&
data
;
int
numAngles
;
int
**
angleIndexArray
;
RealOpenMM
**
angleParamArray
;
double
**
angleParamArray
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
};
...
...
@@ -171,7 +171,7 @@ private:
CpuPlatform
::
PlatformData
&
data
;
int
numTorsions
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
double
**
torsionParamArray
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
};
...
...
@@ -212,7 +212,7 @@ private:
CpuPlatform
::
PlatformData
&
data
;
int
numTorsions
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
double
**
torsionParamArray
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
};
...
...
@@ -395,8 +395,8 @@ private:
CpuPlatform
::
PlatformData
&
data
;
int
numParticles
;
bool
isPeriodic
;
RealOpenMM
**
particleParamArray
;
RealOpenMM
nonbondedCutoff
;
double
**
particleParamArray
;
double
nonbondedCutoff
;
CpuCustomGBForce
*
ixn
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
string
>
particleParameterNames
,
globalParameterNames
,
energyParamDerivNames
,
valueNames
;
...
...
@@ -440,8 +440,8 @@ public:
private:
CpuPlatform
::
PlatformData
&
data
;
int
numParticles
;
RealOpenMM
cutoffDistance
;
RealOpenMM
**
particleParamArray
;
double
cutoffDistance
;
double
**
particleParamArray
;
CpuCustomManyParticleForce
*
ixn
;
std
::
vector
<
std
::
string
>
globalParameterNames
;
NonbondedMethod
nonbondedMethod
;
...
...
@@ -516,7 +516,7 @@ public:
private:
CpuPlatform
::
PlatformData
&
data
;
CpuLangevinDynamics
*
dynamics
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
double
>
masses
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
};
...
...
platforms/cpu/include/CpuLangevinDynamics.h
View file @
a783b996
...
...
@@ -48,7 +48,7 @@ public:
* @param threads thread pool for parallelizing computation
* @param random random number generator
*/
CpuLangevinDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
friction
,
RealOpenMM
temperature
,
OpenMM
::
ThreadPool
&
threads
,
OpenMM
::
CpuRandom
&
random
);
CpuLangevinDynamics
(
int
numberOfAtoms
,
double
deltaT
,
double
friction
,
double
temperature
,
OpenMM
::
ThreadPool
&
threads
,
OpenMM
::
CpuRandom
&
random
);
/**
* Destructor.
...
...
@@ -65,8 +65,8 @@ public:
* @param inverseMasses inverse atom masses
* @param xPrime xPrime
*/
void
updatePart1
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
velocities
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
xPrime
);
void
updatePart1
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
velocities
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
std
::
vector
<
double
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Vec
3
>&
xPrime
);
/**
* Second update step.
...
...
@@ -78,8 +78,8 @@ public:
* @param inverseMasses inverse atom masses
* @param xPrime xPrime
*/
void
updatePart2
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
velocities
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
xPrime
);
void
updatePart2
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
velocities
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
std
::
vector
<
double
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Vec
3
>&
xPrime
);
/**
* Third update
...
...
@@ -89,8 +89,8 @@ public:
* @param velocities velocities
* @param inverseMasses inverse atom masses
*/
void
updatePart3
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
xPrime
);
void
updatePart3
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
velocities
,
std
::
vector
<
double
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Vec
3
>&
xPrime
);
private:
void
threadUpdate1
(
int
threadIndex
);
...
...
@@ -101,11 +101,11 @@ private:
std
::
vector
<
OpenMM_SFMT
::
SFMT
>
threadRandom
;
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
OpenMM
::
Real
Vec
*
atomCoordinates
;
OpenMM
::
Real
Vec
*
velocities
;
OpenMM
::
Real
Vec
*
forces
;
RealOpenMM
*
inverseMasses
;
OpenMM
::
Real
Vec
*
xPrime
;
OpenMM
::
Vec
3
*
atomCoordinates
;
OpenMM
::
Vec
3
*
velocities
;
OpenMM
::
Vec
3
*
forces
;
double
*
inverseMasses
;
OpenMM
::
Vec
3
*
xPrime
;
};
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuNeighborList.h
View file @
a783b996
...
...
@@ -33,7 +33,7 @@
* -------------------------------------------------------------------------- */
#include "AlignedArray.h"
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include "windowsExportCpu.h"
#include "openmm/internal/gmx_atomic.h"
#include "openmm/internal/ThreadPool.h"
...
...
@@ -49,7 +49,7 @@ public:
class
Voxels
;
CpuNeighborList
(
int
blockSize
);
void
computeNeighborList
(
int
numAtoms
,
const
AlignedArray
<
float
>&
atomLocations
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
const
Real
Vec
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
const
Vec
3
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
int
getNumBlocks
()
const
;
int
getBlockSize
()
const
;
const
std
::
vector
<
int
>&
getSortedAtoms
()
const
;
...
...
@@ -72,7 +72,7 @@ private:
Voxels
*
voxels
;
const
std
::
vector
<
std
::
set
<
int
>
>*
exclusions
;
const
float
*
atomLocations
;
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
int
numAtoms
;
bool
usePeriodic
;
float
maxDistance
;
...
...
platforms/cpu/include/CpuNonbondedForce.h
View file @
a783b996
...
...
@@ -87,7 +87,7 @@ class CpuNonbondedForce {
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
Real
Vec
*
periodicBoxVectors
);
void
setPeriodic
(
Vec
3
*
periodicBoxVectors
);
/**---------------------------------------------------------------------------------------
...
...
@@ -129,9 +129,9 @@ class CpuNonbondedForce {
--------------------------------------------------------------------------------------- */
void
calculateReciprocalIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
std
::
vector
<
Real
Vec
>&
atomCoordinates
,
void
calculateReciprocalIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
std
::
vector
<
Vec
3
>&
atomCoordinates
,
const
std
::
vector
<
std
::
pair
<
float
,
float
>
>&
atomParameters
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
std
::
vector
<
Real
Vec
>&
forces
,
double
*
totalEnergy
)
const
;
std
::
vector
<
Vec
3
>&
forces
,
double
*
totalEnergy
)
const
;
/**---------------------------------------------------------------------------------------
...
...
@@ -149,7 +149,7 @@ class CpuNonbondedForce {
--------------------------------------------------------------------------------------- */
void
calculateDirectIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
std
::
vector
<
Real
Vec
>&
atomCoordinates
,
const
std
::
vector
<
std
::
pair
<
float
,
float
>
>&
atomParameters
,
void
calculateDirectIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
std
::
vector
<
Vec
3
>&
atomCoordinates
,
const
std
::
vector
<
std
::
pair
<
float
,
float
>
>&
atomParameters
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
double
*
totalEnergy
,
ThreadPool
&
threads
);
/**
...
...
@@ -167,7 +167,7 @@ protected:
bool
tableIsValid
;
const
CpuNeighborList
*
neighborList
;
float
recipBoxSize
[
3
];
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
float
cutoffDistance
,
switchingDistance
;
float
krf
,
crf
;
...
...
@@ -180,7 +180,7 @@ protected:
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
float
*
posq
;
Real
Vec
const
*
atomCoordinates
;
Vec
3
const
*
atomCoordinates
;
std
::
pair
<
float
,
float
>
const
*
atomParameters
;
std
::
set
<
int
>
const
*
exclusions
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
...
...
platforms/cpu/include/CpuSETTLE.h
View file @
a783b996
...
...
@@ -58,7 +58,7 @@ public:
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
apply
(
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
void
apply
(
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinatesP
,
std
::
vector
<
double
>&
inverseMasses
,
double
tolerance
);
/**
* Apply the constraint algorithm to velocities.
...
...
@@ -68,7 +68,7 @@ public:
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
velocities
,
std
::
vector
<
double
>&
inverseMasses
,
double
tolerance
);
private:
std
::
vector
<
ReferenceSETTLEAlgorithm
*>
threadSettle
;
ThreadPool
&
threads
;
...
...
platforms/cpu/src/CpuBondForce.cpp
View file @
a783b996
...
...
@@ -37,20 +37,20 @@ using namespace std;
class
CpuBondForce
::
ComputeForceTask
:
public
ThreadPool
::
Task
{
public:
ComputeForceTask
(
CpuBondForce
&
owner
,
vector
<
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
vector
<
Real
Vec
>&
forces
,
vector
<
RealOpenMM
>&
threadEnergy
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
:
owner
(
owner
),
atomCoordinates
(
atomCoordinates
),
ComputeForceTask
(
CpuBondForce
&
owner
,
vector
<
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
vector
<
Vec
3
>&
forces
,
vector
<
double
>&
threadEnergy
,
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
:
owner
(
owner
),
atomCoordinates
(
atomCoordinates
),
parameters
(
parameters
),
forces
(
forces
),
threadEnergy
(
threadEnergy
),
totalEnergy
(
totalEnergy
),
referenceBondIxn
(
referenceBondIxn
)
{
}
void
execute
(
ThreadPool
&
threads
,
int
threadIndex
)
{
RealOpenMM
*
energy
=
(
totalEnergy
==
NULL
?
NULL
:
&
threadEnergy
[
threadIndex
]);
double
*
energy
=
(
totalEnergy
==
NULL
?
NULL
:
&
threadEnergy
[
threadIndex
]);
owner
.
threadComputeForce
(
threads
,
threadIndex
,
atomCoordinates
,
parameters
,
forces
,
energy
,
referenceBondIxn
);
}
CpuBondForce
&
owner
;
vector
<
Real
Vec
>&
atomCoordinates
;
RealOpenMM
**
parameters
;
vector
<
Real
Vec
>&
forces
;
vector
<
RealOpenMM
>&
threadEnergy
;
RealOpenMM
*
totalEnergy
;
vector
<
Vec
3
>&
atomCoordinates
;
double
**
parameters
;
vector
<
Vec
3
>&
forces
;
vector
<
double
>&
threadEnergy
;
double
*
totalEnergy
;
ReferenceBondIxn
&
referenceBondIxn
;
};
...
...
@@ -183,11 +183,11 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec
}
}
void
CpuBondForce
::
calculateForce
(
vector
<
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
vector
<
Real
Vec
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
void
CpuBondForce
::
calculateForce
(
vector
<
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
vector
<
Vec
3
>&
forces
,
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
// Have the worker threads compute their forces.
vector
<
RealOpenMM
>
threadEnergy
(
threads
->
getNumThreads
(),
0
);
vector
<
double
>
threadEnergy
(
threads
->
getNumThreads
(),
0
);
ComputeForceTask
task
(
*
this
,
atomCoordinates
,
parameters
,
forces
,
threadEnergy
,
totalEnergy
,
referenceBondIxn
);
threads
->
execute
(
task
);
threads
->
waitForThreads
();
...
...
@@ -206,8 +206,8 @@ void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM**
*
totalEnergy
+=
threadEnergy
[
i
];
}
void
CpuBondForce
::
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
vector
<
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
vector
<
Real
Vec
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
void
CpuBondForce
::
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
vector
<
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
vector
<
Vec
3
>&
forces
,
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
vector
<
int
>&
bonds
=
threadBonds
[
threadIndex
];
int
numBonds
=
bonds
.
size
();
for
(
int
i
=
0
;
i
<
numBonds
;
i
++
)
{
...
...
platforms/cpu/src/CpuCustomGBForce.cpp
View file @
a783b996
...
...
@@ -176,7 +176,7 @@ void CpuCustomGBForce::setUseCutoff(float distance, const CpuNeighborList& neigh
neighborList
=
&
neighbors
;
}
void
CpuCustomGBForce
::
setPeriodic
(
Real
Vec
&
boxSize
)
{
void
CpuCustomGBForce
::
setPeriodic
(
Vec
3
&
boxSize
)
{
if
(
cutoff
)
{
assert
(
boxSize
[
0
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
1
]
>=
2.0
*
cutoffDistance
);
...
...
@@ -188,7 +188,7 @@ void CpuCustomGBForce::setPeriodic(RealVec& boxSize) {
periodicBoxSize
[
2
]
=
boxSize
[
2
];
}
void
CpuCustomGBForce
::
calculateIxn
(
int
numberOfAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
CpuCustomGBForce
::
calculateIxn
(
int
numberOfAtoms
,
float
*
posq
,
double
**
atomParameters
,
map
<
string
,
double
>&
globalParameters
,
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
)
{
// Record the parameters for the threads.
...
...
@@ -362,7 +362,7 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
calculateChainRuleForces
(
data
,
numberOfAtoms
,
posq
,
atomParameters
,
forces
,
boxSize
,
invBoxSize
);
}
void
CpuCustomGBForce
::
calculateParticlePairValue
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
CpuCustomGBForce
::
calculateParticlePairValue
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
double
**
atomParameters
,
bool
useExclusions
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
values
[
index
][
i
]
=
0.0
f
;
...
...
@@ -409,7 +409,7 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i
}
}
void
CpuCustomGBForce
::
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
CpuCustomGBForce
::
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
double
**
atomParameters
,
vector
<
float
>&
valueArray
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
fvec4
deltaR
;
fvec4
pos1
(
posq
+
4
*
atom1
);
...
...
@@ -436,7 +436,7 @@ void CpuCustomGBForce::calculateOnePairValue(int index, int atom1, int atom2, Th
}
void
CpuCustomGBForce
::
calculateSingleParticleEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
float
*
forces
,
double
&
totalEnergy
)
{
double
**
atomParameters
,
float
*
forces
,
double
&
totalEnergy
)
{
for
(
int
i
=
data
.
firstAtom
;
i
<
data
.
lastAtom
;
i
++
)
{
data
.
x
=
posq
[
4
*
i
];
data
.
y
=
posq
[
4
*
i
+
1
];
...
...
@@ -460,7 +460,7 @@ void CpuCustomGBForce::calculateSingleParticleEnergyTerm(int index, ThreadData&
}
}
void
CpuCustomGBForce
::
calculateParticlePairEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
CpuCustomGBForce
::
calculateParticlePairEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
double
**
atomParameters
,
bool
useExclusions
,
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
if
(
cutoff
)
{
// Loop over all pairs in the neighbor list.
...
...
@@ -502,7 +502,7 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da
}
}
void
CpuCustomGBForce
::
calculateOnePairEnergyTerm
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
CpuCustomGBForce
::
calculateOnePairEnergyTerm
(
int
index
,
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
double
**
atomParameters
,
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
// Compute the displacement.
...
...
@@ -547,7 +547,7 @@ void CpuCustomGBForce::calculateOnePairEnergyTerm(int index, int atom1, int atom
data
.
energyParamDerivs
[
i
]
+=
data
.
energyParamDerivExpressions
[
index
][
i
].
evaluate
();
}
void
CpuCustomGBForce
::
calculateChainRuleForces
(
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
CpuCustomGBForce
::
calculateChainRuleForces
(
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
double
**
atomParameters
,
float
*
forces
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
if
(
cutoff
)
{
// Loop over all pairs in the neighbor list.
...
...
@@ -624,7 +624,7 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms,
data
.
energyParamDerivs
[
k
]
+=
dEdV
[
j
][
i
]
*
dValuedParam
[
j
][
k
][
i
];
}
void
CpuCustomGBForce
::
calculateOnePairChainRule
(
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
RealOpenMM
**
atomParameters
,
void
CpuCustomGBForce
::
calculateOnePairChainRule
(
int
atom1
,
int
atom2
,
ThreadData
&
data
,
float
*
posq
,
double
**
atomParameters
,
float
*
forces
,
bool
isExcluded
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
// Compute the displacement.
...
...
platforms/cpu/src/CpuCustomManyParticleForce.cpp
View file @
a783b996
...
...
@@ -98,7 +98,7 @@ CpuCustomManyParticleForce::~CpuCustomManyParticleForce() {
delete
threadData
[
i
];
}
void
CpuCustomManyParticleForce
::
calculateIxn
(
AlignedArray
<
float
>&
posq
,
RealOpenMM
**
particleParameters
,
void
CpuCustomManyParticleForce
::
calculateIxn
(
AlignedArray
<
float
>&
posq
,
double
**
particleParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForces
,
bool
includeEnergy
,
double
&
energy
)
{
// Record the parameters for the threads.
...
...
@@ -191,14 +191,14 @@ void CpuCustomManyParticleForce::threadComputeForce(ThreadPool& threads, int thr
}
}
void
CpuCustomManyParticleForce
::
setUseCutoff
(
RealOpenMM
distance
)
{
void
CpuCustomManyParticleForce
::
setUseCutoff
(
double
distance
)
{
useCutoff
=
true
;
cutoffDistance
=
distance
;
if
(
neighborList
==
NULL
)
neighborList
=
new
CpuNeighborList
(
4
);
}
void
CpuCustomManyParticleForce
::
setPeriodic
(
Real
Vec
*
periodicBoxVectors
)
{
void
CpuCustomManyParticleForce
::
setPeriodic
(
Vec
3
*
periodicBoxVectors
)
{
assert
(
useCutoff
);
assert
(
periodicBoxVectors
[
0
][
0
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
1
][
1
]
>=
2.0
*
cutoffDistance
);
...
...
@@ -220,7 +220,7 @@ void CpuCustomManyParticleForce::setPeriodic(RealVec* periodicBoxVectors) {
}
void
CpuCustomManyParticleForce
::
loopOverInteractions
(
vector
<
int
>&
availableParticles
,
vector
<
int
>&
particleSet
,
int
loopIndex
,
int
startIndex
,
RealOpenMM
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
double
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
int
numParticles
=
availableParticles
.
size
();
double
cutoff2
=
cutoffDistance
*
cutoffDistance
;
int
checkRange
=
(
centralParticleMode
?
1
:
loopIndex
);
...
...
@@ -254,7 +254,7 @@ void CpuCustomManyParticleForce::loopOverInteractions(vector<int>& availablePart
}
}
void
CpuCustomManyParticleForce
::
calculateOneIxn
(
vector
<
int
>&
particleSet
,
RealOpenMM
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
void
CpuCustomManyParticleForce
::
calculateOneIxn
(
vector
<
int
>&
particleSet
,
double
**
particleParameters
,
float
*
forces
,
ThreadData
&
data
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
// Select the ordering to use for the particles.
vector
<
int
>&
permutedParticles
=
data
.
permutedParticles
;
...
...
platforms/cpu/src/CpuCustomNonbondedForce.cpp
View file @
a783b996
...
...
@@ -80,7 +80,7 @@ CpuCustomNonbondedForce::~CpuCustomNonbondedForce() {
delete
threadData
[
i
];
}
void
CpuCustomNonbondedForce
::
setUseCutoff
(
RealOpenMM
distance
,
const
CpuNeighborList
&
neighbors
)
{
void
CpuCustomNonbondedForce
::
setUseCutoff
(
double
distance
,
const
CpuNeighborList
&
neighbors
)
{
cutoff
=
true
;
cutoffDistance
=
distance
;
neighborList
=
&
neighbors
;
...
...
@@ -103,12 +103,12 @@ void CpuCustomNonbondedForce::setInteractionGroups(const vector<pair<set<int>, s
}
}
void
CpuCustomNonbondedForce
::
setUseSwitchingFunction
(
RealOpenMM
distance
)
{
void
CpuCustomNonbondedForce
::
setUseSwitchingFunction
(
double
distance
)
{
useSwitch
=
true
;
switchingDistance
=
distance
;
}
void
CpuCustomNonbondedForce
::
setPeriodic
(
Real
Vec
*
periodicBoxVectors
)
{
void
CpuCustomNonbondedForce
::
setPeriodic
(
Vec
3
*
periodicBoxVectors
)
{
assert
(
cutoff
);
assert
(
periodicBoxVectors
[
0
][
0
]
>=
2.0
*
cutoffDistance
);
assert
(
periodicBoxVectors
[
1
][
1
]
>=
2.0
*
cutoffDistance
);
...
...
@@ -130,9 +130,9 @@ void CpuCustomNonbondedForce::setPeriodic(RealVec* periodicBoxVectors) {
}
void
CpuCustomNonbondedForce
::
calculatePairIxn
(
int
numberOfAtoms
,
float
*
posq
,
vector
<
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
RealOpenMM
*
fixedParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
)
{
void
CpuCustomNonbondedForce
::
calculatePairIxn
(
int
numberOfAtoms
,
float
*
posq
,
vector
<
Vec
3
>&
atomCoordinates
,
double
**
atomParameters
,
double
*
fixedParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
)
{
// Record the parameters for the threads.
this
->
numberOfAtoms
=
numberOfAtoms
;
...
...
platforms/cpu/src/CpuGayBerneForce.cpp
View file @
a783b996
...
...
@@ -111,7 +111,7 @@ const vector<set<int> >& CpuGayBerneForce::getExclusions() const {
return
particleExclusions
;
}
RealOpenMM
CpuGayBerneForce
::
calculateForce
(
const
vector
<
Real
Vec
>&
positions
,
std
::
vector
<
Real
Vec
>&
forces
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
Real
Vec
*
boxVectors
,
CpuPlatform
::
PlatformData
&
data
)
{
double
CpuGayBerneForce
::
calculateForce
(
const
vector
<
Vec
3
>&
positions
,
std
::
vector
<
Vec
3
>&
forces
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
Vec
3
*
boxVectors
,
CpuPlatform
::
PlatformData
&
data
)
{
if
(
nonbondedMethod
==
GayBerneForce
::
CutoffPeriodic
)
{
double
minAllowedSize
=
1.999999
*
cutoffDistance
;
if
(
boxVectors
[
0
][
0
]
<
minAllowedSize
||
boxVectors
[
1
][
1
]
<
minAllowedSize
||
boxVectors
[
2
][
2
]
<
minAllowedSize
)
...
...
@@ -164,10 +164,10 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
int
numThreads
=
threads
.
getNumThreads
();
threadEnergy
[
threadIndex
]
=
0
;
float
*
forces
=
&
(
*
threadForce
)[
threadIndex
][
0
];
vector
<
Real
Vec
>&
torques
=
threadTorque
[
threadIndex
];
vector
<
Vec
3
>&
torques
=
threadTorque
[
threadIndex
];
torques
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
torques
[
i
]
=
Real
Vec
();
torques
[
i
]
=
Vec
3
();
double
energy
=
0.0
;
// Compute this thread's subset of interactions.
...
...
@@ -184,8 +184,8 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
continue
;
if
(
particleExclusions
[
i
].
find
(
j
)
!=
particleExclusions
[
i
].
end
())
continue
;
// This interaction will be handled by an exception.
RealOpenMM
sigma
=
particles
[
i
].
sigmaOver2
+
particles
[
j
].
sigmaOver2
;
RealOpenMM
epsilon
=
particles
[
i
].
sqrtEpsilon
*
particles
[
j
].
sqrtEpsilon
;
double
sigma
=
particles
[
i
].
sigmaOver2
+
particles
[
j
].
sigmaOver2
;
double
epsilon
=
particles
[
i
].
sqrtEpsilon
*
particles
[
j
].
sqrtEpsilon
;
energy
+=
computeOneInteraction
(
i
,
j
,
sigma
,
epsilon
,
positions
,
forces
,
torques
,
boxVectors
);
}
}
...
...
@@ -208,8 +208,8 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
int
second
=
blockAtom
[
k
];
if
(
particles
[
second
].
sqrtEpsilon
==
0.0
f
)
continue
;
RealOpenMM
sigma
=
particles
[
first
].
sigmaOver2
+
particles
[
second
].
sigmaOver2
;
RealOpenMM
epsilon
=
particles
[
first
].
sqrtEpsilon
*
particles
[
second
].
sqrtEpsilon
;
double
sigma
=
particles
[
first
].
sigmaOver2
+
particles
[
second
].
sigmaOver2
;
double
epsilon
=
particles
[
first
].
sqrtEpsilon
*
particles
[
second
].
sqrtEpsilon
;
energy
+=
computeOneInteraction
(
first
,
second
,
sigma
,
epsilon
,
positions
,
forces
,
torques
,
boxVectors
);
}
}
...
...
@@ -235,39 +235,39 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
threadEnergy
[
threadIndex
]
=
energy
;
}
void
CpuGayBerneForce
::
computeEllipsoidFrames
(
const
vector
<
Real
Vec
>&
positions
)
{
void
CpuGayBerneForce
::
computeEllipsoidFrames
(
const
vector
<
Vec
3
>&
positions
)
{
int
numParticles
=
particles
.
size
();
for
(
int
particle
=
0
;
particle
<
numParticles
;
particle
++
)
{
ParticleInfo
&
p
=
particles
[
particle
];
// Compute the local coordinate system of the ellipsoid;
Real
Vec
xdir
,
ydir
,
zdir
;
Vec
3
xdir
,
ydir
,
zdir
;
if
(
p
.
xparticle
==
-
1
)
{
xdir
=
Real
Vec
(
1
,
0
,
0
);
ydir
=
Real
Vec
(
0
,
1
,
0
);
xdir
=
Vec
3
(
1
,
0
,
0
);
ydir
=
Vec
3
(
0
,
1
,
0
);
}
else
{
xdir
=
positions
[
particle
]
-
positions
[
p
.
xparticle
];
xdir
/=
SQRT
(
xdir
.
dot
(
xdir
));
xdir
/=
sqrt
(
xdir
.
dot
(
xdir
));
if
(
p
.
yparticle
==
-
1
)
{
if
(
xdir
[
1
]
>
-
0.5
&&
xdir
[
1
]
<
0.5
)
ydir
=
Real
Vec
(
0
,
1
,
0
);
ydir
=
Vec
3
(
0
,
1
,
0
);
else
ydir
=
Real
Vec
(
1
,
0
,
0
);
ydir
=
Vec
3
(
1
,
0
,
0
);
}
else
ydir
=
positions
[
particle
]
-
positions
[
p
.
yparticle
];
ydir
-=
xdir
*
(
xdir
.
dot
(
ydir
));
ydir
/=
SQRT
(
ydir
.
dot
(
ydir
));
ydir
/=
sqrt
(
ydir
.
dot
(
ydir
));
}
zdir
=
xdir
.
cross
(
ydir
);
// Compute matrices we will need later.
RealOpenMM
(
&
a
)[
3
][
3
]
=
A
[
particle
].
v
;
RealOpenMM
(
&
b
)[
3
][
3
]
=
B
[
particle
].
v
;
RealOpenMM
(
&
g
)[
3
][
3
]
=
G
[
particle
].
v
;
double
(
&
a
)[
3
][
3
]
=
A
[
particle
].
v
;
double
(
&
b
)[
3
][
3
]
=
B
[
particle
].
v
;
double
(
&
g
)[
3
][
3
]
=
G
[
particle
].
v
;
a
[
0
][
0
]
=
xdir
[
0
];
a
[
0
][
1
]
=
xdir
[
1
];
a
[
0
][
2
]
=
xdir
[
2
];
...
...
@@ -277,8 +277,8 @@ void CpuGayBerneForce::computeEllipsoidFrames(const vector<RealVec>& positions)
a
[
2
][
0
]
=
zdir
[
0
];
a
[
2
][
1
]
=
zdir
[
1
];
a
[
2
][
2
]
=
zdir
[
2
];
Real
Vec
r2
(
p
.
rx
*
p
.
rx
,
p
.
ry
*
p
.
ry
,
p
.
rz
*
p
.
rz
);
Real
Vec
e2
(
1
/
sqrt
(
p
.
ex
),
1
/
sqrt
(
p
.
ey
),
1
/
sqrt
(
p
.
ez
));
Vec
3
r2
(
p
.
rx
*
p
.
rx
,
p
.
ry
*
p
.
ry
,
p
.
rz
*
p
.
rz
);
Vec
3
e2
(
1
/
sqrt
(
p
.
ex
),
1
/
sqrt
(
p
.
ey
),
1
/
sqrt
(
p
.
ez
));
for
(
int
i
=
0
;
i
<
3
;
i
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
b
[
i
][
j
]
=
0
;
...
...
@@ -291,33 +291,33 @@ void CpuGayBerneForce::computeEllipsoidFrames(const vector<RealVec>& positions)
}
}
void
CpuGayBerneForce
::
applyTorques
(
const
vector
<
Real
Vec
>&
positions
,
vector
<
Real
Vec
>&
forces
)
{
void
CpuGayBerneForce
::
applyTorques
(
const
vector
<
Vec
3
>&
positions
,
vector
<
Vec
3
>&
forces
)
{
int
numParticles
=
particles
.
size
();
int
numThreads
=
threadTorque
.
size
();
for
(
int
particle
=
0
;
particle
<
numParticles
;
particle
++
)
{
ParticleInfo
&
p
=
particles
[
particle
];
Real
Vec
pos
=
positions
[
particle
];
Vec
3
pos
=
positions
[
particle
];
if
(
p
.
xparticle
!=
-
1
)
{
// Add up the torques from the individual threads.
Real
Vec
torque
;
Vec
3
torque
;
for
(
int
i
=
0
;
i
<
numThreads
;
i
++
)
torque
+=
threadTorque
[
i
][
particle
];
// Apply a force to the x particle.
Real
Vec
dx
=
positions
[
p
.
xparticle
]
-
pos
;
Vec
3
dx
=
positions
[
p
.
xparticle
]
-
pos
;
double
dx2
=
dx
.
dot
(
dx
);
Real
Vec
f
=
torque
.
cross
(
dx
)
/
dx2
;
Vec
3
f
=
torque
.
cross
(
dx
)
/
dx2
;
forces
[
p
.
xparticle
]
+=
f
;
forces
[
particle
]
-=
f
;
if
(
p
.
yparticle
!=
-
1
)
{
// Apply a force to the y particle. This is based on the component of the torque
// that was not already applied to the x particle.
Real
Vec
dy
=
positions
[
p
.
yparticle
]
-
pos
;
Vec
3
dy
=
positions
[
p
.
yparticle
]
-
pos
;
double
dy2
=
dy
.
dot
(
dy
);
Real
Vec
torque2
=
dx
*
(
torque
.
dot
(
dx
)
/
dx2
);
Vec
3
torque2
=
dx
*
(
torque
.
dot
(
dx
)
/
dx2
);
f
=
torque2
.
cross
(
dy
)
/
dy2
;
forces
[
p
.
yparticle
]
+=
f
;
forces
[
particle
]
-=
f
;
...
...
@@ -326,27 +326,27 @@ void CpuGayBerneForce::applyTorques(const vector<RealVec>& positions, vector<Rea
}
}
RealOpenMM
CpuGayBerneForce
::
computeOneInteraction
(
int
particle1
,
int
particle2
,
RealOpenMM
sigma
,
RealOpenMM
epsilon
,
const
Real
Vec
*
positions
,
float
*
forces
,
vector
<
Real
Vec
>&
torques
,
const
Real
Vec
*
boxVectors
)
{
double
CpuGayBerneForce
::
computeOneInteraction
(
int
particle1
,
int
particle2
,
double
sigma
,
double
epsilon
,
const
Vec
3
*
positions
,
float
*
forces
,
vector
<
Vec
3
>&
torques
,
const
Vec
3
*
boxVectors
)
{
// Compute the displacement and check against the cutoff.
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
double
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
nonbondedMethod
==
GayBerneForce
::
CutoffPeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
positions
[
particle2
],
positions
[
particle1
],
boxVectors
,
deltaR
);
else
ReferenceForce
::
getDeltaR
(
positions
[
particle2
],
positions
[
particle1
],
deltaR
);
RealOpenMM
r
=
deltaR
[
ReferenceForce
::
RIndex
];
double
r
=
deltaR
[
ReferenceForce
::
RIndex
];
if
(
nonbondedMethod
!=
GayBerneForce
::
NoCutoff
&&
r
>=
cutoffDistance
)
return
0
;
RealOpenMM
rInv
=
1
/
r
;
Real
Vec
dr
(
deltaR
[
ReferenceForce
::
XIndex
],
deltaR
[
ReferenceForce
::
YIndex
],
deltaR
[
ReferenceForce
::
ZIndex
]);
Real
Vec
drUnit
=
dr
*
rInv
;
double
rInv
=
1
/
r
;
Vec
3
dr
(
deltaR
[
ReferenceForce
::
XIndex
],
deltaR
[
ReferenceForce
::
YIndex
],
deltaR
[
ReferenceForce
::
ZIndex
]);
Vec
3
drUnit
=
dr
*
rInv
;
// Compute the switching function.
RealOpenMM
switchValue
=
1
,
switchDeriv
=
0
;
double
switchValue
=
1
,
switchDeriv
=
0
;
if
(
useSwitchingFunction
&&
r
>
switchingDistance
)
{
RealOpenMM
t
=
(
r
-
switchingDistance
)
/
(
cutoffDistance
-
switchingDistance
);
double
t
=
(
r
-
switchingDistance
)
/
(
cutoffDistance
-
switchingDistance
);
switchValue
=
1
+
t
*
t
*
t
*
(
-
10
+
t
*
(
15
-
t
*
6
));
switchDeriv
=
t
*
t
*
(
-
30
+
t
*
(
60
-
t
*
30
))
/
(
cutoffDistance
-
switchingDistance
);
}
...
...
@@ -354,11 +354,11 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
// Interactions between two point particles can be computed more easily.
if
(
particles
[
particle1
].
isPointParticle
&&
particles
[
particle2
].
isPointParticle
)
{
RealOpenMM
sig
=
sigma
*
rInv
;
RealOpenMM
sig2
=
sig
*
sig
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
energy
=
4
*
epsilon
*
(
sig6
-
1
)
*
sig6
;
Real
Vec
force
=
drUnit
*
(
switchValue
*
4
*
epsilon
*
(
12
*
sig6
-
6
)
*
sig6
*
rInv
-
energy
*
switchDeriv
);
double
sig
=
sigma
*
rInv
;
double
sig2
=
sig
*
sig
;
double
sig6
=
sig2
*
sig2
*
sig2
;
double
energy
=
4
*
epsilon
*
(
sig6
-
1
)
*
sig6
;
Vec
3
force
=
drUnit
*
(
switchValue
*
4
*
epsilon
*
(
12
*
sig6
-
6
)
*
sig6
*
rInv
-
energy
*
switchDeriv
);
forces
[
4
*
particle1
]
+=
force
[
0
];
forces
[
4
*
particle1
+
1
]
+=
force
[
1
];
forces
[
4
*
particle1
+
2
]
+=
force
[
2
];
...
...
@@ -374,31 +374,31 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
Matrix
G12
=
G
[
particle1
]
+
G
[
particle2
];
Matrix
B12inv
=
B12
.
inverse
();
Matrix
G12inv
=
G12
.
inverse
();
RealOpenMM
detG12
=
G12
.
determinant
();
double
detG12
=
G12
.
determinant
();
// Estimate the distance between the ellipsoids and compute the first terms needed for the energy.
RealOpenMM
sigma12
=
1
/
SQRT
(
0.5
*
drUnit
.
dot
(
G12inv
*
drUnit
));
RealOpenMM
h12
=
r
-
sigma12
;
RealOpenMM
rho
=
sigma
/
(
h12
+
sigma
);
RealOpenMM
rho2
=
rho
*
rho
;
RealOpenMM
rho6
=
rho2
*
rho2
*
rho2
;
RealOpenMM
u
=
4
*
epsilon
*
(
rho6
*
rho6
-
rho6
);
RealOpenMM
eta
=
SQRT
(
2
*
s
[
particle1
]
*
s
[
particle2
]
/
detG12
);
RealOpenMM
chi
=
2
*
drUnit
.
dot
(
B12inv
*
drUnit
);
double
sigma12
=
1
/
sqrt
(
0.5
*
drUnit
.
dot
(
G12inv
*
drUnit
));
double
h12
=
r
-
sigma12
;
double
rho
=
sigma
/
(
h12
+
sigma
);
double
rho2
=
rho
*
rho
;
double
rho6
=
rho2
*
rho2
*
rho2
;
double
u
=
4
*
epsilon
*
(
rho6
*
rho6
-
rho6
);
double
eta
=
sqrt
(
2
*
s
[
particle1
]
*
s
[
particle2
]
/
detG12
);
double
chi
=
2
*
drUnit
.
dot
(
B12inv
*
drUnit
);
chi
*=
chi
;
RealOpenMM
energy
=
u
*
eta
*
chi
;
double
energy
=
u
*
eta
*
chi
;
// Compute the terms needed for the force.
Real
Vec
kappa
=
G12inv
*
dr
;
Real
Vec
iota
=
B12inv
*
dr
;
RealOpenMM
rInv2
=
rInv
*
rInv
;
RealOpenMM
dUSLJdr
=
24
*
epsilon
*
(
2
*
rho6
-
1
)
*
rho6
*
rho
/
sigma
;
RealOpenMM
temp
=
0.5
*
sigma12
*
sigma12
*
sigma12
*
rInv2
;
Real
Vec
dudr
=
(
drUnit
+
(
kappa
-
drUnit
*
kappa
.
dot
(
drUnit
))
*
temp
)
*
dUSLJdr
;
Real
Vec
dchidr
=
(
iota
-
drUnit
*
iota
.
dot
(
drUnit
))
*
(
-
8
*
rInv2
*
SQRT
(
chi
));
Real
Vec
force
=
(
dchidr
*
u
+
dudr
*
chi
)
*
(
eta
*
switchValue
)
-
drUnit
*
(
energy
*
switchDeriv
);
Vec
3
kappa
=
G12inv
*
dr
;
Vec
3
iota
=
B12inv
*
dr
;
double
rInv2
=
rInv
*
rInv
;
double
dUSLJdr
=
24
*
epsilon
*
(
2
*
rho6
-
1
)
*
rho6
*
rho
/
sigma
;
double
temp
=
0.5
*
sigma12
*
sigma12
*
sigma12
*
rInv2
;
Vec
3
dudr
=
(
drUnit
+
(
kappa
-
drUnit
*
kappa
.
dot
(
drUnit
))
*
temp
)
*
dUSLJdr
;
Vec
3
dchidr
=
(
iota
-
drUnit
*
iota
.
dot
(
drUnit
))
*
(
-
8
*
rInv2
*
sqrt
(
chi
));
Vec
3
force
=
(
dchidr
*
u
+
dudr
*
chi
)
*
(
eta
*
switchValue
)
-
drUnit
*
(
energy
*
switchDeriv
);
forces
[
4
*
particle1
]
+=
force
[
0
];
forces
[
4
*
particle1
+
1
]
+=
force
[
1
];
forces
[
4
*
particle1
+
2
]
+=
force
[
2
];
...
...
@@ -413,13 +413,13 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
ParticleInfo
&
p
=
particles
[
particle
];
if
(
p
.
isPointParticle
)
continue
;
Real
Vec
dudq
=
(
kappa
*
G
[
particle
]).
cross
(
kappa
*
(
temp
*
dUSLJdr
));
Real
Vec
dchidq
=
(
iota
*
B
[
particle
]).
cross
(
iota
)
*
(
-
4
*
rInv2
);
RealOpenMM
(
&
g12
)[
3
][
3
]
=
G12
.
v
;
RealOpenMM
(
&
a
)[
3
][
3
]
=
A
[
particle
].
v
;
Real
Vec
scale
=
Real
Vec
(
p
.
rx
*
p
.
rx
,
p
.
ry
*
p
.
ry
,
p
.
rz
*
p
.
rz
)
*
(
-
0.5
*
eta
/
detG12
);
Vec
3
dudq
=
(
kappa
*
G
[
particle
]).
cross
(
kappa
*
(
temp
*
dUSLJdr
));
Vec
3
dchidq
=
(
iota
*
B
[
particle
]).
cross
(
iota
)
*
(
-
4
*
rInv2
);
double
(
&
g12
)[
3
][
3
]
=
G12
.
v
;
double
(
&
a
)[
3
][
3
]
=
A
[
particle
].
v
;
Vec
3
scale
=
Vec
3
(
p
.
rx
*
p
.
rx
,
p
.
ry
*
p
.
ry
,
p
.
rz
*
p
.
rz
)
*
(
-
0.5
*
eta
/
detG12
);
Matrix
D
;
RealOpenMM
(
&
d
)[
3
][
3
]
=
D
.
v
;
double
(
&
d
)[
3
][
3
]
=
D
.
v
;
d
[
0
][
0
]
=
scale
[
0
]
*
(
2
*
a
[
0
][
0
]
*
(
g12
[
1
][
1
]
*
g12
[
2
][
2
]
-
g12
[
1
][
2
]
*
g12
[
2
][
1
])
+
a
[
0
][
2
]
*
(
g12
[
1
][
2
]
*
g12
[
0
][
1
]
+
g12
[
1
][
0
]
*
g12
[
2
][
1
]
-
g12
[
1
][
1
]
*
(
g12
[
0
][
2
]
+
g12
[
2
][
0
]))
+
a
[
0
][
1
]
*
(
g12
[
0
][
2
]
*
g12
[
2
][
1
]
+
g12
[
2
][
0
]
*
g12
[
1
][
2
]
-
g12
[
2
][
2
]
*
(
g12
[
0
][
1
]
+
g12
[
1
][
0
])));
...
...
@@ -447,10 +447,10 @@ RealOpenMM CpuGayBerneForce::computeOneInteraction(int particle1, int particle2,
d
[
2
][
2
]
=
scale
[
2
]
*
(
a
[
2
][
0
]
*
(
g12
[
0
][
1
]
*
g12
[
1
][
2
]
+
g12
[
2
][
1
]
*
g12
[
1
][
0
]
-
g12
[
1
][
1
]
*
(
g12
[
0
][
2
]
+
g12
[
2
][
0
]))
+
a
[
2
][
1
]
*
(
g12
[
1
][
0
]
*
g12
[
0
][
2
]
+
g12
[
2
][
0
]
*
g12
[
0
][
1
]
-
g12
[
0
][
0
]
*
(
g12
[
1
][
2
]
+
g12
[
2
][
1
]))
+
2
*
a
[
2
][
2
]
*
(
g12
[
1
][
1
]
*
g12
[
0
][
0
]
-
g12
[
1
][
0
]
*
g12
[
0
][
1
]));
Real
Vec
detadq
;
Vec
3
detadq
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
detadq
+=
Real
Vec
(
a
[
i
][
0
],
a
[
i
][
1
],
a
[
i
][
2
]).
cross
(
Real
Vec
(
d
[
i
][
0
],
d
[
i
][
1
],
d
[
i
][
2
]));
Real
Vec
torque
=
(
dchidq
*
(
u
*
eta
)
+
detadq
*
(
u
*
chi
)
+
dudq
*
(
eta
*
chi
))
*
switchValue
;
detadq
+=
Vec
3
(
a
[
i
][
0
],
a
[
i
][
1
],
a
[
i
][
2
]).
cross
(
Vec
3
(
d
[
i
][
0
],
d
[
i
][
1
],
d
[
i
][
2
]));
Vec
3
torque
=
(
dchidq
*
(
u
*
eta
)
+
detadq
*
(
u
*
chi
)
+
dudq
*
(
eta
*
chi
))
*
switchValue
;
torques
[
particle
]
-=
torque
;
}
return
switchValue
*
energy
;
...
...
platforms/cpu/src/CpuKernels.cpp
View file @
a783b996
This diff is collapsed.
Click to expand it.
platforms/cpu/src/CpuLangevinDynamics.cpp
View file @
a783b996
...
...
@@ -59,15 +59,15 @@ public:
CpuLangevinDynamics
&
owner
;
};
CpuLangevinDynamics
::
CpuLangevinDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
friction
,
RealOpenMM
temperature
,
ThreadPool
&
threads
,
CpuRandom
&
random
)
:
CpuLangevinDynamics
::
CpuLangevinDynamics
(
int
numberOfAtoms
,
double
deltaT
,
double
friction
,
double
temperature
,
ThreadPool
&
threads
,
CpuRandom
&
random
)
:
ReferenceStochasticDynamics
(
numberOfAtoms
,
deltaT
,
friction
,
temperature
),
threads
(
threads
),
random
(
random
)
{
}
CpuLangevinDynamics
::~
CpuLangevinDynamics
()
{
}
void
CpuLangevinDynamics
::
updatePart1
(
int
numberOfAtoms
,
vector
<
Real
Vec
>&
atomCoordinates
,
vector
<
Real
Vec
>&
velocities
,
vector
<
Real
Vec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
Real
Vec
>&
xPrime
)
{
void
CpuLangevinDynamics
::
updatePart1
(
int
numberOfAtoms
,
vector
<
Vec
3
>&
atomCoordinates
,
vector
<
Vec
3
>&
velocities
,
vector
<
Vec
3
>&
forces
,
vector
<
double
>&
inverseMasses
,
vector
<
Vec
3
>&
xPrime
)
{
// Record the parameters for the threads.
this
->
numberOfAtoms
=
numberOfAtoms
;
...
...
@@ -84,8 +84,8 @@ void CpuLangevinDynamics::updatePart1(int numberOfAtoms, vector<RealVec>& atomCo
threads
.
waitForThreads
();
}
void
CpuLangevinDynamics
::
updatePart2
(
int
numberOfAtoms
,
vector
<
Real
Vec
>&
atomCoordinates
,
vector
<
Real
Vec
>&
velocities
,
vector
<
Real
Vec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
Real
Vec
>&
xPrime
)
{
void
CpuLangevinDynamics
::
updatePart2
(
int
numberOfAtoms
,
vector
<
Vec
3
>&
atomCoordinates
,
vector
<
Vec
3
>&
velocities
,
vector
<
Vec
3
>&
forces
,
vector
<
double
>&
inverseMasses
,
vector
<
Vec
3
>&
xPrime
)
{
// Record the parameters for the threads.
this
->
numberOfAtoms
=
numberOfAtoms
;
...
...
@@ -102,8 +102,8 @@ void CpuLangevinDynamics::updatePart2(int numberOfAtoms, vector<RealVec>& atomCo
threads
.
waitForThreads
();
}
void
CpuLangevinDynamics
::
updatePart3
(
int
numberOfAtoms
,
vector
<
Real
Vec
>&
atomCoordinates
,
vector
<
Real
Vec
>&
velocities
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
Real
Vec
>&
xPrime
)
{
void
CpuLangevinDynamics
::
updatePart3
(
int
numberOfAtoms
,
vector
<
Vec
3
>&
atomCoordinates
,
vector
<
Vec
3
>&
velocities
,
vector
<
double
>&
inverseMasses
,
vector
<
Vec
3
>&
xPrime
)
{
// Record the parameters for the threads.
this
->
numberOfAtoms
=
numberOfAtoms
;
...
...
@@ -120,39 +120,39 @@ void CpuLangevinDynamics::updatePart3(int numberOfAtoms, vector<RealVec>& atomCo
}
void
CpuLangevinDynamics
::
threadUpdate1
(
int
threadIndex
)
{
RealOpenMM
dt
=
getDeltaT
();
RealOpenMM
friction
=
getFriction
();
const
RealOpenMM
vscale
=
EXP
(
-
dt
*
friction
);
const
RealOpenMM
fscale
=
(
friction
==
0
?
dt
:
(
1
-
vscale
)
/
friction
);
const
RealOpenMM
kT
=
BOLTZ
*
getTemperature
();
const
RealOpenMM
noisescale
=
SQRT
(
kT
*
(
1
-
vscale
*
vscale
));
double
dt
=
getDeltaT
();
double
friction
=
getFriction
();
const
double
vscale
=
exp
(
-
dt
*
friction
);
const
double
fscale
=
(
friction
==
0
?
dt
:
(
1
-
vscale
)
/
friction
);
const
double
kT
=
BOLTZ
*
getTemperature
();
const
double
noisescale
=
sqrt
(
kT
*
(
1
-
vscale
*
vscale
));
int
start
=
threadIndex
*
numberOfAtoms
/
threads
.
getNumThreads
();
int
end
=
(
threadIndex
+
1
)
*
numberOfAtoms
/
threads
.
getNumThreads
();
for
(
int
i
=
start
;
i
<
end
;
i
++
)
{
if
(
inverseMasses
[
i
]
!=
0.0
)
{
RealOpenMM
sqrtInvMass
=
SQRT
(
inverseMasses
[
i
]);
Real
Vec
noise
(
random
.
getGaussianRandom
(
threadIndex
),
random
.
getGaussianRandom
(
threadIndex
),
random
.
getGaussianRandom
(
threadIndex
));
double
sqrtInvMass
=
sqrt
(
inverseMasses
[
i
]);
Vec
3
noise
(
random
.
getGaussianRandom
(
threadIndex
),
random
.
getGaussianRandom
(
threadIndex
),
random
.
getGaussianRandom
(
threadIndex
));
velocities
[
i
]
=
velocities
[
i
]
*
vscale
+
forces
[
i
]
*
(
fscale
*
inverseMasses
[
i
])
+
noise
*
(
noisescale
*
sqrtInvMass
);
}
}
}
void
CpuLangevinDynamics
::
threadUpdate2
(
int
threadIndex
)
{
const
RealOpenMM
dt
=
getDeltaT
();
const
double
dt
=
getDeltaT
();
int
start
=
threadIndex
*
numberOfAtoms
/
threads
.
getNumThreads
();
int
end
=
(
threadIndex
+
1
)
*
numberOfAtoms
/
threads
.
getNumThreads
();
for
(
int
i
=
start
;
i
<
end
;
i
++
)
{
if
(
inverseMasses
[
i
]
!=
0.0
)
{
RealOpenMM
sqrtInvMass
=
SQRT
(
inverseMasses
[
i
]);
double
sqrtInvMass
=
sqrt
(
inverseMasses
[
i
]);
xPrime
[
i
]
=
atomCoordinates
[
i
]
+
velocities
[
i
]
*
dt
;
}
}
}
void
CpuLangevinDynamics
::
threadUpdate3
(
int
threadIndex
)
{
const
RealOpenMM
invStepSize
=
1.0
/
getDeltaT
();
const
double
invStepSize
=
1.0
/
getDeltaT
();
int
start
=
threadIndex
*
numberOfAtoms
/
threads
.
getNumThreads
();
int
end
=
(
threadIndex
+
1
)
*
numberOfAtoms
/
threads
.
getNumThreads
();
...
...
platforms/cpu/src/CpuNeighborList.cpp
View file @
a783b996
...
...
@@ -59,7 +59,7 @@ public:
*/
class
CpuNeighborList
::
Voxels
{
public:
Voxels
(
int
blockSize
,
float
vsy
,
float
vsz
,
float
miny
,
float
maxy
,
float
minz
,
float
maxz
,
const
Real
Vec
*
boxVectors
,
bool
usePeriodic
)
:
Voxels
(
int
blockSize
,
float
vsy
,
float
vsz
,
float
miny
,
float
maxy
,
float
minz
,
float
maxz
,
const
Vec
3
*
boxVectors
,
bool
usePeriodic
)
:
blockSize
(
blockSize
),
voxelSizeY
(
vsy
),
voxelSizeZ
(
vsz
),
miny
(
miny
),
maxy
(
maxy
),
minz
(
minz
),
maxz
(
maxz
),
usePeriodic
(
usePeriodic
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
...
...
@@ -423,7 +423,7 @@ CpuNeighborList::CpuNeighborList(int blockSize) : blockSize(blockSize) {
}
void
CpuNeighborList
::
computeNeighborList
(
int
numAtoms
,
const
AlignedArray
<
float
>&
atomLocations
,
const
vector
<
set
<
int
>
>&
exclusions
,
const
Real
Vec
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
)
{
const
Vec
3
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
)
{
int
numBlocks
=
(
numAtoms
+
blockSize
-
1
)
/
blockSize
;
blockNeighbors
.
resize
(
numBlocks
);
blockExclusions
.
resize
(
numBlocks
);
...
...
platforms/cpu/src/CpuNonbondedForce.cpp
View file @
a783b996
...
...
@@ -106,7 +106,7 @@ void CpuNonbondedForce::setUseSwitchingFunction(float distance) {
--------------------------------------------------------------------------------------- */
void
CpuNonbondedForce
::
setPeriodic
(
Real
Vec
*
periodicBoxVectors
)
{
void
CpuNonbondedForce
::
setPeriodic
(
Vec
3
*
periodicBoxVectors
)
{
assert
(
cutoff
);
assert
(
periodicBoxVectors
[
0
][
0
]
>=
2.0
*
cutoffDistance
);
...
...
@@ -188,9 +188,9 @@ void CpuNonbondedForce::setUseSwitchingFunction(float distance) {
}
}
void
CpuNonbondedForce
::
calculateReciprocalIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
vector
<
Real
Vec
>&
atomCoordinates
,
void
CpuNonbondedForce
::
calculateReciprocalIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
vector
<
Vec
3
>&
atomCoordinates
,
const
vector
<
pair
<
float
,
float
>
>&
atomParameters
,
const
vector
<
set
<
int
>
>&
exclusions
,
vector
<
Real
Vec
>&
forces
,
double
*
totalEnergy
)
const
{
vector
<
Vec
3
>&
forces
,
double
*
totalEnergy
)
const
{
typedef
std
::
complex
<
float
>
d_complex
;
static
const
float
epsilon
=
1.0
;
...
...
@@ -203,10 +203,10 @@ void CpuNonbondedForce::calculateReciprocalIxn(int numberOfAtoms, float* posq, c
if
(
pme
)
{
pme_t
pmedata
;
pme_init
(
&
pmedata
,
alphaEwald
,
numberOfAtoms
,
meshDim
,
5
,
1
);
vector
<
RealOpenMM
>
charges
(
numberOfAtoms
);
vector
<
double
>
charges
(
numberOfAtoms
);
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
i
++
)
charges
[
i
]
=
posq
[
4
*
i
+
3
];
RealOpenMM
recipEnergy
=
0.0
;
double
recipEnergy
=
0.0
;
pme_exec
(
pmedata
,
atomCoordinates
,
forces
,
charges
,
periodicBoxVectors
,
&
recipEnergy
);
if
(
totalEnergy
)
*
totalEnergy
+=
recipEnergy
;
...
...
@@ -300,7 +300,7 @@ void CpuNonbondedForce::calculateReciprocalIxn(int numberOfAtoms, float* posq, c
}
void
CpuNonbondedForce
::
calculateDirectIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
vector
<
Real
Vec
>&
atomCoordinates
,
const
vector
<
pair
<
float
,
float
>
>&
atomParameters
,
void
CpuNonbondedForce
::
calculateDirectIxn
(
int
numberOfAtoms
,
float
*
posq
,
const
vector
<
Vec
3
>&
atomCoordinates
,
const
vector
<
pair
<
float
,
float
>
>&
atomParameters
,
const
vector
<
set
<
int
>
>&
exclusions
,
vector
<
AlignedArray
<
float
>
>&
threadForce
,
double
*
totalEnergy
,
ThreadPool
&
threads
)
{
// Record the parameters for the threads.
...
...
Prev
1
2
3
4
5
…
8
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