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
dca54ec7
Commit
dca54ec7
authored
Jun 30, 2016
by
Saurabh Belsare
Browse files
Merged fork with latest original master
parents
cace5edf
01f9e415
Changes
384
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
459 additions
and
37 deletions
+459
-37
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
+1
-1
serialization/include/openmm/serialization/CustomCentroidBondForceProxy.h
...clude/openmm/serialization/CustomCentroidBondForceProxy.h
+53
-0
serialization/src/CMAPTorsionForceProxy.cpp
serialization/src/CMAPTorsionForceProxy.cpp
+7
-3
serialization/src/CustomAngleForceProxy.cpp
serialization/src/CustomAngleForceProxy.cpp
+7
-3
serialization/src/CustomBondForceProxy.cpp
serialization/src/CustomBondForceProxy.cpp
+7
-3
serialization/src/CustomCentroidBondForceProxy.cpp
serialization/src/CustomCentroidBondForceProxy.cpp
+170
-0
serialization/src/CustomCompoundBondForceProxy.cpp
serialization/src/CustomCompoundBondForceProxy.cpp
+7
-3
serialization/src/CustomTorsionForceProxy.cpp
serialization/src/CustomTorsionForceProxy.cpp
+7
-3
serialization/src/HarmonicAngleForceProxy.cpp
serialization/src/HarmonicAngleForceProxy.cpp
+7
-3
serialization/src/HarmonicBondForceProxy.cpp
serialization/src/HarmonicBondForceProxy.cpp
+7
-3
serialization/src/MonteCarloAnisotropicBarostatProxy.cpp
serialization/src/MonteCarloAnisotropicBarostatProxy.cpp
+2
-2
serialization/src/MonteCarloBarostatProxy.cpp
serialization/src/MonteCarloBarostatProxy.cpp
+2
-2
serialization/src/MonteCarloMembraneBarostatProxy.cpp
serialization/src/MonteCarloMembraneBarostatProxy.cpp
+2
-2
serialization/src/PeriodicTorsionForceProxy.cpp
serialization/src/PeriodicTorsionForceProxy.cpp
+7
-3
serialization/src/RBTorsionForceProxy.cpp
serialization/src/RBTorsionForceProxy.cpp
+7
-3
serialization/src/SerializationProxyRegistration.cpp
serialization/src/SerializationProxyRegistration.cpp
+3
-0
serialization/tests/TestSerializeCMAPTorsion.cpp
serialization/tests/TestSerializeCMAPTorsion.cpp
+3
-1
serialization/tests/TestSerializeCustomAngleForce.cpp
serialization/tests/TestSerializeCustomAngleForce.cpp
+3
-1
serialization/tests/TestSerializeCustomBondForce.cpp
serialization/tests/TestSerializeCustomBondForce.cpp
+3
-1
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
+154
-0
No files found.
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
View file @
dca54ec7
...
...
@@ -555,7 +555,7 @@ int main(int argc, char* argv[]) {
try
{
registerRPMDOpenCLKernelFactories
();
if
(
argc
>
1
)
Platform
::
getPlatformByName
(
"OpenCL"
).
setPropertyDefaultValue
(
"
OpenCL
Precision"
,
string
(
argv
[
1
]));
Platform
::
getPlatformByName
(
"OpenCL"
).
setPropertyDefaultValue
(
"Precision"
,
string
(
argv
[
1
]));
testFreeParticles
();
testParaHydrogen
();
testCMMotionRemoval
();
...
...
serialization/include/openmm/serialization/CustomCentroidBondForceProxy.h
0 → 100644
View file @
dca54ec7
#ifndef OPENMM_CUSTOMCENTROIDBONDFORCE_PROXY_H_
#define OPENMM_CUSTOMCENTROIDBONDFORCE_PROXY_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/internal/windowsExport.h"
#include "openmm/serialization/SerializationProxy.h"
namespace
OpenMM
{
/**
* This is a proxy for serializing CustomCentroidBondForce objects.
*/
class
OPENMM_EXPORT
CustomCentroidBondForceProxy
:
public
SerializationProxy
{
public:
CustomCentroidBondForceProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_CUSTOMCENTROIDBONDFORCE_PROXY_H_*/
serialization/src/CMAPTorsionForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ CMAPTorsionForceProxy::CMAPTorsionForceProxy() : SerializationProxy("CMAPTorsion
}
void
CMAPTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
CMAPTorsionForce
&
force
=
*
reinterpret_cast
<
const
CMAPTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
maps
=
node
.
createChildNode
(
"Maps"
);
for
(
int
i
=
0
;
i
<
force
.
getNumMaps
();
i
++
)
{
int
size
;
...
...
@@ -63,11 +64,14 @@ void CMAPTorsionForceProxy::serialize(const void* object, SerializationNode& nod
}
void
*
CMAPTorsionForceProxy
::
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"
);
CMAPTorsionForce
*
force
=
new
CMAPTorsionForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
maps
=
node
.
getChildNode
(
"Maps"
);
for
(
int
i
=
0
;
i
<
(
int
)
maps
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
map
=
maps
.
getChildren
()[
i
];
...
...
serialization/src/CustomAngleForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ CustomAngleForceProxy::CustomAngleForceProxy() : SerializationProxy("CustomAngle
}
void
CustomAngleForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
CustomAngleForce
&
force
=
*
reinterpret_cast
<
const
CustomAngleForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setStringProperty
(
"energy"
,
force
.
getEnergyFunction
());
SerializationNode
&
perAngleParams
=
node
.
createChildNode
(
"PerAngleParameters"
);
for
(
int
i
=
0
;
i
<
force
.
getNumPerAngleParameters
();
i
++
)
{
...
...
@@ -70,12 +71,15 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod
}
void
*
CustomAngleForceProxy
::
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"
);
CustomAngleForce
*
force
=
NULL
;
try
{
CustomAngleForce
*
force
=
new
CustomAngleForce
(
node
.
getStringProperty
(
"energy"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
perAngleParams
=
node
.
getChildNode
(
"PerAngleParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perAngleParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perAngleParams
.
getChildren
()[
i
];
...
...
serialization/src/CustomBondForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ CustomBondForceProxy::CustomBondForceProxy() : SerializationProxy("CustomBondFor
}
void
CustomBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
CustomBondForce
&
force
=
*
reinterpret_cast
<
const
CustomBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setStringProperty
(
"energy"
,
force
.
getEnergyFunction
());
SerializationNode
&
perBondParams
=
node
.
createChildNode
(
"PerBondParameters"
);
for
(
int
i
=
0
;
i
<
force
.
getNumPerBondParameters
();
i
++
)
{
...
...
@@ -70,12 +71,15 @@ void CustomBondForceProxy::serialize(const void* object, SerializationNode& node
}
void
*
CustomBondForceProxy
::
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"
);
CustomBondForce
*
force
=
NULL
;
try
{
CustomBondForce
*
force
=
new
CustomBondForce
(
node
.
getStringProperty
(
"energy"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
perBondParams
=
node
.
getChildNode
(
"PerBondParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perBondParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perBondParams
.
getChildren
()[
i
];
...
...
serialization/src/CustomCentroidBondForceProxy.cpp
0 → 100644
View file @
dca54ec7
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/CustomCentroidBondForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/CustomCentroidBondForce.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
CustomCentroidBondForceProxy
::
CustomCentroidBondForceProxy
()
:
SerializationProxy
(
"CustomCentroidBondForce"
)
{
}
void
CustomCentroidBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
const
CustomCentroidBondForce
&
force
=
*
reinterpret_cast
<
const
CustomCentroidBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setIntProperty
(
"groups"
,
force
.
getNumGroupsPerBond
());
node
.
setStringProperty
(
"energy"
,
force
.
getEnergyFunction
());
SerializationNode
&
perBondParams
=
node
.
createChildNode
(
"PerBondParameters"
);
for
(
int
i
=
0
;
i
<
force
.
getNumPerBondParameters
();
i
++
)
{
perBondParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getPerBondParameterName
(
i
));
}
SerializationNode
&
globalParams
=
node
.
createChildNode
(
"GlobalParameters"
);
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
globalParams
.
createChildNode
(
"Parameter"
).
setStringProperty
(
"name"
,
force
.
getGlobalParameterName
(
i
)).
setDoubleProperty
(
"default"
,
force
.
getGlobalParameterDefaultValue
(
i
));
}
SerializationNode
&
groups
=
node
.
createChildNode
(
"Groups"
);
for
(
int
i
=
0
;
i
<
force
.
getNumGroups
();
i
++
)
{
vector
<
int
>
particles
;
vector
<
double
>
weights
;
force
.
getGroupParameters
(
i
,
particles
,
weights
);
SerializationNode
&
group
=
groups
.
createChildNode
(
"Group"
);
for
(
int
j
=
0
;
j
<
(
int
)
particles
.
size
();
j
++
)
{
SerializationNode
&
node
=
group
.
createChildNode
(
"Particle"
);
node
.
setIntProperty
(
"p"
,
particles
[
j
]);
if
(
j
<
weights
.
size
())
node
.
setDoubleProperty
(
"weight"
,
weights
[
j
]);
}
}
SerializationNode
&
bonds
=
node
.
createChildNode
(
"Bonds"
);
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
vector
<
int
>
groups
;
vector
<
double
>
params
;
force
.
getBondParameters
(
i
,
groups
,
params
);
SerializationNode
&
node
=
bonds
.
createChildNode
(
"Bond"
);
for
(
int
j
=
0
;
j
<
(
int
)
groups
.
size
();
j
++
)
{
stringstream
key
;
key
<<
"g"
;
key
<<
j
+
1
;
node
.
setIntProperty
(
key
.
str
(),
groups
[
j
]);
}
for
(
int
j
=
0
;
j
<
(
int
)
params
.
size
();
j
++
)
{
stringstream
key
;
key
<<
"param"
;
key
<<
j
+
1
;
node
.
setDoubleProperty
(
key
.
str
(),
params
[
j
]);
}
}
SerializationNode
&
functions
=
node
.
createChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
functions
.
createChildNode
(
"Function"
,
&
force
.
getTabulatedFunction
(
i
)).
setStringProperty
(
"name"
,
force
.
getTabulatedFunctionName
(
i
));
}
void
*
CustomCentroidBondForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
throw
OpenMMException
(
"Unsupported version number"
);
CustomCentroidBondForce
*
force
=
NULL
;
try
{
CustomCentroidBondForce
*
force
=
new
CustomCentroidBondForce
(
node
.
getIntProperty
(
"groups"
),
node
.
getStringProperty
(
"energy"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
perBondParams
=
node
.
getChildNode
(
"PerBondParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perBondParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perBondParams
.
getChildren
()[
i
];
force
->
addPerBondParameter
(
parameter
.
getStringProperty
(
"name"
));
}
const
SerializationNode
&
globalParams
=
node
.
getChildNode
(
"GlobalParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
globalParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
const
SerializationNode
&
groups
=
node
.
getChildNode
(
"Groups"
);
for
(
int
i
=
0
;
i
<
(
int
)
groups
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
group
=
groups
.
getChildren
()[
i
];
vector
<
int
>
particles
;
vector
<
double
>
weights
;
for
(
int
j
=
0
;
j
<
(
int
)
group
.
getChildren
().
size
();
j
++
)
{
particles
.
push_back
(
group
.
getChildren
()[
j
].
getIntProperty
(
"p"
));
if
(
group
.
getChildren
()[
j
].
hasProperty
(
"weight"
))
weights
.
push_back
(
group
.
getChildren
()[
j
].
getDoubleProperty
(
"weight"
));
}
force
->
addGroup
(
particles
,
weights
);
}
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"Bonds"
);
vector
<
int
>
bondGroups
(
force
->
getNumGroupsPerBond
());
vector
<
double
>
params
(
force
->
getNumPerBondParameters
());
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
bond
=
bonds
.
getChildren
()[
i
];
for
(
int
j
=
0
;
j
<
(
int
)
bondGroups
.
size
();
j
++
)
{
stringstream
key
;
key
<<
"g"
;
key
<<
j
+
1
;
bondGroups
[
j
]
=
bond
.
getIntProperty
(
key
.
str
());
}
for
(
int
j
=
0
;
j
<
(
int
)
params
.
size
();
j
++
)
{
stringstream
key
;
key
<<
"param"
;
key
<<
j
+
1
;
params
[
j
]
=
bond
.
getDoubleProperty
(
key
.
str
());
}
force
->
addBond
(
bondGroups
,
params
);
}
const
SerializationNode
&
functions
=
node
.
getChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
function
=
functions
.
getChildren
()[
i
];
if
(
function
.
hasProperty
(
"type"
))
{
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
function
.
decodeObject
<
TabulatedFunction
>
());
}
else
{
// This is an old file created before TabulatedFunction existed.
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
new
Continuous1DFunction
(
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)));
}
}
return
force
;
}
catch
(...)
{
if
(
force
!=
NULL
)
delete
force
;
throw
;
}
}
serialization/src/CustomCompoundBondForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ CustomCompoundBondForceProxy::CustomCompoundBondForceProxy() : SerializationProx
}
void
CustomCompoundBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
CustomCompoundBondForce
&
force
=
*
reinterpret_cast
<
const
CustomCompoundBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setIntProperty
(
"particles"
,
force
.
getNumParticlesPerBond
());
node
.
setStringProperty
(
"energy"
,
force
.
getEnergyFunction
());
SerializationNode
&
perBondParams
=
node
.
createChildNode
(
"PerBondParameters"
);
...
...
@@ -80,12 +81,15 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo
}
void
*
CustomCompoundBondForceProxy
::
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"
);
CustomCompoundBondForce
*
force
=
NULL
;
try
{
CustomCompoundBondForce
*
force
=
new
CustomCompoundBondForce
(
node
.
getIntProperty
(
"particles"
),
node
.
getStringProperty
(
"energy"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
perBondParams
=
node
.
getChildNode
(
"PerBondParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perBondParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perBondParams
.
getChildren
()[
i
];
...
...
serialization/src/CustomTorsionForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ CustomTorsionForceProxy::CustomTorsionForceProxy() : SerializationProxy("CustomT
}
void
CustomTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
CustomTorsionForce
&
force
=
*
reinterpret_cast
<
const
CustomTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setStringProperty
(
"energy"
,
force
.
getEnergyFunction
());
SerializationNode
&
perTorsionParams
=
node
.
createChildNode
(
"PerTorsionParameters"
);
for
(
int
i
=
0
;
i
<
force
.
getNumPerTorsionParameters
();
i
++
)
{
...
...
@@ -70,12 +71,15 @@ void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& n
}
void
*
CustomTorsionForceProxy
::
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"
);
CustomTorsionForce
*
force
=
NULL
;
try
{
CustomTorsionForce
*
force
=
new
CustomTorsionForce
(
node
.
getStringProperty
(
"energy"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
perTorsionParams
=
node
.
getChildNode
(
"PerTorsionParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perTorsionParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perTorsionParams
.
getChildren
()[
i
];
...
...
serialization/src/HarmonicAngleForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ HarmonicAngleForceProxy::HarmonicAngleForceProxy() : SerializationProxy("Harmoni
}
void
HarmonicAngleForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
HarmonicAngleForce
&
force
=
*
reinterpret_cast
<
const
HarmonicAngleForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
bonds
=
node
.
createChildNode
(
"Angles"
);
for
(
int
i
=
0
;
i
<
force
.
getNumAngles
();
i
++
)
{
int
particle1
,
particle2
,
particle3
;
...
...
@@ -55,11 +56,14 @@ void HarmonicAngleForceProxy::serialize(const void* object, SerializationNode& n
}
void
*
HarmonicAngleForceProxy
::
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"
);
HarmonicAngleForce
*
force
=
new
HarmonicAngleForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
angles
=
node
.
getChildNode
(
"Angles"
);
for
(
int
i
=
0
;
i
<
(
int
)
angles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
angle
=
angles
.
getChildren
()[
i
];
...
...
serialization/src/HarmonicBondForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ HarmonicBondForceProxy::HarmonicBondForceProxy() : SerializationProxy("HarmonicB
}
void
HarmonicBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
HarmonicBondForce
&
force
=
*
reinterpret_cast
<
const
HarmonicBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
bonds
=
node
.
createChildNode
(
"Bonds"
);
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
int
particle1
,
particle2
;
...
...
@@ -55,11 +56,14 @@ void HarmonicBondForceProxy::serialize(const void* object, SerializationNode& no
}
void
*
HarmonicBondForceProxy
::
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"
);
HarmonicBondForce
*
force
=
new
HarmonicBondForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"Bonds"
);
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
bond
=
bonds
.
getChildren
()[
i
];
...
...
serialization/src/MonteCarloAnisotropicBarostatProxy.cpp
View file @
dca54ec7
...
...
@@ -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: *
* *
...
...
@@ -52,7 +52,7 @@ void MonteCarloAnisotropicBarostatProxy::serialize(const void* object, Serializa
node
.
setBoolProperty
(
"scalex"
,
force
.
getScaleX
());
node
.
setBoolProperty
(
"scaley"
,
force
.
getScaleY
());
node
.
setBoolProperty
(
"scalez"
,
force
.
getScaleZ
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
getTemperature
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
get
Default
Temperature
());
node
.
setIntProperty
(
"frequency"
,
force
.
getFrequency
());
node
.
setIntProperty
(
"randomSeed"
,
force
.
getRandomNumberSeed
());
}
...
...
serialization/src/MonteCarloBarostatProxy.cpp
View file @
dca54ec7
...
...
@@ -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: *
* *
...
...
@@ -46,7 +46,7 @@ void MonteCarloBarostatProxy::serialize(const void* object, SerializationNode& n
const
MonteCarloBarostat
&
force
=
*
reinterpret_cast
<
const
MonteCarloBarostat
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setDoubleProperty
(
"pressure"
,
force
.
getDefaultPressure
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
getTemperature
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
get
Default
Temperature
());
node
.
setIntProperty
(
"frequency"
,
force
.
getFrequency
());
node
.
setIntProperty
(
"randomSeed"
,
force
.
getRandomNumberSeed
());
}
...
...
serialization/src/MonteCarloMembraneBarostatProxy.cpp
View file @
dca54ec7
...
...
@@ -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: *
* *
...
...
@@ -47,7 +47,7 @@ void MonteCarloMembraneBarostatProxy::serialize(const void* object, Serializatio
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setDoubleProperty
(
"pressure"
,
force
.
getDefaultPressure
());
node
.
setDoubleProperty
(
"surfaceTension"
,
force
.
getDefaultSurfaceTension
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
getTemperature
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
get
Default
Temperature
());
node
.
setIntProperty
(
"xymode"
,
force
.
getXYMode
());
node
.
setIntProperty
(
"zmode"
,
force
.
getZMode
());
node
.
setIntProperty
(
"frequency"
,
force
.
getFrequency
());
...
...
serialization/src/PeriodicTorsionForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ PeriodicTorsionForceProxy::PeriodicTorsionForceProxy() : SerializationProxy("Per
}
void
PeriodicTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
PeriodicTorsionForce
&
force
=
*
reinterpret_cast
<
const
PeriodicTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
torsions
=
node
.
createChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
particle1
,
particle2
,
particle3
,
particle4
,
periodicity
;
...
...
@@ -55,11 +56,14 @@ void PeriodicTorsionForceProxy::serialize(const void* object, SerializationNode&
}
void
*
PeriodicTorsionForceProxy
::
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"
);
PeriodicTorsionForce
*
force
=
new
PeriodicTorsionForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
torsion
=
torsions
.
getChildren
()[
i
];
...
...
serialization/src/RBTorsionForceProxy.cpp
View file @
dca54ec7
...
...
@@ -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,9 +42,10 @@ RBTorsionForceProxy::RBTorsionForceProxy() : SerializationProxy("RBTorsionForce"
}
void
RBTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
2
);
const
RBTorsionForce
&
force
=
*
reinterpret_cast
<
const
RBTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
torsions
=
node
.
createChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
particle1
,
particle2
,
particle3
,
particle4
;
...
...
@@ -55,11 +56,14 @@ void RBTorsionForceProxy::serialize(const void* object, SerializationNode& node)
}
void
*
RBTorsionForceProxy
::
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"
);
RBTorsionForce
*
force
=
new
RBTorsionForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
torsion
=
torsions
.
getChildren
()[
i
];
...
...
serialization/src/SerializationProxyRegistration.cpp
View file @
dca54ec7
...
...
@@ -36,6 +36,7 @@
#include "openmm/CompoundIntegrator.h"
#include "openmm/CustomAngleForce.h"
#include "openmm/CustomBondForce.h"
#include "openmm/CustomCentroidBondForce.h"
#include "openmm/CustomCompoundBondForce.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/CustomGBForce.h"
...
...
@@ -68,6 +69,7 @@
#include "openmm/serialization/CompoundIntegratorProxy.h"
#include "openmm/serialization/CustomAngleForceProxy.h"
#include "openmm/serialization/CustomBondForceProxy.h"
#include "openmm/serialization/CustomCentroidBondForceProxy.h"
#include "openmm/serialization/CustomCompoundBondForceProxy.h"
#include "openmm/serialization/CustomExternalForceProxy.h"
#include "openmm/serialization/CustomGBForceProxy.h"
...
...
@@ -118,6 +120,7 @@ extern "C" void registerSerializationProxies() {
SerializationProxy
::
registerProxy
(
typeid
(
Continuous3DFunction
),
new
Continuous3DFunctionProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomAngleForce
),
new
CustomAngleForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomBondForce
),
new
CustomBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomCentroidBondForce
),
new
CustomCentroidBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomCompoundBondForce
),
new
CustomCompoundBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomExternalForce
),
new
CustomExternalForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomGBForce
),
new
CustomGBForceProxy
());
...
...
serialization/tests/TestSerializeCMAPTorsion.cpp
View file @
dca54ec7
...
...
@@ -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: *
* *
...
...
@@ -55,6 +55,7 @@ void testSerialization() {
force
.
addTorsion
(
0
,
0
,
2
,
3
,
4
,
5
,
6
,
7
,
8
);
force
.
addTorsion
(
1
,
2
,
3
,
4
,
7
,
1
,
2
,
3
,
4
);
force
.
addTorsion
(
1
,
5
,
1
,
2
,
3
,
2
,
3
,
4
,
8
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -66,6 +67,7 @@ void testSerialization() {
CMAPTorsionForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumMaps
(),
force2
.
getNumMaps
());
for
(
int
i
=
0
;
i
<
force
.
getNumMaps
();
i
++
)
{
int
size1
,
size2
;
...
...
serialization/tests/TestSerializeCustomAngleForce.cpp
View file @
dca54ec7
...
...
@@ -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: *
* *
...
...
@@ -53,6 +53,7 @@ void testSerialization() {
force
.
addAngle
(
4
,
0
,
1
,
params
);
params
[
0
]
=
2.1
;
force
.
addAngle
(
3
,
7
,
6
,
params
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumAngles
(),
force2
.
getNumAngles
());
for
(
int
i
=
0
;
i
<
force
.
getNumAngles
();
i
++
)
{
int
a1
,
a2
,
b1
,
b2
,
c1
,
c2
;
...
...
serialization/tests/TestSerializeCustomBondForce.cpp
View file @
dca54ec7
...
...
@@ -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: *
* *
...
...
@@ -53,6 +53,7 @@ void testSerialization() {
force
.
addBond
(
4
,
0
,
params
);
params
[
0
]
=
2.1
;
force
.
addBond
(
3
,
7
,
params
);
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
...
...
@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumBonds
(),
force2
.
getNumBonds
());
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
int
a1
,
a2
,
b1
,
b2
;
...
...
serialization/tests/TestSerializeCustomCentroidBondForce.cpp
0 → 100644
View file @
dca54ec7
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/CustomCentroidBondForce.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
void
testSerialization
()
{
// Create a Force.
CustomCentroidBondForce
force
(
3
,
"5*sin(distance(g1,g2))^2+y*z"
);
force
.
setForceGroup
(
3
);
force
.
addGlobalParameter
(
"x"
,
1.3
);
force
.
addGlobalParameter
(
"y"
,
2.221
);
force
.
addPerBondParameter
(
"z"
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
vector
<
int
>
particles
;
vector
<
double
>
weights
;
for
(
int
j
=
0
;
j
<
i
+
1
;
j
++
)
{
particles
.
push_back
(
i
+
j
);
if
(
i
<
2
)
weights
.
push_back
(
1.0
/
(
i
+
1
));
}
force
.
addGroup
(
particles
,
weights
);
}
vector
<
int
>
groups
(
3
);
vector
<
double
>
params
(
1
);
groups
[
0
]
=
0
;
groups
[
1
]
=
1
;
groups
[
2
]
=
2
;
params
[
0
]
=
1.0
;
force
.
addBond
(
groups
,
params
);
groups
[
0
]
=
2
;
groups
[
1
]
=
3
;
groups
[
2
]
=
4
;
params
[
0
]
=
-
3.3
;
force
.
addBond
(
groups
,
params
);
groups
[
0
]
=
3
;
groups
[
1
]
=
5
;
groups
[
2
]
=
1
;
params
[
0
]
=
2.1
;
force
.
addBond
(
groups
,
params
);
vector
<
double
>
values
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addTabulatedFunction
(
"f"
,
new
Continuous1DFunction
(
values
,
0.5
,
1.5
));
force
.
setUsesPeriodicBoundaryConditions
(
true
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
CustomCentroidBondForce
>
(
&
force
,
"Force"
,
buffer
);
CustomCentroidBondForce
*
copy
=
XmlSerializer
::
deserialize
<
CustomCentroidBondForce
>
(
buffer
);
// Compare the two forces to see if they are identical.
CustomCentroidBondForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
getNumGroupsPerBond
(),
force2
.
getNumGroupsPerBond
());
ASSERT_EQUAL
(
force
.
getEnergyFunction
(),
force2
.
getEnergyFunction
());
ASSERT_EQUAL
(
force
.
getNumPerBondParameters
(),
force2
.
getNumPerBondParameters
());
for
(
int
i
=
0
;
i
<
force
.
getNumPerBondParameters
();
i
++
)
ASSERT_EQUAL
(
force
.
getPerBondParameterName
(
i
),
force2
.
getPerBondParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getNumGlobalParameters
(),
force2
.
getNumGlobalParameters
());
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
{
ASSERT_EQUAL
(
force
.
getGlobalParameterName
(
i
),
force2
.
getGlobalParameterName
(
i
));
ASSERT_EQUAL
(
force
.
getGlobalParameterDefaultValue
(
i
),
force2
.
getGlobalParameterDefaultValue
(
i
));
}
ASSERT_EQUAL
(
force
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumGroups
(),
force2
.
getNumGroups
());
for
(
int
i
=
0
;
i
<
force
.
getNumGroups
();
i
++
)
{
vector
<
int
>
particles1
,
particles2
;
vector
<
double
>
weights1
,
weights2
;
force
.
getGroupParameters
(
i
,
particles1
,
weights1
);
force2
.
getGroupParameters
(
i
,
particles2
,
weights2
);
ASSERT_EQUAL
(
weights1
.
size
(),
weights2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
weights1
.
size
();
j
++
)
ASSERT_EQUAL
(
weights1
[
j
],
weights2
[
j
]);
ASSERT_EQUAL
(
particles1
.
size
(),
particles2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
particles1
.
size
();
j
++
)
ASSERT_EQUAL
(
particles1
[
j
],
particles2
[
j
]);
}
ASSERT_EQUAL
(
force
.
getNumBonds
(),
force2
.
getNumBonds
());
for
(
int
i
=
0
;
i
<
force
.
getNumBonds
();
i
++
)
{
vector
<
int
>
groups1
,
groups2
;
vector
<
double
>
params1
,
params2
;
force
.
getBondParameters
(
i
,
groups1
,
params1
);
force2
.
getBondParameters
(
i
,
groups2
,
params2
);
ASSERT_EQUAL
(
params1
.
size
(),
params2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
params1
.
size
();
j
++
)
ASSERT_EQUAL
(
params1
[
j
],
params2
[
j
]);
ASSERT_EQUAL
(
groups1
.
size
(),
groups2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
groups1
.
size
();
j
++
)
ASSERT_EQUAL
(
groups1
[
j
],
groups2
[
j
]);
}
ASSERT_EQUAL
(
force
.
getNumTabulatedFunctions
(),
force2
.
getNumTabulatedFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
{
double
min1
,
min2
,
max1
,
max2
;
vector
<
double
>
val1
,
val2
;
dynamic_cast
<
Continuous1DFunction
&>
(
force
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val1
,
min1
,
max1
);
dynamic_cast
<
Continuous1DFunction
&>
(
force2
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
force
.
getTabulatedFunctionName
(
i
),
force2
.
getTabulatedFunctionName
(
i
));
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
val1
.
size
();
j
++
)
ASSERT_EQUAL
(
val1
[
j
],
val2
[
j
]);
}
}
int
main
()
{
try
{
testSerialization
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
Prev
1
…
12
13
14
15
16
17
18
19
20
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