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
c741523e
Commit
c741523e
authored
Oct 18, 2015
by
Robert T. McGibbon
Browse files
Add test for issue #1991
parent
56d3b854
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
tests/TestCustomExternalForce.h
tests/TestCustomExternalForce.h
+33
-0
No files found.
tests/TestCustomExternalForce.h
View file @
c741523e
...
...
@@ -167,6 +167,38 @@ void testPeriodic() {
}
}
void
testGithub1191
()
{
Vec3
vx
(
5
,
0
,
0
);
Vec3
vy
(
0
,
6
,
0
);
Vec3
vz
(
1
,
2
,
7
);
double
x0
=
51
,
y0
=
-
17
,
z0
=
11.2
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
vx
,
vy
,
vz
);
system
.
addParticle
(
1.0
);
CustomExternalForce
*
force
=
new
CustomExternalForce
(
"periodicdistance(x, y, z, x0, y0, z0)^2"
);
force
->
addPerParticleParameter
(
"x0"
);
force
->
addPerParticleParameter
(
"y0"
);
force
->
addPerParticleParameter
(
"z0"
);
vector
<
double
>
params
(
3
);
params
[
0
]
=
x0
;
params
[
1
]
=
y0
;
params
[
2
]
=
z0
;
force
->
addParticle
(
0
,
params
);
system
.
addForce
(
force
);
ASSERT
(
force
->
usesPeriodicBoundaryConditions
());
ASSERT
(
system
.
usesPeriodicBoundaryConditions
());
VerletIntegrator
integrator
(
0.01
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
1
);
positions
[
0
]
=
Vec3
(
x0
,
y0
,
z0
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Positions
|
State
::
Forces
|
State
::
Energy
);
vector
<
Vec3
>
forces
=
state
.
getForces
();
for
(
int
i
=
0
;
i
<
3
;
i
++
)
ASSERT_EQUAL
(
forces
[
0
][
i
],
forces
[
0
][
i
]);
}
void
testIllegalVariable
()
{
System
system
;
system
.
addParticle
(
1.0
);
...
...
@@ -192,6 +224,7 @@ int main(int argc, char* argv[]) {
testForce
();
testManyParameters
();
testPeriodic
();
testGithub1191
();
testIllegalVariable
();
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