Commit 6457307f authored by cmaffeo2's avatar cmaffeo2
Browse files

arbdmodel now preserves particle order

parent 47414bcf
......@@ -491,8 +491,8 @@ class ArbdModel(PdbModel):
def _updateParticleOrder(self):
## Create ordered list
particles = [p for p in self]
self.particles = sorted(particles, key=lambda p: (p.type_, p.idx))
self.particles = [p for p in self]
# self.particles = sorted(particles, key=lambda p: (p.type_, p.idx))
## Update particle indices
for p,i in zip(self.particles,range(len(self.particles))):
......@@ -509,7 +509,7 @@ class ArbdModel(PdbModel):
assert(type(gpu) is int)
numSteps = int(numSteps)
if self.cacheUpToDate == False:
if self.cacheUpToDate == False: # TODO: remove cache?
self._countParticleTypes()
self._updateParticleOrder()
......@@ -566,7 +566,8 @@ class ArbdModel(PdbModel):
self._dihedral_filename = "%s/%s.dihedrals.txt" % (d, prefix)
self._exclusion_filename = "%s/%s.exculsions.txt" % (d, prefix)
self._writeArbdCoordFile( prefix + ".coord.txt" )
# self._writeArbdCoordFile( prefix + ".coord.txt" )
self._writeArbdParticleFile( prefix + ".particles.txt" )
self._writeArbdBondFile()
self._writeArbdAngleFile()
self._writeArbdDihedralFile()
......@@ -574,10 +575,17 @@ class ArbdModel(PdbModel):
self._writeArbdPotentialFiles( prefix, directory = d )
self._writeArbdConf( prefix, numSteps=numSteps, outputPeriod=outputPeriod )
def _writeArbdCoordFile(self, filename):
# def _writeArbdCoordFile(self, filename):
# with open(filename,'w') as fh:
# for p in self.particles:
# fh.write("%f %f %f\n" % tuple(x for x in p.collapsedPosition()))
def _writeArbdParticleFile(self, filename):
with open(filename,'w') as fh:
for p in self.particles:
fh.write("%f %f %f\n" % tuple(x for x in p.collapsedPosition()))
data = tuple([p.idx,p.name] + [x for x in p.collapsedPosition()])
fh.write("ATOM %d %s %f %f %f\n" % data)
def _writeArbdConf(self, prefix, randomSeed=None, numSteps=100000000, outputPeriod=10000, restartCoordinateFile=None):
## TODO: raise exception if _writeArbdPotentialFiles has not been called
......@@ -592,7 +600,8 @@ class ArbdModel(PdbModel):
params['randomSeed'] = "seed %s" % randomSeed
params['numSteps'] = int(numSteps)
params['coordinateFile'] = "%s.coord.txt" % prefix
# params['coordinateFile'] = "%s.coord.txt" % prefix
params['particleFile'] = "%s.particles.txt" % prefix
if restartCoordinateFile is None:
params['restartCoordinates'] = ""
else:
......@@ -646,7 +655,7 @@ diffusion {diffusivity}
## Write coordinates and interactions
fh.write("""
## Input coordinates
inputCoordinates {coordinateFile}
inputParticles {particleFile}
{restartCoordinates}
## Interaction potentials
......
Supports Markdown
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