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
eb9f735a
Commit
eb9f735a
authored
Mar 12, 2014
by
leeping
Browse files
Merge branch 'master' of github.com:leeping/openmm
parents
4362d539
708c4246
Changes
84
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
846 additions
and
101 deletions
+846
-101
serialization/include/openmm/serialization/TabulatedFunctionProxies.h
...n/include/openmm/serialization/TabulatedFunctionProxies.h
+108
-0
serialization/src/CustomCompoundBondForceProxy.cpp
serialization/src/CustomCompoundBondForceProxy.cpp
+19
-0
serialization/src/CustomGBForceProxy.cpp
serialization/src/CustomGBForceProxy.cpp
+14
-15
serialization/src/CustomHbondForceProxy.cpp
serialization/src/CustomHbondForceProxy.cpp
+14
-15
serialization/src/CustomNonbondedForceProxy.cpp
serialization/src/CustomNonbondedForceProxy.cpp
+14
-15
serialization/src/SerializationProxyRegistration.cpp
serialization/src/SerializationProxyRegistration.cpp
+19
-14
serialization/src/TabulatedFunctionProxies.cpp
serialization/src/TabulatedFunctionProxies.cpp
+208
-0
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
+17
-0
serialization/tests/TestSerializeCustomGBForce.cpp
serialization/tests/TestSerializeCustomGBForce.cpp
+6
-10
serialization/tests/TestSerializeCustomHbondForce.cpp
serialization/tests/TestSerializeCustomHbondForce.cpp
+6
-10
serialization/tests/TestSerializeCustomNonbondedForce.cpp
serialization/tests/TestSerializeCustomNonbondedForce.cpp
+5
-6
serialization/tests/TestSerializeTabulatedFunctions.cpp
serialization/tests/TestSerializeTabulatedFunctions.cpp
+230
-0
tests/TestSplineFitter.cpp
tests/TestSplineFitter.cpp
+81
-0
wrappers/generateWrappers.py
wrappers/generateWrappers.py
+7
-5
wrappers/python/CMakeLists.txt
wrappers/python/CMakeLists.txt
+1
-0
wrappers/python/simtk/openmm/app/amberprmtopfile.py
wrappers/python/simtk/openmm/app/amberprmtopfile.py
+34
-6
wrappers/python/simtk/openmm/app/data/absinth.xml
wrappers/python/simtk/openmm/app/data/absinth.xml
+1
-1
wrappers/python/simtk/openmm/app/data/iamoeba.xml
wrappers/python/simtk/openmm/app/data/iamoeba.xml
+37
-0
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+24
-3
wrappers/python/simtk/openmm/app/internal/amber_file_parser.py
...ers/python/simtk/openmm/app/internal/amber_file_parser.py
+1
-1
No files found.
serialization/include/openmm/serialization/TabulatedFunctionProxies.h
0 → 100644
View file @
eb9f735a
#ifndef OPENMM_TABULATEDFUNCTION_PROXIES_H_
#define OPENMM_TABULATEDFUNCTION_PROXIES_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/internal/windowsExport.h"
#include "openmm/serialization/SerializationProxy.h"
namespace
OpenMM
{
/**
* This is a proxy for serializing Continuous1DFunction objects.
*/
class
OPENMM_EXPORT
Continuous1DFunctionProxy
:
public
SerializationProxy
{
public:
Continuous1DFunctionProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
/**
* This is a proxy for serializing Continuous2DFunction objects.
*/
class
OPENMM_EXPORT
Continuous2DFunctionProxy
:
public
SerializationProxy
{
public:
Continuous2DFunctionProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
/**
* This is a proxy for serializing Continuous3DFunction objects.
*/
class
OPENMM_EXPORT
Continuous3DFunctionProxy
:
public
SerializationProxy
{
public:
Continuous3DFunctionProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
/**
* This is a proxy for serializing Discrete1DFunction objects.
*/
class
OPENMM_EXPORT
Discrete1DFunctionProxy
:
public
SerializationProxy
{
public:
Discrete1DFunctionProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
/**
* This is a proxy for serializing Discrete2DFunction objects.
*/
class
OPENMM_EXPORT
Discrete2DFunctionProxy
:
public
SerializationProxy
{
public:
Discrete2DFunctionProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
/**
* This is a proxy for serializing Discrete3DFunction objects.
*/
class
OPENMM_EXPORT
Discrete3DFunctionProxy
:
public
SerializationProxy
{
public:
Discrete3DFunctionProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_TABULATEDFUNCTION_PROXIES_H_*/
serialization/src/CustomCompoundBondForceProxy.cpp
View file @
eb9f735a
...
...
@@ -73,6 +73,9 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo
node
.
setDoubleProperty
(
key
.
str
(),
params
[
j
]);
}
}
SerializationNode
&
functions
=
node
.
createChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
functions
.
createChildNode
(
"Function"
,
&
force
.
getTabulatedFunction
(
i
)).
setStringProperty
(
"name"
,
force
.
getTabulatedFunctionName
(
i
));
}
void
*
CustomCompoundBondForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -110,6 +113,22 @@ void* CustomCompoundBondForceProxy::deserialize(const SerializationNode& node) c
}
force
->
addBond
(
particles
,
params
);
}
const
SerializationNode
&
functions
=
node
.
getChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
function
=
functions
.
getChildren
()[
i
];
if
(
function
.
hasProperty
(
"type"
))
{
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
function
.
decodeObject
<
TabulatedFunction
>
());
}
else
{
// This is an old file created before TabulatedFunction existed.
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
new
Continuous1DFunction
(
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)));
}
}
return
force
;
}
catch
(...)
{
...
...
serialization/src/CustomGBForceProxy.cpp
View file @
eb9f735a
...
...
@@ -87,16 +87,8 @@ void CustomGBForceProxy::serialize(const void* object, SerializationNode& node)
exclusions
.
createChildNode
(
"Exclusion"
).
setIntProperty
(
"p1"
,
particle1
).
setIntProperty
(
"p2"
,
particle2
);
}
SerializationNode
&
functions
=
node
.
createChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumFunctions
();
i
++
)
{
string
name
;
vector
<
double
>
values
;
double
min
,
max
;
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
functions
.
createChildNode
(
"Function"
,
&
force
.
getTabulatedFunction
(
i
)).
setStringProperty
(
"name"
,
force
.
getTabulatedFunctionName
(
i
));
}
void
*
CustomGBForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -147,11 +139,18 @@ void* CustomGBForceProxy::deserialize(const SerializationNode& node) const {
const
SerializationNode
&
functions
=
node
.
getChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
function
=
functions
.
getChildren
()[
i
];
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
));
if
(
function
.
hasProperty
(
"type"
))
{
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
function
.
decodeObject
<
TabulatedFunction
>
());
}
else
{
// This is an old file created before TabulatedFunction existed.
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
new
Continuous1DFunction
(
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)));
}
}
return
force
;
}
...
...
serialization/src/CustomHbondForceProxy.cpp
View file @
eb9f735a
...
...
@@ -92,16 +92,8 @@ void CustomHbondForceProxy::serialize(const void* object, SerializationNode& nod
exclusions
.
createChildNode
(
"Exclusion"
).
setIntProperty
(
"donor"
,
donor
).
setIntProperty
(
"acceptor"
,
acceptor
);
}
SerializationNode
&
functions
=
node
.
createChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumFunctions
();
i
++
)
{
string
name
;
vector
<
double
>
values
;
double
min
,
max
;
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
functions
.
createChildNode
(
"Function"
,
&
force
.
getTabulatedFunction
(
i
)).
setStringProperty
(
"name"
,
force
.
getTabulatedFunctionName
(
i
));
}
void
*
CustomHbondForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -159,11 +151,18 @@ void* CustomHbondForceProxy::deserialize(const SerializationNode& node) const {
const
SerializationNode
&
functions
=
node
.
getChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
function
=
functions
.
getChildren
()[
i
];
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
));
if
(
function
.
hasProperty
(
"type"
))
{
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
function
.
decodeObject
<
TabulatedFunction
>
());
}
else
{
// This is an old file created before TabulatedFunction existed.
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
new
Continuous1DFunction
(
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)));
}
}
return
force
;
}
...
...
serialization/src/CustomNonbondedForceProxy.cpp
View file @
eb9f735a
...
...
@@ -74,16 +74,8 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode&
exclusions
.
createChildNode
(
"Exclusion"
).
setIntProperty
(
"p1"
,
particle1
).
setIntProperty
(
"p2"
,
particle2
);
}
SerializationNode
&
functions
=
node
.
createChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
force
.
getNumFunctions
();
i
++
)
{
string
name
;
vector
<
double
>
values
;
double
min
,
max
;
force
.
getFunctionParameters
(
i
,
name
,
values
,
min
,
max
);
SerializationNode
&
node
=
functions
.
createChildNode
(
"Function"
).
setStringProperty
(
"name"
,
name
).
setDoubleProperty
(
"min"
,
min
).
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
functions
.
createChildNode
(
"Function"
,
&
force
.
getTabulatedFunction
(
i
)).
setStringProperty
(
"name"
,
force
.
getTabulatedFunctionName
(
i
));
}
void
*
CustomNonbondedForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -124,11 +116,18 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
const
SerializationNode
&
functions
=
node
.
getChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
function
=
functions
.
getChildren
()[
i
];
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addFunction
(
function
.
getStringProperty
(
"name"
),
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
));
if
(
function
.
hasProperty
(
"type"
))
{
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
function
.
decodeObject
<
TabulatedFunction
>
());
}
else
{
// This is an old file created before TabulatedFunction existed.
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
new
Continuous1DFunction
(
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)));
}
}
return
force
;
}
...
...
serialization/src/SerializationProxyRegistration.cpp
View file @
eb9f735a
...
...
@@ -30,6 +30,7 @@
* -------------------------------------------------------------------------- */
#include "openmm/AndersenThermostat.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/CMAPTorsionForce.h"
#include "openmm/CMMotionRemover.h"
#include "openmm/CustomAngleForce.h"
...
...
@@ -38,26 +39,26 @@
#include "openmm/CustomExternalForce.h"
#include "openmm/CustomGBForce.h"
#include "openmm/CustomHbondForce.h"
#include "openmm/CustomIntegrator.h"
#include "openmm/CustomNonbondedForce.h"
#include "openmm/CustomTorsionForce.h"
#include "openmm/HarmonicAngleForce.h"
#include "openmm/GBSAOBCForce.h"
#include "openmm/GBVIForce.h"
#include "openmm/HarmonicAngleForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/MonteCarloBarostat.h"
#include "openmm/NonbondedForce.h"
#include "openmm/PeriodicTorsionForce.h"
#include "openmm/RBTorsionForce.h"
#include "openmm/System.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/CustomIntegrator.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/TabulatedFunction.h"
#include "openmm/VariableLangevinIntegrator.h"
#include "openmm/VariableVerletIntegrator.h"
#include "openmm/VerletIntegrator.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/BrownianIntegratorProxy.h"
#include "openmm/serialization/AndersenThermostatProxy.h"
#include "openmm/serialization/CMAPTorsionForceProxy.h"
#include "openmm/serialization/CMMotionRemoverProxy.h"
...
...
@@ -67,23 +68,21 @@
#include "openmm/serialization/CustomExternalForceProxy.h"
#include "openmm/serialization/CustomGBForceProxy.h"
#include "openmm/serialization/CustomHbondForceProxy.h"
#include "openmm/serialization/CustomIntegratorProxy.h"
#include "openmm/serialization/CustomNonbondedForceProxy.h"
#include "openmm/serialization/CustomTorsionForceProxy.h"
#include "openmm/serialization/GBSAOBCForceProxy.h"
#include "openmm/serialization/GBVIForceProxy.h"
#include "openmm/serialization/HarmonicAngleForceProxy.h"
#include "openmm/serialization/HarmonicBondForceProxy.h"
#include "openmm/serialization/LangevinIntegratorProxy.h"
#include "openmm/serialization/MonteCarloBarostatProxy.h"
#include "openmm/serialization/NonbondedForceProxy.h"
#include "openmm/serialization/PeriodicTorsionForceProxy.h"
#include "openmm/serialization/RBTorsionForceProxy.h"
#include "openmm/serialization/SystemProxy.h"
#include "openmm/serialization/StateProxy.h"
#include "openmm/serialization/BrownianIntegratorProxy.h"
#include "openmm/serialization/CustomIntegratorProxy.h"
#include "openmm/serialization/LangevinIntegratorProxy.h"
#include "openmm/serialization/SystemProxy.h"
#include "openmm/serialization/TabulatedFunctionProxies.h"
#include "openmm/serialization/VariableLangevinIntegratorProxy.h"
#include "openmm/serialization/VariableVerletIntegratorProxy.h"
#include "openmm/serialization/VerletIntegratorProxy.h"
...
...
@@ -104,29 +103,35 @@ using namespace OpenMM;
extern
"C"
void
registerSerializationProxies
()
{
SerializationProxy
::
registerProxy
(
typeid
(
AndersenThermostat
),
new
AndersenThermostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
BrownianIntegrator
),
new
BrownianIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CMAPTorsionForce
),
new
CMAPTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CMMotionRemover
),
new
CMMotionRemoverProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
Continuous1DFunction
),
new
Continuous1DFunctionProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
Continuous2DFunction
),
new
Continuous2DFunctionProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
Continuous3DFunction
),
new
Continuous3DFunctionProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomAngleForce
),
new
CustomAngleForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomBondForce
),
new
CustomBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomCompoundBondForce
),
new
CustomCompoundBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomExternalForce
),
new
CustomExternalForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomGBForce
),
new
CustomGBForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomHbondForce
),
new
CustomHbondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomIntegrator
),
new
CustomIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomNonbondedForce
),
new
CustomNonbondedForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomTorsionForce
),
new
CustomTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
Discrete1DFunction
),
new
Discrete1DFunctionProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
Discrete2DFunction
),
new
Discrete2DFunctionProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
Discrete3DFunction
),
new
Discrete3DFunctionProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
GBSAOBCForce
),
new
GBSAOBCForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
GBVIForce
),
new
GBVIForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicAngleForce
),
new
HarmonicAngleForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
HarmonicBondForce
),
new
HarmonicBondForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
LangevinIntegrator
),
new
LangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
MonteCarloBarostat
),
new
MonteCarloBarostatProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
NonbondedForce
),
new
NonbondedForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
PeriodicTorsionForce
),
new
PeriodicTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
RBTorsionForce
),
new
RBTorsionForceProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
System
),
new
SystemProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
State
),
new
StateProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
BrownianIntegrator
),
new
BrownianIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
CustomIntegrator
),
new
CustomIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
LangevinIntegrator
),
new
LangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VariableLangevinIntegrator
),
new
VariableLangevinIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VariableVerletIntegrator
),
new
VariableVerletIntegratorProxy
());
SerializationProxy
::
registerProxy
(
typeid
(
VerletIntegrator
),
new
VerletIntegratorProxy
());
...
...
serialization/src/TabulatedFunctionProxies.cpp
0 → 100644
View file @
eb9f735a
/* -------------------------------------------------------------------------- *
* 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) 2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/TabulatedFunctionProxies.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/TabulatedFunction.h"
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
Continuous1DFunctionProxy
::
Continuous1DFunctionProxy
()
:
SerializationProxy
(
"Continuous1DFunction"
)
{
}
void
Continuous1DFunctionProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
Continuous1DFunction
&
function
=
*
reinterpret_cast
<
const
Continuous1DFunction
*>
(
object
);
double
min
,
max
;
vector
<
double
>
values
;
function
.
getFunctionParameters
(
values
,
min
,
max
);
node
.
setDoubleProperty
(
"min"
,
min
);
node
.
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
void
*
Continuous1DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
return
new
Continuous1DFunction
(
values
,
node
.
getDoubleProperty
(
"min"
),
node
.
getDoubleProperty
(
"max"
));
}
Continuous2DFunctionProxy
::
Continuous2DFunctionProxy
()
:
SerializationProxy
(
"Continuous2DFunction"
)
{
}
void
Continuous2DFunctionProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
Continuous2DFunction
&
function
=
*
reinterpret_cast
<
const
Continuous2DFunction
*>
(
object
);
int
xsize
,
ysize
;
double
xmin
,
xmax
,
ymin
,
ymax
;
vector
<
double
>
values
;
function
.
getFunctionParameters
(
xsize
,
ysize
,
values
,
xmin
,
xmax
,
ymin
,
ymax
);
node
.
setDoubleProperty
(
"xsize"
,
xsize
);
node
.
setDoubleProperty
(
"ysize"
,
ysize
);
node
.
setDoubleProperty
(
"xmin"
,
xmin
);
node
.
setDoubleProperty
(
"xmax"
,
xmax
);
node
.
setDoubleProperty
(
"ymin"
,
ymin
);
node
.
setDoubleProperty
(
"ymax"
,
ymax
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
void
*
Continuous2DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
return
new
Continuous2DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
values
,
node
.
getDoubleProperty
(
"xmin"
),
node
.
getDoubleProperty
(
"xmax"
),
node
.
getDoubleProperty
(
"ymin"
),
node
.
getDoubleProperty
(
"ymax"
));
}
Continuous3DFunctionProxy
::
Continuous3DFunctionProxy
()
:
SerializationProxy
(
"Continuous3DFunction"
)
{
}
void
Continuous3DFunctionProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
Continuous3DFunction
&
function
=
*
reinterpret_cast
<
const
Continuous3DFunction
*>
(
object
);
int
xsize
,
ysize
,
zsize
;
double
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
;
vector
<
double
>
values
;
function
.
getFunctionParameters
(
xsize
,
ysize
,
zsize
,
values
,
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
);
node
.
setDoubleProperty
(
"xsize"
,
xsize
);
node
.
setDoubleProperty
(
"ysize"
,
ysize
);
node
.
setDoubleProperty
(
"zsize"
,
zsize
);
node
.
setDoubleProperty
(
"xmin"
,
xmin
);
node
.
setDoubleProperty
(
"xmax"
,
xmax
);
node
.
setDoubleProperty
(
"ymin"
,
ymin
);
node
.
setDoubleProperty
(
"ymax"
,
ymax
);
node
.
setDoubleProperty
(
"zmin"
,
zmin
);
node
.
setDoubleProperty
(
"zmax"
,
zmax
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
void
*
Continuous3DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
return
new
Continuous3DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
node
.
getIntProperty
(
"zsize"
),
values
,
node
.
getDoubleProperty
(
"xmin"
),
node
.
getDoubleProperty
(
"xmax"
),
node
.
getDoubleProperty
(
"ymin"
),
node
.
getDoubleProperty
(
"ymax"
),
node
.
getDoubleProperty
(
"zmin"
),
node
.
getDoubleProperty
(
"zmax"
));
}
Discrete1DFunctionProxy
::
Discrete1DFunctionProxy
()
:
SerializationProxy
(
"Discrete1DFunction"
)
{
}
void
Discrete1DFunctionProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
Discrete1DFunction
&
function
=
*
reinterpret_cast
<
const
Discrete1DFunction
*>
(
object
);
vector
<
double
>
values
;
function
.
getFunctionParameters
(
values
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
void
*
Discrete1DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
return
new
Discrete1DFunction
(
values
);
}
Discrete2DFunctionProxy
::
Discrete2DFunctionProxy
()
:
SerializationProxy
(
"Discrete2DFunction"
)
{
}
void
Discrete2DFunctionProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
Discrete2DFunction
&
function
=
*
reinterpret_cast
<
const
Discrete2DFunction
*>
(
object
);
int
xsize
,
ysize
;
vector
<
double
>
values
;
function
.
getFunctionParameters
(
xsize
,
ysize
,
values
);
node
.
setDoubleProperty
(
"xsize"
,
xsize
);
node
.
setDoubleProperty
(
"ysize"
,
ysize
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
void
*
Discrete2DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
return
new
Discrete2DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
values
);
}
Discrete3DFunctionProxy
::
Discrete3DFunctionProxy
()
:
SerializationProxy
(
"Discrete3DFunction"
)
{
}
void
Discrete3DFunctionProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
Discrete3DFunction
&
function
=
*
reinterpret_cast
<
const
Discrete3DFunction
*>
(
object
);
int
xsize
,
ysize
,
zsize
;
vector
<
double
>
values
;
function
.
getFunctionParameters
(
xsize
,
ysize
,
zsize
,
values
);
node
.
setDoubleProperty
(
"xsize"
,
xsize
);
node
.
setDoubleProperty
(
"ysize"
,
ysize
);
node
.
setDoubleProperty
(
"zsize"
,
zsize
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
values
[
j
]);
}
void
*
Discrete3DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
().
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
].
getDoubleProperty
(
"v"
));
return
new
Discrete3DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
node
.
getIntProperty
(
"zsize"
),
values
);
}
serialization/tests/TestSerializeCustomCompoundBondForce.cpp
View file @
eb9f735a
...
...
@@ -62,6 +62,10 @@ void testSerialization() {
particles
[
2
]
=
1
;
params
[
0
]
=
2.1
;
force
.
addBond
(
particles
,
params
);
vector
<
double
>
values
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addTabulatedFunction
(
"f"
,
new
Continuous1DFunction
(
values
,
0.5
,
1.5
));
// Serialize and then deserialize it.
...
...
@@ -95,6 +99,19 @@ void testSerialization() {
for
(
int
j
=
0
;
j
<
(
int
)
particles1
.
size
();
j
++
)
ASSERT_EQUAL
(
particles1
[
j
],
particles2
[
j
]);
}
ASSERT_EQUAL
(
force
.
getNumTabulatedFunctions
(),
force2
.
getNumTabulatedFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
{
double
min1
,
min2
,
max1
,
max2
;
vector
<
double
>
val1
,
val2
;
dynamic_cast
<
Continuous1DFunction
&>
(
force
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val1
,
min1
,
max1
);
dynamic_cast
<
Continuous1DFunction
&>
(
force2
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
force
.
getTabulatedFunctionName
(
i
),
force2
.
getTabulatedFunctionName
(
i
));
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
val1
.
size
();
j
++
)
ASSERT_EQUAL
(
val1
[
j
],
val2
[
j
]);
}
}
int
main
()
{
...
...
serialization/tests/TestSerializeCustomGBForce.cpp
View file @
eb9f735a
...
...
@@ -63,7 +63,7 @@ void testSerialization() {
vector
<
double
>
values
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
);
force
.
add
Tabulated
Function
(
"f"
,
new
Discrete1DFunction
(
values
)
);
// Serialize and then deserialize it.
...
...
@@ -120,16 +120,12 @@ void testSerialization() {
ASSERT_EQUAL
(
a1
,
a2
);
ASSERT_EQUAL
(
b1
,
b2
);
}
ASSERT_EQUAL
(
force
.
getNumFunctions
(),
force2
.
getNumFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumFunctions
();
i
++
)
{
string
name1
,
name2
;
double
min1
,
min2
,
max1
,
max2
;
ASSERT_EQUAL
(
force
.
getNumTabulatedFunctions
(),
force2
.
getNumTabulatedFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
{
vector
<
double
>
val1
,
val2
;
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
name1
,
name2
);
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
dynamic_cast
<
Discrete1DFunction
&>
(
force
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val1
);
dynamic_cast
<
Discrete1DFunction
&>
(
force2
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val2
);
ASSERT_EQUAL
(
force
.
getTabulatedFunctionName
(
i
),
force2
.
getTabulatedFunctionName
(
i
));
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
val1
.
size
();
j
++
)
ASSERT_EQUAL
(
val1
[
j
],
val2
[
j
]);
...
...
serialization/tests/TestSerializeCustomHbondForce.cpp
View file @
eb9f735a
...
...
@@ -66,7 +66,7 @@ void testSerialization() {
vector
<
double
>
values
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
force
.
addFunction
(
"f"
,
values
,
0.5
,
1.5
);
force
.
add
Tabulated
Function
(
"f"
,
new
Discrete1DFunction
(
values
)
);
// Serialize and then deserialize it.
...
...
@@ -125,16 +125,12 @@ void testSerialization() {
ASSERT_EQUAL
(
a1
,
a2
);
ASSERT_EQUAL
(
b1
,
b2
);
}
ASSERT_EQUAL
(
force
.
getNumFunctions
(),
force2
.
getNumFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumFunctions
();
i
++
)
{
string
name1
,
name2
;
double
min1
,
min2
,
max1
,
max2
;
ASSERT_EQUAL
(
force
.
getNumTabulatedFunctions
(),
force2
.
getNumTabulatedFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
{
vector
<
double
>
val1
,
val2
;
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
name1
,
name2
);
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
dynamic_cast
<
Discrete1DFunction
&>
(
force
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val1
);
dynamic_cast
<
Discrete1DFunction
&>
(
force2
.
getTabulatedFunction
(
i
)).
getFunctionParameters
(
val2
);
ASSERT_EQUAL
(
force
.
getTabulatedFunctionName
(
i
),
force2
.
getTabulatedFunctionName
(
i
));
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
val1
.
size
();
j
++
)
ASSERT_EQUAL
(
val1
[
j
],
val2
[
j
]);
...
...
serialization/tests/TestSerializeCustomNonbondedForce.cpp
View file @
eb9f735a
...
...
@@ -98,14 +98,13 @@ void testSerialization() {
ASSERT_EQUAL
(
a1
,
a2
);
ASSERT_EQUAL
(
b1
,
b2
);
}
ASSERT_EQUAL
(
force
.
getNumFunctions
(),
force2
.
getNumFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumFunctions
();
i
++
)
{
string
name1
,
name2
;
ASSERT_EQUAL
(
force
.
getNumTabulatedFunctions
(),
force2
.
getNumTabulatedFunctions
());
for
(
int
i
=
0
;
i
<
force
.
getNumTabulatedFunctions
();
i
++
)
{
double
min1
,
min2
,
max1
,
max2
;
vector
<
double
>
val1
,
val2
;
force
.
getFunctionParameters
(
i
,
name1
,
val1
,
min1
,
max1
);
force2
.
getFunctionParameters
(
i
,
name2
,
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
name1
,
name2
);
dynamic_cast
<
Continuous1DFunction
&>
(
force
.
getTabulatedFunction
(
i
))
.
getFunctionParameters
(
val1
,
min1
,
max1
);
dynamic_cast
<
Continuous1DFunction
&>
(
force2
.
getTabulatedFunction
(
i
))
.
getFunctionParameters
(
val2
,
min2
,
max2
);
ASSERT_EQUAL
(
force
.
getTabulatedFunctionName
(
i
),
force2
.
getTabulatedFunctionName
(
i
)
);
ASSERT_EQUAL
(
min1
,
min2
);
ASSERT_EQUAL
(
max1
,
max2
);
ASSERT_EQUAL
(
val1
.
size
(),
val2
.
size
());
...
...
serialization/tests/TestSerializeTabulatedFunctions.cpp
0 → 100644
View file @
eb9f735a
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/TabulatedFunction.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using
namespace
OpenMM
;
using
namespace
std
;
void
testContinuous1DFunction
()
{
// Create a function.
double
min
=
0.5
,
max
=
1.5
;
vector
<
double
>
values
(
60
);
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
Continuous1DFunction
function
(
values
,
min
,
max
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
Continuous1DFunction
>
(
&
function
,
"Function"
,
buffer
);
Continuous1DFunction
*
copy
=
XmlSerializer
::
deserialize
<
Continuous1DFunction
>
(
buffer
);
// Compare the two forces to see if they are identical.
double
min2
,
max2
;
vector
<
double
>
values2
;
copy
->
getFunctionParameters
(
values2
,
min2
,
max2
);
ASSERT_EQUAL
(
min
,
min2
);
ASSERT_EQUAL
(
max
,
max2
);
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
}
void
testContinuous2DFunction
()
{
// Create a function.
int
xsize
=
5
,
ysize
=
12
;
double
xmin
=
0.5
,
xmax
=
1.5
,
ymin
=
0.1
,
ymax
=
5.0
;
vector
<
double
>
values
(
xsize
*
ysize
);
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
Continuous2DFunction
function
(
xsize
,
ysize
,
values
,
xmin
,
xmax
,
ymin
,
ymax
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
Continuous2DFunction
>
(
&
function
,
"Function"
,
buffer
);
Continuous2DFunction
*
copy
=
XmlSerializer
::
deserialize
<
Continuous2DFunction
>
(
buffer
);
// Compare the two forces to see if they are identical.
int
xsize2
,
ysize2
;
double
xmin2
,
xmax2
,
ymin2
,
ymax2
;
vector
<
double
>
values2
;
copy
->
getFunctionParameters
(
xsize2
,
ysize2
,
values2
,
xmin2
,
xmax2
,
ymin2
,
ymax2
);
ASSERT_EQUAL
(
xsize
,
xsize2
);
ASSERT_EQUAL
(
ysize
,
ysize2
);
ASSERT_EQUAL
(
xmin
,
xmin2
);
ASSERT_EQUAL
(
xmax
,
xmax2
);
ASSERT_EQUAL
(
ymin
,
ymin2
);
ASSERT_EQUAL
(
ymax
,
ymax2
);
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
}
void
testContinuous3DFunction
()
{
// Create a function.
int
xsize
=
5
,
ysize
=
4
,
zsize
=
3
;
double
xmin
=
0.5
,
xmax
=
1.5
,
ymin
=
0.1
,
ymax
=
5.0
,
zmin
=
0.3
,
zmax
=
0.9
;
vector
<
double
>
values
(
xsize
*
ysize
*
zsize
);
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
Continuous3DFunction
function
(
xsize
,
ysize
,
zsize
,
values
,
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
Continuous3DFunction
>
(
&
function
,
"Function"
,
buffer
);
Continuous3DFunction
*
copy
=
XmlSerializer
::
deserialize
<
Continuous3DFunction
>
(
buffer
);
// Compare the two forces to see if they are identical.
int
xsize2
,
ysize2
,
zsize2
;
double
xmin2
,
xmax2
,
ymin2
,
ymax2
,
zmin2
,
zmax2
;
vector
<
double
>
values2
;
copy
->
getFunctionParameters
(
xsize2
,
ysize2
,
zsize2
,
values2
,
xmin2
,
xmax2
,
ymin2
,
ymax2
,
zmin2
,
zmax2
);
ASSERT_EQUAL
(
xsize
,
xsize2
);
ASSERT_EQUAL
(
ysize
,
ysize2
);
ASSERT_EQUAL
(
zsize
,
zsize2
);
ASSERT_EQUAL
(
xmin
,
xmin2
);
ASSERT_EQUAL
(
xmax
,
xmax2
);
ASSERT_EQUAL
(
ymin
,
ymin2
);
ASSERT_EQUAL
(
ymax
,
ymax2
);
ASSERT_EQUAL
(
zmin
,
zmin2
);
ASSERT_EQUAL
(
zmax
,
zmax2
);
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
}
void
testDiscrete1DFunction
()
{
// Create a function.
vector
<
double
>
values
(
60
);
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
Discrete1DFunction
function
(
values
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
Discrete1DFunction
>
(
&
function
,
"Function"
,
buffer
);
Discrete1DFunction
*
copy
=
XmlSerializer
::
deserialize
<
Discrete1DFunction
>
(
buffer
);
// Compare the two forces to see if they are identical.
vector
<
double
>
values2
;
copy
->
getFunctionParameters
(
values2
);
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
}
void
testDiscrete2DFunction
()
{
// Create a function.
int
xsize
=
5
,
ysize
=
12
;
vector
<
double
>
values
(
xsize
*
ysize
);
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
Discrete2DFunction
function
(
xsize
,
ysize
,
values
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
Discrete2DFunction
>
(
&
function
,
"Function"
,
buffer
);
Discrete2DFunction
*
copy
=
XmlSerializer
::
deserialize
<
Discrete2DFunction
>
(
buffer
);
// Compare the two forces to see if they are identical.
int
xsize2
,
ysize2
;
vector
<
double
>
values2
;
copy
->
getFunctionParameters
(
xsize2
,
ysize2
,
values2
);
ASSERT_EQUAL
(
xsize
,
xsize2
);
ASSERT_EQUAL
(
ysize
,
ysize2
);
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
}
void
testDiscrete3DFunction
()
{
// Create a function.
int
xsize
=
5
,
ysize
=
4
,
zsize
=
3
;
vector
<
double
>
values
(
xsize
*
ysize
*
zsize
);
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
i
++
)
values
[
i
]
=
sin
((
double
)
i
);
Discrete3DFunction
function
(
xsize
,
ysize
,
zsize
,
values
);
// Serialize and then deserialize it.
stringstream
buffer
;
XmlSerializer
::
serialize
<
Discrete3DFunction
>
(
&
function
,
"Function"
,
buffer
);
Discrete3DFunction
*
copy
=
XmlSerializer
::
deserialize
<
Discrete3DFunction
>
(
buffer
);
// Compare the two forces to see if they are identical.
int
xsize2
,
ysize2
,
zsize2
;
vector
<
double
>
values2
;
copy
->
getFunctionParameters
(
xsize2
,
ysize2
,
zsize2
,
values2
);
ASSERT_EQUAL
(
xsize
,
xsize2
);
ASSERT_EQUAL
(
ysize
,
ysize2
);
ASSERT_EQUAL
(
zsize
,
zsize2
);
ASSERT_EQUAL
(
values
.
size
(),
values2
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
ASSERT_EQUAL
(
values
[
j
],
values2
[
j
]);
}
int
main
()
{
try
{
testContinuous1DFunction
();
testContinuous2DFunction
();
testContinuous3DFunction
();
testDiscrete1DFunction
();
testDiscrete2DFunction
();
testDiscrete3DFunction
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
tests/TestSplineFitter.cpp
View file @
eb9f735a
...
...
@@ -84,10 +84,91 @@ void testPeriodicSpline() {
}
}
void
test2DSpline
()
{
const
int
xsize
=
15
;
const
int
ysize
=
17
;
vector
<
double
>
x
(
xsize
);
vector
<
double
>
y
(
ysize
);
vector
<
double
>
f
(
xsize
*
ysize
);
for
(
int
i
=
0
;
i
<
xsize
;
i
++
)
x
[
i
]
=
0.5
*
i
+
0.1
*
sin
(
double
(
i
));
for
(
int
i
=
0
;
i
<
ysize
;
i
++
)
y
[
i
]
=
0.6
*
i
+
0.1
*
sin
(
double
(
i
));
for
(
int
i
=
0
;
i
<
xsize
;
i
++
)
for
(
int
j
=
0
;
j
<
ysize
;
j
++
)
f
[
i
+
j
*
xsize
]
=
sin
(
x
[
i
])
*
cos
(
0.4
*
y
[
j
]);
vector
<
vector
<
double
>
>
c
;
SplineFitter
::
create2DNaturalSpline
(
x
,
y
,
f
,
c
);
for
(
int
i
=
0
;
i
<
xsize
;
i
++
)
for
(
int
j
=
0
;
j
<
ysize
;
j
++
)
{
double
value
=
SplineFitter
::
evaluate2DSpline
(
x
,
y
,
f
,
c
,
x
[
i
],
y
[
j
]);
ASSERT_EQUAL_TOL
(
f
[
i
+
j
*
xsize
],
value
,
1e-6
);
}
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
j
=
0
;
j
<
10
;
j
++
)
{
double
s
=
x
[
0
]
+
(
i
+
1
)
*
(
x
[
xsize
-
1
]
-
x
[
0
])
/
12.0
;
double
t
=
y
[
0
]
+
(
j
+
1
)
*
(
y
[
ysize
-
1
]
-
y
[
0
])
/
12.0
;
double
value
=
SplineFitter
::
evaluate2DSpline
(
x
,
y
,
f
,
c
,
s
,
t
);
ASSERT_EQUAL_TOL
(
sin
(
s
)
*
cos
(
0.4
*
t
),
value
,
0.02
);
double
dx
,
dy
;
SplineFitter
::
evaluate2DSplineDerivatives
(
x
,
y
,
f
,
c
,
s
,
t
,
dx
,
dy
);
ASSERT_EQUAL_TOL
(
cos
(
s
)
*
cos
(
0.4
*
t
),
dx
,
0.05
);
ASSERT_EQUAL_TOL
(
-
0.4
*
sin
(
s
)
*
sin
(
0.4
*
t
),
dy
,
0.05
);
}
}
}
void
test3DSpline
()
{
const
int
xsize
=
8
;
const
int
ysize
=
9
;
const
int
zsize
=
10
;
vector
<
double
>
x
(
xsize
);
vector
<
double
>
y
(
ysize
);
vector
<
double
>
z
(
zsize
);
vector
<
double
>
f
(
xsize
*
ysize
*
zsize
);
for
(
int
i
=
0
;
i
<
xsize
;
i
++
)
x
[
i
]
=
0.2
*
i
+
0.02
*
sin
(
0.4
*
double
(
i
));
for
(
int
i
=
0
;
i
<
ysize
;
i
++
)
y
[
i
]
=
0.2
*
i
+
0.02
*
sin
(
0.45
*
double
(
i
));
for
(
int
i
=
0
;
i
<
zsize
;
i
++
)
z
[
i
]
=
0.2
*
i
+
0.02
*
sin
(
0.5
*
double
(
i
));
for
(
int
i
=
0
;
i
<
xsize
;
i
++
)
for
(
int
j
=
0
;
j
<
ysize
;
j
++
)
for
(
int
k
=
0
;
k
<
zsize
;
k
++
)
f
[
i
+
j
*
xsize
+
k
*
xsize
*
ysize
]
=
sin
(
x
[
i
])
*
cos
(
0.4
*
y
[
j
])
*
(
1
+
z
[
k
]);
vector
<
vector
<
double
>
>
c
;
SplineFitter
::
create3DNaturalSpline
(
x
,
y
,
z
,
f
,
c
);
for
(
int
i
=
0
;
i
<
xsize
;
i
++
)
for
(
int
j
=
0
;
j
<
ysize
;
j
++
)
{
for
(
int
k
=
0
;
k
<
zsize
;
k
++
)
{
double
value
=
SplineFitter
::
evaluate3DSpline
(
x
,
y
,
z
,
f
,
c
,
x
[
i
],
y
[
j
],
z
[
k
]);
ASSERT_EQUAL_TOL
(
f
[
i
+
j
*
xsize
+
k
*
xsize
*
ysize
],
value
,
1e-6
);
}
}
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
j
=
0
;
j
<
10
;
j
++
)
{
for
(
int
k
=
0
;
k
<
10
;
k
++
)
{
double
s
=
x
[
0
]
+
(
i
+
1
)
*
(
x
[
xsize
-
1
]
-
x
[
0
])
/
12.0
;
double
t
=
y
[
0
]
+
(
j
+
1
)
*
(
y
[
ysize
-
1
]
-
y
[
0
])
/
12.0
;
double
u
=
z
[
0
]
+
(
k
+
1
)
*
(
z
[
zsize
-
1
]
-
z
[
0
])
/
12.0
;
double
value
=
SplineFitter
::
evaluate3DSpline
(
x
,
y
,
z
,
f
,
c
,
s
,
t
,
u
);
ASSERT_EQUAL_TOL
(
sin
(
s
)
*
cos
(
0.4
*
t
)
*
(
1
+
u
),
value
,
0.02
);
double
dx
,
dy
,
dz
;
SplineFitter
::
evaluate3DSplineDerivatives
(
x
,
y
,
z
,
f
,
c
,
s
,
t
,
u
,
dx
,
dy
,
dz
);
ASSERT_EQUAL_TOL
(
cos
(
s
)
*
cos
(
0.4
*
t
)
*
(
1
+
u
),
dx
,
0.1
);
ASSERT_EQUAL_TOL
(
-
0.4
*
sin
(
s
)
*
sin
(
0.4
*
t
)
*
(
1
+
u
),
dy
,
0.1
);
ASSERT_EQUAL_TOL
(
sin
(
s
)
*
cos
(
0.4
*
t
),
dz
,
0.1
);
}
}
}
}
int
main
()
{
try
{
testNaturalSpline
();
testPeriodicSpline
();
test2DSpline
();
test3DSpline
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
wrappers/generateWrappers.py
View file @
eb9f735a
...
...
@@ -42,7 +42,7 @@ def getText(subNodePath, node):
def
convertOpenMMPrefix
(
name
):
return
name
.
replace
(
'OpenMM::'
,
'OpenMM_'
)
OPENMM_RE_PATTERN
=
re
.
compile
(
"(.*)OpenMM:[a-zA-Z:]*:(.*)"
)
OPENMM_RE_PATTERN
=
re
.
compile
(
"(.*)OpenMM:[a-zA-Z
0-9_
:]*:(.*)"
)
def
stripOpenMMPrefix
(
name
,
rePattern
=
OPENMM_RE_PATTERN
):
try
:
m
=
rePattern
.
search
(
name
)
...
...
@@ -624,6 +624,8 @@ class CSourceGenerator(WrapperGenerator):
unwrappedType
=
type
[:
-
1
].
strip
()
if
unwrappedType
in
self
.
classesByShortName
:
unwrappedType
=
self
.
classesByShortName
[
unwrappedType
]
if
unwrappedType
==
'const std::string'
:
return
'std::string(%s)'
%
value
return
'*'
+
self
.
unwrapValue
(
unwrappedType
+
'*'
,
value
)
if
type
in
self
.
classesByShortName
:
return
'static_cast<%s>(%s)'
%
(
self
.
classesByShortName
[
type
],
value
)
...
...
@@ -1665,14 +1667,14 @@ class FortranSourceGenerator(WrapperGenerator):
return
type
def
isHandleType
(
self
,
type
):
if
type
.
startswith
(
'OpenMM_'
):
return
True
;
if
type
==
'Vec3'
:
return
True
if
type
==
'OpenMM_Vec3'
:
return
False
if
type
.
endswith
(
'*'
)
or
type
.
endswith
(
'&'
):
return
self
.
isHandleType
(
type
[:
-
1
].
strip
())
if
type
.
startswith
(
'const '
):
return
self
.
isHandleType
(
type
[
6
:].
strip
())
if
type
.
startswith
(
'OpenMM_'
):
return
True
;
return
False
def
writeOutput
(
self
):
...
...
wrappers/python/CMakeLists.txt
View file @
eb9f735a
...
...
@@ -55,6 +55,7 @@ foreach(SUBDIR ${SUBDIRS})
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.xml"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.pdb"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.prmtop"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.dms"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.top"
)
foreach
(
file
${
STAGING_INPUT_FILES1
}
)
...
...
wrappers/python/simtk/openmm/app/amberprmtopfile.py
View file @
eb9f735a
...
...
@@ -31,6 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
__author__
=
"Peter Eastman"
__version__
=
"1.0"
from
math
import
sqrt
from
simtk.openmm.app
import
Topology
from
simtk.openmm.app
import
PDBFile
from
simtk.openmm.app.internal
import
amber_file_parser
...
...
@@ -118,6 +119,8 @@ class AmberPrmtopFile(object):
element
=
elem
.
sodium
elif
upper
.
startswith
(
'MG'
):
element
=
elem
.
magnesium
elif
upper
.
startswith
(
'ZN'
):
element
=
elem
.
zinc
else
:
try
:
element
=
elem
.
get_by_symbol
(
atomName
[
0
])
...
...
@@ -142,7 +145,8 @@ class AmberPrmtopFile(object):
def
createSystem
(
self
,
nonbondedMethod
=
ff
.
NoCutoff
,
nonbondedCutoff
=
1.0
*
unit
.
nanometer
,
constraints
=
None
,
rigidWater
=
True
,
implicitSolvent
=
None
,
implicitSolventKappa
=
0.0
*
(
1
/
unit
.
nanometer
),
implicitSolventSaltConc
=
0.0
*
(
unit
.
moles
/
unit
.
liter
),
implicitSolventKappa
=
None
,
temperature
=
298.15
*
unit
.
kelvin
,
soluteDielectric
=
1.0
,
solventDielectric
=
78.5
,
removeCMMotion
=
True
,
hydrogenMass
=
None
,
ewaldErrorTolerance
=
0.0005
):
"""Construct an OpenMM System representing the topology described by this prmtop file.
...
...
@@ -155,7 +159,12 @@ class AmberPrmtopFile(object):
Allowed values are None, HBonds, AllBonds, or HAngles.
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- implicitSolvent (object=None) If not None, the implicit solvent model to use. Allowed values are HCT, OBC1, OBC2, GBn, or GBn2.
- implicitSolventKappa (float=0.0*1/unit.nanometer) The Debye-screening parameter corresponding to ionic strength used for implicit solvent
- implicitSolventSaltConc (float=0.0*unit.moles/unit.liter) The salt concentration for GB
calculations (modelled as a debye screening parameter). It is converted to the debye length (kappa)
using the provided temperature and solventDielectric
- temperature (float=300*kelvin) Temperature of the system. Only used to compute the Debye length from
implicitSolventSoltConc
- implicitSolventKappa (float units of 1/length) If this value is set, implicitSolventSaltConc will be ignored.
- soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model.
- solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model.
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
...
...
@@ -197,10 +206,29 @@ class AmberPrmtopFile(object):
implicitString
=
'GBn2'
else
:
raise
ValueError
(
'Illegal value for implicit solvent model'
)
sys
=
amber_file_parser
.
readAmberSystem
(
prmtop_loader
=
self
.
_prmtop
,
shake
=
constraintString
,
nonbondedCutoff
=
nonbondedCutoff
,
nonbondedMethod
=
methodMap
[
nonbondedMethod
],
flexibleConstraints
=
False
,
gbmodel
=
implicitString
,
soluteDielectric
=
soluteDielectric
,
solventDielectric
=
solventDielectric
,
implicitSolventKappa
=
implicitSolventKappa
,
rigidWater
=
rigidWater
,
elements
=
self
.
elements
)
# If implicitSolventKappa is None, compute it from the salt concentration
if
implicitSolvent
is
not
None
and
implicitSolventKappa
is
None
:
if
unit
.
is_quantity
(
implicitSolventSaltConc
):
implicitSolventSaltConc
=
implicitSolventSaltConc
.
value_in_unit
(
unit
.
moles
/
unit
.
liter
)
if
unit
.
is_quantity
(
temperature
):
temperature
=
temperature
.
value_in_unit
(
unit
.
kelvin
)
# The constant is 1 / sqrt( epsilon_0 * kB / (2 * NA * q^2 * 1000) )
# where NA is avogadro's number, epsilon_0 is the permittivity of
# free space, q is the elementary charge (this number matches
# Amber's kappa conversion factor)
implicitSolventKappa
=
50.33355
*
sqrt
(
implicitSolventSaltConc
/
solventDielectric
/
temperature
)
# Multiply by 0.73 to account for ion exclusions, and multiply by 10
# to convert to 1/nm from 1/angstroms
implicitSolventKappa
*=
7.3
elif
implicitSolvent
is
None
:
implicitSolventKappa
=
0.0
sys
=
amber_file_parser
.
readAmberSystem
(
prmtop_loader
=
self
.
_prmtop
,
shake
=
constraintString
,
nonbondedCutoff
=
nonbondedCutoff
,
nonbondedMethod
=
methodMap
[
nonbondedMethod
],
flexibleConstraints
=
False
,
gbmodel
=
implicitString
,
soluteDielectric
=
soluteDielectric
,
solventDielectric
=
solventDielectric
,
implicitSolventKappa
=
implicitSolventKappa
,
rigidWater
=
rigidWater
,
elements
=
self
.
elements
)
if
hydrogenMass
is
not
None
:
for
atom1
,
atom2
in
self
.
topology
.
bonds
():
if
atom1
.
element
==
elem
.
hydrogen
:
...
...
wrappers/python/simtk/openmm/app/data/absinth.xml
View file @
eb9f735a
...
...
@@ -4151,7 +4151,7 @@
<EnergyTerm
type=
"ParticlePairNoExclusions"
>
include(chargeGroup1*numChargeGroups+chargeGroup2)*screening1*screening2*138.935456*charge1*charge2/r
</EnergyTerm>
<Function
name=
"sigma"
min=
"0"
max=
"675
"
>
<Function
name=
"sigma"
type=
"Discrete1D
"
>
0.27 0.3 0.285 0.185 0.27 0.285 0.315 0.27 0.235 0.295 0.27 0.30152225 0.355862 0.2932777648 0.235 0.29253280555 0.235 0.29267889715 0.235 0.3817314 0.366188 0.47079995 0.405 0.315 0.3099 0.241
0.3 0.33 0.315 0.265 0.3 0.315 0.345 0.3 0.265 0.325 0.3 0.33152225 0.385862 0.3232777648 0.265 0.32253280555 0.265 0.32267889715 0.265 0.4117314 0.396188 0.50079995 0.435 0.345 0.3399 0.271
0.285 0.315 0.3 0.25 0.285 0.3 0.33 0.285 0.25 0.31 0.285 0.31652225 0.370862 0.3082777648 0.25 0.30753280555 0.25 0.30767889715 0.25 0.3967314 0.381188 0.48579995 0.42 0.33 0.3249 0.256
...
...
wrappers/python/simtk/openmm/app/data/iamoeba.xml
0 → 100644
View file @
eb9f735a
<ForceField>
<AtomTypes>
<Type
name=
"380"
class=
"73"
element=
"O"
mass=
"15.999"
/>
<Type
name=
"381"
class=
"74"
element=
"H"
mass=
"1.008"
/>
</AtomTypes>
<Residues>
<Residue
name=
"HOH"
>
<Atom
name=
"H1"
type=
"381"
/>
<Atom
name=
"H2"
type=
"381"
/>
<Atom
name=
"O"
type=
"380"
/>
<Bond
from=
"0"
to=
"2"
/>
<Bond
from=
"1"
to=
"2"
/>
</Residue>
</Residues>
<AmoebaBondForce
bond-cubic=
"-25.5"
bond-quartic=
"379.3125"
>
<Bond
class1=
"73"
class2=
"74"
length=
"9.584047e-02"
k=
"2.3331232e+05"
/>
</AmoebaBondForce>
<AmoebaAngleForce
angle-cubic=
"-0.014"
angle-quartic=
"5.6e-05"
angle-pentic=
"-7e-07"
angle-sextic=
"2.2e-08"
>
<Angle
class1=
"74"
class2=
"73"
class3=
"74"
k=
"6.359379296918e-02"
angle1=
"1.064826e+02"
/>
</AmoebaAngleForce>
<AmoebaOutOfPlaneBendForce
type=
"ALLINGER"
opbend-cubic=
"-0.014"
opbend-quartic=
"5.6e-05"
opbend-pentic=
"-7e-07"
opbend-sextic=
"2.2e-08"
>
<!-- LPW: Mark's force field parsing code requires AmoebaOutOfPlaneBendForce in order to read AmoebaAngleForce, even if the clause is empty -->
</AmoebaOutOfPlaneBendForce>
<AmoebaVdwForce
type=
"BUFFERED-14-7"
radiusrule=
"CUBIC-MEAN"
radiustype=
"R-MIN"
radiussize=
"DIAMETER"
epsilonrule=
"HHG"
vdw-13-scale=
"0.0"
vdw-14-scale=
"1.0"
vdw-15-scale=
"1.0"
>
<Vdw
class=
"73"
sigma=
"3.645297e-01"
epsilon=
"8.2348e-01"
reduction=
"1.0"
/>
<Vdw
class=
"74"
sigma=
"0.0"
epsilon=
"0.0"
reduction=
"1.0"
/>
</AmoebaVdwForce>
<AmoebaMultipoleForce
direct11Scale=
"0.0"
direct12Scale=
"1.0"
direct13Scale=
"1.0"
direct14Scale=
"1.0"
mpole12Scale=
"0.0"
mpole13Scale=
"0.0"
mpole14Scale=
"0.4"
mpole15Scale=
"0.8"
mutual11Scale=
"1.0"
mutual12Scale=
"1.0"
mutual13Scale=
"1.0"
mutual14Scale=
"1.0"
polar12Scale=
"0.0"
polar13Scale=
"0.0"
polar14Intra=
"0.5"
polar14Scale=
"1.0"
polar15Scale=
"1.0"
>
<Multipole
type=
"380"
kz=
"-381"
kx=
"-381"
c0=
"-5.94024e-01"
d1=
"0.0"
d2=
"0.0"
d3=
"4.682021361460e-03"
q11=
"2.111247211390e-04"
q21=
"0.0"
q22=
"-3.009710770960e-04"
q31=
"0.0"
q32=
"0.0"
q33=
"8.984635595700e-05"
/>
<Multipole
type=
"381"
kz=
"380"
kx=
"381"
c0=
"2.97012e-01"
d1=
"-4.969244847950e-03"
d2=
"0.0"
d3=
"-6.646702999580e-03"
q11=
"1.750551751017e-04"
q21=
"0.0"
q22=
"2.029112480700e-05"
q31=
"-3.392685963908e-05"
q32=
"0.0"
q33=
"-1.953462999087e-04"
/>
<Polarize
type=
"380"
polarizability=
"8.063631227791e-04"
thole=
"2.36164e-01"
pgrp1=
"381"
/>
<Polarize
type=
"381"
polarizability=
"5.048434386104e-04"
thole=
"2.36164e-01"
pgrp1=
"380"
/>
</AmoebaMultipoleForce>
<AmoebaUreyBradleyForce
cubic=
"0.0"
quartic=
"0.0"
>
<UreyBradley
class1=
"74"
class2=
"73"
class3=
"74"
k=
"-4.31294e+03"
d=
"1.535676676685e-01"
/>
</AmoebaUreyBradleyForce>
</ForceField>
wrappers/python/simtk/openmm/app/forcefield.py
View file @
eb9f735a
...
...
@@ -1509,7 +1509,17 @@ class CustomGBGenerator:
generator
.
energyTerms
.
append
((
term
.
text
,
computationMap
[
term
.
attrib
[
'type'
]]))
for
function
in
element
.
findall
(
"Function"
):
values
=
[
float
(
x
)
for
x
in
function
.
text
.
split
()]
generator
.
functions
.
append
((
function
.
attrib
[
'name'
],
values
,
float
(
function
.
attrib
[
'min'
]),
float
(
function
.
attrib
[
'max'
])))
if
'type'
in
function
.
attrib
:
type
=
function
.
attrib
[
'type'
]
else
:
type
=
'Continuous1D'
params
=
{}
for
key
in
function
.
attrib
:
if
key
.
endswith
(
'size'
):
params
[
key
]
=
int
(
function
.
attrib
[
key
])
elif
key
.
endswith
(
'min'
)
or
key
.
endswith
(
'max'
):
params
[
key
]
=
float
(
function
.
attrib
[
key
])
generator
.
functions
.
append
((
function
.
attrib
[
'name'
],
type
,
values
,
params
))
def
createForce
(
self
,
sys
,
data
,
nonbondedMethod
,
nonbondedCutoff
,
args
):
methodMap
=
{
NoCutoff
:
mm
.
CustomGBForce
.
NoCutoff
,
...
...
@@ -1526,8 +1536,19 @@ class CustomGBGenerator:
force
.
addComputedValue
(
value
[
0
],
value
[
1
],
value
[
2
])
for
term
in
self
.
energyTerms
:
force
.
addEnergyTerm
(
term
[
0
],
term
[
1
])
for
function
in
self
.
functions
:
force
.
addFunction
(
function
[
0
],
function
[
1
],
function
[
2
],
function
[
3
])
for
(
name
,
type
,
values
,
params
)
in
self
.
functions
:
if
type
==
'Continuous1D'
:
force
.
addTabulatedFunction
(
name
,
mm
.
Continuous1DFunction
(
values
,
params
[
'min'
],
params
[
'max'
]))
elif
type
==
'Continuous2D'
:
force
.
addTabulatedFunction
(
name
,
mm
.
Continuous2DFunction
(
params
[
'xsize'
],
params
[
'ysize'
],
values
,
params
[
'xmin'
],
params
[
'xmax'
],
params
[
'ymin'
],
params
[
'ymax'
]))
elif
type
==
'Continuous3D'
:
force
.
addTabulatedFunction
(
name
,
mm
.
Continuous2DFunction
(
params
[
'xsize'
],
params
[
'ysize'
],
params
[
'zsize'
],
values
,
params
[
'xmin'
],
params
[
'xmax'
],
params
[
'ymin'
],
params
[
'ymax'
],
params
[
'zmin'
],
params
[
'zmax'
]))
elif
type
==
'Discrete1D'
:
force
.
addTabulatedFunction
(
name
,
mm
.
Discrete1DFunction
(
values
))
elif
type
==
'Discrete2D'
:
force
.
addTabulatedFunction
(
name
,
mm
.
Discrete2DFunction
(
params
[
'xsize'
],
params
[
'ysize'
],
values
))
elif
type
==
'Discrete3D'
:
force
.
addTabulatedFunction
(
name
,
mm
.
Discrete2DFunction
(
params
[
'xsize'
],
params
[
'ysize'
],
params
[
'zsize'
],
values
))
for
atom
in
data
.
atoms
:
t
=
data
.
atomType
[
atom
]
if
t
in
self
.
typeMap
:
...
...
wrappers/python/simtk/openmm/app/internal/amber_file_parser.py
View file @
eb9f735a
...
...
@@ -890,7 +890,7 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
else
:
raise
Exception
(
"Illegal value specified for implicit solvent model"
)
for
iAtom
in
range
(
prmtop
.
getNumAtoms
()):
if
gbmodel
==
'OBC2'
:
if
gbmodel
==
'OBC2'
and
implicitSolventKappa
==
0
:
gb
.
addParticle
(
charges
[
iAtom
],
gb_parms
[
iAtom
][
0
],
gb_parms
[
iAtom
][
1
])
elif
gbmodel
==
'GBn2'
:
gb
.
addParticle
([
charges
[
iAtom
],
gb_parms
[
iAtom
][
0
],
gb_parms
[
iAtom
][
1
],
...
...
Prev
1
2
3
4
5
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