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
5d9b6481
Commit
5d9b6481
authored
Sep 22, 2010
by
Peter Eastman
Browse files
Continuing to implement serialization
parent
6ee040ff
Changes
24
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
5253 additions
and
19 deletions
+5253
-19
serialization/CMakeLists.txt
serialization/CMakeLists.txt
+1
-1
serialization/include/openmm/serialization/AndersenThermostatProxy.h
...on/include/openmm/serialization/AndersenThermostatProxy.h
+53
-0
serialization/include/openmm/serialization/GBSAOBCForceProxy.h
...lization/include/openmm/serialization/GBSAOBCForceProxy.h
+53
-0
serialization/include/openmm/serialization/NonbondedForceProxy.h
...zation/include/openmm/serialization/NonbondedForceProxy.h
+53
-0
serialization/include/openmm/serialization/PeriodicTorsionForceProxy.h
.../include/openmm/serialization/PeriodicTorsionForceProxy.h
+53
-0
serialization/include/openmm/serialization/RBTorsionForceProxy.h
...zation/include/openmm/serialization/RBTorsionForceProxy.h
+53
-0
serialization/src/AndersenThermostatProxy.cpp
serialization/src/AndersenThermostatProxy.cpp
+63
-0
serialization/src/GBSAOBCForceProxy.cpp
serialization/src/GBSAOBCForceProxy.cpp
+76
-0
serialization/src/HarmonicAngleForceProxy.cpp
serialization/src/HarmonicAngleForceProxy.cpp
+4
-4
serialization/src/HarmonicBondForceProxy.cpp
serialization/src/HarmonicBondForceProxy.cpp
+2
-2
serialization/src/NonbondedForceProxy.cpp
serialization/src/NonbondedForceProxy.cpp
+90
-0
serialization/src/PeriodicTorsionForceProxy.cpp
serialization/src/PeriodicTorsionForceProxy.cpp
+70
-0
serialization/src/RBTorsionForceProxy.cpp
serialization/src/RBTorsionForceProxy.cpp
+72
-0
serialization/src/SerializationNode.cpp
serialization/src/SerializationNode.cpp
+8
-10
serialization/src/SerializationProxyRegistration.cpp
serialization/src/SerializationProxyRegistration.cpp
+15
-0
serialization/src/dtoa.cpp
serialization/src/dtoa.cpp
+4321
-0
serialization/src/g_fmt.cpp
serialization/src/g_fmt.cpp
+104
-0
serialization/tests/TestSerializeAndersenThermostat.cpp
serialization/tests/TestSerializeAndersenThermostat.cpp
+72
-0
serialization/tests/TestSerializeGBSAOBCForce.cpp
serialization/tests/TestSerializeGBSAOBCForce.cpp
+88
-0
serialization/tests/TestSerializeHarmonicAngleForce.cpp
serialization/tests/TestSerializeHarmonicAngleForce.cpp
+2
-2
No files found.
serialization/CMakeLists.txt
View file @
5d9b6481
...
...
@@ -77,7 +77,7 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
# Create the library
ADD_LIBRARY
(
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
debug
${
OPENMM_LIBRARY_NAME
}
_d optimized
${
OPENMM_LIBRARY_NAME
}
)
SET_TARGET_PROPERTIES
(
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_BUILDING_SHARED_LIBRARY -DTIXML_USE_STL"
)
SET_TARGET_PROPERTIES
(
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_BUILDING_SHARED_LIBRARY -DTIXML_USE_STL
-DIEEE_8087
"
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
)
ADD_SUBDIRECTORY
(
tests
)
serialization/include/openmm/serialization/AndersenThermostatProxy.h
0 → 100644
View file @
5d9b6481
#ifndef OPENMM_ANDERSENTHERMOSTAT_PROXY_H_
#define OPENMM_ANDERSENTHERMOSTAT_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 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 AndersenThermostat objects.
*/
class
OPENMM_EXPORT
AndersenThermostatProxy
:
public
SerializationProxy
{
public:
AndersenThermostatProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_ANDERSENTHERMOSTAT_PROXY_H_*/
serialization/include/openmm/serialization/GBSAOBCForceProxy.h
0 → 100644
View file @
5d9b6481
#ifndef OPENMM_GBSAOBCFORCE_PROXY_H_
#define OPENMM_GBSAOBCFORCE_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 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 GBSAOBCForce objects.
*/
class
OPENMM_EXPORT
GBSAOBCForceProxy
:
public
SerializationProxy
{
public:
GBSAOBCForceProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_GBSAOBCFORCE_PROXY_H_*/
serialization/include/openmm/serialization/NonbondedForceProxy.h
0 → 100644
View file @
5d9b6481
#ifndef OPENMM_NONBONDEDFORCE_PROXY_H_
#define OPENMM_NONBONDEDFORCE_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 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 NonbondedForce objects.
*/
class
OPENMM_EXPORT
NonbondedForceProxy
:
public
SerializationProxy
{
public:
NonbondedForceProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_NONBONDEDFORCE_PROXY_H_*/
serialization/include/openmm/serialization/PeriodicTorsionForceProxy.h
0 → 100644
View file @
5d9b6481
#ifndef OPENMM_PERIODICTORSIONFORCE_PROXY_H_
#define OPENMM_PERIODICTORSIONFORCE_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 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 PeriodicTorsionForce objects.
*/
class
OPENMM_EXPORT
PeriodicTorsionForceProxy
:
public
SerializationProxy
{
public:
PeriodicTorsionForceProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_PERIODICTORSIONFORCE_PROXY_H_*/
serialization/include/openmm/serialization/RBTorsionForceProxy.h
0 → 100644
View file @
5d9b6481
#ifndef OPENMM_RBTORSIONFORCE_PROXY_H_
#define OPENMM_RBTORSIONFORCE_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 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 RBTorsionForce objects.
*/
class
OPENMM_EXPORT
RBTorsionForceProxy
:
public
SerializationProxy
{
public:
RBTorsionForceProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_RBTORSIONFORCE_PROXY_H_*/
serialization/src/AndersenThermostatProxy.cpp
0 → 100644
View file @
5d9b6481
/* -------------------------------------------------------------------------- *
* 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 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/AndersenThermostatProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/AndersenThermostat.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
AndersenThermostatProxy
::
AndersenThermostatProxy
()
:
SerializationProxy
(
"AndersenThermostat"
)
{
}
void
AndersenThermostatProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
const
AndersenThermostat
&
force
=
*
reinterpret_cast
<
const
AndersenThermostat
*>
(
object
);
node
.
setDoubleProperty
(
"temperature"
,
force
.
getDefaultTemperature
());
node
.
setDoubleProperty
(
"frequency"
,
force
.
getDefaultCollisionFrequency
());
node
.
setIntProperty
(
"randomSeed"
,
force
.
getRandomNumberSeed
());
}
void
*
AndersenThermostatProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
AndersenThermostat
*
force
=
NULL
;
try
{
AndersenThermostat
*
force
=
new
AndersenThermostat
(
node
.
getDoubleProperty
(
"temperature"
),
node
.
getDoubleProperty
(
"frequency"
));
force
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
return
force
;
}
catch
(...)
{
if
(
force
!=
NULL
)
delete
force
;
throw
;
}
}
serialization/src/GBSAOBCForceProxy.cpp
0 → 100644
View file @
5d9b6481
/* -------------------------------------------------------------------------- *
* 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 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/GBSAOBCForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/GBSAOBCForce.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
GBSAOBCForceProxy
::
GBSAOBCForceProxy
()
:
SerializationProxy
(
"GBSAOBCForce"
)
{
}
void
GBSAOBCForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
const
GBSAOBCForce
&
force
=
*
reinterpret_cast
<
const
GBSAOBCForce
*>
(
object
);
node
.
setIntProperty
(
"method"
,
(
int
)
force
.
getNonbondedMethod
());
node
.
setDoubleProperty
(
"cutoff"
,
force
.
getCutoffDistance
());
node
.
setDoubleProperty
(
"soluteDielectric"
,
force
.
getSoluteDielectric
());
node
.
setDoubleProperty
(
"solventDielectric"
,
force
.
getSolventDielectric
());
SerializationNode
&
particles
=
node
.
createChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
double
charge
,
radius
,
scale
;
force
.
getParticleParameters
(
i
,
charge
,
radius
,
scale
);
particles
.
createChildNode
(
"Particle"
).
setDoubleProperty
(
"q"
,
charge
).
setDoubleProperty
(
"r"
,
radius
).
setDoubleProperty
(
"scale"
,
scale
);
}
}
void
*
GBSAOBCForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
GBSAOBCForce
*
force
=
new
GBSAOBCForce
();
try
{
force
->
setNonbondedMethod
((
GBSAOBCForce
::
NonbondedMethod
)
node
.
getIntProperty
(
"method"
));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoff"
));
force
->
setSoluteDielectric
(
node
.
getDoubleProperty
(
"soluteDielectric"
));
force
->
setSolventDielectric
(
node
.
getDoubleProperty
(
"solventDielectric"
));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
force
->
addParticle
(
particle
.
getDoubleProperty
(
"q"
),
particle
.
getDoubleProperty
(
"r"
),
particle
.
getDoubleProperty
(
"scale"
));
}
}
catch
(...)
{
delete
force
;
throw
;
}
return
force
;
}
serialization/src/HarmonicAngleForceProxy.cpp
View file @
5d9b6481
...
...
@@ -55,10 +55,10 @@ void HarmonicAngleForceProxy::serialize(const void* object, SerializationNode& n
void
*
HarmonicAngleForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
HarmonicAngleForce
*
force
=
new
HarmonicAngleForce
();
try
{
const
SerializationNode
&
bond
s
=
node
.
getChildNode
(
"Angles"
);
for
(
int
i
=
0
;
i
<
(
int
)
bond
s
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
constraint
=
bond
s
.
getChildren
()[
i
];
force
->
addAngle
(
constraint
.
getDoubleProperty
(
"p1"
),
constraint
.
getDoubleProperty
(
"p2"
),
constraint
.
getDoubleProperty
(
"p3"
),
constraint
.
getDoubleProperty
(
"a"
),
constraint
.
getDoubleProperty
(
"k"
));
const
SerializationNode
&
angle
s
=
node
.
getChildNode
(
"Angles"
);
for
(
int
i
=
0
;
i
<
(
int
)
angle
s
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
angle
=
angle
s
.
getChildren
()[
i
];
force
->
addAngle
(
angle
.
getDoubleProperty
(
"p1"
),
angle
.
getDoubleProperty
(
"p2"
),
angle
.
getDoubleProperty
(
"p3"
),
angle
.
getDoubleProperty
(
"a"
),
angle
.
getDoubleProperty
(
"k"
));
}
}
catch
(...)
{
...
...
serialization/src/HarmonicBondForceProxy.cpp
View file @
5d9b6481
...
...
@@ -57,8 +57,8 @@ void* HarmonicBondForceProxy::deserialize(const SerializationNode& node) const {
try
{
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"Bonds"
);
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
c
on
straint
=
bonds
.
getChildren
()[
i
];
force
->
addBond
(
c
on
straint
.
getDoubleProperty
(
"p1"
),
c
on
straint
.
getDoubleProperty
(
"p2"
),
c
on
straint
.
getDoubleProperty
(
"d"
),
c
on
straint
.
getDoubleProperty
(
"k"
));
const
SerializationNode
&
b
on
d
=
bonds
.
getChildren
()[
i
];
force
->
addBond
(
b
on
d
.
getDoubleProperty
(
"p1"
),
b
on
d
.
getDoubleProperty
(
"p2"
),
b
on
d
.
getDoubleProperty
(
"d"
),
b
on
d
.
getDoubleProperty
(
"k"
));
}
}
catch
(...)
{
...
...
serialization/src/NonbondedForceProxy.cpp
0 → 100644
View file @
5d9b6481
/* -------------------------------------------------------------------------- *
* 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 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/NonbondedForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/NonbondedForce.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
NonbondedForceProxy
::
NonbondedForceProxy
()
:
SerializationProxy
(
"NonbondedForce"
)
{
}
void
NonbondedForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
const
NonbondedForce
&
force
=
*
reinterpret_cast
<
const
NonbondedForce
*>
(
object
);
node
.
setIntProperty
(
"method"
,
(
int
)
force
.
getNonbondedMethod
());
node
.
setDoubleProperty
(
"cutoff"
,
force
.
getCutoffDistance
());
node
.
setDoubleProperty
(
"ewaldTolerance"
,
force
.
getEwaldErrorTolerance
());
node
.
setDoubleProperty
(
"rfDielectric"
,
force
.
getReactionFieldDielectric
());
node
.
setIntProperty
(
"dispersionCorrection"
,
force
.
getUseDispersionCorrection
());
SerializationNode
&
particles
=
node
.
createChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
double
charge
,
sigma
,
epsilon
;
force
.
getParticleParameters
(
i
,
charge
,
sigma
,
epsilon
);
particles
.
createChildNode
(
"Particle"
).
setDoubleProperty
(
"q"
,
charge
).
setDoubleProperty
(
"sig"
,
sigma
).
setDoubleProperty
(
"eps"
,
epsilon
);
}
SerializationNode
&
exceptions
=
node
.
createChildNode
(
"Exceptions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumExceptions
();
i
++
)
{
int
particle1
,
particle2
;
double
chargeProd
,
sigma
,
epsilon
;
force
.
getExceptionParameters
(
i
,
particle1
,
particle2
,
chargeProd
,
sigma
,
epsilon
);
exceptions
.
createChildNode
(
"Exception"
).
setIntProperty
(
"p1"
,
particle1
).
setIntProperty
(
"p2"
,
particle2
).
setDoubleProperty
(
"q"
,
chargeProd
).
setDoubleProperty
(
"sig"
,
sigma
).
setDoubleProperty
(
"eps"
,
epsilon
);
}
}
void
*
NonbondedForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
NonbondedForce
*
force
=
new
NonbondedForce
();
try
{
force
->
setNonbondedMethod
((
NonbondedForce
::
NonbondedMethod
)
node
.
getIntProperty
(
"method"
));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoff"
));
force
->
setEwaldErrorTolerance
(
node
.
getDoubleProperty
(
"ewaldTolerance"
));
force
->
setReactionFieldDielectric
(
node
.
getDoubleProperty
(
"rfDielectric"
));
force
->
setUseDispersionCorrection
(
node
.
getIntProperty
(
"dispersionCorrection"
));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
force
->
addParticle
(
particle
.
getDoubleProperty
(
"q"
),
particle
.
getDoubleProperty
(
"sig"
),
particle
.
getDoubleProperty
(
"eps"
));
}
const
SerializationNode
&
exceptions
=
node
.
getChildNode
(
"Exceptions"
);
for
(
int
i
=
0
;
i
<
(
int
)
exceptions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
exception
=
exceptions
.
getChildren
()[
i
];
force
->
addException
(
exception
.
getDoubleProperty
(
"p1"
),
exception
.
getDoubleProperty
(
"p2"
),
exception
.
getDoubleProperty
(
"q"
),
exception
.
getDoubleProperty
(
"sig"
),
exception
.
getDoubleProperty
(
"eps"
));
}
}
catch
(...)
{
delete
force
;
throw
;
}
return
force
;
}
serialization/src/PeriodicTorsionForceProxy.cpp
0 → 100644
View file @
5d9b6481
/* -------------------------------------------------------------------------- *
* 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 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/PeriodicTorsionForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/PeriodicTorsionForce.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
PeriodicTorsionForceProxy
::
PeriodicTorsionForceProxy
()
:
SerializationProxy
(
"PeriodicTorsionForce"
)
{
}
void
PeriodicTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
const
PeriodicTorsionForce
&
force
=
*
reinterpret_cast
<
const
PeriodicTorsionForce
*>
(
object
);
SerializationNode
&
torsions
=
node
.
createChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
particle1
,
particle2
,
particle3
,
particle4
,
periodicity
;
double
phase
,
k
;
force
.
getTorsionParameters
(
i
,
particle1
,
particle2
,
particle3
,
particle4
,
periodicity
,
phase
,
k
);
torsions
.
createChildNode
(
"Torsion"
).
setIntProperty
(
"p1"
,
particle1
).
setIntProperty
(
"p2"
,
particle2
).
setIntProperty
(
"p3"
,
particle3
).
setIntProperty
(
"p4"
,
particle4
).
setIntProperty
(
"periodicity"
,
periodicity
).
setDoubleProperty
(
"phase"
,
phase
).
setDoubleProperty
(
"k"
,
k
);
}
}
void
*
PeriodicTorsionForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
PeriodicTorsionForce
*
force
=
new
PeriodicTorsionForce
();
try
{
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
torsion
=
torsions
.
getChildren
()[
i
];
force
->
addTorsion
(
torsion
.
getDoubleProperty
(
"p1"
),
torsion
.
getDoubleProperty
(
"p2"
),
torsion
.
getDoubleProperty
(
"p3"
),
torsion
.
getDoubleProperty
(
"p4"
),
torsion
.
getIntProperty
(
"periodicity"
),
torsion
.
getDoubleProperty
(
"phase"
),
torsion
.
getDoubleProperty
(
"k"
));
}
}
catch
(...)
{
delete
force
;
throw
;
}
return
force
;
}
serialization/src/RBTorsionForceProxy.cpp
0 → 100644
View file @
5d9b6481
/* -------------------------------------------------------------------------- *
* 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 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/RBTorsionForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/RBTorsionForce.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
RBTorsionForceProxy
::
RBTorsionForceProxy
()
:
SerializationProxy
(
"RBTorsionForce"
)
{
}
void
RBTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
const
RBTorsionForce
&
force
=
*
reinterpret_cast
<
const
RBTorsionForce
*>
(
object
);
SerializationNode
&
torsions
=
node
.
createChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumTorsions
();
i
++
)
{
int
particle1
,
particle2
,
particle3
,
particle4
;
double
c0
,
c1
,
c2
,
c3
,
c4
,
c5
;
force
.
getTorsionParameters
(
i
,
particle1
,
particle2
,
particle3
,
particle4
,
c0
,
c1
,
c2
,
c3
,
c4
,
c5
);
torsions
.
createChildNode
(
"Torsion"
).
setIntProperty
(
"p1"
,
particle1
).
setIntProperty
(
"p2"
,
particle2
).
setIntProperty
(
"p3"
,
particle3
).
setIntProperty
(
"p4"
,
particle4
).
setDoubleProperty
(
"c0"
,
c0
).
setDoubleProperty
(
"c1"
,
c1
).
setDoubleProperty
(
"c2"
,
c2
).
setDoubleProperty
(
"c3"
,
c3
).
setDoubleProperty
(
"c4"
,
c4
).
setDoubleProperty
(
"c5"
,
c5
);
}
}
void
*
RBTorsionForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
RBTorsionForce
*
force
=
new
RBTorsionForce
();
try
{
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
torsion
=
torsions
.
getChildren
()[
i
];
force
->
addTorsion
(
torsion
.
getDoubleProperty
(
"p1"
),
torsion
.
getDoubleProperty
(
"p2"
),
torsion
.
getDoubleProperty
(
"p3"
),
torsion
.
getDoubleProperty
(
"p4"
),
torsion
.
getDoubleProperty
(
"c0"
),
torsion
.
getDoubleProperty
(
"c1"
),
torsion
.
getDoubleProperty
(
"c2"
),
torsion
.
getDoubleProperty
(
"c3"
),
torsion
.
getDoubleProperty
(
"c4"
),
torsion
.
getDoubleProperty
(
"c5"
));
}
}
catch
(...)
{
delete
force
;
throw
;
}
return
force
;
}
serialization/src/SerializationNode.cpp
View file @
5d9b6481
...
...
@@ -36,6 +36,9 @@
using
namespace
OpenMM
;
using
namespace
std
;
extern
"C"
char
*
g_fmt
(
char
*
,
double
);
extern
"C"
double
strtod
(
const
char
*
s00
,
char
**
se
);
const
string
&
SerializationNode
::
getName
()
const
{
return
name
;
}
...
...
@@ -122,25 +125,20 @@ double SerializationNode::getDoubleProperty(const string& name) const {
map
<
string
,
string
>::
const_iterator
iter
=
properties
.
find
(
name
);
if
(
iter
==
properties
.
end
())
throw
OpenMMException
(
"Unknown property '"
+
name
+
"' in node '"
+
getName
()
+
"'"
);
double
value
;
stringstream
(
iter
->
second
)
>>
value
;
return
value
;
return
strtod
(
iter
->
second
.
c_str
(),
NULL
);
}
double
SerializationNode
::
getDoubleProperty
(
const
string
&
name
,
double
defaultValue
)
const
{
map
<
string
,
string
>::
const_iterator
iter
=
properties
.
find
(
name
);
if
(
iter
==
properties
.
end
())
return
defaultValue
;
double
value
;
stringstream
(
iter
->
second
)
>>
value
;
return
value
;
return
strtod
(
iter
->
second
.
c_str
(),
NULL
);
}
SerializationNode
&
SerializationNode
::
setDoubleProperty
(
const
string
&
name
,
double
value
)
{
stringstream
s
;
s
.
precision
(
16
);
s
<<
value
;
properties
[
name
]
=
s
.
str
();
char
buffer
[
32
];
g_fmt
(
buffer
,
value
);
properties
[
name
]
=
string
(
buffer
);
return
*
this
;
}
...
...
serialization/src/SerializationProxyRegistration.cpp
View file @
5d9b6481
...
...
@@ -29,12 +29,22 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/AndersenThermostat.h"
#include "openmm/HarmonicAngleForce.h"
#include "openmm/GBSAOBCForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/PeriodicTorsionForce.h"
#include "openmm/RBTorsionForce.h"
#include "openmm/System.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/AndersenThermostatProxy.h"
#include "openmm/serialization/GBSAOBCForceProxy.h"
#include "openmm/serialization/HarmonicAngleForceProxy.h"
#include "openmm/serialization/HarmonicBondForceProxy.h"
#include "openmm/serialization/NonbondedForceProxy.h"
#include "openmm/serialization/PeriodicTorsionForceProxy.h"
#include "openmm/serialization/RBTorsionForceProxy.h"
#include "openmm/serialization/SystemProxy.h"
#if defined(WIN32)
...
...
@@ -52,7 +62,12 @@
using
namespace
OpenMM
;
extern
"C"
void
registerSerializationProxies
()
{
SerializationProxy
::
registerProxy
(
typeid
(
AndersenThermostat
),
new
AndersenThermostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
GBSAOBCForce
),
new
GBSAOBCForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicAngleForce
),
new
HarmonicAngleForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicBondForce
),
new
HarmonicBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
NonbondedForce
),
new
NonbondedForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
PeriodicTorsionForce
),
new
PeriodicTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RBTorsionForce
),
new
RBTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
System
),
new
SystemProxy
());
}
\ No newline at end of file
serialization/src/dtoa.cpp
0 → 100644
View file @
5d9b6481
This diff is collapsed.
Click to expand it.
serialization/src/g_fmt.cpp
0 → 100644
View file @
5d9b6481
/****************************************************************
*
* The author of this software is David M. Gay.
*
* Copyright (c) 1991, 1996 by Lucent Technologies.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose without fee is hereby granted, provided that this entire notice
* is included in all copies of any software which is or includes a copy
* or modification of this software and in all copies of the supporting
* documentation for such software.
*
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*
***************************************************************/
/* g_fmt(buf,x) stores the closest decimal approximation to x in buf;
* it suffices to declare buf
* char buf[32];
*/
#ifdef __cplusplus
extern
"C"
{
#endif
extern
char
*
dtoa
(
double
,
int
,
int
,
int
*
,
int
*
,
char
**
);
extern
char
*
g_fmt
(
char
*
,
double
);
extern
void
freedtoa
(
char
*
);
#ifdef __cplusplus
}
#endif
char
*
g_fmt
(
register
char
*
b
,
double
x
)
{
register
int
i
,
k
;
register
char
*
s
;
int
decpt
,
j
,
sign
;
char
*
b0
,
*
s0
,
*
se
;
b0
=
b
;
#ifdef IGNORE_ZERO_SIGN
if
(
!
x
)
{
*
b
++
=
'0'
;
*
b
=
0
;
goto
done
;
}
#endif
s
=
s0
=
dtoa
(
x
,
0
,
0
,
&
decpt
,
&
sign
,
&
se
);
if
(
sign
)
*
b
++
=
'-'
;
if
(
decpt
==
9999
)
/* Infinity or Nan */
{
while
(
*
b
++
=
*
s
++
);
goto
done0
;
}
if
(
decpt
<=
-
4
||
decpt
>
se
-
s
+
5
)
{
*
b
++
=
*
s
++
;
if
(
*
s
)
{
*
b
++
=
'.'
;
while
(
*
b
=
*
s
++
)
b
++
;
}
*
b
++
=
'e'
;
/* sprintf(b, "%+.2d", decpt - 1); */
if
(
--
decpt
<
0
)
{
*
b
++
=
'-'
;
decpt
=
-
decpt
;
}
else
*
b
++
=
'+'
;
for
(
j
=
2
,
k
=
10
;
10
*
k
<=
decpt
;
j
++
,
k
*=
10
);
for
(;;)
{
i
=
decpt
/
k
;
*
b
++
=
i
+
'0'
;
if
(
--
j
<=
0
)
break
;
decpt
-=
i
*
k
;
decpt
*=
10
;
}
*
b
=
0
;
}
else
if
(
decpt
<=
0
)
{
*
b
++
=
'.'
;
for
(;
decpt
<
0
;
decpt
++
)
*
b
++
=
'0'
;
while
(
*
b
++
=
*
s
++
);
}
else
{
while
(
*
b
=
*
s
++
)
{
b
++
;
if
(
--
decpt
==
0
&&
*
s
)
*
b
++
=
'.'
;
}
for
(;
decpt
>
0
;
decpt
--
)
*
b
++
=
'0'
;
*
b
=
0
;
}
done0:
freedtoa
(
s0
);
done:
return
b0
;
}
serialization/tests/TestSerializeAndersenThermostat.cpp
0 → 100644
View file @
5d9b6481
/* -------------------------------------------------------------------------- *
* 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 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 "../../../tests/AssertionUtilities.h"
#include "openmm/AndersenThermostat.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
void
testSerialization
()
{
// Create a Force.
AndersenThermostat
force
(
250.0
,
0.2
);
force
.
setRandomNumberSeed
(
3
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
AndersenThermostat
>
(
&
force
,
"Force"
,
buffer
);
AndersenThermostat
*
copy
=
XmlSerializer
::
deserialize
<
AndersenThermostat
>
(
buffer
);
// Compare the two forces to see if they are identical.
AndersenThermostat
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getDefaultTemperature
(),
force2
.
getDefaultTemperature
());
ASSERT_EQUAL
(
force
.
getDefaultCollisionFrequency
(),
force2
.
getDefaultCollisionFrequency
());
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/TestSerializeGBSAOBCForce.cpp
0 → 100644
View file @
5d9b6481
/* -------------------------------------------------------------------------- *
* 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 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 "../../../tests/AssertionUtilities.h"
#include "openmm/GBSAOBCForce.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
void
testSerialization
()
{
// Create a Force.
GBSAOBCForce
force
;
force
.
setNonbondedMethod
(
GBSAOBCForce
::
CutoffPeriodic
);
force
.
setCutoffDistance
(
2.0
);
force
.
setSoluteDielectric
(
5.1
);
force
.
setSolventDielectric
(
50.0
);
force
.
addParticle
(
1
,
0.1
,
0.01
);
force
.
addParticle
(
0.5
,
0.2
,
0.02
);
force
.
addParticle
(
-
0.5
,
0.3
,
0.03
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
GBSAOBCForce
>
(
&
force
,
"Force"
,
buffer
);
GBSAOBCForce
*
copy
=
XmlSerializer
::
deserialize
<
GBSAOBCForce
>
(
buffer
);
// Compare the two forces to see if they are identical.
GBSAOBCForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getNonbondedMethod
(),
force2
.
getNonbondedMethod
());
ASSERT_EQUAL
(
force
.
getCutoffDistance
(),
force2
.
getCutoffDistance
());
ASSERT_EQUAL
(
force
.
getSoluteDielectric
(),
force2
.
getSoluteDielectric
());
ASSERT_EQUAL
(
force
.
getSolventDielectric
(),
force2
.
getSolventDielectric
());
ASSERT_EQUAL
(
force
.
getNumParticles
(),
force2
.
getNumParticles
());
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
double
charge1
,
radius1
,
scale1
;
double
charge2
,
radius2
,
scale2
;
force
.
getParticleParameters
(
i
,
charge1
,
radius1
,
scale1
);
force2
.
getParticleParameters
(
i
,
charge2
,
radius2
,
scale2
);
ASSERT_EQUAL
(
charge1
,
charge2
);
ASSERT_EQUAL
(
radius1
,
radius2
);
ASSERT_EQUAL
(
scale1
,
scale2
);
}
}
int
main
()
{
try
{
testSerialization
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
serialization/tests/TestSerializeHarmonicAngleForce.cpp
View file @
5d9b6481
...
...
@@ -53,7 +53,7 @@ void testSerialization() {
XmlSerializer
::
serialize
<
HarmonicAngleForce
>
(
&
force
,
"Force"
,
buffer
);
HarmonicAngleForce
*
copy
=
XmlSerializer
::
deserialize
<
HarmonicAngleForce
>
(
buffer
);
// Compare the two
system
s to see if they are identical.
// Compare the two
force
s to see if they are identical.
HarmonicAngleForce
&
force2
=
*
copy
;
ASSERT_EQUAL
(
force
.
getNumAngles
(),
force2
.
getNumAngles
());
...
...
@@ -61,7 +61,7 @@ void testSerialization() {
int
a1
,
a2
,
a3
,
b1
,
b2
,
b3
;
double
da
,
db
,
ka
,
kb
;
force
.
getAngleParameters
(
i
,
a1
,
a2
,
a3
,
da
,
ka
);
force
.
getAngleParameters
(
i
,
b1
,
b2
,
b3
,
db
,
kb
);
force
2
.
getAngleParameters
(
i
,
b1
,
b2
,
b3
,
db
,
kb
);
ASSERT_EQUAL
(
a1
,
b1
);
ASSERT_EQUAL
(
a2
,
b2
);
ASSERT_EQUAL
(
a3
,
b3
);
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment