Commit 9f206616 authored by peastman's avatar peastman
Browse files

Merge pull request #126 from peastman/master

Minor enhancements and bug fixes
parents e76fe9c2 808504df
...@@ -5752,7 +5752,7 @@ void CudaRemoveCMMotionKernel::initialize(const System& system, const CMMotionRe ...@@ -5752,7 +5752,7 @@ void CudaRemoveCMMotionKernel::initialize(const System& system, const CMMotionRe
for (int i = 0; i < numAtoms; i++) for (int i = 0; i < numAtoms; i++)
totalMass += system.getParticleMass(i); totalMass += system.getParticleMass(i);
map<string, string> defines; map<string, string> defines;
defines["INVERSE_TOTAL_MASS"] = cu.doubleToString(1.0/totalMass); defines["INVERSE_TOTAL_MASS"] = cu.doubleToString(totalMass == 0 ? 0.0 : 1.0/totalMass);
CUmodule module = cu.createModule(CudaKernelSources::removeCM, defines); CUmodule module = cu.createModule(CudaKernelSources::removeCM, defines);
kernel1 = cu.getKernel(module, "calcCenterOfMassMomentum"); kernel1 = cu.getKernel(module, "calcCenterOfMassMomentum");
kernel2 = cu.getKernel(module, "removeCenterOfMassMomentum"); kernel2 = cu.getKernel(module, "removeCenterOfMassMomentum");
......
...@@ -5978,7 +5978,7 @@ void OpenCLRemoveCMMotionKernel::initialize(const System& system, const CMMotion ...@@ -5978,7 +5978,7 @@ void OpenCLRemoveCMMotionKernel::initialize(const System& system, const CMMotion
for (int i = 0; i < numAtoms; i++) for (int i = 0; i < numAtoms; i++)
totalMass += system.getParticleMass(i); totalMass += system.getParticleMass(i);
map<string, string> defines; map<string, string> defines;
defines["INVERSE_TOTAL_MASS"] = cl.doubleToString(1.0/totalMass); defines["INVERSE_TOTAL_MASS"] = cl.doubleToString(totalMass == 0 ? 0.0 : 1.0/totalMass);
cl::Program program = cl.createProgram(OpenCLKernelSources::removeCM, defines); cl::Program program = cl.createProgram(OpenCLKernelSources::removeCM, defines);
kernel1 = cl::Kernel(program, "calcCenterOfMassMomentum"); kernel1 = cl::Kernel(program, "calcCenterOfMassMomentum");
kernel1.setArg<cl_int>(0, numAtoms); kernel1.setArg<cl_int>(0, numAtoms);
......
...@@ -70,7 +70,10 @@ class PDBFile(object): ...@@ -70,7 +70,10 @@ class PDBFile(object):
# Load the PDB file # Load the PDB file
pdb = PdbStructure(open(file), load_all_models=True) inputfile = file
if isinstance(file, str):
inputfile = open(file)
pdb = PdbStructure(inputfile, load_all_models=True)
PDBFile._loadNameReplacementTables() PDBFile._loadNameReplacementTables()
# Build the topology # Build the topology
...@@ -140,7 +143,8 @@ class PDBFile(object): ...@@ -140,7 +143,8 @@ class PDBFile(object):
for connect in pdb.models[0].connects: for connect in pdb.models[0].connects:
i = connect[0] i = connect[0]
for j in connect[1:]: for j in connect[1:]:
connectBonds.append((atomByNumber[i], atomByNumber[j])) if i in atomByNumber and j in atomByNumber:
connectBonds.append((atomByNumber[i], atomByNumber[j]))
if len(connectBonds) > 0: if len(connectBonds) > 0:
# Only add bonds that don't already exist. # Only add bonds that don't already exist.
existingBonds = set(top.bonds()) existingBonds = set(top.bonds())
......
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