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
efa678e0
"docs-source/vscode:/vscode.git/clone" did not exist on "3645e1eeb7cea37bc7af1291e0fd672a85d49db9"
Commit
efa678e0
authored
Dec 21, 2018
by
Peter Eastman
Browse files
Fixed error using 2D tabulated function with CustomHbondForce
parent
813772e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
openmmapi/src/CustomHbondForceImpl.cpp
openmmapi/src/CustomHbondForceImpl.cpp
+3
-3
tests/TestCustomHbondForce.h
tests/TestCustomHbondForce.h
+31
-1
No files found.
openmmapi/src/CustomHbondForceImpl.cpp
View file @
efa678e0
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
8
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -230,9 +230,9 @@ ExpressionTreeNode CustomHbondForceImpl::replaceFunctions(const ExpressionTreeNo
const
Operation
&
op
=
node
.
getOperation
();
if
(
op
.
getId
()
==
Operation
::
VARIABLE
&&
variables
.
find
(
op
.
getName
())
==
variables
.
end
())
throw
OpenMMException
(
"CustomHBondForce: Unknown variable '"
+
op
.
getName
()
+
"'"
);
if
(
op
.
getId
()
!=
Operation
::
CUSTOM
||
op
.
getN
umArguments
()
<
2
)
if
(
op
.
getId
()
!=
Operation
::
CUSTOM
||
(
op
.
getN
ame
()
!=
"distance"
&&
op
.
getName
()
!=
"angle"
&&
op
.
getName
()
!=
"dihedral"
)
)
{
// This is not a
n
angle or dihedral, so process its children.
// This is not a
distance,
angle
,
or dihedral, so process its children.
vector
<
ExpressionTreeNode
>
children
;
for
(
auto
&
child
:
node
.
getChildren
())
...
...
tests/TestCustomHbondForce.h
View file @
efa678e0
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
8
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -225,6 +225,35 @@ void testCustomFunctions() {
ASSERT_EQUAL_TOL
(
0.1
*
2
+
0.1
*
2
,
state
.
getPotentialEnergy
(),
TOL
);
}
void
test2DFunction
()
{
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
CustomHbondForce
*
custom
=
new
CustomHbondForce
(
"tab(dtype, atype)"
);
custom
->
addPerDonorParameter
(
"dtype"
);
custom
->
addPerAcceptorParameter
(
"atype"
);
custom
->
addDonor
(
1
,
0
,
-
1
,
{
0.0
});
custom
->
addDonor
(
2
,
0
,
-
1
,
{
2.0
});
custom
->
addAcceptor
(
0
,
1
,
-
1
,
{
1.0
});
vector
<
double
>
function
=
{
0.0
,
1.0
,
2.0
,
5.0
,
6.0
,
7.0
};
custom
->
addTabulatedFunction
(
"tab"
,
new
Discrete2DFunction
(
3
,
2
,
function
));
system
.
addForce
(
custom
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
3
);
positions
[
0
]
=
Vec3
(
0
,
0
,
0
);
positions
[
1
]
=
Vec3
(
0
,
2
,
0
);
positions
[
2
]
=
Vec3
(
2
,
0
,
0
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces
=
state
.
getForces
();
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0
,
0
),
forces
[
0
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0
,
0
),
forces
[
1
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0
,
0
),
forces
[
2
],
TOL
);
ASSERT_EQUAL_TOL
(
12.0
,
state
.
getPotentialEnergy
(),
TOL
);
}
void
testIllegalVariable
()
{
System
system
;
system
.
addParticle
(
1.0
);
...
...
@@ -280,6 +309,7 @@ int main(int argc, char* argv[]) {
testExclusions
();
testCutoff
();
testCustomFunctions
();
test2DFunction
();
testIllegalVariable
();
testParameters
();
runPlatformTests
();
...
...
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