Commit 58b6e3b6 authored by Andy Simmonett's avatar Andy Simmonett
Browse files

Merge branch 'master' of github.com:pandegroup/openmm into dpme

parents 7b66ba19 02e7a5d6
...@@ -772,7 +772,7 @@ class GromacsTopFile(object): ...@@ -772,7 +772,7 @@ class GromacsTopFile(object):
if periodic is None: if periodic is None:
periodic = mm.PeriodicTorsionForce() periodic = mm.PeriodicTorsionForce()
sys.addForce(periodic) sys.addForce(periodic)
periodic.addTorsion(baseAtomIndex+atoms[0], baseAtomIndex+atoms[1], baseAtomIndex+atoms[2], baseAtomIndex+atoms[3], int(params[7]), float(params[5])*degToRad, k) periodic.addTorsion(baseAtomIndex+atoms[0], baseAtomIndex+atoms[1], baseAtomIndex+atoms[2], baseAtomIndex+atoms[3], int(float(params[7])), float(params[5])*degToRad, k)
elif dihedralType == '2': elif dihedralType == '2':
# Harmonic torsion # Harmonic torsion
k = float(params[6]) k = float(params[6])
......
...@@ -186,8 +186,7 @@ class Modeller(object): ...@@ -186,8 +186,7 @@ class Modeller(object):
def convertWater(self, model='tip3p'): def convertWater(self, model='tip3p'):
"""Convert all water molecules to a different water model. """Convert all water molecules to a different water model.
@deprecated Use addExtraParticles() instead. It performs the same @deprecated Use addExtraParticles() instead. It performs the same function but in a more general way.
function but in a more general way.
Parameters Parameters
---------- ----------
...@@ -871,7 +870,7 @@ class Modeller(object): ...@@ -871,7 +870,7 @@ class Modeller(object):
# and causes hydrogens to spread out evenly. # and causes hydrogens to spread out evenly.
system = System() system = System()
nonbonded = CustomNonbondedForce('100/((r/0.1)^4+1)') nonbonded = CustomNonbondedForce('100/(r/0.1)^4')
nonbonded.setNonbondedMethod(CustomNonbondedForce.CutoffNonPeriodic); nonbonded.setNonbondedMethod(CustomNonbondedForce.CutoffNonPeriodic);
nonbonded.setCutoffDistance(1*nanometer) nonbonded.setCutoffDistance(1*nanometer)
bonds = HarmonicBondForce() bonds = HarmonicBondForce()
......
...@@ -74,6 +74,11 @@ def getNodeText(node): ...@@ -74,6 +74,11 @@ def getNodeText(node):
s = "%s%s\n\n" % (s, getNodeText(n)) s = "%s%s\n\n" % (s, getNodeText(n))
elif n.tag == "ref": elif n.tag == "ref":
s = "%s%s" % (s, getNodeText(n)) s = "%s%s" % (s, getNodeText(n))
elif n.tag == "xrefsect":
title = n.find("xreftitle")
description = n.find("xrefdescription")
if title is not None and description is not None and getNodeText(title).lower() == "deprecated":
s = "%s\n@deprecated %s\n\n" % (s, getNodeText(description))
else: else:
if n.tag in docTags: if n.tag in docTags:
tag = docTags[n.tag] tag = docTags[n.tag]
...@@ -242,6 +247,7 @@ class SwigInputBuilder: ...@@ -242,6 +247,7 @@ class SwigInputBuilder:
self.fOut.write("\n/* Declare factories */\n\n") self.fOut.write("\n/* Declare factories */\n\n")
forceSubclassList = [] forceSubclassList = []
integratorSubclassList = [] integratorSubclassList = []
tabulatedFunctionSubclassList = []
for classNode in findNodes(self.doc.getroot(), "compounddef", kind="class", prot="public"): for classNode in findNodes(self.doc.getroot(), "compounddef", kind="class", prot="public"):
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortClassName=stripOpenmmPrefix(className) shortClassName=stripOpenmmPrefix(className)
...@@ -256,6 +262,8 @@ class SwigInputBuilder: ...@@ -256,6 +262,8 @@ class SwigInputBuilder:
forceSubclassList.append(shortClassName) forceSubclassList.append(shortClassName)
elif baseName == 'OpenMM::Integrator': elif baseName == 'OpenMM::Integrator':
integratorSubclassList.append(shortClassName) integratorSubclassList.append(shortClassName)
elif baseName == 'OpenMM::TabulatedFunction':
tabulatedFunctionSubclassList.append(shortClassName)
self.fOut.write("%factory(OpenMM::Force& OpenMM::System::getForce") self.fOut.write("%factory(OpenMM::Force& OpenMM::System::getForce")
for name in sorted(forceSubclassList): for name in sorted(forceSubclassList):
...@@ -292,6 +300,16 @@ class SwigInputBuilder: ...@@ -292,6 +300,16 @@ class SwigInputBuilder:
self.fOut.write(",\n OpenMM::%s" % name) self.fOut.write(",\n OpenMM::%s" % name)
self.fOut.write(");\n\n") self.fOut.write(");\n\n")
self.fOut.write("%factory(OpenMM::TabulatedFunction* OpenMM::TabulatedFunction::__copy__")
for name in sorted(tabulatedFunctionSubclassList):
self.fOut.write(",\n OpenMM::%s" % name)
self.fOut.write(");\n\n")
self.fOut.write("%factory(OpenMM::TabulatedFunction* OpenMM_XmlSerializer__deserializeTabulatedFunction")
for name in sorted(tabulatedFunctionSubclassList):
self.fOut.write(",\n OpenMM::%s" % name)
self.fOut.write(");\n\n")
self.fOut.write("%factory(OpenMM::VirtualSite& OpenMM::System::getVirtualSite, OpenMM::TwoParticleAverageSite, OpenMM::ThreeParticleAverageSite, OpenMM::OutOfPlaneSite, OpenMM::LocalCoordinatesSite);\n\n") self.fOut.write("%factory(OpenMM::VirtualSite& OpenMM::System::getVirtualSite, OpenMM::TwoParticleAverageSite, OpenMM::ThreeParticleAverageSite, OpenMM::OutOfPlaneSite, OpenMM::LocalCoordinatesSite);\n\n")
self.fOut.write("\n") self.fOut.write("\n")
......
...@@ -322,14 +322,14 @@ Parameters: ...@@ -322,14 +322,14 @@ Parameters:
} }
%extend OpenMM::XmlSerializer { %extend OpenMM::XmlSerializer {
%feature(docstring, "This method exists only for backward compatibility. @deprecated Use serialize() instead.") serializeSystem; %feature(docstring, "This method exists only for backward compatibility.\n@deprecated Use serialize() instead.") serializeSystem;
static std::string serializeSystem(const OpenMM::System* object) { static std::string serializeSystem(const OpenMM::System* object) {
std::stringstream ss; std::stringstream ss;
OpenMM::XmlSerializer::serialize<OpenMM::System>(object, "System", ss); OpenMM::XmlSerializer::serialize<OpenMM::System>(object, "System", ss);
return ss.str(); return ss.str();
} }
%feature(docstring, "This method exists only for backward compatibility. @deprecated Use deserialize() instead.") deserializeSystem; %feature(docstring, "This method exists only for backward compatibility.\n@deprecated Use deserialize() instead.") deserializeSystem;
%newobject deserializeSystem; %newobject deserializeSystem;
static OpenMM::System* deserializeSystem(const char* inputString) { static OpenMM::System* deserializeSystem(const char* inputString) {
std::stringstream ss; std::stringstream ss;
...@@ -363,6 +363,19 @@ Parameters: ...@@ -363,6 +363,19 @@ Parameters:
return OpenMM::XmlSerializer::deserialize<OpenMM::Integrator>(ss); return OpenMM::XmlSerializer::deserialize<OpenMM::Integrator>(ss);
} }
static std::string _serializeTabulatedFunction(const OpenMM::TabulatedFunction* object) {
std::stringstream ss;
OpenMM::XmlSerializer::serialize<OpenMM::TabulatedFunction>(object, "TabulatedFunction", ss);
return ss.str();
}
%newobject _deserializeTabulatedFunction;
static OpenMM::TabulatedFunction* _deserializeTabulatedFunction(const char* inputString) {
std::stringstream ss;
ss << inputString;
return OpenMM::XmlSerializer::deserialize<OpenMM::TabulatedFunction>(ss);
}
static std::string _serializeStateAsLists( static std::string _serializeStateAsLists(
const std::vector<Vec3>& pos, const std::vector<Vec3>& pos,
const std::vector<Vec3>& vel, const std::vector<Vec3>& vel,
...@@ -463,6 +476,8 @@ Parameters: ...@@ -463,6 +476,8 @@ Parameters:
return XmlSerializer._serializeIntegrator(object) return XmlSerializer._serializeIntegrator(object)
elif isinstance(object, State): elif isinstance(object, State):
return XmlSerializer._serializeState(object) return XmlSerializer._serializeState(object)
elif isinstance(object, TabulatedFunction):
return XmlSerializer._serializeTabulatedFunction(object)
raise ValueError("Unsupported object type") raise ValueError("Unsupported object type")
@staticmethod @staticmethod
...@@ -481,6 +496,8 @@ Parameters: ...@@ -481,6 +496,8 @@ Parameters:
return XmlSerializer._deserializeIntegrator(inputString) return XmlSerializer._deserializeIntegrator(inputString)
if type == "State": if type == "State":
return XmlSerializer._deserializeState(inputString) return XmlSerializer._deserializeState(inputString)
if type == "TabulatedFunction":
return XmlSerializer._deserializeTabulatedFunction(inputString)
raise ValueError("Unsupported object type") raise ValueError("Unsupported object type")
%} %}
} }
...@@ -530,3 +547,22 @@ Parameters: ...@@ -530,3 +547,22 @@ Parameters:
return OpenMM::XmlSerializer::clone<OpenMM::Integrator>(*self); return OpenMM::XmlSerializer::clone<OpenMM::Integrator>(*self);
} }
} }
%extend OpenMM::TabulatedFunction {
%pythoncode %{
def __getstate__(self):
serializationString = XmlSerializer.serialize(self)
return serializationString
def __setstate__(self, serializationString):
system = XmlSerializer.deserialize(serializationString)
self.this = system.this
def __deepcopy__(self, memo):
return self.__copy__()
%}
%newobject __copy__;
OpenMM::TabulatedFunction* __copy__() {
return OpenMM::XmlSerializer::clone<OpenMM::TabulatedFunction>(*self);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment