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
4e1e1b11
"wrappers/python/vscode:/vscode.git/clone" did not exist on "7a791b94c8345d02719a8b0d2d5e7303ba65bcaf"
Commit
4e1e1b11
authored
Oct 11, 2010
by
Peter Eastman
Browse files
Custom functions are now represented by natural splines
parent
06a98e93
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
32 deletions
+30
-32
platforms/reference/tests/TestReferenceCustomHbondForce.cpp
platforms/reference/tests/TestReferenceCustomHbondForce.cpp
+1
-1
platforms/reference/tests/TestReferenceCustomNonbondedForce.cpp
...rms/reference/tests/TestReferenceCustomNonbondedForce.cpp
+11
-4
serialization/src/CustomGBForceProxy.cpp
serialization/src/CustomGBForceProxy.cpp
+3
-4
serialization/src/CustomHbondForceProxy.cpp
serialization/src/CustomHbondForceProxy.cpp
+3
-4
serialization/src/CustomNonbondedForceProxy.cpp
serialization/src/CustomNonbondedForceProxy.cpp
+3
-4
serialization/tests/TestSerializeCustomGBForce.cpp
serialization/tests/TestSerializeCustomGBForce.cpp
+3
-5
serialization/tests/TestSerializeCustomHbondForce.cpp
serialization/tests/TestSerializeCustomHbondForce.cpp
+3
-5
serialization/tests/TestSerializeCustomNonbondedForce.cpp
serialization/tests/TestSerializeCustomNonbondedForce.cpp
+3
-5
No files found.
platforms/reference/tests/TestReferenceCustomHbondForce.cpp
View file @
4e1e1b11
...
...
@@ -195,7 +195,7 @@ void testCustomFunctions() {
vector
<
double
>
function
(
2
);
function
[
0
]
=
0
;
function
[
1
]
=
1
;
custom
->
addFunction
(
"foo"
,
function
,
0
,
10
,
true
);
custom
->
addFunction
(
"foo"
,
function
,
0
,
10
);
system
.
addForce
(
custom
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
3
);
...
...
platforms/reference/tests/TestReferenceCustomNonbondedForce.cpp
View file @
4e1e1b11
...
...
@@ -203,7 +203,7 @@ void testPeriodic() {
ASSERT_EQUAL_TOL
(
1.9
+
1
+
0.9
,
state
.
getPotentialEnergy
(),
TOL
);
}
void
testTabulatedFunction
(
bool
interpolating
)
{
void
testTabulatedFunction
()
{
ReferencePlatform
platform
;
System
system
;
system
.
addParticle
(
1.0
);
...
...
@@ -215,7 +215,7 @@ void testTabulatedFunction(bool interpolating) {
vector
<
double
>
table
;
for
(
int
i
=
0
;
i
<
21
;
i
++
)
table
.
push_back
(
std
::
sin
(
0.25
*
i
));
forceField
->
addFunction
(
"fn"
,
table
,
1.0
,
6.0
,
interpolating
);
forceField
->
addFunction
(
"fn"
,
table
,
1.0
,
6.0
);
system
.
addForce
(
forceField
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
2
);
...
...
@@ -233,6 +233,14 @@ void testTabulatedFunction(bool interpolating) {
ASSERT_EQUAL_VEC
(
Vec3
(
force
,
0
,
0
),
forces
[
1
],
0.1
);
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
0.02
);
}
for
(
int
i
=
1
;
i
<
20
;
i
++
)
{
double
x
=
0.25
*
i
+
1.0
;
positions
[
1
]
=
Vec3
(
x
,
0
,
0
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Energy
);
double
energy
=
(
x
<
1.0
||
x
>
6.0
?
0.0
:
std
::
sin
(
x
-
1.0
))
+
1.0
;
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
1e-4
);
}
}
void
testCoulombLennardJones
()
{
...
...
@@ -317,8 +325,7 @@ int main() {
testExclusions
();
testCutoff
();
testPeriodic
();
testTabulatedFunction
(
true
);
testTabulatedFunction
(
false
);
testTabulatedFunction
();
testCoulombLennardJones
();
}
catch
(
const
exception
&
e
)
{
...
...
serialization/src/CustomGBForceProxy.cpp
View file @
4e1e1b11
...
...
@@ -91,9 +91,8 @@ void CustomGBForceProxy::serialize(const void* object, SerializationNode& node)
string
name
;
vector
<
double
>
values
;
double
min
,
max
;
bool
interpolating
;
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
,
interpolating
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
).
setIntProperty
(
"interpolating"
,
interpolating
);
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
...
...
@@ -152,7 +151,7 @@ void* CustomGBForceProxy::deserialize(const SerializationNode& node) const {
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)
,
(
bool
)
function
.
getIntProperty
(
"interpolating"
)
);
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
));
}
return
force
;
}
...
...
serialization/src/CustomHbondForceProxy.cpp
View file @
4e1e1b11
...
...
@@ -96,9 +96,8 @@ void CustomHbondForceProxy::serialize(const void* object, SerializationNode& nod
string
name
;
vector
<
double
>
values
;
double
min
,
max
;
bool
interpolating
;
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
,
interpolating
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
).
setIntProperty
(
"interpolating"
,
interpolating
);
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
...
...
@@ -164,7 +163,7 @@ void* CustomHbondForceProxy::deserialize(const SerializationNode& node) const {
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)
,
(
bool
)
function
.
getIntProperty
(
"interpolating"
)
);
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
));
}
return
force
;
}
...
...
serialization/src/CustomNonbondedForceProxy.cpp
View file @
4e1e1b11
...
...
@@ -78,9 +78,8 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode&
string
name
;
vector
<
double
>
values
;
double
min
,
max
;
bool
interpolating
;
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
,
interpolating
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
).
setIntProperty
(
"interpolating"
,
interpolating
);
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
...
...
@@ -129,7 +128,7 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)
,
(
bool
)
function
.
getIntProperty
(
"interpolating"
)
);
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
));
}
return
force
;
}
...
...
serialization/tests/TestSerializeCustomGBForce.cpp
View file @
4e1e1b11
...
...
@@ -63,7 +63,7 @@ void testSerialization() {
vector
<
double
>
values
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
,
true
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
);
// Serialize and then deserialize it.
...
...
@@ -125,13 +125,11 @@ void testSerialization() {
string
name1
,
name2
;
double
min1
,
min2
,
max1
,
max2
;
vector
<
double
>
val1
,
val2
;
bool
interp1
,
interp2
;
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
,
interp1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
,
interp2
);
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
name1
,
name2
);
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
ASSERT_EQUAL
(
interp1
,
interp2
);
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
for
(
int
j
=
0
;
j
<
val1
.
size
();
j
++
)
ASSERT_EQUAL
(
val1
[
j
],
val2
[
j
]);
...
...
serialization/tests/TestSerializeCustomHbondForce.cpp
View file @
4e1e1b11
...
...
@@ -66,7 +66,7 @@ void testSerialization() {
vector
<
double
>
values
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
,
true
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
);
// Serialize and then deserialize it.
...
...
@@ -130,13 +130,11 @@ void testSerialization() {
string
name1
,
name2
;
double
min1
,
min2
,
max1
,
max2
;
vector
<
double
>
val1
,
val2
;
bool
interp1
,
interp2
;
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
,
interp1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
,
interp2
);
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
name1
,
name2
);
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
ASSERT_EQUAL
(
interp1
,
interp2
);
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
for
(
int
j
=
0
;
j
<
val1
.
size
();
j
++
)
ASSERT_EQUAL
(
val1
[
j
],
val2
[
j
]);
...
...
serialization/tests/TestSerializeCustomNonbondedForce.cpp
View file @
4e1e1b11
...
...
@@ -59,7 +59,7 @@ void testSerialization() {
vector
<
double
>
values
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
,
true
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
);
// Serialize and then deserialize it.
...
...
@@ -103,13 +103,11 @@ void testSerialization() {
string
name1
,
name2
;
double
min1
,
min2
,
max1
,
max2
;
vector
<
double
>
val1
,
val2
;
bool
interp1
,
interp2
;
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
,
interp1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
,
interp2
);
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
name1
,
name2
);
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
ASSERT_EQUAL
(
interp1
,
interp2
);
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
for
(
int
j
=
0
;
j
<
val1
.
size
();
j
++
)
ASSERT_EQUAL
(
val1
[
j
],
val2
[
j
]);
...
...
Prev
1
2
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