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
5a06df78
Commit
5a06df78
authored
Mar 04, 2020
by
tic20
Browse files
Merge
https://github.com/openmm/openmm
parents
8dd60914
a9223eea
Changes
335
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
880 additions
and
41 deletions
+880
-41
plugins/drude/platforms/reference/tests/TestReferenceDrudeNoseHoover.cpp
...latforms/reference/tests/TestReferenceDrudeNoseHoover.cpp
+50
-0
plugins/drude/serialization/include/openmm/serialization/DrudeNoseHooverIntegratorProxy.h
...ude/openmm/serialization/DrudeNoseHooverIntegratorProxy.h
+18
-0
plugins/drude/serialization/src/DrudeNoseHooverIntegratorProxy.cpp
...rude/serialization/src/DrudeNoseHooverIntegratorProxy.cpp
+80
-0
plugins/drude/serialization/src/DrudeSerializationProxyRegistration.cpp
...serialization/src/DrudeSerializationProxyRegistration.cpp
+3
-0
plugins/drude/serialization/tests/TestSerializeDrudeNoseHooverIntegrator.cpp
...lization/tests/TestSerializeDrudeNoseHooverIntegrator.cpp
+109
-0
plugins/drude/tests/TestDrudeNoseHoover.h
plugins/drude/tests/TestDrudeNoseHoover.h
+283
-0
plugins/rpmd/platforms/cuda/CMakeLists.txt
plugins/rpmd/platforms/cuda/CMakeLists.txt
+10
-9
plugins/rpmd/platforms/cuda/src/CudaRpmdKernelSources.h.in
plugins/rpmd/platforms/cuda/src/CudaRpmdKernelSources.h.in
+1
-1
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
+1
-1
plugins/rpmd/platforms/opencl/CMakeLists.txt
plugins/rpmd/platforms/opencl/CMakeLists.txt
+10
-9
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernelSources.h.in
...ns/rpmd/platforms/opencl/src/OpenCLRpmdKernelSources.h.in
+1
-1
serialization/include/openmm/serialization/LangevinMiddleIntegratorProxy.h
...lude/openmm/serialization/LangevinMiddleIntegratorProxy.h
+17
-0
serialization/include/openmm/serialization/NoseHooverIntegratorProxy.h
.../include/openmm/serialization/NoseHooverIntegratorProxy.h
+17
-0
serialization/src/LangevinMiddleIntegratorProxy.cpp
serialization/src/LangevinMiddleIntegratorProxy.cpp
+6
-6
serialization/src/NonbondedForceProxy.cpp
serialization/src/NonbondedForceProxy.cpp
+6
-3
serialization/src/NoseHooverIntegratorProxy.cpp
serialization/src/NoseHooverIntegratorProxy.cpp
+128
-0
serialization/src/SerializationProxyRegistration.cpp
serialization/src/SerializationProxyRegistration.cpp
+7
-4
serialization/tests/TestSerializeIntegrator.cpp
serialization/tests/TestSerializeIntegrator.cpp
+6
-6
serialization/tests/TestSerializeNonbondedForce.cpp
serialization/tests/TestSerializeNonbondedForce.cpp
+3
-1
serialization/tests/TestSerializeNoseHooverIntegrator.cpp
serialization/tests/TestSerializeNoseHooverIntegrator.cpp
+124
-0
No files found.
plugins/drude/platforms/reference/tests/TestReferenceDrudeNoseHoover.cpp
0 → 100644
View file @
5a06df78
/* -------------------------------------------------------------------------- *
* 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) 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 "ReferenceTests.h"
#include "openmm/Platform.h"
using
namespace
OpenMM
;
using
namespace
std
;
//extern "C" OPENMM_EXPORT void registerDrudeReferenceKernelFactories();
Platform
&
initializePlatform
(
int
argc
,
char
*
argv
[])
{
/* registerDrudeReferenceKernelFactories();
*/
return
Platform
::
getPlatformByName
(
"Reference"
);
}
#include "TestDrudeNoseHoover.h"
void
runPlatformTests
()
{
}
plugins/drude/serialization/include/openmm/serialization/DrudeNoseHooverIntegratorProxy.h
0 → 100644
View file @
5a06df78
#ifndef OPENMM_DRUDE_NOSE_HOOVER_INTEGRATOR_PROXY_H_
#define OPENMM_DRUDE_NOSE_HOOVER_INTEGRATOR_PROXY_H_
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/internal/windowsExportDrude.h"
namespace
OpenMM
{
class
OPENMM_EXPORT_DRUDE
DrudeNoseHooverIntegratorProxy
:
public
SerializationProxy
{
public:
DrudeNoseHooverIntegratorProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
#endif
/*OPENMM_DRUDE_NOSE_HOOVER_INTEGRATOR_PROXY_H_*/
plugins/drude/serialization/src/DrudeNoseHooverIntegratorProxy.cpp
0 → 100644
View file @
5a06df78
/* -------------------------------------------------------------------------- *
* 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: Andrew C. Simmonett, Andreas Krämer *
* 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/DrudeNoseHooverIntegratorProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/DrudeNoseHooverIntegrator.h"
#include <vector>
#include <assert.h>
#include <OpenMM.h>
using
namespace
std
;
using
namespace
OpenMM
;
DrudeNoseHooverIntegratorProxy
::
DrudeNoseHooverIntegratorProxy
()
:
SerializationProxy
(
"DrudeNoseHooverIntegrator"
)
{
}
void
DrudeNoseHooverIntegratorProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
DrudeNoseHooverIntegrator
&
integrator
=
*
reinterpret_cast
<
const
DrudeNoseHooverIntegrator
*>
(
object
);
node
.
setDoubleProperty
(
"stepSize"
,
integrator
.
getStepSize
());
node
.
setDoubleProperty
(
"constraintTolerance"
,
integrator
.
getConstraintTolerance
());
node
.
setDoubleProperty
(
"maximumPairDistance"
,
integrator
.
getMaximumPairDistance
());
assert
(
not
integrator
.
hasSubsystemThermostats
());
node
.
setDoubleProperty
(
"temperature"
,
integrator
.
getTemperature
());
node
.
setDoubleProperty
(
"relativeTemperature"
,
integrator
.
getRelativeTemperature
());
node
.
setDoubleProperty
(
"collisionFrequency"
,
integrator
.
getCollisionFrequency
());
node
.
setDoubleProperty
(
"relativeCollisionFrequency"
,
integrator
.
getRelativeCollisionFrequency
());
node
.
setIntProperty
(
"chainLength"
,
integrator
.
getThermostat
().
getChainLength
());
node
.
setIntProperty
(
"numMTS"
,
integrator
.
getThermostat
().
getNumMultiTimeSteps
());
node
.
setIntProperty
(
"numYS"
,
integrator
.
getThermostat
().
getNumYoshidaSuzukiTimeSteps
());
}
void
*
DrudeNoseHooverIntegratorProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
DrudeNoseHooverIntegrator
*
integrator
;
integrator
=
new
DrudeNoseHooverIntegrator
(
node
.
getDoubleProperty
(
"temperature"
),
node
.
getDoubleProperty
(
"collisionFrequency"
),
node
.
getDoubleProperty
(
"relativeTemperature"
),
node
.
getDoubleProperty
(
"relativeCollisionFrequency"
),
node
.
getDoubleProperty
(
"stepSize"
),
node
.
getIntProperty
(
"chainLength"
),
node
.
getIntProperty
(
"numMTS"
),
node
.
getIntProperty
(
"numYS"
)
);
integrator
->
setConstraintTolerance
(
node
.
getDoubleProperty
(
"constraintTolerance"
));
integrator
->
setMaximumPairDistance
(
node
.
getDoubleProperty
(
"maximumPairDistance"
));
return
integrator
;
}
plugins/drude/serialization/src/DrudeSerializationProxyRegistration.cpp
View file @
5a06df78
...
@@ -42,11 +42,13 @@
...
@@ -42,11 +42,13 @@
#include "openmm/DrudeForce.h"
#include "openmm/DrudeForce.h"
#include "openmm/DrudeLangevinIntegrator.h"
#include "openmm/DrudeLangevinIntegrator.h"
#include "openmm/DrudeNoseHooverIntegrator.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/DrudeForceProxy.h"
#include "openmm/serialization/DrudeForceProxy.h"
#include "openmm/serialization/DrudeLangevinIntegratorProxy.h"
#include "openmm/serialization/DrudeLangevinIntegratorProxy.h"
#include "openmm/serialization/DrudeNoseHooverIntegratorProxy.h"
#if defined(WIN32)
#if defined(WIN32)
#include <windows.h>
#include <windows.h>
...
@@ -65,4 +67,5 @@ using namespace OpenMM;
...
@@ -65,4 +67,5 @@ using namespace OpenMM;
extern
"C"
OPENMM_EXPORT_DRUDE
void
registerDrudeSerializationProxies
()
{
extern
"C"
OPENMM_EXPORT_DRUDE
void
registerDrudeSerializationProxies
()
{
SerializationProxy
::
registerProxy
(
typeid
(
DrudeForce
),
new
DrudeForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
DrudeForce
),
new
DrudeForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
DrudeLangevinIntegrator
),
new
DrudeLangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
DrudeLangevinIntegrator
),
new
DrudeLangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
DrudeNoseHooverIntegrator
),
new
DrudeNoseHooverIntegratorProxy
());
}
}
plugins/drude/serialization/tests/TestSerializeDrudeNoseHooverIntegrator.cpp
0 → 100644
View file @
5a06df78
/* -------------------------------------------------------------------------- *
* 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: Andrew C. Simmonett and Andreas Kraemer
* 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/DrudeNoseHooverIntegrator.h"
#include "ReferencePlatform.h"
#include "openmm/serialization/XmlSerializer.h"
#include "openmm/System.h"
#include "openmm/DrudeForce.h"
#include "openmm/Context.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
extern
"C"
void
registerDrudeSerializationProxies
();
//extern "C" OPENMM_EXPORT void registerDrudeReferenceKernelFactories();
//extern "C" OPENMM_EXPORT void registerKernelFactories();
void
assertIntegratorsEqual
(
const
DrudeNoseHooverIntegrator
&
integrator1
,
const
DrudeNoseHooverIntegrator
&
integrator2
){
ASSERT_EQUAL
(
integrator1
.
getStepSize
(),
integrator2
.
getStepSize
());
ASSERT_EQUAL
(
integrator1
.
getConstraintTolerance
(),
integrator2
.
getConstraintTolerance
());
ASSERT_EQUAL
(
integrator1
.
getMaximumPairDistance
(),
integrator2
.
getMaximumPairDistance
());
ASSERT_EQUAL
(
integrator1
.
getNumThermostats
(),
integrator2
.
getNumThermostats
());
for
(
int
i
=
0
;
i
<
integrator1
.
getNumThermostats
();
i
++
)
{
const
auto
&
thermostat1
=
integrator1
.
getThermostat
(
i
);
const
auto
&
thermostat2
=
integrator2
.
getThermostat
(
i
);
ASSERT_EQUAL
(
thermostat1
.
getTemperature
(),
thermostat2
.
getTemperature
());
ASSERT_EQUAL
(
thermostat1
.
getCollisionFrequency
(),
thermostat2
.
getCollisionFrequency
());
ASSERT_EQUAL
(
thermostat1
.
getRelativeTemperature
(),
thermostat2
.
getRelativeTemperature
());
ASSERT_EQUAL
(
thermostat1
.
getRelativeCollisionFrequency
(),
thermostat2
.
getRelativeCollisionFrequency
());
ASSERT_EQUAL
(
thermostat1
.
getChainLength
(),
thermostat2
.
getChainLength
());
ASSERT_EQUAL
(
thermostat1
.
getNumMultiTimeSteps
(),
thermostat2
.
getNumMultiTimeSteps
());
ASSERT_EQUAL
(
thermostat1
.
getNumYoshidaSuzukiTimeSteps
(),
thermostat2
.
getNumYoshidaSuzukiTimeSteps
());
ASSERT_EQUAL
(
thermostat1
.
getChainID
(),
thermostat2
.
getChainID
());
const
auto
&
thermostat1Atoms
=
thermostat1
.
getThermostatedAtoms
();
const
auto
&
thermostat2Atoms
=
thermostat2
.
getThermostatedAtoms
();
ASSERT_EQUAL
(
thermostat1Atoms
.
size
(),
thermostat2Atoms
.
size
());
for
(
int
j
=
0
;
j
<
thermostat1Atoms
.
size
();
++
j
)
{
ASSERT_EQUAL
(
thermostat1Atoms
[
j
],
thermostat2Atoms
[
j
]);
}
const
auto
&
thermostat1Pairs
=
thermostat1
.
getThermostatedPairs
();
const
auto
&
thermostat2Pairs
=
thermostat2
.
getThermostatedPairs
();
ASSERT_EQUAL
(
thermostat1Pairs
.
size
(),
thermostat2Pairs
.
size
());
for
(
int
j
=
0
;
j
<
thermostat1Pairs
.
size
();
++
j
)
{
ASSERT_EQUAL
(
thermostat1Pairs
[
j
].
first
,
thermostat2Pairs
[
j
].
first
);
ASSERT_EQUAL
(
thermostat1Pairs
[
j
].
second
,
thermostat2Pairs
[
j
].
second
);
}
}
}
void
testSerialization
()
{
// Check with default constructor
System
system
;
system
.
addForce
(
new
DrudeForce
());
for
(
int
i
=
0
;
i
<
10
;
i
++
)
system
.
addParticle
(
1.0
);
DrudeNoseHooverIntegrator
integrator
(
331
,
0.21
,
1.1
,
0.1
,
0.004
,
5
,
5
,
5
);
// Serialize and then deserialize it.
stringstream
buffer2
;
XmlSerializer
::
serialize
<
DrudeNoseHooverIntegrator
>
(
&
integrator
,
"Integrator"
,
buffer2
);
DrudeNoseHooverIntegrator
*
copy
=
XmlSerializer
::
deserialize
<
DrudeNoseHooverIntegrator
>
(
buffer2
);
ASSERT_EQUAL
(
copy
->
getThermostat
(
0
).
getThermostatedAtoms
().
size
(),
0
);
assertIntegratorsEqual
(
integrator
,
*
copy
);
}
int
main
()
{
try
{
testSerialization
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
plugins/drude/tests/TestDrudeNoseHoover.h
0 → 100644
View file @
5a06df78
/* -------------------------------------------------------------------------- *
* 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) 2019 Stanford University and the Authors. *
* Authors: Andreas Krämer and Andrew C. Simmonett *
* 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/NoseHooverChain.h"
#include "openmm/CMMotionRemover.h"
#include "openmm/DrudeNoseHooverIntegrator.h"
#include "openmm/Context.h"
#include "openmm/State.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/VirtualSite.h"
#include "openmm/NonbondedForce.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/System.h"
#include "openmm/DrudeForce.h"
#include "SimTKOpenMMRealType.h"
#include "sfmt/SFMT.h"
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
using
namespace
OpenMM
;
using
namespace
std
;
extern
"C"
OPENMM_EXPORT
void
registerDrudeReferenceKernelFactories
();
extern
"C"
OPENMM_EXPORT
void
registerKernelFactories
();
Platform
&
initializePlatform
(
int
argc
,
char
*
argv
[]);
void
build_waterbox
(
System
&
system
,
int
gridSize
,
double
polarizability
,
vector
<
Vec3
>
&
positions
)
{
// Create a box of SWM4-NDP water molecules. This involves constraints, virtual sites,
// and Drude particles.
const
int
numMolecules
=
gridSize
*
gridSize
*
gridSize
;
const
double
spacing
=
0.8
;
const
double
boxSize
=
spacing
*
(
gridSize
+
1
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
DrudeForce
*
drude
=
new
DrudeForce
();
CMMotionRemover
*
cmm
=
new
CMMotionRemover
(
1
);
system
.
addForce
(
cmm
);
system
.
addForce
(
nonbonded
);
system
.
addForce
(
drude
);
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
boxSize
,
0
,
0
),
Vec3
(
0
,
boxSize
,
0
),
Vec3
(
0
,
0
,
boxSize
));
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
nonbonded
->
setCutoffDistance
(
1.2
);
nonbonded
->
setSwitchingDistance
(
0.8
);
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
int
startIndex
=
system
.
getNumParticles
();
system
.
addParticle
(
15.6
);
// O
system
.
addParticle
(
0.4
);
// D
system
.
addParticle
(
1.0
);
// H1
system
.
addParticle
(
1.0
);
// H2
system
.
addParticle
(
0.0
);
// M
nonbonded
->
addParticle
(
1.71636
,
0.318395
,
0.21094
*
4.184
);
nonbonded
->
addParticle
(
-
1.71636
,
1
,
0
);
nonbonded
->
addParticle
(
0.55733
,
1
,
0
);
nonbonded
->
addParticle
(
0.55733
,
1
,
0
);
nonbonded
->
addParticle
(
-
1.11466
,
1
,
0
);
for
(
int
j
=
0
;
j
<
5
;
j
++
)
for
(
int
k
=
0
;
k
<
j
;
k
++
)
nonbonded
->
addException
(
startIndex
+
j
,
startIndex
+
k
,
0
,
1
,
0
);
system
.
addConstraint
(
startIndex
,
startIndex
+
2
,
0.09572
);
system
.
addConstraint
(
startIndex
,
startIndex
+
3
,
0.09572
);
system
.
addConstraint
(
startIndex
+
2
,
startIndex
+
3
,
0.15139
);
system
.
setVirtualSite
(
startIndex
+
4
,
new
ThreeParticleAverageSite
(
startIndex
,
startIndex
+
2
,
startIndex
+
3
,
0.786646558
,
0.106676721
,
0.106676721
));
drude
->
addParticle
(
startIndex
+
1
,
startIndex
,
-
1
,
-
1
,
-
1
,
-
1.71636
,
polarizability
,
1
,
1
);
}
for
(
int
i
=
0
;
i
<
gridSize
;
i
++
)
{
for
(
int
j
=
0
;
j
<
gridSize
;
j
++
)
{
for
(
int
k
=
0
;
k
<
gridSize
;
k
++
)
{
Vec3
pos
(
i
*
spacing
,
j
*
spacing
,
k
*
spacing
);
positions
.
push_back
(
pos
);
positions
.
push_back
(
pos
);
positions
.
push_back
(
pos
+
Vec3
(
0.09572
,
0
,
0
));
positions
.
push_back
(
pos
+
Vec3
(
-
0.023999
,
0.092663
,
0
));
positions
.
push_back
(
pos
);
}
}
}
}
void
testWaterBox
(
Platform
&
platform
)
{
// Create a box of SWM4-NDP water molecules. This involves constraints, virtual sites,
// and Drude particles.
System
system
;
const
int
gridSize
=
3
;
vector
<
Vec3
>
positions
;
double
polarizability
=
ONE_4PI_EPS0
*
1.71636
*
1.71636
/
(
100000
*
4.184
);
build_waterbox
(
system
,
gridSize
,
polarizability
,
positions
);
const
int
numMolecules
=
gridSize
*
gridSize
*
gridSize
;
int
numStandardDof
=
3
*
3
*
numMolecules
-
system
.
getNumConstraints
();
int
numDrudeDof
=
3
*
numMolecules
;
int
numDof
=
numStandardDof
+
numDrudeDof
;
const
double
temperature
=
300.0
;
const
double
temperatureDrude
=
10.0
;
// Simulate it and check the temperature.
int
chainLength
=
4
;
int
numMTS
=
4
;
int
numYS
=
5
;
double
frequency
=
800.0
;
double
frequencyDrude
=
2000.0
;
int
randomSeed
=
100
;
DrudeNoseHooverIntegrator
integ
(
temperature
,
frequency
,
temperatureDrude
,
frequencyDrude
,
0.0005
,
chainLength
,
numMTS
,
numYS
);
Context
context
(
system
,
integ
,
platform
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temperature
,
randomSeed
);
std
::
vector
<
Vec3
>
velocities
=
context
.
getState
(
State
::
Velocities
).
getVelocities
();
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
){
Vec3
noize
;
for
(
int
j
=
0
;
j
<
3
;
j
++
){
noize
[
j
]
=
float
(((
i
+
18311
)
*
(
j
+
18253
)
*
313419097822414
)
%
18313
)
/
float
(
18313
);
noize
[
j
]
*=
sqrt
(
3
*
BOLTZ
*
temperatureDrude
/
0.4
);
}
velocities
[
5
*
i
+
1
]
=
velocities
[
5
*
i
]
+
noize
;
}
context
.
setVelocities
(
velocities
);
context
.
applyConstraints
(
1e-6
);
// Equilibrate.
integ
.
step
(
500
);
// Compute the internal and center of mass temperatures.
double
totalKE
=
0
;
const
int
numSteps
=
4000
;
double
meanTemp
=
0.0
;
double
meanDrudeTemp
=
0.0
;
double
meanConserved
=
0.0
;
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
integ
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Energy
);
double
KE
=
state
.
getKineticEnergy
();
double
PE
=
state
.
getPotentialEnergy
();
double
fullKE
=
integ
.
computeTotalKineticEnergy
();
double
drudeKE
=
integ
.
computeDrudeKineticEnergy
();
double
temp
=
KE
/
(
0.5
*
numStandardDof
*
BOLTZ
);
double
drudeTemp
=
drudeKE
/
(
0.5
*
numDrudeDof
*
BOLTZ
);
meanTemp
=
(
i
*
meanTemp
+
temp
)
/
(
i
+
1
);
meanDrudeTemp
=
(
i
*
meanDrudeTemp
+
drudeTemp
)
/
(
i
+
1
);
double
heatBathEnergy
=
integ
.
computeHeatBathEnergy
();
double
conserved
=
PE
+
fullKE
+
heatBathEnergy
;
meanConserved
=
(
i
*
meanConserved
+
conserved
)
/
(
i
+
1
);
totalKE
+=
KE
;
ASSERT
(
fabs
(
meanConserved
-
conserved
)
<
0.6
);
}
totalKE
/=
numSteps
;
ASSERT_USUALLY_EQUAL_TOL
(
temperature
,
meanTemp
,
0.004
);
ASSERT_USUALLY_EQUAL_TOL
(
temperatureDrude
,
meanDrudeTemp
,
0.004
);
}
double
testWaterBoxWithHardWallConstraint
(
Platform
&
platform
,
double
hardWallConstraint
){
// Create a box of SWM4-NDP water molecules. This involves constraints, virtual sites,
// and Drude particles.
System
system
;
const
int
gridSize
=
3
;
vector
<
Vec3
>
positions
;
double
polarizability
=
1e-2
;
build_waterbox
(
system
,
gridSize
,
polarizability
,
positions
);
const
int
numMolecules
=
gridSize
*
gridSize
*
gridSize
;
int
numStandardDof
=
3
*
3
*
numMolecules
-
system
.
getNumConstraints
();
int
numDrudeDof
=
3
*
numMolecules
;
int
numDof
=
numStandardDof
+
numDrudeDof
;
const
double
temperature
=
300.0
;
const
double
temperatureDrude
=
10.0
;
// Simulate it and check the temperature.
int
chainLength
=
4
;
int
numMTS
=
3
;
int
numYS
=
3
;
double
frequency
=
25.0
;
double
frequencyDrude
=
25.0
;
int
randomSeed
=
100
;
DrudeNoseHooverIntegrator
integ
(
temperature
,
frequency
,
temperatureDrude
,
frequencyDrude
,
0.0005
,
chainLength
,
numMTS
,
numYS
);
integ
.
setMaxDrudeDistance
(
hardWallConstraint
);
Context
context
(
system
,
integ
,
platform
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
temperature
,
randomSeed
);
std
::
vector
<
Vec3
>
velocities
=
context
.
getState
(
State
::
Velocities
).
getVelocities
();
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
){
Vec3
noize
;
for
(
int
j
=
0
;
j
<
3
;
j
++
){
noize
[
j
]
=
float
(((
i
+
18311
)
*
(
j
+
18253
)
*
313419097822414
)
%
18313
)
/
float
(
18313
);
noize
[
j
]
*=
sqrt
(
3
*
BOLTZ
*
temperatureDrude
/
0.4
);
}
velocities
[
5
*
i
+
1
]
=
velocities
[
5
*
i
]
+
noize
;
}
context
.
setVelocities
(
velocities
);
context
.
applyConstraints
(
1e-6
);
// Equilibrate.
integ
.
step
(
10
);
// Compute the internal and center of mass temperatures.
double
totalKE
=
0
;
const
int
numSteps
=
10
;
double
meanTemp
=
0.0
;
double
meanDrudeTemp
=
0.0
;
double
meanConserved
=
0.0
;
double
maxR
=
0.0
;
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
integ
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Energy
|
State
::
Positions
);
double
KE
=
state
.
getKineticEnergy
();
double
PE
=
state
.
getPotentialEnergy
();
double
fullKE
=
integ
.
computeTotalKineticEnergy
();
double
drudeKE
=
integ
.
computeDrudeKineticEnergy
();
double
temp
=
KE
/
(
0.5
*
numStandardDof
*
BOLTZ
);
double
drudeTemp
=
drudeKE
/
(
0.5
*
numDrudeDof
*
BOLTZ
);
meanTemp
=
(
i
*
meanTemp
+
temp
)
/
(
i
+
1
);
meanDrudeTemp
=
(
i
*
meanDrudeTemp
+
drudeTemp
)
/
(
i
+
1
);
double
heatBathEnergy
=
integ
.
computeHeatBathEnergy
();
double
conserved
=
PE
+
fullKE
+
heatBathEnergy
;
meanConserved
=
(
i
*
meanConserved
+
conserved
)
/
(
i
+
1
);
const
auto
&
positions
=
state
.
getPositions
();
for
(
int
mol
=
0
;
mol
<
gridSize
*
gridSize
*
gridSize
;
++
mol
)
{
auto
dR
=
positions
[
5
*
mol
+
1
]
-
positions
[
5
*
mol
];
maxR
=
std
::
max
(
maxR
,
std
::
sqrt
(
dR
.
dot
(
dR
)));
}
totalKE
+=
KE
;
}
totalKE
/=
numSteps
;
return
maxR
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
registerKernelFactories
();
Platform
&
platform
=
initializePlatform
(
argc
,
argv
);
testWaterBox
(
platform
);
double
maxDrudeDistance
=
0.005
;
double
observedDrudeDistance
=
testWaterBoxWithHardWallConstraint
(
platform
,
0.0
);
ASSERT
(
observedDrudeDistance
>
maxDrudeDistance
);
observedDrudeDistance
=
testWaterBoxWithHardWallConstraint
(
platform
,
maxDrudeDistance
);
ASSERT
(
observedDrudeDistance
<
maxDrudeDistance
);
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
plugins/rpmd/platforms/cuda/CMakeLists.txt
View file @
5a06df78
...
@@ -63,27 +63,28 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
...
@@ -63,27 +63,28 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/cuda/include
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/cuda/include
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/cuda/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/cuda/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_BINARY_DIR
}
/platforms/cuda/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_BINARY_DIR
}
/platforms/cuda/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/common/include
)
# Set variables needed for encoding kernel sources into a C++ class
# Set variables needed for encoding kernel sources into a C++ class
SET
(
CUDA
_SOURCE_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
SET
(
KERNEL
_SOURCE_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
SET
(
CUDA
_SOURCE_CLASS CudaRpmdKernelSources
)
SET
(
KERNEL
_SOURCE_CLASS CudaRpmdKernelSources
)
SET
(
CUDA_
KERNELS_CPP
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
CUDA
_SOURCE_CLASS
}
.cpp
)
SET
(
KERNELS_CPP
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
KERNEL
_SOURCE_CLASS
}
.cpp
)
SET
(
CUDA_
KERNELS_H
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
CUDA
_SOURCE_CLASS
}
.h
)
SET
(
KERNELS_H
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
KERNEL
_SOURCE_CLASS
}
.h
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
CUDA_
KERNELS_CPP
}
${
CUDA_
KERNELS_H
}
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
KERNELS_CPP
}
${
KERNELS_H
}
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_BINARY_DIR
}
/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_BINARY_DIR
}
/src
)
# Create the library
# Create the library
INCLUDE_DIRECTORIES
(
${
CUDA_TOOLKIT_INCLUDE
}
)
INCLUDE_DIRECTORIES
(
${
CUDA_TOOLKIT_INCLUDE
}
)
FILE
(
GLOB CUDA_KERNELS
${
CUDA
_SOURCE_DIR
}
/kernels/*.cu
)
FILE
(
GLOB CUDA_KERNELS
${
KERNEL
_SOURCE_DIR
}
/kernels/*.cu
)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
CUDA_
KERNELS_CPP
}
${
CUDA_
KERNELS_H
}
ADD_CUSTOM_COMMAND
(
OUTPUT
${
KERNELS_CPP
}
${
KERNELS_H
}
COMMAND
${
CMAKE_COMMAND
}
COMMAND
${
CMAKE_COMMAND
}
ARGS -D
CUDA
_SOURCE_DIR=
${
CUDA
_SOURCE_DIR
}
-D
CUDA_
KERNELS_CPP=
${
CUDA_
KERNELS_CPP
}
-D
CUDA_
KERNELS_H=
${
CUDA_
KERNELS_H
}
-D
CUDA
_SOURCE_CLASS=
${
CUDA
_SOURCE_CLASS
}
-
P
${
CMAKE_SOURCE_DIR
}
/platforms/cuda/EncodeCUDA
Files.cmake
ARGS -D
KERNEL
_SOURCE_DIR=
${
KERNEL
_SOURCE_DIR
}
-D KERNELS_CPP=
${
KERNELS_CPP
}
-D KERNELS_H=
${
KERNELS_H
}
-D
KERNEL
_SOURCE_CLASS=
${
KERNEL
_SOURCE_CLASS
}
-
D KERNEL_FILE_EXTENSION=cu -P
${
CMAKE_SOURCE_DIR
}
/cmake_modules/EncodeKernel
Files.cmake
DEPENDS
${
CUDA_KERNELS
}
DEPENDS
${
CUDA_KERNELS
}
)
)
SET_SOURCE_FILES_PROPERTIES
(
${
CUDA_
KERNELS_CPP
}
${
CUDA_
KERNELS_H
}
PROPERTIES GENERATED TRUE
)
SET_SOURCE_FILES_PROPERTIES
(
${
KERNELS_CPP
}
${
KERNELS_H
}
PROPERTIES GENERATED TRUE
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
OPENMM_LIBRARY_NAME
}
${
PTHREADS_LIB
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
OPENMM_LIBRARY_NAME
}
${
PTHREADS_LIB
}
)
...
...
plugins/rpmd/platforms/cuda/src/CudaRpmdKernelSources.h.in
View file @
5a06df78
...
@@ -39,7 +39,7 @@ namespace OpenMM {
...
@@ -39,7 +39,7 @@ namespace OpenMM {
class CudaRpmdKernelSources {
class CudaRpmdKernelSources {
public:
public:
@
CUDA
_FILE_DECLARATIONS@
@
KERNEL
_FILE_DECLARATIONS@
};
};
} // namespace OpenMM
} // namespace OpenMM
...
...
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
View file @
5a06df78
...
@@ -307,7 +307,7 @@ void CudaIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& pos
...
@@ -307,7 +307,7 @@ void CudaIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& pos
double4
periodicBoxSize
=
cu
.
getPeriodicBoxSize
();
double4
periodicBoxSize
=
cu
.
getPeriodicBoxSize
();
vector
<
Vec3
>
offsetPos
(
numParticles
);
vector
<
Vec3
>
offsetPos
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
int4
offset
=
cu
.
getPosCellOffsets
()[
i
];
mm_
int4
offset
=
cu
.
getPosCellOffsets
()[
i
];
offsetPos
[
order
[
i
]]
=
pos
[
order
[
i
]]
+
Vec3
(
offset
.
x
*
periodicBoxSize
.
x
,
offset
.
y
*
periodicBoxSize
.
y
,
offset
.
z
*
periodicBoxSize
.
z
);
offsetPos
[
order
[
i
]]
=
pos
[
order
[
i
]]
+
Vec3
(
offset
.
x
*
periodicBoxSize
.
x
,
offset
.
y
*
periodicBoxSize
.
y
,
offset
.
z
*
periodicBoxSize
.
z
);
}
}
...
...
plugins/rpmd/platforms/opencl/CMakeLists.txt
View file @
5a06df78
...
@@ -62,27 +62,28 @@ ENDFOREACH(subdir)
...
@@ -62,27 +62,28 @@ ENDFOREACH(subdir)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/opencl/include
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/opencl/include
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/opencl/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/opencl/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/common/include
)
# Set variables needed for encoding kernel sources into a C++ class
# Set variables needed for encoding kernel sources into a C++ class
SET
(
C
L_SOURCE_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
SET
(
KERNE
L_SOURCE_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
SET
(
C
L_SOURCE_CLASS OpenCLRpmdKernelSources
)
SET
(
KERNE
L_SOURCE_CLASS OpenCLRpmdKernelSources
)
SET
(
CL_
KERNELS_CPP
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
C
L_SOURCE_CLASS
}
.cpp
)
SET
(
KERNELS_CPP
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
KERNE
L_SOURCE_CLASS
}
.cpp
)
SET
(
CL_
KERNELS_H
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
C
L_SOURCE_CLASS
}
.h
)
SET
(
KERNELS_H
${
CMAKE_CURRENT_BINARY_DIR
}
/src/
${
KERNE
L_SOURCE_CLASS
}
.h
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
CL_
KERNELS_CPP
}
${
CL_
KERNELS_H
}
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
KERNELS_CPP
}
${
KERNELS_H
}
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_BINARY_DIR
}
/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_BINARY_DIR
}
/src
)
# Create the library
# Create the library
INCLUDE_DIRECTORIES
(
${
OPENCL_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
OPENCL_INCLUDE_DIR
}
)
FILE
(
GLOB OPENCL_KERNELS
${
C
L_SOURCE_DIR
}
/kernels/*.cl
)
FILE
(
GLOB OPENCL_KERNELS
${
KERNE
L_SOURCE_DIR
}
/kernels/*.cl
)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
CL_
KERNELS_CPP
}
${
CL_
KERNELS_H
}
ADD_CUSTOM_COMMAND
(
OUTPUT
${
KERNELS_CPP
}
${
KERNELS_H
}
COMMAND
${
CMAKE_COMMAND
}
COMMAND
${
CMAKE_COMMAND
}
ARGS -D
C
L_SOURCE_DIR=
${
C
L_SOURCE_DIR
}
-D
CL_
KERNELS_CPP=
${
CL_
KERNELS_CPP
}
-D
CL_
KERNELS_H=
${
CL_
KERNELS_H
}
-D
C
L_SOURCE_CLASS=
${
C
L_SOURCE_CLASS
}
-P
${
CMAKE_SOURCE_DIR
}
/
platforms/opencl
/Encode
CL
Files.cmake
ARGS -D
KERNE
L_SOURCE_DIR=
${
KERNE
L_SOURCE_DIR
}
-D KERNELS_CPP=
${
KERNELS_CPP
}
-D KERNELS_H=
${
KERNELS_H
}
-D
KERNE
L_SOURCE_CLASS=
${
KERNE
L_SOURCE_CLASS
}
-D KERNEL_FILE_EXTENSION=cl
-P
${
CMAKE_SOURCE_DIR
}
/
cmake_modules
/Encode
Kernel
Files.cmake
DEPENDS
${
OPENCL_KERNELS
}
DEPENDS
${
OPENCL_KERNELS
}
)
)
SET_SOURCE_FILES_PROPERTIES
(
${
CL_
KERNELS_CPP
}
${
CL_
KERNELS_H
}
PROPERTIES GENERATED TRUE
)
SET_SOURCE_FILES_PROPERTIES
(
${
KERNELS_CPP
}
${
KERNELS_H
}
PROPERTIES GENERATED TRUE
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
OPENMM_LIBRARY_NAME
}
${
OPENCL_LIBRARIES
}
${
PTHREADS_LIB
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
OPENMM_LIBRARY_NAME
}
${
OPENCL_LIBRARIES
}
${
PTHREADS_LIB
}
)
...
...
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernelSources.h.in
View file @
5a06df78
...
@@ -39,7 +39,7 @@ namespace OpenMM {
...
@@ -39,7 +39,7 @@ namespace OpenMM {
class OpenCLRpmdKernelSources {
class OpenCLRpmdKernelSources {
public:
public:
@
C
L_FILE_DECLARATIONS@
@
KERNE
L_FILE_DECLARATIONS@
};
};
} // namespace OpenMM
} // namespace OpenMM
...
...
serialization/include/openmm/serialization/LangevinMiddleIntegratorProxy.h
0 → 100644
View file @
5a06df78
#ifndef OPENMM_LANGEVIN_MIDDLE_INTEGRATOR_PROXY_H_
#define OPENMM_LANGEVIN_MIDDLE_INTEGRATOR_PROXY_H_
#include "openmm/serialization/XmlSerializer.h"
namespace
OpenMM
{
class
LangevinMiddleIntegratorProxy
:
public
SerializationProxy
{
public:
LangevinMiddleIntegratorProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
#endif
/*OPENMM_LANGEVIN_MIDDLE_INTEGRATOR_PROXY_H_*/
\ No newline at end of file
serialization/include/openmm/serialization/
BAOABLangevin
IntegratorProxy.h
→
serialization/include/openmm/serialization/
NoseHoover
IntegratorProxy.h
View file @
5a06df78
#ifndef OPENMM_BAOAB_LANGEVIN_INTEGRATOR_PROXY_H_
#ifndef OPENMM_NOSE_HOOVER_INTEGRATOR_PROXY_H_
#define OPENMM_BAOAB_LANGEVIN_INTEGRATOR_PROXY_H_
#define OPENMM_NOSE_HOOVER_INTEGRATOR_PROXY_H_
#include "openmm/serialization/XmlSerializer.h"
#include "openmm/serialization/XmlSerializer.h"
namespace
OpenMM
{
namespace
OpenMM
{
class
BAOABLangevinIntegratorProxy
:
public
SerializationProxy
{
class
NoseHooverIntegratorProxy
:
public
SerializationProxy
{
public:
public:
BAOABLangevinIntegratorProxy
();
NoseHooverIntegratorProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
};
}
}
#endif
/*OPENMM_BAOAB_LANGEVIN_INTEGRATOR_PROXY_H_*/
#endif
/*OPENMM_NOSE_HOOVER_INTEGRATOR_PROXY_H_*/
\ No newline at end of file
serialization/src/
BAOAB
LangevinIntegratorProxy.cpp
→
serialization/src/Langevin
Middle
IntegratorProxy.cpp
View file @
5a06df78
...
@@ -29,19 +29,19 @@
...
@@ -29,19 +29,19 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "openmm/serialization/
BAOAB
LangevinIntegratorProxy.h"
#include "openmm/serialization/Langevin
Middle
IntegratorProxy.h"
#include <OpenMM.h>
#include <OpenMM.h>
using
namespace
std
;
using
namespace
std
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
BAOAB
LangevinIntegratorProxy
::
BAOAB
LangevinIntegratorProxy
()
:
SerializationProxy
(
"
BAOAB
LangevinIntegrator"
)
{
Langevin
Middle
IntegratorProxy
::
Langevin
Middle
IntegratorProxy
()
:
SerializationProxy
(
"Langevin
Middle
Integrator"
)
{
}
}
void
BAOAB
LangevinIntegratorProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
void
Langevin
Middle
IntegratorProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
node
.
setIntProperty
(
"version"
,
1
);
const
BAOAB
LangevinIntegrator
&
integrator
=
*
reinterpret_cast
<
const
BAOAB
LangevinIntegrator
*>
(
object
);
const
Langevin
Middle
Integrator
&
integrator
=
*
reinterpret_cast
<
const
Langevin
Middle
Integrator
*>
(
object
);
node
.
setDoubleProperty
(
"stepSize"
,
integrator
.
getStepSize
());
node
.
setDoubleProperty
(
"stepSize"
,
integrator
.
getStepSize
());
node
.
setDoubleProperty
(
"constraintTolerance"
,
integrator
.
getConstraintTolerance
());
node
.
setDoubleProperty
(
"constraintTolerance"
,
integrator
.
getConstraintTolerance
());
node
.
setDoubleProperty
(
"temperature"
,
integrator
.
getTemperature
());
node
.
setDoubleProperty
(
"temperature"
,
integrator
.
getTemperature
());
...
@@ -49,10 +49,10 @@ void BAOABLangevinIntegratorProxy::serialize(const void* object, SerializationNo
...
@@ -49,10 +49,10 @@ void BAOABLangevinIntegratorProxy::serialize(const void* object, SerializationNo
node
.
setIntProperty
(
"randomSeed"
,
integrator
.
getRandomNumberSeed
());
node
.
setIntProperty
(
"randomSeed"
,
integrator
.
getRandomNumberSeed
());
}
}
void
*
BAOAB
LangevinIntegratorProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
void
*
Langevin
Middle
IntegratorProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
throw
OpenMMException
(
"Unsupported version number"
);
BAOAB
LangevinIntegrator
*
integrator
=
new
BAOAB
LangevinIntegrator
(
node
.
getDoubleProperty
(
"temperature"
),
Langevin
Middle
Integrator
*
integrator
=
new
Langevin
Middle
Integrator
(
node
.
getDoubleProperty
(
"temperature"
),
node
.
getDoubleProperty
(
"friction"
),
node
.
getDoubleProperty
(
"stepSize"
));
node
.
getDoubleProperty
(
"friction"
),
node
.
getDoubleProperty
(
"stepSize"
));
integrator
->
setConstraintTolerance
(
node
.
getDoubleProperty
(
"constraintTolerance"
));
integrator
->
setConstraintTolerance
(
node
.
getDoubleProperty
(
"constraintTolerance"
));
integrator
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
integrator
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
...
...
serialization/src/NonbondedForceProxy.cpp
View file @
5a06df78
...
@@ -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-20
18
Stanford University and the Authors. *
* Portions copyright (c) 2010-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -42,7 +42,7 @@ NonbondedForceProxy::NonbondedForceProxy() : SerializationProxy("NonbondedForce"
...
@@ -42,7 +42,7 @@ NonbondedForceProxy::NonbondedForceProxy() : SerializationProxy("NonbondedForce"
}
}
void
NonbondedForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
void
NonbondedForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
3
);
node
.
setIntProperty
(
"version"
,
4
);
const
NonbondedForce
&
force
=
*
reinterpret_cast
<
const
NonbondedForce
*>
(
object
);
const
NonbondedForce
&
force
=
*
reinterpret_cast
<
const
NonbondedForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setIntProperty
(
"method"
,
(
int
)
force
.
getNonbondedMethod
());
node
.
setIntProperty
(
"method"
,
(
int
)
force
.
getNonbondedMethod
());
...
@@ -52,6 +52,7 @@ void NonbondedForceProxy::serialize(const void* object, SerializationNode& node)
...
@@ -52,6 +52,7 @@ void NonbondedForceProxy::serialize(const void* object, SerializationNode& node)
node
.
setDoubleProperty
(
"ewaldTolerance"
,
force
.
getEwaldErrorTolerance
());
node
.
setDoubleProperty
(
"ewaldTolerance"
,
force
.
getEwaldErrorTolerance
());
node
.
setDoubleProperty
(
"rfDielectric"
,
force
.
getReactionFieldDielectric
());
node
.
setDoubleProperty
(
"rfDielectric"
,
force
.
getReactionFieldDielectric
());
node
.
setIntProperty
(
"dispersionCorrection"
,
force
.
getUseDispersionCorrection
());
node
.
setIntProperty
(
"dispersionCorrection"
,
force
.
getUseDispersionCorrection
());
node
.
setIntProperty
(
"exceptionsUsePeriodic"
,
force
.
getExceptionsUsePeriodicBoundaryConditions
());
double
alpha
;
double
alpha
;
int
nx
,
ny
,
nz
;
int
nx
,
ny
,
nz
;
force
.
getPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
force
.
getPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
...
@@ -101,7 +102,7 @@ void NonbondedForceProxy::serialize(const void* object, SerializationNode& node)
...
@@ -101,7 +102,7 @@ void NonbondedForceProxy::serialize(const void* object, SerializationNode& node)
void
*
NonbondedForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
void
*
NonbondedForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
3
)
if
(
version
<
1
||
version
>
4
)
throw
OpenMMException
(
"Unsupported version number"
);
throw
OpenMMException
(
"Unsupported version number"
);
NonbondedForce
*
force
=
new
NonbondedForce
();
NonbondedForce
*
force
=
new
NonbondedForce
();
try
{
try
{
...
@@ -137,6 +138,8 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const {
...
@@ -137,6 +138,8 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const {
for
(
auto
&
offset
:
exceptionOffsets
.
getChildren
())
for
(
auto
&
offset
:
exceptionOffsets
.
getChildren
())
force
->
addExceptionParameterOffset
(
offset
.
getStringProperty
(
"parameter"
),
offset
.
getIntProperty
(
"exception"
),
offset
.
getDoubleProperty
(
"q"
),
offset
.
getDoubleProperty
(
"sig"
),
offset
.
getDoubleProperty
(
"eps"
));
force
->
addExceptionParameterOffset
(
offset
.
getStringProperty
(
"parameter"
),
offset
.
getIntProperty
(
"exception"
),
offset
.
getDoubleProperty
(
"q"
),
offset
.
getDoubleProperty
(
"sig"
),
offset
.
getDoubleProperty
(
"eps"
));
}
}
if
(
version
>=
4
)
force
->
setExceptionsUsePeriodicBoundaryConditions
(
node
.
getIntProperty
(
"exceptionsUsePeriodic"
));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
auto
&
particle
:
particles
.
getChildren
())
for
(
auto
&
particle
:
particles
.
getChildren
())
force
->
addParticle
(
particle
.
getDoubleProperty
(
"q"
),
particle
.
getDoubleProperty
(
"sig"
),
particle
.
getDoubleProperty
(
"eps"
));
force
->
addParticle
(
particle
.
getDoubleProperty
(
"q"
),
particle
.
getDoubleProperty
(
"sig"
),
particle
.
getDoubleProperty
(
"eps"
));
...
...
serialization/src/NoseHooverIntegratorProxy.cpp
0 → 100644
View file @
5a06df78
/* -------------------------------------------------------------------------- *
* 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: Andrew C. Simmonett, Andreas Krämer *
* 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/NoseHooverIntegratorProxy.h"
#include <vector>
#include <OpenMM.h>
using
namespace
std
;
using
namespace
OpenMM
;
NoseHooverIntegratorProxy
::
NoseHooverIntegratorProxy
()
:
SerializationProxy
(
"NoseHooverIntegrator"
)
{
}
void
NoseHooverIntegratorProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
NoseHooverIntegrator
&
integrator
=
*
reinterpret_cast
<
const
NoseHooverIntegrator
*>
(
object
);
node
.
setDoubleProperty
(
"stepSize"
,
integrator
.
getStepSize
());
node
.
setDoubleProperty
(
"constraintTolerance"
,
integrator
.
getConstraintTolerance
());
node
.
setDoubleProperty
(
"maximumPairDistance"
,
integrator
.
getMaximumPairDistance
());
node
.
setBoolProperty
(
"hasSubsystemThermostats"
,
integrator
.
hasSubsystemThermostats
());
if
(
integrator
.
hasSubsystemThermostats
())
{
// Serialize all thermostats separately
for
(
int
i
=
0
;
i
<
integrator
.
getNumThermostats
();
i
++
){
const
auto
&
chain
=
integrator
.
getThermostat
(
i
);
auto
&
chainNode
=
node
.
createChildNode
(
"Thermostat"
);
chainNode
.
setDoubleProperty
(
"temperature"
,
chain
.
getTemperature
());
chainNode
.
setDoubleProperty
(
"collisionFrequency"
,
chain
.
getCollisionFrequency
());
chainNode
.
setDoubleProperty
(
"relativeTemperature"
,
chain
.
getRelativeTemperature
());
chainNode
.
setDoubleProperty
(
"relativeCollisionFrequency"
,
chain
.
getRelativeCollisionFrequency
());
chainNode
.
setIntProperty
(
"chainLength"
,
chain
.
getChainLength
());
chainNode
.
setIntProperty
(
"numMTS"
,
chain
.
getNumMultiTimeSteps
());
chainNode
.
setIntProperty
(
"numYS"
,
chain
.
getNumYoshidaSuzukiTimeSteps
());
auto
&
particlesNode
=
chainNode
.
createChildNode
(
"ThermostatedAtoms"
);
for
(
int
particle
:
chain
.
getThermostatedAtoms
()){
particlesNode
.
createChildNode
(
"Particle"
).
setIntProperty
(
"index"
,
particle
);
}
auto
&
pairsNode
=
chainNode
.
createChildNode
(
"ThermostatedPairs"
);
for
(
auto
&
pair
:
chain
.
getThermostatedPairs
()){
auto
&
pairNode
=
pairsNode
.
createChildNode
(
"Pair"
);
pairNode
.
setIntProperty
(
"index1"
,
pair
.
first
);
pairNode
.
setIntProperty
(
"index2"
,
pair
.
second
);
}
}
}
else
{
// Serialize standard thermostat
node
.
setDoubleProperty
(
"temperature"
,
integrator
.
getTemperature
());
node
.
setDoubleProperty
(
"collisionFrequency"
,
integrator
.
getCollisionFrequency
());
node
.
setIntProperty
(
"chainLength"
,
integrator
.
getThermostat
().
getChainLength
());
node
.
setIntProperty
(
"numMTS"
,
integrator
.
getThermostat
().
getNumMultiTimeSteps
());
node
.
setIntProperty
(
"numYS"
,
integrator
.
getThermostat
().
getNumYoshidaSuzukiTimeSteps
());
}
}
void
*
NoseHooverIntegratorProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
NoseHooverIntegrator
*
integrator
;
if
(
node
.
getBoolProperty
(
"hasSubsystemThermostats"
)){
// deserialize all chains
integrator
=
new
NoseHooverIntegrator
(
node
.
getDoubleProperty
(
"stepSize"
));
for
(
auto
&
chainNode
:
node
.
getChildren
())
{
// particles
const
auto
&
particlesNode
=
chainNode
.
getChildNode
(
"ThermostatedAtoms"
);
vector
<
int
>
particles
;
for
(
auto
&
particleNode
:
particlesNode
.
getChildren
()){
particles
.
push_back
(
particleNode
.
getIntProperty
(
"index"
));
}
// pairs
const
auto
&
pairsNode
=
chainNode
.
getChildNode
(
"ThermostatedPairs"
);
vector
<
pair
<
int
,
int
>>
pairs
;
for
(
auto
&
pairNode
:
pairsNode
.
getChildren
()){
pairs
.
emplace_back
(
pairNode
.
getIntProperty
(
"index1"
),
pairNode
.
getIntProperty
(
"index2"
));
}
integrator
->
addSubsystemThermostat
(
particles
,
pairs
,
chainNode
.
getDoubleProperty
(
"temperature"
),
chainNode
.
getDoubleProperty
(
"collisionFrequency"
),
chainNode
.
getDoubleProperty
(
"relativeTemperature"
),
chainNode
.
getDoubleProperty
(
"relativeCollisionFrequency"
),
chainNode
.
getIntProperty
(
"chainLength"
),
chainNode
.
getIntProperty
(
"numMTS"
),
chainNode
.
getIntProperty
(
"numYS"
)
);
}
}
else
{
integrator
=
new
NoseHooverIntegrator
(
node
.
getDoubleProperty
(
"temperature"
),
node
.
getDoubleProperty
(
"collisionFrequency"
),
node
.
getDoubleProperty
(
"stepSize"
),
node
.
getIntProperty
(
"chainLength"
),
node
.
getIntProperty
(
"numMTS"
),
node
.
getIntProperty
(
"numYS"
)
);
}
integrator
->
setConstraintTolerance
(
node
.
getDoubleProperty
(
"constraintTolerance"
));
integrator
->
setMaximumPairDistance
(
node
.
getDoubleProperty
(
"maximumPairDistance"
));
return
integrator
;
}
serialization/src/SerializationProxyRegistration.cpp
View file @
5a06df78
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "openmm/AndersenThermostat.h"
#include "openmm/AndersenThermostat.h"
#include "openmm/BAOABLangevinIntegrator.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/CMAPTorsionForce.h"
#include "openmm/CMAPTorsionForce.h"
#include "openmm/CMMotionRemover.h"
#include "openmm/CMMotionRemover.h"
...
@@ -52,10 +51,12 @@
...
@@ -52,10 +51,12 @@
#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/LangevinMiddleIntegrator.h"
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include "openmm/MonteCarloBarostat.h"
#include "openmm/MonteCarloBarostat.h"
#include "openmm/MonteCarloMembraneBarostat.h"
#include "openmm/MonteCarloMembraneBarostat.h"
#include "openmm/NonbondedForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/NoseHooverIntegrator.h"
#include "openmm/PeriodicTorsionForce.h"
#include "openmm/PeriodicTorsionForce.h"
#include "openmm/RBTorsionForce.h"
#include "openmm/RBTorsionForce.h"
#include "openmm/RMSDForce.h"
#include "openmm/RMSDForce.h"
...
@@ -66,7 +67,6 @@
...
@@ -66,7 +67,6 @@
#include "openmm/VerletIntegrator.h"
#include "openmm/VerletIntegrator.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/BAOABLangevinIntegratorProxy.h"
#include "openmm/serialization/BrownianIntegratorProxy.h"
#include "openmm/serialization/BrownianIntegratorProxy.h"
#include "openmm/serialization/AndersenThermostatProxy.h"
#include "openmm/serialization/AndersenThermostatProxy.h"
#include "openmm/serialization/CMAPTorsionForceProxy.h"
#include "openmm/serialization/CMAPTorsionForceProxy.h"
...
@@ -89,10 +89,12 @@
...
@@ -89,10 +89,12 @@
#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/LangevinMiddleIntegratorProxy.h"
#include "openmm/serialization/MonteCarloAnisotropicBarostatProxy.h"
#include "openmm/serialization/MonteCarloAnisotropicBarostatProxy.h"
#include "openmm/serialization/MonteCarloBarostatProxy.h"
#include "openmm/serialization/MonteCarloBarostatProxy.h"
#include "openmm/serialization/MonteCarloMembraneBarostatProxy.h"
#include "openmm/serialization/MonteCarloMembraneBarostatProxy.h"
#include "openmm/serialization/NonbondedForceProxy.h"
#include "openmm/serialization/NonbondedForceProxy.h"
#include "openmm/serialization/NoseHooverIntegratorProxy.h"
#include "openmm/serialization/PeriodicTorsionForceProxy.h"
#include "openmm/serialization/PeriodicTorsionForceProxy.h"
#include "openmm/serialization/RBTorsionForceProxy.h"
#include "openmm/serialization/RBTorsionForceProxy.h"
#include "openmm/serialization/RMSDForceProxy.h"
#include "openmm/serialization/RMSDForceProxy.h"
...
@@ -119,7 +121,6 @@ using namespace OpenMM;
...
@@ -119,7 +121,6 @@ using namespace OpenMM;
extern
"C"
void
registerSerializationProxies
()
{
extern
"C"
void
registerSerializationProxies
()
{
SerializationProxy
::
registerProxy
(
typeid
(
AndersenThermostat
),
new
AndersenThermostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
AndersenThermostat
),
new
AndersenThermostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
BAOABLangevinIntegrator
),
new
BAOABLangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
BrownianIntegrator
),
new
BrownianIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
BrownianIntegrator
),
new
BrownianIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CMAPTorsionForce
),
new
CMAPTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CMAPTorsionForce
),
new
CMAPTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CMMotionRemover
),
new
CMMotionRemoverProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CMMotionRemover
),
new
CMMotionRemoverProxy
());
...
@@ -147,10 +148,12 @@ extern "C" void registerSerializationProxies() {
...
@@ -147,10 +148,12 @@ 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
(
LangevinMiddleIntegrator
),
new
LangevinMiddleIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
MonteCarloAnisotropicBarostat
),
new
MonteCarloAnisotropicBarostatProxy
());
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
(
MonteCarloMembraneBarostat
),
new
MonteCarloMembraneBarostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
NonbondedForce
),
new
NonbondedForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
NonbondedForce
),
new
NonbondedForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
NoseHooverIntegrator
),
new
NoseHooverIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
PeriodicTorsionForce
),
new
PeriodicTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
PeriodicTorsionForce
),
new
PeriodicTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RBTorsionForce
),
new
RBTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RBTorsionForce
),
new
RBTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RMSDForce
),
new
RMSDForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RMSDForce
),
new
RMSDForceProxy
());
...
@@ -159,4 +162,4 @@ extern "C" void registerSerializationProxies() {
...
@@ -159,4 +162,4 @@ extern "C" void registerSerializationProxies() {
SerializationProxy
::
registerProxy
(
typeid
(
VariableLangevinIntegrator
),
new
VariableLangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VariableLangevinIntegrator
),
new
VariableLangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VariableVerletIntegrator
),
new
VariableVerletIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VariableVerletIntegrator
),
new
VariableVerletIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VerletIntegrator
),
new
VerletIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VerletIntegrator
),
new
VerletIntegratorProxy
());
}
}
\ No newline at end of file
serialization/tests/TestSerializeIntegrator.cpp
View file @
5a06df78
...
@@ -31,11 +31,11 @@
...
@@ -31,11 +31,11 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/BAOABLangevinIntegrator.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/CompoundIntegrator.h"
#include "openmm/CompoundIntegrator.h"
#include "openmm/CustomIntegrator.h"
#include "openmm/CustomIntegrator.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/LangevinMiddleIntegrator.h"
#include "openmm/VariableLangevinIntegrator.h"
#include "openmm/VariableLangevinIntegrator.h"
#include "openmm/VariableVerletIntegrator.h"
#include "openmm/VariableVerletIntegrator.h"
#include "openmm/VerletIntegrator.h"
#include "openmm/VerletIntegrator.h"
...
@@ -75,11 +75,11 @@ void testSerializeLangevinIntegrator() {
...
@@ -75,11 +75,11 @@ void testSerializeLangevinIntegrator() {
delete
intg2
;
delete
intg2
;
}
}
void
testSerialize
BAOAB
LangevinIntegrator
()
{
void
testSerializeLangevin
Middle
Integrator
()
{
BAOAB
LangevinIntegrator
*
intg
=
new
BAOAB
LangevinIntegrator
(
372.4
,
1.234
,
0.0018
);
Langevin
Middle
Integrator
*
intg
=
new
Langevin
Middle
Integrator
(
372.4
,
1.234
,
0.0018
);
stringstream
ss
;
stringstream
ss
;
XmlSerializer
::
serialize
<
Integrator
>
(
intg
,
"
BAOAB
LangevinIntegrator"
,
ss
);
XmlSerializer
::
serialize
<
Integrator
>
(
intg
,
"Langevin
Middle
Integrator"
,
ss
);
BAOAB
LangevinIntegrator
*
intg2
=
dynamic_cast
<
BAOAB
LangevinIntegrator
*>
(
XmlSerializer
::
deserialize
<
Integrator
>
(
ss
));
Langevin
Middle
Integrator
*
intg2
=
dynamic_cast
<
Langevin
Middle
Integrator
*>
(
XmlSerializer
::
deserialize
<
Integrator
>
(
ss
));
ASSERT_EQUAL
(
intg
->
getConstraintTolerance
(),
intg2
->
getConstraintTolerance
());
ASSERT_EQUAL
(
intg
->
getConstraintTolerance
(),
intg2
->
getConstraintTolerance
());
ASSERT_EQUAL
(
intg
->
getStepSize
(),
intg2
->
getStepSize
());
ASSERT_EQUAL
(
intg
->
getStepSize
(),
intg2
->
getStepSize
());
ASSERT_EQUAL
(
intg
->
getTemperature
(),
intg2
->
getTemperature
());
ASSERT_EQUAL
(
intg
->
getTemperature
(),
intg2
->
getTemperature
());
...
@@ -259,7 +259,7 @@ int main() {
...
@@ -259,7 +259,7 @@ int main() {
testSerializeVariableLangevinIntegrator
();
testSerializeVariableLangevinIntegrator
();
testSerializeVariableVerletIntegrator
();
testSerializeVariableVerletIntegrator
();
testSerializeLangevinIntegrator
();
testSerializeLangevinIntegrator
();
testSerialize
BAOAB
LangevinIntegrator
();
testSerializeLangevin
Middle
Integrator
();
testSerializeCompoundIntegrator
();
testSerializeCompoundIntegrator
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
...
...
serialization/tests/TestSerializeNonbondedForce.cpp
View file @
5a06df78
...
@@ -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-20
18
Stanford University and the Authors. *
* Portions copyright (c) 2010-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -50,6 +50,7 @@ void testSerialization() {
...
@@ -50,6 +50,7 @@ void testSerialization() {
force
.
setEwaldErrorTolerance
(
1e-3
);
force
.
setEwaldErrorTolerance
(
1e-3
);
force
.
setReactionFieldDielectric
(
50.0
);
force
.
setReactionFieldDielectric
(
50.0
);
force
.
setUseDispersionCorrection
(
false
);
force
.
setUseDispersionCorrection
(
false
);
force
.
setExceptionsUsePeriodicBoundaryConditions
(
true
);
double
alpha
=
0.5
;
double
alpha
=
0.5
;
int
nx
=
3
,
ny
=
5
,
nz
=
7
;
int
nx
=
3
,
ny
=
5
,
nz
=
7
;
force
.
setPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
force
.
setPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
...
@@ -83,6 +84,7 @@ void testSerialization() {
...
@@ -83,6 +84,7 @@ void testSerialization() {
ASSERT_EQUAL
(
force
.
getEwaldErrorTolerance
(),
force2
.
getEwaldErrorTolerance
());
ASSERT_EQUAL
(
force
.
getEwaldErrorTolerance
(),
force2
.
getEwaldErrorTolerance
());
ASSERT_EQUAL
(
force
.
getReactionFieldDielectric
(),
force2
.
getReactionFieldDielectric
());
ASSERT_EQUAL
(
force
.
getReactionFieldDielectric
(),
force2
.
getReactionFieldDielectric
());
ASSERT_EQUAL
(
force
.
getUseDispersionCorrection
(),
force2
.
getUseDispersionCorrection
());
ASSERT_EQUAL
(
force
.
getUseDispersionCorrection
(),
force2
.
getUseDispersionCorrection
());
ASSERT_EQUAL
(
force
.
getExceptionsUsePeriodicBoundaryConditions
(),
force2
.
getExceptionsUsePeriodicBoundaryConditions
());
ASSERT_EQUAL
(
force
.
getNumParticles
(),
force2
.
getNumParticles
());
ASSERT_EQUAL
(
force
.
getNumParticles
(),
force2
.
getNumParticles
());
ASSERT_EQUAL
(
force
.
getNumExceptions
(),
force2
.
getNumExceptions
());
ASSERT_EQUAL
(
force
.
getNumExceptions
(),
force2
.
getNumExceptions
());
ASSERT_EQUAL
(
force
.
getNumGlobalParameters
(),
force2
.
getNumGlobalParameters
());
ASSERT_EQUAL
(
force
.
getNumGlobalParameters
(),
force2
.
getNumGlobalParameters
());
...
...
serialization/tests/TestSerializeNoseHooverIntegrator.cpp
0 → 100644
View file @
5a06df78
/* -------------------------------------------------------------------------- *
* 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: Andrew C. Simmonett and Andreas Kraemer
* 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/NoseHooverIntegrator.h"
#include "openmm/serialization/XmlSerializer.h"
#include "openmm/System.h"
#include "openmm/Context.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
void
assertIntegratorsEqual
(
const
NoseHooverIntegrator
&
integrator1
,
const
NoseHooverIntegrator
&
integrator2
){
ASSERT_EQUAL
(
integrator1
.
getStepSize
(),
integrator2
.
getStepSize
());
ASSERT_EQUAL
(
integrator1
.
getConstraintTolerance
(),
integrator2
.
getConstraintTolerance
());
ASSERT_EQUAL
(
integrator1
.
getMaximumPairDistance
(),
integrator2
.
getMaximumPairDistance
());
ASSERT_EQUAL
(
integrator1
.
getNumThermostats
(),
integrator2
.
getNumThermostats
());
for
(
int
i
=
0
;
i
<
integrator1
.
getNumThermostats
();
i
++
)
{
const
auto
&
thermostat1
=
integrator1
.
getThermostat
(
i
);
const
auto
&
thermostat2
=
integrator2
.
getThermostat
(
i
);
ASSERT_EQUAL
(
thermostat1
.
getTemperature
(),
thermostat2
.
getTemperature
());
ASSERT_EQUAL
(
thermostat1
.
getCollisionFrequency
(),
thermostat2
.
getCollisionFrequency
());
ASSERT_EQUAL
(
thermostat1
.
getRelativeTemperature
(),
thermostat2
.
getRelativeTemperature
());
ASSERT_EQUAL
(
thermostat1
.
getRelativeCollisionFrequency
(),
thermostat2
.
getRelativeCollisionFrequency
());
ASSERT_EQUAL
(
thermostat1
.
getChainLength
(),
thermostat2
.
getChainLength
());
ASSERT_EQUAL
(
thermostat1
.
getNumMultiTimeSteps
(),
thermostat2
.
getNumMultiTimeSteps
());
ASSERT_EQUAL
(
thermostat1
.
getNumYoshidaSuzukiTimeSteps
(),
thermostat2
.
getNumYoshidaSuzukiTimeSteps
());
ASSERT_EQUAL
(
thermostat1
.
getChainID
(),
thermostat2
.
getChainID
());
const
auto
&
thermostat1Atoms
=
thermostat1
.
getThermostatedAtoms
();
const
auto
&
thermostat2Atoms
=
thermostat2
.
getThermostatedAtoms
();
ASSERT_EQUAL
(
thermostat1Atoms
.
size
(),
thermostat2Atoms
.
size
());
for
(
int
j
=
0
;
j
<
thermostat1Atoms
.
size
();
++
j
)
{
ASSERT_EQUAL
(
thermostat1Atoms
[
j
],
thermostat2Atoms
[
j
]);
}
const
auto
&
thermostat1Pairs
=
thermostat1
.
getThermostatedPairs
();
const
auto
&
thermostat2Pairs
=
thermostat2
.
getThermostatedPairs
();
ASSERT_EQUAL
(
thermostat1Pairs
.
size
(),
thermostat2Pairs
.
size
());
for
(
int
j
=
0
;
j
<
thermostat1Pairs
.
size
();
++
j
)
{
ASSERT_EQUAL
(
thermostat1Pairs
[
j
].
first
,
thermostat2Pairs
[
j
].
first
);
ASSERT_EQUAL
(
thermostat1Pairs
[
j
].
second
,
thermostat2Pairs
[
j
].
second
);
}
}
}
void
testSerialization
()
{
// Check with custom subsystem thermostats
NoseHooverIntegrator
integrator_sub
(
0.0006
);
integrator_sub
.
setConstraintTolerance
(
0.0404
);
integrator_sub
.
setMaximumPairDistance
(
0.0051
);
integrator_sub
.
addSubsystemThermostat
(
{
0
,
1
,
2
,
3
,
4
,
7
},
{{
0
,
7
}},
301.1
,
1.1
,
1.2
,
1.3
,
9
,
2
,
5
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
NoseHooverIntegrator
>
(
&
integrator_sub
,
"Integrator"
,
buffer
);
NoseHooverIntegrator
*
copy
=
XmlSerializer
::
deserialize
<
NoseHooverIntegrator
>
(
buffer
);
assertIntegratorsEqual
(
integrator_sub
,
*
copy
);
// Check with default constructor
System
system
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
system
.
addParticle
(
1.0
);
NoseHooverIntegrator
integrator
(
331
,
1.1
,
0.004
,
5
,
5
,
5
);
Context
context
(
system
,
integrator
);
// Serialize and then deserialize it.
stringstream
buffer2
;
XmlSerializer
::
serialize
<
NoseHooverIntegrator
>
(
&
integrator
,
"Integrator"
,
buffer2
);
copy
=
XmlSerializer
::
deserialize
<
NoseHooverIntegrator
>
(
buffer2
);
// for thermostats that apply to the whole system, the particles are not serialized ...
ASSERT_EQUAL
(
copy
->
getThermostat
(
0
).
getThermostatedAtoms
().
size
(),
0
);
// ... but assigned when creating a context.
Context
context2
(
system
,
*
copy
);
assertIntegratorsEqual
(
integrator
,
*
copy
);
}
int
main
()
{
try
{
testSerialization
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
Prev
1
…
11
12
13
14
15
16
17
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