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
6185317a
Commit
6185317a
authored
May 21, 2013
by
peastman
Browse files
Implemented serialization for Drude plugin
parent
6f98dd5f
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
659 additions
and
7 deletions
+659
-7
plugins/drude/CMakeLists.txt
plugins/drude/CMakeLists.txt
+3
-3
plugins/drude/platforms/cuda/src/CudaDrudeKernelFactory.cpp
plugins/drude/platforms/cuda/src/CudaDrudeKernelFactory.cpp
+1
-1
plugins/drude/platforms/opencl/src/OpenCLDrudeKernelFactory.cpp
...s/drude/platforms/opencl/src/OpenCLDrudeKernelFactory.cpp
+1
-1
plugins/drude/platforms/reference/src/ReferenceDrudeKernelFactory.cpp
...e/platforms/reference/src/ReferenceDrudeKernelFactory.cpp
+2
-2
plugins/drude/serialization/CMakeLists.txt
plugins/drude/serialization/CMakeLists.txt
+87
-0
plugins/drude/serialization/include/openmm/serialization/DrudeForceProxy.h
...ialization/include/openmm/serialization/DrudeForceProxy.h
+53
-0
plugins/drude/serialization/include/openmm/serialization/DrudeLangevinIntegratorProxy.h
...clude/openmm/serialization/DrudeLangevinIntegratorProxy.h
+53
-0
plugins/drude/serialization/include/openmm/serialization/internal/windowsExportDrudeSerialization.h
.../serialization/internal/windowsExportDrudeSerialization.h
+41
-0
plugins/drude/serialization/src/DrudeForceProxy.cpp
plugins/drude/serialization/src/DrudeForceProxy.cpp
+86
-0
plugins/drude/serialization/src/DrudeLangevinIntegratorProxy.cpp
.../drude/serialization/src/DrudeLangevinIntegratorProxy.cpp
+64
-0
plugins/drude/serialization/src/DrudeSerializationProxyRegistration.cpp
...serialization/src/DrudeSerializationProxyRegistration.cpp
+69
-0
plugins/drude/serialization/tests/CMakeLists.txt
plugins/drude/serialization/tests/CMakeLists.txt
+17
-0
plugins/drude/serialization/tests/TestSerializeDrudeForce.cpp
...ins/drude/serialization/tests/TestSerializeDrudeForce.cpp
+104
-0
plugins/drude/serialization/tests/TestSerializeDrudeLangevinIntegrator.cpp
...ialization/tests/TestSerializeDrudeLangevinIntegrator.cpp
+78
-0
No files found.
plugins/drude/CMakeLists.txt
View file @
6185317a
...
@@ -205,9 +205,9 @@ ELSE (EXECUTABLE_OUTPUT_PATH)
...
@@ -205,9 +205,9 @@ ELSE (EXECUTABLE_OUTPUT_PATH)
SET
(
TEST_PATH .
)
SET
(
TEST_PATH .
)
ENDIF
(
EXECUTABLE_OUTPUT_PATH
)
ENDIF
(
EXECUTABLE_OUTPUT_PATH
)
#
IF (OPENMM_BUILD_SERIALIZATION_SUPPORT)
IF
(
OPENMM_BUILD_SERIALIZATION_SUPPORT
)
#
ADD_SUBDIRECTORY(serialization)
ADD_SUBDIRECTORY
(
serialization
)
#
ENDIF (OPENMM_BUILD_SERIALIZATION_SUPPORT)
ENDIF
(
OPENMM_BUILD_SERIALIZATION_SUPPORT
)
#INCLUDE(ApiDoxygen.cmake)
#INCLUDE(ApiDoxygen.cmake)
...
...
plugins/drude/platforms/cuda/src/CudaDrudeKernelFactory.cpp
View file @
6185317a
/* -------------------------------------------------------------------------- *
/* -------------------------------------------------------------------------- *
* OpenMM
Amoeba
*
* OpenMM
Drude
*
* -------------------------------------------------------------------------- *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Simbios, the NIH National Center for Physics-Based Simulation of *
...
...
plugins/drude/platforms/opencl/src/OpenCLDrudeKernelFactory.cpp
View file @
6185317a
/* -------------------------------------------------------------------------- *
/* -------------------------------------------------------------------------- *
* OpenMM
Amoeba
*
* OpenMM
Drude
*
* -------------------------------------------------------------------------- *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Simbios, the NIH National Center for Physics-Based Simulation of *
...
...
plugins/drude/platforms/reference/src/ReferenceDrudeKernelFactory.cpp
View file @
6185317a
/* -------------------------------------------------------------------------- *
/* -------------------------------------------------------------------------- *
* OpenMM
Amoeba
*
* OpenMM
Drude
*
* -------------------------------------------------------------------------- *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* 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) 2011 Stanford University and the Authors.
*
* Portions copyright (c) 2011
-2013
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
...
plugins/drude/serialization/CMakeLists.txt
0 → 100644
View file @
6185317a
#---------------------------------------------------
# OpenMMDrude Serialization Library
#
# Creates OpenMMDrude serializatin library, base name=OpenMMDrudeSerialization.
# Default libraries are shared & optimized. Variants
# are created for static (_static) and debug (_d).
#
# Windows:
# OpenMMDrudeSerialization[_d].dll
# OpenMMDrudeSerialization[_d].lib
# Unix:
# libOpenMMDrudeSerialization[_d].so
#----------------------------------------------------
# The source is organized into subdirectories, but we handle them all from
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET
(
OPENMM_SOURCE_SUBDIRS . ../../../serialization
)
SET
(
OPENMM_DRUDE_SOURCE_SUBDIRS .
)
# Collect up information about the version of the OpenMM library we're building
# and make it available to the code so it can be built into the binaries.
SET
(
OPENMM_DRUDE_LIBRARY_NAME OpenMMDrude
)
SET
(
OPENMM_SERIALIZATION_LIBRARY_NAME OpenMMSerialization
)
SET
(
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME OpenMMDrudeSerialization
)
# Ensure that debug libraries have "_d" appended to their names.
# CMake gets this right on Windows automatically with this definition.
IF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
SET
(
CMAKE_DEBUG_POSTFIX
"_d"
CACHE INTERNAL
""
FORCE
)
ENDIF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
# But on Unix or Cygwin we have to add the suffix manually
IF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
SET
(
OPENMM_DRUDE_LIBRARY_NAME
${
OPENMM_DRUDE_LIBRARY_NAME
}
_d
)
SET
(
OPENMM_SERIALIZATION_LIBRARY_NAME
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
_d
)
SET
(
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME
${
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME
}
_d
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
# These are all the places to search for header files which are
# to be part of the API.
SET
(
API_INCLUDE_DIRS
)
# start empty
FOREACH
(
subdir
${
OPENMM_SOURCE_SUBDIRS
}
)
# append
SET
(
API_INCLUDE_DIRS
${
API_INCLUDE_DIRS
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include/internal
)
ENDFOREACH
(
subdir
)
# We'll need both *relative* path names, starting with their API_INCLUDE_DIRS,
# and absolute pathnames.
SET
(
API_REL_INCLUDE_FILES
)
# start these out empty
SET
(
API_ABS_INCLUDE_FILES
)
FOREACH
(
dir
${
API_INCLUDE_DIRS
}
)
FILE
(
GLOB fullpaths
${
dir
}
/*.h
)
# returns full pathnames
SET
(
API_ABS_INCLUDE_FILES
${
API_ABS_INCLUDE_FILES
}
${
fullpaths
}
)
FOREACH
(
pathname
${
fullpaths
}
)
GET_FILENAME_COMPONENT
(
filename
${
pathname
}
NAME
)
SET
(
API_REL_INCLUDE_FILES
${
API_REL_INCLUDE_FILES
}
${
dir
}
/
${
filename
}
)
ENDFOREACH
(
pathname
)
ENDFOREACH
(
dir
)
# collect up source files
SET
(
SOURCE_FILES
)
# empty
SET
(
SOURCE_INCLUDE_FILES
)
FOREACH
(
subdir
${
OPENMM_DRUDE_SOURCE_SUBDIRS
}
)
FILE
(
GLOB_RECURSE src_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.c
)
FILE
(
GLOB incl_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.h
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.hpp
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
src_files
}
)
#append
SET
(
SOURCE_INCLUDE_FILES
${
SOURCE_INCLUDE_FILES
}
${
incl_files
}
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../serialization/
${
subdir
}
/include
)
ENDFOREACH
(
subdir
)
#Message( "API_REL_INCLUDE_FILES=${API_REL_INCLUDE_FILES}\n" )
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
# Create the library
ADD_LIBRARY
(
${
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME
}
${
OPENMM_DRUDE_LIBRARY_NAME
}
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
${
SHARED_TARGET
}
)
SET_TARGET_PROPERTIES
(
${
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_DRUDE_SERIALIZATION_BUILDING_SHARED_LIBRARY -DTIXML_USE_STL -DIEEE_8087"
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME
}
)
ADD_SUBDIRECTORY
(
tests
)
plugins/drude/serialization/include/openmm/serialization/DrudeForceProxy.h
0 → 100644
View file @
6185317a
#ifndef OPENMM_DRUDE_FORCE_PROXY_H_
#define OPENMM_DRUDE_FORCE_PROXY_H_
/* -------------------------------------------------------------------------- *
* OpenMMDrude *
* -------------------------------------------------------------------------- *
* 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) 2013 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/internal/windowsExportDrudeSerialization.h"
#include "openmm/serialization/SerializationProxy.h"
namespace
OpenMM
{
/**
* This is a proxy for serializing DrudeForce objects.
*/
class
OPENMM_EXPORT_DRUDE_SERIALIZATION
DrudeForceProxy
:
public
SerializationProxy
{
public:
DrudeForceProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_DRUDE_FORCE_PROXY_H_*/
plugins/drude/serialization/include/openmm/serialization/DrudeLangevinIntegratorProxy.h
0 → 100644
View file @
6185317a
#ifndef OPENMM_DRUDE_LANGEVIN_INTEGRATOR_PROXY_H_
#define OPENMM_DRUDE_LANGEVIN_INTEGRATOR_PROXY_H_
/* -------------------------------------------------------------------------- *
* OpenMMDrude *
* -------------------------------------------------------------------------- *
* 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) 2013 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/internal/windowsExportDrudeSerialization.h"
#include "openmm/serialization/SerializationProxy.h"
namespace
OpenMM
{
/**
* This is a proxy for serializing DrudeLangevinIntegrator objects.
*/
class
OPENMM_EXPORT_DRUDE_SERIALIZATION
DrudeLangevinIntegratorProxy
:
public
SerializationProxy
{
public:
DrudeLangevinIntegratorProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_DRUDE_LANGEVIN_INTEGRATOR_PROXY_H_*/
plugins/drude/serialization/include/openmm/serialization/internal/windowsExportDrudeSerialization.h
0 → 100644
View file @
6185317a
#ifndef OPENMM_WINDOWSEXPORTDRUDESERIALIZATION_H_
#define OPENMM_WINDOWSEXPORTDRUDESERIALIZATION_H_
/*
* Shared libraries are messy in Visual Studio. We have to distinguish three
* cases:
* (1) this header is being used to build the OpenMM shared library
* (dllexport)
* (2) this header is being used by a *client* of the OpenMM shared
* library (dllimport)
* (3) we are building the OpenMM static library, or the client is
* being compiled with the expectation of linking with the
* OpenMM static library (nothing special needed)
* In the CMake script for building this library, we define one of the symbols
* OPENMM_DRUDE_SERIALIZATION_BUILDING_{SHARED|STATIC}_LIBRARY
* Client code normally has no special symbol defined, in which case we'll
* assume it wants to use the shared library. However, if the client defines
* the symbol OPENMM_USE_STATIC_LIBRARIES we'll suppress the dllimport so
* that the client code can be linked with static libraries. Note that
* the client symbol is not library dependent, while the library symbols
* affect only the OpenMM library, meaning that other libraries can
* be clients of this one. However, we are assuming all-static or all-shared.
*/
#ifdef _MSC_VER
// We don't want to hear about how sprintf is "unsafe".
#pragma warning(disable:4996)
// Keep MS VC++ quiet about lack of dll export of private members.
#pragma warning(disable:4251)
#if defined(OPENMM_DRUDE_SERIALIZATION_BUILDING_SHARED_LIBRARY)
#define OPENMM_EXPORT_DRUDE_SERIALIZATION __declspec(dllexport)
#elif defined(OPENMM_DRUDE_SERIALIZATION_BUILDING_STATIC_LIBRARY) || defined(OPENMM_DRUDE_SERIALIZATION_USE_STATIC_LIBRARIES)
#define OPENMM_EXPORT_DRUDE_SERIALIZATION
#else
#define OPENMM_EXPORT_DRUDE_SERIALIZATION __declspec(dllimport) // i.e., a client of a shared library
#endif
#else
#define OPENMM_EXPORT_DRUDE_SERIALIZATION // Linux, Mac
#endif
#endif // OPENMM_WINDOWSEXPORTDRUDESERIALIZATION_H_
plugins/drude/serialization/src/DrudeForceProxy.cpp
0 → 100644
View file @
6185317a
/* -------------------------------------------------------------------------- *
* OpenMMDrude *
* -------------------------------------------------------------------------- *
* 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) 2013 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/DrudeForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/DrudeForce.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
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
);
SerializationNode
&
particles
=
node
.
createChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
int
p
,
p1
,
p2
,
p3
,
p4
;
double
charge
,
polarizability
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
i
,
p
,
p1
,
p2
,
p3
,
p4
,
charge
,
polarizability
,
aniso12
,
aniso34
);
particles
.
createChildNode
(
"Particle"
).
setIntProperty
(
"p"
,
p
).
setIntProperty
(
"p1"
,
p1
).
setIntProperty
(
"p2"
,
p2
).
setIntProperty
(
"p3"
,
p3
).
setIntProperty
(
"p4"
,
p4
)
.
setDoubleProperty
(
"charge"
,
charge
).
setDoubleProperty
(
"polarizability"
,
polarizability
).
setDoubleProperty
(
"a12"
,
aniso12
).
setDoubleProperty
(
"a34"
,
aniso34
);
}
SerializationNode
&
pairs
=
node
.
createChildNode
(
"ScreenedPairs"
);
for
(
int
i
=
0
;
i
<
force
.
getNumScreenedPairs
();
i
++
)
{
int
p1
,
p2
;
double
thole
;
force
.
getScreenedPairParameters
(
i
,
p1
,
p2
,
thole
);
pairs
.
createChildNode
(
"Pair"
).
setIntProperty
(
"p1"
,
p1
).
setIntProperty
(
"p2"
,
p2
).
setDoubleProperty
(
"thole"
,
thole
);
}
}
void
*
DrudeForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
DrudeForce
*
force
=
new
DrudeForce
();
try
{
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
.
getIntProperty
(
"p"
),
particle
.
getIntProperty
(
"p1"
),
particle
.
getIntProperty
(
"p2"
),
particle
.
getIntProperty
(
"p3"
),
particle
.
getIntProperty
(
"p4"
),
particle
.
getDoubleProperty
(
"charge"
),
particle
.
getDoubleProperty
(
"polarizability"
),
particle
.
getDoubleProperty
(
"a12"
),
particle
.
getDoubleProperty
(
"a34"
));
}
const
SerializationNode
&
pairs
=
node
.
getChildNode
(
"ScreenedPairs"
);
for
(
int
i
=
0
;
i
<
(
int
)
pairs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
pair
=
pairs
.
getChildren
()[
i
];
force
->
addScreenedPair
(
pair
.
getIntProperty
(
"p1"
),
pair
.
getIntProperty
(
"p2"
),
pair
.
getDoubleProperty
(
"thole"
));
}
}
catch
(...)
{
delete
force
;
throw
;
}
return
force
;
}
plugins/drude/serialization/src/DrudeLangevinIntegratorProxy.cpp
0 → 100644
View file @
6185317a
/* -------------------------------------------------------------------------- *
* OpenMMDrude *
* -------------------------------------------------------------------------- *
* 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) 2013 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/DrudeLangevinIntegratorProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/DrudeLangevinIntegrator.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
DrudeLangevinIntegratorProxy
::
DrudeLangevinIntegratorProxy
()
:
SerializationProxy
(
"DrudeLangevinIntegrator"
)
{
}
void
DrudeLangevinIntegratorProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
DrudeLangevinIntegrator
&
integrator
=
*
reinterpret_cast
<
const
DrudeLangevinIntegrator
*>
(
object
);
node
.
setDoubleProperty
(
"stepSize"
,
integrator
.
getStepSize
());
node
.
setDoubleProperty
(
"constraintTolerance"
,
integrator
.
getConstraintTolerance
());
node
.
setDoubleProperty
(
"temperature"
,
integrator
.
getTemperature
());
node
.
setDoubleProperty
(
"friction"
,
integrator
.
getFriction
());
node
.
setDoubleProperty
(
"drudeTemperature"
,
integrator
.
getDrudeTemperature
());
node
.
setDoubleProperty
(
"drudeFriction"
,
integrator
.
getDrudeFriction
());
node
.
setIntProperty
(
"randomSeed"
,
integrator
.
getRandomNumberSeed
());
}
void
*
DrudeLangevinIntegratorProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
DrudeLangevinIntegrator
*
integrator
=
new
DrudeLangevinIntegrator
(
node
.
getDoubleProperty
(
"temperature"
),
node
.
getDoubleProperty
(
"friction"
),
node
.
getDoubleProperty
(
"drudeTemperature"
),
node
.
getDoubleProperty
(
"drudeFriction"
),
node
.
getDoubleProperty
(
"stepSize"
));
integrator
->
setConstraintTolerance
(
node
.
getDoubleProperty
(
"constraintTolerance"
));
integrator
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
return
integrator
;
}
\ No newline at end of file
plugins/drude/serialization/src/DrudeSerializationProxyRegistration.cpp
0 → 100644
View file @
6185317a
/* -------------------------------------------------------------------------- *
* OpenMMDrude *
* -------------------------------------------------------------------------- *
* 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) 2013 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. *
* -------------------------------------------------------------------------- */
#ifdef WIN32
#include <windows.h>
#include <sstream>
#else
#include <dlfcn.h>
#include <dirent.h>
#include <cstdlib>
#endif
#include "openmm/OpenMMException.h"
#include "openmm/DrudeForce.h"
#include "openmm/DrudeLangevinIntegrator.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/DrudeForceProxy.h"
#include "openmm/serialization/DrudeLangevinIntegratorProxy.h"
#include "openmm/serialization/internal/windowsExportDrudeSerialization.h"
#if defined(WIN32)
#include <windows.h>
extern
"C"
OPENMM_EXPORT_DRUDE_SERIALIZATION
void
registerDrudeSerializationProxies
();
BOOL
WINAPI
DllMain
(
HANDLE
hModule
,
DWORD
ul_reason_for_call
,
LPVOID
lpReserved
)
{
if
(
ul_reason_for_call
==
DLL_PROCESS_ATTACH
)
registerDrudeSerializationProxies
();
return
TRUE
;
}
#else
extern
"C"
void
__attribute__
((
constructor
))
registerDrudeSerializationProxies
();
#endif
using
namespace
OpenMM
;
extern
"C"
OPENMM_EXPORT_DRUDE_SERIALIZATION
void
registerDrudeSerializationProxies
()
{
SerializationProxy
::
registerProxy
(
typeid
(
DrudeForce
),
new
DrudeForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
DrudeLangevinIntegrator
),
new
DrudeLangevinIntegratorProxy
());
}
plugins/drude/serialization/tests/CMakeLists.txt
0 → 100644
View file @
6185317a
#
# Testing
#
ENABLE_TESTING
()
# Automatically create tests using files named "Test*.cpp"
FILE
(
GLOB TEST_PROGS
"*Test*.cpp"
)
FOREACH
(
TEST_PROG
${
TEST_PROGS
}
)
GET_FILENAME_COMPONENT
(
TEST_ROOT
${
TEST_PROG
}
NAME_WE
)
# All tests use shared libraries
ADD_EXECUTABLE
(
${
TEST_ROOT
}
${
TEST_PROG
}
)
TARGET_LINK_LIBRARIES
(
${
TEST_ROOT
}
${
OPENMM_SERIALIZATION_LIBRARY_NAME
}
${
OPENMM_DRUDE_SERIALIZATION_LIBRARY_NAME
}
${
OPENMM_DRUDE_LIBRARY_NAME
}
)
ADD_TEST
(
${
TEST_ROOT
}
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
)
ENDFOREACH
(
TEST_PROG
${
TEST_PROGS
}
)
plugins/drude/serialization/tests/TestSerializeDrudeForce.cpp
0 → 100644
View file @
6185317a
/* -------------------------------------------------------------------------- *
* OpenMMDrude *
* -------------------------------------------------------------------------- *
* 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) 2013 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/Platform.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/DrudeForce.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
extern
"C"
void
registerDrudeSerializationProxies
();
void
testSerialization
()
{
// Create a Force.
DrudeForce
force1
;
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
);
force1
.
addScreenedPair
(
0
,
1
,
2.6
);
force1
.
addScreenedPair
(
1
,
2
,
2.2
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
DrudeForce
>
(
&
force1
,
"Force"
,
buffer
);
DrudeForce
*
copy
=
XmlSerializer
::
deserialize
<
DrudeForce
>
(
buffer
);
// Compare the two forces to see if they are identical.
DrudeForce
&
force2
=
*
copy
;
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
;
double
charge1
,
charge2
;
double
polar1
,
polar2
;
double
aa12
,
ba12
,
aa34
,
ba34
;
force1
.
getParticleParameters
(
i
,
a1
,
a2
,
a3
,
a4
,
a5
,
charge1
,
polar1
,
aa12
,
aa34
);
force2
.
getParticleParameters
(
i
,
b1
,
b2
,
b3
,
b4
,
b5
,
charge2
,
polar2
,
ba12
,
ba34
);
ASSERT_EQUAL
(
a1
,
b1
);
ASSERT_EQUAL
(
a2
,
b2
);
ASSERT_EQUAL
(
a3
,
b3
);
ASSERT_EQUAL
(
a4
,
b4
);
ASSERT_EQUAL
(
a5
,
b5
);
ASSERT_EQUAL
(
charge1
,
charge2
);
ASSERT_EQUAL
(
polar1
,
polar2
);
ASSERT_EQUAL
(
aa12
,
ba12
);
ASSERT_EQUAL
(
aa34
,
ba34
);
}
ASSERT_EQUAL
(
force1
.
getNumScreenedPairs
(),
force2
.
getNumScreenedPairs
());
for
(
int
i
=
0
;
i
<
(
int
)
force1
.
getNumScreenedPairs
();
i
++
)
{
int
a1
,
a2
,
b1
,
b2
;
double
thole1
,
thole2
;
force1
.
getScreenedPairParameters
(
i
,
a1
,
a2
,
thole1
);
force1
.
getScreenedPairParameters
(
i
,
b1
,
b2
,
thole2
);
ASSERT_EQUAL
(
a1
,
b1
);
ASSERT_EQUAL
(
a2
,
b2
);
ASSERT_EQUAL
(
thole1
,
thole2
);
}
}
int
main
()
{
try
{
registerDrudeSerializationProxies
();
testSerialization
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
plugins/drude/serialization/tests/TestSerializeDrudeLangevinIntegrator.cpp
0 → 100644
View file @
6185317a
/* -------------------------------------------------------------------------- *
* OpenMMDrude *
* -------------------------------------------------------------------------- *
* 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) 2013 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/Platform.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/DrudeLangevinIntegrator.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
extern
"C"
void
registerDrudeSerializationProxies
();
void
testSerialization
()
{
// Create an Integrator.
DrudeLangevinIntegrator
integ1
(
301.1
,
0.95
,
10.5
,
1.2
,
0.001
);
integ1
.
setRandomNumberSeed
(
18
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
DrudeLangevinIntegrator
>
(
&
integ1
,
"Integrator"
,
buffer
);
DrudeLangevinIntegrator
*
copy
=
XmlSerializer
::
deserialize
<
DrudeLangevinIntegrator
>
(
buffer
);
// Compare the two integrators to see if they are identical.
DrudeLangevinIntegrator
&
integ2
=
*
copy
;
ASSERT_EQUAL
(
integ1
.
getTemperature
(),
integ2
.
getTemperature
());
ASSERT_EQUAL
(
integ1
.
getFriction
(),
integ2
.
getFriction
());
ASSERT_EQUAL
(
integ1
.
getDrudeTemperature
(),
integ2
.
getDrudeTemperature
());
ASSERT_EQUAL
(
integ1
.
getDrudeFriction
(),
integ2
.
getDrudeFriction
());
ASSERT_EQUAL
(
integ1
.
getRandomNumberSeed
(),
integ2
.
getRandomNumberSeed
());
}
int
main
()
{
try
{
registerDrudeSerializationProxies
();
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