Unverified Commit 3aa4bb8c authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Code cleanup (#3014)

parent 84a93cf8
...@@ -12,7 +12,6 @@ import os.path ...@@ -12,7 +12,6 @@ import os.path
import shutil import shutil
import time import time
from glob import glob from glob import glob
from os.path import join, exists
from subprocess import call from subprocess import call
from argparse import ArgumentParser from argparse import ArgumentParser
from datetime import datetime, timedelta from datetime import datetime, timedelta
......
...@@ -2,7 +2,6 @@ from __future__ import print_function ...@@ -2,7 +2,6 @@ from __future__ import print_function
import openmm.app as app import openmm.app as app
import openmm as mm import openmm as mm
import openmm.unit as unit import openmm.unit as unit
import sys
from datetime import datetime from datetime import datetime
import os import os
from argparse import ArgumentParser from argparse import ArgumentParser
...@@ -68,8 +67,6 @@ def runOneTest(testName, options): ...@@ -68,8 +67,6 @@ def runOneTest(testName, options):
else: else:
ff = app.ForceField('amoeba2009.xml', 'amoeba2009_gk.xml') ff = app.ForceField('amoeba2009.xml', 'amoeba2009_gk.xml')
pdb = app.PDBFile('5dfr_minimized.pdb') pdb = app.PDBFile('5dfr_minimized.pdb')
cutoff = 2.0*unit.nanometers
vdwCutoff = 1.2*unit.nanometers
system = ff.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, constraints=constraints, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) system = ff.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, constraints=constraints, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization)
for f in system.getForces(): for f in system.getForces():
if isinstance(f, mm.AmoebaMultipoleForce) or isinstance(f, mm.AmoebaVdwForce) or isinstance(f, mm.AmoebaGeneralizedKirkwoodForce) or isinstance(f, mm.AmoebaWcaDispersionForce): if isinstance(f, mm.AmoebaMultipoleForce) or isinstance(f, mm.AmoebaVdwForce) or isinstance(f, mm.AmoebaGeneralizedKirkwoodForce) or isinstance(f, mm.AmoebaWcaDispersionForce):
...@@ -86,7 +83,6 @@ def runOneTest(testName, options): ...@@ -86,7 +83,6 @@ def runOneTest(testName, options):
fileName = names[testName] fileName = names[testName]
prmtop = app.AmberPrmtopFile(os.path.join(dirname, f'PME/Topologies/{fileName}.prmtop')) prmtop = app.AmberPrmtopFile(os.path.join(dirname, f'PME/Topologies/{fileName}.prmtop'))
inpcrd = app.AmberInpcrdFile(os.path.join(dirname, f'PME/Coordinates/{fileName}.inpcrd')) inpcrd = app.AmberInpcrdFile(os.path.join(dirname, f'PME/Coordinates/{fileName}.inpcrd'))
topology = prmtop.topology
positions = inpcrd.positions positions = inpcrd.positions
dt = 0.004*unit.picoseconds dt = 0.004*unit.picoseconds
method = app.PME method = app.PME
......
from openmm.app import * from openmm.app import *
from openmm import * from openmm import *
from openmm.unit import * from openmm.unit import *
from sys import stdout, exit, stderr from sys import stdout
# Read the PSF # Read the PSF
psf = CharmmPsfFile('ala_ala_ala.psf') psf = CharmmPsfFile('ala_ala_ala.psf')
......
...@@ -40,25 +40,25 @@ ComputeParameterSet::ComputeParameterSet(ComputeContext& context, int numParamet ...@@ -40,25 +40,25 @@ ComputeParameterSet::ComputeParameterSet(ComputeContext& context, int numParamet
string elementType = (useDoublePrecision ? "double" : "float"); string elementType = (useDoublePrecision ? "double" : "float");
if (!arrayPerParameter) { if (!arrayPerParameter) {
while (params > 2) { while (params > 2) {
std::stringstream name; std::stringstream arrayName;
name << "param" << (++bufferCount); arrayName << "param" << (++bufferCount);
arrays.push_back(context.createArray()); arrays.push_back(context.createArray());
arrays.back()->initialize(context, numObjects, elementSize*4, name.str()); arrays.back()->initialize(context, numObjects, elementSize*4, arrayName.str());
params -= 4; params -= 4;
} }
if (params > 1) { if (params > 1) {
std::stringstream name; std::stringstream arrayName;
name << "param" << (++bufferCount); arrayName << "param" << (++bufferCount);
arrays.push_back(context.createArray()); arrays.push_back(context.createArray());
arrays.back()->initialize(context, numObjects, elementSize*2, name.str()); arrays.back()->initialize(context, numObjects, elementSize*2, arrayName.str());
params -= 2; params -= 2;
} }
} }
while (params > 0) { while (params > 0) {
std::stringstream name; std::stringstream arrayName;
name << "param" << (++bufferCount); arrayName << "param" << (++bufferCount);
arrays.push_back(context.createArray()); arrays.push_back(context.createArray());
arrays.back()->initialize(context, numObjects, elementSize, name.str()); arrays.back()->initialize(context, numObjects, elementSize, arrayName.str());
params--; params--;
} }
for (ArrayInterface* array : arrays) for (ArrayInterface* array : arrays)
......
...@@ -159,8 +159,8 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec ...@@ -159,8 +159,8 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec
if (atom != -1) if (atom != -1)
throw OpenMMException("CpuBondForce: Internal error: atoms assigned to threads incorrectly"); throw OpenMMException("CpuBondForce: Internal error: atoms assigned to threads incorrectly");
atom = thread; atom = thread;
for (int bond : atomBonds[atom]) for (int bondIndex : atomBonds[atom])
candidateBonds.push_back(bond); candidateBonds.push_back(bondIndex);
} }
} }
......
...@@ -51,7 +51,7 @@ class OPENMM_EXPORT ReferenceBondIxn { ...@@ -51,7 +51,7 @@ class OPENMM_EXPORT ReferenceBondIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
~ReferenceBondIxn(); virtual ~ReferenceBondIxn();
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
......
...@@ -4894,7 +4894,7 @@ AmoebaReferencePmeMultipoleForce::~AmoebaReferencePmeMultipoleForce() ...@@ -4894,7 +4894,7 @@ AmoebaReferencePmeMultipoleForce::~AmoebaReferencePmeMultipoleForce()
fftpack_destroy(_fftplan); fftpack_destroy(_fftplan);
} }
if (_pmeGrid) { if (_pmeGrid) {
delete _pmeGrid; delete[] _pmeGrid;
} }
}; };
...@@ -4980,7 +4980,7 @@ void AmoebaReferencePmeMultipoleForce::resizePmeArrays() ...@@ -4980,7 +4980,7 @@ void AmoebaReferencePmeMultipoleForce::resizePmeArrays()
_totalGridSize = _pmeGridDimensions[0]*_pmeGridDimensions[1]*_pmeGridDimensions[2]; _totalGridSize = _pmeGridDimensions[0]*_pmeGridDimensions[1]*_pmeGridDimensions[2];
if (_pmeGridSize < _totalGridSize) { if (_pmeGridSize < _totalGridSize) {
if (_pmeGrid) { if (_pmeGrid) {
delete _pmeGrid; delete[] _pmeGrid;
} }
_pmeGrid = new t_complex[_totalGridSize]; _pmeGrid = new t_complex[_totalGridSize];
_pmeGridSize = _totalGridSize; _pmeGridSize = _totalGridSize;
......
from __future__ import print_function from __future__ import print_function
import sys, os import sys, os
import time
import getopt
import re import re
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
...@@ -97,7 +95,7 @@ class WrapperGenerator: ...@@ -97,7 +95,7 @@ class WrapperGenerator:
self.findBaseNodes(node, orderedClassNodes) self.findBaseNodes(node, orderedClassNodes)
return orderedClassNodes return orderedClassNodes
def findBaseNodes(self, node, excludedClassNodes=[]): def findBaseNodes(self, node, excludedClassNodes):
if node in excludedClassNodes: if node in excludedClassNodes:
return return
if node.attrib['prot'] == 'private': if node.attrib['prot'] == 'private':
...@@ -114,7 +112,6 @@ class WrapperGenerator: ...@@ -114,7 +112,6 @@ class WrapperGenerator:
def getClassMethods(self, classNode): def getClassMethods(self, classNode):
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
methodList = [] methodList = []
for section in findNodes(classNode, "sectiondef", kind="public-static-func")+findNodes(classNode, "sectiondef", kind="public-func"): for section in findNodes(classNode, "sectiondef", kind="public-static-func")+findNodes(classNode, "sectiondef", kind="public-func"):
for memberNode in findNodes(section, "memberdef", kind="function", prot="public"): for memberNode in findNodes(section, "memberdef", kind="function", prot="public"):
...@@ -202,7 +199,6 @@ class CHeaderGenerator(WrapperGenerator): ...@@ -202,7 +199,6 @@ class CHeaderGenerator(WrapperGenerator):
for node in findNodes(section, "memberdef", kind="enum", prot="public"): for node in findNodes(section, "memberdef", kind="enum", prot="public"):
enumNodes.append(node) enumNodes.append(node)
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className) typeName = convertOpenMMPrefix(className)
for enumNode in enumNodes: for enumNode in enumNodes:
enumName = getText("name", enumNode) enumName = getText("name", enumNode)
...@@ -1023,7 +1019,6 @@ class FortranSourceGenerator(WrapperGenerator): ...@@ -1023,7 +1019,6 @@ class FortranSourceGenerator(WrapperGenerator):
def writeOneConstructor(self, classNode, methodNode, functionName, wrapperFunctionName): def writeOneConstructor(self, classNode, methodNode, functionName, wrapperFunctionName):
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className) typeName = convertOpenMMPrefix(className)
self.out.write("OPENMM_EXPORT_AMOEBA void %s(%s*& result" % (wrapperFunctionName, typeName)) self.out.write("OPENMM_EXPORT_AMOEBA void %s(%s*& result" % (wrapperFunctionName, typeName))
self.writeArguments(methodNode, True) self.writeArguments(methodNode, True)
...@@ -1049,8 +1044,6 @@ class FortranSourceGenerator(WrapperGenerator): ...@@ -1049,8 +1044,6 @@ class FortranSourceGenerator(WrapperGenerator):
returnType = self.getType(methodType) returnType = self.getType(methodType)
hasReturnValue = (returnType in ('int', 'bool', 'double')) hasReturnValue = (returnType in ('int', 'bool', 'double'))
hasReturnArg = not (hasReturnValue or returnType == 'void') hasReturnArg = not (hasReturnValue or returnType == 'void')
if methodType in self.classesByShortName:
methodType = self.classesByShortName[methodType]
self.out.write("OPENMM_EXPORT_AMOEBA ") self.out.write("OPENMM_EXPORT_AMOEBA ")
if hasReturnValue: if hasReturnValue:
self.out.write(returnType) self.out.write(returnType)
...@@ -1069,7 +1062,7 @@ class FortranSourceGenerator(WrapperGenerator): ...@@ -1069,7 +1062,7 @@ class FortranSourceGenerator(WrapperGenerator):
returnArg = 'char* result' returnArg = 'char* result'
else: else:
returnArg = "%s& result" % returnType returnArg = "%s& result" % returnType
numArgs = self.writeArguments(methodNode, isInstanceMethod, returnArg) self.writeArguments(methodNode, isInstanceMethod, returnArg)
if hasReturnArg and returnType == 'const char*': if hasReturnArg and returnType == 'const char*':
self.out.write(", int result_length") self.out.write(", int result_length")
self.out.write(") {\n") self.out.write(") {\n")
......
...@@ -64,12 +64,12 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod ...@@ -64,12 +64,12 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod
int p1, p2, p3; int p1, p2, p3;
vector<double> params; vector<double> params;
force.getAngleParameters(i, p1, p2, p3, params); force.getAngleParameters(i, p1, p2, p3, params);
SerializationNode& node = angles.createChildNode("Angle").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3); SerializationNode& angle = angles.createChildNode("Angle").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3);
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); angle.setDoubleProperty(key.str(), params[j]);
} }
} }
} }
......
...@@ -64,12 +64,12 @@ void CustomBondForceProxy::serialize(const void* object, SerializationNode& node ...@@ -64,12 +64,12 @@ void CustomBondForceProxy::serialize(const void* object, SerializationNode& node
int p1, p2; int p1, p2;
vector<double> params; vector<double> params;
force.getBondParameters(i, p1, p2, params); force.getBondParameters(i, p1, p2, params);
SerializationNode& node = bonds.createChildNode("Bond").setIntProperty("p1", p1).setIntProperty("p2", p2); SerializationNode& bond = bonds.createChildNode("Bond").setIntProperty("p1", p1).setIntProperty("p2", p2);
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); bond.setDoubleProperty(key.str(), params[j]);
} }
} }
} }
......
...@@ -56,8 +56,8 @@ void CustomCVForceProxy::serialize(const void* object, SerializationNode& node) ...@@ -56,8 +56,8 @@ void CustomCVForceProxy::serialize(const void* object, SerializationNode& node)
} }
SerializationNode& cvs = node.createChildNode("CollectiveVariables"); SerializationNode& cvs = node.createChildNode("CollectiveVariables");
for (int i = 0; i < force.getNumCollectiveVariables(); i++) { for (int i = 0; i < force.getNumCollectiveVariables(); i++) {
SerializationNode& node = cvs.createChildNode("CollectiveVariable").setStringProperty("name", force.getCollectiveVariableName(i)); SerializationNode& cv = cvs.createChildNode("CollectiveVariable").setStringProperty("name", force.getCollectiveVariableName(i));
node.createChildNode("Force", &force.getCollectiveVariable(i)); cv.createChildNode("Force", &force.getCollectiveVariable(i));
} }
SerializationNode& functions = node.createChildNode("Functions"); SerializationNode& functions = node.createChildNode("Functions");
for (int i = 0; i < force.getNumTabulatedFunctions(); i++) for (int i = 0; i < force.getNumTabulatedFunctions(); i++)
......
...@@ -78,18 +78,18 @@ void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNo ...@@ -78,18 +78,18 @@ void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNo
vector<int> groups; vector<int> groups;
vector<double> params; vector<double> params;
force.getBondParameters(i, groups, params); force.getBondParameters(i, groups, params);
SerializationNode& node = bonds.createChildNode("Bond"); SerializationNode& bond = bonds.createChildNode("Bond");
for (int j = 0; j < (int) groups.size(); j++) { for (int j = 0; j < (int) groups.size(); j++) {
stringstream key; stringstream key;
key << "g"; key << "g";
key << j+1; key << j+1;
node.setIntProperty(key.str(), groups[j]); bond.setIntProperty(key.str(), groups[j]);
} }
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); bond.setDoubleProperty(key.str(), params[j]);
} }
} }
SerializationNode& functions = node.createChildNode("Functions"); SerializationNode& functions = node.createChildNode("Functions");
......
...@@ -65,18 +65,18 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo ...@@ -65,18 +65,18 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo
vector<int> particles; vector<int> particles;
vector<double> params; vector<double> params;
force.getBondParameters(i, particles, params); force.getBondParameters(i, particles, params);
SerializationNode& node = bonds.createChildNode("Bond"); SerializationNode& bond = bonds.createChildNode("Bond");
for (int j = 0; j < (int) particles.size(); j++) { for (int j = 0; j < (int) particles.size(); j++) {
stringstream key; stringstream key;
key << "p"; key << "p";
key << j+1; key << j+1;
node.setIntProperty(key.str(), particles[j]); bond.setIntProperty(key.str(), particles[j]);
} }
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); bond.setDoubleProperty(key.str(), params[j]);
} }
} }
SerializationNode& functions = node.createChildNode("Functions"); SerializationNode& functions = node.createChildNode("Functions");
......
...@@ -56,15 +56,15 @@ void CustomExternalForceProxy::serialize(const void* object, SerializationNode& ...@@ -56,15 +56,15 @@ void CustomExternalForceProxy::serialize(const void* object, SerializationNode&
} }
SerializationNode& particles = node.createChildNode("Particles"); SerializationNode& particles = node.createChildNode("Particles");
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
int particle; int particleIndex;
vector<double> params; vector<double> params;
force.getParticleParameters(i, particle, params); force.getParticleParameters(i, particleIndex, params);
SerializationNode& node = particles.createChildNode("Particle").setIntProperty("index", particle); SerializationNode& particle = particles.createChildNode("Particle").setIntProperty("index", particleIndex);
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); particle.setDoubleProperty(key.str(), params[j]);
} }
} }
} }
......
...@@ -77,12 +77,12 @@ void CustomGBForceProxy::serialize(const void* object, SerializationNode& node) ...@@ -77,12 +77,12 @@ void CustomGBForceProxy::serialize(const void* object, SerializationNode& node)
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
vector<double> params; vector<double> params;
force.getParticleParameters(i, params); force.getParticleParameters(i, params);
SerializationNode& node = particles.createChildNode("Particle"); SerializationNode& particle = particles.createChildNode("Particle");
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); particle.setDoubleProperty(key.str(), params[j]);
} }
} }
SerializationNode& exclusions = node.createChildNode("Exclusions"); SerializationNode& exclusions = node.createChildNode("Exclusions");
......
...@@ -65,12 +65,12 @@ void CustomHbondForceProxy::serialize(const void* object, SerializationNode& nod ...@@ -65,12 +65,12 @@ void CustomHbondForceProxy::serialize(const void* object, SerializationNode& nod
int p1, p2, p3; int p1, p2, p3;
vector<double> params; vector<double> params;
force.getDonorParameters(i, p1, p2, p3, params); force.getDonorParameters(i, p1, p2, p3, params);
SerializationNode& node = donors.createChildNode("Donor").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3); SerializationNode& donor = donors.createChildNode("Donor").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3);
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); donor.setDoubleProperty(key.str(), params[j]);
} }
} }
SerializationNode& acceptors = node.createChildNode("Acceptors"); SerializationNode& acceptors = node.createChildNode("Acceptors");
...@@ -78,12 +78,12 @@ void CustomHbondForceProxy::serialize(const void* object, SerializationNode& nod ...@@ -78,12 +78,12 @@ void CustomHbondForceProxy::serialize(const void* object, SerializationNode& nod
int p1, p2, p3; int p1, p2, p3;
vector<double> params; vector<double> params;
force.getAcceptorParameters(i, p1, p2, p3, params); force.getAcceptorParameters(i, p1, p2, p3, params);
SerializationNode& node = acceptors.createChildNode("Acceptor").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3); SerializationNode& acceptor = acceptors.createChildNode("Acceptor").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3);
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); acceptor.setDoubleProperty(key.str(), params[j]);
} }
} }
SerializationNode& exclusions = node.createChildNode("Exclusions"); SerializationNode& exclusions = node.createChildNode("Exclusions");
......
...@@ -63,13 +63,13 @@ void CustomManyParticleForceProxy::serialize(const void* object, SerializationNo ...@@ -63,13 +63,13 @@ void CustomManyParticleForceProxy::serialize(const void* object, SerializationNo
vector<double> params; vector<double> params;
int type; int type;
force.getParticleParameters(i, params, type); force.getParticleParameters(i, params, type);
SerializationNode& node = particles.createChildNode("Particle"); SerializationNode& particle = particles.createChildNode("Particle");
node.setIntProperty("type", type); particle.setIntProperty("type", type);
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); particle.setDoubleProperty(key.str(), params[j]);
} }
} }
SerializationNode& exclusions = node.createChildNode("Exclusions"); SerializationNode& exclusions = node.createChildNode("Exclusions");
......
...@@ -67,12 +67,12 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode& ...@@ -67,12 +67,12 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode&
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
vector<double> params; vector<double> params;
force.getParticleParameters(i, params); force.getParticleParameters(i, params);
SerializationNode& node = particles.createChildNode("Particle"); SerializationNode& particle = particles.createChildNode("Particle");
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); particle.setDoubleProperty(key.str(), params[j]);
} }
} }
SerializationNode& exclusions = node.createChildNode("Exclusions"); SerializationNode& exclusions = node.createChildNode("Exclusions");
......
...@@ -64,12 +64,12 @@ void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& n ...@@ -64,12 +64,12 @@ void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& n
int p1, p2, p3, p4; int p1, p2, p3, p4;
vector<double> params; vector<double> params;
force.getTorsionParameters(i, p1, p2, p3, p4, params); force.getTorsionParameters(i, p1, p2, p3, p4, params);
SerializationNode& node = torsions.createChildNode("Torsion").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3).setIntProperty("p4", p4); SerializationNode& torsion = torsions.createChildNode("Torsion").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3).setIntProperty("p4", p4);
for (int j = 0; j < (int) params.size(); j++) { for (int j = 0; j < (int) params.size(); j++) {
stringstream key; stringstream key;
key << "param"; key << "param";
key << j+1; key << j+1;
node.setDoubleProperty(key.str(), params[j]); torsion.setDoubleProperty(key.str(), params[j]);
} }
} }
} }
......
from __future__ import print_function from __future__ import print_function
import sys, os import sys, os
import time
import getopt
import re import re
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
...@@ -110,7 +108,7 @@ class WrapperGenerator: ...@@ -110,7 +108,7 @@ class WrapperGenerator:
self.findBaseNodes(node, orderedClassNodes) self.findBaseNodes(node, orderedClassNodes)
return orderedClassNodes return orderedClassNodes
def findBaseNodes(self, node, excludedClassNodes=[]): def findBaseNodes(self, node, excludedClassNodes):
if node in excludedClassNodes: if node in excludedClassNodes:
return return
if node.attrib['prot'] == 'private': if node.attrib['prot'] == 'private':
...@@ -127,7 +125,6 @@ class WrapperGenerator: ...@@ -127,7 +125,6 @@ class WrapperGenerator:
def getClassMethods(self, classNode): def getClassMethods(self, classNode):
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
methodList = [] methodList = []
for section in findNodes(classNode, "sectiondef", kind="public-static-func")+findNodes(classNode, "sectiondef", kind="public-func"): for section in findNodes(classNode, "sectiondef", kind="public-static-func")+findNodes(classNode, "sectiondef", kind="public-func"):
for memberNode in findNodes(section, "memberdef", kind="function", prot="public"): for memberNode in findNodes(section, "memberdef", kind="function", prot="public"):
...@@ -211,7 +208,6 @@ class CHeaderGenerator(WrapperGenerator): ...@@ -211,7 +208,6 @@ class CHeaderGenerator(WrapperGenerator):
for node in findNodes(section, "memberdef", kind="enum", prot="public"): for node in findNodes(section, "memberdef", kind="enum", prot="public"):
enumNodes.append(node) enumNodes.append(node)
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className) typeName = convertOpenMMPrefix(className)
for enumNode in enumNodes: for enumNode in enumNodes:
enumName = getText("name", enumNode) enumName = getText("name", enumNode)
...@@ -1590,7 +1586,6 @@ class FortranSourceGenerator(WrapperGenerator): ...@@ -1590,7 +1586,6 @@ class FortranSourceGenerator(WrapperGenerator):
def writeOneConstructor(self, classNode, methodNode, functionName, wrapperFunctionName): def writeOneConstructor(self, classNode, methodNode, functionName, wrapperFunctionName):
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className) typeName = convertOpenMMPrefix(className)
self.out.write("OPENMM_EXPORT void %s(%s*& result" % (wrapperFunctionName, typeName)) self.out.write("OPENMM_EXPORT void %s(%s*& result" % (wrapperFunctionName, typeName))
self.writeArguments(methodNode, True) self.writeArguments(methodNode, True)
...@@ -1616,8 +1611,6 @@ class FortranSourceGenerator(WrapperGenerator): ...@@ -1616,8 +1611,6 @@ class FortranSourceGenerator(WrapperGenerator):
returnType = self.getType(methodType) returnType = self.getType(methodType)
hasReturnValue = (returnType in ('int', 'bool', 'double')) hasReturnValue = (returnType in ('int', 'bool', 'double'))
hasReturnArg = not (hasReturnValue or returnType == 'void') hasReturnArg = not (hasReturnValue or returnType == 'void')
if methodType in self.classesByShortName:
methodType = self.classesByShortName[methodType]
self.out.write("OPENMM_EXPORT ") self.out.write("OPENMM_EXPORT ")
if hasReturnValue: if hasReturnValue:
self.out.write(returnType) self.out.write(returnType)
...@@ -1636,7 +1629,7 @@ class FortranSourceGenerator(WrapperGenerator): ...@@ -1636,7 +1629,7 @@ class FortranSourceGenerator(WrapperGenerator):
returnArg = 'char* result' returnArg = 'char* result'
else: else:
returnArg = "%s& result" % returnType returnArg = "%s& result" % returnType
numArgs = self.writeArguments(methodNode, isInstanceMethod, returnArg) self.writeArguments(methodNode, isInstanceMethod, returnArg)
if hasReturnArg and returnType == 'const char*': if hasReturnArg and returnType == 'const char*':
self.out.write(", int result_length") self.out.write(", int result_length")
self.out.write(") {\n") self.out.write(") {\n")
......
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