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
62c4fd53
Commit
62c4fd53
authored
Oct 22, 2008
by
Peter Eastman
Browse files
Renamed "atoms" to "particles"
parent
ad75a390
Changes
48
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
333 additions
and
333 deletions
+333
-333
openmmapi/src/HarmonicBondForce.cpp
openmmapi/src/HarmonicBondForce.cpp
+6
-6
openmmapi/src/NonbondedForce.cpp
openmmapi/src/NonbondedForce.cpp
+15
-15
openmmapi/src/NonbondedForceImpl.cpp
openmmapi/src/NonbondedForceImpl.cpp
+10
-10
openmmapi/src/OpenMMContext.cpp
openmmapi/src/OpenMMContext.cpp
+3
-3
openmmapi/src/OpenMMContextImpl.cpp
openmmapi/src/OpenMMContextImpl.cpp
+5
-5
openmmapi/src/PeriodicTorsionForce.cpp
openmmapi/src/PeriodicTorsionForce.cpp
+10
-10
openmmapi/src/RBTorsionForce.cpp
openmmapi/src/RBTorsionForce.cpp
+10
-10
openmmapi/src/State.cpp
openmmapi/src/State.cpp
+3
-3
openmmapi/src/System.cpp
openmmapi/src/System.cpp
+8
-8
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+62
-62
platforms/cuda/src/CudaKernels.h
platforms/cuda/src/CudaKernels.h
+5
-5
platforms/cuda/src/CudaPlatform.cpp
platforms/cuda/src/CudaPlatform.cpp
+2
-2
platforms/cuda/src/CudaStreamFactory.cpp
platforms/cuda/src/CudaStreamFactory.cpp
+3
-3
platforms/cuda/tests/TestCudaCMMotionRemover.cpp
platforms/cuda/tests/TestCudaCMMotionRemover.cpp
+13
-13
platforms/cuda/tests/TestCudaGBSAOBCForceField.cpp
platforms/cuda/tests/TestCudaGBSAOBCForceField.cpp
+17
-17
platforms/cuda/tests/TestCudaLangevinIntegrator.cpp
platforms/cuda/tests/TestCudaLangevinIntegrator.cpp
+24
-24
platforms/cuda/tests/TestCudaNonbondedForce.cpp
platforms/cuda/tests/TestCudaNonbondedForce.cpp
+20
-20
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+102
-102
platforms/reference/src/ReferenceKernels.h
platforms/reference/src/ReferenceKernels.h
+6
-6
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
...forms/reference/tests/TestReferenceAndersenThermostat.cpp
+9
-9
No files found.
openmmapi/src/HarmonicBondForce.cpp
View file @
62c4fd53
...
@@ -39,16 +39,16 @@ using namespace OpenMM;
...
@@ -39,16 +39,16 @@ using namespace OpenMM;
HarmonicBondForce
::
HarmonicBondForce
(
int
numBonds
)
:
bonds
(
numBonds
)
{
HarmonicBondForce
::
HarmonicBondForce
(
int
numBonds
)
:
bonds
(
numBonds
)
{
}
}
void
HarmonicBondForce
::
getBondParameters
(
int
index
,
int
&
atom1
,
int
&
atom
2
,
double
&
length
,
double
&
k
)
const
{
void
HarmonicBondForce
::
getBondParameters
(
int
index
,
int
&
particle1
,
int
&
particle
2
,
double
&
length
,
double
&
k
)
const
{
atom
1
=
bonds
[
index
].
atom
1
;
particle
1
=
bonds
[
index
].
particle
1
;
atom
2
=
bonds
[
index
].
atom
2
;
particle
2
=
bonds
[
index
].
particle
2
;
length
=
bonds
[
index
].
length
;
length
=
bonds
[
index
].
length
;
k
=
bonds
[
index
].
k
;
k
=
bonds
[
index
].
k
;
}
}
void
HarmonicBondForce
::
setBondParameters
(
int
index
,
int
atom1
,
int
atom
2
,
double
length
,
double
k
)
{
void
HarmonicBondForce
::
setBondParameters
(
int
index
,
int
particle1
,
int
particle
2
,
double
length
,
double
k
)
{
bonds
[
index
].
atom1
=
atom
1
;
bonds
[
index
].
particle1
=
particle
1
;
bonds
[
index
].
atom2
=
atom
2
;
bonds
[
index
].
particle2
=
particle
2
;
bonds
[
index
].
length
=
length
;
bonds
[
index
].
length
=
length
;
bonds
[
index
].
k
=
k
;
bonds
[
index
].
k
=
k
;
}
}
...
...
openmmapi/src/NonbondedForce.cpp
View file @
62c4fd53
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
NonbondedForce
::
NonbondedForce
(
int
num
Atom
s
,
int
numNonbonded14
)
:
atoms
(
numAtom
s
),
nb14s
(
numNonbonded14
),
NonbondedForce
::
NonbondedForce
(
int
num
Particle
s
,
int
numNonbonded14
)
:
particles
(
numParticle
s
),
nb14s
(
numNonbonded14
),
nonbondedMethod
(
NoCutoff
),
cutoffDistance
(
1.0
)
{
nonbondedMethod
(
NoCutoff
),
cutoffDistance
(
1.0
)
{
periodicBoxVectors
[
0
]
=
Vec3
(
2
,
0
,
0
);
periodicBoxVectors
[
0
]
=
Vec3
(
2
,
0
,
0
);
periodicBoxVectors
[
1
]
=
Vec3
(
0
,
2
,
0
);
periodicBoxVectors
[
1
]
=
Vec3
(
0
,
2
,
0
);
...
@@ -77,29 +77,29 @@ void NonbondedForce::setPeriodicBoxVectors(Vec3 a, Vec3 b, Vec3 c) {
...
@@ -77,29 +77,29 @@ void NonbondedForce::setPeriodicBoxVectors(Vec3 a, Vec3 b, Vec3 c) {
periodicBoxVectors
[
2
]
=
c
;
periodicBoxVectors
[
2
]
=
c
;
}
}
void
NonbondedForce
::
get
Atom
Parameters
(
int
index
,
double
&
charge
,
double
&
radius
,
double
&
depth
)
const
{
void
NonbondedForce
::
get
Particle
Parameters
(
int
index
,
double
&
charge
,
double
&
radius
,
double
&
depth
)
const
{
charge
=
atom
s
[
index
].
charge
;
charge
=
particle
s
[
index
].
charge
;
radius
=
atom
s
[
index
].
radius
;
radius
=
particle
s
[
index
].
radius
;
depth
=
atom
s
[
index
].
depth
;
depth
=
particle
s
[
index
].
depth
;
}
}
void
NonbondedForce
::
set
Atom
Parameters
(
int
index
,
double
charge
,
double
radius
,
double
depth
)
{
void
NonbondedForce
::
set
Particle
Parameters
(
int
index
,
double
charge
,
double
radius
,
double
depth
)
{
atom
s
[
index
].
charge
=
charge
;
particle
s
[
index
].
charge
=
charge
;
atom
s
[
index
].
radius
=
radius
;
particle
s
[
index
].
radius
=
radius
;
atom
s
[
index
].
depth
=
depth
;
particle
s
[
index
].
depth
=
depth
;
}
}
void
NonbondedForce
::
getNonbonded14Parameters
(
int
index
,
int
&
atom1
,
int
&
atom
2
,
double
&
charge
,
double
&
radius
,
double
&
depth
)
const
{
void
NonbondedForce
::
getNonbonded14Parameters
(
int
index
,
int
&
particle1
,
int
&
particle
2
,
double
&
charge
,
double
&
radius
,
double
&
depth
)
const
{
atom
1
=
nb14s
[
index
].
atom
1
;
particle
1
=
nb14s
[
index
].
particle
1
;
atom
2
=
nb14s
[
index
].
atom
2
;
particle
2
=
nb14s
[
index
].
particle
2
;
charge
=
nb14s
[
index
].
charge
;
charge
=
nb14s
[
index
].
charge
;
radius
=
nb14s
[
index
].
radius
;
radius
=
nb14s
[
index
].
radius
;
depth
=
nb14s
[
index
].
depth
;
depth
=
nb14s
[
index
].
depth
;
}
}
void
NonbondedForce
::
setNonbonded14Parameters
(
int
index
,
int
atom1
,
int
atom
2
,
double
charge
,
double
radius
,
double
depth
)
{
void
NonbondedForce
::
setNonbonded14Parameters
(
int
index
,
int
particle1
,
int
particle
2
,
double
charge
,
double
radius
,
double
depth
)
{
nb14s
[
index
].
atom1
=
atom
1
;
nb14s
[
index
].
particle1
=
particle
1
;
nb14s
[
index
].
atom2
=
atom
2
;
nb14s
[
index
].
particle2
=
particle
2
;
nb14s
[
index
].
charge
=
charge
;
nb14s
[
index
].
charge
=
charge
;
nb14s
[
index
].
radius
=
radius
;
nb14s
[
index
].
radius
=
radius
;
nb14s
[
index
].
depth
=
depth
;
nb14s
[
index
].
depth
=
depth
;
...
...
openmmapi/src/NonbondedForceImpl.cpp
View file @
62c4fd53
...
@@ -50,23 +50,23 @@ void NonbondedForceImpl::initialize(OpenMMContextImpl& context) {
...
@@ -50,23 +50,23 @@ void NonbondedForceImpl::initialize(OpenMMContextImpl& context) {
// See if the system contains a HarmonicBondForce. If so, use it to identify exclusions.
// See if the system contains a HarmonicBondForce. If so, use it to identify exclusions.
System
&
system
=
context
.
getSystem
();
System
&
system
=
context
.
getSystem
();
vector
<
set
<
int
>
>
exclusions
(
owner
.
getNum
Atom
s
());
vector
<
set
<
int
>
>
exclusions
(
owner
.
getNum
Particle
s
());
for
(
int
i
=
0
;
i
<
system
.
getNumForces
();
i
++
)
{
for
(
int
i
=
0
;
i
<
system
.
getNumForces
();
i
++
)
{
if
(
dynamic_cast
<
HarmonicBondForce
*>
(
&
system
.
getForce
(
i
))
!=
NULL
)
{
if
(
dynamic_cast
<
HarmonicBondForce
*>
(
&
system
.
getForce
(
i
))
!=
NULL
)
{
const
HarmonicBondForce
&
force
=
dynamic_cast
<
const
HarmonicBondForce
&>
(
system
.
getForce
(
i
));
const
HarmonicBondForce
&
force
=
dynamic_cast
<
const
HarmonicBondForce
&>
(
system
.
getForce
(
i
));
vector
<
vector
<
int
>
>
bondIndices
(
force
.
getNumBonds
());
vector
<
vector
<
int
>
>
bondIndices
(
force
.
getNumBonds
());
set
<
pair
<
int
,
int
>
>
bonded14set
;
set
<
pair
<
int
,
int
>
>
bonded14set
;
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
++
i
)
{
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
++
i
)
{
int
atom1
,
atom
2
;
int
particle1
,
particle
2
;
double
length
,
k
;
double
length
,
k
;
force
.
getBondParameters
(
i
,
atom1
,
atom
2
,
length
,
k
);
force
.
getBondParameters
(
i
,
particle1
,
particle
2
,
length
,
k
);
bondIndices
[
i
].
push_back
(
atom
1
);
bondIndices
[
i
].
push_back
(
particle
1
);
bondIndices
[
i
].
push_back
(
atom
2
);
bondIndices
[
i
].
push_back
(
particle
2
);
}
}
findExclusions
(
bondIndices
,
exclusions
,
bonded14set
);
findExclusions
(
bondIndices
,
exclusions
,
bonded14set
);
}
}
}
}
dynamic_cast
<
CalcNonbondedForceKernel
&>
(
kernel
.
getImpl
()).
initialize
(
context
.
getSystem
(),
owner
,
exclusions
);
dynamic_cast
<
CalcNonbondedForceKernel
&>
(
kernel
.
getImpl
()).
initialize
(
context
.
getSystem
(),
owner
,
exclusions
);
}
}
void
NonbondedForceImpl
::
calcForces
(
OpenMMContextImpl
&
context
,
Stream
&
forces
)
{
void
NonbondedForceImpl
::
calcForces
(
OpenMMContextImpl
&
context
,
Stream
&
forces
)
{
...
@@ -100,12 +100,12 @@ void NonbondedForceImpl::findExclusions(const vector<vector<int> >& bondIndices,
...
@@ -100,12 +100,12 @@ void NonbondedForceImpl::findExclusions(const vector<vector<int> >& bondIndices,
}
}
}
}
void
NonbondedForceImpl
::
addExclusionsToSet
(
const
vector
<
set
<
int
>
>&
bonded12
,
set
<
int
>&
exclusions
,
int
base
Atom
,
int
from
Atom
,
int
currentLevel
)
const
{
void
NonbondedForceImpl
::
addExclusionsToSet
(
const
vector
<
set
<
int
>
>&
bonded12
,
set
<
int
>&
exclusions
,
int
base
Particle
,
int
from
Particle
,
int
currentLevel
)
const
{
for
(
set
<
int
>::
const_iterator
iter
=
bonded12
[
from
Atom
].
begin
();
iter
!=
bonded12
[
from
Atom
].
end
();
++
iter
)
{
for
(
set
<
int
>::
const_iterator
iter
=
bonded12
[
from
Particle
].
begin
();
iter
!=
bonded12
[
from
Particle
].
end
();
++
iter
)
{
if
(
*
iter
!=
base
Atom
)
if
(
*
iter
!=
base
Particle
)
exclusions
.
insert
(
*
iter
);
exclusions
.
insert
(
*
iter
);
if
(
currentLevel
>
0
)
if
(
currentLevel
>
0
)
addExclusionsToSet
(
bonded12
,
exclusions
,
base
Atom
,
*
iter
,
currentLevel
-
1
);
addExclusionsToSet
(
bonded12
,
exclusions
,
base
Particle
,
*
iter
,
currentLevel
-
1
);
}
}
}
}
openmmapi/src/OpenMMContext.cpp
View file @
62c4fd53
...
@@ -66,7 +66,7 @@ Integrator& OpenMMContext::getIntegrator() {
...
@@ -66,7 +66,7 @@ Integrator& OpenMMContext::getIntegrator() {
}
}
State
OpenMMContext
::
getState
(
int
types
)
const
{
State
OpenMMContext
::
getState
(
int
types
)
const
{
State
state
(
impl
->
getTime
(),
impl
->
getSystem
().
getNum
Atom
s
(),
State
::
DataType
(
types
));
State
state
(
impl
->
getTime
(),
impl
->
getSystem
().
getNum
Particle
s
(),
State
::
DataType
(
types
));
if
(
types
&
State
::
Energy
)
if
(
types
&
State
::
Energy
)
state
.
setEnergy
(
impl
->
calcKineticEnergy
(),
impl
->
calcPotentialEnergy
());
state
.
setEnergy
(
impl
->
calcKineticEnergy
(),
impl
->
calcPotentialEnergy
());
if
(
types
&
State
::
Forces
)
{
if
(
types
&
State
::
Forces
)
{
...
@@ -93,13 +93,13 @@ void OpenMMContext::setTime(double time) {
...
@@ -93,13 +93,13 @@ void OpenMMContext::setTime(double time) {
}
}
void
OpenMMContext
::
setPositions
(
const
vector
<
Vec3
>&
positions
)
{
void
OpenMMContext
::
setPositions
(
const
vector
<
Vec3
>&
positions
)
{
if
((
int
)
positions
.
size
()
!=
impl
->
getSystem
().
getNum
Atom
s
())
if
((
int
)
positions
.
size
()
!=
impl
->
getSystem
().
getNum
Particle
s
())
throw
OpenMMException
(
"Called setPositions() on an OpenMMContext with the wrong number of positions"
);
throw
OpenMMException
(
"Called setPositions() on an OpenMMContext with the wrong number of positions"
);
impl
->
getPositions
().
loadFromArray
(
&
positions
[
0
]);
impl
->
getPositions
().
loadFromArray
(
&
positions
[
0
]);
}
}
void
OpenMMContext
::
setVelocities
(
const
vector
<
Vec3
>&
velocities
)
{
void
OpenMMContext
::
setVelocities
(
const
vector
<
Vec3
>&
velocities
)
{
if
((
int
)
velocities
.
size
()
!=
impl
->
getSystem
().
getNum
Atom
s
())
if
((
int
)
velocities
.
size
()
!=
impl
->
getSystem
().
getNum
Particle
s
())
throw
OpenMMException
(
"Called setVelocities() on an OpenMMContext with the wrong number of velocities"
);
throw
OpenMMException
(
"Called setVelocities() on an OpenMMContext with the wrong number of velocities"
);
impl
->
getVelocities
().
loadFromArray
(
&
velocities
[
0
]);
impl
->
getVelocities
().
loadFromArray
(
&
velocities
[
0
]);
}
}
...
...
openmmapi/src/OpenMMContextImpl.cpp
View file @
62c4fd53
...
@@ -67,16 +67,16 @@ OpenMMContextImpl::OpenMMContextImpl(OpenMMContext& owner, System& system, Integ
...
@@ -67,16 +67,16 @@ OpenMMContextImpl::OpenMMContextImpl(OpenMMContext& owner, System& system, Integ
throw
OpenMMException
(
"Specified a Platform for an OpenMMContext which does not support all required kernels"
);
throw
OpenMMException
(
"Specified a Platform for an OpenMMContext which does not support all required kernels"
);
platform
->
contextCreated
(
*
this
);
platform
->
contextCreated
(
*
this
);
kineticEnergyKernel
=
platform
->
createKernel
(
CalcKineticEnergyKernel
::
Name
(),
*
this
);
kineticEnergyKernel
=
platform
->
createKernel
(
CalcKineticEnergyKernel
::
Name
(),
*
this
);
vector
<
double
>
masses
(
system
.
getNum
Atom
s
());
vector
<
double
>
masses
(
system
.
getNum
Particle
s
());
for
(
size_t
i
=
0
;
i
<
masses
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
masses
.
size
();
++
i
)
masses
[
i
]
=
system
.
get
Atom
Mass
(
i
);
masses
[
i
]
=
system
.
get
Particle
Mass
(
i
);
dynamic_cast
<
CalcKineticEnergyKernel
&>
(
kineticEnergyKernel
.
getImpl
()).
initialize
(
system
);
dynamic_cast
<
CalcKineticEnergyKernel
&>
(
kineticEnergyKernel
.
getImpl
()).
initialize
(
system
);
for
(
size_t
i
=
0
;
i
<
forceImpls
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
forceImpls
.
size
();
++
i
)
forceImpls
[
i
]
->
initialize
(
*
this
);
forceImpls
[
i
]
->
initialize
(
*
this
);
integrator
.
initialize
(
*
this
);
integrator
.
initialize
(
*
this
);
positions
=
platform
->
createStream
(
"
atom
Positions"
,
system
.
getNum
Atom
s
(),
Stream
::
Double3
,
*
this
);
positions
=
platform
->
createStream
(
"
particle
Positions"
,
system
.
getNum
Particle
s
(),
Stream
::
Double3
,
*
this
);
velocities
=
platform
->
createStream
(
"
atom
Velocities"
,
system
.
getNum
Atom
s
(),
Stream
::
Double3
,
*
this
);
velocities
=
platform
->
createStream
(
"
particle
Velocities"
,
system
.
getNum
Particle
s
(),
Stream
::
Double3
,
*
this
);
forces
=
platform
->
createStream
(
"
atom
Forces"
,
system
.
getNum
Atom
s
(),
Stream
::
Double3
,
*
this
);
forces
=
platform
->
createStream
(
"
particle
Forces"
,
system
.
getNum
Particle
s
(),
Stream
::
Double3
,
*
this
);
double
zero
[]
=
{
0.0
,
0.0
,
0.0
};
double
zero
[]
=
{
0.0
,
0.0
,
0.0
};
velocities
.
fillWithValue
(
&
zero
);
velocities
.
fillWithValue
(
&
zero
);
}
}
...
...
openmmapi/src/PeriodicTorsionForce.cpp
View file @
62c4fd53
...
@@ -39,21 +39,21 @@ using namespace OpenMM;
...
@@ -39,21 +39,21 @@ using namespace OpenMM;
PeriodicTorsionForce
::
PeriodicTorsionForce
(
int
numTorsions
)
:
periodicTorsions
(
numTorsions
)
{
PeriodicTorsionForce
::
PeriodicTorsionForce
(
int
numTorsions
)
:
periodicTorsions
(
numTorsions
)
{
}
}
void
PeriodicTorsionForce
::
getTorsionParameters
(
int
index
,
int
&
atom1
,
int
&
atom2
,
int
&
atom3
,
int
&
atom
4
,
int
&
periodicity
,
double
&
phase
,
double
&
k
)
const
{
void
PeriodicTorsionForce
::
getTorsionParameters
(
int
index
,
int
&
particle1
,
int
&
particle2
,
int
&
particle3
,
int
&
particle
4
,
int
&
periodicity
,
double
&
phase
,
double
&
k
)
const
{
atom
1
=
periodicTorsions
[
index
].
atom
1
;
particle
1
=
periodicTorsions
[
index
].
particle
1
;
atom
2
=
periodicTorsions
[
index
].
atom
2
;
particle
2
=
periodicTorsions
[
index
].
particle
2
;
atom
3
=
periodicTorsions
[
index
].
atom
3
;
particle
3
=
periodicTorsions
[
index
].
particle
3
;
atom
4
=
periodicTorsions
[
index
].
atom
4
;
particle
4
=
periodicTorsions
[
index
].
particle
4
;
periodicity
=
periodicTorsions
[
index
].
periodicity
;
periodicity
=
periodicTorsions
[
index
].
periodicity
;
phase
=
periodicTorsions
[
index
].
phase
;
phase
=
periodicTorsions
[
index
].
phase
;
k
=
periodicTorsions
[
index
].
k
;
k
=
periodicTorsions
[
index
].
k
;
}
}
void
PeriodicTorsionForce
::
setTorsionParameters
(
int
index
,
int
atom1
,
int
atom2
,
int
atom3
,
int
atom
4
,
int
periodicity
,
double
phase
,
double
k
)
{
void
PeriodicTorsionForce
::
setTorsionParameters
(
int
index
,
int
particle1
,
int
particle2
,
int
particle3
,
int
particle
4
,
int
periodicity
,
double
phase
,
double
k
)
{
periodicTorsions
[
index
].
atom1
=
atom
1
;
periodicTorsions
[
index
].
particle1
=
particle
1
;
periodicTorsions
[
index
].
atom2
=
atom
2
;
periodicTorsions
[
index
].
particle2
=
particle
2
;
periodicTorsions
[
index
].
atom3
=
atom
3
;
periodicTorsions
[
index
].
particle3
=
particle
3
;
periodicTorsions
[
index
].
atom4
=
atom
4
;
periodicTorsions
[
index
].
particle4
=
particle
4
;
periodicTorsions
[
index
].
periodicity
=
periodicity
;
periodicTorsions
[
index
].
periodicity
=
periodicity
;
periodicTorsions
[
index
].
phase
=
phase
;
periodicTorsions
[
index
].
phase
=
phase
;
periodicTorsions
[
index
].
k
=
k
;
periodicTorsions
[
index
].
k
=
k
;
...
...
openmmapi/src/RBTorsionForce.cpp
View file @
62c4fd53
...
@@ -39,11 +39,11 @@ using namespace OpenMM;
...
@@ -39,11 +39,11 @@ using namespace OpenMM;
RBTorsionForce
::
RBTorsionForce
(
int
numTorsions
)
:
rbTorsions
(
numTorsions
)
{
RBTorsionForce
::
RBTorsionForce
(
int
numTorsions
)
:
rbTorsions
(
numTorsions
)
{
}
}
void
RBTorsionForce
::
getTorsionParameters
(
int
index
,
int
&
atom1
,
int
&
atom2
,
int
&
atom3
,
int
&
atom
4
,
double
&
c0
,
double
&
c1
,
double
&
c2
,
double
&
c3
,
double
&
c4
,
double
&
c5
)
const
{
void
RBTorsionForce
::
getTorsionParameters
(
int
index
,
int
&
particle1
,
int
&
particle2
,
int
&
particle3
,
int
&
particle
4
,
double
&
c0
,
double
&
c1
,
double
&
c2
,
double
&
c3
,
double
&
c4
,
double
&
c5
)
const
{
atom
1
=
rbTorsions
[
index
].
atom
1
;
particle
1
=
rbTorsions
[
index
].
particle
1
;
atom
2
=
rbTorsions
[
index
].
atom
2
;
particle
2
=
rbTorsions
[
index
].
particle
2
;
atom
3
=
rbTorsions
[
index
].
atom
3
;
particle
3
=
rbTorsions
[
index
].
particle
3
;
atom
4
=
rbTorsions
[
index
].
atom
4
;
particle
4
=
rbTorsions
[
index
].
particle
4
;
c0
=
rbTorsions
[
index
].
c
[
0
];
c0
=
rbTorsions
[
index
].
c
[
0
];
c1
=
rbTorsions
[
index
].
c
[
1
];
c1
=
rbTorsions
[
index
].
c
[
1
];
c2
=
rbTorsions
[
index
].
c
[
2
];
c2
=
rbTorsions
[
index
].
c
[
2
];
...
@@ -52,11 +52,11 @@ void RBTorsionForce::getTorsionParameters(int index, int& atom1, int& atom2, int
...
@@ -52,11 +52,11 @@ void RBTorsionForce::getTorsionParameters(int index, int& atom1, int& atom2, int
c5
=
rbTorsions
[
index
].
c
[
5
];
c5
=
rbTorsions
[
index
].
c
[
5
];
}
}
void
RBTorsionForce
::
setTorsionParameters
(
int
index
,
int
atom1
,
int
atom2
,
int
atom3
,
int
atom
4
,
double
c0
,
double
c1
,
double
c2
,
double
c3
,
double
c4
,
double
c5
)
{
void
RBTorsionForce
::
setTorsionParameters
(
int
index
,
int
particle1
,
int
particle2
,
int
particle3
,
int
particle
4
,
double
c0
,
double
c1
,
double
c2
,
double
c3
,
double
c4
,
double
c5
)
{
rbTorsions
[
index
].
atom1
=
atom
1
;
rbTorsions
[
index
].
particle1
=
particle
1
;
rbTorsions
[
index
].
atom2
=
atom
2
;
rbTorsions
[
index
].
particle2
=
particle
2
;
rbTorsions
[
index
].
atom3
=
atom
3
;
rbTorsions
[
index
].
particle3
=
particle
3
;
rbTorsions
[
index
].
atom4
=
atom
4
;
rbTorsions
[
index
].
particle4
=
particle
4
;
rbTorsions
[
index
].
c
[
0
]
=
c0
;
rbTorsions
[
index
].
c
[
0
]
=
c0
;
rbTorsions
[
index
].
c
[
1
]
=
c1
;
rbTorsions
[
index
].
c
[
1
]
=
c1
;
rbTorsions
[
index
].
c
[
2
]
=
c2
;
rbTorsions
[
index
].
c
[
2
]
=
c2
;
...
...
openmmapi/src/State.cpp
View file @
62c4fd53
...
@@ -68,9 +68,9 @@ const map<string, double>& State::getParameters() const {
...
@@ -68,9 +68,9 @@ const map<string, double>& State::getParameters() const {
throw
OpenMMException
(
"Invoked getParameters() on a State which does not contain parameters."
);
throw
OpenMMException
(
"Invoked getParameters() on a State which does not contain parameters."
);
return
parameters
;
return
parameters
;
}
}
State
::
State
(
double
time
,
int
num
Atom
s
,
DataType
types
)
:
types
(
types
),
time
(
time
),
ke
(
0
),
pe
(
0
),
State
::
State
(
double
time
,
int
num
Particle
s
,
DataType
types
)
:
types
(
types
),
time
(
time
),
ke
(
0
),
pe
(
0
),
positions
(
(
types
&
Positions
)
==
0
?
0
:
num
Atom
s
),
velocities
(
(
types
&
Velocities
)
==
0
?
0
:
num
Atom
s
),
positions
(
(
types
&
Positions
)
==
0
?
0
:
num
Particle
s
),
velocities
(
(
types
&
Velocities
)
==
0
?
0
:
num
Particle
s
),
forces
(
(
types
&
Forces
)
==
0
?
0
:
num
Atom
s
)
{
forces
(
(
types
&
Forces
)
==
0
?
0
:
num
Particle
s
)
{
}
}
vector
<
Vec3
>&
State
::
updPositions
()
{
vector
<
Vec3
>&
State
::
updPositions
()
{
return
positions
;
return
positions
;
...
...
openmmapi/src/System.cpp
View file @
62c4fd53
...
@@ -34,8 +34,8 @@
...
@@ -34,8 +34,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
System
::
System
(
int
num
Atom
s
,
int
numConstraints
)
:
masses
(
num
Atom
s
),
constraints
(
numConstraints
),
forces
(
0
)
{
System
::
System
(
int
num
Particle
s
,
int
numConstraints
)
:
masses
(
num
Particle
s
),
constraints
(
numConstraints
),
forces
(
0
)
{
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
masses
[
i
]
=
0.0
;
masses
[
i
]
=
0.0
;
}
}
...
@@ -44,14 +44,14 @@ System::~System() {
...
@@ -44,14 +44,14 @@ System::~System() {
delete
forces
[
i
];
delete
forces
[
i
];
}
}
void
System
::
getConstraintParameters
(
int
index
,
int
&
atom1
,
int
&
atom
2
,
double
&
distance
)
const
{
void
System
::
getConstraintParameters
(
int
index
,
int
&
particle1
,
int
&
particle
2
,
double
&
distance
)
const
{
atom
1
=
constraints
[
index
].
atom
1
;
particle
1
=
constraints
[
index
].
particle
1
;
atom
2
=
constraints
[
index
].
atom
2
;
particle
2
=
constraints
[
index
].
particle
2
;
distance
=
constraints
[
index
].
distance
;
distance
=
constraints
[
index
].
distance
;
}
}
void
System
::
setConstraintParameters
(
int
index
,
int
atom1
,
int
atom
2
,
double
distance
)
{
void
System
::
setConstraintParameters
(
int
index
,
int
particle1
,
int
particle
2
,
double
distance
)
{
constraints
[
index
].
atom1
=
atom
1
;
constraints
[
index
].
particle1
=
particle
1
;
constraints
[
index
].
atom2
=
atom
2
;
constraints
[
index
].
particle2
=
particle
2
;
constraints
[
index
].
distance
=
distance
;
constraints
[
index
].
distance
=
distance
;
}
}
platforms/cuda/src/CudaKernels.cpp
View file @
62c4fd53
...
@@ -86,17 +86,17 @@ void CudaCalcHarmonicBondForceKernel::initialize(const System& system, const Har
...
@@ -86,17 +86,17 @@ void CudaCalcHarmonicBondForceKernel::initialize(const System& system, const Har
data
.
primaryKernel
=
this
;
data
.
primaryKernel
=
this
;
data
.
hasBonds
=
true
;
data
.
hasBonds
=
true
;
numBonds
=
force
.
getNumBonds
();
numBonds
=
force
.
getNumBonds
();
vector
<
int
>
atom
1
(
numBonds
);
vector
<
int
>
particle
1
(
numBonds
);
vector
<
int
>
atom
2
(
numBonds
);
vector
<
int
>
particle
2
(
numBonds
);
vector
<
float
>
length
(
numBonds
);
vector
<
float
>
length
(
numBonds
);
vector
<
float
>
k
(
numBonds
);
vector
<
float
>
k
(
numBonds
);
for
(
int
i
=
0
;
i
<
numBonds
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numBonds
;
i
++
)
{
double
lengthValue
,
kValue
;
double
lengthValue
,
kValue
;
force
.
getBondParameters
(
i
,
atom1
[
i
],
atom
2
[
i
],
lengthValue
,
kValue
);
force
.
getBondParameters
(
i
,
particle1
[
i
],
particle
2
[
i
],
lengthValue
,
kValue
);
length
[
i
]
=
(
float
)
lengthValue
;
length
[
i
]
=
(
float
)
lengthValue
;
k
[
i
]
=
(
float
)
kValue
;
k
[
i
]
=
(
float
)
kValue
;
}
}
gpuSetBondParameters
(
data
.
gpu
,
atom1
,
atom
2
,
length
,
k
);
gpuSetBondParameters
(
data
.
gpu
,
particle1
,
particle
2
,
length
,
k
);
}
}
void
CudaCalcHarmonicBondForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
void
CudaCalcHarmonicBondForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
...
@@ -119,18 +119,18 @@ void CudaCalcHarmonicAngleForceKernel::initialize(const System& system, const Ha
...
@@ -119,18 +119,18 @@ void CudaCalcHarmonicAngleForceKernel::initialize(const System& system, const Ha
data
.
hasAngles
=
true
;
data
.
hasAngles
=
true
;
numAngles
=
force
.
getNumAngles
();
numAngles
=
force
.
getNumAngles
();
const
float
RadiansToDegrees
=
180.0
/
3.14159265
;
const
float
RadiansToDegrees
=
180.0
/
3.14159265
;
vector
<
int
>
atom
1
(
numAngles
);
vector
<
int
>
particle
1
(
numAngles
);
vector
<
int
>
atom
2
(
numAngles
);
vector
<
int
>
particle
2
(
numAngles
);
vector
<
int
>
atom
3
(
numAngles
);
vector
<
int
>
particle
3
(
numAngles
);
vector
<
float
>
angle
(
numAngles
);
vector
<
float
>
angle
(
numAngles
);
vector
<
float
>
k
(
numAngles
);
vector
<
float
>
k
(
numAngles
);
for
(
int
i
=
0
;
i
<
numAngles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numAngles
;
i
++
)
{
double
angleValue
,
kValue
;
double
angleValue
,
kValue
;
force
.
getAngleParameters
(
i
,
atom1
[
i
],
atom2
[
i
],
atom
3
[
i
],
angleValue
,
kValue
);
force
.
getAngleParameters
(
i
,
particle1
[
i
],
particle2
[
i
],
particle
3
[
i
],
angleValue
,
kValue
);
angle
[
i
]
=
(
float
)
(
angleValue
*
RadiansToDegrees
);
angle
[
i
]
=
(
float
)
(
angleValue
*
RadiansToDegrees
);
k
[
i
]
=
(
float
)
kValue
;
k
[
i
]
=
(
float
)
kValue
;
}
}
gpuSetBondAngleParameters
(
data
.
gpu
,
atom1
,
atom2
,
atom
3
,
angle
,
k
);
gpuSetBondAngleParameters
(
data
.
gpu
,
particle1
,
particle2
,
particle
3
,
angle
,
k
);
}
}
void
CudaCalcHarmonicAngleForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
void
CudaCalcHarmonicAngleForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
...
@@ -153,20 +153,20 @@ void CudaCalcPeriodicTorsionForceKernel::initialize(const System& system, const
...
@@ -153,20 +153,20 @@ void CudaCalcPeriodicTorsionForceKernel::initialize(const System& system, const
data
.
hasPeriodicTorsions
=
true
;
data
.
hasPeriodicTorsions
=
true
;
numTorsions
=
force
.
getNumTorsions
();
numTorsions
=
force
.
getNumTorsions
();
const
float
RadiansToDegrees
=
180.0
/
3.14159265
;
const
float
RadiansToDegrees
=
180.0
/
3.14159265
;
vector
<
int
>
atom
1
(
numTorsions
);
vector
<
int
>
particle
1
(
numTorsions
);
vector
<
int
>
atom
2
(
numTorsions
);
vector
<
int
>
particle
2
(
numTorsions
);
vector
<
int
>
atom
3
(
numTorsions
);
vector
<
int
>
particle
3
(
numTorsions
);
vector
<
int
>
atom
4
(
numTorsions
);
vector
<
int
>
particle
4
(
numTorsions
);
vector
<
float
>
k
(
numTorsions
);
vector
<
float
>
k
(
numTorsions
);
vector
<
float
>
phase
(
numTorsions
);
vector
<
float
>
phase
(
numTorsions
);
vector
<
int
>
periodicity
(
numTorsions
);
vector
<
int
>
periodicity
(
numTorsions
);
for
(
int
i
=
0
;
i
<
numTorsions
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numTorsions
;
i
++
)
{
double
kValue
,
phaseValue
;
double
kValue
,
phaseValue
;
force
.
getTorsionParameters
(
i
,
atom1
[
i
],
atom2
[
i
],
atom3
[
i
],
atom
4
[
i
],
periodicity
[
i
],
phaseValue
,
kValue
);
force
.
getTorsionParameters
(
i
,
particle1
[
i
],
particle2
[
i
],
particle3
[
i
],
particle
4
[
i
],
periodicity
[
i
],
phaseValue
,
kValue
);
k
[
i
]
=
(
float
)
kValue
;
k
[
i
]
=
(
float
)
kValue
;
phase
[
i
]
=
(
float
)
(
phaseValue
*
RadiansToDegrees
);
phase
[
i
]
=
(
float
)
(
phaseValue
*
RadiansToDegrees
);
}
}
gpuSetDihedralParameters
(
data
.
gpu
,
atom1
,
atom2
,
atom3
,
atom
4
,
k
,
phase
,
periodicity
);
gpuSetDihedralParameters
(
data
.
gpu
,
particle1
,
particle2
,
particle3
,
particle
4
,
k
,
phase
,
periodicity
);
}
}
void
CudaCalcPeriodicTorsionForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
void
CudaCalcPeriodicTorsionForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
...
@@ -188,10 +188,10 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
...
@@ -188,10 +188,10 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
data
.
primaryKernel
=
this
;
data
.
primaryKernel
=
this
;
data
.
hasRB
=
true
;
data
.
hasRB
=
true
;
numTorsions
=
force
.
getNumTorsions
();
numTorsions
=
force
.
getNumTorsions
();
vector
<
int
>
atom
1
(
numTorsions
);
vector
<
int
>
particle
1
(
numTorsions
);
vector
<
int
>
atom
2
(
numTorsions
);
vector
<
int
>
particle
2
(
numTorsions
);
vector
<
int
>
atom
3
(
numTorsions
);
vector
<
int
>
particle
3
(
numTorsions
);
vector
<
int
>
atom
4
(
numTorsions
);
vector
<
int
>
particle
4
(
numTorsions
);
vector
<
float
>
c0
(
numTorsions
);
vector
<
float
>
c0
(
numTorsions
);
vector
<
float
>
c1
(
numTorsions
);
vector
<
float
>
c1
(
numTorsions
);
vector
<
float
>
c2
(
numTorsions
);
vector
<
float
>
c2
(
numTorsions
);
...
@@ -200,7 +200,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
...
@@ -200,7 +200,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
vector
<
float
>
c5
(
numTorsions
);
vector
<
float
>
c5
(
numTorsions
);
for
(
int
i
=
0
;
i
<
numTorsions
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numTorsions
;
i
++
)
{
double
c
[
6
];
double
c
[
6
];
force
.
getTorsionParameters
(
i
,
atom1
[
i
],
atom2
[
i
],
atom3
[
i
],
atom
4
[
i
],
c
[
0
],
c
[
1
],
c
[
2
],
c
[
3
],
c
[
4
],
c
[
5
]);
force
.
getTorsionParameters
(
i
,
particle1
[
i
],
particle2
[
i
],
particle3
[
i
],
particle
4
[
i
],
c
[
0
],
c
[
1
],
c
[
2
],
c
[
3
],
c
[
4
],
c
[
5
]);
c0
[
i
]
=
(
float
)
c
[
0
];
c0
[
i
]
=
(
float
)
c
[
0
];
c1
[
i
]
=
(
float
)
c
[
1
];
c1
[
i
]
=
(
float
)
c
[
1
];
c2
[
i
]
=
(
float
)
c
[
2
];
c2
[
i
]
=
(
float
)
c
[
2
];
...
@@ -208,7 +208,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
...
@@ -208,7 +208,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
c4
[
i
]
=
(
float
)
c
[
4
];
c4
[
i
]
=
(
float
)
c
[
4
];
c5
[
i
]
=
(
float
)
c
[
5
];
c5
[
i
]
=
(
float
)
c
[
5
];
}
}
gpuSetRbDihedralParameters
(
data
.
gpu
,
atom1
,
atom2
,
atom3
,
atom
4
,
c0
,
c1
,
c2
,
c3
,
c4
,
c5
);
gpuSetRbDihedralParameters
(
data
.
gpu
,
particle1
,
particle2
,
particle3
,
particle
4
,
c0
,
c1
,
c2
,
c3
,
c4
,
c5
);
}
}
void
CudaCalcRBTorsionForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
void
CudaCalcRBTorsionForceKernel
::
executeForces
(
OpenMMContextImpl
&
context
)
{
...
@@ -229,51 +229,51 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
...
@@ -229,51 +229,51 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
if
(
data
.
primaryKernel
==
NULL
)
if
(
data
.
primaryKernel
==
NULL
)
data
.
primaryKernel
=
this
;
data
.
primaryKernel
=
this
;
data
.
hasNonbonded
=
true
;
data
.
hasNonbonded
=
true
;
num
Atom
s
=
force
.
getNum
Atom
s
();
num
Particle
s
=
force
.
getNum
Particle
s
();
num14
=
force
.
getNumNonbonded14
();
num14
=
force
.
getNumNonbonded14
();
_gpuContext
*
gpu
=
data
.
gpu
;
_gpuContext
*
gpu
=
data
.
gpu
;
// Initialize nonbonded interactions.
// Initialize nonbonded interactions.
{
{
vector
<
int
>
atom
(
numAtom
s
);
vector
<
int
>
particle
(
numParticle
s
);
vector
<
float
>
c6
(
num
Atom
s
);
vector
<
float
>
c6
(
num
Particle
s
);
vector
<
float
>
c12
(
num
Atom
s
);
vector
<
float
>
c12
(
num
Particle
s
);
vector
<
float
>
q
(
num
Atom
s
);
vector
<
float
>
q
(
num
Particle
s
);
vector
<
char
>
symbol
;
vector
<
char
>
symbol
;
vector
<
vector
<
int
>
>
exclusionList
(
num
Atom
s
);
vector
<
vector
<
int
>
>
exclusionList
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
i
++
)
{
double
charge
,
radius
,
depth
;
double
charge
,
radius
,
depth
;
force
.
get
Atom
Parameters
(
i
,
charge
,
radius
,
depth
);
force
.
get
Particle
Parameters
(
i
,
charge
,
radius
,
depth
);
atom
[
i
]
=
i
;
particle
[
i
]
=
i
;
q
[
i
]
=
(
float
)
charge
;
q
[
i
]
=
(
float
)
charge
;
c6
[
i
]
=
(
float
)
(
4
*
depth
*
pow
(
radius
,
6.0
));
c6
[
i
]
=
(
float
)
(
4
*
depth
*
pow
(
radius
,
6.0
));
c12
[
i
]
=
(
float
)
(
4
*
depth
*
pow
(
radius
,
12.0
));
c12
[
i
]
=
(
float
)
(
4
*
depth
*
pow
(
radius
,
12.0
));
exclusionList
[
i
]
=
vector
<
int
>
(
exclusions
[
i
].
begin
(),
exclusions
[
i
].
end
());
exclusionList
[
i
]
=
vector
<
int
>
(
exclusions
[
i
].
begin
(),
exclusions
[
i
].
end
());
exclusionList
[
i
].
push_back
(
i
);
exclusionList
[
i
].
push_back
(
i
);
}
}
gpuSetCoulombParameters
(
gpu
,
138.935485
f
,
atom
,
c6
,
c12
,
q
,
symbol
,
exclusionList
);
gpuSetCoulombParameters
(
gpu
,
138.935485
f
,
particle
,
c6
,
c12
,
q
,
symbol
,
exclusionList
);
}
}
// Initialize 1-4 nonbonded interactions.
// Initialize 1-4 nonbonded interactions.
{
{
vector
<
int
>
atom
1
(
num14
);
vector
<
int
>
particle
1
(
num14
);
vector
<
int
>
atom
2
(
num14
);
vector
<
int
>
particle
2
(
num14
);
vector
<
float
>
c6
(
num14
);
vector
<
float
>
c6
(
num14
);
vector
<
float
>
c12
(
num14
);
vector
<
float
>
c12
(
num14
);
vector
<
float
>
q1
(
num14
);
vector
<
float
>
q1
(
num14
);
vector
<
float
>
q2
(
num14
);
vector
<
float
>
q2
(
num14
);
for
(
int
i
=
0
;
i
<
num14
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num14
;
i
++
)
{
double
charge
,
sig
,
eps
;
double
charge
,
sig
,
eps
;
force
.
getNonbonded14Parameters
(
i
,
atom1
[
i
],
atom
2
[
i
],
charge
,
sig
,
eps
);
force
.
getNonbonded14Parameters
(
i
,
particle1
[
i
],
particle
2
[
i
],
charge
,
sig
,
eps
);
c6
[
i
]
=
(
float
)
(
4
*
eps
*
pow
(
sig
,
6.0
));
c6
[
i
]
=
(
float
)
(
4
*
eps
*
pow
(
sig
,
6.0
));
c12
[
i
]
=
(
float
)
(
4
*
eps
*
pow
(
sig
,
12.0
));
c12
[
i
]
=
(
float
)
(
4
*
eps
*
pow
(
sig
,
12.0
));
float
q
=
(
float
)
std
::
sqrt
(
charge
);
float
q
=
(
float
)
std
::
sqrt
(
charge
);
q1
[
i
]
=
q
;
q1
[
i
]
=
q
;
q2
[
i
]
=
q
;
q2
[
i
]
=
q
;
}
}
gpuSetLJ14Parameters
(
gpu
,
138.935485
f
,
1.0
f
,
atom1
,
atom
2
,
c6
,
c12
,
q1
,
q2
);
gpuSetLJ14Parameters
(
gpu
,
138.935485
f
,
1.0
f
,
particle1
,
particle
2
,
c6
,
c12
,
q1
,
q2
);
}
}
}
}
...
@@ -292,19 +292,19 @@ CudaCalcGBSAOBCForceFieldKernel::~CudaCalcGBSAOBCForceFieldKernel() {
...
@@ -292,19 +292,19 @@ CudaCalcGBSAOBCForceFieldKernel::~CudaCalcGBSAOBCForceFieldKernel() {
}
}
void
CudaCalcGBSAOBCForceFieldKernel
::
initialize
(
const
System
&
system
,
const
GBSAOBCForceField
&
force
)
{
void
CudaCalcGBSAOBCForceFieldKernel
::
initialize
(
const
System
&
system
,
const
GBSAOBCForceField
&
force
)
{
int
num
Atom
s
=
system
.
getNum
Atom
s
();
int
num
Particle
s
=
system
.
getNum
Particle
s
();
_gpuContext
*
gpu
=
data
.
gpu
;
_gpuContext
*
gpu
=
data
.
gpu
;
vector
<
int
>
atom
(
numAtom
s
);
vector
<
int
>
particle
(
numParticle
s
);
vector
<
float
>
radius
(
num
Atom
s
);
vector
<
float
>
radius
(
num
Particle
s
);
vector
<
float
>
scale
(
num
Atom
s
);
vector
<
float
>
scale
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
i
++
)
{
double
charge
,
atom
Radius
,
scalingFactor
;
double
charge
,
particle
Radius
,
scalingFactor
;
force
.
get
Atom
Parameters
(
i
,
charge
,
atom
Radius
,
scalingFactor
);
force
.
get
Particle
Parameters
(
i
,
charge
,
particle
Radius
,
scalingFactor
);
atom
[
i
]
=
i
;
particle
[
i
]
=
i
;
radius
[
i
]
=
(
float
)
atom
Radius
;
radius
[
i
]
=
(
float
)
particle
Radius
;
scale
[
i
]
=
(
float
)
scalingFactor
;
scale
[
i
]
=
(
float
)
scalingFactor
;
}
}
gpuSetObcParameters
(
gpu
,
force
.
getSoluteDielectric
(),
force
.
getSolventDielectric
(),
atom
,
radius
,
scale
);
gpuSetObcParameters
(
gpu
,
force
.
getSoluteDielectric
(),
force
.
getSolventDielectric
(),
particle
,
radius
,
scale
);
data
.
useOBC
=
true
;
data
.
useOBC
=
true
;
}
}
...
@@ -331,31 +331,31 @@ void CudaIntegrateLangevinStepKernel::initialize(const System& system, const Lan
...
@@ -331,31 +331,31 @@ void CudaIntegrateLangevinStepKernel::initialize(const System& system, const Lan
// Set masses.
// Set masses.
_gpuContext
*
gpu
=
data
.
gpu
;
_gpuContext
*
gpu
=
data
.
gpu
;
int
num
Atom
s
=
system
.
getNum
Atom
s
();
int
num
Particle
s
=
system
.
getNum
Particle
s
();
vector
<
float
>
mass
(
num
Atom
s
);
vector
<
float
>
mass
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
i
++
)
for
(
int
i
=
0
;
i
<
num
Particle
s
;
i
++
)
mass
[
i
]
=
(
float
)
system
.
get
Atom
Mass
(
i
);
mass
[
i
]
=
(
float
)
system
.
get
Particle
Mass
(
i
);
gpuSetMass
(
gpu
,
mass
);
gpuSetMass
(
gpu
,
mass
);
// Set constraints.
// Set constraints.
int
numConstraints
=
system
.
getNumConstraints
();
int
numConstraints
=
system
.
getNumConstraints
();
vector
<
int
>
atom
1
(
numConstraints
);
vector
<
int
>
particle
1
(
numConstraints
);
vector
<
int
>
atom
2
(
numConstraints
);
vector
<
int
>
particle
2
(
numConstraints
);
vector
<
float
>
distance
(
numConstraints
);
vector
<
float
>
distance
(
numConstraints
);
vector
<
float
>
invMass1
(
numConstraints
);
vector
<
float
>
invMass1
(
numConstraints
);
vector
<
float
>
invMass2
(
numConstraints
);
vector
<
float
>
invMass2
(
numConstraints
);
for
(
int
i
=
0
;
i
<
numConstraints
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numConstraints
;
i
++
)
{
int
atom1Index
,
atom
2Index
;
int
particle1Index
,
particle
2Index
;
double
constraintDistance
;
double
constraintDistance
;
system
.
getConstraintParameters
(
i
,
atom1Index
,
atom
2Index
,
constraintDistance
);
system
.
getConstraintParameters
(
i
,
particle1Index
,
particle
2Index
,
constraintDistance
);
atom1
[
i
]
=
atom
1Index
;
particle1
[
i
]
=
particle
1Index
;
atom2
[
i
]
=
atom
2Index
;
particle2
[
i
]
=
particle
2Index
;
distance
[
i
]
=
(
float
)
constraintDistance
;
distance
[
i
]
=
(
float
)
constraintDistance
;
invMass1
[
i
]
=
1.0
f
/
mass
[
atom
1Index
];
invMass1
[
i
]
=
1.0
f
/
mass
[
particle
1Index
];
invMass2
[
i
]
=
1.0
f
/
mass
[
atom
2Index
];
invMass2
[
i
]
=
1.0
f
/
mass
[
particle
2Index
];
}
}
gpuSetShakeParameters
(
gpu
,
atom1
,
atom
2
,
distance
,
invMass1
,
invMass2
);
gpuSetShakeParameters
(
gpu
,
particle1
,
particle
2
,
distance
,
invMass1
,
invMass2
);
// Initialize any terms that haven't already been handled by a Force.
// Initialize any terms that haven't already been handled by a Force.
...
@@ -433,10 +433,10 @@ void CudaIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, const
...
@@ -433,10 +433,10 @@ void CudaIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, const
//}
//}
void
CudaCalcKineticEnergyKernel
::
initialize
(
const
System
&
system
)
{
void
CudaCalcKineticEnergyKernel
::
initialize
(
const
System
&
system
)
{
int
num
Atom
s
=
system
.
getNum
Atom
s
();
int
num
Particle
s
=
system
.
getNum
Particle
s
();
masses
.
resize
(
num
Atom
s
);
masses
.
resize
(
num
Particle
s
);
for
(
size_t
i
=
0
;
i
<
num
Atom
s
;
++
i
)
for
(
size_t
i
=
0
;
i
<
num
Particle
s
;
++
i
)
masses
[
i
]
=
system
.
get
Atom
Mass
(
i
);
masses
[
i
]
=
system
.
get
Particle
Mass
(
i
);
}
}
double
CudaCalcKineticEnergyKernel
::
execute
(
OpenMMContextImpl
&
context
)
{
double
CudaCalcKineticEnergyKernel
::
execute
(
OpenMMContextImpl
&
context
)
{
...
...
platforms/cuda/src/CudaKernels.h
View file @
62c4fd53
...
@@ -195,7 +195,7 @@ public:
...
@@ -195,7 +195,7 @@ public:
*
*
* @param system the System this kernel will be applied to
* @param system the System this kernel will be applied to
* @param force the NonbondedForce this kernel will be used for
* @param force the NonbondedForce this kernel will be used for
* @param exclusions the i'th element lists the indices of all
atom
s with which the i'th
atom
should not interact through
* @param exclusions the i'th element lists the indices of all
particle
s with which the i'th
particle
should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation.
* the standard nonbonded calculation.
*/
*/
...
@@ -215,7 +215,7 @@ public:
...
@@ -215,7 +215,7 @@ public:
double
executeEnergy
(
OpenMMContextImpl
&
context
);
double
executeEnergy
(
OpenMMContextImpl
&
context
);
private:
private:
CudaPlatform
::
PlatformData
&
data
;
CudaPlatform
::
PlatformData
&
data
;
int
num
Atom
s
,
num14
;
int
num
Particle
s
,
num14
;
System
&
system
;
System
&
system
;
};
};
...
@@ -293,7 +293,7 @@ public:
...
@@ -293,7 +293,7 @@ public:
}
}
~
CudaIntegrateLangevinStepKernel
();
~
CudaIntegrateLangevinStepKernel
();
/**
/**
* Initialize the kernel, setting up the
atomic
masses.
* Initialize the kernel, setting up the
particle
masses.
*
*
* @param system the System this kernel will be applied to
* @param system the System this kernel will be applied to
* @param integrator the LangevinIntegrator this kernel will be used for
* @param integrator the LangevinIntegrator this kernel will be used for
...
@@ -345,7 +345,7 @@ private:
...
@@ -345,7 +345,7 @@ private:
//};
//};
//
//
///**
///**
// * This kernel is invoked by AndersenThermostat at the start of each time step to adjust the
atom
velocities.
// * This kernel is invoked by AndersenThermostat at the start of each time step to adjust the
particle
velocities.
// */
// */
//class CudaApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel {
//class CudaApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel {
//public:
//public:
...
@@ -401,7 +401,7 @@ public:
...
@@ -401,7 +401,7 @@ public:
CudaRemoveCMMotionKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CudaPlatform
::
PlatformData
&
data
)
:
RemoveCMMotionKernel
(
name
,
platform
),
data
(
data
)
{
CudaRemoveCMMotionKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CudaPlatform
::
PlatformData
&
data
)
:
RemoveCMMotionKernel
(
name
,
platform
),
data
(
data
)
{
}
}
/**
/**
* Initialize the kernel, setting up the
atomic
masses.
* Initialize the kernel, setting up the
particle
masses.
*
*
* @param system the System this kernel will be applied to
* @param system the System this kernel will be applied to
* @param force the CMMotionRemover this kernel will be used for
* @param force the CMMotionRemover this kernel will be used for
...
...
platforms/cuda/src/CudaPlatform.cpp
View file @
62c4fd53
...
@@ -63,8 +63,8 @@ const StreamFactory& CudaPlatform::getDefaultStreamFactory() const {
...
@@ -63,8 +63,8 @@ const StreamFactory& CudaPlatform::getDefaultStreamFactory() const {
}
}
void
CudaPlatform
::
contextCreated
(
OpenMMContextImpl
&
context
)
const
{
void
CudaPlatform
::
contextCreated
(
OpenMMContextImpl
&
context
)
const
{
int
num
Atom
s
=
context
.
getSystem
().
getNum
Atom
s
();
int
num
Particle
s
=
context
.
getSystem
().
getNum
Particle
s
();
_gpuContext
*
gpu
=
(
_gpuContext
*
)
gpuInit
(
num
Atom
s
);
_gpuContext
*
gpu
=
(
_gpuContext
*
)
gpuInit
(
num
Particle
s
);
context
.
setPlatformData
(
new
PlatformData
(
gpu
));
context
.
setPlatformData
(
new
PlatformData
(
gpu
));
}
}
...
...
platforms/cuda/src/CudaStreamFactory.cpp
View file @
62c4fd53
...
@@ -39,17 +39,17 @@
...
@@ -39,17 +39,17 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
StreamImpl
*
CudaStreamFactory
::
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
{
StreamImpl
*
CudaStreamFactory
::
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
{
if
(
name
==
"
atom
Positions"
)
{
if
(
name
==
"
particle
Positions"
)
{
CudaPlatform
::
PlatformData
&
data
=
*
static_cast
<
CudaPlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
CudaPlatform
::
PlatformData
&
data
=
*
static_cast
<
CudaPlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
float
padding
[]
=
{
100000.0
f
,
100000.0
f
,
100000.0
f
,
0.2
f
};
float
padding
[]
=
{
100000.0
f
,
100000.0
f
,
100000.0
f
,
0.2
f
};
return
new
CudaStreamImpl
<
float4
>
(
name
,
size
,
type
,
platform
,
data
.
gpu
->
psPosq4
,
4
,
padding
);
return
new
CudaStreamImpl
<
float4
>
(
name
,
size
,
type
,
platform
,
data
.
gpu
->
psPosq4
,
4
,
padding
);
}
}
if
(
name
==
"
atom
Velocities"
)
{
if
(
name
==
"
particle
Velocities"
)
{
CudaPlatform
::
PlatformData
&
data
=
*
static_cast
<
CudaPlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
CudaPlatform
::
PlatformData
&
data
=
*
static_cast
<
CudaPlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
float
padding
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
};
float
padding
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
};
return
new
CudaStreamImpl
<
float4
>
(
name
,
size
,
type
,
platform
,
data
.
gpu
->
psVelm4
,
4
,
padding
);
return
new
CudaStreamImpl
<
float4
>
(
name
,
size
,
type
,
platform
,
data
.
gpu
->
psVelm4
,
4
,
padding
);
}
}
if
(
name
==
"
atom
Forces"
)
{
if
(
name
==
"
particle
Forces"
)
{
CudaPlatform
::
PlatformData
&
data
=
*
static_cast
<
CudaPlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
CudaPlatform
::
PlatformData
&
data
=
*
static_cast
<
CudaPlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
float
padding
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
};
float
padding
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
};
return
new
CudaStreamImpl
<
float4
>
(
name
,
size
,
type
,
platform
,
data
.
gpu
->
psForce4
,
4
,
padding
);
return
new
CudaStreamImpl
<
float4
>
(
name
,
size
,
type
,
platform
,
data
.
gpu
->
psForce4
,
4
,
padding
);
...
...
platforms/cuda/tests/TestCudaCMMotionRemover.cpp
View file @
62c4fd53
...
@@ -51,35 +51,35 @@ using namespace std;
...
@@ -51,35 +51,35 @@ using namespace std;
Vec3
calcCM
(
const
vector
<
Vec3
>&
values
,
System
&
system
)
{
Vec3
calcCM
(
const
vector
<
Vec3
>&
values
,
System
&
system
)
{
Vec3
cm
;
Vec3
cm
;
for
(
int
j
=
0
;
j
<
system
.
getNum
Atom
s
();
++
j
)
{
for
(
int
j
=
0
;
j
<
system
.
getNum
Particle
s
();
++
j
)
{
cm
[
0
]
+=
values
[
j
][
0
]
*
system
.
get
Atom
Mass
(
j
);
cm
[
0
]
+=
values
[
j
][
0
]
*
system
.
get
Particle
Mass
(
j
);
cm
[
1
]
+=
values
[
j
][
1
]
*
system
.
get
Atom
Mass
(
j
);
cm
[
1
]
+=
values
[
j
][
1
]
*
system
.
get
Particle
Mass
(
j
);
cm
[
2
]
+=
values
[
j
][
2
]
*
system
.
get
Atom
Mass
(
j
);
cm
[
2
]
+=
values
[
j
][
2
]
*
system
.
get
Particle
Mass
(
j
);
}
}
return
cm
;
return
cm
;
}
}
void
testMotionRemoval
()
{
void
testMotionRemoval
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
num
Atom
s
,
0
);
System
system
(
num
Particle
s
,
0
);
LangevinIntegrator
integrator
(
0.0
,
1e-5
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
1e-5
,
0.01
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
1
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
(
1
);
bonds
->
setBondParameters
(
0
,
2
,
3
,
2.0
,
0.5
);
bonds
->
setBondParameters
(
0
,
2
,
3
,
2.0
,
0.5
);
system
.
addForce
(
bonds
);
system
.
addForce
(
bonds
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
num
Atom
s
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
i
+
1
);
system
.
set
Particle
Mass
(
i
,
i
+
1
);
nonbonded
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
nonbonded
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
CMMotionRemover
*
remover
=
new
CMMotionRemover
();
CMMotionRemover
*
remover
=
new
CMMotionRemover
();
system
.
addForce
(
remover
);
system
.
addForce
(
remover
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
vector
<
Vec3
>
velocities
(
num
Atom
s
);
vector
<
Vec3
>
velocities
(
num
Particle
s
);
init_gen_rand
(
0
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
}
}
...
...
platforms/cuda/tests/TestCudaGBSAOBCForceField.cpp
View file @
62c4fd53
...
@@ -50,15 +50,15 @@ using namespace std;
...
@@ -50,15 +50,15 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSingle
Atom
()
{
void
testSingle
Particle
()
{
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
1
,
0
);
System
system
(
1
,
0
);
system
.
set
Atom
Mass
(
0
,
2.0
);
system
.
set
Particle
Mass
(
0
,
2.0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
GBSAOBCForceField
*
forceField
=
new
GBSAOBCForceField
(
1
);
GBSAOBCForceField
*
forceField
=
new
GBSAOBCForceField
(
1
);
NonbondedForce
*
standard
=
new
NonbondedForce
(
1
,
0
);
NonbondedForce
*
standard
=
new
NonbondedForce
(
1
,
0
);
forceField
->
set
Atom
Parameters
(
0
,
0.5
,
0.15
,
1
);
forceField
->
set
Particle
Parameters
(
0
,
0.5
,
0.15
,
1
);
standard
->
set
Atom
Parameters
(
0
,
0.5
,
1
,
0
);
standard
->
set
Particle
Parameters
(
0
,
0.5
,
1
,
0
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
system
.
addForce
(
standard
);
system
.
addForce
(
standard
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
...
@@ -76,25 +76,25 @@ void testSingleAtom() {
...
@@ -76,25 +76,25 @@ void testSingleAtom() {
void
testForce
()
{
void
testForce
()
{
CudaPlatform
platform
;
CudaPlatform
platform
;
const
int
num
Atom
s
=
10
;
const
int
num
Particle
s
=
10
;
System
system
(
num
Atom
s
,
0
);
System
system
(
num
Particle
s
,
0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
GBSAOBCForceField
*
forceField
=
new
GBSAOBCForceField
(
num
Atom
s
);
GBSAOBCForceField
*
forceField
=
new
GBSAOBCForceField
(
num
Particle
s
);
NonbondedForce
*
standard
=
new
NonbondedForce
(
num
Atom
s
,
0
);
NonbondedForce
*
standard
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
double
charge
=
i
%
2
==
0
?
-
1
:
1
;
double
charge
=
i
%
2
==
0
?
-
1
:
1
;
forceField
->
set
Atom
Parameters
(
i
,
charge
,
0.15
,
1
);
forceField
->
set
Particle
Parameters
(
i
,
charge
,
0.15
,
1
);
standard
->
set
Atom
Parameters
(
i
,
charge
,
1
,
0
);
standard
->
set
Particle
Parameters
(
i
,
charge
,
1
,
0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
system
.
addForce
(
standard
);
system
.
addForce
(
standard
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
// Set random positions for all the
atom
s.
// Set random positions for all the
particle
s.
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
init_gen_rand
(
0
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
positions
[
i
]
=
Vec3
(
5.0
*
genrand_real2
(),
5.0
*
genrand_real2
(),
5.0
*
genrand_real2
());
positions
[
i
]
=
Vec3
(
5.0
*
genrand_real2
(),
5.0
*
genrand_real2
(),
5.0
*
genrand_real2
());
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -102,14 +102,14 @@ void testForce() {
...
@@ -102,14 +102,14 @@ void testForce() {
// Take a small step in the direction of the energy gradient.
// Take a small step in the direction of the energy gradient.
double
norm
=
0.0
;
double
norm
=
0.0
;
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
Vec3
f
=
state
.
getForces
()[
i
];
Vec3
f
=
state
.
getForces
()[
i
];
norm
+=
f
[
0
]
*
f
[
0
]
+
f
[
1
]
*
f
[
1
]
+
f
[
2
]
*
f
[
2
];
norm
+=
f
[
0
]
*
f
[
0
]
+
f
[
1
]
*
f
[
1
]
+
f
[
2
]
*
f
[
2
];
}
}
norm
=
std
::
sqrt
(
norm
);
norm
=
std
::
sqrt
(
norm
);
const
double
delta
=
1e-3
;
const
double
delta
=
1e-3
;
double
step
=
delta
/
norm
;
double
step
=
delta
/
norm
;
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
Vec3
p
=
positions
[
i
];
Vec3
p
=
positions
[
i
];
Vec3
f
=
state
.
getForces
()[
i
];
Vec3
f
=
state
.
getForces
()[
i
];
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
...
@@ -124,7 +124,7 @@ void testForce() {
...
@@ -124,7 +124,7 @@ void testForce() {
int
main
()
{
int
main
()
{
try
{
try
{
testSingle
Atom
();
testSingle
Particle
();
testForce
();
testForce
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
...
...
platforms/cuda/tests/TestCudaLangevinIntegrator.cpp
View file @
62c4fd53
...
@@ -53,8 +53,8 @@ const double TOL = 1e-5;
...
@@ -53,8 +53,8 @@ const double TOL = 1e-5;
void
testSingleBond
()
{
void
testSingleBond
()
{
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
2
,
0
);
System
system
(
2
,
0
);
system
.
set
Atom
Mass
(
0
,
2.0
);
system
.
set
Particle
Mass
(
0
,
2.0
);
system
.
set
Atom
Mass
(
1
,
2.0
);
system
.
set
Particle
Mass
(
1
,
2.0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
(
1
);
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
(
1
);
forceField
->
setBondParameters
(
0
,
0
,
1
,
1.5
,
1
);
forceField
->
setBondParameters
(
0
,
0
,
1
,
1.5
,
1
);
...
@@ -95,20 +95,20 @@ void testSingleBond() {
...
@@ -95,20 +95,20 @@ void testSingleBond() {
}
}
void
testTemperature
()
{
void
testTemperature
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
num
Atom
s
,
0
);
System
system
(
num
Particle
s
,
0
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Atom
s
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
2.0
);
system
.
set
Particle
Mass
(
i
,
2.0
);
forceField
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
...
@@ -125,30 +125,30 @@ void testTemperature() {
...
@@ -125,30 +125,30 @@ void testTemperature() {
integrator
.
step
(
1
);
integrator
.
step
(
1
);
}
}
ke
/=
1000
;
ke
/=
1000
;
double
expected
=
0.5
*
num
Atom
s
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
num
Particle
s
*
3
*
BOLTZ
*
temp
;
ASSERT_EQUAL_TOL
(
expected
,
ke
,
3
*
expected
/
std
::
sqrt
(
1000.0
));
ASSERT_EQUAL_TOL
(
expected
,
ke
,
3
*
expected
/
std
::
sqrt
(
1000.0
));
}
}
void
testConstraints
()
{
void
testConstraints
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
int
numConstraints
=
4
;
const
int
numConstraints
=
4
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
(
num
Atom
s
,
numConstraints
);
System
system
(
num
Particle
s
,
numConstraints
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Atom
s
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
10.0
);
system
.
set
Particle
Mass
(
i
,
10.0
);
forceField
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
0.2
:
-
0.2
),
0.5
,
5.0
);
}
}
for
(
int
i
=
0
;
i
<
numConstraints
;
++
i
)
for
(
int
i
=
0
;
i
<
numConstraints
;
++
i
)
system
.
setConstraintParameters
(
i
,
2
*
i
,
2
*
i
+
1
,
1.0
);
system
.
setConstraintParameters
(
i
,
2
*
i
,
2
*
i
+
1
,
1.0
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
vector
<
Vec3
>
velocities
(
num
Atom
s
);
vector
<
Vec3
>
velocities
(
num
Particle
s
);
init_gen_rand
(
0
);
init_gen_rand
(
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
positions
[
i
]
=
Vec3
(
i
/
2
,
(
i
+
1
)
/
2
,
0
);
positions
[
i
]
=
Vec3
(
i
/
2
,
(
i
+
1
)
/
2
,
0
);
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
velocities
[
i
]
=
Vec3
(
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
,
genrand_real2
()
-
0.5
);
}
}
...
@@ -160,11 +160,11 @@ void testConstraints() {
...
@@ -160,11 +160,11 @@ void testConstraints() {
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Positions
);
State
state
=
context
.
getState
(
State
::
Positions
);
for
(
int
j
=
0
;
j
<
numConstraints
;
++
j
)
{
for
(
int
j
=
0
;
j
<
numConstraints
;
++
j
)
{
int
atom1
,
atom
2
;
int
particle1
,
particle
2
;
double
distance
;
double
distance
;
system
.
getConstraintParameters
(
j
,
atom1
,
atom
2
,
distance
);
system
.
getConstraintParameters
(
j
,
particle1
,
particle
2
,
distance
);
Vec3
p1
=
state
.
getPositions
()[
atom
1
];
Vec3
p1
=
state
.
getPositions
()[
particle
1
];
Vec3
p2
=
state
.
getPositions
()[
atom
2
];
Vec3
p2
=
state
.
getPositions
()[
particle
2
];
double
dist
=
std
::
sqrt
((
p1
[
0
]
-
p2
[
0
])
*
(
p1
[
0
]
-
p2
[
0
])
+
(
p1
[
1
]
-
p2
[
1
])
*
(
p1
[
1
]
-
p2
[
1
])
+
(
p1
[
2
]
-
p2
[
2
])
*
(
p1
[
2
]
-
p2
[
2
]));
double
dist
=
std
::
sqrt
((
p1
[
0
]
-
p2
[
0
])
*
(
p1
[
0
]
-
p2
[
0
])
+
(
p1
[
1
]
-
p2
[
1
])
*
(
p1
[
1
]
-
p2
[
1
])
+
(
p1
[
2
]
-
p2
[
2
])
*
(
p1
[
2
]
-
p2
[
2
]));
ASSERT_EQUAL_TOL
(
distance
,
dist
,
2e-4
);
ASSERT_EQUAL_TOL
(
distance
,
dist
,
2e-4
);
}
}
...
...
platforms/cuda/tests/TestCudaNonbondedForce.cpp
View file @
62c4fd53
...
@@ -54,8 +54,8 @@ void testCoulomb() {
...
@@ -54,8 +54,8 @@ void testCoulomb() {
System
system
(
2
,
0
);
System
system
(
2
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
forceField
->
set
Atom
Parameters
(
0
,
0.5
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
0
,
0.5
,
1
,
0
);
forceField
->
set
Atom
Parameters
(
1
,
-
1.5
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
-
1.5
,
1
,
0
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
vector
<
Vec3
>
positions
(
2
);
...
@@ -75,8 +75,8 @@ void testLJ() {
...
@@ -75,8 +75,8 @@ void testLJ() {
System
system
(
2
,
0
);
System
system
(
2
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
2
,
0
);
forceField
->
set
Atom
Parameters
(
0
,
0
,
1.2
,
1
);
forceField
->
set
Particle
Parameters
(
0
,
0
,
1.2
,
1
);
forceField
->
set
Atom
Parameters
(
1
,
0
,
1.4
,
2
);
forceField
->
set
Particle
Parameters
(
1
,
0
,
1.4
,
2
);
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
vector
<
Vec3
>
positions
(
2
);
...
@@ -112,11 +112,11 @@ void testExclusionsAnd14() {
...
@@ -112,11 +112,11 @@ void testExclusionsAnd14() {
vector
<
Vec3
>
positions
(
5
);
vector
<
Vec3
>
positions
(
5
);
const
double
r
=
1.0
;
const
double
r
=
1.0
;
for
(
int
j
=
0
;
j
<
5
;
++
j
)
{
for
(
int
j
=
0
;
j
<
5
;
++
j
)
{
nonbonded
->
set
Atom
Parameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
j
,
0
,
1.5
,
0
);
positions
[
j
]
=
Vec3
(
0
,
j
,
0
);
positions
[
j
]
=
Vec3
(
0
,
j
,
0
);
}
}
nonbonded
->
set
Atom
Parameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
set
Atom
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
...
@@ -142,8 +142,8 @@ void testExclusionsAnd14() {
...
@@ -142,8 +142,8 @@ void testExclusionsAnd14() {
// Test Coulomb forces
// Test Coulomb forces
nonbonded
->
set
Atom
Parameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
set
Atom
Parameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
OpenMMContext
context2
(
system
,
integrator
,
platform
);
OpenMMContext
context2
(
system
,
integrator
,
platform
);
...
@@ -171,9 +171,9 @@ void testCutoff() {
...
@@ -171,9 +171,9 @@ void testCutoff() {
System
system
(
3
,
0
);
System
system
(
3
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
3
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
3
,
0
);
forceField
->
set
Atom
Parameters
(
0
,
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
0
,
1.0
,
1
,
0
);
forceField
->
set
Atom
Parameters
(
1
,
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
1
,
1.0
,
1
,
0
);
forceField
->
set
Atom
Parameters
(
2
,
1.0
,
1
,
0
);
forceField
->
set
Particle
Parameters
(
2
,
1.0
,
1
,
0
);
forceField
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
forceField
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
const
double
cutoff
=
2.9
;
const
double
cutoff
=
2.9
;
forceField
->
setCutoffDistance
(
cutoff
);
forceField
->
setCutoffDistance
(
cutoff
);
...
@@ -225,10 +225,10 @@ void testCutoff14() {
...
@@ -225,10 +225,10 @@ void testCutoff14() {
// Test LJ forces
// Test LJ forces
nonbonded
->
set
Atom
Parameters
(
0
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
0
,
0
,
1.5
,
1
);
for
(
int
j
=
1
;
j
<
5
;
++
j
)
for
(
int
j
=
1
;
j
<
5
;
++
j
)
nonbonded
->
set
Atom
Parameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
j
,
0
,
1.5
,
0
);
nonbonded
->
set
Atom
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
set
Particle
Parameters
(
i
,
0
,
1.5
,
1
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0.0
);
context
.
reinitialize
();
context
.
reinitialize
();
...
@@ -255,8 +255,8 @@ void testCutoff14() {
...
@@ -255,8 +255,8 @@ void testCutoff14() {
// Test Coulomb forces
// Test Coulomb forces
const
double
q
=
0.7
;
const
double
q
=
0.7
;
nonbonded
->
set
Atom
Parameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
0
,
q
,
1.5
,
0
);
nonbonded
->
set
Atom
Parameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
set
Particle
Parameters
(
i
,
q
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
i
==
3
?
q
*
q
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
0
,
0
,
3
,
i
==
3
?
q
*
q
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
setNonbonded14Parameters
(
1
,
1
,
4
,
0
,
1.5
,
0
);
context
.
reinitialize
();
context
.
reinitialize
();
...
@@ -290,9 +290,9 @@ void testPeriodic() {
...
@@ -290,9 +290,9 @@ void testPeriodic() {
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
bonds
->
setBondParameters
(
0
,
0
,
1
,
1
,
0
);
system
.
addForce
(
bonds
);
system
.
addForce
(
bonds
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
3
,
0
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
(
3
,
0
);
nonbonded
->
set
Atom
Parameters
(
0
,
1.0
,
1
,
0
);
nonbonded
->
set
Particle
Parameters
(
0
,
1.0
,
1
,
0
);
nonbonded
->
set
Atom
Parameters
(
1
,
1.0
,
1
,
0
);
nonbonded
->
set
Particle
Parameters
(
1
,
1.0
,
1
,
0
);
nonbonded
->
set
Atom
Parameters
(
2
,
1.0
,
1
,
0
);
nonbonded
->
set
Particle
Parameters
(
2
,
1.0
,
1
,
0
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
const
double
cutoff
=
2.0
;
const
double
cutoff
=
2.0
;
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
62c4fd53
This diff is collapsed.
Click to expand it.
platforms/reference/src/ReferenceKernels.h
View file @
62c4fd53
...
@@ -194,7 +194,7 @@ public:
...
@@ -194,7 +194,7 @@ public:
*
*
* @param system the System this kernel will be applied to
* @param system the System this kernel will be applied to
* @param force the NonbondedForce this kernel will be used for
* @param force the NonbondedForce this kernel will be used for
* @param exclusions the i'th element lists the indices of all
atom
s with which the i'th
atom
should not interact through
* @param exclusions the i'th element lists the indices of all
particle
s with which the i'th
particle
should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation.
* the standard nonbonded calculation.
*/
*/
...
@@ -213,9 +213,9 @@ public:
...
@@ -213,9 +213,9 @@ public:
*/
*/
double
executeEnergy
(
OpenMMContextImpl
&
context
);
double
executeEnergy
(
OpenMMContextImpl
&
context
);
private:
private:
int
num
Atom
s
,
num14
;
int
num
Particle
s
,
num14
;
int
**
exclusionArray
,
**
bonded14IndexArray
;
int
**
exclusionArray
,
**
bonded14IndexArray
;
RealOpenMM
**
atom
ParamArray
,
**
bonded14ParamArray
;
RealOpenMM
**
particle
ParamArray
,
**
bonded14ParamArray
;
RealOpenMM
nonbondedCutoff
,
periodicBoxSize
[
3
];
RealOpenMM
nonbondedCutoff
,
periodicBoxSize
[
3
];
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
...
@@ -298,7 +298,7 @@ public:
...
@@ -298,7 +298,7 @@ public:
}
}
~
ReferenceIntegrateLangevinStepKernel
();
~
ReferenceIntegrateLangevinStepKernel
();
/**
/**
* Initialize the kernel, setting up the
atomic
masses.
* Initialize the kernel, setting up the
particle
masses.
*
*
* @param system the System this kernel will be applied to
* @param system the System this kernel will be applied to
* @param integrator the LangevinIntegrator this kernel will be used for
* @param integrator the LangevinIntegrator this kernel will be used for
...
@@ -355,7 +355,7 @@ private:
...
@@ -355,7 +355,7 @@ private:
};
};
/**
/**
* This kernel is invoked by AndersenThermostat at the start of each time step to adjust the
atom
velocities.
* This kernel is invoked by AndersenThermostat at the start of each time step to adjust the
particle
velocities.
*/
*/
class
ReferenceApplyAndersenThermostatKernel
:
public
ApplyAndersenThermostatKernel
{
class
ReferenceApplyAndersenThermostatKernel
:
public
ApplyAndersenThermostatKernel
{
public:
public:
...
@@ -411,7 +411,7 @@ public:
...
@@ -411,7 +411,7 @@ public:
ReferenceRemoveCMMotionKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
RemoveCMMotionKernel
(
name
,
platform
)
{
ReferenceRemoveCMMotionKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
RemoveCMMotionKernel
(
name
,
platform
)
{
}
}
/**
/**
* Initialize the kernel, setting up the
atomic
masses.
* Initialize the kernel, setting up the
particle
masses.
*
*
* @param system the System this kernel will be applied to
* @param system the System this kernel will be applied to
* @param force the CMMotionRemover this kernel will be used for
* @param force the CMMotionRemover this kernel will be used for
...
...
platforms/reference/tests/TestReferenceAndersenThermostat.cpp
View file @
62c4fd53
...
@@ -49,23 +49,23 @@ using namespace OpenMM;
...
@@ -49,23 +49,23 @@ using namespace OpenMM;
using
namespace
std
;
using
namespace
std
;
void
testTemperature
()
{
void
testTemperature
()
{
const
int
num
Atom
s
=
8
;
const
int
num
Particle
s
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
(
num
Atom
s
,
0
);
System
system
(
num
Particle
s
,
0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Atom
s
,
0
);
NonbondedForce
*
forceField
=
new
NonbondedForce
(
num
Particle
s
,
0
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
{
system
.
set
Atom
Mass
(
i
,
2.0
);
system
.
set
Particle
Mass
(
i
,
2.0
);
forceField
->
set
Atom
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
forceField
->
set
Particle
Parameters
(
i
,
(
i
%
2
==
0
?
1.0
:
-
1.0
),
1.0
,
5.0
);
}
}
system
.
addForce
(
forceField
);
system
.
addForce
(
forceField
);
AndersenThermostat
*
thermstat
=
new
AndersenThermostat
(
temp
,
collisionFreq
);
AndersenThermostat
*
thermstat
=
new
AndersenThermostat
(
temp
,
collisionFreq
);
system
.
addForce
(
thermstat
);
system
.
addForce
(
thermstat
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
OpenMMContext
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
num
Atom
s
);
vector
<
Vec3
>
positions
(
num
Particle
s
);
for
(
int
i
=
0
;
i
<
num
Atom
s
;
++
i
)
for
(
int
i
=
0
;
i
<
num
Particle
s
;
++
i
)
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
positions
[
i
]
=
Vec3
((
i
%
2
==
0
?
2
:
-
2
),
(
i
%
4
<
2
?
2
:
-
2
),
(
i
<
4
?
2
:
-
2
));
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
...
@@ -82,7 +82,7 @@ void testTemperature() {
...
@@ -82,7 +82,7 @@ void testTemperature() {
integrator
.
step
(
1
);
integrator
.
step
(
1
);
}
}
ke
/=
1000
;
ke
/=
1000
;
double
expected
=
0.5
*
num
Atom
s
*
3
*
BOLTZ
*
temp
;
double
expected
=
0.5
*
num
Particle
s
*
3
*
BOLTZ
*
temp
;
ASSERT_EQUAL_TOL
(
expected
,
ke
,
3
*
expected
/
std
::
sqrt
(
1000.0
));
ASSERT_EQUAL_TOL
(
expected
,
ke
,
3
*
expected
/
std
::
sqrt
(
1000.0
));
}
}
...
...
Prev
1
2
3
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