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
cf8a03e8
Commit
cf8a03e8
authored
Mar 12, 2014
by
peastman
Browse files
Merged changes from main branch
parents
f7f70136
31d02cdc
Changes
205
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
809 additions
and
192 deletions
+809
-192
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
+11
-8
wrappers/python/CMakeLists.txt
wrappers/python/CMakeLists.txt
+1
-2
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/desmonddmsfile.py
wrappers/python/simtk/openmm/app/desmonddmsfile.py
+79
-79
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
wrappers/python/simtk/openmm/app/internal/customgbforces.py
wrappers/python/simtk/openmm/app/internal/customgbforces.py
+7
-7
No files found.
serialization/src/CustomGBForceProxy.cpp
View file @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
/* -------------------------------------------------------------------------- *
* 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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
/* -------------------------------------------------------------------------- *
* 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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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
)
...
...
@@ -75,9 +75,10 @@ class WrapperGenerator:
# Read all the XML files and merge them into a single document.
self
.
doc
=
etree
.
ElementTree
(
etree
.
Element
(
'root'
))
for
file
in
os
.
listdir
(
inputDirname
):
root
=
etree
.
parse
(
os
.
path
.
join
(
inputDirname
,
file
)).
getroot
()
for
node
in
root
:
self
.
doc
.
getroot
().
append
(
node
)
if
file
.
lower
().
endswith
(
'xml'
):
root
=
etree
.
parse
(
os
.
path
.
join
(
inputDirname
,
file
)).
getroot
()
for
node
in
root
:
self
.
doc
.
getroot
().
append
(
node
)
self
.
out
=
output
...
...
@@ -623,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
)
...
...
@@ -1664,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 @
cf8a03e8
find_program
(
PYTHON_EXECUTABLE NAMES python
)
#############################################
### Copy all source files to staging area ###
#############################################
...
...
@@ -57,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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
<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/desmonddmsfile.py
View file @
cf8a03e8
'''
"""
desmonddmsfile.py: Load Desmond dms files
Portions copyright (c) 2013 Stanford University and the Authors
...
...
@@ -23,7 +23,7 @@ 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.
'''
"""
import
os
import
math
...
...
@@ -38,16 +38,16 @@ from simtk.unit import (nanometer, angstrom, dalton, radian,
class
DesmondDMSFile
(
object
):
'''
DesmondDMSFile parses a Desmond DMS (desmond molecular system) and
"""
DesmondDMSFile parses a Desmond DMS (desmond molecular system) and
constructs a topology and (optionally) an OpenMM System from it
'''
"""
def
__init__
(
self
,
file
):
'''
Load a DMS file
"""
Load a DMS file
Parameters:
- file (string) the name of the file to load
'''
- file (string) the name of the file to load
"""
# sqlite3 is included in the standard lib, but at python
# compile time, you can disable support (I think), so it's
...
...
@@ -73,8 +73,8 @@ class DesmondDMSFile(object):
# build the provenance string
provenance
=
[]
q
=
'''
SELECT id, user, timestamp, version, workdir, cmdline, executable
FROM provenance
'''
q
=
"""
SELECT id, user, timestamp, version, workdir, cmdline, executable
FROM provenance
"""
#for id, user, timestamp, version, workdir, cmdline, executable in self._conn.execute(q):
for
row
in
self
.
_conn
.
execute
(
'SELECT * FROM provenance'
):
rowdict
=
dict
(
zip
(
self
.
_tables
[
'provenance'
],
row
))
...
...
@@ -89,23 +89,23 @@ class DesmondDMSFile(object):
self
.
_angleConstraints
=
[{}
for
x
in
range
(
len
(
self
.
_topologyAtoms
))]
def
getPositions
(
self
):
'''
Get the positions of each atom in the system
'''
"""
Get the positions of each atom in the system
"""
return
self
.
positions
def
getTopology
(
self
):
'''
Get the topology of the system
'''
"""
Get the topology of the system
"""
return
self
.
topology
def
getProvenance
(
self
):
'''
Get the provenance string of this system
'''
"""
Get the provenance string of this system
"""
return
self
.
provenance
def
_createTopology
(
self
):
'''
Build the topology of the system
'''
"""
Build the topology of the system
"""
top
=
Topology
()
positions
=
[]
...
...
@@ -119,8 +119,8 @@ class DesmondDMSFile(object):
lastChain
=
None
lastResId
=
None
c
=
top
.
addChain
()
q
=
'''
SELECT id, name, anum, resname, resid, chain, x, y, z
FROM particle
'''
q
=
"""
SELECT id, name, anum, resname, resid, chain, x, y, z
FROM particle
"""
for
(
atomId
,
atomName
,
atomNumber
,
resName
,
resId
,
chain
,
x
,
y
,
z
)
in
self
.
_conn
.
execute
(
q
):
newChain
=
False
if
chain
!=
lastChain
:
...
...
@@ -156,17 +156,17 @@ class DesmondDMSFile(object):
def
createSystem
(
self
,
nonbondedMethod
=
ff
.
NoCutoff
,
nonbondedCutoff
=
1.0
*
nanometer
,
ewaldErrorTolerance
=
0.0005
,
removeCMMotion
=
True
,
hydrogenMass
=
None
):
'''
Construct an OpenMM System representing the topology described by this dms file
"""
Construct an OpenMM System representing the topology described by this dms file
Parameters:
- nonbondedMethod (object=NoCutoff) The method to use for nonbonded interactions. Allowed values are
NoCutoff, CutoffNonPeriodic, CutoffPeriodic, Ewald, or PME.
- nonbondedCutoff (distance=1*nanometer) The cutoff distance to use for nonbonded interactions
- ewaldErrorTolerance (float=0.0005) The error tolerance to use if nonbondedMethod is Ewald or PME.
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
- hydrogenMass (mass=None) The mass to use for hydrogen atoms bound to heavy atoms. Any mass added to a hydrogen is
subtracted from the heavy atom to keep their total mass the same.
'''
- nonbondedMethod (object=NoCutoff) The method to use for nonbonded interactions. Allowed values are
NoCutoff, CutoffNonPeriodic, CutoffPeriodic, Ewald, or PME.
- nonbondedCutoff (distance=1*nanometer) The cutoff distance to use for nonbonded interactions
- ewaldErrorTolerance (float=0.0005) The error tolerance to use if nonbondedMethod is Ewald or PME.
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
- hydrogenMass (mass=None) The mass to use for hydrogen atoms bound to heavy atoms. Any mass added to a hydrogen is
subtracted from the heavy atom to keep their total mass the same.
"""
self
.
_checkForUnsupportedTerms
()
sys
=
mm
.
System
()
...
...
@@ -219,14 +219,14 @@ class DesmondDMSFile(object):
return
sys
def
_addBondsToSystem
(
self
,
sys
):
'''
Create the harmonic bonds
'''
"""
Create the harmonic bonds
"""
bonds
=
mm
.
HarmonicBondForce
()
sys
.
addForce
(
bonds
)
q
=
'''
SELECT p0, p1, r0, fc, constrained
q
=
"""
SELECT p0, p1, r0, fc, constrained
FROM stretch_harm_term INNER JOIN stretch_harm_param
ON stretch_harm_term.param=stretch_harm_param.id
'''
ON stretch_harm_term.param=stretch_harm_param.id
"""
for
p0
,
p1
,
r0
,
fc
,
constrained
in
self
.
_conn
.
execute
(
q
):
if
constrained
:
sys
.
addConstraint
(
p0
,
p1
,
r0
*
angstrom
)
...
...
@@ -242,15 +242,15 @@ class DesmondDMSFile(object):
return
bonds
def
_addAnglesToSystem
(
self
,
sys
):
'''
Create the harmonic angles
'''
"""
Create the harmonic angles
"""
angles
=
mm
.
HarmonicAngleForce
()
sys
.
addForce
(
angles
)
degToRad
=
math
.
pi
/
180
q
=
'''
SELECT p0, p1, p2, theta0, fc, constrained
q
=
"""
SELECT p0, p1, p2, theta0, fc, constrained
FROM angle_harm_term INNER JOIN angle_harm_param
ON angle_harm_term.param=angle_harm_param.id
'''
ON angle_harm_term.param=angle_harm_param.id
"""
for
p0
,
p1
,
p2
,
theta0
,
fc
,
constrained
in
self
.
_conn
.
execute
(
q
):
if
constrained
:
l1
=
self
.
_atomBonds
[
p1
][
p0
]
...
...
@@ -267,15 +267,15 @@ class DesmondDMSFile(object):
return
angles
def
_addConstraintsToSystem
(
self
,
sys
):
'''
Add constraints to system. Normally these should already be
"""
Add constraints to system. Normally these should already be
added by the bonds table, but we want to make sure that there's
no extra information in the constraints table that we're not
including in the system
'''
including in the system
"""
for
term_table
in
[
n
for
n
in
self
.
_tables
.
keys
()
if
n
.
startswith
(
'constraint_a'
)
and
n
.
endswith
(
'term'
)]:
param_table
=
term_table
.
replace
(
'term'
,
'param'
)
q
=
'''
SELECT p0, p1, r1
q
=
"""
SELECT p0, p1, r1
FROM %(term)s INNER JOIN %(param)s
ON %(term)s.param=%(param)s.id
'''
%
\
ON %(term)s.param=%(param)s.id
"""
%
\
{
'term'
:
term_table
,
'param'
:
param_table
}
for
p0
,
p1
,
r1
in
self
.
_conn
.
execute
(
q
):
if
not
p1
in
self
.
_atomBonds
[
p0
]:
...
...
@@ -285,9 +285,9 @@ class DesmondDMSFile(object):
if
'constraint_hoh_term'
in
self
.
_tables
:
degToRad
=
math
.
pi
/
180
q
=
'''
SELECT p0, p1, p2, r1, r2, theta
q
=
"""
SELECT p0, p1, p2, r1, r2, theta
FROM constraint_hoh_term INNER JOIN constraint_hoh_param
ON constraint_hoh_term.param=constraint_hoh_param.id
'''
ON constraint_hoh_term.param=constraint_hoh_param.id
"""
for
p0
,
p1
,
p2
,
r1
,
r2
,
theta
in
self
.
_conn
.
execute
(
q
):
# Here, p0 is the heavy atom and p1 and p2 are the H1 and H2
# wihth O-H1 and O-H2 distances r1 and r2
...
...
@@ -296,14 +296,14 @@ class DesmondDMSFile(object):
sys
.
addConstraint
(
p1
,
p2
,
length
)
def
_addPeriodicTorsionsToSystem
(
self
,
sys
):
'''
Create the torsion terms
'''
"""
Create the torsion terms
"""
periodic
=
mm
.
PeriodicTorsionForce
()
sys
.
addForce
(
periodic
)
q
=
'''
SELECT p0, p1, p2, p3, phi0, fc0, fc1, fc2, fc3, fc4, fc5, fc6
q
=
"""
SELECT p0, p1, p2, p3, phi0, fc0, fc1, fc2, fc3, fc4, fc5, fc6
FROM dihedral_trig_term INNER JOIN dihedral_trig_param
ON dihedral_trig_term.param=dihedral_trig_param.id
'''
ON dihedral_trig_term.param=dihedral_trig_param.id
"""
for
p0
,
p1
,
p2
,
p3
,
phi0
,
fc0
,
fc1
,
fc2
,
fc3
,
fc4
,
fc5
,
fc6
in
self
.
_conn
.
execute
(
q
):
for
order
,
fc
in
enumerate
([
fc0
,
fc1
,
fc2
,
fc3
,
fc4
,
fc5
,
fc6
]):
if
fc
==
0
:
...
...
@@ -312,8 +312,8 @@ class DesmondDMSFile(object):
def
_addImproperHarmonicTorsionsToSystem
(
self
,
sys
):
'''
Create the improper harmonic torsion terms
'''
"""
Create the improper harmonic torsion terms
"""
if
not
self
.
_hasTable
(
'improper_harm_term'
):
return
...
...
@@ -322,15 +322,15 @@ class DesmondDMSFile(object):
harmonicTorsion
.
addPerTorsionParameter
(
'k'
)
sys
.
addForce
(
harmonicTorsion
)
q
=
'''
SELECT p0, p1, p2, p3, phi0, fc
q
=
"""
SELECT p0, p1, p2, p3, phi0, fc
FROM improper_harm_term INNER JOIN improper_harm_param
ON improper_harm_term.param=improper_harm_param.id
'''
ON improper_harm_term.param=improper_harm_param.id
"""
for
p0
,
p1
,
p2
,
p3
,
phi0
,
fc
in
self
.
_conn
.
execute
(
q
):
harmonicTorsion
.
addTorsion
(
p0
,
p1
,
p2
,
p3
,
[
phi0
*
degree
,
fc
*
kilocalorie_per_mole
])
def
_addCMAPToSystem
(
self
,
sys
):
'''
Create the CMAP terms
'''
"""
Create the CMAP terms
"""
if
not
self
.
_hasTable
(
'torsiontorsion_cmap_term'
):
return
...
...
@@ -354,30 +354,30 @@ class DesmondDMSFile(object):
index
=
cmap
.
addMap
(
size
,
map
*
kilocalorie_per_mole
)
cmap_indices
[
name
]
=
index
q
=
'''
SELECT p0, p1, p2, p3, p4, p5, p6, p7, cmapid
q
=
"""
SELECT p0, p1, p2, p3, p4, p5, p6, p7, cmapid
FROM torsiontorsion_cmap_term INNER JOIN torsiontorsion_cmap_param
ON torsiontorsion_cmap_term.param=torsiontorsion_cmap_param.id
'''
ON torsiontorsion_cmap_term.param=torsiontorsion_cmap_param.id
"""
for
p0
,
p1
,
p2
,
p3
,
p4
,
p5
,
p6
,
p7
,
cmapid
in
self
.
_conn
.
execute
(
q
):
cmap
.
addTorsion
(
cmap_indices
[
cmapid
],
p0
,
p1
,
p2
,
p3
,
p4
,
p5
,
p6
,
p7
)
def
_addNonbondedForceToSystem
(
self
,
sys
):
'''
Create the nonbonded force
'''
"""
Create the nonbonded force
"""
nb
=
mm
.
NonbondedForce
()
sys
.
addForce
(
nb
)
q
=
'''
SELECT charge, sigma, epsilon
q
=
"""
SELECT charge, sigma, epsilon
FROM particle INNER JOIN nonbonded_param
ON particle.nbtype=nonbonded_param.id
'''
ON particle.nbtype=nonbonded_param.id
"""
for
charge
,
sigma
,
epsilon
in
self
.
_conn
.
execute
(
q
):
nb
.
addParticle
(
charge
,
sigma
*
angstrom
,
epsilon
*
kilocalorie_per_mole
)
for
p0
,
p1
in
self
.
_conn
.
execute
(
'SELECT p0, p1 FROM exclusion'
):
nb
.
addException
(
p0
,
p1
,
0.0
,
1.0
,
0.0
)
q
=
'''
SELECT p0, p1, aij, bij, qij
q
=
"""
SELECT p0, p1, aij, bij, qij
FROM pair_12_6_es_term INNER JOIN pair_12_6_es_param
ON pair_12_6_es_term.param=pair_12_6_es_param.id;
'''
ON pair_12_6_es_term.param=pair_12_6_es_param.id;
"""
for
p0
,
p1
,
a_ij
,
b_ij
,
q_ij
in
self
.
_conn
.
execute
(
q
):
a_ij
=
(
a_ij
*
kilocalorie_per_mole
*
(
angstrom
**
12
)).
in_units_of
(
kilojoule_per_mole
*
(
nanometer
**
12
))
b_ij
=
(
b_ij
*
kilocalorie_per_mole
*
(
angstrom
**
6
)).
in_units_of
(
kilojoule_per_mole
*
(
nanometer
**
6
))
...
...
@@ -391,41 +391,41 @@ class DesmondDMSFile(object):
new_sigma
=
(
a_ij
/
b_ij
)
**
(
1.0
/
6.0
)
nb
.
addException
(
p0
,
p1
,
q_ij
,
new_sigma
,
new_epsilon
,
True
)
n_total
=
self
.
_conn
.
execute
(
'''
SELECT COUNT(*) FROM pair_12_6_es_term
'''
).
fetchone
()
n_in_exclusions
=
self
.
_conn
.
execute
(
'''
SELECT COUNT(*)
n_total
=
self
.
_conn
.
execute
(
"""
SELECT COUNT(*) FROM pair_12_6_es_term
"""
).
fetchone
()
n_in_exclusions
=
self
.
_conn
.
execute
(
"""
SELECT COUNT(*)
FROM exclusion INNER JOIN pair_12_6_es_term
ON exclusion.p0==pair_12_6_es_term.p0 AND exclusion.p1==pair_12_6_es_term.p1
'''
).
fetchone
()
ON exclusion.p0==pair_12_6_es_term.p0 AND exclusion.p1==pair_12_6_es_term.p1
"""
).
fetchone
()
if
not
n_total
==
n_in_exclusions
:
raise
NotImplementedError
(
'All pair_12_6_es_terms must have a corresponding exclusion'
)
return
nb
def
_addVirtualSitesToSystem
(
self
,
sys
):
'''
Create any virtual sites in the systempy
'''
"""
Create any virtual sites in the systempy
"""
if
not
any
(
t
.
startswith
(
'virtual_'
)
for
t
in
self
.
_tables
.
keys
()):
return
if
'virtual_lc2_term'
in
self
.
_tables
:
q
=
'''
SELECT p0, p1, p2, c1
q
=
"""
SELECT p0, p1, p2, c1
FROM virtual_lc2_term INNER JOIN virtual_lc2_param
ON virtual_lc2_term.param=virtual_lc2_param.id
'''
ON virtual_lc2_term.param=virtual_lc2_param.id
"""
for
p0
,
p1
,
p2
,
c1
in
self
.
_conn
.
execute
(
q
):
vsite
=
mm
.
TwoParticleAverageSite
(
p1
,
p2
,
(
1
-
c1
),
c1
)
sys
.
setVirtualSite
(
p0
,
vsite
)
if
'virtual_lc3_term'
in
self
.
_tables
:
q
=
'''
SELECT p0, p1, p2, p3, c1, c2
q
=
"""
SELECT p0, p1, p2, p3, c1, c2
FROM virtual_lc3_term INNER JOIN virtual_lc3_param
ON virtual_lc3_term.param=virtual_lc3_param.id
'''
ON virtual_lc3_term.param=virtual_lc3_param.id
"""
for
p0
,
p1
,
p2
,
p3
,
c1
,
c2
in
self
.
_conn
.
execute
(
q
):
vsite
=
mm
.
ThreeParticleAverageSite
(
p1
,
p2
,
p3
,
(
1
-
c1
-
c2
),
c1
,
c2
)
sys
.
setVirtualSite
(
p0
,
vsite
)
if
'virtual_out3_term'
in
self
.
_tables
:
q
=
'''
SELECT p0, p1, p2, p3, c1, c2, c3
q
=
"""
SELECT p0, p1, p2, p3, c1, c2, c3
FROM virtual_out3_term INNER JOIN virtual_out3_param
ON virtual_out3_term.param=virtual_out3_param.id
'''
ON virtual_out3_term.param=virtual_out3_param.id
"""
for
p0
,
p1
,
p2
,
p3
,
c1
,
c2
,
c3
in
self
.
_conn
.
execute
(
q
):
vsite
=
mm
.
OutOfPlaneSite
(
p1
,
p2
,
p3
,
c1
,
c2
,
c3
)
sys
.
setVirtualSite
(
p0
,
vsite
)
...
...
@@ -436,14 +436,14 @@ class DesmondDMSFile(object):
def
_hasTable
(
self
,
table_name
):
'''
Does our DMS file contain this table?
'''
"""
Does our DMS file contain this table?
"""
return
table_name
in
self
.
_tables
def
_readSchemas
(
self
):
'''
Read the schemas of each of the tables in the dms file, populating
"""
Read the schemas of each of the tables in the dms file, populating
the `_tables` instance attribute
'''
"""
tables
=
{}
for
table
in
self
.
_conn
.
execute
(
"SELECT name FROM sqlite_master WHERE type='table'"
):
names
=
[]
...
...
@@ -453,9 +453,9 @@ class DesmondDMSFile(object):
self
.
_tables
=
tables
def
_checkForUnsupportedTerms
(
self
):
'''
Check the file for forcefield terms that are not currenty supported,
"""
Check the file for forcefield terms that are not currenty supported,
raising a NotImplementedError
'''
"""
if
'posre_harm_term'
in
self
.
_tables
:
raise
NotImplementedError
(
'Position restraints are not implemented.'
)
flat_bottom_potential_terms
=
[
'stretch_fbhw_term'
,
'angle_fbhw_term'
,
...
...
@@ -488,8 +488,8 @@ class DesmondDMSFile(object):
raise
NotImplementedError
(
'Drude particles are not currently supported'
)
def
close
(
self
):
'''
Close the SQL connection
'''
"""
Close the SQL connection
"""
if
self
.
_open
:
self
.
_conn
.
close
()
...
...
wrappers/python/simtk/openmm/app/forcefield.py
View file @
cf8a03e8
...
...
@@ -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 @
cf8a03e8
...
...
@@ -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
],
...
...
wrappers/python/simtk/openmm/app/internal/customgbforces.py
View file @
cf8a03e8
...
...
@@ -6,9 +6,9 @@ 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) 2012 University of Virginia and the Authors.
Portions copyright (c) 2012
-2014
University of Virginia and the Authors.
Authors: Christoph Klein, Michael R. Shirts
Contributors: Jason M. Swails
Contributors: Jason M. Swails
, Peter Eastman
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
...
...
@@ -31,7 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
from
__future__
import
division
from
simtk.openmm
import
CustomGBForce
from
simtk.openmm
import
CustomGBForce
,
Discrete1DFunction
d0
=
[
2.26685
,
2.32548
,
2.38397
,
2.44235
,
2.50057
,
2.55867
,
2.61663
,
2.67444
,
2.73212
,
2.78965
,
2.84705
,
2.9043
,
2.96141
,
3.0184
,
3.07524
,
3.13196
,
...
...
@@ -331,8 +331,8 @@ def GBSAGBnForce(solventDielectric=78.5, soluteDielectric=1, SA=None,
custom
.
addGlobalParameter
(
"neckScale"
,
0.361825
)
custom
.
addGlobalParameter
(
"neckCut"
,
0.68
)
custom
.
addFunction
(
"getd0"
,
d0
,
0
,
440
)
custom
.
addFunction
(
"getm0"
,
m0
,
0
,
440
)
custom
.
add
Tabulated
Function
(
"getd0"
,
Discrete1DFunction
(
d0
)
)
custom
.
add
Tabulated
Function
(
"getm0"
,
Discrete1DFunction
(
m0
)
)
custom
.
addComputedValue
(
"I"
,
"Ivdw+neckScale*Ineck;"
"Ineck=step(radius1+radius2+neckCut-r)*getm0(index)/(1+100*(r-getd0(index))^2+0.3*1000000*(r-getd0(index))^6);"
...
...
@@ -380,8 +380,8 @@ def GBSAGBn2Force(solventDielectric=78.5, soluteDielectric=1, SA=None,
custom
.
addGlobalParameter
(
"neckScale"
,
0.826836
)
custom
.
addGlobalParameter
(
"neckCut"
,
0.68
)
custom
.
addFunction
(
"getd0"
,
d0
,
0
,
440
)
custom
.
addFunction
(
"getm0"
,
m0
,
0
,
440
)
custom
.
add
Tabulated
Function
(
"getd0"
,
Discrete1DFunction
(
d0
)
)
custom
.
add
Tabulated
Function
(
"getm0"
,
Discrete1DFunction
(
m0
)
)
custom
.
addComputedValue
(
"I"
,
"Ivdw+neckScale*Ineck;"
"Ineck=step(radius1+radius2+neckCut-r)*getm0(index)/(1+100*(r-getd0(index))^2+0.3*1000000*(r-getd0(index))^6);"
...
...
Prev
1
…
6
7
8
9
10
11
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