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
d1c6b858
Commit
d1c6b858
authored
Oct 10, 2018
by
Peter Eastman
Browse files
Fixed error in parameter offsets for nonbonded exceptions
parent
76780eef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
12 deletions
+28
-12
platforms/cpu/src/CpuKernels.cpp
platforms/cpu/src/CpuKernels.cpp
+5
-2
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+5
-2
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+5
-2
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+5
-2
tests/TestNonbondedForce.h
tests/TestNonbondedForce.h
+8
-4
No files found.
platforms/cpu/src/CpuKernels.cpp
View file @
d1c6b858
...
@@ -505,14 +505,17 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
...
@@ -505,14 +505,17 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
numParticles
=
force
.
getNumParticles
();
numParticles
=
force
.
getNumParticles
();
exclusions
.
resize
(
numParticles
);
exclusions
.
resize
(
numParticles
);
vector
<
int
>
nb14s
;
vector
<
int
>
nb14s
;
map
<
int
,
int
>
nb14Index
;
for
(
int
i
=
0
;
i
<
force
.
getNumExceptions
();
i
++
)
{
for
(
int
i
=
0
;
i
<
force
.
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
double
chargeProd
,
sigma
,
epsilon
;
force
.
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
force
.
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
exclusions
[
particle1
].
insert
(
particle2
);
exclusions
[
particle1
].
insert
(
particle2
);
exclusions
[
particle2
].
insert
(
particle1
);
exclusions
[
particle2
].
insert
(
particle1
);
if
(
chargeProd
!=
0.0
||
epsilon
!=
0.0
||
exceptionsWithOffsets
.
find
(
i
)
!=
exceptionsWithOffsets
.
end
())
if
(
chargeProd
!=
0.0
||
epsilon
!=
0.0
||
exceptionsWithOffsets
.
find
(
i
)
!=
exceptionsWithOffsets
.
end
())
{
nb14Index
[
i
]
=
nb14s
.
size
();
nb14s
.
push_back
(
i
);
nb14s
.
push_back
(
i
);
}
}
}
// Record the particle parameters.
// Record the particle parameters.
...
@@ -572,7 +575,7 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
...
@@ -572,7 +575,7 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
}
}
else
else
paramIndex
=
paramPos
-
paramNames
.
begin
();
paramIndex
=
paramPos
-
paramNames
.
begin
();
exceptionParamOffsets
[
exception
].
push_back
(
make_tuple
(
charge
,
sigma
,
epsilon
,
paramIndex
));
exceptionParamOffsets
[
nb14Index
[
exception
]
]
.
push_back
(
make_tuple
(
charge
,
sigma
,
epsilon
,
paramIndex
));
}
}
paramValues
.
resize
(
paramNames
.
size
(),
0.0
);
paramValues
.
resize
(
paramNames
.
size
(),
0.0
);
...
...
platforms/cuda/src/CudaKernels.cpp
View file @
d1c6b858
...
@@ -1584,13 +1584,16 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
...
@@ -1584,13 +1584,16 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
}
}
vector<pair<int, int> > exclusions;
vector<pair<int, int> > exclusions;
vector<int> exceptions;
vector<int> exceptions;
map<int, int> exceptionIndex;
for (int i = 0; i < force.getNumExceptions(); i++) {
for (int i = 0; i < force.getNumExceptions(); i++) {
int particle1, particle2;
int particle1, particle2;
double chargeProd, sigma, epsilon;
double chargeProd, sigma, epsilon;
force.getExceptionParameters(i, particle1, particle2, chargeProd, sigma, epsilon);
force.getExceptionParameters(i, particle1, particle2, chargeProd, sigma, epsilon);
exclusions.push_back(pair<int, int>(particle1, particle2));
exclusions.push_back(pair<int, int>(particle1, particle2));
if (chargeProd != 0.0 || epsilon != 0.0 || exceptionsWithOffsets.find(i) != exceptionsWithOffsets.end())
if (chargeProd != 0.0 || epsilon != 0.0 || exceptionsWithOffsets.find(i) != exceptionsWithOffsets.end()) {
exceptionIndex[i] = exceptions.size();
exceptions.push_back(i);
exceptions.push_back(i);
}
}
}
// Initialize nonbonded interactions.
// Initialize nonbonded interactions.
...
@@ -2033,7 +2036,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
...
@@ -2033,7 +2036,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
}
}
else
else
paramIndex = paramPos-paramNames.begin();
paramIndex = paramPos-paramNames.begin();
exceptionOffsetVec[exception].push_back(make_float4(charge, sigma, epsilon, paramIndex));
exceptionOffsetVec[exception
Index[exception]
].push_back(make_float4(charge, sigma, epsilon, paramIndex));
}
}
paramValues.resize(paramNames.size(), 0.0);
paramValues.resize(paramNames.size(), 0.0);
particleParamOffsets.initialize<float4>(cu, max(force.getNumParticleParameterOffsets(), 1), "particleParamOffsets");
particleParamOffsets.initialize<float4>(cu, max(force.getNumParticleParameterOffsets(), 1), "particleParamOffsets");
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
d1c6b858
...
@@ -1576,13 +1576,16 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
...
@@ -1576,13 +1576,16 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
}
}
vector<pair<int, int> > exclusions;
vector<pair<int, int> > exclusions;
vector<int> exceptions;
vector<int> exceptions;
map<int, int> exceptionIndex;
for (int i = 0; i < force.getNumExceptions(); i++) {
for (int i = 0; i < force.getNumExceptions(); i++) {
int particle1, particle2;
int particle1, particle2;
double chargeProd, sigma, epsilon;
double chargeProd, sigma, epsilon;
force.getExceptionParameters(i, particle1, particle2, chargeProd, sigma, epsilon);
force.getExceptionParameters(i, particle1, particle2, chargeProd, sigma, epsilon);
exclusions.push_back(pair<int, int>(particle1, particle2));
exclusions.push_back(pair<int, int>(particle1, particle2));
if (chargeProd != 0.0 || epsilon != 0.0 || exceptionsWithOffsets.find(i) != exceptionsWithOffsets.end())
if (chargeProd != 0.0 || epsilon != 0.0 || exceptionsWithOffsets.find(i) != exceptionsWithOffsets.end()) {
exceptionIndex[i] = exceptions.size();
exceptions.push_back(i);
exceptions.push_back(i);
}
}
}
// Initialize nonbonded interactions.
// Initialize nonbonded interactions.
...
@@ -1963,7 +1966,7 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
...
@@ -1963,7 +1966,7 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
}
}
else
else
paramIndex = paramPos-paramNames.begin();
paramIndex = paramPos-paramNames.begin();
exceptionOffsetVec[exception].push_back(mm_float4(charge, sigma, epsilon, paramIndex));
exceptionOffsetVec[exception
Index[exception]
].push_back(mm_float4(charge, sigma, epsilon, paramIndex));
}
}
paramValues.resize(paramNames.size(), 0.0);
paramValues.resize(paramNames.size(), 0.0);
particleParamOffsets.initialize<mm_float4>(cl, max(force.getNumParticleParameterOffsets(), 1), "particleParamOffsets");
particleParamOffsets.initialize<mm_float4>(cl, max(force.getNumParticleParameterOffsets(), 1), "particleParamOffsets");
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
d1c6b858
...
@@ -877,14 +877,17 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
...
@@ -877,14 +877,17 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
numParticles
=
force
.
getNumParticles
();
numParticles
=
force
.
getNumParticles
();
exclusions
.
resize
(
numParticles
);
exclusions
.
resize
(
numParticles
);
vector
<
int
>
nb14s
;
vector
<
int
>
nb14s
;
map
<
int
,
int
>
nb14Index
;
for
(
int
i
=
0
;
i
<
force
.
getNumExceptions
();
i
++
)
{
for
(
int
i
=
0
;
i
<
force
.
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
double
chargeProd
,
sigma
,
epsilon
;
force
.
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
force
.
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
exclusions
[
particle1
].
insert
(
particle2
);
exclusions
[
particle1
].
insert
(
particle2
);
exclusions
[
particle2
].
insert
(
particle1
);
exclusions
[
particle2
].
insert
(
particle1
);
if
(
chargeProd
!=
0.0
||
epsilon
!=
0.0
||
exceptionsWithOffsets
.
find
(
i
)
!=
exceptionsWithOffsets
.
end
())
if
(
chargeProd
!=
0.0
||
epsilon
!=
0.0
||
exceptionsWithOffsets
.
find
(
i
)
!=
exceptionsWithOffsets
.
end
())
{
nb14Index
[
i
]
=
nb14s
.
size
();
nb14s
.
push_back
(
i
);
nb14s
.
push_back
(
i
);
}
}
}
// Build the arrays.
// Build the arrays.
...
@@ -916,7 +919,7 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
...
@@ -916,7 +919,7 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
int
exception
;
int
exception
;
double
charge
,
sigma
,
epsilon
;
double
charge
,
sigma
,
epsilon
;
force
.
getExceptionParameterOffset
(
i
,
param
,
exception
,
charge
,
sigma
,
epsilon
);
force
.
getExceptionParameterOffset
(
i
,
param
,
exception
,
charge
,
sigma
,
epsilon
);
exceptionParamOffsets
[
make_pair
(
param
,
exception
)]
=
{
charge
,
sigma
,
epsilon
};
exceptionParamOffsets
[
make_pair
(
param
,
nb14Index
[
exception
]
)]
=
{
charge
,
sigma
,
epsilon
};
}
}
nonbondedMethod
=
CalcNonbondedForceKernel
::
NonbondedMethod
(
force
.
getNonbondedMethod
());
nonbondedMethod
=
CalcNonbondedForceKernel
::
NonbondedMethod
(
force
.
getNonbondedMethod
());
nonbondedCutoff
=
force
.
getCutoffDistance
();
nonbondedCutoff
=
force
.
getCutoffDistance
();
...
...
tests/TestNonbondedForce.h
View file @
d1c6b858
...
@@ -743,8 +743,9 @@ void testParameterOffsets() {
...
@@ -743,8 +743,9 @@ void testParameterOffsets() {
force
->
addParticle
(
1.0
,
0.5
,
0.6
);
force
->
addParticle
(
1.0
,
0.5
,
0.6
);
force
->
addParticle
(
-
1.0
,
2.0
,
0.7
);
force
->
addParticle
(
-
1.0
,
2.0
,
0.7
);
force
->
addParticle
(
0.5
,
2.0
,
0.8
);
force
->
addParticle
(
0.5
,
2.0
,
0.8
);
force
->
addException
(
0
,
1
,
1.0
,
1.5
,
1
.0
);
force
->
addException
(
0
,
3
,
0.0
,
1.0
,
0
.0
);
force
->
addException
(
2
,
3
,
0.5
,
1.0
,
1.5
);
force
->
addException
(
2
,
3
,
0.5
,
1.0
,
1.5
);
force
->
addException
(
0
,
1
,
1.0
,
1.5
,
1.0
);
force
->
addGlobalParameter
(
"p1"
,
0.0
);
force
->
addGlobalParameter
(
"p1"
,
0.0
);
force
->
addGlobalParameter
(
"p2"
,
1.0
);
force
->
addGlobalParameter
(
"p2"
,
1.0
);
force
->
addParticleParameterOffset
(
"p1"
,
0
,
3.0
,
0.5
,
0.5
);
force
->
addParticleParameterOffset
(
"p1"
,
0
,
3.0
,
0.5
,
0.5
);
...
@@ -775,12 +776,15 @@ void testParameterOffsets() {
...
@@ -775,12 +776,15 @@ void testParameterOffsets() {
pairSigma
[
i
][
j
]
=
0.5
*
(
particleSigma
[
i
]
+
particleSigma
[
j
]);
pairSigma
[
i
][
j
]
=
0.5
*
(
particleSigma
[
i
]
+
particleSigma
[
j
]);
pairEpsilon
[
i
][
j
]
=
sqrt
(
particleEpsilon
[
i
]
*
particleEpsilon
[
j
]);
pairEpsilon
[
i
][
j
]
=
sqrt
(
particleEpsilon
[
i
]
*
particleEpsilon
[
j
]);
}
}
pairChargeProd
[
0
][
1
]
=
1
.0
;
pairChargeProd
[
0
][
3
]
=
0
.0
;
pairSigma
[
0
][
1
]
=
1.
5
;
pairSigma
[
0
][
3
]
=
1.
0
;
pairEpsilon
[
0
][
1
]
=
1
.0
;
pairEpsilon
[
0
][
3
]
=
0
.0
;
pairChargeProd
[
2
][
3
]
=
0.5
+
0.5
*
0.5
;
pairChargeProd
[
2
][
3
]
=
0.5
+
0.5
*
0.5
;
pairSigma
[
2
][
3
]
=
1.0
+
0.5
*
0.5
;
pairSigma
[
2
][
3
]
=
1.0
+
0.5
*
0.5
;
pairEpsilon
[
2
][
3
]
=
1.5
+
1.5
*
0.5
;
pairEpsilon
[
2
][
3
]
=
1.5
+
1.5
*
0.5
;
pairChargeProd
[
0
][
1
]
=
1.0
;
pairSigma
[
0
][
1
]
=
1.5
;
pairEpsilon
[
0
][
1
]
=
1.0
;
// Compute the expected energy.
// Compute the expected energy.
...
...
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