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
b3176be4
"platforms/hip/tests/TestHipCustomManyParticleForce.cpp" did not exist on "786e1ee7db83a016d3af8cc707f3cd2c7f24e012"
Commit
b3176be4
authored
Jun 24, 2020
by
Charlles Abreu
Browse files
Elimination of setPeriodic method in tabulated functions
parent
ab67382e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
24 deletions
+39
-24
openmmapi/include/openmm/TabulatedFunction.h
openmmapi/include/openmm/TabulatedFunction.h
+0
-6
openmmapi/src/TabulatedFunction.cpp
openmmapi/src/TabulatedFunction.cpp
+0
-4
serialization/tests/TestSerializeTabulatedFunctions.cpp
serialization/tests/TestSerializeTabulatedFunctions.cpp
+22
-9
tests/TestCustomNonbondedForce.h
tests/TestCustomNonbondedForce.h
+17
-5
No files found.
openmmapi/include/openmm/TabulatedFunction.h
View file @
b3176be4
...
@@ -68,12 +68,6 @@ public:
...
@@ -68,12 +68,6 @@ public:
*
*
*/
*/
bool
getPeriodic
()
const
;
bool
getPeriodic
()
const
;
/**
* Set the periodicity status for the tabulated function.
*
* @param periodic whether the function is periodic with period L = max - min
*/
void
setPeriodic
(
bool
periodic
);
protected:
protected:
bool
periodic
;
bool
periodic
;
};
};
...
...
openmmapi/src/TabulatedFunction.cpp
View file @
b3176be4
...
@@ -39,10 +39,6 @@ bool TabulatedFunction::getPeriodic() const {
...
@@ -39,10 +39,6 @@ bool TabulatedFunction::getPeriodic() const {
return
periodic
;
return
periodic
;
}
}
void
TabulatedFunction
::
setPeriodic
(
bool
periodic
)
{
this
->
periodic
=
periodic
;
}
Continuous1DFunction
::
Continuous1DFunction
(
const
vector
<
double
>&
values
,
double
min
,
double
max
,
bool
periodic
)
{
Continuous1DFunction
::
Continuous1DFunction
(
const
vector
<
double
>&
values
,
double
min
,
double
max
,
bool
periodic
)
{
this
->
periodic
=
periodic
;
this
->
periodic
=
periodic
;
setFunctionParameters
(
values
,
min
,
max
);
setFunctionParameters
(
values
,
min
,
max
);
...
...
serialization/tests/TestSerializeTabulatedFunctions.cpp
View file @
b3176be4
...
@@ -63,16 +63,29 @@ void testContinuous1DFunction() {
...
@@ -63,16 +63,29 @@ void testContinuous1DFunction() {
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
}
// Same test with periodic function:
void
testPeriodicContinuous1DFunction
()
{
// Create a function.
values
.
push_back
(
values
[
0
]);
double
min
=
0.5
,
max
=
1.5
;
function
.
setPeriodic
(
true
);
vector
<
double
>
values
(
60
);
function
.
setFunctionParameters
(
values
,
min
,
max
);
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
()
-
1
;
i
++
)
stringstream
newBuffer
;
values
[
i
]
=
sin
((
double
)
i
);
XmlSerializer
::
serialize
<
Continuous1DFunction
>
(
&
function
,
"Function"
,
newBuffer
);
values
[
values
.
size
()
-
1
]
=
values
[
0
];
Continuous1DFunction
*
newCopy
=
XmlSerializer
::
deserialize
<
Continuous1DFunction
>
(
newBuffer
);
Continuous1DFunction
function
(
values
,
min
,
max
,
true
);
newCopy
->
getFunctionParameters
(
values2
,
min2
,
max2
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
Continuous1DFunction
>
(
&
function
,
"Function"
,
buffer
);
Continuous1DFunction
*
copy
=
XmlSerializer
::
deserialize
<
Continuous1DFunction
>
(
buffer
);
// Compare the two forces to see if they are identical.
double
min2
,
max2
;
vector
<
double
>
values2
;
copy
->
getFunctionParameters
(
values2
,
min2
,
max2
);
ASSERT_EQUAL
(
min
,
min2
);
ASSERT_EQUAL
(
min
,
min2
);
ASSERT_EQUAL
(
max
,
max2
);
ASSERT_EQUAL
(
max
,
max2
);
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
...
...
tests/TestCustomNonbondedForce.h
View file @
b3176be4
...
@@ -355,14 +355,26 @@ void testContinuous1DFunction() {
...
@@ -355,14 +355,26 @@ void testContinuous1DFunction() {
double
energy
=
(
x
<
1.0
||
x
>
6.0
?
0.0
:
sin
(
x
-
1.0
))
+
1.0
;
double
energy
=
(
x
<
1.0
||
x
>
6.0
?
0.0
:
sin
(
x
-
1.0
))
+
1.0
;
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
1e-4
);
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
1e-4
);
}
}
}
void
testPeriodicContinuous1DFunction
()
{
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
CustomNonbondedForce
*
forceField
=
new
CustomNonbondedForce
(
"fn(r)+1"
);
forceField
->
addParticle
(
vector
<
double
>
());
forceField
->
addParticle
(
vector
<
double
>
());
vector
<
double
>
table
;
double
twoPi
=
8.0
*
atan
(
1.0
);
double
twoPi
=
8.0
*
atan
(
1.0
);
for
(
int
i
=
0
;
i
<
20
;
i
++
)
for
(
int
i
=
0
;
i
<
20
;
i
++
)
table
[
i
]
=
sin
(
i
*
twoPi
/
20.0
);
table
.
push_back
(
sin
(
i
*
twoPi
/
20.0
));
table
[
20
]
=
table
[
0
];
table
.
push_back
(
table
[
0
]);
continuous1DFunction
->
setFunctionParameters
(
table
,
1.0
,
twoPi
+
1.0
);
Continuous1DFunction
*
continuous1DFunction
=
new
Continuous1DFunction
(
table
,
1.0
,
twoPi
+
1.0
);
continuous1DFunction
->
setPeriodic
(
true
);
forceField
->
addTabulatedFunction
(
"fn"
,
continuous1DFunction
);
context
.
reinitialize
();
system
.
addForce
(
forceField
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
positions
[
0
]
=
Vec3
(
0
,
0
,
0
);
positions
[
0
]
=
Vec3
(
0
,
0
,
0
);
for
(
int
i
=
1
;
i
<
30
;
i
++
)
{
for
(
int
i
=
1
;
i
<
30
;
i
++
)
{
double
x
=
(
7.0
/
30.0
)
*
i
;
double
x
=
(
7.0
/
30.0
)
*
i
;
...
...
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