convert tabs to spaces, remove extra spaces, fix comments

This commit is contained in:
danielque
2023-08-09 16:49:09 +02:00
parent 633058e1ab
commit d560b34214
47 changed files with 1263 additions and 1266 deletions

View File

@ -39,10 +39,10 @@ def distance(box,x1,y1,z1,x2,y2,z2):
if len(argv) < 3: if len(argv) < 3:
raise StandardError,"group_energy.py data.file dump.file1 dump.file2 ..." raise StandardError,"group_energy.py data.file dump.file1 dump.file2 ..."
dt = data(argv[1]) # data file dt = data(argv[1]) # data file
q = dt.get("Atoms",4) q = dt.get("Atoms",4)
files = ' '.join(argv[2:]) # dump files files = ' '.join(argv[2:]) # dump files
d = dump(files,0) d = dump(files,0)
d.map(1,"id",2,"type",3,"x",4,"y",5,"z") d.map(1,"id",2,"type",3,"x",4,"y",5,"z")

View File

@ -1,5 +1,5 @@
# simple test of data tool # simple test of data tool
# requires files/data.micelle # requires files/data.micelle and dump.micelle
# creates tmp.data # creates tmp.data
d = data("files/data.micelle") d = data("files/data.micelle")

View File

@ -1,5 +1,4 @@
# simple test of vcr tool # simple test of vcr tool
# requires files/bucky*png files
d = dump("files/dump.micelle") d = dump("files/dump.micelle")
dt = data("files/data.micelle") dt = data("files/data.micelle")

View File

@ -17,7 +17,7 @@ if len(argv) < 3:
maxcut = float(argv[1]) maxcut = float(argv[1])
maxcut_sq = maxcut*maxcut maxcut_sq = maxcut*maxcut
files = ' '.join(argv[2:]) # dump files files = ' '.join(argv[2:]) # dump files
d = dump(files,0) d = dump(files,0)
d.map(1,"id",2,"type",3,"x",4,"y",5,"z") d.map(1,"id",2,"type",3,"x",4,"y",5,"z")

View File

@ -4,7 +4,7 @@
# Purpose: create images from LAMMPS dump snapshots # Purpose: create images from LAMMPS dump snapshots
# Syntax: movie.py raster/svg theta phi dump.1 dump.2 ... # Syntax: movie.py raster/svg theta phi dump.1 dump.2 ...
# raster/svg = style of image to create # raster/svg = style of image to create
# theta/phi = vertical (z) and azimuthal angle to view from # theta/phi = vertical (z) and azimuthal angle to view from
# files = one or more dump files # files = one or more dump files
# Example: movie.py svg 60 130 dump.* # Example: movie.py svg 60 130 dump.*
# Author: Steve Plimpton (Sandia) # Author: Steve Plimpton (Sandia)

View File

@ -15,16 +15,16 @@ a = animate("image*.png") create GUI to animate set of image files
Actions (same as GUI widgets): Actions (same as GUI widgets):
a.first() go to first frame a.first() go to first frame
a.prev() go to previous frame a.prev() go to previous frame
a.back() play backwards from current frame to start a.back() play backwards from current frame to start
a.stop() stop on current frame a.stop() stop on current frame
a.play() play from current frame to end a.play() play from current frame to end
a.next() go to next frame a.next() go to next frame
a.last() go to last frame a.last() go to last frame
a.frame(31) set frame slider a.frame(31) set frame slider
a.delay(0.4) set delay slider a.delay(0.4) set delay slider
""" """
# History # History

View File

@ -12,14 +12,14 @@ oneline = "Read dump files with bond info"
docstr = """ docstr = """
b = bdump("dump.one") read in one or more dump files b = bdump("dump.one") read in one or more dump files
b = bdump("dump.1 dump.2.gz") can be gzipped b = bdump("dump.1 dump.2.gz") can be gzipped
b = bdump("dump.*") wildcard expands to multiple files b = bdump("dump.*") wildcard expands to multiple files
b = bdump("dump.*",0) two args = store filenames, but don't read b = bdump("dump.*",0) two args = store filenames, but don't read
incomplete and duplicate snapshots are deleted incomplete and duplicate snapshots are deleted
no column name assignment is performed no column name assignment is performed
time = b.next() read next snapshot from dump files time = b.next() read next snapshot from dump files
used with 2-argument constructor to allow reading snapshots one-at-a-time used with 2-argument constructor to allow reading snapshots one-at-a-time
snapshot will be skipped only if another snapshot has same time stamp snapshot will be skipped only if another snapshot has same time stamp
@ -148,15 +148,15 @@ class bdump:
snap = self.read_snapshot(f) snap = self.read_snapshot(f)
if not snap: if not snap:
self.nextfile += 1 self.nextfile += 1
if self.nextfile == len(self.flist): return -1 if self.nextfile == len(self.flist): return -1
f.close() f.close()
self.eof = 0 self.eof = 0
continue continue
self.eof = f.tell() self.eof = f.tell()
f.close() f.close()
try: try:
self.findtime(snap.time) self.findtime(snap.time)
continue continue
except: break except: break
self.snaps.append(snap) self.snaps.append(snap)

View File

@ -13,11 +13,11 @@
oneline = "Read, create, manipulate ChemCell data files" oneline = "Read, create, manipulate ChemCell data files"
docstr = """ docstr = """
c = cdata() create a datafile object c = cdata() create a datafile object
c = cdata("mem.surf") read in one or more ChemCell data files c = cdata("mem.surf") read in one or more ChemCell data files
c = cdata("mem.part.gz mem.surf") can be gzipped c = cdata("mem.part.gz mem.surf") can be gzipped
c = cdata("mem.*") wildcard expands to multiple files c = cdata("mem.*") wildcard expands to multiple files
c.read("mem.surf") read in one or more data files c.read("mem.surf") read in one or more data files
read() has same argument options as constructor read() has same argument options as constructor
files contain the following kinds of entries, each of which becomes an object files contain the following kinds of entries, each of which becomes an object
@ -30,10 +30,10 @@ c.read("mem.surf") read in one or more data files
ID can be any number or string, must be unique ID can be any number or string, must be unique
c.box(ID,xlo,ylo,zlo,xhi,yhi,zhi) create a box region c.box(ID,xlo,ylo,zlo,xhi,yhi,zhi) create a box region
c.sphere(ID,x,y,z,r) create a sphere region c.sphere(ID,x,y,z,r) create a sphere region
c.shell(ID,x,y,z,r,rinner) create a shell region c.shell(ID,x,y,z,r,rinner) create a shell region
c.cyl(ID,'x',c1,c2,r,lo,hi) create a axis-aligned cylinder region c.cyl(ID,'x',c1,c2,r,lo,hi) create a axis-aligned cylinder region
c.cap(ID,'x',c1,c2,r,lo,hi) create a axis-aligned capped-cylinder region c.cap(ID,'x',c1,c2,r,lo,hi) create a axis-aligned capped-cylinder region
c.q(ID,q1,q2,...) set region triangulation quality factors c.q(ID,q1,q2,...) set region triangulation quality factors
box() can create an axis-aligned plane, line, or point if lo=hi box() can create an axis-aligned plane, line, or point if lo=hi
@ -58,13 +58,13 @@ c.bins(ID,nx,ny) set binning parameters for a surf
for surfselect(), test is string like "$x < 2.0 and $y > 0.0" for surfselect(), test is string like "$x < 2.0 and $y > 0.0"
bins are used when particles are created inside/outside a surf bins are used when particles are created inside/outside a surf
c.part(ID,n,id_in) create N particles inside object id_in c.part(ID,n,id_in) create N particles inside object id_in
c.part(ID,n,id_in,id_out) particles are also outside object id_out c.part(ID,n,id_in,id_out) particles are also outside object id_out
c.part2d(ID,n,id_on) create 2d particles on object id_on c.part2d(ID,n,id_on) create 2d particles on object id_on
c.partarray(ID,nx,nz,nz,x,y,z,dx,dy,dz) create 3d grid of particles c.partarray(ID,nx,nz,nz,x,y,z,dx,dy,dz) create 3d grid of particles
c.partring(ID,n,x,y,z,r,'x') create ring of particles c.partring(ID,n,x,y,z,r,'x') create ring of particles
c.partsurf(ID,id_on) change surf of existing 2d particle group c.partsurf(ID,id_on) change surf of existing 2d particle group
c.seed(43284) set random # seed (def = 12345) c.seed(43284) set random # seed (def = 12345)
generate particle positions randomly (unless otherwise noted) generate particle positions randomly (unless otherwise noted)
for part(), id_in and id_out must be IDs of a surf, region, or union object for part(), id_in and id_out must be IDs of a surf, region, or union object
@ -88,9 +88,9 @@ c.project(ID,ID2,dx,dy,dz,eps,fg) project particles in ID to surf of obj ID2
particles are converted to 2d assigned to surf ID2 particles are converted to 2d assigned to surf ID2
c.center(ID,x,y,z) set center point of object c.center(ID,x,y,z) set center point of object
c.trans(ID,dx,dy,dz) translate an object c.trans(ID,dx,dy,dz) translate an object
c.rotate(ID,'x',1,1,0,'z',-1,1,0) rotate an object c.rotate(ID,'x',1,1,0,'z',-1,1,0) rotate an object
c.scale(ID,sx,sy,sz) scale an object c.scale(ID,sx,sy,sz) scale an object
objects must be surface or particle group, regions cannot be changed objects must be surface or particle group, regions cannot be changed
for center(), default is middle of bounding box (set when obj is created) for center(), default is middle of bounding box (set when obj is created)
@ -98,11 +98,11 @@ c.scale(ID,sx,sy,sz) scale an object
object is rotated so that it's current xyz axes point along new ones object is rotated so that it's current xyz axes point along new ones
rotation and scaling occur relative to center point rotation and scaling occur relative to center point
c.union(ID,id1,id2,...) create a new union object from id1,id2,etc c.union(ID,id1,id2,...) create a new union object from id1,id2,etc
c.join(ID,id1,id2,...) create a new object by joining id1,id2,etc c.join(ID,id1,id2,...) create a new object by joining id1,id2,etc
c.delete(id1,id2,...) delete one or more objects c.delete(id1,id2,...) delete one or more objects
c.rename(ID,IDnew) rename an object c.rename(ID,IDnew) rename an object
c.copy(ID,IDnew) create a new object as copy of old object c.copy(ID,IDnew) create a new object as copy of old object
for union, all lower-level objects must be of surface, region, or union style for union, all lower-level objects must be of surface, region, or union style
for join, all joined objects must be of same style: group, surf, line for join, all joined objects must be of same style: group, surf, line
@ -115,10 +115,10 @@ c.unselect() unselect all objects
selection applies to write() and viz() selection applies to write() and viz()
c.write("file") write all selected objs to ChemCell file c.write("file") write all selected objs to ChemCell file
c.write("file",id1,id2,...) write only listed & selected objects to file c.write("file",id1,id2,...) write only listed & selected objects to file
c.append("file") append all selected objs to ChemCell file c.append("file") append all selected objs to ChemCell file
c.append("file",id1,id2,...) append only listed & selected objects c.append("file",id1,id2,...) append only listed & selected objects
union objects are skipped, not written to file union objects are skipped, not written to file
@ -800,8 +800,6 @@ class cdata:
# bracket pt = xyz +/- scale*dir # bracket pt = xyz +/- scale*dir
# multiply scale by factor each iteration # multiply scale by factor each iteration
#print "AAA",i,start,stop,x,y,z,dir
scale = EPS scale = EPS
bracket = start bracket = start
while scale < maxscale: while scale < maxscale:
@ -1166,7 +1164,7 @@ class cdata:
return 0,0,-1 return 0,0,-1
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# return list of atoms and triangles to viz for cdata object # return list of atoms and triangles and lines to viz for cdata object
def viz(self,isnap): def viz(self,isnap):
if isnap: if isnap:

