--- /home/sjplimp/oldpizza/src/dump.py 2005-09-07 10:13:09.000000000 -0600 +++ /home/sjplimp/pizza/src/dump.py 2005-10-18 08:50:17.000000000 -0600 @@ -106,8 +106,8 @@ index,time,flag = d.iterator(0/1) loop over dump snapshots time,box,atoms,bonds,tris = d.viz(index) return list of viz objects d.atype = "color" set column returned as "type" by viz -d.bonds("dump.bond") read bond list from dump file -d.bonds(data) extract bond list from data object +d.extra("dump.bond") read bond list from dump file +d.extra(data) extract bond/tri list from data iterator() loops over selected timesteps iterator() called with arg = 0 first time, with arg = 1 on subsequent calls @@ -118,11 +118,12 @@ time = timestep value box = [xlo,ylo,zlo,xhi,yhi,zhi] atoms = id,type,x,y,z for each atom as 2d array - bonds = id,type,x1,y1,z1,x2,y2,z1,t1,t2 for each bond as 2d array + bonds = id,type,x1,y1,z1,x2,y2,z2,t1,t2 for each bond as 2d array if bonds() was used to define bonds, else empty list - tris = empty list of triangles + tris = id,type,x1,y1,z1,x2,y2,z2,x3,y3,z3,nx,ny,nz for each tri as 2d array + if extra() was used to define tris, else empty list atype is column name viz() will return as atom type (def = "type") - bonds() stores list of bonds to return each time viz() is called + extra() stores list of bonds/tris to return each time viz() is called """ # History @@ -149,7 +150,10 @@ # aselect = class for atom selection # atype = name of vector used as atom type by viz extract # bondflag = 0 if no bonds, 1 if they are defined -# bondlist = list of bonds for all snapshots [(id,type,atom1,atom2),...] +# bondlist = list of bonds to viz() return for all snapshots +# only a list of atom pairs, coords have to be created for each snapshot +# triflag = 0 if no tris, 1 if they are defined +# trilist = list of tris to viz() return for all snapshots # Snap = one snapshot # time = time stamp # tselect = 0/1 if this snapshot selected @@ -164,6 +168,7 @@ import sys, commands, re, glob, types from os import popen from math import * # any function could be used by set() +from copy import deepcopy import Numeric try: from DEFAULTS import PIZZA_GUNZIP @@ -184,6 +189,8 @@ self.atype = "type" self.bondflag = 0 self.bondlist = [] + self.triflag = 0 + self.trilist = [] # flist = list of all dump file names @@ -819,18 +826,17 @@ atom = snap.atoms[i] atoms.append([atom[id],atom[type],atom[x],atom[y],atom[z]]) - # need Numeric mode here # create list of current bond coords from static bondlist # alist = dictionary of atom IDs for atoms list - # lookup bond atom IDs in alist - # try is used since some may not be there (due to atom selection) - # those bonds are not returned to viz caller + # lookup bond atom IDs in alist and grab their coords + # try is used since some atoms may be unselected + # any bond with unselected atom is not returned to viz caller + # need Numeric mode here bonds = [] if self.bondflag: alist = {} - for i in xrange(len(atoms)): - alist[int(atoms[i][0])] = i + for i in xrange(len(atoms)): alist[int(atoms[i][0])] = i for one in self.bondlist: try: i = alist[abs(int(one[2]))] @@ -841,7 +847,8 @@ atom2[2],atom2[3],atom2[4],atom1[1],atom2[1]]) except: continue - tris = [] + tris = [] + if self.triflag: tris = deepcopy(self.trilist) return time,box,atoms,bonds,tris @@ -869,12 +876,10 @@ return [xlo,ylo,zlo,xhi,yhi,zhi] # -------------------------------------------------------------------- - # build static bondlist from dump file or data file - - def bonds(self,arg): - self.bondflag = 1 + # grab bonds/tris from a bond dump file or data file - if type(arg) is types.StringType: # read bonds from a dump file + def extra(self,arg): + if type(arg) is types.StringType: # read bonds from bond dump file try: f = open(arg,'r') @@ -900,21 +905,28 @@ bondlist[i] = [i+1] + ints[start:stop] start += ncol stop += ncol + self.bondflag = 1 + self.bondlist = bondlist except: raise StandardError, "could not read bonds from dump file" - else: # grab bonds from data object - try: + else: + try: # grab bonds from data object bondlist = [] bondlines = arg.sections["Bonds"] for line in bondlines: words = line.split() bondlist.append([int(words[0]),int(words[1]), int(words[2]),int(words[3])]) + self.bondflag = 1 + self.bondlist = bondlist except: - raise StandardError, "could not extract bonds from data object" - - self.bondlist = bondlist + try: # grab tris from cdata object + tmp,tmp,tmp,tmp,trilist = arg.viz(0) + self.triflag = 1 + self.trilist = trilist + except: + raise StandardError,"could not extract bonds/tris from data object" # --------------------------------------------------------------------