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
df07fbe9
Commit
df07fbe9
authored
Jul 13, 2016
by
peastman
Browse files
Serialization of parameter derivatives
parent
ff8cac54
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
105 additions
and
14 deletions
+105
-14
serialization/src/CustomAngleForceProxy.cpp
serialization/src/CustomAngleForceProxy.cpp
+13
-2
serialization/src/CustomBondForceProxy.cpp
serialization/src/CustomBondForceProxy.cpp
+13
-2
serialization/src/CustomCentroidBondForceProxy.cpp
serialization/src/CustomCentroidBondForceProxy.cpp
+13
-2
serialization/src/CustomCompoundBondForceProxy.cpp
serialization/src/CustomCompoundBondForceProxy.cpp
+13
-2
serialization/src/CustomGBForceProxy.cpp
serialization/src/CustomGBForceProxy.cpp
+15
-3
serialization/src/CustomTorsionForceProxy.cpp
serialization/src/CustomTorsionForceProxy.cpp
+13
-2
serialization/tests/TestSerializeCustomAngleForce.cpp
serialization/tests/TestSerializeCustomAngleForce.cpp
+4
-0
serialization/tests/TestSerializeCustomBondForce.cpp
serialization/tests/TestSerializeCustomBondForce.cpp
+4
-0
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
+4
-0
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
+4
-0
serialization/tests/TestSerializeCustomGBForce.cpp
serialization/tests/TestSerializeCustomGBForce.cpp
+5
-1
serialization/tests/TestSerializeCustomTorsionForce.cpp
serialization/tests/TestSerializeCustomTorsionForce.cpp
+4
-0
No files found.
serialization/src/CustomAngleForceProxy.cpp
View file @
df07fbe9
...
...
@@ -42,7 +42,7 @@ CustomAngleForceProxy::CustomAngleForceProxy() : SerializationProxy("CustomAngle
}
void
CustomAngleForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
CustomAngleForce
&
force
=
*
reinterpret_cast
<
const
CustomAngleForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
...
...
@@ -55,6 +55,10 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
globalParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getGlobalParameterName
(
i
)).
setDoubleProperty
(
"default"
,
force
.
getGlobalParameterDefaultValue
(
i
));
}
SerializationNode
&
energyDerivs
=
node
.
createChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
{
energyDerivs
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getEnergyParameterDerivativeName
(
i
));
}
SerializationNode
&
angles
=
node
.
createChildNode
(
"Angles"
);
for
(
int
i
=
0
;
i
<
force
.
getNumAngles
();
i
++
)
{
int
p1
,
p2
,
p3
;
...
...
@@ -72,7 +76,7 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod
void
*
CustomAngleForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
CustomAngleForce
*
force
=
NULL
;
try
{
...
...
@@ -90,6 +94,13 @@ void* CustomAngleForceProxy::deserialize(const SerializationNode& node) const {
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
2
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
angles
=
node
.
getChildNode
(
"Angles"
);
vector
<
double
>
params
(
force
->
getNumPerAngleParameters
());
for
(
int
i
=
0
;
i
<
(
int
)
angles
.
getChildren
().
size
();
i
++
)
{
...
...
serialization/src/CustomBondForceProxy.cpp
View file @
df07fbe9
...
...
@@ -42,7 +42,7 @@ CustomBondForceProxy::CustomBondForceProxy() : SerializationProxy("CustomBondFor
}
void
CustomBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
CustomBondForce
&
force
=
*
reinterpret_cast
<
const
CustomBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
...
...
@@ -55,6 +55,10 @@ void CustomBondForceProxy::serialize(const void* object, SerializationNode& node
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
globalParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getGlobalParameterName
(
i
)).
setDoubleProperty
(
"default"
,
force
.
getGlobalParameterDefaultValue
(
i
));
}
SerializationNode
&
energyDerivs
=
node
.
createChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
{
energyDerivs
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getEnergyParameterDerivativeName
(
i
));
}
SerializationNode
&
bonds
=
node
.
createChildNode
(
"Bonds"
);
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
int
p1
,
p2
;
...
...
@@ -72,7 +76,7 @@ void CustomBondForceProxy::serialize(const void* object, SerializationNode& node
void
*
CustomBondForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
CustomBondForce
*
force
=
NULL
;
try
{
...
...
@@ -90,6 +94,13 @@ void* CustomBondForceProxy::deserialize(const SerializationNode& node) const {
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
2
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"Bonds"
);
vector
<
double
>
params
(
force
->
getNumPerBondParameters
());
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
getChildren
().
size
();
i
++
)
{
...
...
serialization/src/CustomCentroidBondForceProxy.cpp
View file @
df07fbe9
...
...
@@ -42,7 +42,7 @@ CustomCentroidBondForceProxy::CustomCentroidBondForceProxy() : SerializationProx
}
void
CustomCentroidBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
CustomCentroidBondForce
&
force
=
*
reinterpret_cast
<
const
CustomCentroidBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
...
...
@@ -56,6 +56,10 @@ void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNo
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
globalParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getGlobalParameterName
(
i
)).
setDoubleProperty
(
"default"
,
force
.
getGlobalParameterDefaultValue
(
i
));
}
SerializationNode
&
energyDerivs
=
node
.
createChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
{
energyDerivs
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getEnergyParameterDerivativeName
(
i
));
}
SerializationNode
&
groups
=
node
.
createChildNode
(
"Groups"
);
for
(
int
i
=
0
;
i
<
force
.
getNumGroups
();
i
++
)
{
vector
<
int
>
particles
;
...
...
@@ -95,7 +99,7 @@ void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNo
void
*
CustomCentroidBondForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
CustomCentroidBondForce
*
force
=
NULL
;
try
{
...
...
@@ -113,6 +117,13 @@ void* CustomCentroidBondForceProxy::deserialize(const SerializationNode& node) c
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
2
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
groups
=
node
.
getChildNode
(
"Groups"
);
for
(
int
i
=
0
;
i
<
(
int
)
groups
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
group
=
groups
.
getChildren
()[
i
];
...
...
serialization/src/CustomCompoundBondForceProxy.cpp
View file @
df07fbe9
...
...
@@ -42,7 +42,7 @@ CustomCompoundBondForceProxy::CustomCompoundBondForceProxy() : SerializationProx
}
void
CustomCompoundBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
CustomCompoundBondForce
&
force
=
*
reinterpret_cast
<
const
CustomCompoundBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
...
...
@@ -56,6 +56,10 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
globalParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getGlobalParameterName
(
i
)).
setDoubleProperty
(
"default"
,
force
.
getGlobalParameterDefaultValue
(
i
));
}
SerializationNode
&
energyDerivs
=
node
.
createChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
{
energyDerivs
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getEnergyParameterDerivativeName
(
i
));
}
SerializationNode
&
bonds
=
node
.
createChildNode
(
"Bonds"
);
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
vector
<
int
>
particles
;
...
...
@@ -82,7 +86,7 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo
void
*
CustomCompoundBondForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
CustomCompoundBondForce
*
force
=
NULL
;
try
{
...
...
@@ -100,6 +104,13 @@ void* CustomCompoundBondForceProxy::deserialize(const SerializationNode& node) c
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
2
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"Bonds"
);
vector
<
int
>
particles
(
force
->
getNumParticlesPerBond
());
vector
<
double
>
params
(
force
->
getNumPerBondParameters
());
...
...
serialization/src/CustomGBForceProxy.cpp
View file @
df07fbe9
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -42,7 +42,7 @@ CustomGBForceProxy::CustomGBForceProxy() : SerializationProxy("CustomGBForce") {
}
void
CustomGBForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
CustomGBForce
&
force
=
*
reinterpret_cast
<
const
CustomGBForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setIntProperty
(
"method"
,
(
int
)
force
.
getNonbondedMethod
());
...
...
@@ -55,6 +55,10 @@ void CustomGBForceProxy::serialize(const void* object, SerializationNode& node)
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
globalParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getGlobalParameterName
(
i
)).
setDoubleProperty
(
"default"
,
force
.
getGlobalParameterDefaultValue
(
i
));
}
SerializationNode
&
energyDerivs
=
node
.
createChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
{
energyDerivs
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getEnergyParameterDerivativeName
(
i
));
}
SerializationNode
&
computedValues
=
node
.
createChildNode
(
"ComputedValues"
);
for
(
int
i
=
0
;
i
<
force
.
getNumComputedValues
();
i
++
)
{
string
name
,
expression
;
...
...
@@ -93,7 +97,8 @@ void CustomGBForceProxy::serialize(const void* object, SerializationNode& node)
}
void
*
CustomGBForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
throw
OpenMMException
(
"Unsupported version number"
);
CustomGBForce
*
force
=
NULL
;
try
{
...
...
@@ -111,6 +116,13 @@ void* CustomGBForceProxy::deserialize(const SerializationNode& node) const {
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
1
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
computedValues
=
node
.
getChildNode
(
"ComputedValues"
);
for
(
int
i
=
0
;
i
<
(
int
)
computedValues
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
value
=
computedValues
.
getChildren
()[
i
];
...
...
serialization/src/CustomTorsionForceProxy.cpp
View file @
df07fbe9
...
...
@@ -42,7 +42,7 @@ CustomTorsionForceProxy::CustomTorsionForceProxy() : SerializationProxy("CustomT
}
void
CustomTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
CustomTorsionForce
&
force
=
*
reinterpret_cast
<
const
CustomTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
...
...
@@ -55,6 +55,10 @@ void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& n
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
globalParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getGlobalParameterName
(
i
)).
setDoubleProperty
(
"default"
,
force
.
getGlobalParameterDefaultValue
(
i
));
}
SerializationNode
&
energyDerivs
=
node
.
createChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
{
energyDerivs
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getEnergyParameterDerivativeName
(
i
));
}
SerializationNode
&
torsions
=
node
.
createChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
p1
,
p2
,
p3
,
p4
;
...
...
@@ -72,7 +76,7 @@ void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& n
void
*
CustomTorsionForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
CustomTorsionForce
*
force
=
NULL
;
try
{
...
...
@@ -90,6 +94,13 @@ void* CustomTorsionForceProxy::deserialize(const SerializationNode& node) const
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
2
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
vector
<
double
>
params
(
force
->
getNumPerTorsionParameters
());
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
...
...
serialization/tests/TestSerializeCustomAngleForce.cpp
View file @
df07fbe9
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
force
.
addGlobalParameter
(
"x"
,
1.3
);
force
.
addGlobalParameter
(
"y"
,
2.221
);
force
.
addPerAngleParameter
(
"z"
);
force
.
addEnergyParameterDerivative
(
"y"
);
vector
<
double
>
params
(
1
);
params
[
0
]
=
1.0
;
force
.
addAngle
(
1
,
2
,
3
,
params
);
...
...
@@ -74,6 +75,9 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
getNumEnergyParameterDerivatives
(),
force2
.
getNumEnergyParameterDerivatives
());
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
ASSERT_EQUAL
(
force
.
getEnergyParameterDerivativeName
(
i
),
force2
.
getEnergyParameterDerivativeName
(
i
));
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumAngles
(),
force2
.
getNumAngles
());
for
(
int
i
=
0
;
i
<
force
.
getNumAngles
();
i
++
)
{
...
...
serialization/tests/TestSerializeCustomBondForce.cpp
View file @
df07fbe9
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
force
.
addGlobalParameter
(
"x"
,
1.3
);
force
.
addGlobalParameter
(
"y"
,
2.221
);
force
.
addPerBondParameter
(
"z"
);
force
.
addEnergyParameterDerivative
(
"y"
);
vector
<
double
>
params
(
1
);
params
[
0
]
=
1.0
;
force
.
addBond
(
1
,
2
,
params
);
...
...
@@ -74,6 +75,9 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
getNumEnergyParameterDerivatives
(),
force2
.
getNumEnergyParameterDerivatives
());
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
ASSERT_EQUAL
(
force
.
getEnergyParameterDerivativeName
(
i
),
force2
.
getEnergyParameterDerivativeName
(
i
));
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumBonds
(),
force2
.
getNumBonds
());
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
...
...
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
View file @
df07fbe9
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
force
.
addGlobalParameter
(
"x"
,
1.3
);
force
.
addGlobalParameter
(
"y"
,
2.221
);
force
.
addPerBondParameter
(
"z"
);
force
.
addEnergyParameterDerivative
(
"y"
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
vector
<
int
>
particles
;
vector
<
double
>
weights
;
...
...
@@ -99,6 +100,9 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
getNumEnergyParameterDerivatives
(),
force2
.
getNumEnergyParameterDerivatives
());
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
ASSERT_EQUAL
(
force
.
getEnergyParameterDerivativeName
(
i
),
force2
.
getEnergyParameterDerivativeName
(
i
));
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumGroups
(),
force2
.
getNumGroups
());
for
(
int
i
=
0
;
i
<
force
.
getNumGroups
();
i
++
)
{
...
...
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
View file @
df07fbe9
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
force
.
addGlobalParameter
(
"x"
,
1.3
);
force
.
addGlobalParameter
(
"y"
,
2.221
);
force
.
addPerBondParameter
(
"z"
);
force
.
addEnergyParameterDerivative
(
"y"
);
vector
<
int
>
particles
(
3
);
vector
<
double
>
params
(
1
);
particles
[
0
]
=
0
;
...
...
@@ -89,6 +90,9 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
getNumEnergyParameterDerivatives
(),
force2
.
getNumEnergyParameterDerivatives
());
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
ASSERT_EQUAL
(
force
.
getEnergyParameterDerivativeName
(
i
),
force2
.
getEnergyParameterDerivativeName
(
i
));
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumBonds
(),
force2
.
getNumBonds
());
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
...
...
serialization/tests/TestSerializeCustomGBForce.cpp
View file @
df07fbe9
...
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -48,6 +48,7 @@ void testSerialization() {
force
.
addGlobalParameter
(
"x"
,
1.3
);
force
.
addGlobalParameter
(
"y"
,
2.221
);
force
.
addPerParticleParameter
(
"z"
);
force
.
addEnergyParameterDerivative
(
"y"
);
force
.
addComputedValue
(
"a"
,
"x+1"
,
CustomGBForce
::
ParticlePairNoExclusions
);
force
.
addComputedValue
(
"b"
,
"y-1"
,
CustomGBForce
::
SingleParticle
);
force
.
addEnergyTerm
(
"a*b"
,
CustomGBForce
::
SingleParticle
);
...
...
@@ -86,6 +87,9 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
getNumEnergyParameterDerivatives
(),
force2
.
getNumEnergyParameterDerivatives
());
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
ASSERT_EQUAL
(
force
.
getEnergyParameterDerivativeName
(
i
),
force2
.
getEnergyParameterDerivativeName
(
i
));
ASSERT_EQUAL
(
force
.
getNumComputedValues
(),
force2
.
getNumComputedValues
());
for
(
int
i
=
0
;
i
<
force
.
getNumComputedValues
();
i
++
)
{
string
name1
,
name2
,
expression1
,
expression2
;
...
...
serialization/tests/TestSerializeCustomTorsionForce.cpp
View file @
df07fbe9
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
force
.
addGlobalParameter
(
"x"
,
1.3
);
force
.
addGlobalParameter
(
"y"
,
2.221
);
force
.
addPerTorsionParameter
(
"z"
);
force
.
addEnergyParameterDerivative
(
"y"
);
vector
<
double
>
params
(
1
);
params
[
0
]
=
1.0
;
force
.
addTorsion
(
1
,
2
,
3
,
4
,
params
);
...
...
@@ -74,6 +75,9 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
getNumEnergyParameterDerivatives
(),
force2
.
getNumEnergyParameterDerivatives
());
for
(
int
i
=
0
;
i
<
force
.
getNumEnergyParameterDerivatives
();
i
++
)
ASSERT_EQUAL
(
force
.
getEnergyParameterDerivativeName
(
i
),
force2
.
getEnergyParameterDerivativeName
(
i
));
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumTorsions
(),
force2
.
getNumTorsions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
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