View File

@ -11,7 +11,7 @@
oneline = "Convert LAMMPS snapshots to AtomEye CFG format" oneline = "Convert LAMMPS snapshots to AtomEye CFG format"
docstr = """ docstr = """
c = cfg(d) d = object containing atom coords (dump, data) c = cfg(d) d = object containing atom coords (dump, data)
c.one() write all snapshots to tmp.cfg c.one() write all snapshots to tmp.cfg
c.one("new") write all snapshots to new.cfg c.one("new") write all snapshots to new.cfg

View File

@ -12,11 +12,11 @@ oneline = "Create bead-spring chains for LAMMPS input"
docstr = """ docstr = """
c = chain(N,rho) setup box with N monomers at reduced density rho c = chain(N,rho) setup box with N monomers at reduced density rho
c = chain(N,rho,1,1,2) x,y,z = aspect ratio of box (def = 1,1,1) c = chain(N,rho,1,1,2) x,y,z = aspect ratio of box (def = 1,1,1)
c.seed = 48379 set random # seed (def = 12345) c.seed = 48379 set random # seed (def = 12345)
c.mtype = 2 set type of monomers (def = 1) c.mtype = 2 set type of monomers (def = 1)
c.btype = 1 set type of bonds (def = 1) c.btype = 1 set type of bonds (def = 1)
c.blen = 0.97 set length of bonds (def = 0.97) c.blen = 0.97 set length of bonds (def = 0.97)
c.dmin = 1.02 set min dist from i-1 to i+1 site (def = 1.02) c.dmin = 1.02 set min dist from i-1 to i+1 site (def = 1.02)
@ -24,7 +24,7 @@ c.id = "chain" set molecule ID to chain # (default)
c.id = "end1" set molecule ID to count from one end of chain c.id = "end1" set molecule ID to count from one end of chain
c.id = "end2" set molecule ID to count from either end of chain c.id = "end2" set molecule ID to count from either end of chain
c.build(100,10) create 100 chains, each of length 10 c.build(100,10) create 100 chains, each of length 10
can be invoked multiple times interleaved with different settings can be invoked multiple times interleaved with different settings
must fill box with total of N monomers must fill box with total of N monomers
@ -112,7 +112,7 @@ class chain:
x = self.xlo + self.random()*self.xprd x = self.xlo + self.random()*self.xprd
y = self.ylo + self.random()*self.yprd y = self.ylo + self.random()*self.yprd
z = self.zlo + self.random()*self.zprd z = self.zlo + self.random()*self.zprd
ix = iy = iz = 0 ix = iy = iz = 0
else: else:
restriction = True restriction = True
while restriction: while restriction:
@ -150,7 +150,7 @@ class chain:
atoms.append([idatom,idmol,self.mtype,x,y,z,ix,iy,iz]) atoms.append([idatom,idmol,self.mtype,x,y,z,ix,iy,iz])
if imonomer: if imonomer:
bondid = id_bond_prev + imonomer bondid = id_bond_prev + imonomer
bonds.append([bondid,self.btype,idatom-1,idatom]) bonds.append([bondid,self.btype,idatom-1,idatom])
self.atoms += atoms self.atoms += atoms

View File

@ -26,7 +26,7 @@ nvec = c.nvec # of vectors of thermo info
nlen = c.nlen length of each vectors nlen = c.nlen length of each vectors
names = c.names list of vector names names = c.names list of vector names
a,b,... = c.get("A","B",...) return one or more vectors of values a,b,... = c.get("A","B",...) return one or more vectors of values
c.write("file.txt") write all vectors to a file c.write("file.txt") write all vectors to a file
c.write("file.txt","A","B",...) write listed vectors to a file c.write("file.txt","A","B",...) write listed vectors to a file
get and write allow abbreviated (uniquely) vector names get and write allow abbreviated (uniquely) vector names
@ -117,9 +117,9 @@ class clog:
else: else:
count = 0 count = 0
for i in range(self.nvec): for i in range(self.nvec):
if self.names[i].find(key) == 0: if self.names[i].find(key) == 0:
count += 1 count += 1
index = i index = i
if count == 1: if count == 1:
map.append(index) map.append(index)
else: else:
@ -145,9 +145,9 @@ class clog:
else: else:
count = 0 count = 0
for i in range(self.nvec): for i in range(self.nvec):
if self.names[i].find(key) == 0: if self.names[i].find(key) == 0:
count += 1 count += 1
index = i index = i
if count == 1: if count == 1:
map.append(index) map.append(index)
else: else:
@ -261,26 +261,26 @@ class clog:
elif s1 >= 0 and s2 >= 0 and s2 < s1: # found s1,s2 with s2 before s1 elif s1 >= 0 and s2 >= 0 and s2 < s1: # found s1,s2 with s2 before s1
s1 = 0 s1 = 0
elif s1 == -1 and s2 >= 0: # found s2, but no s1 elif s1 == -1 and s2 >= 0: # found s2, but no s1
last = 1 last = 1
s1 = 0 s1 = 0
elif s1 >= 0 and s2 == -1: # found s1, but no s2 elif s1 >= 0 and s2 == -1: # found s1, but no s2
last = 1 last = 1
s1 = txt.find("\n",s1) + 1 s1 = txt.find("\n",s1) + 1
s2 = txt.rfind("\n",s1) + 1 s2 = txt.rfind("\n",s1) + 1
eof -= len(txt) - s2 eof -= len(txt) - s2
elif s1 == -1 and s2 == -1: # found neither elif s1 == -1 and s2 == -1: # found neither
# could be end-of-file section # could be end-of-file section
# or entire read was one chunk # or entire read was one chunk
if txt.find("Loop time of",start) == start: # end of file, so exit if txt.find("Loop time of",start) == start: # end of file, so exit
eof -= len(txt) - start # reset eof to "Loop" eof -= len(txt) - start # reset eof to "Loop"
break break
last = 1 # entire read is a chunk last = 1 # entire read is a chunk
s1 = 0 s1 = 0
s2 = txt.rfind("\n",s1) + 1 s2 = txt.rfind("\n",s1) + 1
eof -= len(txt) - s2 eof -= len(txt) - s2
if s1 == s2: break if s1 == s2: break
chunk = txt[s1:s2-1] chunk = txt[s1:s2-1]
start = s2 start = s2

View File

