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
94fbbe9c
Commit
94fbbe9c
authored
Apr 20, 2016
by
Peter Eastman
Browse files
Reference implementation of periodic boundary conditions for AMOEBA bonded forces
parent
b4dcef47
Changes
41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletion
+40
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaTorsionTorsionForce.cpp
...eference/tests/TestReferenceAmoebaTorsionTorsionForce.cpp
+40
-1
No files found.
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaTorsionTorsionForce.cpp
View file @
94fbbe9c
...
...
@@ -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 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -2669,6 +2669,44 @@ void testTorsionTorsion(int systemId, bool includeDerivs) {
ASSERT_EQUAL_TOL
(
expectedEnergy
,
state
.
getPotentialEnergy
(),
tolerance
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numberOfParticles
=
6
;
for
(
int
ii
=
0
;
ii
<
numberOfParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaTorsionTorsionForce
*
amoebaTorsionTorsionForce
=
new
AmoebaTorsionTorsionForce
();
int
chiralCheckAtomIndex
;
int
gridIndex
;
chiralCheckAtomIndex
=
5
;
gridIndex
=
2
;
amoebaTorsionTorsionForce
->
addTorsionTorsion
(
0
,
1
,
2
,
3
,
4
,
chiralCheckAtomIndex
,
0
);
amoebaTorsionTorsionForce
->
setTorsionTorsionGrid
(
0
,
getTorsionGrid
(
gridIndex
,
false
));
amoebaTorsionTorsionForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaTorsionTorsionForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numberOfParticles
);
positions
[
0
]
=
Vec3
(
0
,
1
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
positions
[
2
]
=
Vec3
(
0
,
0
,
0.5
);
positions
[
3
]
=
Vec3
(
0.4
,
0.4
,
0.4
);
positions
[
4
]
=
Vec3
(
1
,
0
,
1
);
positions
[
5
]
=
Vec3
(
1
,
1
,
0
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
// Move one atom to a position that should give identical results.
positions
[
0
]
=
Vec3
(
0
,
-
2
,
0
);
context
.
setPositions
(
positions
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
...
...
@@ -2677,6 +2715,7 @@ int main(int numberOfArguments, char* argv[]) {
registerAmoebaReferenceKernelFactories
();
testTorsionTorsion
(
1
,
true
);
testTorsionTorsion
(
1
,
false
);
testPeriodic
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"exception: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
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