mirror of
https://github.com/ParticulateFlow/LPP.git
synced 2025-12-08 06:37:46 +00:00
convert tabs to spaces, remove extra spaces, fix comments
This commit is contained in:
@ -39,10 +39,10 @@ def distance(box,x1,y1,z1,x2,y2,z2):
|
||||
if len(argv) < 3:
|
||||
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)
|
||||
|
||||
files = ' '.join(argv[2:]) # dump files
|
||||
files = ' '.join(argv[2:]) # dump files
|
||||
d = dump(files,0)
|
||||
d.map(1,"id",2,"type",3,"x",4,"y",5,"z")
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# simple test of data tool
|
||||
# requires files/data.micelle
|
||||
# requires files/data.micelle and dump.micelle
|
||||
# creates tmp.data
|
||||
|
||||
d = data("files/data.micelle")
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
# simple test of vcr tool
|
||||
# requires files/bucky*png files
|
||||
|
||||
d = dump("files/dump.micelle")
|
||||
dt = data("files/data.micelle")
|
||||
|
||||
@ -17,7 +17,7 @@ if len(argv) < 3:
|
||||
maxcut = float(argv[1])
|
||||
maxcut_sq = maxcut*maxcut
|
||||
|
||||
files = ' '.join(argv[2:]) # dump files
|
||||
files = ' '.join(argv[2:]) # dump files
|
||||
d = dump(files,0)
|
||||
d.map(1,"id",2,"type",3,"x",4,"y",5,"z")
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
# Purpose: create images from LAMMPS dump snapshots
|
||||
# Syntax: movie.py raster/svg theta phi dump.1 dump.2 ...
|
||||
# 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
|
||||
# Example: movie.py svg 60 130 dump.*
|
||||
# Author: Steve Plimpton (Sandia)
|
||||
|
||||
@ -15,16 +15,16 @@ a = animate("image*.png") create GUI to animate set of image files
|
||||
|
||||
Actions (same as GUI widgets):
|
||||
|
||||
a.first() go to first frame
|
||||
a.first() go to first frame
|
||||
a.prev() go to previous frame
|
||||
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.next() go to next frame
|
||||
a.last() go to last frame
|
||||
a.next() go to next frame
|
||||
a.last() go to last frame
|
||||
|
||||
a.frame(31) set frame slider
|
||||
a.delay(0.4) set delay slider
|
||||
a.frame(31) set frame slider
|
||||
a.delay(0.4) set delay slider
|
||||
"""
|
||||
|
||||
# History
|
||||
|
||||
16
src/bdump.py
16
src/bdump.py
@ -12,14 +12,14 @@ oneline = "Read dump files with bond info"
|
||||
|
||||
docstr = """
|
||||
b = bdump("dump.one") read in one or more dump files
|
||||
b = bdump("dump.1 dump.2.gz") can be gzipped
|
||||
b = bdump("dump.*") wildcard expands to multiple files
|
||||
b = bdump("dump.*",0) two args = store filenames, but don't read
|
||||
b = bdump("dump.1 dump.2.gz") can be gzipped
|
||||
b = bdump("dump.*") wildcard expands to multiple files
|
||||
b = bdump("dump.*",0) two args = store filenames, but don't read
|
||||
|
||||
incomplete and duplicate snapshots are deleted
|
||||
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
|
||||
snapshot will be skipped only if another snapshot has same time stamp
|
||||
@ -148,15 +148,15 @@ class bdump:
|
||||
snap = self.read_snapshot(f)
|
||||
if not snap:
|
||||
self.nextfile += 1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
f.close()
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = f.tell()
|
||||
f.close()
|
||||
try:
|
||||
self.findtime(snap.time)
|
||||
continue
|
||||
continue
|
||||
except: break
|
||||
|
||||
self.snaps.append(snap)
|
||||
|
||||
40
src/cdata.py
40
src/cdata.py
@ -13,11 +13,11 @@
|
||||
oneline = "Read, create, manipulate ChemCell data files"
|
||||
|
||||
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.part.gz mem.surf") can be gzipped
|
||||
c = cdata("mem.*") wildcard expands to multiple files
|
||||
c.read("mem.surf") read in one or more data files
|
||||
c = cdata("mem.*") wildcard expands to multiple files
|
||||
c.read("mem.surf") read in one or more data files
|
||||
|
||||
read() has same argument options as constructor
|
||||
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
|
||||
|
||||
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.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.cap(ID,'x',c1,c2,r,lo,hi) create a axis-aligned capped-cylinder 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.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.q(ID,q1,q2,...) set region triangulation quality factors
|
||||
|
||||
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"
|
||||
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,id_out) particles are also outside object id_out
|
||||
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.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.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.seed(43284) set random # seed (def = 12345)
|
||||
c.seed(43284) set random # seed (def = 12345)
|
||||
|
||||
generate particle positions randomly (unless otherwise noted)
|
||||
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
|
||||
|
||||
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.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
|
||||
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
|
||||
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.delete(id1,id2,...) delete one or more objects
|
||||
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 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()
|
||||
|
||||
c.write("file") write all selected objs to ChemCell 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",id1,id2,...) append only listed & selected objects
|
||||
c.write("file") write all selected objs to ChemCell 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",id1,id2,...) append only listed & selected objects
|
||||
|
||||
union objects are skipped, not written to file
|
||||
|
||||
@ -800,8 +800,6 @@ class cdata:
|
||||
# bracket pt = xyz +/- scale*dir
|
||||
# multiply scale by factor each iteration
|
||||
|
||||
#print "AAA",i,start,stop,x,y,z,dir
|
||||
|
||||
scale = EPS
|
||||
bracket = start
|
||||
while scale < maxscale:
|
||||
@ -1166,7 +1164,7 @@ class cdata:
|
||||
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):
|
||||
if isnap:
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
oneline = "Convert LAMMPS snapshots to AtomEye CFG format"
|
||||
|
||||
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("new") write all snapshots to new.cfg
|
||||
|
||||
12
src/chain.py
12
src/chain.py
@ -12,11 +12,11 @@ oneline = "Create bead-spring chains for LAMMPS input"
|
||||
|
||||
docstr = """
|
||||
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.mtype = 2 set type of monomers (def = 1)
|
||||
c.btype = 1 set type of bonds (def = 1)
|
||||
c.mtype = 2 set type of monomers (def = 1)
|
||||
c.btype = 1 set type of bonds (def = 1)
|
||||
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)
|
||||
|
||||
@ -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 = "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
|
||||
must fill box with total of N monomers
|
||||
@ -112,7 +112,7 @@ class chain:
|
||||
x = self.xlo + self.random()*self.xprd
|
||||
y = self.ylo + self.random()*self.yprd
|
||||
z = self.zlo + self.random()*self.zprd
|
||||
ix = iy = iz = 0
|
||||
ix = iy = iz = 0
|
||||
else:
|
||||
restriction = True
|
||||
while restriction:
|
||||
@ -150,7 +150,7 @@ class chain:
|
||||
|
||||
atoms.append([idatom,idmol,self.mtype,x,y,z,ix,iy,iz])
|
||||
if imonomer:
|
||||
bondid = id_bond_prev + imonomer
|
||||
bondid = id_bond_prev + imonomer
|
||||
bonds.append([bondid,self.btype,idatom-1,idatom])
|
||||
|
||||
self.atoms += atoms
|
||||
|
||||
30
src/clog.py
30
src/clog.py
@ -26,7 +26,7 @@ nvec = c.nvec # of vectors of thermo info
|
||||
nlen = c.nlen length of each vectors
|
||||
names = c.names list of vector names
|
||||
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
|
||||
|
||||
get and write allow abbreviated (uniquely) vector names
|
||||
@ -117,9 +117,9 @@ class clog:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
@ -145,9 +145,9 @@ class clog:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
@ -261,26 +261,26 @@ class clog:
|
||||
elif s1 >= 0 and s2 >= 0 and s2 < s1: # found s1,s2 with s2 before s1
|
||||
s1 = 0
|
||||
elif s1 == -1 and s2 >= 0: # found s2, but no s1
|
||||
last = 1
|
||||
last = 1
|
||||
s1 = 0
|
||||
elif s1 >= 0 and s2 == -1: # found s1, but no s2
|
||||
last = 1
|
||||
s1 = txt.find("\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
|
||||
# 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
|
||||
eof -= len(txt) - start # reset eof to "Loop"
|
||||
break
|
||||
eof -= len(txt) - start # reset eof to "Loop"
|
||||
break
|
||||
|
||||
last = 1 # entire read is a chunk
|
||||
last = 1 # entire read is a chunk
|
||||
s1 = 0
|
||||
s2 = txt.rfind("\n",s1) + 1
|
||||
eof -= len(txt) - s2
|
||||
if s1 == s2: break
|
||||
eof -= len(txt) - s2
|
||||
if s1 == s2: break
|
||||
|
||||
chunk = txt[s1:s2-1]
|
||||
start = s2
|
||||
|
||||
60
src/data.py
60
src/data.py
@ -12,7 +12,7 @@ oneline = "Read, write, manipulate LAMMPS data files"
|
||||
|
||||
docstr = """
|
||||
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)
|
||||
|
||||
@ -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
|
||||
|
||||
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.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.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.replace("Atoms",5,vec) replace Nth column of section with vector
|
||||
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
|
||||
also replaces ix,iy,iz if they are defined
|
||||
@ -109,16 +109,16 @@ class data:
|
||||
found = 0
|
||||
for keyword in hkeywords:
|
||||
if line.find(keyword) >= 0:
|
||||
found = 1
|
||||
words = line.split()
|
||||
if keyword == "xlo xhi" or keyword == "ylo yhi" or \
|
||||
keyword == "zlo zhi":
|
||||
headers[keyword] = (float(words[0]),float(words[1]))
|
||||
elif keyword == "xy xz yz":
|
||||
headers[keyword] = \
|
||||
found = 1
|
||||
words = line.split()
|
||||
if keyword == "xlo xhi" or keyword == "ylo yhi" or \
|
||||
keyword == "zlo zhi":
|
||||
headers[keyword] = (float(words[0]),float(words[1]))
|
||||
elif keyword == "xy xz yz":
|
||||
headers[keyword] = \
|
||||
(float(words[0]),float(words[1]),float(words[2]))
|
||||
else:
|
||||
headers[keyword] = int(words[0])
|
||||
headers[keyword] = int(words[0])
|
||||
if not found:
|
||||
break
|
||||
|
||||
@ -128,11 +128,11 @@ class data:
|
||||
for pair in skeywords:
|
||||
keyword,length = pair[0],pair[1]
|
||||
if keyword == line:
|
||||
found = 1
|
||||
found = 1
|
||||
if not headers.has_key(length):
|
||||
raise StandardError, \
|
||||
"data section %s has no matching header value" % line
|
||||
f.readline()
|
||||
f.readline()
|
||||
list = []
|
||||
for i in xrange(headers[length]): list.append(f.readline())
|
||||
sections[keyword] = list
|
||||
@ -225,8 +225,8 @@ class data:
|
||||
if dm.scaled(nsnap): scaleflag = 1
|
||||
else: scaleflag = 0
|
||||
dm.sort(ntime)
|
||||
|
||||
if scaleflag: dm.unscale(ntime)
|
||||
|
||||
x,y,z = dm.vecs(ntime,"x","y","z")
|
||||
if scaleflag: dm.scale(ntime)
|
||||
|
||||
@ -259,19 +259,19 @@ class data:
|
||||
if self.headers.has_key(keyword):
|
||||
if keyword == "xlo xhi" or keyword == "ylo yhi" or \
|
||||
keyword == "zlo zhi":
|
||||
pair = self.headers[keyword]
|
||||
print >>f,pair[0],pair[1],keyword
|
||||
pair = self.headers[keyword]
|
||||
print >>f,pair[0],pair[1],keyword
|
||||
elif keyword == "xy xz yz":
|
||||
triple = self.headers[keyword]
|
||||
print >>f,triple[0],triple[1],triple[2],keyword
|
||||
triple = self.headers[keyword]
|
||||
print >>f,triple[0],triple[1],triple[2],keyword
|
||||
else:
|
||||
print >>f,self.headers[keyword],keyword
|
||||
print >>f,self.headers[keyword],keyword
|
||||
for pair in skeywords:
|
||||
keyword = pair[0]
|
||||
if self.sections.has_key(keyword):
|
||||
print >>f,"\n%s\n" % keyword
|
||||
for line in self.sections[keyword]:
|
||||
print >>f,line,
|
||||
print >>f,line,
|
||||
f.close()
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
@ -331,7 +331,7 @@ class data:
|
||||
float(atom1words[z]),
|
||||
float(atom2words[x]),float(atom2words[y]),
|
||||
float(atom2words[z]),
|
||||
float(atom1words[type]),float(atom2words[type])])
|
||||
float(atom1words[type]),float(atom2words[type])])
|
||||
|
||||
tris = []
|
||||
lines = []
|
||||
@ -357,18 +357,18 @@ class data:
|
||||
|
||||
hkeywords = ["atoms","lines","tris",
|
||||
"bonds","angles","dihedrals","impropers",
|
||||
"atom types","bond types","angle types","dihedral types",
|
||||
"improper types","xlo xhi","ylo yhi","zlo zhi","xy xz yz"]
|
||||
"atom types","bond types","angle types","dihedral types",
|
||||
"improper types","xlo xhi","ylo yhi","zlo zhi","xy xz yz"]
|
||||
|
||||
skeywords = [["Masses","atom types"],
|
||||
["Atoms","atoms"],["Lines","lines"],["Triangles","tris"],
|
||||
["Bonds","bonds"],
|
||||
["Angles","angles"],["Dihedrals","dihedrals"],
|
||||
["Impropers","impropers"],["Velocities","atoms"],
|
||||
["Angles","angles"],["Dihedrals","dihedrals"],
|
||||
["Impropers","impropers"],["Velocities","atoms"],
|
||||
["Pair Coeffs","atom types"],
|
||||
["Bond Coeffs","bond types"],["Angle Coeffs","angle types"],
|
||||
["Dihedral Coeffs","dihedral types"],
|
||||
["Improper Coeffs","improper types"],
|
||||
["Bond Coeffs","bond types"],["Angle Coeffs","angle types"],
|
||||
["Dihedral Coeffs","dihedral types"],
|
||||
["Improper Coeffs","improper types"],
|
||||
["BondBond Coeffs","angle types"],
|
||||
["BondAngle Coeffs","angle types"],
|
||||
["MiddleBondTorsion Coeffs","dihedral types"],
|
||||
|
||||
66
src/dump.py
66
src/dump.py
@ -12,15 +12,15 @@ oneline = "Read, write, manipulate dump files and particle attributes"
|
||||
|
||||
docstr = """
|
||||
d = dump("dump.one") read in one or more dump files
|
||||
d = dump("dump.1 dump.2.gz") can be gzipped
|
||||
d = dump("dump.*") wildcard expands to multiple files
|
||||
d = dump("dump.*",0) two args = store filenames, but don't read
|
||||
d = dump("dump.1 dump.2.gz") can be gzipped
|
||||
d = dump("dump.*") wildcard expands to multiple files
|
||||
d = dump("dump.*",0) two args = store filenames, but don't read
|
||||
|
||||
incomplete and duplicate snapshots are deleted
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
d.tselect.all() select all timesteps
|
||||
d.tselect.one(N) select only timestep N
|
||||
d.tselect.none() deselect all timesteps
|
||||
d.tselect.skip(M) select every Mth step
|
||||
d.tselect.all() select all timesteps
|
||||
d.tselect.one(N) select only timestep N
|
||||
d.tselect.none() deselect all timesteps
|
||||
d.tselect.skip(M) select every Mth step
|
||||
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
|
||||
skip() and test() only select from currently selected timesteps
|
||||
test() uses a Python Boolean expression with $t for timestep value
|
||||
Python comparison syntax: == != < > <= >= and or
|
||||
|
||||
d.aselect.all() select all atoms in all steps
|
||||
d.aselect.all(N) select all atoms in one step
|
||||
d.aselect.all() select all atoms in all steps
|
||||
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",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
|
||||
$name must end with a space
|
||||
|
||||
d.write("file") 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.write("file") 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
|
||||
|
||||
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
|
||||
|
||||
d.scale() scale x,y,z to 0-1 for all timesteps
|
||||
d.scale(100) scale atom coords for timestep N
|
||||
d.unscale() unscale x,y,z to box size to all timesteps
|
||||
d.unscale(1000) unscale atom coords for timestep N
|
||||
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.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("x") sort atoms by column value in all steps
|
||||
d.sort(1000) sort atoms in timestep N
|
||||
d.scale() scale x,y,z to 0-1 for all timesteps
|
||||
d.scale(100) scale atom coords for timestep N
|
||||
d.unscale() unscale x,y,z to box size to all timesteps
|
||||
d.unscale(1000) unscale atom coords for timestep N
|
||||
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.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("x") sort atoms by column value in all steps
|
||||
d.sort(1000) sort atoms in timestep N
|
||||
|
||||
scale(), unscale(), wrap(), unwrap(), owrap() operate on all steps and atoms
|
||||
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
|
||||
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.spread("ke",N,"color") 2nd col = N ints spread over 1st col
|
||||
d.clone(1000,"color") clone timestep N values to other steps
|
||||
d.spread("ke",N,"color") 2nd col = N ints spread over 1st col
|
||||
d.clone(1000,"color") clone timestep N values to other steps
|
||||
|
||||
minmax() 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
|
||||
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.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
|
||||
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.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() called with arg = 0 first time, with arg = 1 on subsequent calls
|
||||
@ -331,15 +331,15 @@ class dump:
|
||||
snap = self.read_snapshot(f)
|
||||
if not snap:
|
||||
self.nextfile += 1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
f.close()
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = f.tell()
|
||||
f.close()
|
||||
try:
|
||||
self.findtime(snap.time)
|
||||
continue
|
||||
continue
|
||||
except: break
|
||||
|
||||
# select the new snapshot with all its atoms
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
oneline = "Convert LAMMPS snapshots or meshes to Ensight format"
|
||||
|
||||
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.maxtype = 10 max particle type, set if query to data will be bad
|
||||
|
||||
@ -268,20 +268,20 @@ class ensight:
|
||||
files = []
|
||||
if n < 10:
|
||||
file = root + "000" + str(n) + ".xyz"
|
||||
for pair in pairs:
|
||||
files.append(root + "000" + str(n) + "." + pair[0])
|
||||
for pair in pairs:
|
||||
files.append(root + "000" + str(n) + "." + pair[0])
|
||||
elif n < 100:
|
||||
file = root + "00" + str(n) + ".xyz"
|
||||
for pair in pairs:
|
||||
files.append(root + "00" + str(n) + "." + pair[0])
|
||||
for pair in pairs:
|
||||
files.append(root + "00" + str(n) + "." + pair[0])
|
||||
elif n < 1000:
|
||||
file = root + "0" + str(n) + ".xyz"
|
||||
for pair in pairs:
|
||||
files.append(root + "0" + str(n) + "." + pair[0])
|
||||
for pair in pairs:
|
||||
files.append(root + "0" + str(n) + "." + pair[0])
|
||||
else:
|
||||
file = root + str(n) + ".xyz"
|
||||
for pair in pairs:
|
||||
files.append(root + str(n) + "." + pair[0])
|
||||
for pair in pairs:
|
||||
files.append(root + str(n) + "." + pair[0])
|
||||
|
||||
if self.which == 0:
|
||||
f = open(file,"w")
|
||||
@ -309,7 +309,7 @@ class ensight:
|
||||
self.variable_file_atoms(f,pairs[i][1],atoms,values)
|
||||
else:
|
||||
self.variable_file_elements(f,pairs[i][1],etype,values)
|
||||
f.close()
|
||||
f.close()
|
||||
|
||||
print time,
|
||||
sys.stdout.flush()
|
||||
|
||||
32
src/gl.py
32
src/gl.py
@ -16,8 +16,8 @@ g = gl(d) create OpenGL display for data in d
|
||||
d = atom snapshot object (dump, data)
|
||||
|
||||
g.bg("black") set background color (def = "black")
|
||||
g.size(N) set image size to NxN
|
||||
g.size(N,M) set image size to NxM
|
||||
g.size(N) set image size to NxN
|
||||
g.size(N,M) set image size to NxM
|
||||
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.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.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(0,"blue") 2nd arg = one color or list of colors
|
||||
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(0,"blue") 2nd arg = one color or list of colors
|
||||
g.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
|
||||
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.bcol() set bond color, same args as acol()
|
||||
g.brad() set bond thickness, same args as arad()
|
||||
g.bcol() set bond color, same args as acol()
|
||||
g.brad() set bond thickness, same args as arad()
|
||||
|
||||
g.tcol() set triangle color, same args as acol()
|
||||
g.tfill() set triangle fill, 0 fill, 1 line, 2 both
|
||||
g.tcol() set triangle color, same args as acol()
|
||||
g.tfill() set triangle fill, 0 fill, 1 line, 2 both
|
||||
|
||||
g.lcol() set line color, same args as acol()
|
||||
g.lrad() set line thickness, same args as arad()
|
||||
|
||||
g.adef() set atom/bond/tri/line properties to default
|
||||
g.bdef() default = "loop" for colors, 0.45 for radii
|
||||
g.tdef() default = 0.25 for bond/line thickness
|
||||
g.ldef() default = 0 fill
|
||||
g.bdef() default = "loop" for colors, 0.45 for radii
|
||||
g.tdef() default = 0.25 for bond/line thickness
|
||||
g.ldef() default = 0 fill
|
||||
|
||||
by default 100 types are assigned
|
||||
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[2] = 0.0
|
||||
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[1] = -dot*self.view[1] # up perp to v = up - dot * v
|
||||
self.up[2] = 1.0 - dot*self.view[2]
|
||||
@ -636,7 +636,7 @@ class gl:
|
||||
fraction*(self.scale_stop - self.scale_start)
|
||||
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)
|
||||
|
||||
@ -691,7 +691,7 @@ class gl:
|
||||
fraction*(self.scale_stop - self.scale_start)
|
||||
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)
|
||||
|
||||
@ -781,7 +781,7 @@ class gl:
|
||||
red,green,blue = self.vizinfo.lcolor[itype]
|
||||
glColor3f(red,green,blue)
|
||||
thick = self.vizinfo.lrad[itype]
|
||||
glLineWidth(thick)
|
||||
glLineWidth(thick)
|
||||
glBegin(GL_LINES)
|
||||
glVertex3f(line[2],line[3],line[4])
|
||||
glVertex3f(line[5],line[6],line[7])
|
||||
|
||||
18
src/gnu.py
18
src/gnu.py
@ -11,12 +11,12 @@
|
||||
oneline = "Create plots via GnuPlot plotting program"
|
||||
|
||||
docstr = """
|
||||
g = gnu() start up GnuPlot
|
||||
g.stop() shut down GnuPlot process
|
||||
g = gnu() start up GnuPlot
|
||||
g.stop() shut down GnuPlot process
|
||||
|
||||
g.plot(a) plot vector A against linear index
|
||||
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) plot B against A
|
||||
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
|
||||
|
||||
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.enter() enter GnuPlot shell
|
||||
g.enter() enter GnuPlot shell
|
||||
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
|
||||
|
||||
all vectors must be of equal length
|
||||
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
|
||||
|
||||
g.hide(N) delete window for figure N
|
||||
g.save("file") save current plot as file.eps
|
||||
g.hide(N) delete window for figure N
|
||||
g.save("file") save current plot as file.eps
|
||||
|
||||
Set attributes for current plot:
|
||||
|
||||
|
||||
@ -13,14 +13,14 @@ oneline = "View and manipulate images"
|
||||
docstr = """
|
||||
i = image("my1.gif my2.gif") display thumbnails of matching images
|
||||
i = image("*.png *.gif") wildcards allowed
|
||||
i = image("") blank string matches all image suffixes
|
||||
i = image() no display window opened if no arg
|
||||
i = image("") blank string matches all image suffixes
|
||||
i = image() no display window opened if no arg
|
||||
|
||||
image suffixes for blank string = *.png, *.bmp, *.gif, *.tiff, *.tif
|
||||
click on a thumbnail to view it full-size
|
||||
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
|
||||
|
||||
@ -216,7 +216,7 @@ class thumbnails:
|
||||
self.bigexist = 0
|
||||
if self.window:
|
||||
self.window.destroy()
|
||||
self.window = None
|
||||
self.window = None
|
||||
|
||||
# create a new window with the big image
|
||||
|
||||
|
||||
18
src/ldump.py
18
src/ldump.py
@ -12,14 +12,14 @@ oneline = "Read dump files with line segment info"
|
||||
|
||||
docstr = """
|
||||
l = ldump("dump.one") read in one or more dump files
|
||||
l = ldump("dump.1 dump.2.gz") can be gzipped
|
||||
l = ldump("dump.*") wildcard expands to multiple files
|
||||
l = ldump("dump.*",0) two args = store filenames, but don't read
|
||||
l = ldump("dump.1 dump.2.gz") can be gzipped
|
||||
l = ldump("dump.*") wildcard expands to multiple files
|
||||
l = ldump("dump.*",0) two args = store filenames, but don't read
|
||||
|
||||
incomplete and duplicate snapshots are deleted
|
||||
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
|
||||
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
|
||||
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()
|
||||
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)
|
||||
if not snap:
|
||||
self.nextfile += 1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
f.close()
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = f.tell()
|
||||
f.close()
|
||||
try:
|
||||
self.findtime(snap.time)
|
||||
continue
|
||||
continue
|
||||
except: break
|
||||
|
||||
self.snaps.append(snap)
|
||||
|
||||
38
src/log.py
38
src/log.py
@ -28,7 +28,7 @@ nvec = l.nvec # of vectors of thermo info
|
||||
nlen = l.nlen length of each vectors
|
||||
names = l.names list of vector names
|
||||
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
|
||||
|
||||
get and write allow abbreviated (uniquely) vector names
|
||||
@ -133,9 +133,9 @@ class log:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
@ -161,9 +161,9 @@ class log:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
@ -224,7 +224,7 @@ class log:
|
||||
keywords.insert(0,"Step")
|
||||
i = 0
|
||||
for keyword in keywords:
|
||||
self.names.append(keyword)
|
||||
self.names.append(keyword)
|
||||
self.ptr[keyword] = i
|
||||
i += 1
|
||||
|
||||
@ -234,7 +234,7 @@ class log:
|
||||
line = txt[s1:s2]
|
||||
words = line.split()
|
||||
for i in range(len(words)):
|
||||
self.names.append(words[i])
|
||||
self.names.append(words[i])
|
||||
self.ptr[words[i]] = i
|
||||
|
||||
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 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
|
||||
s1 = 0
|
||||
elif s1 == -1 and s2 >= 0: # found s2, but no s1
|
||||
last = 1
|
||||
last = 1
|
||||
s1 = 0
|
||||
elif s1 >= 0 and s2 == -1: # found s1, but no s2
|
||||
last = 1
|
||||
if self.style == 1:
|
||||
s2 = txt.rfind("\n--",s1) + 1
|
||||
else:
|
||||
s1 = txt.find("\n",s1) + 1
|
||||
s1 = txt.find("\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
|
||||
# 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
|
||||
eof -= len(txt) - start # reset eof to "Loop"
|
||||
break
|
||||
eof -= len(txt) - start # reset eof to "Loop"
|
||||
break
|
||||
|
||||
last = 1 # entire read is a chunk
|
||||
last = 1 # entire read is a chunk
|
||||
s1 = 0
|
||||
if self.style == 1:
|
||||
s2 = txt.rfind("\n--",s1) + 1
|
||||
else:
|
||||
s2 = txt.rfind("\n",s1) + 1
|
||||
eof -= len(txt) - s2
|
||||
if s1 == s2: break
|
||||
eof -= len(txt) - s2
|
||||
if s1 == s2: break
|
||||
|
||||
chunk = txt[s1:s2-1]
|
||||
start = s2
|
||||
|
||||
@ -11,12 +11,12 @@
|
||||
oneline = "Create plots via MatLab numerical analysis program"
|
||||
|
||||
docstr = """
|
||||
m = matlab() start up MatLab
|
||||
m.stop() shut down MatLab process
|
||||
m = matlab() start up MatLab
|
||||
m.stop() shut down MatLab process
|
||||
|
||||
m.plot(a) plot vector A against linear index
|
||||
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) plot B against A
|
||||
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
|
||||
|
||||
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.enter() enter MatLab shell
|
||||
m.enter() enter MatLab shell
|
||||
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
|
||||
|
||||
@ -40,12 +40,12 @@ m.export("data",range(100),a,...) create file with columns of numbers
|
||||
cols = importdata('data')
|
||||
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
|
||||
|
||||
m.hide(N) delete window for figure N
|
||||
m.save("file") save current plot as file.eps
|
||||
m.hide(N) delete window for figure N
|
||||
m.save("file") save current plot as file.eps
|
||||
|
||||
Set attributes for current plot:
|
||||
|
||||
|
||||
32
src/mdump.py
32
src/mdump.py
@ -12,13 +12,13 @@ oneline = "Read, write, manipulate mesh dump files"
|
||||
|
||||
docstr = """
|
||||
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.*") wildcard expands to multiple files
|
||||
m = mdump("mesh.*",0) two args = store filenames, but don't read
|
||||
m = mdump("mesh.1 mesh.2.gz") can be gzipped
|
||||
m = mdump("mesh.*") wildcard expands to multiple files
|
||||
m = mdump("mesh.*",0) two args = store filenames, but don't read
|
||||
|
||||
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
|
||||
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.tselect.all() select all timesteps
|
||||
m.tselect.one(N) select only timestep N
|
||||
m.tselect.none() deselect all timesteps
|
||||
m.tselect.skip(M) select every Mth step
|
||||
m.tselect.all() select all timesteps
|
||||
m.tselect.one(N) select only timestep N
|
||||
m.tselect.none() deselect all timesteps
|
||||
m.tselect.skip(M) select every Mth step
|
||||
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
|
||||
skip() and test() only select from currently selected timesteps
|
||||
test() uses a Python Boolean expression with $t for timestep value
|
||||
Python comparison syntax: == != < > <= >= and or
|
||||
|
||||
m.eselect.all() select all elems in all steps
|
||||
m.eselect.all(N) select all elems in one step
|
||||
m.eselect.all() select all elems in all steps
|
||||
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",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
|
||||
$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
|
||||
|
||||
vecs() returns vectors with one value for each selected elem in the timestep
|
||||
@ -253,15 +253,15 @@ class mdump:
|
||||
snap = self.read_snapshot(f)
|
||||
if not snap:
|
||||
self.nextfile += 1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
f.close()
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = f.tell()
|
||||
f.close()
|
||||
try:
|
||||
self.findtime(snap.time)
|
||||
continue
|
||||
continue
|
||||
except: break
|
||||
|
||||
# select the new snapshot with all its elements
|
||||
|
||||
@ -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
|
||||
|
||||
p.coeff(d) extract pairwise coeffs from data object
|
||||
p.init(cut1,cut2,...) setup based on coeffs and cutoffs
|
||||
p.coeff(d) extract pairwise coeffs from data object
|
||||
p.init(cut1,cut2,...) setup based on coeffs and cutoffs
|
||||
|
||||
init args are specific to pair style:
|
||||
lj/cut = cutlj
|
||||
@ -156,7 +156,7 @@ class pair:
|
||||
# args = cutlj, cut_coul (cut_coul optional)
|
||||
|
||||
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]
|
||||
self.cut_ljsq = cut_lj*cut_lj
|
||||
|
||||
@ -210,7 +210,7 @@ class pair:
|
||||
# args = cutlj_inner,cutlj,cutcoul_inner,cut_coul (last 2 optional)
|
||||
|
||||
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 = list[1]
|
||||
|
||||
|
||||
@ -14,9 +14,9 @@ docstr = """
|
||||
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.seed = 48379 set random # seed (def = 12345)
|
||||
p.randomized = 0 1 = choose next particle randomly, 0 = as generated
|
||||
p.dim = 2 set dimension of created box (def = 3)
|
||||
p.seed = 48379 set random # seed (def = 12345)
|
||||
p.randomized = 0 1 = choose next particle randomly, 0 = as generated
|
||||
p.dim = 2 set dimension of created box (def = 3)
|
||||
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.lattice = [Nx,Ny,Nz] generate Nx by Ny by Nz lattice of particles
|
||||
|
||||
10
src/pizza.py
10
src/pizza.py
@ -26,12 +26,12 @@ type ? for help, CTRL-D to quit
|
||||
|
||||
help = """
|
||||
pizza.py switch arg(s) switch arg(s) ...
|
||||
-s silent (else print start-up help)
|
||||
-t log dump raster load only these tools
|
||||
-x raster rasmol load all tools except these
|
||||
-s silent (else print start-up help)
|
||||
-t log dump raster load only these tools
|
||||
-x raster rasmol load all tools except these
|
||||
-f mine.py arg1 arg2 run script file with args
|
||||
-c "vec = range(100)" run Python command
|
||||
-q quit (else interactive)
|
||||
-c "vec = range(100)" run Python command
|
||||
-q quit (else interactive)
|
||||
|
||||
Everything typed at the ">" prompt is a Python command
|
||||
|
||||
|
||||
@ -16,8 +16,8 @@ r = raster(d) create Raster3d wrapper for data in d
|
||||
d = atom snapshot object (dump, data)
|
||||
|
||||
r.bg("black") set background color (def = "black")
|
||||
r.size(N) set image size to NxN
|
||||
r.size(N,M) set image size to NxM
|
||||
r.size(N) set image size to NxN
|
||||
r.size(N,M) set image size to NxM
|
||||
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.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
|
||||
size = fontsize (e.g. 10), "red" = color of text
|
||||
|
||||
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(0,"blue") 2nd arg = one color or list of colors
|
||||
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(0,"blue") 2nd arg = one color or list of colors
|
||||
r.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
|
||||
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.bcol() set bond color, same args as acol()
|
||||
r.brad() set bond thickness, same args as arad()
|
||||
r.bcol() set bond color, same args as acol()
|
||||
r.brad() set bond thickness, same args as arad()
|
||||
|
||||
r.tcol() set triangle color, same args as acol()
|
||||
r.tfill() set triangle fill, 0 fill, 1 line, 2 both
|
||||
r.tcol() set triangle color, same args as acol()
|
||||
r.tfill() set triangle fill, 0 fill, 1 line, 2 both
|
||||
|
||||
r.lcol() set line color, same args as acol()
|
||||
r.lrad() set line thickness, same args as arad()
|
||||
|
||||
r.adef() set atom/bond/tri/line properties to default
|
||||
r.bdef() default = "loop" for colors, 0.45 for radii
|
||||
r.tdef() default = 0.25 for bond/line thickness
|
||||
r.ldef() default = 0 fill
|
||||
r.bdef() default = "loop" for colors, 0.45 for radii
|
||||
r.tdef() default = 0.25 for bond/line thickness
|
||||
r.ldef() default = 0 fill
|
||||
|
||||
by default 100 types are assigned
|
||||
if atom/bond/tri/line has type > # defined properties, is an error
|
||||
@ -297,9 +297,9 @@ class raster:
|
||||
self.scale = 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
|
||||
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)
|
||||
self.xtrans = float(nums[0][0])
|
||||
self.ytrans = float(nums[0][1])
|
||||
@ -344,9 +344,9 @@ class raster:
|
||||
self.scale = 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
|
||||
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)
|
||||
self.xtrans = float(nums[0][0])
|
||||
self.ytrans = float(nums[0][1])
|
||||
@ -527,31 +527,31 @@ def box_write(f,box,color,thick):
|
||||
blue = color[2]
|
||||
|
||||
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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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" % \
|
||||
(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
|
||||
@ -634,7 +634,7 @@ def rotation_matrix(coord1,angle1,coord2,angle2):
|
||||
# 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" % \
|
||||
(c11,c12,c13,c21,c22,c23,c31,c32,c33)
|
||||
(c11,c12,c13,c21,c22,c23,c31,c32,c33)
|
||||
return matrix
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
58
src/svg.py
58
src/svg.py
@ -16,8 +16,8 @@ s = svg(d) create SVG object for data in d
|
||||
d = atom snapshot object (dump, data)
|
||||
|
||||
s.bg("black") set background color (def = "black")
|
||||
s.size(N) set image size to NxN
|
||||
s.size(N,M) set image size to NxM
|
||||
s.size(N) set image size to NxN
|
||||
s.size(N,M) set image size to NxM
|
||||
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.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
|
||||
size = fontsize (e.g. 10), "red" = color of text
|
||||
|
||||
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(0,"blue") 2nd arg = one color or list of colors
|
||||
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(0,"blue") 2nd arg = one color or list of colors
|
||||
s.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
|
||||
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.bcol() set bond color, same args as acol()
|
||||
s.brad() set bond thickness, same args as arad()
|
||||
s.bcol() set bond color, same args as acol()
|
||||
s.brad() set bond thickness, same args as arad()
|
||||
|
||||
s.tcol() set triangle color, same args as acol()
|
||||
s.tfill() set triangle fill, 0 fill, 1 line, 2 both
|
||||
s.tcol() set triangle color, same args as acol()
|
||||
s.tfill() set triangle fill, 0 fill, 1 line, 2 both
|
||||
|
||||
s.lcol() set line color, same args as acol()
|
||||
s.lrad() set line thickness, same args as arad()
|
||||
|
||||
s.adef() set atom/bond/tri/line properties to default
|
||||
s.bdef() default = "loop" for colors, 0.45 for radii
|
||||
s.tdef() default = 0.25 for bond/line thickness
|
||||
s.ldef() default = 0 fill
|
||||
s.bdef() default = "loop" for colors, 0.45 for radii
|
||||
s.tdef() default = 0.25 for bond/line thickness
|
||||
s.ldef() default = 0 fill
|
||||
|
||||
by default 100 types are assigned
|
||||
if atom/bond/tri/line has type > # defined properties, is an error
|
||||
@ -248,10 +248,10 @@ class svg:
|
||||
|
||||
fraction = float(i) / (ncount-1)
|
||||
|
||||
if self.select != "":
|
||||
if self.select != "":
|
||||
newstr = self.select % fraction
|
||||
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 n == nstart: self.distance = compute_distance(box)
|
||||
@ -261,7 +261,7 @@ class svg:
|
||||
elif n < 1000: file = self.file + "0" + str(n)
|
||||
else: file = self.file + str(n)
|
||||
|
||||
if self.panflag:
|
||||
if self.panflag:
|
||||
self.ztheta = self.ztheta_start + \
|
||||
fraction*(self.ztheta_stop - self.ztheta_start)
|
||||
self.azphi = self.azphi_start + \
|
||||
@ -270,9 +270,9 @@ class svg:
|
||||
fraction*(self.scale_stop - self.scale_start)
|
||||
|
||||
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,
|
||||
sys.stdout.flush()
|
||||
i += 1
|
||||
@ -290,7 +290,7 @@ class svg:
|
||||
for i in range(ncount):
|
||||
fraction = float(i) / (ncount-1)
|
||||
|
||||
if self.select != "":
|
||||
if self.select != "":
|
||||
newstr = self.select % fraction
|
||||
data.aselect.test(newstr,ntime)
|
||||
time,boxone,atoms,bonds,tris,lines = data.viz(which)
|
||||
@ -303,18 +303,18 @@ class svg:
|
||||
elif n < 1000: file = self.file + "0" + str(n)
|
||||
else: file = self.file + str(n)
|
||||
|
||||
if self.panflag:
|
||||
if self.panflag:
|
||||
self.ztheta = self.ztheta_start + \
|
||||
fraction*(self.ztheta_stop - self.ztheta_start)
|
||||
self.azphi = 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)
|
||||
|
||||
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,
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
@ -512,18 +512,18 @@ class svg:
|
||||
|
||||
if flag == 0:
|
||||
if obj[0] == 0: # atom with its color and radius
|
||||
itype = int(obj[1])
|
||||
if itype > self.vizinfo.nacolor:
|
||||
itype = int(obj[1])
|
||||
if itype > self.vizinfo.nacolor:
|
||||
raise StandardError,"atom type too big"
|
||||
color = self.vizinfo.acolor[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,
|
||||
color[0]*255,color[1]*255,color[2]*255,self.thick)
|
||||
|
||||
elif obj[0] == 1: # tri with its color (need to add fill type)
|
||||
itype = int(obj[1])
|
||||
if itype > self.vizinfo.ntcolor:
|
||||
if itype > self.vizinfo.ntcolor:
|
||||
raise StandardError,"tri type too big"
|
||||
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" />' % \
|
||||
@ -532,17 +532,17 @@ class svg:
|
||||
|
||||
elif obj[0] == 2: # bond with its color and thickness
|
||||
itype = int(obj[1])
|
||||
if itype > self.vizinfo.nbcolor:
|
||||
if itype > self.vizinfo.nbcolor:
|
||||
raise StandardError,"bond type too big"
|
||||
color = self.vizinfo.bcolor[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],
|
||||
color[0]*255,color[1]*255,color[2]*255,thick*self.factor)
|
||||
|
||||
elif obj[0] == 3: # line with its color and thickness
|
||||
itype = int(obj[1])
|
||||
if itype > self.vizinfo.nlcolor:
|
||||
if itype > self.vizinfo.nlcolor:
|
||||
raise StandardError,"line type too big"
|
||||
color = self.vizinfo.lcolor[itype]
|
||||
thick = self.vizinfo.lrad[itype]
|
||||
|
||||
22
src/tdump.py
22
src/tdump.py
@ -12,14 +12,14 @@ oneline = "Read dump files with triangle info"
|
||||
|
||||
docstr = """
|
||||
t = tdump("dump.one") read in one or more dump files
|
||||
t = tdump("dump.1 dump.2.gz") can be gzipped
|
||||
t = tdump("dump.*") wildcard expands to multiple files
|
||||
t = tdump("dump.*",0) two args = store filenames, but don't read
|
||||
t = tdump("dump.1 dump.2.gz") can be gzipped
|
||||
t = tdump("dump.*") wildcard expands to multiple files
|
||||
t = tdump("dump.*",0) two args = store filenames, but don't read
|
||||
|
||||
incomplete and duplicate snapshots are deleted
|
||||
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
|
||||
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
|
||||
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()
|
||||
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)
|
||||
if not snap:
|
||||
self.nextfile += 1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
f.close()
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = f.tell()
|
||||
f.close()
|
||||
try:
|
||||
self.findtime(snap.time)
|
||||
continue
|
||||
continue
|
||||
except: break
|
||||
|
||||
self.snaps.append(snap)
|
||||
@ -295,8 +295,8 @@ class tdump:
|
||||
corner3y = self.names["corner3y"]
|
||||
corner3z = self.names["corner3z"]
|
||||
|
||||
# create line list from id,type,corner1x,...corner3z
|
||||
# don't add line if all 4 values are 0 since not a line
|
||||
# create tris list from id,type,corner1x,...corner3z
|
||||
# don't add tri if all 4 values are 0 since not a line
|
||||
|
||||
tris = []
|
||||
for i in xrange(snap.natoms):
|
||||
|
||||
36
src/vcr.py
36
src/vcr.py
@ -16,26 +16,26 @@ v.add(gl) add a gl window to vcr GUI
|
||||
|
||||
Actions (same as GUI widgets):
|
||||
|
||||
v.first() go to first frame
|
||||
v.first() go to first frame
|
||||
v.prev() go to previous frame
|
||||
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.next() go to next frame
|
||||
v.last() go to last frame
|
||||
v.next() go to next frame
|
||||
v.last() go to last frame
|
||||
|
||||
v.frame(31) set frame slider
|
||||
v.delay(0.4) set delay slider
|
||||
v.q(5) set quality slider
|
||||
v.frame(31) set frame slider
|
||||
v.delay(0.4) set delay slider
|
||||
v.q(5) set quality slider
|
||||
|
||||
v.xaxis() view scene from x axis
|
||||
v.yaxis() view scene from y axis
|
||||
v.zaxis() view scene from z axis
|
||||
v.box() toggle bounding box
|
||||
v.axis() toggle display of xyz axes
|
||||
v.norm() recenter and resize the view
|
||||
v.ortho() toggle ortho/perspective button
|
||||
v.reload() reload all frames from gl viewer data files
|
||||
v.xaxis() view scene from x axis
|
||||
v.yaxis() view scene from y axis
|
||||
v.zaxis() view scene from z axis
|
||||
v.box() toggle bounding box
|
||||
v.axis() toggle display of xyz axes
|
||||
v.norm() recenter and resize the view
|
||||
v.ortho() toggle ortho/perspective button
|
||||
v.reload() reload all frames from gl viewer data files
|
||||
|
||||
v.clipxlo(0.2) clip scene at x lo fraction of box
|
||||
v.clipxhi(1.0) clip at x hi
|
||||
@ -44,9 +44,9 @@ v.clipyhi(1.0)
|
||||
v.clipzlo(0.2) clip in z
|
||||
v.clipzhi(1.0)
|
||||
|
||||
v.save() save current scene to file.png
|
||||
v.file("image") set filename
|
||||
v.saveall() toggle save-all checkbox
|
||||
v.save() save current scene to file.png
|
||||
v.file("image") set filename
|
||||
v.saveall() toggle save-all checkbox
|
||||
"""
|
||||
|
||||
# History
|
||||
|
||||
18
src/vec.py
18
src/vec.py
@ -19,10 +19,10 @@ v = vec(array) array = list of numeric vectors
|
||||
assigns names = "col1", "col2", etc
|
||||
|
||||
nvec = v.nvec # of vectors
|
||||
nlen = v.nlen lengths of vectors
|
||||
names = v.names list of vector names
|
||||
nlen = v.nlen lengths of vectors
|
||||
names = v.names list of vector names
|
||||
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
|
||||
|
||||
get and write allow abbreviated (uniquely) vector names or digits (1-Nvec)
|
||||
@ -99,9 +99,9 @@ class vec:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
@ -127,9 +127,9 @@ class vec:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
|
||||
26
src/vmd.py
26
src/vmd.py
@ -17,24 +17,24 @@
|
||||
oneline = "Control VMD from python"
|
||||
|
||||
docstr = """
|
||||
v = vmd() start up VMD
|
||||
v.stop() shut down VMD instance
|
||||
v.clear() delete all visualizations
|
||||
v = vmd() start up VMD
|
||||
v.stop() shut down VMD instance
|
||||
v.clear() delete all visualizations
|
||||
|
||||
v.rep(style) set default representation style. One of
|
||||
(Lines|VDW|Licorice|DynamicBonds|Points|CPK)
|
||||
v.new(file[,type]) load new file (default file type 'lammpstrj')
|
||||
v.rep(style) set default representation style. One of
|
||||
(Lines|VDW|Licorice|DynamicBonds|Points|CPK)
|
||||
v.new(file[,type]) load new file (default file type 'lammpstrj')
|
||||
v.data(file[,atomstyle]) load new data file (default atom style 'full')
|
||||
v.replace(file[,type]) replace current frames with new file
|
||||
v.append(file[,type]) append file to current frame(s)
|
||||
v.replace(file[,type]) replace current frames with new file
|
||||
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.frame(frame) set current frame
|
||||
v.flush() flush pending input to VMD and update GUI
|
||||
v.read(file) read Tcl script file (e.g. saved state)
|
||||
v.frame(frame) set current frame
|
||||
v.flush() flush pending input to VMD and update GUI
|
||||
v.read(file) read Tcl script file (e.g. saved state)
|
||||
|
||||
v.enter() enter interactive shell
|
||||
v.debug([True|False]) display generated VMD script commands?
|
||||
v.enter() enter interactive shell
|
||||
v.debug([True|False]) display generated VMD script commands?
|
||||
"""
|
||||
|
||||
# History
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
oneline = "Convert LAMMPS snapshots to VTK format"
|
||||
|
||||
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("new") write all snapshots to new.vtk
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
oneline = "Convert LAMMPS snapshots to XYZ format"
|
||||
|
||||
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("new") write all snapshots to new.xyz
|
||||
|
||||
Reference in New Issue
Block a user