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
3439d873
Commit
3439d873
authored
Oct 06, 2014
by
peastman
Browse files
Serialization support for MonteCarloMembraneBarostat and MonteCarloAnisotropicBarostat
parent
77c40022
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
420 additions
and
2 deletions
+420
-2
serialization/include/openmm/serialization/MonteCarloAnisotropicBarostatProxy.h
...openmm/serialization/MonteCarloAnisotropicBarostatProxy.h
+53
-0
serialization/include/openmm/serialization/MonteCarloMembraneBarostatProxy.h
...de/openmm/serialization/MonteCarloMembraneBarostatProxy.h
+53
-0
serialization/src/MonteCarloAnisotropicBarostatProxy.cpp
serialization/src/MonteCarloAnisotropicBarostatProxy.cpp
+77
-0
serialization/src/MonteCarloBarostatProxy.cpp
serialization/src/MonteCarloBarostatProxy.cpp
+1
-1
serialization/src/MonteCarloMembraneBarostatProxy.cpp
serialization/src/MonteCarloMembraneBarostatProxy.cpp
+75
-0
serialization/src/SerializationProxyRegistration.cpp
serialization/src/SerializationProxyRegistration.cpp
+7
-1
serialization/tests/TestSerializeMonteCarloAnisotropicBarostat.cpp
...tion/tests/TestSerializeMonteCarloAnisotropicBarostat.cpp
+77
-0
serialization/tests/TestSerializeMonteCarloMembraneBarostat.cpp
...ization/tests/TestSerializeMonteCarloMembraneBarostat.cpp
+77
-0
No files found.
serialization/include/openmm/serialization/MonteCarloAnisotropicBarostatProxy.h
0 → 100644
View file @
3439d873
#ifndef OPENMM_MONTECARLOANISOTROPICBAROSTAT_PROXY_H_
#define OPENMM_MONTECARLOANISOTROPICBAROSTAT_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) 2010=2014 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 MonteCarloAnisotropicBarostat objects.
*/
class
OPENMM_EXPORT
MonteCarloAnisotropicBarostatProxy
:
public
SerializationProxy
{
public:
MonteCarloAnisotropicBarostatProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_MONTECARLOANISOTROPICBAROSTAT_PROXY_H_*/
serialization/include/openmm/serialization/MonteCarloMembraneBarostatProxy.h
0 → 100644
View file @
3439d873
#ifndef OPENMM_MONTECARLOMEMBRANEBAROSTAT_PROXY_H_
#define OPENMM_MONTECARLOMEMBRANEBAROSTAT_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) 2010=2014 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 MonteCarloMembraneBarostat objects.
*/
class
OPENMM_EXPORT
MonteCarloMembraneBarostatProxy
:
public
SerializationProxy
{
public:
MonteCarloMembraneBarostatProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_MONTECARLOMEMBRANEBAROSTAT_PROXY_H_*/
serialization/src/MonteCarloAnisotropicBarostatProxy.cpp
0 → 100644
View file @
3439d873
/* -------------------------------------------------------------------------- *
* 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-2014 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/MonteCarloAnisotropicBarostatProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
MonteCarloAnisotropicBarostatProxy
::
MonteCarloAnisotropicBarostatProxy
()
:
SerializationProxy
(
"MonteCarloAnisotropicBarostat"
)
{
}
void
MonteCarloAnisotropicBarostatProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
MonteCarloAnisotropicBarostat
&
force
=
*
reinterpret_cast
<
const
MonteCarloAnisotropicBarostat
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
Vec3
pressure
=
force
.
getDefaultPressure
();
node
.
setDoubleProperty
(
"pressurex"
,
pressure
[
0
]);
node
.
setDoubleProperty
(
"pressurey"
,
pressure
[
1
]);
node
.
setDoubleProperty
(
"pressurez"
,
pressure
[
2
]);
node
.
setBoolProperty
(
"scalex"
,
force
.
getScaleX
());
node
.
setBoolProperty
(
"scaley"
,
force
.
getScaleY
());
node
.
setBoolProperty
(
"scalez"
,
force
.
getScaleZ
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
getTemperature
());
node
.
setIntProperty
(
"frequency"
,
force
.
getFrequency
());
node
.
setIntProperty
(
"randomSeed"
,
force
.
getRandomNumberSeed
());
}
void
*
MonteCarloAnisotropicBarostatProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
MonteCarloAnisotropicBarostat
*
force
=
NULL
;
try
{
Vec3
pressure
(
node
.
getDoubleProperty
(
"pressurex"
),
node
.
getDoubleProperty
(
"pressurey"
),
node
.
getDoubleProperty
(
"pressurez"
));
force
=
new
MonteCarloAnisotropicBarostat
(
pressure
,
node
.
getDoubleProperty
(
"temperature"
),
node
.
getBoolProperty
(
"scalex"
),
node
.
getBoolProperty
(
"scaley"
),
node
.
getBoolProperty
(
"scalez"
),
node
.
getIntProperty
(
"frequency"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
return
force
;
}
catch
(...)
{
if
(
force
!=
NULL
)
delete
force
;
throw
;
}
}
serialization/src/MonteCarloBarostatProxy.cpp
View file @
3439d873
...
@@ -56,7 +56,7 @@ void* MonteCarloBarostatProxy::deserialize(const SerializationNode& node) const
...
@@ -56,7 +56,7 @@ void* MonteCarloBarostatProxy::deserialize(const SerializationNode& node) const
throw
OpenMMException
(
"Unsupported version number"
);
throw
OpenMMException
(
"Unsupported version number"
);
MonteCarloBarostat
*
force
=
NULL
;
MonteCarloBarostat
*
force
=
NULL
;
try
{
try
{
MonteCarloBarostat
*
force
=
new
MonteCarloBarostat
(
node
.
getDoubleProperty
(
"pressure"
),
node
.
getDoubleProperty
(
"temperature"
),
node
.
getIntProperty
(
"frequency"
));
force
=
new
MonteCarloBarostat
(
node
.
getDoubleProperty
(
"pressure"
),
node
.
getDoubleProperty
(
"temperature"
),
node
.
getIntProperty
(
"frequency"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
force
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
return
force
;
return
force
;
...
...
serialization/src/MonteCarloMembraneBarostatProxy.cpp
0 → 100644
View file @
3439d873
/* -------------------------------------------------------------------------- *
* 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-2014 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/MonteCarloMembraneBarostatProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/MonteCarloMembraneBarostat.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
MonteCarloMembraneBarostatProxy
::
MonteCarloMembraneBarostatProxy
()
:
SerializationProxy
(
"MonteCarloMembraneBarostat"
)
{
}
void
MonteCarloMembraneBarostatProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
MonteCarloMembraneBarostat
&
force
=
*
reinterpret_cast
<
const
MonteCarloMembraneBarostat
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setDoubleProperty
(
"pressure"
,
force
.
getDefaultPressure
());
node
.
setDoubleProperty
(
"surfaceTension"
,
force
.
getDefaultSurfaceTension
());
node
.
setDoubleProperty
(
"temperature"
,
force
.
getTemperature
());
node
.
setIntProperty
(
"xymode"
,
force
.
getXYMode
());
node
.
setIntProperty
(
"zmode"
,
force
.
getZMode
());
node
.
setIntProperty
(
"frequency"
,
force
.
getFrequency
());
node
.
setIntProperty
(
"randomSeed"
,
force
.
getRandomNumberSeed
());
}
void
*
MonteCarloMembraneBarostatProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
MonteCarloMembraneBarostat
*
force
=
NULL
;
try
{
MonteCarloMembraneBarostat
::
XYMode
xymode
=
(
MonteCarloMembraneBarostat
::
XYMode
)
node
.
getIntProperty
(
"xymode"
);
MonteCarloMembraneBarostat
::
ZMode
zmode
=
(
MonteCarloMembraneBarostat
::
ZMode
)
node
.
getIntProperty
(
"zmode"
);
force
=
new
MonteCarloMembraneBarostat
(
node
.
getDoubleProperty
(
"pressure"
),
node
.
getDoubleProperty
(
"surfaceTension"
),
node
.
getDoubleProperty
(
"temperature"
),
xymode
,
zmode
,
node
.
getIntProperty
(
"frequency"
));
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
force
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
return
force
;
}
catch
(...)
{
if
(
force
!=
NULL
)
delete
force
;
throw
;
}
}
serialization/src/SerializationProxyRegistration.cpp
View file @
3439d873
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2010 Stanford University and the Authors.
*
* Portions copyright (c) 2010
-2014
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -48,7 +48,9 @@
...
@@ -48,7 +48,9 @@
#include "openmm/HarmonicAngleForce.h"
#include "openmm/HarmonicAngleForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include "openmm/MonteCarloBarostat.h"
#include "openmm/MonteCarloBarostat.h"
#include "openmm/MonteCarloMembraneBarostat.h"
#include "openmm/NonbondedForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/PeriodicTorsionForce.h"
#include "openmm/PeriodicTorsionForce.h"
#include "openmm/RBTorsionForce.h"
#include "openmm/RBTorsionForce.h"
...
@@ -78,7 +80,9 @@
...
@@ -78,7 +80,9 @@
#include "openmm/serialization/HarmonicAngleForceProxy.h"
#include "openmm/serialization/HarmonicAngleForceProxy.h"
#include "openmm/serialization/HarmonicBondForceProxy.h"
#include "openmm/serialization/HarmonicBondForceProxy.h"
#include "openmm/serialization/LangevinIntegratorProxy.h"
#include "openmm/serialization/LangevinIntegratorProxy.h"
#include "openmm/serialization/MonteCarloAnisotropicBarostatProxy.h"
#include "openmm/serialization/MonteCarloBarostatProxy.h"
#include "openmm/serialization/MonteCarloBarostatProxy.h"
#include "openmm/serialization/MonteCarloMembraneBarostatProxy.h"
#include "openmm/serialization/NonbondedForceProxy.h"
#include "openmm/serialization/NonbondedForceProxy.h"
#include "openmm/serialization/PeriodicTorsionForceProxy.h"
#include "openmm/serialization/PeriodicTorsionForceProxy.h"
#include "openmm/serialization/RBTorsionForceProxy.h"
#include "openmm/serialization/RBTorsionForceProxy.h"
...
@@ -129,7 +133,9 @@ extern "C" void registerSerializationProxies() {
...
@@ -129,7 +133,9 @@ extern "C" void registerSerializationProxies() {
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicAngleForce
),
new
HarmonicAngleForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicAngleForce
),
new
HarmonicAngleForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicBondForce
),
new
HarmonicBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicBondForce
),
new
HarmonicBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
LangevinIntegrator
),
new
LangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
LangevinIntegrator
),
new
LangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
MonteCarloAnisotropicBarostat
),
new
MonteCarloAnisotropicBarostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
MonteCarloBarostat
),
new
MonteCarloBarostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
MonteCarloBarostat
),
new
MonteCarloBarostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
MonteCarloMembraneBarostat
),
new
MonteCarloMembraneBarostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
NonbondedForce
),
new
NonbondedForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
NonbondedForce
),
new
NonbondedForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
PeriodicTorsionForce
),
new
PeriodicTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
PeriodicTorsionForce
),
new
PeriodicTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RBTorsionForce
),
new
RBTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RBTorsionForce
),
new
RBTorsionForceProxy
());
...
...
serialization/tests/TestSerializeMonteCarloAnisotropicBarostat.cpp
0 → 100644
View file @
3439d873
/* -------------------------------------------------------------------------- *
* 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-2014 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/MonteCarloAnisotropicBarostat.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
void
testSerialization
()
{
// Create a Force.
MonteCarloAnisotropicBarostat
force
(
Vec3
(
15.1
,
18.2
,
19.3
),
250.0
,
true
,
false
,
true
,
14
);
force
.
setForceGroup
(
3
);
force
.
setRandomNumberSeed
(
3
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
MonteCarloAnisotropicBarostat
>
(
&
force
,
"Force"
,
buffer
);
MonteCarloAnisotropicBarostat
*
copy
=
XmlSerializer
::
deserialize
<
MonteCarloAnisotropicBarostat
>
(
buffer
);
// Compare the two forces to see if they are identical.
MonteCarloAnisotropicBarostat
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL_VEC
(
force
.
getDefaultPressure
(),
force2
.
getDefaultPressure
(),
0.0
);
ASSERT_EQUAL
(
force
.
getTemperature
(),
force2
.
getTemperature
());
ASSERT_EQUAL
(
force
.
getScaleX
(),
force2
.
getScaleX
());
ASSERT_EQUAL
(
force
.
getScaleY
(),
force2
.
getScaleY
());
ASSERT_EQUAL
(
force
.
getScaleZ
(),
force2
.
getScaleZ
());
ASSERT_EQUAL
(
force
.
getFrequency
(),
force2
.
getFrequency
());
ASSERT_EQUAL
(
force
.
getRandomNumberSeed
(),
force2
.
getRandomNumberSeed
());
}
int
main
()
{
try
{
testSerialization
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
serialization/tests/TestSerializeMonteCarloMembraneBarostat.cpp
0 → 100644
View file @
3439d873
/* -------------------------------------------------------------------------- *
* 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-2014 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/MonteCarloMembraneBarostat.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
void
testSerialization
()
{
// Create a Force.
MonteCarloMembraneBarostat
force
(
25.5
,
11.2
,
250.0
,
MonteCarloMembraneBarostat
::
XYAnisotropic
,
MonteCarloMembraneBarostat
::
ZFixed
,
14
);
force
.
setForceGroup
(
3
);
force
.
setRandomNumberSeed
(
3
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
MonteCarloMembraneBarostat
>
(
&
force
,
"Force"
,
buffer
);
MonteCarloMembraneBarostat
*
copy
=
XmlSerializer
::
deserialize
<
MonteCarloMembraneBarostat
>
(
buffer
);
// Compare the two forces to see if they are identical.
MonteCarloMembraneBarostat
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getForceGroup
(),
force2
.
getForceGroup
());
ASSERT_EQUAL
(
force
.
getDefaultPressure
(),
force2
.
getDefaultPressure
());
ASSERT_EQUAL
(
force
.
getDefaultSurfaceTension
(),
force2
.
getDefaultSurfaceTension
());
ASSERT_EQUAL
(
force
.
getTemperature
(),
force2
.
getTemperature
());
ASSERT_EQUAL
(
force
.
getXYMode
(),
force2
.
getXYMode
());
ASSERT_EQUAL
(
force
.
getZMode
(),
force2
.
getZMode
());
ASSERT_EQUAL
(
force
.
getFrequency
(),
force2
.
getFrequency
());
ASSERT_EQUAL
(
force
.
getRandomNumberSeed
(),
force2
.
getRandomNumberSeed
());
}
int
main
()
{
try
{
testSerialization
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
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