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
f2e0735f
Commit
f2e0735f
authored
Nov 21, 2012
by
Peter Eastman
Browse files
Added updateParametersInContext() methods to most AMOEBA forces.
parent
e6696626
Changes
65
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
122 additions
and
44 deletions
+122
-44
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaOutOfPlaneBendForce.cpp
...eference/tests/TestReferenceAmoebaOutOfPlaneBendForce.cpp
+15
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaPiTorsionForce.cpp
...rms/reference/tests/TestReferenceAmoebaPiTorsionForce.cpp
+15
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaStretchBendForce.cpp
...s/reference/tests/TestReferenceAmoebaStretchBendForce.cpp
+15
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaVdwForce.cpp
...platforms/reference/tests/TestReferenceAmoebaVdwForce.cpp
+29
-0
plugins/amoeba/platforms/reference/tests/TestReferenceWcaDispersionForce.cpp
...forms/reference/tests/TestReferenceWcaDispersionForce.cpp
+48
-41
No files found.
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaOutOfPlaneBendForce.cpp
View file @
f2e0735f
...
@@ -332,6 +332,20 @@ void testOneOutOfPlaneBend( FILE* log ) {
...
@@ -332,6 +332,20 @@ void testOneOutOfPlaneBend( FILE* log ) {
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaOutOfPlaneBendForce
,
TOL
,
"testOneOutOfPlaneBend"
,
log
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaOutOfPlaneBendForce
,
TOL
,
"testOneOutOfPlaneBend"
,
log
);
// Try changing the bend parameters and make sure it's still correct.
amoebaOutOfPlaneBendForce
->
setOutOfPlaneBendParameters
(
0
,
0
,
1
,
2
,
3
,
1.1
*
kOutOfPlaneBend
);
bool
exceptionThrown
=
false
;
try
{
// This should throw an exception.
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaOutOfPlaneBendForce
,
TOL
,
"testOneOutOfPlaneBend"
,
log
);
}
catch
(
std
::
exception
ex
)
{
exceptionThrown
=
true
;
}
ASSERT
(
exceptionThrown
);
amoebaOutOfPlaneBendForce
->
updateParametersInContext
(
context
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaOutOfPlaneBendForce
,
TOL
,
"testOneOutOfPlaneBend"
,
log
);
}
}
void
testOneOutOfPlaneBend2
(
FILE
*
log
,
int
setId
)
{
void
testOneOutOfPlaneBend2
(
FILE
*
log
,
int
setId
)
{
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaPiTorsionForce.cpp
View file @
f2e0735f
...
@@ -298,6 +298,20 @@ void testOnePiTorsion( FILE* log ) {
...
@@ -298,6 +298,20 @@ void testOnePiTorsion( FILE* log ) {
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaPiTorsionForce
,
TOL
,
"testOnePiTorsion"
,
log
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaPiTorsionForce
,
TOL
,
"testOnePiTorsion"
,
log
);
// Try changing the torsion parameters and make sure it's still correct.
amoebaPiTorsionForce
->
setPiTorsionParameters
(
0
,
0
,
1
,
2
,
3
,
4
,
5
,
1.2
*
kTorsion
);
bool
exceptionThrown
=
false
;
try
{
// This should throw an exception.
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaPiTorsionForce
,
TOL
,
"testOnePiTorsion"
,
log
);
}
catch
(
std
::
exception
ex
)
{
exceptionThrown
=
true
;
}
ASSERT
(
exceptionThrown
);
amoebaPiTorsionForce
->
updateParametersInContext
(
context
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaPiTorsionForce
,
TOL
,
"testOnePiTorsion"
,
log
);
}
}
int
main
(
int
numberOfArguments
,
char
*
argv
[]
)
{
int
main
(
int
numberOfArguments
,
char
*
argv
[]
)
{
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaStretchBendForce.cpp
View file @
f2e0735f
...
@@ -284,6 +284,20 @@ void testOneStretchBend( FILE* log ) {
...
@@ -284,6 +284,20 @@ void testOneStretchBend( FILE* log ) {
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaStretchBendForce
,
TOL
,
"testOneStretchBend"
,
log
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaStretchBendForce
,
TOL
,
"testOneStretchBend"
,
log
);
// Try changing the stretch-bend parameters and make sure it's still correct.
amoebaStretchBendForce
->
setStretchBendParameters
(
0
,
0
,
1
,
2
,
1.1
*
abLength
,
1.2
*
cbLength
,
1.3
*
angleStretchBend
,
1.4
*
kStretchBend
);
bool
exceptionThrown
=
false
;
try
{
// This should throw an exception.
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaStretchBendForce
,
TOL
,
"testOneStretchBend"
,
log
);
}
catch
(
std
::
exception
ex
)
{
exceptionThrown
=
true
;
}
ASSERT
(
exceptionThrown
);
amoebaStretchBendForce
->
updateParametersInContext
(
context
);
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaStretchBendForce
,
TOL
,
"testOneStretchBend"
,
log
);
}
}
int
main
(
int
numberOfArguments
,
char
*
argv
[]
)
{
int
main
(
int
numberOfArguments
,
char
*
argv
[]
)
{
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaVdwForce.cpp
View file @
f2e0735f
...
@@ -172,6 +172,35 @@ void testVdw( FILE* log ) {
...
@@ -172,6 +172,35 @@ void testVdw( FILE* log ) {
ASSERT_EQUAL_VEC
(
expectedForces
[
ii
],
forces
[
ii
],
tolerance
);
ASSERT_EQUAL_VEC
(
expectedForces
[
ii
],
forces
[
ii
],
tolerance
);
}
}
ASSERT_EQUAL_TOL
(
expectedEnergy
,
state
.
getPotentialEnergy
(),
tolerance
);
ASSERT_EQUAL_TOL
(
expectedEnergy
,
state
.
getPotentialEnergy
(),
tolerance
);
// Try changing the particle parameters and make sure it's still correct.
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
{
int
indexIV
;
double
mass
,
sigma
,
epsilon
,
reduction
;
amoebaVdwForce
->
getParticleParameters
(
i
,
indexIV
,
sigma
,
epsilon
,
reduction
);
amoebaVdwForce
->
setParticleParameters
(
i
,
indexIV
,
0.9
*
sigma
,
2.0
*
epsilon
,
0.95
*
reduction
);
}
LangevinIntegrator
integrator2
(
0.0
,
0.1
,
0.01
);
Context
context2
(
system
,
integrator2
,
Platform
::
getPlatformByName
(
platformName
));
context2
.
setPositions
(
positions
);
State
state1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
bool
exceptionThrown
=
false
;
try
{
// This should throw an exception.
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
tolerance
);
}
catch
(
std
::
exception
ex
)
{
exceptionThrown
=
true
;
}
ASSERT
(
exceptionThrown
);
amoebaVdwForce
->
updateParametersInContext
(
context
);
state1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
tolerance
);
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
tolerance
);
}
}
void
setupAndGetForcesEnergyVdwAmmonia
(
const
std
::
string
&
sigmaCombiningRule
,
const
std
::
string
&
epsilonCombiningRule
,
double
cutoff
,
void
setupAndGetForcesEnergyVdwAmmonia
(
const
std
::
string
&
sigmaCombiningRule
,
const
std
::
string
&
epsilonCombiningRule
,
double
cutoff
,
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceWcaDispersionForce.cpp
View file @
f2e0735f
...
@@ -52,13 +52,29 @@
...
@@ -52,13 +52,29 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
const
double
TOL
=
1e-4
;
const
double
TOL
=
1e-4
;
void
setupAndGetForcesEnergyWcaDispersionAmmonia
(
std
::
vector
<
Vec3
>&
forces
,
double
&
energy
,
FILE
*
log
){
void
compareForcesEnergy
(
std
::
string
&
testName
,
double
expectedEnergy
,
double
energy
,
const
std
::
vector
<
Vec3
>&
expectedForces
,
const
std
::
vector
<
Vec3
>&
forces
,
double
tolerance
,
FILE
*
log
)
{
// beginning of WcaDispersion setup
// beginning of WcaDispersion setup
for
(
unsigned
int
ii
=
0
;
ii
<
forces
.
size
();
ii
++
){
ASSERT_EQUAL_VEC_MOD
(
expectedForces
[
ii
],
forces
[
ii
],
tolerance
,
testName
);
}
ASSERT_EQUAL_TOL_MOD
(
expectedEnergy
,
energy
,
tolerance
,
testName
);
}
// test Wca dispersion
void
testWcaDispersionAmmonia
(
FILE
*
log
)
{
std
::
string
testName
=
"testWcaDispersionAmmonia"
;
int
numberOfParticles
=
8
;
// Create the system.
System
system
;
System
system
;
AmoebaWcaDispersionForce
*
amoebaWcaDispersionForce
=
new
AmoebaWcaDispersionForce
();;
AmoebaWcaDispersionForce
*
amoebaWcaDispersionForce
=
new
AmoebaWcaDispersionForce
();;
int
numberOfParticles
=
8
;
amoebaWcaDispersionForce
->
setEpso
(
4.6024000e-01
);
amoebaWcaDispersionForce
->
setEpso
(
4.6024000e-01
);
amoebaWcaDispersionForce
->
setEpsh
(
5.6484000e-02
);
amoebaWcaDispersionForce
->
setEpsh
(
5.6484000e-02
);
...
@@ -105,46 +121,12 @@ void setupAndGetForcesEnergyWcaDispersionAmmonia( std::vector<Vec3>& forces, dou
...
@@ -105,46 +121,12 @@ void setupAndGetForcesEnergyWcaDispersionAmmonia( std::vector<Vec3>& forces, dou
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
forces
=
state
.
getForces
();
std
::
vector
<
Vec3
>
forces
=
state
.
getForces
();
energy
=
state
.
getPotentialEnergy
();
double
energy
=
state
.
getPotentialEnergy
();
}
void
compareForcesEnergy
(
std
::
string
&
testName
,
double
expectedEnergy
,
double
energy
,
std
::
vector
<
Vec3
>&
expectedForces
,
std
::
vector
<
Vec3
>&
forces
,
double
tolerance
,
FILE
*
log
)
{
#ifdef AMOEBA_DEBUG
if
(
log
){
(
void
)
fprintf
(
log
,
"%s: expected energy=%14.7e %14.7e
\n
"
,
testName
.
c_str
(),
expectedEnergy
,
energy
);
for
(
unsigned
int
ii
=
0
;
ii
<
forces
.
size
();
ii
++
){
(
void
)
fprintf
(
log
,
"%6u [%14.7e %14.7e %14.7e] [%14.7e %14.7e %14.7e]
\n
"
,
ii
,
expectedForces
[
ii
][
0
],
expectedForces
[
ii
][
1
],
expectedForces
[
ii
][
2
],
forces
[
ii
][
0
],
forces
[
ii
][
1
],
forces
[
ii
][
2
]
);
}
(
void
)
fflush
(
log
);
}
#endif
for
(
unsigned
int
ii
=
0
;
ii
<
forces
.
size
();
ii
++
){
ASSERT_EQUAL_VEC_MOD
(
expectedForces
[
ii
],
forces
[
ii
],
tolerance
,
testName
);
}
ASSERT_EQUAL_TOL_MOD
(
expectedEnergy
,
energy
,
tolerance
,
testName
);
}
// test Wca dispersion
void
testWcaDispersionAmmonia
(
FILE
*
log
)
{
std
::
string
testName
=
"testWcaDispersionAmmonia"
;
int
numberOfParticles
=
8
;
std
::
vector
<
Vec3
>
forces
;
double
energy
;
setupAndGetForcesEnergyWcaDispersionAmmonia
(
forces
,
energy
,
log
);
std
::
vector
<
Vec3
>
expectedForces
(
numberOfParticles
);
// TINKER-computed values
// TINKER-computed values
std
::
vector
<
Vec3
>
expectedForces
(
numberOfParticles
);
double
expectedEnergy
=
-
2.6981209e+01
;
double
expectedEnergy
=
-
2.6981209e+01
;
expectedForces
[
0
]
=
Vec3
(
4.7839388e+00
,
-
7.3510133e-04
,
-
5.0382764e-01
);
expectedForces
[
0
]
=
Vec3
(
4.7839388e+00
,
-
7.3510133e-04
,
-
5.0382764e-01
);
...
@@ -158,6 +140,31 @@ void testWcaDispersionAmmonia( FILE* log ) {
...
@@ -158,6 +140,31 @@ void testWcaDispersionAmmonia( FILE* log ) {
double
tolerance
=
1.0e-04
;
double
tolerance
=
1.0e-04
;
compareForcesEnergy
(
testName
,
expectedEnergy
,
energy
,
expectedForces
,
forces
,
tolerance
,
log
);
compareForcesEnergy
(
testName
,
expectedEnergy
,
energy
,
expectedForces
,
forces
,
tolerance
,
log
);
// Try changing the particle parameters and make sure it's still correct.
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
{
double
radius
,
epsilon
;
amoebaWcaDispersionForce
->
getParticleParameters
(
i
,
radius
,
epsilon
);
amoebaWcaDispersionForce
->
setParticleParameters
(
i
,
0.9
*
radius
,
2.0
*
epsilon
);
}
LangevinIntegrator
integrator2
(
0.0
,
0.1
,
0.01
);
Context
context2
(
system
,
integrator2
,
Platform
::
getPlatformByName
(
platformName
));
context2
.
setPositions
(
positions
);
State
state1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
bool
exceptionThrown
=
false
;
try
{
// This should throw an exception.
compareForcesEnergy
(
testName
,
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
state1
.
getForces
(),
state2
.
getForces
(),
tolerance
,
log
);
}
catch
(
std
::
exception
ex
)
{
exceptionThrown
=
true
;
}
ASSERT
(
exceptionThrown
);
amoebaWcaDispersionForce
->
updateParametersInContext
(
context
);
state1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
compareForcesEnergy
(
testName
,
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
state1
.
getForces
(),
state2
.
getForces
(),
tolerance
,
log
);
}
}
int
main
(
int
numberOfArguments
,
char
*
argv
[]
)
{
int
main
(
int
numberOfArguments
,
char
*
argv
[]
)
{
...
...
Prev
1
2
3
4
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