@ -12,7 +12,7 @@ oneline = "Read, write, manipulate LAMMPS data files"
docstr = """ docstr = """
d = data("data.poly") read a LAMMPS data file, can be gzipped d = data("data.poly") read a LAMMPS data file, can be gzipped
d = data() create an empty data file d = data() create an empty data file
d.map(1,"id",3,"x") assign names to atom columns (1-N) d.map(1,"id",3,"x") assign names to atom columns (1-N)
@ -26,13 +26,13 @@ d.reorder("Atoms",1,3,2,4,5) reorder columns (1-N) in a data file section
1,3,2,4,5 = new order of previous columns, can delete columns this way 1,3,2,4,5 = new order of previous columns, can delete columns this way
d.title = "My LAMMPS data file" set title of the data file d.title = "My LAMMPS data file" set title of the data file
d.headers["atoms"] = 1500 set a header value d.headers["atoms"] = 1500 set a header value
d.sections["Bonds"] = lines set a section to list of lines (with newlines) d.sections["Bonds"] = lines set a section to list of lines (with newlines)
d.delete("bonds") delete a keyword or section of data file d.delete("bonds") delete a keyword or section of data file
d.delete("Bonds") d.delete("Bonds")
d.replace("Atoms",5,vec) replace Nth column of section with vector d.replace("Atoms",5,vec) replace Nth column of section with vector
d.newxyz(dmp,1000) replace xyz in Atoms with xyz of snapshot N d.newxyz(dmp,1000) replace xyz in Atoms with xyz of snapshot N
newxyz assumes id,x,y,z are defined in both data and dump files newxyz assumes id,x,y,z are defined in both data and dump files
also replaces ix,iy,iz if they are defined also replaces ix,iy,iz if they are defined
@ -109,16 +109,16 @@ class data:
found = 0 found = 0
for keyword in hkeywords: for keyword in hkeywords:
if line.find(keyword) >= 0: if line.find(keyword) >= 0:
found = 1 found = 1
words = line.split() words = line.split()
if keyword == "xlo xhi" or keyword == "ylo yhi" or \ if keyword == "xlo xhi" or keyword == "ylo yhi" or \
keyword == "zlo zhi": keyword == "zlo zhi":
headers[keyword] = (float(words[0]),float(words[1])) headers[keyword] = (float(words[0]),float(words[1]))
elif keyword == "xy xz yz": elif keyword == "xy xz yz":
headers[keyword] = \ headers[keyword] = \
(float(words[0]),float(words[1]),float(words[2])) (float(words[0]),float(words[1]),float(words[2]))
else: else:
headers[keyword] = int(words[0]) headers[keyword] = int(words[0])
if not found: if not found:
break break
@ -128,11 +128,11 @@ class data:
for pair in skeywords: for pair in skeywords:
keyword,length = pair[0],pair[1] keyword,length = pair[0],pair[1]
if keyword == line: if keyword == line:
found = 1 found = 1
if not headers.has_key(length): if not headers.has_key(length):
raise StandardError, \ raise StandardError, \
"data section %s has no matching header value" % line "data section %s has no matching header value" % line
f.readline() f.readline()
list = [] list = []
for i in xrange(headers[length]): list.append(f.readline()) for i in xrange(headers[length]): list.append(f.readline())
sections[keyword] = list sections[keyword] = list
@ -225,8 +225,8 @@ class data:
if dm.scaled(nsnap): scaleflag = 1 if dm.scaled(nsnap): scaleflag = 1
else: scaleflag = 0 else: scaleflag = 0
dm.sort(ntime) dm.sort(ntime)
if scaleflag: dm.unscale(ntime) if scaleflag: dm.unscale(ntime)
x,y,z = dm.vecs(ntime,"x","y","z") x,y,z = dm.vecs(ntime,"x","y","z")
if scaleflag: dm.scale(ntime) if scaleflag: dm.scale(ntime)
@ -259,19 +259,19 @@ class data:
if self.headers.has_key(keyword): if self.headers.has_key(keyword):
if keyword == "xlo xhi" or keyword == "ylo yhi" or \ if keyword == "xlo xhi" or keyword == "ylo yhi" or \
keyword == "zlo zhi": keyword == "zlo zhi":
pair = self.headers[keyword] pair = self.headers[keyword]
print >>f,pair[0],pair[1],keyword print >>f,pair[0],pair[1],keyword
elif keyword == "xy xz yz": elif keyword == "xy xz yz":
triple = self.headers[keyword] triple = self.headers[keyword]
print >>f,triple[0],triple[1],triple[2],keyword print >>f,triple[0],triple[1],triple[2],keyword
else: else:
print >>f,self.headers[keyword],keyword print >>f,self.headers[keyword],keyword
for pair in skeywords: for pair in skeywords:
keyword = pair[0] keyword = pair[0]
if self.sections.has_key(keyword): if self.sections.has_key(keyword):
print >>f,"\n%s\n" % keyword print >>f,"\n%s\n" % keyword
for line in self.sections[keyword]: for line in self.sections[keyword]:
print >>f,line, print >>f,line,
f.close() f.close()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -331,7 +331,7 @@ class data:
float(atom1words[z]), float(atom1words[z]),
float(atom2words[x]),float(atom2words[y]), float(atom2words[x]),float(atom2words[y]),
float(atom2words[z]), float(atom2words[z]),
float(atom1words[type]),float(atom2words[type])]) float(atom1words[type]),float(atom2words[type])])
tris = [] tris = []
lines = [] lines = []
@ -357,18 +357,18 @@ class data:
hkeywords = ["atoms","lines","tris", hkeywords = ["atoms","lines","tris",
"bonds","angles","dihedrals","impropers", "bonds","angles","dihedrals","impropers",
"atom types","bond types","angle types","dihedral types", "atom types","bond types","angle types","dihedral types",
"improper types","xlo xhi","ylo yhi","zlo zhi","xy xz yz"] "improper types","xlo xhi","ylo yhi","zlo zhi","xy xz yz"]
skeywords = [["Masses","atom types"], skeywords = [["Masses","atom types"],
["Atoms","atoms"],["Lines","lines"],["Triangles","tris"], ["Atoms","atoms"],["Lines","lines"],["Triangles","tris"],
["Bonds","bonds"], ["Bonds","bonds"],
["Angles","angles"],["Dihedrals","dihedrals"], ["Angles","angles"],["Dihedrals","dihedrals"],
["Impropers","impropers"],["Velocities","atoms"], ["Impropers","impropers"],["Velocities","atoms"],
["Pair Coeffs","atom types"], ["Pair Coeffs","atom types"],
["Bond Coeffs","bond types"],["Angle Coeffs","angle types"], ["Bond Coeffs","bond types"],["Angle Coeffs","angle types"],
["Dihedral Coeffs","dihedral types"], ["Dihedral Coeffs","dihedral types"],
["Improper Coeffs","improper types"], ["Improper Coeffs","improper types"],
["BondBond Coeffs","angle types"], ["BondBond Coeffs","angle types"],
["BondAngle Coeffs","angle types"], ["BondAngle Coeffs","angle types"],
["MiddleBondTorsion Coeffs","dihedral types"], ["MiddleBondTorsion Coeffs","dihedral types"],

View File

@ -12,15 +12,15 @@ oneline = "Read, write, manipulate dump files and particle attributes"
docstr = """ docstr = """
d = dump("dump.one") read in one or more dump files d = dump("dump.one") read in one or more dump files
d = dump("dump.1 dump.2.gz") can be gzipped d = dump("dump.1 dump.2.gz") can be gzipped
d = dump("dump.*") wildcard expands to multiple files d = dump("dump.*") wildcard expands to multiple files
d = dump("dump.*",0) two args = store filenames, but don't read d = dump("dump.*",0) two args = store filenames, but don't read
incomplete and duplicate snapshots are deleted incomplete and duplicate snapshots are deleted
if atoms have 5 or 8 columns, assign id,type,x,y,z (ix,iy,iz) if atoms have 5 or 8 columns, assign id,type,x,y,z (ix,iy,iz)
atoms will be unscaled if stored in files as scaled atoms will be unscaled if stored in files as scaled
time = d.next() read next snapshot from dump files time = d.next() read next snapshot from dump files
used with 2-argument constructor to allow reading snapshots one-at-a-time used with 2-argument constructor to allow reading snapshots one-at-a-time
snapshot will be skipped only if another snapshot has same time stamp snapshot will be skipped only if another snapshot has same time stamp
@ -32,20 +32,20 @@ d.map(1,"id",3,"x") assign names to atom columns (1-N)
not needed if dump file is self-describing not needed if dump file is self-describing
d.tselect.all() select all timesteps d.tselect.all() select all timesteps
d.tselect.one(N) select only timestep N d.tselect.one(N) select only timestep N
d.tselect.none() deselect all timesteps d.tselect.none() deselect all timesteps
d.tselect.skip(M) select every Mth step d.tselect.skip(M) select every Mth step
d.tselect.test("$t >= 100 and $t < 10000") select matching timesteps d.tselect.test("$t >= 100 and $t < 10000") select matching timesteps
d.delete() delete non-selected timesteps d.delete() delete non-selected timesteps
selecting a timestep also selects all atoms in the timestep selecting a timestep also selects all atoms in the timestep
skip() and test() only select from currently selected timesteps skip() and test() only select from currently selected timesteps
test() uses a Python Boolean expression with $t for timestep value test() uses a Python Boolean expression with $t for timestep value
Python comparison syntax: == != < > <= >= and or Python comparison syntax: == != < > <= >= and or
d.aselect.all() select all atoms in all steps d.aselect.all() select all atoms in all steps
d.aselect.all(N) select all atoms in one step d.aselect.all(N) select all atoms in one step
d.aselect.test("$id > 100 and $type == 2") select match atoms in all steps d.aselect.test("$id > 100 and $type == 2") select match atoms in all steps
d.aselect.test("$id > 100 and $type == 2",N) select matching atoms in one step d.aselect.test("$id > 100 and $type == 2",N) select matching atoms in one step
@ -56,24 +56,24 @@ d.aselect.test("$id > 100 and $type == 2",N) select matching atoms in one step
Python comparison syntax: == != < > <= >= and or Python comparison syntax: == != < > <= >= and or
$name must end with a space $name must end with a space
d.write("file") write selected steps/atoms to dump file d.write("file") write selected steps/atoms to dump file
d.write("file",head,app) write selected steps/atoms to dump file d.write("file",head,app) write selected steps/atoms to dump file
d.scatter("tmp") write selected steps/atoms to multiple files d.scatter("tmp") write selected steps/atoms to multiple files
write() can be specified with 2 additional flags write() can be specified with 2 additional flags
headd = 0/1 for no/yes snapshot header, app = 0/1 for write vs append head = 0/1 for no/yes snapshot header, app = 0/1 for write vs append
scatter() files are given timestep suffix: e.g. tmp.0, tmp.100, etc scatter() files are given timestep suffix: e.g. tmp.0, tmp.100, etc
d.scale() scale x,y,z to 0-1 for all timesteps d.scale() scale x,y,z to 0-1 for all timesteps
d.scale(100) scale atom coords for timestep N d.scale(100) scale atom coords for timestep N
d.unscale() unscale x,y,z to box size to all timesteps d.unscale() unscale x,y,z to box size to all timesteps
d.unscale(1000) unscale atom coords for timestep N d.unscale(1000) unscale atom coords for timestep N
d.wrap() wrap x,y,z into periodic box via ix,iy,iz d.wrap() wrap x,y,z into periodic box via ix,iy,iz
d.unwrap() unwrap x,y,z out of box via ix,iy,iz d.unwrap() unwrap x,y,z out of box via ix,iy,iz
d.owrap("other") wrap x,y,z to same image as another atom d.owrap("other") wrap x,y,z to same image as another atom
d.sort() sort atoms by atom ID in all selected steps d.sort() sort atoms by atom ID in all selected steps
d.sort("x") sort atoms by column value in all steps d.sort("x") sort atoms by column value in all steps
d.sort(1000) sort atoms in timestep N d.sort(1000) sort atoms in timestep N
scale(), unscale(), wrap(), unwrap(), owrap() operate on all steps and atoms scale(), unscale(), wrap(), unwrap(), owrap() operate on all steps and atoms
wrap(), unwrap(), owrap() require ix,iy,iz be defined wrap(), unwrap(), owrap() require ix,iy,iz be defined
@ -85,8 +85,8 @@ d.sort(1000) sort atoms in timestep N
m1,m2 = d.minmax("type") find min/max values for a column m1,m2 = d.minmax("type") find min/max values for a column
d.set("$ke = $vx * $vx + $vy * $vy") set a column to a computed value d.set("$ke = $vx * $vx + $vy * $vy") set a column to a computed value
d.setv("type",vector) set a column to a vector of values d.setv("type",vector) set a column to a vector of values
d.spread("ke",N,"color") 2nd col = N ints spread over 1st col d.spread("ke",N,"color") 2nd col = N ints spread over 1st col
d.clone(1000,"color") clone timestep N values to other steps d.clone(1000,"color") clone timestep N values to other steps
minmax() operates on selected timesteps and atoms minmax() operates on selected timesteps and atoms
set() operates on selected timesteps and atoms set() operates on selected timesteps and atoms
@ -107,7 +107,7 @@ d.clone(1000,"color") clone timestep N values to other steps
values at every timestep are set to value at timestep N for that atom ID values at every timestep are set to value at timestep N for that atom ID
useful for propagating a color map useful for propagating a color map
t = d.time() return vector of selected timestep values t = d.time() return vector of selected timestep values
fx,fy,... = d.atom(100,"fx","fy",...) return vector(s) for atom ID N fx,fy,... = d.atom(100,"fx","fy",...) return vector(s) for atom ID N
fx,fy,... = d.vecs(1000,"fx","fy",...) return vector(s) for timestep N fx,fy,... = d.vecs(1000,"fx","fy",...) return vector(s) for timestep N
@ -117,7 +117,7 @@ fx,fy,... = d.vecs(1000,"fx","fy",...) return vector(s) for timestep N
index,time,flag = d.iterator(0/1) loop over dump snapshots index,time,flag = d.iterator(0/1) loop over dump snapshots
time,box,atoms,bonds,tris,lines = d.viz(index) return list of viz objects time,box,atoms,bonds,tris,lines = d.viz(index) return list of viz objects
d.atype = "color" set column returned as "type" by viz d.atype = "color" set column returned as "type" by viz
d.extra(obj) extract bond/tri/line info from obj d.extra(obj) extract bond/tri/line info from obj
iterator() loops over selected timesteps iterator() loops over selected timesteps
iterator() called with arg = 0 first time, with arg = 1 on subsequent calls iterator() called with arg = 0 first time, with arg = 1 on subsequent calls
@ -331,15 +331,15 @@ class dump:
snap = self.read_snapshot(f) snap = self.read_snapshot(f)
if not snap: if not snap:
self.nextfile += 1 self.nextfile += 1
if self.nextfile == len(self.flist): return -1 if self.nextfile == len(self.flist): return -1
f.close() f.close()
self.eof = 0 self.eof = 0
continue continue
self.eof = f.tell() self.eof = f.tell()
f.close() f.close()
try: try:
self.findtime(snap.time) self.findtime(snap.time)
continue continue
except: break except: break
# select the new snapshot with all its atoms # select the new snapshot with all its atoms

View File

@ -11,7 +11,7 @@
oneline = "Convert LAMMPS snapshots or meshes to Ensight format" oneline = "Convert LAMMPS snapshots or meshes to Ensight format"
docstr = """ docstr = """
e = ensight(d) d = object with atoms or elements (dump,data,mdump) e = ensight(d) d = object with atoms or elements (dump,data,mdump)
e.change = 1 set to 1 if element nodal xyz change with time (def = 0) e.change = 1 set to 1 if element nodal xyz change with time (def = 0)
e.maxtype = 10 max particle type, set if query to data will be bad e.maxtype = 10 max particle type, set if query to data will be bad
@ -268,20 +268,20 @@ class ensight:
files = [] files = []
if n < 10: if n < 10:
file = root + "000" + str(n) + ".xyz" file = root + "000" + str(n) + ".xyz"
for pair in pairs: for pair in pairs:
files.append(root + "000" + str(n) + "." + pair[0]) files.append(root + "000" + str(n) + "." + pair[0])
elif n < 100: elif n < 100:
file = root + "00" + str(n) + ".xyz" file = root + "00" + str(n) + ".xyz"
for pair in pairs: for pair in pairs:
files.append(root + "00" + str(n) + "." + pair[0]) files.append(root + "00" + str(n) + "." + pair[0])
elif n < 1000: elif n < 1000:
file = root + "0" + str(n) + ".xyz" file = root + "0" + str(n) + ".xyz"
for pair in pairs: for pair in pairs:
files.append(root + "0" + str(n) + "." + pair[0]) files.append(root + "0" + str(n) + "." + pair[0])
else: else:
file = root + str(n) + ".xyz" file = root + str(n) + ".xyz"
for pair in pairs: for pair in pairs:
files.append(root + str(n) + "." + pair[0]) files.append(root + str(n) + "." + pair[0])
if self.which == 0: if self.which == 0:
f = open(file,"w") f = open(file,"w")
@ -309,7 +309,7 @@ class ensight:
self.variable_file_atoms(f,pairs[i][1],atoms,values) self.variable_file_atoms(f,pairs[i][1],atoms,values)
else: else:
self.variable_file_elements(f,pairs[i][1],etype,values) self.variable_file_elements(f,pairs[i][1],etype,values)
f.close() f.close()
print time, print time,
sys.stdout.flush() sys.stdout.flush()

View File

@ -16,8 +16,8 @@ g = gl(d) create OpenGL display for data in d
d = atom snapshot object (dump, data) d = atom snapshot object (dump, data)
g.bg("black") set background color (def = "black") g.bg("black") set background color (def = "black")
g.size(N) set image size to NxN g.size(N) set image size to NxN
g.size(N,M) set image size to NxM g.size(N,M) set image size to NxM
g.rotate(60,135) view from z theta and azimuthal phi (def = 60,30) g.rotate(60,135) view from z theta and azimuthal phi (def = 60,30)
g.shift(x,y) translate by x,y pixels in view window (def = 0,0) g.shift(x,y) translate by x,y pixels in view window (def = 0,0)
g.zoom(0.5) scale image by factor (def = 1) g.zoom(0.5) scale image by factor (def = 1)
@ -43,9 +43,9 @@ g.select = "" no extra aselect (default)
%g varies from 0.0 to 1.0 from beginning to end of all() %g varies from 0.0 to 1.0 from beginning to end of all()
g.acol(2,"green") set atom colors by atom type (1-N) g.acol(2,"green") set atom colors by atom type (1-N)
g.acol([2,4],["red","blue"]) 1st arg = one type or list of types g.acol([2,4],["red","blue"]) 1st arg = one type or list of types
g.acol(0,"blue") 2nd arg = one color or list of colors g.acol(0,"blue") 2nd arg = one color or list of colors
g.acol(range(20),["red","blue"]) if list lengths unequal, interpolate g.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
g.acol(range(10),"loop") assign colors in loop, randomly ordered g.acol(range(10),"loop") assign colors in loop, randomly ordered
@ -55,19 +55,19 @@ g.acol(range(10),"loop") assign colors in loop, randomly ordered
g.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol() g.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol()
g.bcol() set bond color, same args as acol() g.bcol() set bond color, same args as acol()
g.brad() set bond thickness, same args as arad() g.brad() set bond thickness, same args as arad()
g.tcol() set triangle color, same args as acol() g.tcol() set triangle color, same args as acol()
g.tfill() set triangle fill, 0 fill, 1 line, 2 both g.tfill() set triangle fill, 0 fill, 1 line, 2 both
g.lcol() set line color, same args as acol() g.lcol() set line color, same args as acol()
g.lrad() set line thickness, same args as arad() g.lrad() set line thickness, same args as arad()
g.adef() set atom/bond/tri/line properties to default g.adef() set atom/bond/tri/line properties to default
g.bdef() default = "loop" for colors, 0.45 for radii g.bdef() default = "loop" for colors, 0.45 for radii
g.tdef() default = 0.25 for bond/line thickness g.tdef() default = 0.25 for bond/line thickness
g.ldef() default = 0 fill g.ldef() default = 0 fill
by default 100 types are assigned by default 100 types are assigned
if atom/bond/tri/line has type > # defined properties, is an error if atom/bond/tri/line has type > # defined properties, is an error
@ -312,7 +312,7 @@ class gl:
self.up[1] = sin(pi*self.azphi/180) self.up[1] = sin(pi*self.azphi/180)
self.up[2] = 0.0 self.up[2] = 0.0
else: else:
dot = self.view[2] # dot = (0,0,1) . view dot = self.view[2] # dot = (0,0,1) . view
self.up[0] = -dot*self.view[0] # up projected onto v = dot * v self.up[0] = -dot*self.view[0] # up projected onto v = dot * v
self.up[1] = -dot*self.view[1] # up perp to v = up - dot * v self.up[1] = -dot*self.view[1] # up perp to v = up - dot * v
self.up[2] = 1.0 - dot*self.view[2] self.up[2] = 1.0 - dot*self.view[2]
@ -636,7 +636,7 @@ class gl:
fraction*(self.scale_stop - self.scale_start) fraction*(self.scale_stop - self.scale_start)
self.viewupright() self.viewupright()
if n == nstart or self.panflag: self.center = compute_center(box) if n == nstart or self.panflag: self.center = compute_center(box)
if bonds: self.bonds_augment(bonds) if bonds: self.bonds_augment(bonds)
@ -691,7 +691,7 @@ class gl:
fraction*(self.scale_stop - self.scale_start) fraction*(self.scale_stop - self.scale_start)
self.viewupright() self.viewupright()
if n == nstart or self.panflag: self.center = compute_center(box) if n == nstart or self.panflag: self.center = compute_center(box)
if bonds: self.bonds_augment(bonds) if bonds: self.bonds_augment(bonds)
@ -781,7 +781,7 @@ class gl:
red,green,blue = self.vizinfo.lcolor[itype] red,green,blue = self.vizinfo.lcolor[itype]
glColor3f(red,green,blue) glColor3f(red,green,blue)
thick = self.vizinfo.lrad[itype] thick = self.vizinfo.lrad[itype]
glLineWidth(thick) glLineWidth(thick)
glBegin(GL_LINES) glBegin(GL_LINES)
glVertex3f(line[2],line[3],line[4]) glVertex3f(line[2],line[3],line[4])
glVertex3f(line[5],line[6],line[7]) glVertex3f(line[5],line[6],line[7])

View File

@ -11,12 +11,12 @@
oneline = "Create plots via GnuPlot plotting program" oneline = "Create plots via GnuPlot plotting program"
docstr = """ docstr = """
g = gnu() start up GnuPlot g = gnu() start up GnuPlot
g.stop() shut down GnuPlot process g.stop() shut down GnuPlot process
g.plot(a) plot vector A against linear index g.plot(a) plot vector A against linear index
g.plot(a,b) plot B against A g.plot(a,b) plot B against A
g.plot(a,b,c,d,...) plot B against A, D against C, etc g.plot(a,b,c,d,...) plot B against A, D against C, etc
g.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc g.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc
each plot argument can be a tuple, list, or Numeric/NumPy vector each plot argument can be a tuple, list, or Numeric/NumPy vector
@ -29,21 +29,21 @@ g.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc
g("plot 'file.dat' using 2:3 with lines") execute string in GnuPlot g("plot 'file.dat' using 2:3 with lines") execute string in GnuPlot
g.enter() enter GnuPlot shell g.enter() enter GnuPlot shell
gnuplot> plot sin(x) with lines type commands directly to GnuPlot gnuplot> plot sin(x) with lines type commands directly to GnuPlot
gnuplot> exit, quit exit GnuPlot shell gnuplot> exit, quit exit GnuPlot shell
g.export("data",range(100),a,...) create file with columns of numbers g.export("data",range(100),a,...) create file with columns of numbers
all vectors must be of equal length all vectors must be of equal length
could plot from file with GnuPlot command: plot 'data' using 1:2 with lines could plot from file with GnuPlot command: plot 'data' using 1:2 with lines
g.select(N) figure N becomes the current plot g.select(N) figure N becomes the current plot
subsequent commands apply to this plot subsequent commands apply to this plot
g.hide(N) delete window for figure N g.hide(N) delete window for figure N
g.save("file") save current plot as file.eps g.save("file") save current plot as file.eps
Set attributes for current plot: Set attributes for current plot:

View File

@ -13,14 +13,14 @@ oneline = "View and manipulate images"
docstr = """ docstr = """
i = image("my1.gif my2.gif") display thumbnails of matching images i = image("my1.gif my2.gif") display thumbnails of matching images
i = image("*.png *.gif") wildcards allowed i = image("*.png *.gif") wildcards allowed
i = image("") blank string matches all image suffixes i = image("") blank string matches all image suffixes
i = image() no display window opened if no arg i = image() no display window opened if no arg
image suffixes for blank string = *.png, *.bmp, *.gif, *.tiff, *.tif image suffixes for blank string = *.png, *.bmp, *.gif, *.tiff, *.tif
click on a thumbnail to view it full-size click on a thumbnail to view it full-size
click on thumbnail again to remove full-sized version click on thumbnail again to remove full-sized version
i.view("*.png *.gif") display thumbnails of matching images i.view("*.png *.gif") display thumbnails of matching images
view arg is same as constructor arg view arg is same as constructor arg
@ -216,7 +216,7 @@ class thumbnails:
self.bigexist = 0 self.bigexist = 0
if self.window: if self.window:
self.window.destroy() self.window.destroy()
self.window = None self.window = None
# create a new window with the big image # create a new window with the big image

View File

@ -12,14 +12,14 @@ oneline = "Read dump files with line segment info"
docstr = """ docstr = """
l = ldump("dump.one") read in one or more dump files l = ldump("dump.one") read in one or more dump files
l = ldump("dump.1 dump.2.gz") can be gzipped l = ldump("dump.1 dump.2.gz") can be gzipped
l = ldump("dump.*") wildcard expands to multiple files l = ldump("dump.*") wildcard expands to multiple files
l = ldump("dump.*",0) two args = store filenames, but don't read l = ldump("dump.*",0) two args = store filenames, but don't read
incomplete and duplicate snapshots are deleted incomplete and duplicate snapshots are deleted
no column name assignment is performed no column name assignment is performed
time = l.next() read next snapshot from dump files time = l.next() read next snapshot from dump files
used with 2-argument constructor to allow reading snapshots one-at-a-time used with 2-argument constructor to allow reading snapshots one-at-a-time
snapshot will be skipped only if another snapshot has same time stamp snapshot will be skipped only if another snapshot has same time stamp
@ -43,7 +43,7 @@ time,box,atoms,bonds,tris,lines = l.viz(index) return list of viz objects
lines = id,type,x1,y1,z1,x2,y2,z2 for each line as 2d array lines = id,type,x1,y1,z1,x2,y2,z2 for each line as 2d array
id,type are from associated atom id,type are from associated atom
l.owrap(...) wrap lines to same image as their atoms l.owrap(...) wrap lines to same image as their atoms
owrap() is called by dump tool's owrap() owrap() is called by dump tool's owrap()
useful for wrapping all molecule's atoms/lines the same so it is contiguous useful for wrapping all molecule's atoms/lines the same so it is contiguous
@ -155,15 +155,15 @@ class ldump:
snap = self.read_snapshot(f) snap = self.read_snapshot(f)
if not snap: if not snap:
self.nextfile += 1 self.nextfile += 1
if self.nextfile == len(self.flist): return -1 if self.nextfile == len(self.flist): return -1
f.close() f.close()
self.eof = 0 self.eof = 0
continue continue
self.eof = f.tell() self.eof = f.tell()
f.close() f.close()
try: try:
self.findtime(snap.time) self.findtime(snap.time)
continue continue
except: break except: break
self.snaps.append(snap) self.snaps.append(snap)

View File

@ -28,7 +28,7 @@ nvec = l.nvec # of vectors of thermo info
nlen = l.nlen length of each vectors nlen = l.nlen length of each vectors
names = l.names list of vector names names = l.names list of vector names
t,pe,... = l.get("Time","KE",...) return one or more vectors of values t,pe,... = l.get("Time","KE",...) return one or more vectors of values
l.write("file.txt") write all vectors to a file l.write("file.txt") write all vectors to a file
l.write("file.txt","Time","PE",...) write listed vectors to a file l.write("file.txt","Time","PE",...) write listed vectors to a file
get and write allow abbreviated (uniquely) vector names get and write allow abbreviated (uniquely) vector names
@ -133,9 +133,9 @@ class log:
else: else:
count = 0 count = 0
for i in range(self.nvec): for i in range(self.nvec):
if self.names[i].find(key) == 0: if self.names[i].find(key) == 0:
count += 1 count += 1
index = i index = i
if count == 1: if count == 1:
map.append(index) map.append(index)
else: else:
@ -161,9 +161,9 @@ class log:
else: else:
count = 0 count = 0
for i in range(self.nvec): for i in range(self.nvec):
if self.names[i].find(key) == 0: if self.names[i].find(key) == 0:
count += 1 count += 1
index = i index = i
if count == 1: if count == 1:
map.append(index) map.append(index)
else: else:
@ -224,7 +224,7 @@ class log:
keywords.insert(0,"Step") keywords.insert(0,"Step")
i = 0 i = 0
for keyword in keywords: for keyword in keywords:
self.names.append(keyword) self.names.append(keyword)
self.ptr[keyword] = i self.ptr[keyword] = i
i += 1 i += 1
@ -234,7 +234,7 @@ class log:
line = txt[s1:s2] line = txt[s1:s2]
words = line.split() words = line.split()
for i in range(len(words)): for i in range(len(words)):
self.names.append(words[i]) self.names.append(words[i])
self.ptr[words[i]] = i self.ptr[words[i]] = i
self.nvec = len(self.names) self.nvec = len(self.names)
@ -273,36 +273,36 @@ class log:
if s1 >= 0 and s2 >= 0 and s1 < s2: # found s1,s2 with s1 before s2 if s1 >= 0 and s2 >= 0 and s1 < s2: # found s1,s2 with s1 before s2
if self.style == 2: if self.style == 2:
s1 = txt.find("\n",s1) + 1 s1 = txt.find("\n",s1) + 1
elif s1 >= 0 and s2 >= 0 and s2 < s1: # found s1,s2 with s2 before s1 elif s1 >= 0 and s2 >= 0 and s2 < s1: # found s1,s2 with s2 before s1
s1 = 0 s1 = 0
elif s1 == -1 and s2 >= 0: # found s2, but no s1 elif s1 == -1 and s2 >= 0: # found s2, but no s1
last = 1 last = 1
s1 = 0 s1 = 0
elif s1 >= 0 and s2 == -1: # found s1, but no s2 elif s1 >= 0 and s2 == -1: # found s1, but no s2
last = 1 last = 1
if self.style == 1: if self.style == 1:
s2 = txt.rfind("\n--",s1) + 1 s2 = txt.rfind("\n--",s1) + 1
else: else:
s1 = txt.find("\n",s1) + 1 s1 = txt.find("\n",s1) + 1
s2 = txt.rfind("\n",s1) + 1 s2 = txt.rfind("\n",s1) + 1
eof -= len(txt) - s2 eof -= len(txt) - s2
elif s1 == -1 and s2 == -1: # found neither elif s1 == -1 and s2 == -1: # found neither
# could be end-of-file section # could be end-of-file section
# or entire read was one chunk # or entire read was one chunk
if txt.find("Loop time of",start) == start: # end of file, so exit if txt.find("Loop time of",start) == start: # end of file, so exit
eof -= len(txt) - start # reset eof to "Loop" eof -= len(txt) - start # reset eof to "Loop"
break break
last = 1 # entire read is a chunk last = 1 # entire read is a chunk
s1 = 0 s1 = 0
if self.style == 1: if self.style == 1:
s2 = txt.rfind("\n--",s1) + 1 s2 = txt.rfind("\n--",s1) + 1
else: else:
s2 = txt.rfind("\n",s1) + 1 s2 = txt.rfind("\n",s1) + 1
eof -= len(txt) - s2 eof -= len(txt) - s2
if s1 == s2: break if s1 == s2: break
chunk = txt[s1:s2-1] chunk = txt[s1:s2-1]
start = s2 start = s2

View File

@ -11,12 +11,12 @@
oneline = "Create plots via MatLab numerical analysis program" oneline = "Create plots via MatLab numerical analysis program"
docstr = """ docstr = """
m = matlab() start up MatLab m = matlab() start up MatLab
m.stop() shut down MatLab process m.stop() shut down MatLab process
m.plot(a) plot vector A against linear index m.plot(a) plot vector A against linear index
m.plot(a,b) plot B against A m.plot(a,b) plot B against A
m.plot(a,b,c,d,...) plot B against A, D against C, etc m.plot(a,b,c,d,...) plot B against A, D against C, etc
m.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc m.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc
each plot argument can be a tuple, list, or Numeric/NumPy vector each plot argument can be a tuple, list, or Numeric/NumPy vector
@ -29,9 +29,9 @@ m.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc
m("c = a + b") execute string in MatLab m("c = a + b") execute string in MatLab
m.enter() enter MatLab shell m.enter() enter MatLab shell
matlab> c = a + b type commands directly to MatLab matlab> c = a + b type commands directly to MatLab
matlab> exit, quit exit MatLab shell matlab> exit, quit exit MatLab shell
m.export("data",range(100),a,...) create file with columns of numbers m.export("data",range(100),a,...) create file with columns of numbers
@ -40,12 +40,12 @@ m.export("data",range(100),a,...) create file with columns of numbers
cols = importdata('data') cols = importdata('data')
plot(cols(:,1),cols(:,2)) plot(cols(:,1),cols(:,2))
m.select(N) figure N becomes the current plot m.select(N) figure N becomes the current plot
subsequent commands apply to this plot subsequent commands apply to this plot
m.hide(N) delete window for figure N m.hide(N) delete window for figure N
m.save("file") save current plot as file.eps m.save("file") save current plot as file.eps
Set attributes for current plot: Set attributes for current plot:

View File

@ -12,13 +12,13 @@ oneline = "Read, write, manipulate mesh dump files"
docstr = """ docstr = """
m = mdump("mesh.one") read in one or more mesh dump files m = mdump("mesh.one") read in one or more mesh dump files
m = mdump("mesh.1 mesh.2.gz") can be gzipped m = mdump("mesh.1 mesh.2.gz") can be gzipped
m = mdump("mesh.*") wildcard expands to multiple files m = mdump("mesh.*") wildcard expands to multiple files
m = mdump("mesh.*",0) two args = store filenames, but don't read m = mdump("mesh.*",0) two args = store filenames, but don't read
incomplete and duplicate snapshots are deleted incomplete and duplicate snapshots are deleted
time = m.next() read next snapshot from dump files time = m.next() read next snapshot from dump files
used with 2-argument constructor to allow reading snapshots one-at-a-time used with 2-argument constructor to allow reading snapshots one-at-a-time
snapshot will be skipped only if another snapshot has same time stamp snapshot will be skipped only if another snapshot has same time stamp
@ -28,20 +28,20 @@ time = m.next() read next snapshot from dump files
m.map(2,"temperature") assign names to element value columns (1-N) m.map(2,"temperature") assign names to element value columns (1-N)
m.tselect.all() select all timesteps m.tselect.all() select all timesteps
m.tselect.one(N) select only timestep N m.tselect.one(N) select only timestep N
m.tselect.none() deselect all timesteps m.tselect.none() deselect all timesteps
m.tselect.skip(M) select every Mth step m.tselect.skip(M) select every Mth step
m.tselect.test("$t >= 100 and $t < 10000") select matching timesteps m.tselect.test("$t >= 100 and $t < 10000") select matching timesteps
m.delete() delete non-selected timesteps m.delete() delete non-selected timesteps
selecting a timestep also selects all elements in the timestep selecting a timestep also selects all elements in the timestep
skip() and test() only select from currently selected timesteps skip() and test() only select from currently selected timesteps
test() uses a Python Boolean expression with $t for timestep value test() uses a Python Boolean expression with $t for timestep value
Python comparison syntax: == != < > <= >= and or Python comparison syntax: == != < > <= >= and or
m.eselect.all() select all elems in all steps m.eselect.all() select all elems in all steps
m.eselect.all(N) select all elems in one step m.eselect.all(N) select all elems in one step
m.eselect.test("$id > 100 and $type == 2") select match elems in all steps m.eselect.test("$id > 100 and $type == 2") select match elems in all steps
m.eselect.test("$id > 100 and $type == 2",N) select matching elems in one step m.eselect.test("$id > 100 and $type == 2",N) select matching elems in one step
@ -52,7 +52,7 @@ m.eselect.test("$id > 100 and $type == 2",N) select matching elems in one step
Python comparison syntax: == != < > <= >= and or Python comparison syntax: == != < > <= >= and or
$name must end with a space $name must end with a space
t = m.time() return vector of selected timestep values t = m.time() return vector of selected timestep values
fx,fy,... = m.vecs(1000,"fx","fy",...) return vector(s) for timestep N fx,fy,... = m.vecs(1000,"fx","fy",...) return vector(s) for timestep N
vecs() returns vectors with one value for each selected elem in the timestep vecs() returns vectors with one value for each selected elem in the timestep
@ -253,15 +253,15 @@ class mdump:
snap = self.read_snapshot(f) snap = self.read_snapshot(f)
if not snap: if not snap:
self.nextfile += 1 self.nextfile += 1
if self.nextfile == len(self.flist): return -1 if self.nextfile == len(self.flist): return -1
f.close() f.close()
self.eof = 0 self.eof = 0
continue continue
self.eof = f.tell() self.eof = f.tell()
f.close() f.close()
try: try:
self.findtime(snap.time) self.findtime(snap.time)
continue continue
except: break except: break
# select the new snapshot with all its elements # select the new snapshot with all its elements

View File

@ -15,8 +15,8 @@ p = pair("lj/charmm/coul/charmm") create pair object for specific pair style
available styles: lj/cut, lj/cut/coul/cut, lj/charmm/coul/charmm available styles: lj/cut, lj/cut/coul/cut, lj/charmm/coul/charmm
p.coeff(d) extract pairwise coeffs from data object p.coeff(d) extract pairwise coeffs from data object
p.init(cut1,cut2,...) setup based on coeffs and cutoffs p.init(cut1,cut2,...) setup based on coeffs and cutoffs
init args are specific to pair style: init args are specific to pair style:
lj/cut = cutlj lj/cut = cutlj
@ -156,7 +156,7 @@ class pair:
# args = cutlj, cut_coul (cut_coul optional) # args = cutlj, cut_coul (cut_coul optional)
def init_lj_cut_coul_cut(self,list): def init_lj_cut_coul_cut(self,list):
self.qqr2e = 332.0636 # convert energy to kcal/mol self.qqr2e = 332.0636 # convert energy to kcal/mol
cut_lj = list[0] cut_lj = list[0]
self.cut_ljsq = cut_lj*cut_lj self.cut_ljsq = cut_lj*cut_lj
@ -210,7 +210,7 @@ class pair:
# args = cutlj_inner,cutlj,cutcoul_inner,cut_coul (last 2 optional) # args = cutlj_inner,cutlj,cutcoul_inner,cut_coul (last 2 optional)
def init_lj_charmm_coul_charmm(self,list): def init_lj_charmm_coul_charmm(self,list):
self.qqr2e = 332.0636 # convert energy to kcal/mol self.qqr2e = 332.0636 # convert energy to kcal/mol
cut_lj_inner = list[0] cut_lj_inner = list[0]
cut_lj = list[1] cut_lj = list[1]

View File

@ -14,9 +14,9 @@ docstr = """
p = patch(vfrac) setup box with a specified volume fraction p = patch(vfrac) setup box with a specified volume fraction
p = patch(vfrac,1,1,2) x,y,z = aspect ratio of box (def = 1,1,1) p = patch(vfrac,1,1,2) x,y,z = aspect ratio of box (def = 1,1,1)
p.seed = 48379 set random # seed (def = 12345) p.seed = 48379 set random # seed (def = 12345)
p.randomized = 0 1 = choose next particle randomly, 0 = as generated p.randomized = 0 1 = choose next particle randomly, 0 = as generated
p.dim = 2 set dimension of created box (def = 3) p.dim = 2 set dimension of created box (def = 3)
p.blen = 0.97 set length of tether bonds (def = 0.97) p.blen = 0.97 set length of tether bonds (def = 0.97)
p.dmin = 1.02 set min r from i-1 to i+1 tether site (def = 1.02) p.dmin = 1.02 set min r from i-1 to i+1 tether site (def = 1.02)
p.lattice = [Nx,Ny,Nz] generate Nx by Ny by Nz lattice of particles p.lattice = [Nx,Ny,Nz] generate Nx by Ny by Nz lattice of particles

View File

@ -26,12 +26,12 @@ type ? for help, CTRL-D to quit
help = """ help = """
pizza.py switch arg(s) switch arg(s) ... pizza.py switch arg(s) switch arg(s) ...
-s silent (else print start-up help) -s silent (else print start-up help)
-t log dump raster load only these tools -t log dump raster load only these tools
-x raster rasmol load all tools except these -x raster rasmol load all tools except these
-f mine.py arg1 arg2 run script file with args -f mine.py arg1 arg2 run script file with args
-c "vec = range(100)" run Python command -c "vec = range(100)" run Python command
-q quit (else interactive) -q quit (else interactive)
Everything typed at the ">" prompt is a Python command Everything typed at the ">" prompt is a Python command

View File

@ -16,8 +16,8 @@ r = raster(d) create Raster3d wrapper for data in d
d = atom snapshot object (dump, data) d = atom snapshot object (dump, data)
r.bg("black") set background color (def = "black") r.bg("black") set background color (def = "black")
r.size(N) set image size to NxN r.size(N) set image size to NxN
r.size(N,M) set image size to NxM r.size(N,M) set image size to NxM
r.rotate(60,135) view from z theta and azimuthal phi (def = 60,30) r.rotate(60,135) view from z theta and azimuthal phi (def = 60,30)
r.shift(x,y) translate by x,y pixels in view window (def = 0,0) r.shift(x,y) translate by x,y pixels in view window (def = 0,0)
r.zoom(0.5) scale image by factor (def = 1) r.zoom(0.5) scale image by factor (def = 1)
@ -49,9 +49,9 @@ r.nolabel() delete all labels
x,y coords = -0.5 to 0.5, "h" or "t" for Helvetica or Times font x,y coords = -0.5 to 0.5, "h" or "t" for Helvetica or Times font
size = fontsize (e.g. 10), "red" = color of text size = fontsize (e.g. 10), "red" = color of text
r.acol(2,"green") set atom colors by atom type (1-N) r.acol(2,"green") set atom colors by atom type (1-N)
r.acol([2,4],["red","blue"]) 1st arg = one type or list of types r.acol([2,4],["red","blue"]) 1st arg = one type or list of types
r.acol(0,"blue") 2nd arg = one color or list of colors r.acol(0,"blue") 2nd arg = one color or list of colors
r.acol(range(20),["red","blue"]) if list lengths unequal, interpolate r.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
r.acol(range(10),"loop") assign colors in loop, randomly ordered r.acol(range(10),"loop") assign colors in loop, randomly ordered
@ -61,19 +61,19 @@ r.acol(range(10),"loop") assign colors in loop, randomly ordered
r.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol() r.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol()
r.bcol() set bond color, same args as acol() r.bcol() set bond color, same args as acol()
r.brad() set bond thickness, same args as arad() r.brad() set bond thickness, same args as arad()
r.tcol() set triangle color, same args as acol() r.tcol() set triangle color, same args as acol()
r.tfill() set triangle fill, 0 fill, 1 line, 2 both r.tfill() set triangle fill, 0 fill, 1 line, 2 both
r.lcol() set line color, same args as acol() r.lcol() set line color, same args as acol()
r.lrad() set line thickness, same args as arad() r.lrad() set line thickness, same args as arad()
r.adef() set atom/bond/tri/line properties to default r.adef() set atom/bond/tri/line properties to default
r.bdef() default = "loop" for colors, 0.45 for radii r.bdef() default = "loop" for colors, 0.45 for radii
r.tdef() default = 0.25 for bond/line thickness r.tdef() default = 0.25 for bond/line thickness
r.ldef() default = 0 fill r.ldef() default = 0 fill
by default 100 types are assigned by default 100 types are assigned
if atom/bond/tri/line has type > # defined properties, is an error if atom/bond/tri/line has type > # defined properties, is an error
@ -297,9 +297,9 @@ class raster:
self.scale = self.scale_start + \ self.scale = self.scale_start + \
fraction*(self.scale_stop - self.scale_start) fraction*(self.scale_stop - self.scale_start)
if n == nstart or self.panflag: if n == nstart or self.panflag:
self.xtrans = self.ytrans = self.ztrans = 0.0 self.xtrans = self.ytrans = self.ztrans = 0.0
output = self.single(1,file,box,atoms,bonds,tris,lines) output = self.single(1,file,box,atoms,bonds,tris,lines)
nums = re.findall("translation to:\s*(\S*)\s*(\S*)\s*(\S*)\s",output) nums = re.findall("translation to:\s*(\S*)\s*(\S*)\s*(\S*)\s",output)
self.xtrans = float(nums[0][0]) self.xtrans = float(nums[0][0])
self.ytrans = float(nums[0][1]) self.ytrans = float(nums[0][1])
@ -344,9 +344,9 @@ class raster:
self.scale = self.scale_start + \ self.scale = self.scale_start + \
fraction*(self.scale_stop - self.scale_start) fraction*(self.scale_stop - self.scale_start)
if n == nstart or self.panflag: if n == nstart or self.panflag:
self.xtrans = self.ytrans = self.ztrans = 0.0 self.xtrans = self.ytrans = self.ztrans = 0.0
output = self.single(1,file,box,atoms,bonds,tris,lines) output = self.single(1,file,box,atoms,bonds,tris,lines)
nums = re.findall("translation to:\s*(\S*)\s*(\S*)\s*(\S*)\s",output) nums = re.findall("translation to:\s*(\S*)\s*(\S*)\s*(\S*)\s",output)
self.xtrans = float(nums[0][0]) self.xtrans = float(nums[0][0])
self.ytrans = float(nums[0][1]) self.ytrans = float(nums[0][1])
@ -527,31 +527,31 @@ def box_write(f,box,color,thick):
blue = color[2] blue = color[2]
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,ylo,zlo,thick,xhi,ylo,zlo,thick,red,green,blue) (xlo,ylo,zlo,thick,xhi,ylo,zlo,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,yhi,zlo,thick,xhi,yhi,zlo,thick,red,green,blue) (xlo,yhi,zlo,thick,xhi,yhi,zlo,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,ylo,zhi,thick,xhi,ylo,zhi,thick,red,green,blue) (xlo,ylo,zhi,thick,xhi,ylo,zhi,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,yhi,zhi,thick,xhi,yhi,zhi,thick,red,green,blue) (xlo,yhi,zhi,thick,xhi,yhi,zhi,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,ylo,zlo,thick,xlo,yhi,zlo,thick,red,green,blue) (xlo,ylo,zlo,thick,xlo,yhi,zlo,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xhi,ylo,zlo,thick,xhi,yhi,zlo,thick,red,green,blue) (xhi,ylo,zlo,thick,xhi,yhi,zlo,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,ylo,zhi,thick,xlo,yhi,zhi,thick,red,green,blue) (xlo,ylo,zhi,thick,xlo,yhi,zhi,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xhi,ylo,zhi,thick,xhi,yhi,zhi,thick,red,green,blue) (xhi,ylo,zhi,thick,xhi,yhi,zhi,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,ylo,zlo,thick,xlo,ylo,zhi,thick,red,green,blue) (xlo,ylo,zlo,thick,xlo,ylo,zhi,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xhi,ylo,zlo,thick,xhi,ylo,zhi,thick,red,green,blue) (xhi,ylo,zlo,thick,xhi,ylo,zhi,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xlo,yhi,zlo,thick,xlo,yhi,zhi,thick,red,green,blue) (xlo,yhi,zlo,thick,xlo,yhi,zhi,thick,red,green,blue)
print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \ print >>f,"3\n%g %g %g %g %g %g %g %g %g %g %g" % \
(xhi,yhi,zlo,thick,xhi,yhi,zhi,thick,red,green,blue) (xhi,yhi,zlo,thick,xhi,yhi,zhi,thick,red,green,blue)
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# compute 3x3 rotation matrix for viewing angle # compute 3x3 rotation matrix for viewing angle
@ -634,7 +634,7 @@ def rotation_matrix(coord1,angle1,coord2,angle2):
# each line padded with 0.0 for 4x4 raster3d matrix # each line padded with 0.0 for 4x4 raster3d matrix
matrix = "%g %g %g 0.0\n%g %g %g 0.0\n%g %g %g 0.0" % \ matrix = "%g %g %g 0.0\n%g %g %g 0.0\n%g %g %g 0.0" % \
(c11,c12,c13,c21,c22,c23,c31,c32,c33) (c11,c12,c13,c21,c22,c23,c31,c32,c33)
return matrix return matrix
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -16,8 +16,8 @@ s = svg(d) create SVG object for data in d
d = atom snapshot object (dump, data) d = atom snapshot object (dump, data)
s.bg("black") set background color (def = "black") s.bg("black") set background color (def = "black")
s.size(N) set image size to NxN s.size(N) set image size to NxN
s.size(N,M) set image size to NxM s.size(N,M) set image size to NxM
s.rotate(60,135) view from z theta and azimuthal phi (def = 60,30) s.rotate(60,135) view from z theta and azimuthal phi (def = 60,30)
s.shift(x,y) translate by x,y pixels in view window (def = 0,0) s.shift(x,y) translate by x,y pixels in view window (def = 0,0)
s.zoom(0.5) scale image by factor (def = 1) s.zoom(0.5) scale image by factor (def = 1)
@ -49,9 +49,9 @@ s.nolabel() delete all labels
x,y coords = -0.5 to 0.5, "h" or "t" for Helvetica or Times font x,y coords = -0.5 to 0.5, "h" or "t" for Helvetica or Times font
size = fontsize (e.g. 10), "red" = color of text size = fontsize (e.g. 10), "red" = color of text
s.acol(2,"green") set atom colors by atom type (1-N) s.acol(2,"green") set atom colors by atom type (1-N)
s.acol([2,4],["red","blue"]) 1st arg = one type or list of types s.acol([2,4],["red","blue"]) 1st arg = one type or list of types
s.acol(0,"blue") 2nd arg = one color or list of colors s.acol(0,"blue") 2nd arg = one color or list of colors
s.acol(range(20),["red","blue"]) if list lengths unequal, interpolate s.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
s.acol(range(10),"loop") assign colors in loop, randomly ordered s.acol(range(10),"loop") assign colors in loop, randomly ordered
@ -61,19 +61,19 @@ s.acol(range(10),"loop") assign colors in loop, randomly ordered
s.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol() s.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol()
s.bcol() set bond color, same args as acol() s.bcol() set bond color, same args as acol()
s.brad() set bond thickness, same args as arad() s.brad() set bond thickness, same args as arad()
s.tcol() set triangle color, same args as acol() s.tcol() set triangle color, same args as acol()
s.tfill() set triangle fill, 0 fill, 1 line, 2 both s.tfill() set triangle fill, 0 fill, 1 line, 2 both
s.lcol() set line color, same args as acol() s.lcol() set line color, same args as acol()
s.lrad() set line thickness, same args as arad() s.lrad() set line thickness, same args as arad()
s.adef() set atom/bond/tri/line properties to default s.adef() set atom/bond/tri/line properties to default
s.bdef() default = "loop" for colors, 0.45 for radii s.bdef() default = "loop" for colors, 0.45 for radii
s.tdef() default = 0.25 for bond/line thickness s.tdef() default = 0.25 for bond/line thickness
s.ldef() default = 0 fill s.ldef() default = 0 fill
by default 100 types are assigned by default 100 types are assigned
if atom/bond/tri/line has type > # defined properties, is an error if atom/bond/tri/line has type > # defined properties, is an error
@ -248,10 +248,10 @@ class svg:
fraction = float(i) / (ncount-1) fraction = float(i) / (ncount-1)
if self.select != "": if self.select != "":
newstr = self.select % fraction newstr = self.select % fraction
data.aselect.test(newstr,time) data.aselect.test(newstr,time)
time,boxone,atoms,bonds,tris,lines = data.viz(which) time,boxone,atoms,bonds,tris,lines = data.viz(which)
if self.boxflag < 2: box = boxone if self.boxflag < 2: box = boxone
if n == nstart: self.distance = compute_distance(box) if n == nstart: self.distance = compute_distance(box)
@ -261,7 +261,7 @@ class svg:
elif n < 1000: file = self.file + "0" + str(n) elif n < 1000: file = self.file + "0" + str(n)
else: file = self.file + str(n) else: file = self.file + str(n)
if self.panflag: if self.panflag:
self.ztheta = self.ztheta_start + \ self.ztheta = self.ztheta_start + \
fraction*(self.ztheta_stop - self.ztheta_start) fraction*(self.ztheta_stop - self.ztheta_start)
self.azphi = self.azphi_start + \ self.azphi = self.azphi_start + \
@ -270,9 +270,9 @@ class svg:
fraction*(self.scale_stop - self.scale_start) fraction*(self.scale_stop - self.scale_start)
scaleflag = 0 scaleflag = 0
if n == nstart or self.panflag: scaleflag = 1 if n == nstart or self.panflag: scaleflag = 1
self.single(file,box,atoms,bonds,tris,lines,scaleflag) self.single(file,box,atoms,bonds,tris,lines,scaleflag)
print time, print time,
sys.stdout.flush() sys.stdout.flush()
i += 1 i += 1
@ -290,7 +290,7 @@ class svg:
for i in range(ncount): for i in range(ncount):
fraction = float(i) / (ncount-1) fraction = float(i) / (ncount-1)
if self.select != "": if self.select != "":
newstr = self.select % fraction newstr = self.select % fraction
data.aselect.test(newstr,ntime) data.aselect.test(newstr,ntime)
time,boxone,atoms,bonds,tris,lines = data.viz(which) time,boxone,atoms,bonds,tris,lines = data.viz(which)
@ -303,18 +303,18 @@ class svg:
elif n < 1000: file = self.file + "0" + str(n) elif n < 1000: file = self.file + "0" + str(n)
else: file = self.file + str(n) else: file = self.file + str(n)
if self.panflag: if self.panflag:
self.ztheta = self.ztheta_start + \ self.ztheta = self.ztheta_start + \
fraction*(self.ztheta_stop - self.ztheta_start) fraction*(self.ztheta_stop - self.ztheta_start)
self.azphi = self.azphi_start + \ self.azphi = self.azphi_start + \
fraction*(self.azphi_stop - self.azphi_start) fraction*(self.azphi_stop - self.azphi_start)
self.scale = self.scale_start + \ self.scale = self.scale_start + \
fraction*(self.scale_stop - self.scale_start) fraction*(self.scale_stop - self.scale_start)
scaleflag = 0 scaleflag = 0
if n == nstart or self.panflag: scaleflag = 1 if n == nstart or self.panflag: scaleflag = 1
self.single(file,box,atoms,bonds,tris,lines,scaleflag) self.single(file,box,atoms,bonds,tris,lines,scaleflag)
print n, print n,
sys.stdout.flush() sys.stdout.flush()
n += 1 n += 1
@ -512,18 +512,18 @@ class svg:
if flag == 0: if flag == 0:
if obj[0] == 0: # atom with its color and radius if obj[0] == 0: # atom with its color and radius
itype = int(obj[1]) itype = int(obj[1])
if itype > self.vizinfo.nacolor: if itype > self.vizinfo.nacolor:
raise StandardError,"atom type too big" raise StandardError,"atom type too big"
color = self.vizinfo.acolor[itype] color = self.vizinfo.acolor[itype]
rad = self.vizinfo.arad[itype] rad = self.vizinfo.arad[itype]
print >>f,'<circle cx="%s" cy="%s" r="%s" fill="rgb(%s,%s,%s)" stroke-width="%s" />' % \ print >>f,'<circle cx="%s" cy="%s" r="%s" fill="rgb(%s,%s,%s)" stroke-width="%s" />' % \
(obj[2],obj[3],rad*self.factor, (obj[2],obj[3],rad*self.factor,
color[0]*255,color[1]*255,color[2]*255,self.thick) color[0]*255,color[1]*255,color[2]*255,self.thick)
elif obj[0] == 1: # tri with its color (need to add fill type) elif obj[0] == 1: # tri with its color (need to add fill type)
itype = int(obj[1]) itype = int(obj[1])
if itype > self.vizinfo.ntcolor: if itype > self.vizinfo.ntcolor:
raise StandardError,"tri type too big" raise StandardError,"tri type too big"
color = self.vizinfo.tcolor[itype] color = self.vizinfo.tcolor[itype]
print >>f,'<polygon points= "%s,%s %s,%s %s,%s" fill="rgb(%s,%s,%s)" stroke="black" stroke-width="0.01" />' % \ print >>f,'<polygon points= "%s,%s %s,%s %s,%s" fill="rgb(%s,%s,%s)" stroke="black" stroke-width="0.01" />' % \
@ -532,17 +532,17 @@ class svg:
elif obj[0] == 2: # bond with its color and thickness elif obj[0] == 2: # bond with its color and thickness
itype = int(obj[1]) itype = int(obj[1])
if itype > self.vizinfo.nbcolor: if itype > self.vizinfo.nbcolor:
raise StandardError,"bond type too big" raise StandardError,"bond type too big"
color = self.vizinfo.bcolor[itype] color = self.vizinfo.bcolor[itype]
thick = self.vizinfo.brad[itype] thick = self.vizinfo.brad[itype]
print >>f,'<line x1="%s" y1="%s" x2="%s" y2="%s" stroke="rgb(%s,%s,%s)" stroke-width="%s" />' % \ print >>f,'<line x1="%s" y1="%s" x2="%s" y2="%s" stroke="rgb(%s,%s,%s)" stroke-width="%s" />' % \
(obj[2],obj[3],obj[5],obj[6], (obj[2],obj[3],obj[5],obj[6],
color[0]*255,color[1]*255,color[2]*255,thick*self.factor) color[0]*255,color[1]*255,color[2]*255,thick*self.factor)
elif obj[0] == 3: # line with its color and thickness elif obj[0] == 3: # line with its color and thickness
itype = int(obj[1]) itype = int(obj[1])
if itype > self.vizinfo.nlcolor: if itype > self.vizinfo.nlcolor:
raise StandardError,"line type too big" raise StandardError,"line type too big"
color = self.vizinfo.lcolor[itype] color = self.vizinfo.lcolor[itype]
thick = self.vizinfo.lrad[itype] thick = self.vizinfo.lrad[itype]

View File

@ -12,14 +12,14 @@ oneline = "Read dump files with triangle info"
docstr = """ docstr = """
t = tdump("dump.one") read in one or more dump files t = tdump("dump.one") read in one or more dump files
t = tdump("dump.1 dump.2.gz") can be gzipped t = tdump("dump.1 dump.2.gz") can be gzipped
t = tdump("dump.*") wildcard expands to multiple files t = tdump("dump.*") wildcard expands to multiple files
t = tdump("dump.*",0) two args = store filenames, but don't read t = tdump("dump.*",0) two args = store filenames, but don't read
incomplete and duplicate snapshots are deleted incomplete and duplicate snapshots are deleted
no column name assignment is performed no column name assignment is performed
time = t.next() read next snapshot from dump files time = t.next() read next snapshot from dump files
used with 2-argument constructor to allow reading snapshots one-at-a-time used with 2-argument constructor to allow reading snapshots one-at-a-time
snapshot will be skipped only if another snapshot has same time stamp snapshot will be skipped only if another snapshot has same time stamp
@ -43,7 +43,7 @@ time,box,atoms,bonds,tris,lines = t.viz(index) return list of viz objects
id,type are from associated atom id,type are from associated atom
lines = NULL lines = NULL
t.owrap(...) wrap tris to same image as their atoms t.owrap(...) wrap tris to same image as their atoms
owrap() is called by dump tool's owrap() owrap() is called by dump tool's owrap()
useful for wrapping all molecule's atoms/tris the same so it is contiguous useful for wrapping all molecule's atoms/tris the same so it is contiguous
@ -156,15 +156,15 @@ class tdump:
snap = self.read_snapshot(f) snap = self.read_snapshot(f)
if not snap: if not snap:
self.nextfile += 1 self.nextfile += 1
if self.nextfile == len(self.flist): return -1 if self.nextfile == len(self.flist): return -1
f.close() f.close()
self.eof = 0 self.eof = 0
continue continue
self.eof = f.tell() self.eof = f.tell()
f.close() f.close()
try: try:
self.findtime(snap.time) self.findtime(snap.time)
continue continue
except: break except: break
self.snaps.append(snap) self.snaps.append(snap)
@ -295,8 +295,8 @@ class tdump:
corner3y = self.names["corner3y"] corner3y = self.names["corner3y"]
corner3z = self.names["corner3z"] corner3z = self.names["corner3z"]
# create line list from id,type,corner1x,...corner3z # create tris list from id,type,corner1x,...corner3z
# don't add line if all 4 values are 0 since not a line # don't add tri if all 4 values are 0 since not a line
tris = [] tris = []
for i in xrange(snap.natoms): for i in xrange(snap.natoms):

View File

@ -16,26 +16,26 @@ v.add(gl) add a gl window to vcr GUI
Actions (same as GUI widgets): Actions (same as GUI widgets):
v.first() go to first frame v.first() go to first frame
v.prev() go to previous frame v.prev() go to previous frame
v.back() play backwards from current frame to start v.back() play backwards from current frame to start
v.stop() stop on current frame v.stop() stop on current frame
v.play() play from current frame to end v.play() play from current frame to end
v.next() go to next frame v.next() go to next frame
v.last() go to last frame v.last() go to last frame
v.frame(31) set frame slider v.frame(31) set frame slider
v.delay(0.4) set delay slider v.delay(0.4) set delay slider
v.q(5) set quality slider v.q(5) set quality slider
v.xaxis() view scene from x axis v.xaxis() view scene from x axis
v.yaxis() view scene from y axis v.yaxis() view scene from y axis
v.zaxis() view scene from z axis v.zaxis() view scene from z axis
v.box() toggle bounding box v.box() toggle bounding box
v.axis() toggle display of xyz axes v.axis() toggle display of xyz axes
v.norm() recenter and resize the view v.norm() recenter and resize the view
v.ortho() toggle ortho/perspective button v.ortho() toggle ortho/perspective button
v.reload() reload all frames from gl viewer data files v.reload() reload all frames from gl viewer data files
v.clipxlo(0.2) clip scene at x lo fraction of box v.clipxlo(0.2) clip scene at x lo fraction of box
v.clipxhi(1.0) clip at x hi v.clipxhi(1.0) clip at x hi
@ -44,9 +44,9 @@ v.clipyhi(1.0)
v.clipzlo(0.2) clip in z v.clipzlo(0.2) clip in z
v.clipzhi(1.0) v.clipzhi(1.0)
v.save() save current scene to file.png v.save() save current scene to file.png
v.file("image") set filename v.file("image") set filename
v.saveall() toggle save-all checkbox v.saveall() toggle save-all checkbox
""" """
# History # History

View File

@ -19,10 +19,10 @@ v = vec(array) array = list of numeric vectors
assigns names = "col1", "col2", etc assigns names = "col1", "col2", etc
nvec = v.nvec # of vectors nvec = v.nvec # of vectors
nlen = v.nlen lengths of vectors nlen = v.nlen lengths of vectors
names = v.names list of vector names names = v.names list of vector names
x,y,... = l.get(1,"col2",...) return one or more vectors of values x,y,... = l.get(1,"col2",...) return one or more vectors of values
l.write("file.txt") write all vectors to a file l.write("file.txt") write all vectors to a file
l.write("file.txt","col1",7,...) write listed vectors to a file l.write("file.txt","col1",7,...) write listed vectors to a file
get and write allow abbreviated (uniquely) vector names or digits (1-Nvec) get and write allow abbreviated (uniquely) vector names or digits (1-Nvec)
@ -99,9 +99,9 @@ class vec:
else: else:
count = 0 count = 0
for i in range(self.nvec): for i in range(self.nvec):
if self.names[i].find(key) == 0: if self.names[i].find(key) == 0:
count += 1 count += 1
index = i index = i
if count == 1: if count == 1:
map.append(index) map.append(index)
else: else:
@ -127,9 +127,9 @@ class vec:
else: else:
count = 0 count = 0
for i in range(self.nvec): for i in range(self.nvec):
if self.names[i].find(key) == 0: if self.names[i].find(key) == 0:
count += 1 count += 1
index = i index = i
if count == 1: if count == 1:
map.append(index) map.append(index)
else: else:

View File

@ -17,24 +17,24 @@
oneline = "Control VMD from python" oneline = "Control VMD from python"
docstr = """ docstr = """
v = vmd() start up VMD v = vmd() start up VMD
v.stop() shut down VMD instance v.stop() shut down VMD instance
v.clear() delete all visualizations v.clear() delete all visualizations
v.rep(style) set default representation style. One of v.rep(style) set default representation style. One of
(Lines|VDW|Licorice|DynamicBonds|Points|CPK) (Lines|VDW|Licorice|DynamicBonds|Points|CPK)
v.new(file[,type]) load new file (default file type 'lammpstrj') v.new(file[,type]) load new file (default file type 'lammpstrj')
v.data(file[,atomstyle]) load new data file (default atom style 'full') v.data(file[,atomstyle]) load new data file (default atom style 'full')
v.replace(file[,type]) replace current frames with new file v.replace(file[,type]) replace current frames with new file
v.append(file[,type]) append file to current frame(s) v.append(file[,type]) append file to current frame(s)
v.set(snap,x,y,z,(True|False)) set coordinates from a pizza.py snapshot to new or current frame v.set(snap,x,y,z,(True|False)) set coordinates from a pizza.py snapshot to new or current frame
v.frame(frame) set current frame v.frame(frame) set current frame
v.flush() flush pending input to VMD and update GUI v.flush() flush pending input to VMD and update GUI
v.read(file) read Tcl script file (e.g. saved state) v.read(file) read Tcl script file (e.g. saved state)
v.enter() enter interactive shell v.enter() enter interactive shell
v.debug([True|False]) display generated VMD script commands? v.debug([True|False]) display generated VMD script commands?
""" """
# History # History

View File

@ -11,7 +11,7 @@
oneline = "Convert LAMMPS snapshots to VTK format" oneline = "Convert LAMMPS snapshots to VTK format"
docstr = """ docstr = """
v = vtk(d) d = object containing atom coords (dump, data) v = vtk(d) d = object containing atom coords (dump, data)
v.one() write all snapshots to tmp.vtk v.one() write all snapshots to tmp.vtk
v.one("new") write all snapshots to new.vtk v.one("new") write all snapshots to new.vtk

View File

@ -11,7 +11,7 @@
oneline = "Convert LAMMPS snapshots to XYZ format" oneline = "Convert LAMMPS snapshots to XYZ format"
docstr = """ docstr = """
x = xyz(d) d = object containing atom coords (dump, data) x = xyz(d) d = object containing atom coords (dump, data)
x.one() write all snapshots to tmp.xyz x.one() write all snapshots to tmp.xyz
x.one("new") write all snapshots to new.xyz x.one("new") write all snapshots to new.xyz