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
1d7b9307
Commit
1d7b9307
authored
Oct 31, 2015
by
John Chodera (MSKCC)
Browse files
Validation of interaction groups now occurs during kernel initialization.
parent
7323ad80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
openmmapi/src/CustomNonbondedForce.cpp
openmmapi/src/CustomNonbondedForce.cpp
+2
-2
openmmapi/src/CustomNonbondedForceImpl.cpp
openmmapi/src/CustomNonbondedForceImpl.cpp
+20
-0
No files found.
openmmapi/src/CustomNonbondedForce.cpp
View file @
1d7b9307
...
@@ -263,9 +263,9 @@ void CustomNonbondedForce::setFunctionParameters(int index, const std::string& n
...
@@ -263,9 +263,9 @@ void CustomNonbondedForce::setFunctionParameters(int index, const std::string& n
int
CustomNonbondedForce
::
addInteractionGroup
(
const
std
::
set
<
int
>&
set1
,
const
std
::
set
<
int
>&
set2
)
{
int
CustomNonbondedForce
::
addInteractionGroup
(
const
std
::
set
<
int
>&
set1
,
const
std
::
set
<
int
>&
set2
)
{
for
(
set
<
int
>::
iterator
it
=
set1
.
begin
();
it
!=
set1
.
end
();
++
it
)
for
(
set
<
int
>::
iterator
it
=
set1
.
begin
();
it
!=
set1
.
end
();
++
it
)
ASSERT
_VALID_INDEX
(
*
it
,
particles
);
ASSERT
(
*
it
>=
0
);
for
(
set
<
int
>::
iterator
it
=
set2
.
begin
();
it
!=
set2
.
end
();
++
it
)
for
(
set
<
int
>::
iterator
it
=
set2
.
begin
();
it
!=
set2
.
end
();
++
it
)
ASSERT
_VALID_INDEX
(
*
it
,
particles
);
ASSERT
(
*
it
>=
0
);
interactionGroups
.
push_back
(
InteractionGroupInfo
(
set1
,
set2
));
interactionGroups
.
push_back
(
InteractionGroupInfo
(
set1
,
set2
));
return
interactionGroups
.
size
()
-
1
;
return
interactionGroups
.
size
()
-
1
;
}
}
...
...
openmmapi/src/CustomNonbondedForceImpl.cpp
View file @
1d7b9307
...
@@ -111,6 +111,26 @@ void CustomNonbondedForceImpl::initialize(ContextImpl& context) {
...
@@ -111,6 +111,26 @@ void CustomNonbondedForceImpl::initialize(ContextImpl& context) {
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
throw
OpenMMException
(
"CustomNonbondedForce: The cutoff distance cannot be greater than half the periodic box size."
);
throw
OpenMMException
(
"CustomNonbondedForce: The cutoff distance cannot be greater than half the periodic box size."
);
}
}
// Check that all interaction groups only specify particles that have been defined.
for
(
int
group
=
0
;
group
<
owner
.
getNumInteractionGroups
();
group
++
)
{
set
<
int
>
set1
,
set2
;
owner
.
getInteractionGroupParameters
(
group
,
set1
,
set2
);
for
(
set
<
int
>::
iterator
it
=
set1
.
begin
();
it
!=
set1
.
end
();
++
it
)
if
((
*
it
<
0
)
||
(
*
it
>=
owner
.
getNumParticles
()))
{
stringstream
msg
;
msg
<<
"CustomNonbondedForce: Interaction group "
<<
group
<<
" set1 contains a particle index ("
<<
*
it
<<
") "
<<
"not present in system ("
<<
owner
.
getNumParticles
()
<<
" particles)."
;
throw
OpenMMException
(
msg
.
str
());
}
for
(
set
<
int
>::
iterator
it
=
set2
.
begin
();
it
!=
set2
.
end
();
++
it
)
if
((
*
it
<
0
)
||
(
*
it
>=
owner
.
getNumParticles
()))
{
stringstream
msg
;
msg
<<
"CustomNonbondedForce: Interaction group "
<<
group
<<
" set2 contains a particle index ("
<<
*
it
<<
") "
<<
"not present in system ("
<<
owner
.
getNumParticles
()
<<
" particles)."
;
throw
OpenMMException
(
msg
.
str
());
}
}
kernel
.
getAs
<
CalcCustomNonbondedForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomNonbondedForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
}
...
...
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