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
047934e2
Commit
047934e2
authored
Mar 01, 2017
by
Rafal P. Wiewiora
Browse files
Merge remote-tracking branch 'upstream/master'
parents
ce3a5dc0
d12c9bd1
Changes
351
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
276 additions
and
197 deletions
+276
-197
openmmapi/src/NonbondedForce.cpp
openmmapi/src/NonbondedForce.cpp
+20
-1
openmmapi/src/NonbondedForceImpl.cpp
openmmapi/src/NonbondedForceImpl.cpp
+24
-11
openmmapi/src/PeriodicTorsionForceImpl.cpp
openmmapi/src/PeriodicTorsionForceImpl.cpp
+1
-0
openmmapi/src/RBTorsionForceImpl.cpp
openmmapi/src/RBTorsionForceImpl.cpp
+1
-0
openmmapi/src/ThreadPool.cpp
openmmapi/src/ThreadPool.cpp
+17
-5
platforms/cpu/include/CpuBondForce.h
platforms/cpu/include/CpuBondForce.h
+5
-6
platforms/cpu/include/CpuCustomGBForce.h
platforms/cpu/include/CpuCustomGBForce.h
+11
-12
platforms/cpu/include/CpuCustomManyParticleForce.h
platforms/cpu/include/CpuCustomManyParticleForce.h
+9
-10
platforms/cpu/include/CpuCustomNonbondedForce.h
platforms/cpu/include/CpuCustomNonbondedForce.h
+12
-12
platforms/cpu/include/CpuGBSAOBCForce.h
platforms/cpu/include/CpuGBSAOBCForce.h
+1
-2
platforms/cpu/include/CpuGayBerneForce.h
platforms/cpu/include/CpuGayBerneForce.h
+25
-26
platforms/cpu/include/CpuKernels.h
platforms/cpu/include/CpuKernels.h
+24
-16
platforms/cpu/include/CpuLangevinDynamics.h
platforms/cpu/include/CpuLangevinDynamics.h
+14
-17
platforms/cpu/include/CpuNeighborList.h
platforms/cpu/include/CpuNeighborList.h
+4
-5
platforms/cpu/include/CpuNonbondedForce.h
platforms/cpu/include/CpuNonbondedForce.h
+54
-20
platforms/cpu/include/CpuNonbondedForceVec4.h
platforms/cpu/include/CpuNonbondedForceVec4.h
+15
-1
platforms/cpu/include/CpuNonbondedForceVec8.h
platforms/cpu/include/CpuNonbondedForceVec8.h
+15
-0
platforms/cpu/include/CpuSETTLE.h
platforms/cpu/include/CpuSETTLE.h
+3
-5
platforms/cpu/src/CpuBondForce.cpp
platforms/cpu/src/CpuBondForce.cpp
+10
-27
platforms/cpu/src/CpuCustomGBForce.cpp
platforms/cpu/src/CpuCustomGBForce.cpp
+11
-21
No files found.
openmmapi/src/NonbondedForce.cpp
View file @
047934e2
...
@@ -48,7 +48,8 @@ using std::stringstream;
...
@@ -48,7 +48,8 @@ using std::stringstream;
using
std
::
vector
;
using
std
::
vector
;
NonbondedForce
::
NonbondedForce
()
:
nonbondedMethod
(
NoCutoff
),
cutoffDistance
(
1.0
),
switchingDistance
(
-
1.0
),
rfDielectric
(
78.3
),
NonbondedForce
::
NonbondedForce
()
:
nonbondedMethod
(
NoCutoff
),
cutoffDistance
(
1.0
),
switchingDistance
(
-
1.0
),
rfDielectric
(
78.3
),
ewaldErrorTol
(
5e-4
),
alpha
(
0.0
),
useSwitchingFunction
(
false
),
useDispersionCorrection
(
true
),
recipForceGroup
(
-
1
),
nx
(
0
),
ny
(
0
),
nz
(
0
)
{
ewaldErrorTol
(
5e-4
),
alpha
(
0.0
),
dalpha
(
0.0
),
useSwitchingFunction
(
false
),
useDispersionCorrection
(
true
),
recipForceGroup
(
-
1
),
nx
(
0
),
ny
(
0
),
nz
(
0
),
dnx
(
0
),
dny
(
0
),
dnz
(
0
)
{
}
}
NonbondedForce
::
NonbondedMethod
NonbondedForce
::
getNonbondedMethod
()
const
{
NonbondedForce
::
NonbondedMethod
NonbondedForce
::
getNonbondedMethod
()
const
{
...
@@ -106,6 +107,13 @@ void NonbondedForce::getPMEParameters(double& alpha, int& nx, int& ny, int& nz)
...
@@ -106,6 +107,13 @@ void NonbondedForce::getPMEParameters(double& alpha, int& nx, int& ny, int& nz)
nz
=
this
->
nz
;
nz
=
this
->
nz
;
}
}
void
NonbondedForce
::
getLJPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
{
alpha
=
this
->
dalpha
;
nx
=
this
->
dnx
;
ny
=
this
->
dny
;
nz
=
this
->
dnz
;
}
void
NonbondedForce
::
setPMEParameters
(
double
alpha
,
int
nx
,
int
ny
,
int
nz
)
{
void
NonbondedForce
::
setPMEParameters
(
double
alpha
,
int
nx
,
int
ny
,
int
nz
)
{
this
->
alpha
=
alpha
;
this
->
alpha
=
alpha
;
this
->
nx
=
nx
;
this
->
nx
=
nx
;
...
@@ -113,10 +121,21 @@ void NonbondedForce::setPMEParameters(double alpha, int nx, int ny, int nz) {
...
@@ -113,10 +121,21 @@ void NonbondedForce::setPMEParameters(double alpha, int nx, int ny, int nz) {
this
->
nz
=
nz
;
this
->
nz
=
nz
;
}
}
void
NonbondedForce
::
setLJPMEParameters
(
double
alpha
,
int
nx
,
int
ny
,
int
nz
)
{
this
->
dalpha
=
alpha
;
this
->
dnx
=
nx
;
this
->
dny
=
ny
;
this
->
dnz
=
nz
;
}
void
NonbondedForce
::
getPMEParametersInContext
(
const
Context
&
context
,
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
{
void
NonbondedForce
::
getPMEParametersInContext
(
const
Context
&
context
,
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
{
dynamic_cast
<
const
NonbondedForceImpl
&>
(
getImplInContext
(
context
)).
getPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
dynamic_cast
<
const
NonbondedForceImpl
&>
(
getImplInContext
(
context
)).
getPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
}
}
void
NonbondedForce
::
getLJPMEParametersInContext
(
const
Context
&
context
,
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
{
dynamic_cast
<
const
NonbondedForceImpl
&>
(
getImplInContext
(
context
)).
getLJPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
}
int
NonbondedForce
::
addParticle
(
double
charge
,
double
sigma
,
double
epsilon
)
{
int
NonbondedForce
::
addParticle
(
double
charge
,
double
sigma
,
double
epsilon
)
{
particles
.
push_back
(
ParticleInfo
(
charge
,
sigma
,
epsilon
));
particles
.
push_back
(
ParticleInfo
(
charge
,
sigma
,
epsilon
));
return
particles
.
size
()
-
1
;
return
particles
.
size
()
-
1
;
...
...
openmmapi/src/NonbondedForceImpl.cpp
View file @
047934e2
...
@@ -90,9 +90,7 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
...
@@ -90,9 +90,7 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
exceptions
[
particle1
].
insert
(
particle2
);
exceptions
[
particle1
].
insert
(
particle2
);
exceptions
[
particle2
].
insert
(
particle1
);
exceptions
[
particle2
].
insert
(
particle1
);
}
}
if
(
owner
.
getNonbondedMethod
()
==
NonbondedForce
::
CutoffPeriodic
||
if
(
owner
.
getNonbondedMethod
()
!=
NonbondedForce
::
NoCutoff
&&
owner
.
getNonbondedMethod
()
!=
NonbondedForce
::
CutoffNonPeriodic
)
{
owner
.
getNonbondedMethod
()
==
NonbondedForce
::
Ewald
||
owner
.
getNonbondedMethod
()
==
NonbondedForce
::
PME
)
{
Vec3
boxVectors
[
3
];
Vec3
boxVectors
[
3
];
system
.
getDefaultPeriodicBoxVectors
(
boxVectors
[
0
],
boxVectors
[
1
],
boxVectors
[
2
]);
system
.
getDefaultPeriodicBoxVectors
(
boxVectors
[
0
],
boxVectors
[
1
],
boxVectors
[
2
]);
double
cutoff
=
owner
.
getCutoffDistance
();
double
cutoff
=
owner
.
getCutoffDistance
();
...
@@ -151,19 +149,29 @@ void NonbondedForceImpl::calcEwaldParameters(const System& system, const Nonbond
...
@@ -151,19 +149,29 @@ void NonbondedForceImpl::calcEwaldParameters(const System& system, const Nonbond
kmaxz
++
;
kmaxz
++
;
}
}
void
NonbondedForceImpl
::
calcPMEParameters
(
const
System
&
system
,
const
NonbondedForce
&
force
,
double
&
alpha
,
int
&
xsize
,
int
&
ysize
,
int
&
zsize
)
{
void
NonbondedForceImpl
::
calcPMEParameters
(
const
System
&
system
,
const
NonbondedForce
&
force
,
double
&
alpha
,
int
&
xsize
,
int
&
ysize
,
int
&
zsize
,
bool
lj
)
{
force
.
getPMEParameters
(
alpha
,
xsize
,
ysize
,
zsize
);
if
(
lj
)
force
.
getLJPMEParameters
(
alpha
,
xsize
,
ysize
,
zsize
);
else
force
.
getPMEParameters
(
alpha
,
xsize
,
ysize
,
zsize
);
if
(
alpha
==
0.0
)
{
if
(
alpha
==
0.0
)
{
Vec3
boxVectors
[
3
];
Vec3
boxVectors
[
3
];
system
.
getDefaultPeriodicBoxVectors
(
boxVectors
[
0
],
boxVectors
[
1
],
boxVectors
[
2
]);
system
.
getDefaultPeriodicBoxVectors
(
boxVectors
[
0
],
boxVectors
[
1
],
boxVectors
[
2
]);
double
tol
=
force
.
getEwaldErrorTolerance
();
double
tol
=
force
.
getEwaldErrorTolerance
();
alpha
=
(
1.0
/
force
.
getCutoffDistance
())
*
std
::
sqrt
(
-
log
(
2.0
*
tol
));
alpha
=
(
1.0
/
force
.
getCutoffDistance
())
*
std
::
sqrt
(
-
log
(
2.0
*
tol
));
xsize
=
(
int
)
ceil
(
2
*
alpha
*
boxVectors
[
0
][
0
]
/
(
3
*
pow
(
tol
,
0.2
)));
if
(
lj
)
{
ysize
=
(
int
)
ceil
(
2
*
alpha
*
boxVectors
[
1
][
1
]
/
(
3
*
pow
(
tol
,
0.2
)));
xsize
=
(
int
)
ceil
(
alpha
*
boxVectors
[
0
][
0
]
/
(
3
*
pow
(
tol
,
0.2
)));
zsize
=
(
int
)
ceil
(
2
*
alpha
*
boxVectors
[
2
][
2
]
/
(
3
*
pow
(
tol
,
0.2
)));
ysize
=
(
int
)
ceil
(
alpha
*
boxVectors
[
1
][
1
]
/
(
3
*
pow
(
tol
,
0.2
)));
xsize
=
max
(
xsize
,
5
);
zsize
=
(
int
)
ceil
(
alpha
*
boxVectors
[
2
][
2
]
/
(
3
*
pow
(
tol
,
0.2
)));
ysize
=
max
(
ysize
,
5
);
}
zsize
=
max
(
zsize
,
5
);
else
{
xsize
=
(
int
)
ceil
(
2
*
alpha
*
boxVectors
[
0
][
0
]
/
(
3
*
pow
(
tol
,
0.2
)));
ysize
=
(
int
)
ceil
(
2
*
alpha
*
boxVectors
[
1
][
1
]
/
(
3
*
pow
(
tol
,
0.2
)));
zsize
=
(
int
)
ceil
(
2
*
alpha
*
boxVectors
[
2
][
2
]
/
(
3
*
pow
(
tol
,
0.2
)));
}
xsize
=
max
(
xsize
,
6
);
ysize
=
max
(
ysize
,
6
);
zsize
=
max
(
zsize
,
6
);
}
}
}
}
...
@@ -277,8 +285,13 @@ double NonbondedForceImpl::calcDispersionCorrection(const System& system, const
...
@@ -277,8 +285,13 @@ double NonbondedForceImpl::calcDispersionCorrection(const System& system, const
void
NonbondedForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
NonbondedForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcNonbondedForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcNonbondedForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
void
NonbondedForceImpl
::
getPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
{
void
NonbondedForceImpl
::
getPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
{
kernel
.
getAs
<
CalcNonbondedForceKernel
>
().
getPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
kernel
.
getAs
<
CalcNonbondedForceKernel
>
().
getPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
}
}
void
NonbondedForceImpl
::
getLJPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
{
kernel
.
getAs
<
CalcNonbondedForceKernel
>
().
getLJPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
}
openmmapi/src/PeriodicTorsionForceImpl.cpp
View file @
047934e2
...
@@ -63,4 +63,5 @@ std::vector<std::string> PeriodicTorsionForceImpl::getKernelNames() {
...
@@ -63,4 +63,5 @@ std::vector<std::string> PeriodicTorsionForceImpl::getKernelNames() {
void
PeriodicTorsionForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
PeriodicTorsionForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcPeriodicTorsionForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcPeriodicTorsionForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/RBTorsionForceImpl.cpp
View file @
047934e2
...
@@ -63,4 +63,5 @@ std::vector<std::string> RBTorsionForceImpl::getKernelNames() {
...
@@ -63,4 +63,5 @@ std::vector<std::string> RBTorsionForceImpl::getKernelNames() {
void
RBTorsionForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
RBTorsionForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcRBTorsionForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcRBTorsionForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/ThreadPool.cpp
View file @
047934e2
...
@@ -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) 2013-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2013-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -40,10 +40,17 @@ class ThreadPool::ThreadData {
...
@@ -40,10 +40,17 @@ class ThreadPool::ThreadData {
public:
public:
ThreadData
(
ThreadPool
&
owner
,
int
index
)
:
owner
(
owner
),
index
(
index
),
isDeleted
(
false
)
{
ThreadData
(
ThreadPool
&
owner
,
int
index
)
:
owner
(
owner
),
index
(
index
),
isDeleted
(
false
)
{
}
}
void
executeTask
()
{
if
(
owner
.
currentTask
!=
NULL
)
owner
.
currentTask
->
execute
(
owner
,
index
);
else
owner
.
currentFunction
(
owner
,
index
);
}
ThreadPool
&
owner
;
ThreadPool
&
owner
;
int
index
;
int
index
;
bool
isDeleted
;
bool
isDeleted
;
Task
*
currentTask
;
Task
*
currentTask
;
function
<
void
(
ThreadPool
&
pool
,
int
)
>
currentFunction
;
};
};
static
void
*
threadBody
(
void
*
args
)
{
static
void
*
threadBody
(
void
*
args
)
{
...
@@ -54,13 +61,13 @@ static void* threadBody(void* args) {
...
@@ -54,13 +61,13 @@ static void* threadBody(void* args) {
data
.
owner
.
syncThreads
();
data
.
owner
.
syncThreads
();
if
(
data
.
isDeleted
)
if
(
data
.
isDeleted
)
break
;
break
;
data
.
currentTask
->
execute
(
data
.
owner
,
data
.
index
);
data
.
executeTask
(
);
}
}
delete
&
data
;
delete
&
data
;
return
0
;
return
0
;
}
}
ThreadPool
::
ThreadPool
(
int
numThreads
)
{
ThreadPool
::
ThreadPool
(
int
numThreads
)
:
currentTask
(
NULL
)
{
if
(
numThreads
<=
0
)
if
(
numThreads
<=
0
)
numThreads
=
getNumProcessors
();
numThreads
=
getNumProcessors
();
this
->
numThreads
=
numThreads
;
this
->
numThreads
=
numThreads
;
...
@@ -99,8 +106,13 @@ int ThreadPool::getNumThreads() const {
...
@@ -99,8 +106,13 @@ int ThreadPool::getNumThreads() const {
}
}
void
ThreadPool
::
execute
(
Task
&
task
)
{
void
ThreadPool
::
execute
(
Task
&
task
)
{
for
(
int
i
=
0
;
i
<
(
int
)
threadData
.
size
();
i
++
)
currentTask
=
&
task
;
threadData
[
i
]
->
currentTask
=
&
task
;
resumeThreads
();
}
void
ThreadPool
::
execute
(
function
<
void
(
ThreadPool
&
,
int
)
>
task
)
{
currentTask
=
NULL
;
currentFunction
=
task
;
resumeThreads
();
resumeThreads
();
}
}
...
...
platforms/cpu/include/CpuBondForce.h
View file @
047934e2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,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) 2014 Stanford University and the Authors.
*
* Portions copyright (c) 2014
-2017
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -46,7 +46,6 @@ namespace OpenMM {
...
@@ -46,7 +46,6 @@ namespace OpenMM {
*/
*/
class
OPENMM_EXPORT_CPU
CpuBondForce
{
class
OPENMM_EXPORT_CPU
CpuBondForce
{
public:
public:
class
ComputeForceTask
;
CpuBondForce
();
CpuBondForce
();
/**
/**
* Analyze the set of bonds and decide which to compute with each thread.
* Analyze the set of bonds and decide which to compute with each thread.
...
@@ -55,13 +54,13 @@ public:
...
@@ -55,13 +54,13 @@ public:
/**
/**
* Compute the forces from all bonds.
* Compute the forces from all bonds.
*/
*/
void
calculateForce
(
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
void
calculateForce
(
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
/**
/**
* This routine contains the code executed by each thread.
* This routine contains the code executed by each thread.
*/
*/
void
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
void
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
private:
private:
bool
canAssignBond
(
int
bond
,
int
thread
,
std
::
vector
<
int
>&
atomThread
);
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
);
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 @
047934e2
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
7
Stanford University and Simbios.
* Contributors: Peter Eastman
* Contributors: Peter Eastman
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -39,7 +39,6 @@ namespace OpenMM {
...
@@ -39,7 +39,6 @@ namespace OpenMM {
class
CpuCustomGBForce
{
class
CpuCustomGBForce
{
private:
private:
class
ComputeForceTask
;
class
ThreadData
;
class
ThreadData
;
bool
cutoff
;
bool
cutoff
;
...
@@ -60,7 +59,7 @@ private:
...
@@ -60,7 +59,7 @@ private:
// The following variables are used to make information accessible to the individual threads.
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
int
numberOfAtoms
;
float
*
posq
;
float
*
posq
;
RealOpenMM
**
atomParameters
;
double
**
atomParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
bool
includeForce
,
includeEnergy
;
bool
includeForce
,
includeEnergy
;
...
@@ -82,7 +81,7 @@ private:
...
@@ -82,7 +81,7 @@ private:
* @param useExclusions specifies whether to use exclusions
* @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
);
bool
useExclusions
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
...
@@ -96,7 +95,7 @@ private:
...
@@ -96,7 +95,7 @@ private:
* @param atomParameters atomParameters[atomIndex][paramterIndex]
* @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
);
std
::
vector
<
float
>&
valueArray
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
...
@@ -111,7 +110,7 @@ private:
...
@@ -111,7 +110,7 @@ private:
* @param totalEnergy the energy contribution is added to this
* @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
* Calculate an energy term that is based on particle pairs
...
@@ -126,7 +125,7 @@ private:
...
@@ -126,7 +125,7 @@ private:
* @param totalEnergy the energy contribution is added to this
* @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
);
bool
useExclusions
,
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
...
@@ -142,7 +141,7 @@ private:
...
@@ -142,7 +141,7 @@ private:
* @param totalEnergy the energy contribution is added to this
* @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
);
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
...
@@ -155,7 +154,7 @@ private:
...
@@ -155,7 +154,7 @@ private:
* @param forces forces on atoms are added to this
* @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
);
float
*
forces
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
...
@@ -170,7 +169,7 @@ private:
...
@@ -170,7 +169,7 @@ private:
* @param isExcluded specifies whether this is an excluded pair
* @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
);
float
*
forces
,
bool
isExcluded
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
);
/**
/**
...
@@ -218,7 +217,7 @@ public:
...
@@ -218,7 +217,7 @@ public:
* @param boxSize the X, Y, and Z widths of the periodic box
* @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
* Calculate custom GB ixn
...
@@ -232,7 +231,7 @@ public:
...
@@ -232,7 +231,7 @@ public:
* @param energyParamDerivs derivatives of the energy with respect to global parameters
* @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
);
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
);
};
};
...
...
platforms/cpu/include/CpuCustomManyParticleForce.h
View file @
047934e2
/* Portions copyright (c) 2009-201
4
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
7
Stanford University and Simbios.
* Contributors: Peter Eastman
* Contributors: Peter Eastman
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -48,13 +48,12 @@ private:
...
@@ -48,13 +48,12 @@ private:
class
DistanceTermInfo
;
class
DistanceTermInfo
;
class
AngleTermInfo
;
class
AngleTermInfo
;
class
DihedralTermInfo
;
class
DihedralTermInfo
;
class
ComputeForceTask
;
class
ThreadData
;
class
ThreadData
;
int
numParticles
,
numParticlesPerSet
,
numPerParticleParameters
,
numTypes
;
int
numParticles
,
numParticlesPerSet
,
numPerParticleParameters
,
numTypes
;
bool
useCutoff
,
usePeriodic
,
triclinic
,
centralParticleMode
;
bool
useCutoff
,
usePeriodic
,
triclinic
,
centralParticleMode
;
RealOpenMM
cutoffDistance
;
double
cutoffDistance
;
float
recipBoxSize
[
3
];
float
recipBoxSize
[
3
];
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
AlignedArray
<
fvec4
>
periodicBoxVec4
;
CpuNeighborList
*
neighborList
;
CpuNeighborList
*
neighborList
;
ThreadPool
&
threads
;
ThreadPool
&
threads
;
...
@@ -66,7 +65,7 @@ private:
...
@@ -66,7 +65,7 @@ private:
std
::
vector
<
ThreadData
*>
threadData
;
std
::
vector
<
ThreadData
*>
threadData
;
// The following variables are used to make information accessible to the individual threads.
// The following variables are used to make information accessible to the individual threads.
float
*
posq
;
float
*
posq
;
RealOpenMM
**
particleParameters
;
double
**
particleParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
bool
includeForces
,
includeEnergy
;
bool
includeForces
,
includeEnergy
;
...
@@ -82,7 +81,7 @@ private:
...
@@ -82,7 +81,7 @@ private:
* interaction for each one.
* interaction for each one.
*/
*/
void
loopOverInteractions
(
std
::
vector
<
int
>&
availableParticles
,
std
::
vector
<
int
>&
particleSet
,
int
loopIndex
,
int
startIndex
,
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 +104,7 @@ private:
...
@@ -105,7 +104,7 @@ private:
* @param boxSize the size of the periodic box
* @param boxSize the size of the periodic box
* @param invBoxSize the inverse 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
* Compute the displacement and squared distance between two points, optionally using
...
@@ -133,7 +132,7 @@ public:
...
@@ -133,7 +132,7 @@ public:
*
*
* @param distance the cutoff distance
* @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
* Set the force to use periodic boundary conditions. This requires that a cutoff has
...
@@ -142,7 +141,7 @@ public:
...
@@ -142,7 +141,7 @@ public:
*
*
* @param periodicBoxVectors the vectors defining the periodic box
* @param periodicBoxVectors the vectors defining the periodic box
*/
*/
void
setPeriodic
(
Real
Vec
*
periodicBoxVectors
);
void
setPeriodic
(
Vec
3
*
periodicBoxVectors
);
/**
/**
* Calculate the interaction.
* Calculate the interaction.
...
@@ -155,7 +154,7 @@ public:
...
@@ -155,7 +154,7 @@ public:
* @param includeEnergy whether to compute energy
* @param includeEnergy whether to compute energy
* @param energy the total energy is added to this
* @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
);
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForces
,
bool
includeEnergy
,
double
&
energy
);
};
};
...
...
platforms/cpu/include/CpuCustomNonbondedForce.h
View file @
047934e2
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
7
Stanford University and Simbios.
* Contributors: Peter Eastman
* Contributors: Peter Eastman
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -67,7 +67,7 @@ class CpuCustomNonbondedForce {
...
@@ -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 {
...
@@ -88,7 +88,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setUseSwitchingFunction
(
RealOpenMM
distance
);
void
setUseSwitchingFunction
(
double
distance
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -100,7 +100,7 @@ class CpuCustomNonbondedForce {
...
@@ -100,7 +100,7 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
Real
Vec
*
periodicBoxVectors
);
void
setPeriodic
(
Vec
3
*
periodicBoxVectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -118,22 +118,22 @@ class CpuCustomNonbondedForce {
...
@@ -118,22 +118,22 @@ class CpuCustomNonbondedForce {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
calculatePairIxn
(
int
numberOfAtoms
,
float
*
posq
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
void
calculatePairIxn
(
int
numberOfAtoms
,
float
*
posq
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
double
**
atomParameters
,
RealOpenMM
*
fixedParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
double
*
fixedParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
);
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
);
private:
private:
class
ComputeForceTask
;
class
ThreadData
;
class
ThreadData
;
bool
cutoff
;
bool
cutoff
;
bool
useSwitch
;
bool
useSwitch
;
bool
periodic
;
bool
periodic
;
bool
triclinic
;
bool
triclinic
;
bool
useInteractionGroups
;
const
CpuNeighborList
*
neighborList
;
const
CpuNeighborList
*
neighborList
;
float
recipBoxSize
[
3
];
float
recipBoxSize
[
3
];
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
AlignedArray
<
fvec4
>
periodicBoxVec4
;
RealOpenMM
cutoffDistance
,
switchingDistance
;
double
cutoffDistance
,
switchingDistance
;
ThreadPool
&
threads
;
ThreadPool
&
threads
;
const
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
const
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
ThreadData
*>
threadData
;
std
::
vector
<
ThreadData
*>
threadData
;
...
@@ -143,8 +143,8 @@ private:
...
@@ -143,8 +143,8 @@ private:
// The following variables are used to make information accessible to the individual threads.
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
int
numberOfAtoms
;
float
*
posq
;
float
*
posq
;
Real
Vec
const
*
atomCoordinates
;
Vec
3
const
*
atomCoordinates
;
RealOpenMM
**
atomParameters
;
double
**
atomParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
const
std
::
map
<
std
::
string
,
double
>*
globalParameters
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
bool
includeForce
,
includeEnergy
;
bool
includeForce
,
includeEnergy
;
...
@@ -185,7 +185,7 @@ public:
...
@@ -185,7 +185,7 @@ public:
CompiledExpressionSet
expressionSet
;
CompiledExpressionSet
expressionSet
;
std
::
vector
<
double
>
particleParam
;
std
::
vector
<
double
>
particleParam
;
double
r
;
double
r
;
std
::
vector
<
RealOpenMM
>
energyParamDerivs
;
std
::
vector
<
double
>
energyParamDerivs
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuGBSAOBCForce.h
View file @
047934e2
/* Portions copyright (c) 2006-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
7
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
...
@@ -36,7 +36,6 @@ namespace OpenMM {
...
@@ -36,7 +36,6 @@ namespace OpenMM {
class
CpuGBSAOBCForce
{
class
CpuGBSAOBCForce
{
public:
public:
class
ComputeTask
;
CpuGBSAOBCForce
();
CpuGBSAOBCForce
();
/**
/**
...
...
platforms/cpu/include/CpuGayBerneForce.h
View file @
047934e2
...
@@ -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) 2016 Stanford University and the Authors.
*
* Portions copyright (c) 2016
-2017
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
#include "openmm/internal/ThreadPool.h"
#include "openmm/internal/ThreadPool.h"
#include "CpuNeighborList.h"
#include "CpuNeighborList.h"
#include "CpuPlatform.h"
#include "CpuPlatform.h"
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <set>
#include <set>
#include <utility>
#include <utility>
...
@@ -45,7 +45,6 @@ namespace OpenMM {
...
@@ -45,7 +45,6 @@ namespace OpenMM {
class
CpuGayBerneForce
{
class
CpuGayBerneForce
{
public:
public:
struct
Matrix
;
struct
Matrix
;
class
ComputeTask
;
/**
/**
* Constructor.
* Constructor.
...
@@ -62,7 +61,7 @@ public:
...
@@ -62,7 +61,7 @@ public:
* @param data the platform data for the current context
* @param data the platform data for the current context
* @return the energy of the interaction
* @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.
* This routine contains the code executed by each thread.
...
@@ -82,43 +81,43 @@ private:
...
@@ -82,43 +81,43 @@ private:
std
::
set
<
std
::
pair
<
int
,
int
>
>
exclusions
;
std
::
set
<
std
::
pair
<
int
,
int
>
>
exclusions
;
std
::
vector
<
std
::
set
<
int
>
>
particleExclusions
;
std
::
vector
<
std
::
set
<
int
>
>
particleExclusions
;
GayBerneForce
::
NonbondedMethod
nonbondedMethod
;
GayBerneForce
::
NonbondedMethod
nonbondedMethod
;
RealOpenMM
cutoffDistance
,
switchingDistance
;
double
cutoffDistance
,
switchingDistance
;
bool
useSwitchingFunction
;
bool
useSwitchingFunction
;
std
::
vector
<
RealOpenMM
>
s
;
std
::
vector
<
double
>
s
;
std
::
vector
<
Matrix
>
A
,
B
,
G
;
std
::
vector
<
Matrix
>
A
,
B
,
G
;
std
::
vector
<
double
>
threadEnergy
;
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.
// 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
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
Real
Vec
*
boxVectors
;
Vec
3
*
boxVectors
;
void
*
atomicCounter
;
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
,
double
computeOneInteraction
(
int
particle1
,
int
particle2
,
double
sigma
,
double
epsilon
,
const
Vec
3
*
positions
,
float
*
forces
,
std
::
vector
<
Real
Vec
>&
torques
,
const
Real
Vec
*
boxVectors
);
float
*
forces
,
std
::
vector
<
Vec
3
>&
torques
,
const
Vec
3
*
boxVectors
);
};
};
struct
CpuGayBerneForce
::
ParticleInfo
{
struct
CpuGayBerneForce
::
ParticleInfo
{
int
xparticle
,
yparticle
;
int
xparticle
,
yparticle
;
RealOpenMM
sigmaOver2
,
sqrtEpsilon
,
rx
,
ry
,
rz
,
ex
,
ey
,
ez
;
double
sigmaOver2
,
sqrtEpsilon
,
rx
,
ry
,
rz
,
ex
,
ey
,
ez
;
bool
isPointParticle
;
bool
isPointParticle
;
};
};
struct
CpuGayBerneForce
::
ExceptionInfo
{
struct
CpuGayBerneForce
::
ExceptionInfo
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
RealOpenMM
sigma
,
epsilon
;
double
sigma
,
epsilon
;
};
};
struct
CpuGayBerneForce
::
Matrix
{
struct
CpuGayBerneForce
::
Matrix
{
RealOpenMM
v
[
3
][
3
];
double
v
[
3
][
3
];
Real
Vec
operator
*
(
const
Real
Vec
&
r
)
{
Vec
3
operator
*
(
const
Vec
3
&
r
)
{
return
Real
Vec
(
v
[
0
][
0
]
*
r
[
0
]
+
v
[
0
][
1
]
*
r
[
1
]
+
v
[
0
][
2
]
*
r
[
2
],
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
[
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
]);
v
[
2
][
0
]
*
r
[
0
]
+
v
[
2
][
1
]
*
r
[
1
]
+
v
[
2
][
2
]
*
r
[
2
]);
}
}
Matrix
operator
+
(
const
Matrix
&
m
)
{
Matrix
operator
+
(
const
Matrix
&
m
)
{
...
@@ -129,13 +128,13 @@ struct CpuGayBerneForce::Matrix {
...
@@ -129,13 +128,13 @@ struct CpuGayBerneForce::Matrix {
return
result
;
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
]
-
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
]);
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
()
{
Matrix
inverse
()
{
RealOpenMM
invDet
=
1
/
determinant
();
double
invDet
=
1
/
determinant
();
Matrix
result
;
Matrix
result
;
result
.
v
[
0
][
0
]
=
invDet
*
(
v
[
1
][
1
]
*
v
[
2
][
2
]
-
v
[
1
][
2
]
*
v
[
2
][
1
]);
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
]);
result
.
v
[
1
][
0
]
=
-
invDet
*
(
v
[
1
][
0
]
*
v
[
2
][
2
]
-
v
[
1
][
2
]
*
v
[
2
][
0
]);
...
@@ -150,10 +149,10 @@ struct CpuGayBerneForce::Matrix {
...
@@ -150,10 +149,10 @@ struct CpuGayBerneForce::Matrix {
}
}
};
};
static
Real
Vec
operator
*
(
const
Real
Vec
&
r
,
CpuGayBerneForce
::
Matrix
&
m
)
{
static
Vec
3
operator
*
(
const
Vec
3
&
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
],
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
][
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
]);
m
.
v
[
0
][
2
]
*
r
[
0
]
+
m
.
v
[
1
][
2
]
*
r
[
1
]
+
m
.
v
[
2
][
2
]
*
r
[
2
]);
}
}
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuKernels.h
View file @
047934e2
...
@@ -54,8 +54,6 @@ namespace OpenMM {
...
@@ -54,8 +54,6 @@ namespace OpenMM {
*/
*/
class
CpuCalcForcesAndEnergyKernel
:
public
CalcForcesAndEnergyKernel
{
class
CpuCalcForcesAndEnergyKernel
:
public
CalcForcesAndEnergyKernel
{
public:
public:
class
InitForceTask
;
class
SumForceTask
;
CpuCalcForcesAndEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
,
ContextImpl
&
context
);
CpuCalcForcesAndEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
,
ContextImpl
&
context
);
/**
/**
* Initialize the kernel.
* Initialize the kernel.
...
@@ -91,7 +89,7 @@ public:
...
@@ -91,7 +89,7 @@ public:
private:
private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
Kernel
referenceKernel
;
Kernel
referenceKernel
;
std
::
vector
<
Real
Vec
>
lastPositions
;
std
::
vector
<
Vec
3
>
lastPositions
;
};
};
/**
/**
...
@@ -130,7 +128,7 @@ private:
...
@@ -130,7 +128,7 @@ private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
int
numAngles
;
int
numAngles
;
int
**
angleIndexArray
;
int
**
angleIndexArray
;
RealOpenMM
**
angleParamArray
;
double
**
angleParamArray
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
bool
usePeriodic
;
};
};
...
@@ -171,7 +169,7 @@ private:
...
@@ -171,7 +169,7 @@ private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
int
numTorsions
;
int
numTorsions
;
int
**
torsionIndexArray
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
double
**
torsionParamArray
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
bool
usePeriodic
;
};
};
...
@@ -212,7 +210,7 @@ private:
...
@@ -212,7 +210,7 @@ private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
int
numTorsions
;
int
numTorsions
;
int
**
torsionIndexArray
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
double
**
torsionParamArray
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
bool
usePeriodic
;
};
};
...
@@ -251,27 +249,37 @@ public:
...
@@ -251,27 +249,37 @@ public:
void
copyParametersToContext
(
ContextImpl
&
context
,
const
NonbondedForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
NonbondedForce
&
force
);
/**
/**
* Get the parameters being used for PME.
* Get the parameters being used for PME.
*
*
* @param alpha the separation parameter
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
* @param nz the number of grid points along the Z axis
*/
*/
void
getPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
;
void
getPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
;
/**
* Get the parameters being used for the dispersion term in LJPME.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
void
getLJPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
;
private:
private:
class
PmeIO
;
class
PmeIO
;
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
int
numParticles
,
num14
;
int
numParticles
,
num14
;
int
**
bonded14IndexArray
;
int
**
bonded14IndexArray
;
double
**
bonded14ParamArray
;
double
**
bonded14ParamArray
;
double
nonbondedCutoff
,
switchingDistance
,
rfDielectric
,
ewaldAlpha
,
ewaldSelfEnergy
,
dispersionCoefficient
;
double
nonbondedCutoff
,
switchingDistance
,
rfDielectric
,
ewaldAlpha
,
ewaldDispersionAlpha
,
ewaldSelfEnergy
,
dispersionCoefficient
;
int
kmax
[
3
],
gridSize
[
3
];
int
kmax
[
3
],
gridSize
[
3
]
,
dispersionGridSize
[
3
]
;
bool
useSwitchingFunction
,
useOptimizedPme
,
hasInitializedPme
;
bool
useSwitchingFunction
,
useOptimizedPme
,
hasInitializedPme
,
hasInitializedDispersionPme
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
pair
<
float
,
float
>
>
particleParams
;
std
::
vector
<
std
::
pair
<
float
,
float
>
>
particleParams
;
std
::
vector
<
float
>
C6params
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
CpuNonbondedForce
*
nonbonded
;
CpuNonbondedForce
*
nonbonded
;
Kernel
optimizedPme
;
Kernel
optimizedPme
,
optimizedDispersionPme
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
};
};
...
@@ -395,8 +403,8 @@ private:
...
@@ -395,8 +403,8 @@ private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
int
numParticles
;
int
numParticles
;
bool
isPeriodic
;
bool
isPeriodic
;
RealOpenMM
**
particleParamArray
;
double
**
particleParamArray
;
RealOpenMM
nonbondedCutoff
;
double
nonbondedCutoff
;
CpuCustomGBForce
*
ixn
;
CpuCustomGBForce
*
ixn
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
string
>
particleParameterNames
,
globalParameterNames
,
energyParamDerivNames
,
valueNames
;
std
::
vector
<
std
::
string
>
particleParameterNames
,
globalParameterNames
,
energyParamDerivNames
,
valueNames
;
...
@@ -440,8 +448,8 @@ public:
...
@@ -440,8 +448,8 @@ public:
private:
private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
int
numParticles
;
int
numParticles
;
RealOpenMM
cutoffDistance
;
double
cutoffDistance
;
RealOpenMM
**
particleParamArray
;
double
**
particleParamArray
;
CpuCustomManyParticleForce
*
ixn
;
CpuCustomManyParticleForce
*
ixn
;
std
::
vector
<
std
::
string
>
globalParameterNames
;
std
::
vector
<
std
::
string
>
globalParameterNames
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
...
@@ -516,7 +524,7 @@ public:
...
@@ -516,7 +524,7 @@ public:
private:
private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
CpuLangevinDynamics
*
dynamics
;
CpuLangevinDynamics
*
dynamics
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
double
>
masses
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
};
};
...
...
platforms/cpu/include/CpuLangevinDynamics.h
View file @
047934e2
/* Portions copyright (c) 2013-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2013-201
7
Stanford University and Simbios.
* Authors: Peter Eastman
* Authors: Peter Eastman
* Contributors:
* Contributors:
*
*
...
@@ -35,20 +35,17 @@ namespace OpenMM {
...
@@ -35,20 +35,17 @@ namespace OpenMM {
class
CpuLangevinDynamics
:
public
ReferenceStochasticDynamics
{
class
CpuLangevinDynamics
:
public
ReferenceStochasticDynamics
{
public:
public:
class
Update1Task
;
class
Update2Task
;
class
Update3Task
;
/**
/**
* Constructor.
* Constructor.
*
*
* @param numberOfAtoms number of atoms
* @param numberOfAtoms number of atoms
* @param deltaT delta t for dynamics
* @param deltaT delta t for dynamics
* @param
tau viscosity
* @param
friction friction coefficient
* @param temperature temperature
* @param temperature temperature
* @param threads thread pool for parallelizing computation
* @param threads thread pool for parallelizing computation
* @param random random number generator
* @param random random number generator
*/
*/
CpuLangevinDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
tau
,
RealOpenMM
temperature
,
OpenMM
::
ThreadPool
&
threads
,
OpenMM
::
CpuRandom
&
random
);
CpuLangevinDynamics
(
int
numberOfAtoms
,
double
deltaT
,
double
friction
,
double
temperature
,
OpenMM
::
ThreadPool
&
threads
,
OpenMM
::
CpuRandom
&
random
);
/**
/**
* Destructor.
* Destructor.
...
@@ -65,8 +62,8 @@ public:
...
@@ -65,8 +62,8 @@ public:
* @param inverseMasses inverse atom masses
* @param inverseMasses inverse atom masses
* @param xPrime xPrime
* @param xPrime xPrime
*/
*/
void
updatePart1
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
velocities
,
void
updatePart1
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
velocities
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
xPrime
);
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
std
::
vector
<
double
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Vec
3
>&
xPrime
);
/**
/**
* Second update step.
* Second update step.
...
@@ -78,8 +75,8 @@ public:
...
@@ -78,8 +75,8 @@ public:
* @param inverseMasses inverse atom masses
* @param inverseMasses inverse atom masses
* @param xPrime xPrime
* @param xPrime xPrime
*/
*/
void
updatePart2
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
velocities
,
void
updatePart2
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
velocities
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
xPrime
);
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
std
::
vector
<
double
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Vec
3
>&
xPrime
);
/**
/**
* Third update
* Third update
...
@@ -89,8 +86,8 @@ public:
...
@@ -89,8 +86,8 @@ public:
* @param velocities velocities
* @param velocities velocities
* @param inverseMasses inverse atom masses
* @param inverseMasses inverse atom masses
*/
*/
void
updatePart3
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
velocities
,
void
updatePart3
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
Vec
3
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
Vec
3
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
xPrime
);
std
::
vector
<
double
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
Vec
3
>&
xPrime
);
private:
private:
void
threadUpdate1
(
int
threadIndex
);
void
threadUpdate1
(
int
threadIndex
);
...
@@ -101,11 +98,11 @@ private:
...
@@ -101,11 +98,11 @@ private:
std
::
vector
<
OpenMM_SFMT
::
SFMT
>
threadRandom
;
std
::
vector
<
OpenMM_SFMT
::
SFMT
>
threadRandom
;
// The following variables are used to make information accessible to the individual threads.
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
int
numberOfAtoms
;
OpenMM
::
Real
Vec
*
atomCoordinates
;
OpenMM
::
Vec
3
*
atomCoordinates
;
OpenMM
::
Real
Vec
*
velocities
;
OpenMM
::
Vec
3
*
velocities
;
OpenMM
::
Real
Vec
*
forces
;
OpenMM
::
Vec
3
*
forces
;
RealOpenMM
*
inverseMasses
;
double
*
inverseMasses
;
OpenMM
::
Real
Vec
*
xPrime
;
OpenMM
::
Vec
3
*
xPrime
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuNeighborList.h
View file @
047934e2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,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) 2013-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2013-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "AlignedArray.h"
#include "AlignedArray.h"
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include "windowsExportCpu.h"
#include "windowsExportCpu.h"
#include "openmm/internal/gmx_atomic.h"
#include "openmm/internal/gmx_atomic.h"
#include "openmm/internal/ThreadPool.h"
#include "openmm/internal/ThreadPool.h"
...
@@ -45,11 +45,10 @@ namespace OpenMM {
...
@@ -45,11 +45,10 @@ namespace OpenMM {
class
OPENMM_EXPORT_CPU
CpuNeighborList
{
class
OPENMM_EXPORT_CPU
CpuNeighborList
{
public:
public:
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
Real
Vec
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
const
Vec
3
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
int
getNumBlocks
()
const
;
int
getNumBlocks
()
const
;
int
getBlockSize
()
const
;
int
getBlockSize
()
const
;
const
std
::
vector
<
int
>&
getSortedAtoms
()
const
;
const
std
::
vector
<
int
>&
getSortedAtoms
()
const
;
...
@@ -72,7 +71,7 @@ private:
...
@@ -72,7 +71,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
;
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
int
numAtoms
;
int
numAtoms
;
bool
usePeriodic
;
bool
usePeriodic
;
float
maxDistance
;
float
maxDistance
;
...
...
platforms/cpu/include/CpuNonbondedForce.h
View file @
047934e2
/* Portions copyright (c) 2006-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
7
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
...
@@ -39,7 +39,6 @@ namespace OpenMM {
...
@@ -39,7 +39,6 @@ namespace OpenMM {
class
CpuNonbondedForce
{
class
CpuNonbondedForce
{
public:
public:
class
ComputeDirectTask
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -87,7 +86,7 @@ class CpuNonbondedForce {
...
@@ -87,7 +86,7 @@ class CpuNonbondedForce {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
Real
Vec
*
periodicBoxVectors
);
void
setPeriodic
(
Vec
3
*
periodicBoxVectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -104,16 +103,27 @@ class CpuNonbondedForce {
...
@@ -104,16 +103,27 @@ class CpuNonbondedForce {
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Set the force to use Particle-Mesh Ewald (PME) summation.
Set the force to use Particle-Mesh Ewald (PME) summation.
@param alpha the Ewald separation parameter
@param alpha the Ewald separation parameter
@param gridSize the dimensions of the mesh
@param gridSize the dimensions of the mesh
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setUsePME
(
float
alpha
,
int
meshSize
[
3
]);
void
setUsePME
(
float
alpha
,
int
meshSize
[
3
]);
/**---------------------------------------------------------------------------------------
Set the force to use Particle-Mesh Ewald (PME) summation for dispersion.
@param alpha the Ewald separation parameter
@param gridSize the dimensions of the mesh
--------------------------------------------------------------------------------------- */
void
setUseLJPME
(
float
alpha
,
int
meshSize
[
3
]);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Calculate Ewald ixn
Calculate Ewald ixn
...
@@ -122,16 +132,17 @@ class CpuNonbondedForce {
...
@@ -122,16 +132,17 @@ class CpuNonbondedForce {
@param posq atom coordinates and charges
@param posq atom coordinates and charges
@param atomCoordinates atom coordinates (in format needed by PME)
@param atomCoordinates atom coordinates (in format needed by PME)
@param atomParameters atom parameters (sigma/2, 2*sqrt(epsilon))
@param atomParameters atom parameters (sigma/2, 2*sqrt(epsilon))
@param C6Paramrs C6 parameters for multiplicative representation of dispersion
@param exclusions atom exclusion indices
@param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom
exclusions[atomIndex] contains the list of exclusions for that atom
@param forces force array (forces added)
@param forces force array (forces added)
@param totalEnergy total energy
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
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
>
>&
exclusion
s
,
const
std
::
vector
<
std
::
pair
<
float
,
float
>
>&
atomParameters
,
const
std
::
vector
<
float
>
&
C6param
s
,
std
::
vector
<
Real
Vec
>&
forces
,
double
*
totalEnergy
)
const
;
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
std
::
vector
<
Vec
3
>&
forces
,
double
*
totalEnergy
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -149,8 +160,8 @@ class CpuNonbondedForce {
...
@@ -149,8 +160,8 @@ 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
);
const
std
::
vector
<
float
>&
C6params
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
double
*
totalEnergy
,
ThreadPool
&
threads
);
/**
/**
* This routine contains the code executed by each thread.
* This routine contains the code executed by each thread.
...
@@ -163,28 +174,32 @@ protected:
...
@@ -163,28 +174,32 @@ protected:
bool
periodic
;
bool
periodic
;
bool
triclinic
;
bool
triclinic
;
bool
ewald
;
bool
ewald
;
bool
pme
;
bool
ljpme
,
pme
;
bool
tableIsValid
;
bool
tableIsValid
,
expTableIsValid
;
const
CpuNeighborList
*
neighborList
;
const
CpuNeighborList
*
neighborList
;
float
recipBoxSize
[
3
];
float
recipBoxSize
[
3
];
Real
Vec
periodicBoxVectors
[
3
];
Vec
3
periodicBoxVectors
[
3
];
AlignedArray
<
fvec4
>
periodicBoxVec4
;
AlignedArray
<
fvec4
>
periodicBoxVec4
;
float
cutoffDistance
,
switchingDistance
;
float
cutoffDistance
,
switchingDistance
;
float
krf
,
crf
;
float
krf
,
crf
;
float
alphaEwald
;
float
alphaEwald
,
alphaDispersionEwald
;
int
numRx
,
numRy
,
numRz
;
int
numRx
,
numRy
,
numRz
;
int
meshDim
[
3
];
int
meshDim
[
3
]
,
dispersionMeshDim
[
3
]
;
std
::
vector
<
float
>
erfcTable
,
ewaldScaleTable
;
std
::
vector
<
float
>
erfcTable
,
ewaldScaleTable
;
float
ewaldDX
,
ewaldDXInv
,
erfcDXInv
;
std
::
vector
<
float
>
exptermsTable
,
dExptermsTable
;
float
ewaldDX
,
ewaldDXInv
,
erfcDXInv
,
exptermsDX
,
exptermsDXInv
;
std
::
vector
<
double
>
threadEnergy
;
std
::
vector
<
double
>
threadEnergy
;
// The following variables are used to make information accessible to the individual threads.
// The following variables are used to make information accessible to the individual threads.
int
numberOfAtoms
;
int
numberOfAtoms
;
float
*
posq
;
float
*
posq
;
Real
Vec
const
*
atomCoordinates
;
Vec
3
const
*
atomCoordinates
;
std
::
pair
<
float
,
float
>
const
*
atomParameters
;
std
::
pair
<
float
,
float
>
const
*
atomParameters
;
float
const
*
C6params
;
std
::
set
<
int
>
const
*
exclusions
;
std
::
set
<
int
>
const
*
exclusions
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
std
::
vector
<
AlignedArray
<
float
>
>*
threadForce
;
bool
includeEnergy
;
bool
includeEnergy
;
float
inverseRcut6
;
float
inverseRcut6Expterm
;
void
*
atomicCounter
;
void
*
atomicCounter
;
static
const
float
TWO_OVER_SQRT_PI
;
static
const
float
TWO_OVER_SQRT_PI
;
...
@@ -238,10 +253,29 @@ protected:
...
@@ -238,10 +253,29 @@ protected:
*/
*/
void
tabulateEwaldScaleFactor
();
void
tabulateEwaldScaleFactor
();
/**
* Create a lookup table for the scale factor used with dispersion PME.
*/
void
tabulateExpTerms
();
/**
/**
* Compute a fast approximation to erfc(x).
* Compute a fast approximation to erfc(x).
*/
*/
float
erfcApprox
(
float
x
);
float
erfcApprox
(
float
x
);
/**
* Compute a fast approximation to (1.0 - EXP(-dar^2) * (1.0 + dar^2 + 0.5*dar^4))
* where dar = (dispersionAlpha * R)
* needed for LJPME energies.
*/
float
exptermsApprox
(
float
R
);
/**
* Compute a fast approximation to (1.0 - EXP(-dar^2) * (1.0 + dar^2 + 0.5*dar^4 + dar^6/6.0))
* where dar = (dispersionAlpha * R)
* needed for LJPME forces.
*/
float
dExptermsApprox
(
float
R
);
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuNonbondedForceVec4.h
View file @
047934e2
...
@@ -88,11 +88,25 @@ protected:
...
@@ -88,11 +88,25 @@ protected:
* Compute a fast approximation to erfc(x).
* Compute a fast approximation to erfc(x).
*/
*/
fvec4
erfcApprox
(
const
fvec4
&
x
);
fvec4
erfcApprox
(
const
fvec4
&
x
);
/**
/**
* Evaluate the scale factor used with Ewald and PME: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
* Evaluate the scale factor used with Ewald and PME: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
*/
*/
fvec4
ewaldScaleFunction
(
const
fvec4
&
x
);
fvec4
ewaldScaleFunction
(
const
fvec4
&
x
);
/**
* Compute a fast approximation to (1.0 - EXP(-dar^2) * (1.0 + dar^2 + 0.5*dar^4))
* where dar = (dispersionAlpha * R)
* needed for LJPME energies.
*/
fvec4
exptermsApprox
(
const
fvec4
&
R
);
/**
* Compute a fast approximation to (1.0 - EXP(-dar^2) * (1.0 + dar^2 + 0.5*dar^4 + dar^6/6.0))
* where dar = (dispersionAlpha * R)
* needed for LJPME forces.
*/
fvec4
dExptermsApprox
(
const
fvec4
&
R
);
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuNonbondedForceVec8.h
View file @
047934e2
...
@@ -92,6 +92,21 @@ protected:
...
@@ -92,6 +92,21 @@ protected:
* Evaluate the scale factor used with Ewald and PME: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
* Evaluate the scale factor used with Ewald and PME: erfc(alpha*r) + 2*alpha*r*exp(-alpha*alpha*r*r)/sqrt(PI)
*/
*/
fvec8
ewaldScaleFunction
(
const
fvec8
&
x
);
fvec8
ewaldScaleFunction
(
const
fvec8
&
x
);
/**
* Compute a fast approximation to (1.0 - EXP(-dar^2) * (1.0 + dar^2 + 0.5*dar^4))
* where dar = (dispersionAlpha * R)
* needed for LJPME energies.
*/
fvec8
exptermsApprox
(
const
fvec8
&
R
);
/**
* Compute a fast approximation to (1.0 - EXP(-dar^2) * (1.0 + dar^2 + 0.5*dar^4 + dar^6/6.0))
* where dar = (dispersionAlpha * R)
* needed for LJPME forces.
*/
fvec8
dExptermsApprox
(
const
fvec8
&
R
);
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/cpu/include/CpuSETTLE.h
View file @
047934e2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,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) 2013 Stanford University and the Authors.
*
* Portions copyright (c) 2013
-2017
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -45,8 +45,6 @@ namespace OpenMM {
...
@@ -45,8 +45,6 @@ namespace OpenMM {
*/
*/
class
OPENMM_EXPORT_CPU
CpuSETTLE
:
public
ReferenceConstraintAlgorithm
{
class
OPENMM_EXPORT_CPU
CpuSETTLE
:
public
ReferenceConstraintAlgorithm
{
public:
public:
class
ApplyToPositionsTask
;
class
ApplyToVelocitiesTask
;
CpuSETTLE
(
const
System
&
system
,
const
ReferenceSETTLEAlgorithm
&
settle
,
ThreadPool
&
threads
);
CpuSETTLE
(
const
System
&
system
,
const
ReferenceSETTLEAlgorithm
&
settle
,
ThreadPool
&
threads
);
~
CpuSETTLE
();
~
CpuSETTLE
();
...
@@ -58,7 +56,7 @@ public:
...
@@ -58,7 +56,7 @@ public:
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
* @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.
* Apply the constraint algorithm to velocities.
...
@@ -68,7 +66,7 @@ public:
...
@@ -68,7 +66,7 @@ public:
* @param inverseMasses 1/mass
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
* @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:
private:
std
::
vector
<
ReferenceSETTLEAlgorithm
*>
threadSettle
;
std
::
vector
<
ReferenceSETTLEAlgorithm
*>
threadSettle
;
ThreadPool
&
threads
;
ThreadPool
&
threads
;
...
...
platforms/cpu/src/CpuBondForce.cpp
View file @
047934e2
...
@@ -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) 2014-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2014-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -35,25 +35,6 @@
...
@@ -35,25 +35,6 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
class
CpuBondForce
::
ComputeForceTask
:
public
ThreadPool
::
Task
{
public:
ComputeForceTask
(
CpuBondForce
&
owner
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
threadEnergy
,
RealOpenMM
*
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
]);
owner
.
threadComputeForce
(
threads
,
threadIndex
,
atomCoordinates
,
parameters
,
forces
,
energy
,
referenceBondIxn
);
}
CpuBondForce
&
owner
;
vector
<
RealVec
>&
atomCoordinates
;
RealOpenMM
**
parameters
;
vector
<
RealVec
>&
forces
;
vector
<
RealOpenMM
>&
threadEnergy
;
RealOpenMM
*
totalEnergy
;
ReferenceBondIxn
&
referenceBondIxn
;
};
CpuBondForce
::
CpuBondForce
()
{
CpuBondForce
::
CpuBondForce
()
{
}
}
...
@@ -183,13 +164,15 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec
...
@@ -183,13 +164,15 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec
}
}
}
}
void
CpuBondForce
::
calculateForce
(
vector
<
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
vector
<
Real
Vec
>&
forces
,
void
CpuBondForce
::
calculateForce
(
vector
<
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
vector
<
Vec
3
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
// Have the worker threads compute their forces.
// 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
([
&
]
(
ThreadPool
&
threads
,
int
threadIndex
)
{
threads
->
execute
(
task
);
double
*
energy
=
(
totalEnergy
==
NULL
?
NULL
:
&
threadEnergy
[
threadIndex
]);
threadComputeForce
(
threads
,
threadIndex
,
atomCoordinates
,
parameters
,
forces
,
energy
,
referenceBondIxn
);
});
threads
->
waitForThreads
();
threads
->
waitForThreads
();
// Compute any "extra" bonds.
// Compute any "extra" bonds.
...
@@ -206,8 +189,8 @@ void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM**
...
@@ -206,8 +189,8 @@ void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM**
*
totalEnergy
+=
threadEnergy
[
i
];
*
totalEnergy
+=
threadEnergy
[
i
];
}
}
void
CpuBondForce
::
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
vector
<
Real
Vec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
vector
<
Real
Vec
>&
forces
,
void
CpuBondForce
::
threadComputeForce
(
ThreadPool
&
threads
,
int
threadIndex
,
vector
<
Vec
3
>&
atomCoordinates
,
double
**
parameters
,
vector
<
Vec
3
>&
forces
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
vector
<
int
>&
bonds
=
threadBonds
[
threadIndex
];
vector
<
int
>&
bonds
=
threadBonds
[
threadIndex
];
int
numBonds
=
bonds
.
size
();
int
numBonds
=
bonds
.
size
();
for
(
int
i
=
0
;
i
<
numBonds
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numBonds
;
i
++
)
{
...
...
platforms/cpu/src/CpuCustomGBForce.cpp
View file @
047934e2
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
7
Stanford University and Simbios.
* Contributors: Peter Eastman
* Contributors: Peter Eastman
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -33,16 +33,6 @@
...
@@ -33,16 +33,6 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
class
CpuCustomGBForce
::
ComputeForceTask
:
public
ThreadPool
::
Task
{
public:
ComputeForceTask
(
CpuCustomGBForce
&
owner
)
:
owner
(
owner
)
{
}
void
execute
(
ThreadPool
&
threads
,
int
threadIndex
)
{
owner
.
threadComputeForce
(
threads
,
threadIndex
);
}
CpuCustomGBForce
&
owner
;
};
CpuCustomGBForce
::
ThreadData
::
ThreadData
(
int
numAtoms
,
int
numThreads
,
int
threadIndex
,
CpuCustomGBForce
::
ThreadData
::
ThreadData
(
int
numAtoms
,
int
numThreads
,
int
threadIndex
,
const
vector
<
Lepton
::
CompiledExpression
>&
valueExpressions
,
const
vector
<
Lepton
::
CompiledExpression
>&
valueExpressions
,
const
vector
<
vector
<
Lepton
::
CompiledExpression
>
>&
valueDerivExpressions
,
const
vector
<
vector
<
Lepton
::
CompiledExpression
>
>&
valueDerivExpressions
,
...
@@ -176,7 +166,7 @@ void CpuCustomGBForce::setUseCutoff(float distance, const CpuNeighborList& neigh
...
@@ -176,7 +166,7 @@ void CpuCustomGBForce::setUseCutoff(float distance, const CpuNeighborList& neigh
neighborList
=
&
neighbors
;
neighborList
=
&
neighbors
;
}
}
void
CpuCustomGBForce
::
setPeriodic
(
Real
Vec
&
boxSize
)
{
void
CpuCustomGBForce
::
setPeriodic
(
Vec
3
&
boxSize
)
{
if
(
cutoff
)
{
if
(
cutoff
)
{
assert
(
boxSize
[
0
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
0
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
1
]
>=
2.0
*
cutoffDistance
);
assert
(
boxSize
[
1
]
>=
2.0
*
cutoffDistance
);
...
@@ -188,7 +178,7 @@ void CpuCustomGBForce::setPeriodic(RealVec& boxSize) {
...
@@ -188,7 +178,7 @@ void CpuCustomGBForce::setPeriodic(RealVec& boxSize) {
periodicBoxSize
[
2
]
=
boxSize
[
2
];
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
,
map
<
string
,
double
>&
globalParameters
,
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
)
{
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
)
{
// Record the parameters for the threads.
// Record the parameters for the threads.
...
@@ -206,7 +196,7 @@ void CpuCustomGBForce::calculateIxn(int numberOfAtoms, float* posq, RealOpenMM**
...
@@ -206,7 +196,7 @@ void CpuCustomGBForce::calculateIxn(int numberOfAtoms, float* posq, RealOpenMM**
// Calculate the first computed value.
// Calculate the first computed value.
ComputeForceTask
task
(
*
this
)
;
auto
task
=
[
&
]
(
ThreadPool
&
threads
,
int
threadIndex
)
{
threadComputeForce
(
threads
,
threadIndex
);
}
;
gmx_atomic_set
(
&
counter
,
0
);
gmx_atomic_set
(
&
counter
,
0
);
threads
.
execute
(
task
);
threads
.
execute
(
task
);
threads
.
waitForThreads
();
threads
.
waitForThreads
();
...
@@ -362,7 +352,7 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
...
@@ -362,7 +352,7 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
calculateChainRuleForces
(
data
,
numberOfAtoms
,
posq
,
atomParameters
,
forces
,
boxSize
,
invBoxSize
);
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
)
{
bool
useExclusions
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
values
[
index
][
i
]
=
0.0
f
;
values
[
index
][
i
]
=
0.0
f
;
...
@@ -409,7 +399,7 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i
...
@@ -409,7 +399,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
)
{
vector
<
float
>&
valueArray
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
fvec4
deltaR
;
fvec4
deltaR
;
fvec4
pos1
(
posq
+
4
*
atom1
);
fvec4
pos1
(
posq
+
4
*
atom1
);
...
@@ -436,7 +426,7 @@ void CpuCustomGBForce::calculateOnePairValue(int index, int atom1, int atom2, Th
...
@@ -436,7 +426,7 @@ void CpuCustomGBForce::calculateOnePairValue(int index, int atom1, int atom2, Th
}
}
void
CpuCustomGBForce
::
calculateSingleParticleEnergyTerm
(
int
index
,
ThreadData
&
data
,
int
numAtoms
,
float
*
posq
,
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
++
)
{
for
(
int
i
=
data
.
firstAtom
;
i
<
data
.
lastAtom
;
i
++
)
{
data
.
x
=
posq
[
4
*
i
];
data
.
x
=
posq
[
4
*
i
];
data
.
y
=
posq
[
4
*
i
+
1
];
data
.
y
=
posq
[
4
*
i
+
1
];
...
@@ -460,7 +450,7 @@ void CpuCustomGBForce::calculateSingleParticleEnergyTerm(int index, ThreadData&
...
@@ -460,7 +450,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
)
{
bool
useExclusions
,
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
if
(
cutoff
)
{
if
(
cutoff
)
{
// Loop over all pairs in the neighbor list.
// Loop over all pairs in the neighbor list.
...
@@ -502,7 +492,7 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da
...
@@ -502,7 +492,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
)
{
float
*
forces
,
double
&
totalEnergy
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
// Compute the displacement.
// Compute the displacement.
...
@@ -547,7 +537,7 @@ void CpuCustomGBForce::calculateOnePairEnergyTerm(int index, int atom1, int atom
...
@@ -547,7 +537,7 @@ void CpuCustomGBForce::calculateOnePairEnergyTerm(int index, int atom1, int atom
data
.
energyParamDerivs
[
i
]
+=
data
.
energyParamDerivExpressions
[
index
][
i
].
evaluate
();
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
)
{
float
*
forces
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
if
(
cutoff
)
{
if
(
cutoff
)
{
// Loop over all pairs in the neighbor list.
// Loop over all pairs in the neighbor list.
...
@@ -624,7 +614,7 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms,
...
@@ -624,7 +614,7 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms,
data
.
energyParamDerivs
[
k
]
+=
dEdV
[
j
][
i
]
*
dValuedParam
[
j
][
k
][
i
];
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
)
{
float
*
forces
,
bool
isExcluded
,
const
fvec4
&
boxSize
,
const
fvec4
&
invBoxSize
)
{
// Compute the displacement.
// Compute the displacement.
...
...
Prev
1
2
3
4
5
6
7
8
…
18
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