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
4c6cf680
Unverified
Commit
4c6cf680
authored
Mar 10, 2021
by
Peter Eastman
Committed by
GitHub
Mar 10, 2021
Browse files
Added name property to Forces (#3049)
parent
7c2e5991
Changes
67
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
82 additions
and
12 deletions
+82
-12
openmmapi/include/openmm/Force.h
openmmapi/include/openmm/Force.h
+13
-1
openmmapi/src/Force.cpp
openmmapi/src/Force.cpp
+24
-1
plugins/amoeba/serialization/src/AmoebaGeneralizedKirkwoodForceProxy.cpp
...serialization/src/AmoebaGeneralizedKirkwoodForceProxy.cpp
+3
-2
plugins/amoeba/serialization/src/AmoebaMultipoleForceProxy.cpp
...ns/amoeba/serialization/src/AmoebaMultipoleForceProxy.cpp
+3
-2
plugins/amoeba/serialization/src/AmoebaTorsionTorsionForceProxy.cpp
...oeba/serialization/src/AmoebaTorsionTorsionForceProxy.cpp
+3
-2
plugins/amoeba/serialization/src/AmoebaVdwForceProxy.cpp
plugins/amoeba/serialization/src/AmoebaVdwForceProxy.cpp
+3
-2
plugins/amoeba/serialization/src/AmoebaWcaDispersionForceProxy.cpp
...moeba/serialization/src/AmoebaWcaDispersionForceProxy.cpp
+3
-2
plugins/amoeba/serialization/src/HippoNonbondedForceProxy.cpp
...ins/amoeba/serialization/src/HippoNonbondedForceProxy.cpp
+2
-0
plugins/amoeba/serialization/tests/TestSerializeAmoebaGeneralizedKirkwoodForce.cpp
...ion/tests/TestSerializeAmoebaGeneralizedKirkwoodForce.cpp
+2
-0
plugins/amoeba/serialization/tests/TestSerializeAmoebaMultipoleForce.cpp
...serialization/tests/TestSerializeAmoebaMultipoleForce.cpp
+2
-0
plugins/amoeba/serialization/tests/TestSerializeAmoebaTorsionTorsionForce.cpp
...lization/tests/TestSerializeAmoebaTorsionTorsionForce.cpp
+2
-0
plugins/amoeba/serialization/tests/TestSerializeAmoebaVdwForce.cpp
...moeba/serialization/tests/TestSerializeAmoebaVdwForce.cpp
+2
-0
plugins/amoeba/serialization/tests/TestSerializeAmoebaWcaDispersionForce.cpp
...alization/tests/TestSerializeAmoebaWcaDispersionForce.cpp
+2
-0
plugins/amoeba/serialization/tests/TestSerializeHippoNonbondedForce.cpp
.../serialization/tests/TestSerializeHippoNonbondedForce.cpp
+2
-0
plugins/drude/serialization/src/DrudeForceProxy.cpp
plugins/drude/serialization/src/DrudeForceProxy.cpp
+4
-0
plugins/drude/serialization/tests/TestSerializeDrudeForce.cpp
...ins/drude/serialization/tests/TestSerializeDrudeForce.cpp
+4
-0
serialization/src/AndersenThermostatProxy.cpp
serialization/src/AndersenThermostatProxy.cpp
+2
-0
serialization/src/CMAPTorsionForceProxy.cpp
serialization/src/CMAPTorsionForceProxy.cpp
+2
-0
serialization/src/CMMotionRemoverProxy.cpp
serialization/src/CMMotionRemoverProxy.cpp
+2
-0
serialization/src/CustomAngleForceProxy.cpp
serialization/src/CustomAngleForceProxy.cpp
+2
-0
No files found.
openmmapi/include/openmm/Force.h
View file @
4c6cf680
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-20
1
2 Stanford University and the Authors. *
* Portions copyright (c) 2008-202
1
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
#include "internal/windowsExport.h"
#include <string>
namespace
OpenMM
{
...
...
@@ -78,6 +79,16 @@ public:
* @param group the group index. Legal values are between 0 and 31 (inclusive).
*/
void
setForceGroup
(
int
group
);
/**
* Get the name of this Force. This is an arbitrary, user modifiable identifier.
* By default it equals the class name, but you can change it to anything useful.
*/
const
std
::
string
&
getName
()
const
;
/**
* Set the name of this Force. This is an arbitrary, user modifiable identifier.
* By default it equals the class name, but you can change it to anything useful.
*/
void
setName
(
const
std
::
string
&
name
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions. This method should be overridden for all Force subclasses, or
...
...
@@ -108,6 +119,7 @@ protected:
ContextImpl
&
getContextImpl
(
Context
&
context
);
private:
int
forceGroup
;
std
::
string
name
;
};
}
// namespace OpenMM
...
...
openmmapi/src/Force.cpp
View file @
4c6cf680
...
...
@@ -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) 2012 Stanford University and the Authors.
*
* Portions copyright (c) 2012
-2021
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -34,6 +34,7 @@
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ForceImpl.h"
#include "openmm/serialization/SerializationProxy.h"
#include <vector>
using
namespace
OpenMM
;
...
...
@@ -49,6 +50,28 @@ void Force::setForceGroup(int group) {
forceGroup
=
group
;
}
const
string
&
Force
::
getName
()
const
{
if
(
name
.
size
()
==
0
)
{
// The name hasn't been set yet, so initialize it to the class name. We first
// try to use a SerializationProxy to get the name. If none is registered,
// we use the mangled name generated by the compiler. (We can't do this in the
// constructor, because typeid() doesn't work properly in constructors.)
Force
&
thisRef
=
*
const_cast
<
Force
*>
(
this
);
try
{
thisRef
.
name
=
SerializationProxy
::
getProxy
(
typeid
(
*
this
)).
getTypeName
();
}
catch
(...)
{
thisRef
.
name
=
typeid
(
*
this
).
name
();
}
}
return
name
;
}
void
Force
::
setName
(
const
string
&
name
)
{
this
->
name
=
name
;
}
bool
Force
::
usesPeriodicBoundaryConditions
()
const
{
throw
OpenMMException
(
"usesPeriodicBoundaryConditions is not implemented"
);
}
...
...
plugins/amoeba/serialization/src/AmoebaGeneralizedKirkwoodForceProxy.cpp
View file @
4c6cf680
...
...
@@ -46,6 +46,7 @@ void AmoebaGeneralizedKirkwoodForceProxy::serialize(const void* object, Serializ
const
AmoebaGeneralizedKirkwoodForce
&
force
=
*
reinterpret_cast
<
const
AmoebaGeneralizedKirkwoodForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setDoubleProperty
(
"GeneralizedKirkwoodSolventDielectric"
,
force
.
getSolventDielectric
());
node
.
setDoubleProperty
(
"GeneralizedKirkwoodSoluteDielectric"
,
force
.
getSoluteDielectric
());
//node.setDoubleProperty("GeneralizedKirkwoodDielectricOffset", force.getDielectricOffset());
...
...
@@ -68,8 +69,8 @@ void* AmoebaGeneralizedKirkwoodForceProxy::deserialize(const SerializationNode&
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaGeneralizedKirkwoodForce
*
force
=
new
AmoebaGeneralizedKirkwoodForce
();
try
{
if
(
version
>
1
)
force
->
set
ForceGroup
(
node
.
get
Int
Property
(
"
forceGroup"
,
0
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
set
Name
(
node
.
get
String
Property
(
"
name"
,
force
->
getName
()
));
force
->
setSolventDielectric
(
node
.
getDoubleProperty
(
"GeneralizedKirkwoodSolventDielectric"
));
force
->
setSoluteDielectric
(
node
.
getDoubleProperty
(
"GeneralizedKirkwoodSoluteDielectric"
));
//force->setDielectricOffset( node.getDoubleProperty("GeneralizedKirkwoodDielectricOffset"));
...
...
plugins/amoeba/serialization/src/AmoebaMultipoleForceProxy.cpp
View file @
4c6cf680
...
...
@@ -72,6 +72,7 @@ void AmoebaMultipoleForceProxy::serialize(const void* object, SerializationNode&
const
AmoebaMultipoleForce
&
force
=
*
reinterpret_cast
<
const
AmoebaMultipoleForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setIntProperty
(
"nonbondedMethod"
,
force
.
getNonbondedMethod
());
node
.
setIntProperty
(
"polarizationType"
,
force
.
getPolarizationType
());
node
.
setIntProperty
(
"mutualInducedMaxIterations"
,
force
.
getMutualInducedMaxIterations
());
...
...
@@ -137,8 +138,8 @@ void* AmoebaMultipoleForceProxy::deserialize(const SerializationNode& node) cons
AmoebaMultipoleForce
*
force
=
new
AmoebaMultipoleForce
();
try
{
if
(
version
>
3
)
force
->
set
ForceGroup
(
node
.
get
Int
Property
(
"
forceGroup"
,
0
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
set
Name
(
node
.
get
String
Property
(
"
name"
,
force
->
getName
()
));
force
->
setNonbondedMethod
(
static_cast
<
AmoebaMultipoleForce
::
NonbondedMethod
>
(
node
.
getIntProperty
(
"nonbondedMethod"
)));
if
(
version
>=
2
)
force
->
setPolarizationType
(
static_cast
<
AmoebaMultipoleForce
::
PolarizationType
>
(
node
.
getIntProperty
(
"polarizationType"
)));
...
...
plugins/amoeba/serialization/src/AmoebaTorsionTorsionForceProxy.cpp
View file @
4c6cf680
...
...
@@ -66,6 +66,7 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization
node
.
setIntProperty
(
"version"
,
3
);
const
AmoebaTorsionTorsionForce
&
force
=
*
reinterpret_cast
<
const
AmoebaTorsionTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
// grid[xIdx][yIdx][6 values]
...
...
@@ -123,8 +124,8 @@ void* AmoebaTorsionTorsionForceProxy::deserialize(const SerializationNode& node)
AmoebaTorsionTorsionForce
*
force
=
new
AmoebaTorsionTorsionForce
();
try
{
if
(
version
>
1
)
force
->
set
ForceGroup
(
node
.
get
Int
Property
(
"
forceGroup"
,
0
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
set
Name
(
node
.
get
String
Property
(
"
name"
,
force
->
getName
()
));
if
(
version
>
2
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
grids
=
node
.
getChildNode
(
"TorsionTorsionGrids"
);
...
...
plugins/amoeba/serialization/src/AmoebaVdwForceProxy.cpp
View file @
4c6cf680
...
...
@@ -47,6 +47,7 @@ void AmoebaVdwForceProxy::serialize(const void* object, SerializationNode& node)
bool
useTypes
=
force
.
getUseParticleTypes
();
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setStringProperty
(
"SigmaCombiningRule"
,
force
.
getSigmaCombiningRule
());
node
.
setStringProperty
(
"EpsilonCombiningRule"
,
force
.
getEpsilonCombiningRule
());
node
.
setDoubleProperty
(
"VdwCutoff"
,
force
.
getCutoffDistance
());
...
...
@@ -101,8 +102,8 @@ void* AmoebaVdwForceProxy::deserialize(const SerializationNode& node) const {
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaVdwForce
*
force
=
new
AmoebaVdwForce
();
try
{
if
(
version
>
1
)
force
->
set
ForceGroup
(
node
.
get
Int
Property
(
"
forceGroup"
,
0
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
set
Name
(
node
.
get
String
Property
(
"
name"
,
force
->
getName
()
));
force
->
setSigmaCombiningRule
(
node
.
getStringProperty
(
"SigmaCombiningRule"
));
force
->
setEpsilonCombiningRule
(
node
.
getStringProperty
(
"EpsilonCombiningRule"
));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"VdwCutoff"
));
...
...
plugins/amoeba/serialization/src/AmoebaWcaDispersionForceProxy.cpp
View file @
4c6cf680
...
...
@@ -45,6 +45,7 @@ void AmoebaWcaDispersionForceProxy::serialize(const void* object, SerializationN
node
.
setIntProperty
(
"version"
,
2
);
const
AmoebaWcaDispersionForce
&
force
=
*
reinterpret_cast
<
const
AmoebaWcaDispersionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setDoubleProperty
(
"Epso"
,
force
.
getEpso
());
node
.
setDoubleProperty
(
"Epsh"
,
force
.
getEpsh
());
node
.
setDoubleProperty
(
"Rmino"
,
force
.
getRmino
());
...
...
@@ -70,8 +71,8 @@ void* AmoebaWcaDispersionForceProxy::deserialize(const SerializationNode& node)
AmoebaWcaDispersionForce
*
force
=
new
AmoebaWcaDispersionForce
();
try
{
if
(
version
>
1
)
force
->
set
ForceGroup
(
node
.
get
Int
Property
(
"
forceGroup"
,
0
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
set
Name
(
node
.
get
String
Property
(
"
name"
,
force
->
getName
()
));
force
->
setEpso
(
node
.
getDoubleProperty
(
"Epso"
));
force
->
setEpsh
(
node
.
getDoubleProperty
(
"Epsh"
));
force
->
setRmino
(
node
.
getDoubleProperty
(
"Rmino"
));
...
...
plugins/amoeba/serialization/src/HippoNonbondedForceProxy.cpp
View file @
4c6cf680
...
...
@@ -46,6 +46,7 @@ void HippoNonbondedForceProxy::serialize(const void* object, SerializationNode&
const
HippoNonbondedForce
&
force
=
*
reinterpret_cast
<
const
HippoNonbondedForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setIntProperty
(
"nonbondedMethod"
,
force
.
getNonbondedMethod
());
node
.
setDoubleProperty
(
"cutoffDistance"
,
force
.
getCutoffDistance
());
node
.
setDoubleProperty
(
"switchingDistance"
,
force
.
getSwitchingDistance
());
...
...
@@ -122,6 +123,7 @@ void* HippoNonbondedForceProxy::deserialize(const SerializationNode& node) const
HippoNonbondedForce
*
force
=
new
HippoNonbondedForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setName
(
node
.
getStringProperty
(
"name"
,
force
->
getName
()));
force
->
setNonbondedMethod
(
static_cast
<
HippoNonbondedForce
::
NonbondedMethod
>
(
node
.
getIntProperty
(
"nonbondedMethod"
)));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoffDistance"
));
force
->
setSwitchingDistance
(
node
.
getDoubleProperty
(
"switchingDistance"
));
...
...
plugins/amoeba/serialization/tests/TestSerializeAmoebaGeneralizedKirkwoodForce.cpp
View file @
4c6cf680
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
AmoebaGeneralizedKirkwoodForce
force1
;
force1
.
setForceGroup
(
3
);
force1
.
setName
(
"custom name"
);
force1
.
setSolventDielectric
(
80.0
);
force1
.
setSoluteDielectric
(
1.0
);
//force1.setDielectricOffset( 0.09);
...
...
@@ -66,6 +67,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical.
AmoebaGeneralizedKirkwoodForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force1
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force1
.
getName
(),
force2
.
getName
());
ASSERT_EQUAL
(
force1
.
getSolventDielectric
(),
force2
.
getSolventDielectric
());
ASSERT_EQUAL
(
force1
.
getSoluteDielectric
(),
force2
.
getSoluteDielectric
());
//ASSERT_EQUAL(force1.getDielectricOffset(), force2.getDielectricOffset());
...
...
plugins/amoeba/serialization/tests/TestSerializeAmoebaMultipoleForce.cpp
View file @
4c6cf680
...
...
@@ -60,6 +60,7 @@ void testSerialization() {
AmoebaMultipoleForce
force1
;
force1
.
setForceGroup
(
3
);
force1
.
setName
(
"custom name"
);
force1
.
setNonbondedMethod
(
AmoebaMultipoleForce
::
NoCutoff
);
force1
.
setCutoffDistance
(
0.9
);
force1
.
setAEwald
(
0.544
);
...
...
@@ -111,6 +112,7 @@ void testSerialization() {
AmoebaMultipoleForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force1
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force1
.
getName
(),
force2
.
getName
());
ASSERT_EQUAL
(
force1
.
getCutoffDistance
(),
force2
.
getCutoffDistance
());
ASSERT_EQUAL
(
force1
.
getNonbondedMethod
(),
force2
.
getNonbondedMethod
());
ASSERT_EQUAL
(
force1
.
getAEwald
(),
force2
.
getAEwald
());
...
...
plugins/amoeba/serialization/tests/TestSerializeAmoebaTorsionTorsionForce.cpp
View file @
4c6cf680
...
...
@@ -82,6 +82,7 @@ void testSerialization() {
AmoebaTorsionTorsionForce
force1
;
force1
.
setForceGroup
(
3
);
force1
.
setName
(
"custom name"
);
for
(
unsigned
int
ii
=
0
;
ii
<
5
;
ii
++
)
{
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>
gridVector
;
loadTorsionTorsionGrid
(
gridVector
);
...
...
@@ -102,6 +103,7 @@ void testSerialization() {
AmoebaTorsionTorsionForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force1
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force1
.
getName
(),
force2
.
getName
());
ASSERT_EQUAL
(
force1
.
usesPeriodicBoundaryConditions
(),
force2
.
usesPeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force1
.
getNumTorsionTorsions
(),
force2
.
getNumTorsionTorsions
());
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
force1
.
getNumTorsionTorsions
());
ii
++
)
{
...
...
plugins/amoeba/serialization/tests/TestSerializeAmoebaVdwForce.cpp
View file @
4c6cf680
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
AmoebaVdwForce
force1
;
force1
.
setForceGroup
(
3
);
force1
.
setName
(
"custom name"
);
force1
.
setSigmaCombiningRule
(
"GEOMETRIC"
);
force1
.
setEpsilonCombiningRule
(
"GEOMETRIC"
);
force1
.
setCutoff
(
0.9
);
...
...
@@ -74,6 +75,7 @@ void testSerialization() {
AmoebaVdwForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force1
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force1
.
getName
(),
force2
.
getName
());
ASSERT_EQUAL
(
force1
.
getSigmaCombiningRule
(),
force2
.
getSigmaCombiningRule
());
ASSERT_EQUAL
(
force1
.
getEpsilonCombiningRule
(),
force2
.
getEpsilonCombiningRule
());
ASSERT_EQUAL
(
force1
.
getCutoff
(),
force2
.
getCutoff
());
...
...
plugins/amoeba/serialization/tests/TestSerializeAmoebaWcaDispersionForce.cpp
View file @
4c6cf680
...
...
@@ -46,6 +46,7 @@ void testSerialization() {
AmoebaWcaDispersionForce
force1
;
force1
.
setForceGroup
(
3
);
force1
.
setName
(
"custom name"
);
force1
.
setEpso
(
1.0
);
force1
.
setEpsh
(
1.1
);
force1
.
setRmino
(
1.2
);
...
...
@@ -70,6 +71,7 @@ void testSerialization() {
AmoebaWcaDispersionForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force1
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force1
.
getName
(),
force2
.
getName
());
ASSERT_EQUAL
(
force1
.
getEpso
(),
force2
.
getEpso
());
ASSERT_EQUAL
(
force1
.
getEpsh
(),
force2
.
getEpsh
());
ASSERT_EQUAL
(
force1
.
getRmino
(),
force2
.
getRmino
());
...
...
plugins/amoeba/serialization/tests/TestSerializeHippoNonbondedForce.cpp
View file @
4c6cf680
...
...
@@ -48,6 +48,7 @@ void testSerialization() {
HippoNonbondedForce
force1
;
force1
.
setForceGroup
(
3
);
force1
.
setName
(
"custom name"
);
force1
.
setNonbondedMethod
(
HippoNonbondedForce
::
PME
);
force1
.
setCutoffDistance
(
0.7
);
force1
.
setSwitchingDistance
(
0.6
);
...
...
@@ -79,6 +80,7 @@ void testSerialization() {
HippoNonbondedForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force1
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force1
.
getName
(),
force2
.
getName
());
ASSERT_EQUAL
(
force1
.
getNonbondedMethod
(),
force2
.
getNonbondedMethod
());
ASSERT_EQUAL
(
force1
.
getCutoffDistance
(),
force2
.
getCutoffDistance
());
ASSERT_EQUAL
(
force1
.
getSwitchingDistance
(),
force2
.
getSwitchingDistance
());
...
...
plugins/drude/serialization/src/DrudeForceProxy.cpp
View file @
4c6cf680
...
...
@@ -44,6 +44,8 @@ DrudeForceProxy::DrudeForceProxy() : SerializationProxy("DrudeForce") {
void
DrudeForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
DrudeForce
&
force
=
*
reinterpret_cast
<
const
DrudeForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
SerializationNode
&
particles
=
node
.
createChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
int
p
,
p1
,
p2
,
p3
,
p4
;
...
...
@@ -66,6 +68,8 @@ void* DrudeForceProxy::deserialize(const SerializationNode& node) const {
throw
OpenMMException
(
"Unsupported version number"
);
DrudeForce
*
force
=
new
DrudeForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setName
(
node
.
getStringProperty
(
"name"
,
force
->
getName
()));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
auto
&
particle
:
particles
.
getChildren
())
force
->
addParticle
(
particle
.
getIntProperty
(
"p"
),
particle
.
getIntProperty
(
"p1"
),
particle
.
getIntProperty
(
"p2"
),
particle
.
getIntProperty
(
"p3"
),
particle
.
getIntProperty
(
"p4"
),
...
...
plugins/drude/serialization/tests/TestSerializeDrudeForce.cpp
View file @
4c6cf680
...
...
@@ -45,6 +45,8 @@ void testSerialization() {
// Create a Force.
DrudeForce
force1
;
force1
.
setForceGroup
(
3
);
force1
.
setName
(
"custom name"
);
force1
.
addParticle
(
0
,
1
,
2
,
3
,
4
,
0.5
,
1.0
,
1.5
,
2.0
);
force1
.
addParticle
(
2
,
3
,
7
,
8
,
9
,
0.1
,
1e-4
,
1.0
,
0.9
);
force1
.
addParticle
(
5
,
6
,
-
1
,
-
1
,
-
1
,
0.2
,
0.1
,
1.0
,
1.0
);
...
...
@@ -59,6 +61,8 @@ void testSerialization() {
// Compare the two forces to see if they are identical.
DrudeForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force1
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force1
.
getName
(),
force2
.
getName
());
ASSERT_EQUAL
(
force1
.
getNumParticles
(),
force2
.
getNumParticles
());
for
(
int
i
=
0
;
i
<
(
int
)
force1
.
getNumParticles
();
i
++
)
{
int
a1
,
a2
,
a3
,
a4
,
a5
,
b1
,
b2
,
b3
,
b4
,
b5
;
...
...
serialization/src/AndersenThermostatProxy.cpp
View file @
4c6cf680
...
...
@@ -48,6 +48,7 @@ void AndersenThermostatProxy::serialize(const void* object, SerializationNode& n
node
.
setDoubleProperty
(
"frequency"
,
force
.
getDefaultCollisionFrequency
());
node
.
setIntProperty
(
"randomSeed"
,
force
.
getRandomNumberSeed
());
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
}
void
*
AndersenThermostatProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -57,6 +58,7 @@ void* AndersenThermostatProxy::deserialize(const SerializationNode& node) const
try
{
AndersenThermostat
*
force
=
new
AndersenThermostat
(
node
.
getDoubleProperty
(
"temperature"
),
node
.
getDoubleProperty
(
"frequency"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setName
(
node
.
getStringProperty
(
"name"
,
force
->
getName
()));
force
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
return
force
;
}
...
...
serialization/src/CMAPTorsionForceProxy.cpp
View file @
4c6cf680
...
...
@@ -45,6 +45,7 @@ void CMAPTorsionForceProxy::serialize(const void* object, SerializationNode& nod
node
.
setIntProperty
(
"version"
,
2
);
const
CMAPTorsionForce
&
force
=
*
reinterpret_cast
<
const
CMAPTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
maps
=
node
.
createChildNode
(
"Maps"
);
for
(
int
i
=
0
;
i
<
force
.
getNumMaps
();
i
++
)
{
...
...
@@ -70,6 +71,7 @@ void* CMAPTorsionForceProxy::deserialize(const SerializationNode& node) const {
CMAPTorsionForce
*
force
=
new
CMAPTorsionForce
();
try
{
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setName
(
node
.
getStringProperty
(
"name"
,
force
->
getName
()));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
maps
=
node
.
getChildNode
(
"Maps"
);
...
...
serialization/src/CMMotionRemoverProxy.cpp
View file @
4c6cf680
...
...
@@ -45,6 +45,7 @@ void CMMotionRemoverProxy::serialize(const void* object, SerializationNode& node
node
.
setIntProperty
(
"version"
,
1
);
const
CMMotionRemover
&
force
=
*
reinterpret_cast
<
const
CMMotionRemover
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setIntProperty
(
"frequency"
,
force
.
getFrequency
());
}
...
...
@@ -55,6 +56,7 @@ void* CMMotionRemoverProxy::deserialize(const SerializationNode& node) const {
try
{
CMMotionRemover
*
force
=
new
CMMotionRemover
(
node
.
getIntProperty
(
"frequency"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setName
(
node
.
getStringProperty
(
"name"
,
force
->
getName
()));
return
force
;
}
catch
(...)
{
...
...
serialization/src/CustomAngleForceProxy.cpp
View file @
4c6cf680
...
...
@@ -45,6 +45,7 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod
node
.
setIntProperty
(
"version"
,
3
);
const
CustomAngleForce
&
force
=
*
reinterpret_cast
<
const
CustomAngleForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setStringProperty
(
"name"
,
force
.
getName
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setStringProperty
(
"energy"
,
force
.
getEnergyFunction
());
SerializationNode
&
perAngleParams
=
node
.
createChildNode
(
"PerAngleParameters"
);
...
...
@@ -82,6 +83,7 @@ void* CustomAngleForceProxy::deserialize(const SerializationNode& node) const {
try
{
CustomAngleForce
*
force
=
new
CustomAngleForce
(
node
.
getStringProperty
(
"energy"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setName
(
node
.
getStringProperty
(
"name"
,
force
->
getName
()));
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
perAngleParams
=
node
.
getChildNode
(
"PerAngleParameters"
);
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment