├── .gitignore ├── doc ├── tools.jpg ├── PDFgen.sh ├── histo.txt ├── histo.html ├── xyz.txt ├── vtk.txt ├── xyz.html ├── vmd.txt ├── animate.txt ├── vtk.html ├── vec.txt ├── vmd.html ├── cfg.txt ├── animate.html ├── Section_examples.txt ├── plotview.txt ├── vec.html ├── cfg.html ├── pair.txt ├── Section_examples.html ├── log.txt ├── plotview.html ├── pair.html ├── chain.txt ├── log.html ├── chain.html ├── rasmol.txt ├── ensight.txt ├── olog.txt ├── rasmol.html ├── vcr.txt ├── ensight.html ├── olog.html ├── vcr.html ├── bdump.txt ├── image.txt ├── bdump.html ├── data.txt ├── image.html ├── pdbfile.txt ├── ldump.txt ├── Section_extend.txt ├── tdump.txt ├── Section_tools.txt ├── data.html ├── pdbfile.html ├── Section_extend.html ├── ldump.html ├── gnu.txt └── tdump.html ├── examples ├── files │ ├── bucky0000.gif │ ├── bucky0001.gif │ ├── bucky0002.gif │ ├── bucky0003.gif │ └── vec.txt ├── movie_peptide.py ├── movie_micelle.py ├── test_patch.py ├── test_ensight.py ├── test_vtk.py ├── test_xyz.py ├── test_cfg.py ├── test_image.py ├── test_animate.py ├── test_pair.py ├── test_vcr.py ├── test_vmd.py ├── test_histo.py ├── test_chain.py ├── test_plotview.py ├── test_bdump.py ├── test_ldump.py ├── test_vec.py ├── test_clog.py ├── movie_flow.py ├── movie_melt.py ├── test_log.py ├── test_pdbfile.py ├── test_rasmol.py ├── movie_tri.py ├── test_gnu.py ├── test_matlab.py ├── test_gl.py ├── movie_bucky.py ├── test_svg.py ├── test_data.py ├── test_raster.py ├── test_mdump.py ├── test_cdata.py ├── README ├── test_dump.py └── group_energy.py ├── .github ├── CODEOWNERS └── PULL_REQUEST_TEMPLATE.md ├── scripts ├── dview.py ├── iview.py ├── plot.py ├── dview_standalone.py ├── logview.py ├── clogview.py ├── README ├── movie.py ├── distance.py ├── density.py ├── flux.py ├── density_area.py ├── cluster.py ├── bond_distribute.py └── angle_distribute.py ├── README └── src ├── histo.py ├── DEFAULTS.py └── xyz.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /doc/tools.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lammps/pizza/HEAD/doc/tools.jpg -------------------------------------------------------------------------------- /examples/files/bucky0000.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lammps/pizza/HEAD/examples/files/bucky0000.gif -------------------------------------------------------------------------------- /examples/files/bucky0001.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lammps/pizza/HEAD/examples/files/bucky0001.gif -------------------------------------------------------------------------------- /examples/files/bucky0002.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lammps/pizza/HEAD/examples/files/bucky0002.gif -------------------------------------------------------------------------------- /examples/files/bucky0003.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lammps/pizza/HEAD/examples/files/bucky0003.gif -------------------------------------------------------------------------------- /examples/movie_peptide.py: -------------------------------------------------------------------------------- 1 | # movie of solvated peptide data 2 | 3 | d = dump("dump.peptide") 4 | d.unwrap() 5 | p = pdb("peptide",d) 6 | r.file = "peptide" 7 | r = rasmol(p) 8 | r.all() 9 | -------------------------------------------------------------------------------- /examples/movie_micelle.py: -------------------------------------------------------------------------------- 1 | # movie of self-assembling micelles 2 | 3 | d = dump("dump.micelle") 4 | 5 | s = svg(d) 6 | s.acol([1,2,3,4],["blue","red","cyan","yellow"]) 7 | s.arad(range(4),0.5) 8 | s.zoom(1.5) 9 | 10 | s.file = "micelle" 11 | 12 | s.all() 13 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file contains file patterns that triggers automatic 2 | # code review requests from users that are owners of these files 3 | # Order matters, the last match has the highest precedence 4 | 5 | # for everything 6 | * @rbberger 7 | * @sjplimp 8 | -------------------------------------------------------------------------------- /examples/test_patch.py: -------------------------------------------------------------------------------- 1 | # simple test of patch tool 2 | # creates tmp.data.patch file 3 | 4 | p = patch(0.5) 5 | p.seed = 54321 6 | p.build(100,"hex2",1,2,3) 7 | p.build(50,"tri5",4,5) 8 | p.write("tmp.data.patch") 9 | 10 | print "all done ... type CTRL-D to exit Pizza.py" 11 | -------------------------------------------------------------------------------- /examples/test_ensight.py: -------------------------------------------------------------------------------- 1 | # simple test of xyz tool 2 | # requires files/dump.micelle.* 3 | # creates tmp*.case, etc 4 | 5 | d = dump("files/dump.micelle") 6 | e = ensight(d) 7 | e.one() 8 | e.many() 9 | e.single(0) 10 | 11 | print "all done ... type CTRL-D to exit Pizza.py" 12 | -------------------------------------------------------------------------------- /examples/test_vtk.py: -------------------------------------------------------------------------------- 1 | # simple test of vtk tool 2 | # requires files/dump.peptide.* 3 | # creates tmp*.vtk 4 | 5 | d = dump("files/dump.peptide.*") 6 | v = vtk(d) 7 | v.one() 8 | v.many() 9 | v.single(0,"tmp.single") 10 | 11 | print "all done ... type CTRL-D to exit Pizza.py" 12 | -------------------------------------------------------------------------------- /examples/test_xyz.py: -------------------------------------------------------------------------------- 1 | # simple test of xyz tool 2 | # requires files/dump.peptide.* 3 | # creates tmp*.xyz 4 | 5 | d = dump("files/dump.peptide.*") 6 | x = xyz(d) 7 | x.one() 8 | x.many() 9 | x.single(0,"tmp.single") 10 | 11 | print "all done ... type CTRL-D to exit Pizza.py" 12 | -------------------------------------------------------------------------------- /examples/test_cfg.py: -------------------------------------------------------------------------------- 1 | # simple test of cfg tool 2 | # requires files/dump.peptide.* 3 | # creates tmp*.cfg 4 | 5 | d = dump("files/dump.peptide.*") 6 | d.sort() 7 | x = cfg(d) 8 | x.one() 9 | x.many() 10 | x.single(0,"tmp.single") 11 | 12 | print "all done ... type CTRL-D to exit Pizza.py" 13 | -------------------------------------------------------------------------------- /examples/test_image.py: -------------------------------------------------------------------------------- 1 | # simple test of image tool 2 | # requires files/bucky*.png 3 | 4 | i = image("files/bucky*.gif") 5 | i.convert("files/bucky*.gif","tmp*.png") 6 | i.montage("","files/bucky*.gif","tmp*.png","tmpnew*.gif") 7 | i.view("*.gif") 8 | 9 | print "all done ... type CTRL-D to exit Pizza.py" 10 | -------------------------------------------------------------------------------- /examples/test_animate.py: -------------------------------------------------------------------------------- 1 | # simple test of animate tool 2 | # requires files/bucky*png files 3 | 4 | a = animate("files/bucky*gif") 5 | a.play() 6 | a.delay(0.1) 7 | a.back() 8 | a.last() 9 | a.first() 10 | a.next() 11 | a.previous() 12 | a.frame(1) 13 | 14 | print "all done ... type CTRL-D to exit Pizza.py" 15 | -------------------------------------------------------------------------------- /examples/test_pair.py: -------------------------------------------------------------------------------- 1 | # simple test of pair tool 2 | # requires files/data.rhodo 3 | 4 | p = pair("lj/charmm/coul/charmm") 5 | d = data("files/data.rhodo") 6 | p.coeff(d) 7 | p.init(8.0,10.0) 8 | ev,ec = p.single(5.0,1,2,0.5,-0.5) 9 | print "Energies",ev,ec 10 | 11 | print "all done ... type CTRL-D to exit Pizza.py" 12 | -------------------------------------------------------------------------------- /examples/test_vcr.py: -------------------------------------------------------------------------------- 1 | # simple test of vcr tool 2 | 3 | d = dump("files/dump.micelle") 4 | dt = data("files/data.micelle") 5 | d.extra(dt) 6 | g = gl(d) 7 | g.rotate(0,270) 8 | v = vcr(g) 9 | v.q(10) 10 | v.box() 11 | v.axis() 12 | v.clipxlo(0.2) 13 | v.clipxhi(0.5) 14 | v.play() 15 | 16 | print "all done ... type CTRL-D to exit Pizza.py" 17 | -------------------------------------------------------------------------------- /examples/test_vmd.py: -------------------------------------------------------------------------------- 1 | # simple test of vmd tool 2 | # requires files/dump.peptide.only and files/dump.bond 3 | # uses gl and vcr tools to visualize peptide molecule with bonds 4 | 5 | v = vmd() 6 | v('menu main off') 7 | v.rep('VDW') 8 | v.new('files/peptide.pdb','pdb') 9 | v.flush() 10 | 11 | print "all done ... type CTRL-D to exit Pizza.py" 12 | -------------------------------------------------------------------------------- /examples/test_histo.py: -------------------------------------------------------------------------------- 1 | # simple test of histo tool 2 | # requires files/dump.kinase 3 | 4 | d = dump("files/dump.kinase") 5 | h = histo(d) 6 | x,y = h.compute('x',25) 7 | g = gnu() 8 | g.xtitle("X position") 9 | g.ytitle("Particle Count") 10 | g.title("Histogram of Particle Density") 11 | g.plot(x,y) 12 | 13 | print "all done ... type CTRL-D to exit Pizza.py" 14 | -------------------------------------------------------------------------------- /examples/test_chain.py: -------------------------------------------------------------------------------- 1 | # simple test of chain tool 2 | # creates tmp.data.chain file 3 | 4 | c = chain(500,0.7,1,1,2) 5 | c.seed = 54321 6 | c.build(25,10) 7 | 8 | c.mtype = 2 9 | c.btype = 2 10 | c.blen = 1.5 11 | c.dmin = 1.2 12 | c.id = "end1" 13 | c.build(10,25) 14 | 15 | c.write("tmp.data.chain") 16 | 17 | print "all done ... type CTRL-D to exit Pizza.py" 18 | -------------------------------------------------------------------------------- /examples/test_plotview.py: -------------------------------------------------------------------------------- 1 | # simple test of plotview tool 2 | # requires files/log.obstacle 3 | # creates tmp.plotview.eps 4 | 5 | lg = log("files/log.obstacle") 6 | g = gnu() 7 | p = plotview(lg,g) 8 | 9 | p.select(1) 10 | p.select(6) 11 | p.yes(2) 12 | p.yes(5) 13 | p.no(2) 14 | 15 | p.file("tmp.plotview") 16 | p.save() 17 | 18 | print "all done ... type CTRL-D to exit Pizza.py" 19 | -------------------------------------------------------------------------------- /examples/test_bdump.py: -------------------------------------------------------------------------------- 1 | # simple test of dump tool 2 | # requires files/dump.peptide.only and files/dump.bond 3 | # uses gl and vcr tools to visualize peptide molecule with bonds 4 | 5 | dm = dump("files/dump.peptide.only") 6 | b = bdump("files/dump.bond") 7 | b.map(1,"id",2,"type",3,"atom1",4,"atom2") 8 | dm.extra(b) 9 | g = gl(dm) 10 | v = vcr(g) 11 | 12 | print "all done ... type CTRL-D to exit Pizza.py" 13 | -------------------------------------------------------------------------------- /doc/PDFgen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/csh 2 | # generate a PDF version of Manual 3 | 4 | txt2html -b *.txt 5 | 6 | htmldoc --title --toctitle "Table of Contents" --tocfooter ..i --toclevels 4 --header ... --footer ..1 --size letter --linkstyle plain --linkcolor blue -f Manual.pdf Manual.html Section_intro.html Section_install.html Section_basics.html Section_tools.html Section_examples.html Section_extend.html [a-z]*.html 7 | 8 | txt2html *.txt 9 | -------------------------------------------------------------------------------- /examples/test_ldump.py: -------------------------------------------------------------------------------- 1 | # simple test of dump tool 2 | # requires files/dump.lines 3 | # uses gl and vcr tools to visualize line segments 4 | 5 | d = dump("files/dump.lines") 6 | ld = ldump("files/dump.lines") 7 | ld.map(1,"id",2,"type",6,"end1x",7,"end1y",8,"end2x",9,"end2y") 8 | d.extra(ld) 9 | g = gl(d) 10 | g.arad(0,0.2) 11 | g.lrad(1,5) 12 | g.lcol(1,"green") 13 | v = vcr(g) 14 | 15 | print "all done ... type CTRL-D to exit Pizza.py" 16 | -------------------------------------------------------------------------------- /examples/test_vec.py: -------------------------------------------------------------------------------- 1 | # simple test of vec tool 2 | # requires files/vec.txt 3 | # creates tmp.vec and tmp.vec.two 4 | 5 | v = vec("files/vec.txt") 6 | 7 | print "# of vectors =",v.nvec 8 | print "length of vectors =",v.nlen 9 | print "names of vectors =",v.names 10 | 11 | time,temp,press = v.get(1,"col2",6) 12 | print temp,press 13 | v.write("tmp.vec") 14 | v.write("tmp.vec.two","col1",3) 15 | 16 | print "all done ... type CTRL-D to exit Pizza.py" 17 | -------------------------------------------------------------------------------- /examples/test_clog.py: -------------------------------------------------------------------------------- 1 | # simple test of clog tool 2 | # requires files/log.ccell 3 | # creates tmp.clog and tmp.clog.two 4 | 5 | c = log("files/log.ccell") 6 | 7 | print "# of vectors =",c.nvec 8 | print "length of vectors =",c.nlen 9 | print "names of vectors =",c.names 10 | 11 | time,a,b = c.get("Step","prey","predator") 12 | print a,b 13 | c.write("tmp.clog") 14 | c.write("tmp.clog.two","Step","prey") 15 | 16 | print "all done ... type CTRL-D to exit Pizza.py" 17 | -------------------------------------------------------------------------------- /examples/movie_flow.py: -------------------------------------------------------------------------------- 1 | # movie of flow around obstacle 2 | 3 | d = dump("dump.flow") 4 | d.map(1,"id",2,"type",3,"x",4,"y",5,"z",6,"vx",7,"vy") 5 | d.set("$ke = sqrt($vx*$vx + $vy*$vy)") 6 | d.spread("vx",100,"color") 7 | d.atype = "color" 8 | 9 | r = raster(d) 10 | r.acol(range(100),["red","red","red","red","yellow","green","blue","purple","purple","purple","purple"]) 11 | r.arad(range(100),0.5) 12 | r.rotate(0,-90) 13 | r.zoom(1.5) 14 | r.file = "flow" 15 | 16 | r.all() 17 | -------------------------------------------------------------------------------- /examples/movie_melt.py: -------------------------------------------------------------------------------- 1 | # movie of melting LJ solid 2 | 3 | a = dump("dump.melt") 4 | a.tselect.test("$t == 0") 5 | a.scale() 6 | a.set("$ix = int($x * 4)") 7 | a.set("$iy = int($y * 4)") 8 | a.set("$iz = int($z * 4)") 9 | a.set("$type = ($ix + $iy + $iz) % 2 + 1") 10 | a.unscale() 11 | a.tselect.all() 12 | a.clone(0,"type") 13 | 14 | r = raster(a) 15 | r.acol([1,2],["red","green"]) 16 | r.arad([1,2],0.5) 17 | r.file = "melt" 18 | r.pan(130,25,1,60,135,0.6) 19 | 20 | r.all() 21 | -------------------------------------------------------------------------------- /examples/test_log.py: -------------------------------------------------------------------------------- 1 | # simple test of log tool 2 | # requires files/log.obstacle 3 | # creates tmp.log and tmp.log.two 4 | 5 | lg = log("files/log.obstacle") 6 | 7 | print "# of vectors =",lg.nvec 8 | print "length of vectors =",lg.nlen 9 | print "names of vectors =",lg.names 10 | 11 | time,temp,press = lg.get("Step","Temp","Press") 12 | print temp,press 13 | lg.write("tmp.log") 14 | lg.write("tmp.log.two","Step","E_pair") 15 | 16 | print "all done ... type CTRL-D to exit Pizza.py" 17 | -------------------------------------------------------------------------------- /examples/test_pdbfile.py: -------------------------------------------------------------------------------- 1 | # simple test of pdbfile tool 2 | # requires files/dump.peptide.* and files/peptide.pdb 3 | # creates tmp*.pdb 4 | 5 | d = dump("files/dump.peptide.*") 6 | p = pdbfile("files/peptide",d) 7 | p.one() 8 | p.many() 9 | p.single(0,"tmp.single") 10 | 11 | n = flag = 0 12 | while 1: 13 | index,time,flag = p.iterator(flag) 14 | if flag == -1: break 15 | p.single(time,"tmp.single") 16 | n += 1 17 | 18 | print "Incrementally processed %d PDB files" % n 19 | 20 | print "all done ... type CTRL-D to exit Pizza.py" 21 | -------------------------------------------------------------------------------- /examples/test_rasmol.py: -------------------------------------------------------------------------------- 1 | # simple test of rasmol tool 2 | # requires files/dump.peptide and files/peptide.pdb 3 | # creates tmp*.pdb and tmp*.gif 4 | 5 | d = dump("files/dump.peptide") 6 | d.unwrap() 7 | p = pdbfile("files/peptide",d) 8 | r = rasmol(p) 9 | r.file = "tmp" 10 | 11 | print "kill image window when ready to contine ..." 12 | r.show(0) 13 | r.all() 14 | 15 | # change RasMol settings, run all() with those settings 16 | 17 | print "change RasMol settings as desired, then type 'quit' ..." 18 | r.run(0) 19 | r.all("tmp.rasmol") 20 | 21 | print "all done ... type CTRL-D to exit Pizza.py" 22 | -------------------------------------------------------------------------------- /scripts/dview.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: dview.py 4 | # Purpose: launch vcr tool on LAMMPS dump files 5 | # Syntax: dview.py --n 512 dump.1 dump.2 ... 6 | # files = one or more dump files 7 | # Example: dview.py dump.* 8 | # Author: Steve Plimpton (Sandia) 9 | 10 | # main script 11 | 12 | if len(argv) < 2: 13 | raise StandardError, "Syntax: dview.py --n 512 dump.1 ..." 14 | 15 | if argv[1] == "--n": 16 | n = int(argv[2]) 17 | files = ' '.join(argv[3:]) 18 | else: 19 | n = 512 20 | files = ' '.join(argv[1:]) 21 | 22 | d = dump(files) 23 | g = gl(d,n) 24 | v = vcr(g) 25 | -------------------------------------------------------------------------------- /examples/movie_tri.py: -------------------------------------------------------------------------------- 1 | # movie of triangular particle data 2 | 3 | d = dump("dump.tri") 4 | d.set("$center = ((int($id)-1)/36+1)*36") 5 | d.owrap("center") 6 | 7 | r = raster(d) 8 | r.bg("white") 9 | r.file = "tri" 10 | r.acol([1,2],["blue","red"]) 11 | r.arad([1,2],0.5) 12 | r.box(1) 13 | 14 | # spin 15 | 16 | d.tselect.test("$t == 0") 17 | r.pan(60,150,1,60,30,1) 18 | r.all(0,25,0) 19 | 20 | # slice 21 | 22 | r.pan() 23 | r.rotate(60,30) 24 | r.select = "$x < -12 + (1-%g) * 24" 25 | r.all(0,25,25) 26 | 27 | # timestep animation 28 | 29 | d.tselect.all() 30 | r.rotate(60,30) 31 | r.select = "" 32 | r.all(50) 33 | -------------------------------------------------------------------------------- /examples/test_gnu.py: -------------------------------------------------------------------------------- 1 | # simple test of gnu tool 2 | # creates tmp.eps 3 | 4 | g = gnu() 5 | 6 | g("plot sin(x) with lines") 7 | 8 | a = range(10) 9 | b = [3,6,2,5,7,3,6,5,3,1] 10 | 11 | g.plot(a) 12 | g.plot(a,b) 13 | g.plot(a,b,b,a) 14 | g.mplot(0,10,2,"tmp",a,b) 15 | 16 | g.export("tmp.gnu",a,b) 17 | 18 | g.select(2) 19 | g.plot(a,b,b,a) 20 | g.hide(1) 21 | 22 | g.aspect(1.0) 23 | g.title("My title","x-axis","y-axis") 24 | g.xrange(1,8) 25 | g.yrange(2,7) 26 | g.label(5,4,"this is a test label") 27 | g.curve(1,'g') 28 | g.curve(2,'m') 29 | g.ylog() 30 | 31 | g.save("tmp") 32 | 33 | print "all done ... type CTRL-D to exit Pizza.py" 34 | -------------------------------------------------------------------------------- /examples/test_matlab.py: -------------------------------------------------------------------------------- 1 | # simple test of matlab tool 2 | # creates tmp.eps 3 | 4 | m = matlab() 5 | 6 | a = range(10) 7 | b = [3,6,2,5,7,3,6,5,3,1] 8 | 9 | m.plot(a) 10 | m.plot(a,b) 11 | m.plot(a,b,b,a) 12 | m.mplot(0,10,2,"tmp",a,b) 13 | 14 | m("3*400 - 50") 15 | 16 | m.export("tmp.gnu",a,b) 17 | 18 | m.select(2) 19 | m.plot(a,b,b,a) 20 | m.hide(1) 21 | 22 | m.aspect(1.0) 23 | m.title("My title","x-axis","y-axis") 24 | m.xrange(1,8) 25 | m.yrange(2,7) 26 | m.label(5,4,"this is a test label") 27 | m.curve(1,'g') 28 | m.curve(2,'m') 29 | #m.ylog() 30 | 31 | m.save("tmp") 32 | 33 | print "all done ... type CTRL-D to exit Pizza.py" 34 | -------------------------------------------------------------------------------- /examples/test_gl.py: -------------------------------------------------------------------------------- 1 | # simple test of gl tool 2 | # requires files/dump.kinase 3 | # creates tmp*.png 4 | 5 | d = dump("files/dump.kinase") 6 | g = gl(d) 7 | 8 | g.bg("white") 9 | g.rotate(60,130) 10 | g.box(1) 11 | g.q(10) 12 | g.file = "tmp" 13 | 14 | g.show(0) 15 | g.all() 16 | 17 | from vizinfo import colors 18 | 19 | g.acol([1,4,6,8,9],["gray","red","blue","green","yellow"]) 20 | g.arad(range(9),0.3) 21 | #g.label(0.2,0.4,'h',15,"red","test label #1") 22 | #g.label(-0.2,-0.4,'h',15,"yellow","test label #2") 23 | 24 | g.show(0) 25 | g.pan(60,130,1,60,30,0.5) 26 | g.all(0,10,0) 27 | 28 | print "all done ... type CTRL-D to exit Pizza.py" 29 | -------------------------------------------------------------------------------- /scripts/iview.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: iview.py 4 | # Purpose: launch animate tool on series of image files 5 | # Syntax: iview.py files ... 6 | # files = one or more image files 7 | # Example: iview.py image*png 8 | # Author: Steve Plimpton (Sandia) 9 | 10 | # enable script to run from Python directly w/out Pizza.py 11 | 12 | import sys 13 | from animate import animate 14 | if not globals().has_key("argv"): argv = sys.argv 15 | 16 | # main script 17 | # this could be done with one-line alias in shell start-up file 18 | 19 | if len(argv) < 2: raise StandardError, "Syntax: iview.py files ..." 20 | a = animate(' '.join(argv[1:])) 21 | -------------------------------------------------------------------------------- /examples/movie_bucky.py: -------------------------------------------------------------------------------- 1 | # movie of bucky-ball data 2 | 3 | d = dump("dump.bucky") 4 | d.set("$center = ((int($id)-1)/61+1)*61") 5 | d.owrap("center") 6 | 7 | r = raster(d) 8 | r.file = "bucky" 9 | r.acol([1,2,3],["blue","red","green"]) 10 | r.arad([1,2,3],[0.5,0.5,2.5]) 11 | r.box(1) 12 | 13 | # spin 14 | 15 | d.tselect.test("$t == 0") 16 | r.pan(60,150,1,60,30,1) 17 | r.all(0,25,0) 18 | 19 | # slice 20 | 21 | r.pan() 22 | r.rotate(60,30) 23 | r.select = "$x < -17 + (1-%g) * 34 and $type > 1" 24 | r.all(0,25,25) 25 | 26 | # timestep animation 27 | 28 | d.tselect.all() 29 | d.aselect.test("$type > 1") 30 | r.rotate(60,30) 31 | r.select = "" 32 | r.all(50) 33 | -------------------------------------------------------------------------------- /examples/test_svg.py: -------------------------------------------------------------------------------- 1 | # simple test of svg tool 2 | # requires files/dump.kinase 3 | # creates tmp*.png 4 | 5 | d = dump("files/dump.kinase") 6 | s = svg(d) 7 | 8 | s.bg("white") 9 | s.rotate(60,130) 10 | s.box(1) 11 | s.file = "tmp" 12 | 13 | print "kill image window when ready to contine ..." 14 | s.show(0) 15 | s.all() 16 | 17 | from vizinfo import colors 18 | 19 | s.acol([1,4,6,8,9],["gray","red","blue","green","yellow"]) 20 | s.arad(range(9),0.3) 21 | s.label(0.2,0.4,'h',15,"red","test label #1") 22 | s.label(-0.2,-0.4,'h',15,"yellow","test label #2") 23 | 24 | print "kill image window when ready to contine ..." 25 | s.show(0) 26 | s.pan(60,130,1,60,30,0.5) 27 | s.all(0,10,0) 28 | 29 | print "all done ... type CTRL-D to exit Pizza.py" 30 | -------------------------------------------------------------------------------- /examples/test_data.py: -------------------------------------------------------------------------------- 1 | # simple test of data tool 2 | # requires files/data.micelle and dump.micelle 3 | # creates tmp.data 4 | 5 | d = data("files/data.micelle") 6 | d.map(1,"id",3,"type",4,"x",5,"y",6,"z") 7 | coeffs = d.get("Masses") 8 | print "Masses",coeffs 9 | x = d.get("Atoms",4) 10 | print "X of 1st atom",x[0] 11 | 12 | d.title = "New LAMMPS data file" 13 | 14 | natoms = d.headers["atoms"] 15 | vec = range(1,natoms+1) 16 | vec.reverse() 17 | d.replace("Atoms",1,vec) 18 | 19 | dm = dump("files/dump.micelle") 20 | d.newxyz(dm,1000) 21 | 22 | flag = 0 23 | while 1: 24 | index,time,flag = d.iterator(flag) 25 | if flag == -1: break 26 | time,box,atoms,bonds,tris,lines= d.viz(index) 27 | 28 | d.write("tmp.data") 29 | 30 | print "all done ... type CTRL-D to exit Pizza.py" 31 | -------------------------------------------------------------------------------- /scripts/plot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: plot.py 4 | # Purpose: plots of a file of vectors 5 | # Syntax: plot.py gnu/matlab file 6 | # gnu/matlab = style of plots to create 7 | # file = a file with columns of data 8 | # Example: plot.py gnu file.dat 9 | # Author: Steve Plimpton (Sandia) 10 | 11 | # enable script to run from Python directly w/out Pizza.py 12 | 13 | import sys 14 | from plotview import plotview 15 | from gnu import gnu 16 | from matlab import matlab 17 | if not globals().has_key("argv"): argv = sys.argv 18 | 19 | # main script 20 | 21 | if len(argv) != 3: 22 | raise StandardError, "Syntax: plot.py gnu/matlab file" 23 | 24 | style = argv[1] 25 | file = argv[2] 26 | 27 | v = vec(file) 28 | exec "plot = %s()" % style 29 | p = plotview(v,plot) 30 | 31 | -------------------------------------------------------------------------------- /examples/test_raster.py: -------------------------------------------------------------------------------- 1 | # simple test of raster tool 2 | # requires files/dump.kinase 3 | # creates tmp*.png 4 | 5 | d = dump("files/dump.kinase") 6 | r = raster(d) 7 | 8 | r.bg("white") 9 | r.rotate(60,130) 10 | r.box(1) 11 | r.file = "tmp" 12 | 13 | print "kill image window when ready to contine ..." 14 | r.show(0) 15 | r.all() 16 | a1 = animate("tmp0*png") 17 | 18 | from vizinfo import colors 19 | 20 | r.acol([1,4,6,8,9],["gray","red","blue","green","yellow"]) 21 | r.arad(range(9),0.3) 22 | r.label(0.2,0.4,'h',15,"red","test label #1") 23 | r.label(-0.2,-0.4,'h',15,"yellow","test label #2") 24 | 25 | print "kill image window when ready to contine ..." 26 | r.show(0) 27 | r.pan(60,130,1,60,30,0.5) 28 | r.all(0,10,0) 29 | a2 = animate("tmp0*png") 30 | 31 | print "all done ... type CTRL-D to exit Pizza.py" 32 | -------------------------------------------------------------------------------- /examples/test_mdump.py: -------------------------------------------------------------------------------- 1 | # simple test of mdump tool 2 | # requires files/mesh.grain 3 | # creates tmp.* files 4 | 5 | m = mdump("files/mesh.grain") 6 | 7 | m.tselect.none() 8 | m.tselect.one(200) 9 | m.tselect.all() 10 | m.tselect.skip(2) 11 | m.tselect.all() 12 | m.tselect.test("$t >= 100 and $t <= 200") 13 | m.delete() 14 | 15 | print "Time",m.time() 16 | 17 | m.map(2,"spin") 18 | m.etype = "spin" 19 | 20 | flag = 0 21 | while 1: 22 | index,time,flag = m.iterator(flag) 23 | if flag == -1: break 24 | time,box,atoms,bonds,tris,lines = m.viz(index) 25 | colors = [tri[1] for tri in tris] 26 | print time,colors 27 | 28 | m = dump("files/mesh.grain",0) 29 | while 1: 30 | time = m.next() 31 | if time < 0: break 32 | 33 | print "Incrementally read snaps =",m.nsnaps 34 | 35 | print "all done ... type CTRL-D to exit Pizza.py" 36 | -------------------------------------------------------------------------------- /examples/test_cdata.py: -------------------------------------------------------------------------------- 1 | # simple test of cdata tool 2 | # creates tmp.cdata 3 | 4 | c = cdata() 5 | 6 | c.box("box",0,0,0,10,5,5) 7 | c.sphere("nucleus",7,2,2,1) 8 | c.cap("organelle",'x',2.5,2.5,1,1.5,3.5) 9 | c.q("nucleus",5) 10 | c.union("interior","nucleus","organelle") 11 | 12 | c.surf("nuc","nucleus") 13 | c.surfselect("nuchalf","nuc","$z < 2.0") 14 | 15 | c.part("A",100,"box","interior") 16 | c.part("B",100,"nucleus") 17 | c.part2d("C",100,"organelle") 18 | 19 | c.write("tmp.cdata","box","nucleus","organelle","A","B","C") 20 | 21 | c.lbox("linebox",0,0,0,10,5,5) 22 | c.unselect() 23 | c.select("A","B","C","linebox","organelle","nuchalf") 24 | 25 | #s = svg(c) 26 | #s.rotate(0,0) 27 | #s.lrad(0,0.1) 28 | #s.lcol(0,"yellow") 29 | #s.show(0) 30 | 31 | g = gl(c) 32 | v = vcr(g) 33 | 34 | print "all done ... type CTRL-D to exit Pizza.py" 35 | -------------------------------------------------------------------------------- /scripts/dview_standalone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: dview.py 4 | # Purpose: launch vcr tool on LAMMPS dump files 5 | # Syntax: dview.py dump.1 dump.2 ... 6 | # files = one or more dump files 7 | # Example: dview.py dump.* 8 | # Author: Steve Plimpton (Sandia) 9 | 10 | # enable script to run from Python directly w/out Pizza.py 11 | 12 | import sys 13 | from dump import dump 14 | 15 | # w/out Pizza.py these lines need to come before import of gl tool 16 | import Tkinter 17 | tkroot = Tkinter.Tk() 18 | tkroot.withdraw() 19 | 20 | from gl import gl 21 | from vcr import vcr 22 | if not globals().has_key("argv"): argv = sys.argv 23 | 24 | # main script 25 | 26 | if len(argv) < 2: 27 | raise StandardError, "Syntax: dview.py dump.1 ..." 28 | 29 | files = ' '.join(argv[1:]) 30 | 31 | d = dump(files) 32 | g = gl(d) 33 | v = vcr(g) 34 | -------------------------------------------------------------------------------- /scripts/logview.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: logview.py 4 | # Purpose: plots of LAMMPS log-file thermodynamic data 5 | # Syntax: logview.py gnu/matlab files ... 6 | # gnu/matlab = style of plots to create 7 | # files = one or more log files 8 | # Example: logview.py gnu log.* 9 | # Author: Steve Plimpton (Sandia) 10 | 11 | # enable script to run from Python directly w/out Pizza.py 12 | 13 | import sys 14 | from log import log 15 | from plotview import plotview 16 | from gnu import gnu 17 | from matlab import matlab 18 | if not globals().has_key("argv"): argv = sys.argv 19 | 20 | # main script 21 | 22 | if len(argv) < 3: 23 | raise StandardError, "Syntax: logview.py gnu/matlab files ..." 24 | 25 | style = argv[1] 26 | files = ' '.join(argv[2:]) 27 | 28 | lg = log(files) 29 | exec "plot = %s()" % style 30 | p = plotview(lg,plot) 31 | 32 | -------------------------------------------------------------------------------- /scripts/clogview.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: clogview.py 4 | # Purpose: plots of ChemCell log-file concentration data 5 | # Syntax: clogview.py gnu/matlab files ... 6 | # gnu/matlab = style of plots to create 7 | # files = one or more log files 8 | # Example: clogview.py gnu log.* 9 | # Author: Steve Plimpton (Sandia) 10 | 11 | # enable script to run from Python directly w/out Pizza.py 12 | 13 | import sys 14 | from clog import clog 15 | from plotview import plotview 16 | from gnu import gnu 17 | from matlab import matlab 18 | if not globals().has_key("argv"): argv = sys.argv 19 | 20 | # main script 21 | 22 | if len(argv) < 3: 23 | raise StandardError, "Syntax: clogview.py gnu/matlab files ..." 24 | 25 | style = argv[1] 26 | files = ' '.join(argv[2:]) 27 | 28 | c = clog(files) 29 | exec "plot = %s()" % style 30 | p = plotview(c,plot) 31 | p.x = "Time" 32 | 33 | -------------------------------------------------------------------------------- /scripts/README: -------------------------------------------------------------------------------- 1 | This directory contains a collection of scripts written by Pizza.py 2 | users that are generically useful; you may wish to use them directly 3 | or modify them for your own purposes. You can add your own scripts to 4 | this directory as well. 5 | 6 | Any script in this directory (or other directories you define, see the 7 | Pizza.py manual), can be run from Pizza.py, by typing a line 8 | appropriate to the script's syntax, e.g. 9 | 10 | % pizza.py -f movie.py svg 0.5 60 135 dump.* from the shell 11 | > @run movie.py svg 0.5 60 135 dump.* from Pizza.py 12 | 13 | The top of each script file describes its purpose and syntax. That 14 | information can be be accessed from within Pizza.py by typing "??" or 15 | "? name.py" or "?? name.py". 16 | 17 | Many of the scripts can also be run directly from Python (without 18 | running Pizza.py), so long as the Pizza.py tools (Python files) it 19 | needs to import (e.g. log.py) can be found by Python. 20 | 21 | -------------------------------------------------------------------------------- /scripts/movie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: movie.py 4 | # Purpose: create images from LAMMPS dump snapshots 5 | # Syntax: movie.py raster/svg theta phi dump.1 dump.2 ... 6 | # raster/svg = style of image to create 7 | # theta/phi = vertical (z) and azimuthal angle to view from 8 | # files = one or more dump files 9 | # Example: movie.py svg 60 130 dump.* 10 | # Author: Steve Plimpton (Sandia) 11 | 12 | # enable script to run from Python directly w/out Pizza.py 13 | 14 | import sys 15 | from dump import dump 16 | from raster import raster 17 | from svg import svg 18 | if not globals().has_key("argv"): argv = sys.argv 19 | 20 | # main script 21 | 22 | if len(argv) < 5: 23 | raise StandardError, "Syntax: movie.py raster/svg theta phi dump.1 ..." 24 | 25 | style = argv[1] 26 | theta = float(argv[2]) 27 | phi = float(argv[3]) 28 | files = ' '.join(argv[4:]) 29 | 30 | d = dump(files) 31 | exec "viz = %s(d)" % style 32 | viz.rotate(theta,phi) 33 | viz.all() 34 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | This directory contains a collection of example scripts. There is one 2 | test_*.py script for each tool in Pizza.py. These illustrate how to 3 | use the tool. The small data sets used by these scripts are in the 4 | files sub-directly. 5 | 6 | A test_*.py script can be run by launching Pizza.py from this 7 | directory, e.g. 8 | 9 | % pizza.py -f test_animate.py from the shell 10 | > @run test_animtate.py from Pizza.py 11 | 12 | The other scripts in this directory perform specific tasks. Read the 13 | comments at the top of the script file for an explanation. Most of 14 | these scripts require a data set to operate on, which is not provided. 15 | These scripts are included simply to illustrate how a particular task 16 | can be done in Pizza.py. 17 | 18 | These scripts create output and temporary files as they operate. 19 | These are all named tmp*. Pizza.py does not clean up all the 20 | temporary files, since they are sometimes useful to look at for 21 | debugging or other purposes. 22 | -------------------------------------------------------------------------------- /doc/histo.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | histo tool :h3 10 | 11 | [Purpose:] 12 | 13 | Particle density histogram from a dump. 14 | 15 | [Description:] 16 | 17 | The histo tool creates spatial histograms of particle snapshots in 18 | a dump file. 19 | 20 | The histo constructor takes an object that stores atom snapshots 21 | ("dump"_dump.html, "data"_data.html) as its argument. 22 | 23 | The compute() method creates a histogram in a specific dimension at a 24 | desired resolution, averaged across all selected snapshots and atoms 25 | in the dump. The returned vectors can be plotted; x is the distance 26 | along the chosen dimension, y is the histogram counts. 27 | 28 | [Usage:] 29 | 30 | h = histo(d) d = dump/cdump object :pre 31 | 32 | x,y = h.compute('x',N,lo,hi) compute histogram in dim with N bins :pre 33 | 34 | lo/hi are optional, if not used histo will be over entire box :pre 35 | 36 | [Related tools:] 37 | 38 | "dump"_dump.html 39 | 40 | [Prerequisites:] none 41 | -------------------------------------------------------------------------------- /examples/test_dump.py: -------------------------------------------------------------------------------- 1 | # simple test of dump tool 2 | # requires files/dump.peptide and files/dump.peptide.* 3 | # creates tmp.* files 4 | 5 | d = dump("files/dump.peptide") 6 | 7 | d.tselect.none() 8 | d.tselect.one(2000) 9 | d.tselect.all() 10 | d.tselect.skip(2) 11 | d.tselect.all() 12 | d.tselect.test("$t >= 4000 and $t <= 6000") 13 | d.delete() 14 | 15 | d.aselect.all() 16 | d.aselect.test("$id <= 10") 17 | 18 | d.write("tmp.dump") 19 | d.scatter("tmp") 20 | 21 | d = dump("files/dump.peptide") 22 | d.scale() 23 | d.unscale() 24 | d.unwrap() 25 | d.wrap() 26 | d.set("$xyz = $x + $y + $z") 27 | d.spread("x",100,"color") 28 | d.clone(0,"color") 29 | 30 | print "Time",d.time() 31 | color = d.atom(1,"color") 32 | print "Color of atom 1",color 33 | d.aselect.test("$id <= 10") 34 | color = d.vecs(1000,"color") 35 | print "Color of 1st 10 atoms in step 1000",color 36 | 37 | d.atype = "color" 38 | 39 | flag = 0 40 | while 1: 41 | index,time,flag = d.iterator(flag) 42 | if flag == -1: break 43 | time,box,atoms,bonds,tris,lines = d.viz(index) 44 | colors = [atom[1] for atom in atoms] 45 | print time,colors 46 | 47 | d = dump("files/dump.peptide.*",0) 48 | while 1: 49 | time = d.next() 50 | if time < 0: break 51 | 52 | print "Incrementally read snaps =",d.nsnaps 53 | 54 | print "all done ... type CTRL-D to exit Pizza.py" 55 | -------------------------------------------------------------------------------- /doc/histo.html: -------------------------------------------------------------------------------- 1 | 2 |
Purpose: 15 |
16 |Particle density histogram from a dump. 17 |
18 |Description: 19 |
20 |The histo tool creates spatial histograms of particle snapshots in 21 | a dump file. 22 |
23 |The histo constructor takes an object that stores atom snapshots 24 | (dump, data) as its argument. 25 |
26 |The compute() method creates a histogram in a specific dimension at a 27 | desired resolution, averaged across all selected snapshots and atoms 28 | in the dump. The returned vectors can be plotted; x is the distance 29 | along the chosen dimension, y is the histogram counts. 30 |
31 |Usage: 32 |
33 |h = histo(d) d = dump/cdump object 34 |35 |
x,y = h.compute('x',N,lo,hi) compute histogram in dim with N bins
36 |
37 | lo/hi are optional, if not used histo will be over entire box 38 |39 |
Related tools: 40 |
41 |dump 42 |
43 |Prerequisites: none 44 |
45 | 46 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Summary** 2 | 3 | 4 | 5 | **Related Issue(s)** 6 | 7 | 8 | 9 | **Author(s)** 10 | 11 | 12 | 13 | **Licensing** 14 | 15 | By submitting this pull request, I agree, that my contribution will be included in Pizza.py redistributed under the either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1). 16 | 17 | **Further Information, Files, and Links** 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/xyz.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | xyz tool :h3 10 | 11 | [Purpose:] 12 | 13 | Convert LAMMPS snapshots to XYZ format. 14 | 15 | [Description:] 16 | 17 | The xyz tool converts atom snapshots in a LAMMPS dump or data file to 18 | the XYZ format used by various visualization packages. 19 | 20 | The xyz constructor takes an object that stores atom snapshots 21 | ("dump"_dump.html, "data"_data.html) as its first argument. The atom 22 | snapshots must have "id", "type", "x", "y", and "z" defined; see the 23 | map() methods of those tools. 24 | 25 | The one(), many(), and single() methods convert specific snapshots to 26 | the XYZ format and write them out. Optionally, a file prefix for the 27 | XYZ output files can also be specified. A ".xyz" suffix will be 28 | appended to all output files. 29 | 30 | [Usage:] 31 | 32 | x = xyz(d) d = object containing atom coords (dump, data) :pre 33 | 34 | x.one() write all snapshots to tmp.xyz 35 | x.one("new") write all snapshots to new.xyz 36 | x.many() write snapshots to tmp0000.xyz, tmp0001.xyz, etc 37 | x.many("new") write snapshots to new0000.xyz, new0001.xyz, etc 38 | x.single(N) write snapshot for timestep N to tmp.xyz 39 | x.single(N,"file") write snapshot for timestep N to file.xyz :pre 40 | 41 | [Related tools:] 42 | 43 | "cfg"_cfg.html, "data"_data.html, "dump"_dump.html, 44 | "ensight"_ensight.html, "vtk"_vtk.html 45 | 46 | [Prerequisites:] none 47 | -------------------------------------------------------------------------------- /doc/vtk.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | vtk tool :h3 10 | 11 | [Purpose:] 12 | 13 | Convert LAMMPS snapshots to VTK format. 14 | 15 | [Description:] 16 | 17 | The vtk tool converts atom snapshots in a LAMMPS dump or data file to 18 | the VTK format used by various visualization packages. 19 | 20 | The vtk constructor takes an object that stores atom snapshots 21 | ("dump"_dump.html, "data"_data.html) as its first argument. The atom 22 | snapshots must have "id", "type", "x", "y", and "z" defined; see the 23 | map() methods of those tools. 24 | 25 | The one(), many(), and single() methods convert specific snapshots to 26 | the VTK format and write them out. Optionally, a file prefix for the 27 | XYZ output files can also be specified. A ".xyz" suffix will be 28 | appended to all output files. 29 | 30 | [Usage:] 31 | 32 | v = vtk(d) d = object containing atom coords (dump, data) :pre 33 | 34 | v.one() write all snapshots to tmp.vtk 35 | v.one("new") write all snapshots to new.vtk 36 | v.many() write snapshots to tmp0000.vtk, tmp0001.vtk, etc 37 | v.many("new") write snapshots to new0000.vtk, new0001.vtk, etc 38 | v.single(N) write snapshot for timestep N to tmp.vtk 39 | v.single(N,"file") write snapshot for timestep N to file.vtk :pre 40 | 41 | surfaces in snapshot will be written to SURF1.vtk, SURF2.vtk, etc 42 | where each surface (triangle type) is in a different file :pre 43 | 44 | [Related tools:] 45 | 46 | "cfg"_cfg.html, "data"_data.html, "dump"_dump.html, 47 | "ensight"_ensight.html, "xyz"_xyz.html 48 | 49 | [Prerequisites:] none 50 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is the Pizza.py (1 Oct 2006) software package. 2 | 3 | Copyright (2005) Sandia Corporation. Under the terms of Contract 4 | DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 5 | certain rights in this software. This software is distributed under 6 | the GNU General Public License. 7 | 8 | ---------------------------------------------------------------------- 9 | 10 | Pizza.py is a loosely integrated collection of tools written in 11 | Python, many of which provide pre- and post-processing capability for 12 | the LAMMPS molecular dynamics package. There are tools to create 13 | input files, convert between file formats, process log and dump files, 14 | create plots, and visualize and animate simulation snapshots. 15 | 16 | Pizza.py was developed at Sandia National Laboratories, a US 17 | Department of Energy facility, with funding from the DOE. It is an 18 | open-source code, distributed freely under the terms of the GNU Public 19 | License (GPL). 20 | 21 | The maintainer of Pizza.py is Steve Plimpton, who can be emailed at 22 | sjplimp@sandia.gov. The Pizza.py WWW site 23 | (www.cs.sandia.gov/~sjplimp/lammps.html) and LAMMPS WWW Site 24 | (www.cs.sandia.gov/~sjplimp/lammps.html) have more information about 25 | the code and its uses. 26 | 27 | The Pizza.py (1 Oct 2006) distribution includes the following files 28 | and directories: 29 | 30 | README this file 31 | LICENSE the GNU open-source license 32 | doc HTML documentation for Pizza.py 33 | examples scripts and data sets that exercise Pizza.py tools 34 | scripts various Pizza.py script files 35 | src source code for Pizza.py and its tools 36 | 37 | Point your browser at any of these files to get started: 38 | 39 | doc/Manual.html the Pizza.py manual 40 | doc/Section_intro.html hi-level introduction to Pizza.py 41 | doc/Section_install.html how to install Pizza.py 42 | -------------------------------------------------------------------------------- /doc/xyz.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Convert LAMMPS snapshots to XYZ format. 17 |
18 |Description: 19 |
20 |The xyz tool converts atom snapshots in a LAMMPS dump or data file to 21 | the XYZ format used by various visualization packages. 22 |
23 |The xyz constructor takes an object that stores atom snapshots 24 | (dump, data) as its first argument. The atom 25 | snapshots must have "id", "type", "x", "y", and "z" defined; see the 26 | map() methods of those tools. 27 |
28 |The one(), many(), and single() methods convert specific snapshots to 29 | the XYZ format and write them out. Optionally, a file prefix for the 30 | XYZ output files can also be specified. A ".xyz" suffix will be 31 | appended to all output files. 32 |
33 |Usage: 34 |
35 |x = xyz(d) d = object containing atom coords (dump, data) 36 |37 |
x.one() write all snapshots to tmp.xyz
38 | x.one("new") write all snapshots to new.xyz
39 | x.many() write snapshots to tmp0000.xyz, tmp0001.xyz, etc
40 | x.many("new") write snapshots to new0000.xyz, new0001.xyz, etc
41 | x.single(N) write snapshot for timestep N to tmp.xyz
42 | x.single(N,"file") write snapshot for timestep N to file.xyz
43 |
44 | Related tools: 45 |
46 |cfg, data, dump, 47 | ensight, vtk 48 |
49 |Prerequisites: none 50 |
51 | 52 | -------------------------------------------------------------------------------- /doc/vmd.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | vmd tool :h3 10 | 11 | [Purpose:] 12 | 13 | Control VMD from python. 14 | 15 | [Description:] 16 | 17 | The vmd tool is a simple wrapper on the "VMD visualization 18 | package"_vmd, a popular tool for visualizing snapshots from molecular 19 | dynamics simulations. 20 | 21 | :link(vmd,http://www.ks.uiuc.edu/Research/vmd) 22 | 23 | The vmd constructor invokes VMD in its own window. Data can be passed 24 | to it for visualization via the new(), data(), replace(), and append() 25 | methods. The other methods permit more specialized interactions with 26 | VMD through its command syntax. 27 | 28 | [Usage:] 29 | 30 | v = vmd() start up VMD 31 | v.stop() shut down VMD instance 32 | v.clear() delete all visualizations :pre 33 | 34 | v.rep(style) set default representation style. One of 35 | (Lines|VDW|Licorice|DynamicBonds|Points|CPK) 36 | v.new(file\[,type\]) load new file (default file type 'lammpstrj') 37 | v.data(file\[,atomstyle\]) load new data file (default atom style 'full') 38 | v.replace(file\[,type\]) replace current frames with new file 39 | v.append(file\[,type\]) append file to current frame(s) 40 | v.set(snap,x,y,z,(True|False)) set coordinates from a pizza.py snapshot to new or current frame :pre 41 | 42 | v.frame(frame) set current frame 43 | v.flush() flush pending input to VMD and update GUI 44 | v.read(file) read Tcl script file (e.g. saved state) :pre 45 | 46 | v.enter() enter interactive shell 47 | v.debug(\[True|False\]) display generated VMD script commands? :pre 48 | 49 | [Related tools:] 50 | 51 | "gl"_gl.html 52 | 53 | [Prerequisites:] 54 | 55 | Python pexpect package. 56 | -------------------------------------------------------------------------------- /doc/animate.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | animate tool :h3 10 | 11 | [Purpose:] 12 | 13 | Animate a series of image files. 14 | 15 | [Description:] 16 | 17 | The animate tool displays a GUI to view and animate a series of image 18 | files. 19 | 20 | The animate constructor creates the GUI. The animation can be 21 | controlled by the GUI widgets or by invoking the tool methods: play(), 22 | stop(), next(), etc. The frame slider can be dragged to view a 23 | desired frame. 24 | 25 | Image files can be in any format (PNG, GIF, BMP, etc) recognized by 26 | the Python Image Library (PIL) installed in your Python. Various 27 | Pizza.py visualization tools (raster, rasmol, etc) create such image 28 | files. If a particular image format fails to load, your PIL 29 | installation was linked without support for that format. Rebuild PIL, 30 | and follow its install instructions. 31 | 32 | [Usage:] 33 | 34 | a = animate("image*.png") create GUI to animate set of image files 35 | a = animate("image*.png",1) 2nd arg = sort filenames, 0 = no sort, def = 1 :pre 36 | 37 | Actions (same as GUI widgets): :pre 38 | 39 | a.first() go to first frame 40 | a.prev() go to previous frame 41 | a.back() play backwards from current frame to start 42 | a.stop() stop on current frame 43 | a.play() play from current frame to end 44 | a.next() go to next frame 45 | a.last() go to last frame :pre 46 | 47 | a.frame(31) set frame slider 48 | a.delay(0.4) set delay slider :pre 49 | 50 | [Related tools:] 51 | 52 | "gl"_gl.html, "raster"_raster.html, "rasmol"_rasmol.html, 53 | "svg"_svg.html, "vcr"_vcr.html 54 | 55 | [Prerequisites:] 56 | 57 | Python Tkinter and PIL packages. 58 | -------------------------------------------------------------------------------- /doc/vtk.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Convert LAMMPS snapshots to VTK format. 17 |
18 |Description: 19 |
20 |The vtk tool converts atom snapshots in a LAMMPS dump or data file to 21 | the VTK format used by various visualization packages. 22 |
23 |The vtk constructor takes an object that stores atom snapshots 24 | (dump, data) as its first argument. The atom 25 | snapshots must have "id", "type", "x", "y", and "z" defined; see the 26 | map() methods of those tools. 27 |
28 |The one(), many(), and single() methods convert specific snapshots to 29 | the VTK format and write them out. Optionally, a file prefix for the 30 | XYZ output files can also be specified. A ".xyz" suffix will be 31 | appended to all output files. 32 |
33 |Usage: 34 |
35 |v = vtk(d) d = object containing atom coords (dump, data) 36 |37 |
v.one() write all snapshots to tmp.vtk
38 | v.one("new") write all snapshots to new.vtk
39 | v.many() write snapshots to tmp0000.vtk, tmp0001.vtk, etc
40 | v.many("new") write snapshots to new0000.vtk, new0001.vtk, etc
41 | v.single(N) write snapshot for timestep N to tmp.vtk
42 | v.single(N,"file") write snapshot for timestep N to file.vtk
43 |
44 | surfaces in snapshot will be written to SURF1.vtk, SURF2.vtk, etc 45 | where each surface (triangle type) is in a different file 46 |47 |
Related tools: 48 |
49 |cfg, data, dump, 50 | ensight, xyz 51 |
52 |Prerequisites: none 53 |
54 | 55 | -------------------------------------------------------------------------------- /doc/vec.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | vec tool :h3 10 | 11 | [Purpose:] 12 | 13 | Create numeric vectors from columns in file or list of vecs. 14 | 15 | [Description:] 16 | 17 | The vec tool creates numeric vectors that can be extracted, written to 18 | files, or imported into other tools like "plotview"_plotview.html for 19 | plotting. 20 | 21 | The vec constructor takes either a file or list argument. For a file 22 | argument, columns of numeric data are read from the file. Blank lines 23 | or lines that do not start with a numeric character (0123456789.-) are 24 | skipped. Each column must have the same number of values. For a list 25 | argument, each element of the list is assumed to be a vector of values 26 | (i.e. the list is a list of lists), as shown in the example below. 27 | 28 | The columns of data may be accessed by number (1-N) or by name ("col1" 29 | thru "colN"). 30 | 31 | The get() and write() methods extract the numeric vectors of data. 32 | 33 | [Usage:] 34 | 35 | v = vec("file1") read in numeric vectors from a file 36 | v = vec(array) array = list of numeric vectors :pre 37 | 38 | skip blank lines and lines that start with non-numeric characters 39 | example array with 2 vecs = \[\[1,2,3,4,5\], \[10,20,30,40,50\]\] 40 | assigns names = "col1", "col2", etc :pre 41 | 42 | nvec = v.nvec # of vectors 43 | nlen = v.nlen lengths of vectors 44 | names = v.names list of vector names 45 | x,y,... = l.get(1,"col2",...) return one or more vectors of values 46 | l.write("file.txt") write all vectors to a file 47 | l.write("file.txt","col1",7,...) write listed vectors to a file :pre 48 | 49 | get and write allow abbreviated (uniquely) vector names or digits (1-Nvec) :pre 50 | 51 | [Related tools:] 52 | 53 | "data"_data.html, "dump"_dump.html 54 | 55 | [Prerequisites:] none 56 | -------------------------------------------------------------------------------- /doc/vmd.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Control VMD from python. 17 |
18 |Description: 19 |
20 |The vmd tool is a simple wrapper on the VMD visualization 21 | package, a popular tool for visualizing snapshots from molecular 22 | dynamics simulations. 23 |
24 | 25 | 26 |The vmd constructor invokes VMD in its own window. Data can be passed 27 | to it for visualization via the new(), data(), replace(), and append() 28 | methods. The other methods permit more specialized interactions with 29 | VMD through its command syntax. 30 |
31 |Usage: 32 |
33 |v = vmd() start up VMD 34 | v.stop() shut down VMD instance 35 | v.clear() delete all visualizations 36 |37 |
v.rep(style) set default representation style. One of 38 | (Lines|VDW|Licorice|DynamicBonds|Points|CPK) 39 | v.new(file[,type]) load new file (default file type 'lammpstrj') 40 | v.data(file[,atomstyle]) load new data file (default atom style 'full') 41 | v.replace(file[,type]) replace current frames with new file 42 | v.append(file[,type]) append file to current frame(s) 43 | v.set(snap,x,y,z,(True|False)) set coordinates from a pizza.py snapshot to new or current frame 44 |45 |
v.frame(frame) set current frame 46 | v.flush() flush pending input to VMD and update GUI 47 | v.read(file) read Tcl script file (e.g. saved state) 48 |49 |
v.enter() enter interactive shell 50 | v.debug([True|False]) display generated VMD script commands? 51 |52 |
Related tools: 53 |
54 |gl 55 |
56 |Prerequisites: 57 |
58 |Python pexpect package. 59 |
60 | 61 | -------------------------------------------------------------------------------- /doc/cfg.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | cfg tool :h3 10 | 11 | [Purpose:] 12 | 13 | Convert LAMMPS snapshots to AtomEye CFG format. 14 | 15 | [Description:] 16 | 17 | The cfg tool converts atom snapshots in a LAMMPS dump or data file to 18 | the CFG format used by the "AtomEye"_atomeye visualization tool. 19 | 20 | :link(atomeye,http://164.107.79.177/Archive/Graphics/A) 21 | 22 | The cfg constructor takes an object that stores atom snapshots 23 | ("dump"_dump.html, "data"_data.html) as its first argument. The atom 24 | snapshots must have "id", "type", "x", "y", and "z" defined; see the 25 | map() methods of those tools. 26 | 27 | The one(), many(), and single() methods convert specific snapshots to 28 | the CFG format and write them out. Optionally, a file prefix for the 29 | CFG output files can also be specified. A ".cfg" suffix will be 30 | appended to all output files. 31 | 32 | If your atom snapshots are not sorted by atom ID (e.g. because they 33 | were written out by a parallel LAMMPS run), then you may want to sort 34 | them before converting them to CFG files with this tool. This can be 35 | done by "d = dump("tmp.dump"); d.sort()". This is because AtomEye 36 | does not use atom IDs directly but infers an ID by the order of atoms 37 | as they appear in the CFG file. 38 | 39 | [Usage:] 40 | 41 | c = cfg(d) d = object containing atom coords (dump, data) :pre 42 | 43 | c.one() write all snapshots to tmp.cfg 44 | c.one("new") write all snapshots to new.cfg 45 | c.many() write snapshots to tmp0000.cfg, tmp0001.cfg, etc 46 | c.many("new") write snapshots to new0000.cfg, new0001.cfg, etc 47 | c.single(N) write snapshot for timestep N to tmp.cfg 48 | c.single(N,"file") write snapshot for timestep N to file.cfg :pre 49 | 50 | [Related tools:] 51 | 52 | "data"_data.html, "dump"_dump.html, "ensight"_ensight.html, 53 | "vtk"_vtk.html, "xyz"_xyz.html 54 | 55 | [Prerequisites:] none 56 | -------------------------------------------------------------------------------- /doc/animate.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Animate a series of image files. 17 |
18 |Description: 19 |
20 |The animate tool displays a GUI to view and animate a series of image 21 | files. 22 |
23 |The animate constructor creates the GUI. The animation can be 24 | controlled by the GUI widgets or by invoking the tool methods: play(), 25 | stop(), next(), etc. The frame slider can be dragged to view a 26 | desired frame. 27 |
28 |Image files can be in any format (PNG, GIF, BMP, etc) recognized by 29 | the Python Image Library (PIL) installed in your Python. Various 30 | Pizza.py visualization tools (raster, rasmol, etc) create such image 31 | files. If a particular image format fails to load, your PIL 32 | installation was linked without support for that format. Rebuild PIL, 33 | and follow its install instructions. 34 |
35 |Usage: 36 |
37 |a = animate("image*.png") create GUI to animate set of image files
38 | a = animate("image*.png",1) 2nd arg = sort filenames, 0 = no sort, def = 1
39 |
40 | Actions (same as GUI widgets): 41 |42 |
a.first() go to first frame 43 | a.prev() go to previous frame 44 | a.back() play backwards from current frame to start 45 | a.stop() stop on current frame 46 | a.play() play from current frame to end 47 | a.next() go to next frame 48 | a.last() go to last frame 49 |50 |
a.frame(31) set frame slider 51 | a.delay(0.4) set delay slider 52 |53 |
Related tools: 54 |
55 |gl, raster, rasmol, 56 | svg, vcr 57 |
58 |Prerequisites: 59 |
60 |Python Tkinter and PIL packages. 61 |
62 | 63 | -------------------------------------------------------------------------------- /doc/Section_examples.txt: -------------------------------------------------------------------------------- 1 | "Previous Section"_Section_tools.html - "Pizza.py WWW Site"_pws - 2 | "Pizza.py Documentation"_pd - "Pizza.py Tools"_pt - "Next 3 | Section"_Section_extend.html :c 4 | 5 | :link(pws,http://pizza.sandia.gov) 6 | :link(pd,Manual.html) 7 | :link(pt,Section_tools.html) 8 | 9 | :line 10 | 11 | 5. Example scripts :h3 12 | 13 | The Pizza.py distribution includes 2 sets of example scripts. A 14 | listing of included scripts is given on the "Pizza.py WWW 15 | site"_scripts. 16 | 17 | :link(scripts,http://www.cs.sandia.gov/~sjplimp/pizza/scripts.html) 18 | 19 | (A) The examples directory has a README file and a variety of scripts. 20 | For each tool in Pizza.py there is a test_tool.py script that invokes 21 | the tool on a simple data set (from the files sub-directory) and 22 | exercises various tool methods. These scripts are meant to illustrate 23 | how the tool is used. 24 | 25 | Assuming pizza.py is in your path, each of the test scripts can be run 26 | from within the examples directory by typing one of these lines (from 27 | the shell or from within Pizza.py): 28 | 29 | % pizza.py -f test_animate.py 30 | > @run test_animate.py :pre 31 | 32 | The remaining scripts in the examples directory illustrate how to do 33 | various tasks in Pizza.py. They are not meant to be generically 34 | useful nor are they well documented. Rather they are illustrations of 35 | how to do some specific task quickly and straightforwardly. Most of 36 | these scripts are not meant to be run by other users, since their data 37 | files are not included. 38 | 39 | (B) The scripts directory contains several scripts you may find useful 40 | either to use directly or to modify to create a new script for your 41 | purposes. 42 | 43 | The top of each script file describes its purpose and syntax. That 44 | information can be be accessed from within Pizza.py by typing "??" or 45 | "? name.py" or "?? name.py". 46 | 47 | As explained in "this section"_Section_basics.html#3_5, any file in 48 | the scripts directory can be run from the directory where your data 49 | lives, by typing a line appropriate to the script's syntax, e.g. 50 | 51 | % pizza.py -f movie.py svg 60 135 dump.protein from the shell 52 | > @run movie.py svg 60 135 dump.protein from Pizza.py :pre 53 | -------------------------------------------------------------------------------- /doc/plotview.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | plotview tool :h3 10 | 11 | [Purpose:] 12 | 13 | Plot multiple vectors from a data set. 14 | 15 | [Description:] 16 | 17 | The plotview tool displays a GUI for showing a series of plots of 18 | vectors stored in another Pizza.py tool. Individual plots can be 19 | displayed or hidden or saved to a file. 20 | 21 | The plotview constructor creates the GUI and takes a data object 22 | ("log"_log.html, "vec"_vec.html) and a plot object ("gnu"_gnu.html, 23 | "matlab"_matlab.html) as arguments. 24 | 25 | The vectors in the data object are converted to individual plots. The 26 | 2nd thru Nth vectors are each plotted against the 1st vector to create 27 | N-1 plots. One or more plots can be displayed simultaneously (right 28 | buttons in GUI), but only one is selected at a time (left buttons in 29 | GUI). The yes(), no(), and select() methods perform the same function 30 | as the GUI buttons. 31 | 32 | The currently selected plot can be modified (title, range, etc) 33 | by the methods of the plot object. 34 | 35 | The file() and save() methods (or corresponding GUI widgets) save the 36 | currently selected plot to a PostScript file. 37 | 38 | [Usage:] 39 | 40 | p = plotview(d,pl) create GUI for viewing plots :pre 41 | 42 | d = Pizza.py object that contains vectors (log, vec) 43 | pl = Pizza.py plotting object (gnu, matlab) :pre 44 | 45 | p.select(2) select one plot as current (1-N) 46 | p.yes(3) toggle one plot's visibility 47 | p.no(3) :pre 48 | 49 | only one plot is selected at a time 50 | multiple plots can be visible at same time 51 | select is same as clicking on left-side radio-button 52 | yes/no is same as clicking on right-side checkbox :pre 53 | 54 | p.x = "Time" which vector is X vector (1st vec by default) 55 | p.file("pressure") filename prefix for saving a plot 56 | p.save() save currently selected plot to file.eps :pre 57 | 58 | [Related tools:] 59 | 60 | "log"_log.html, "gnu"_gnu.html, "matlab"_matlab.html 61 | 62 | [Prerequisites:] 63 | 64 | Python Tkinter package. 65 | -------------------------------------------------------------------------------- /doc/vec.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Create numeric vectors from columns in file or list of vecs. 17 |
18 |Description: 19 |
20 |The vec tool creates numeric vectors that can be extracted, written to 21 | files, or imported into other tools like plotview for 22 | plotting. 23 |
24 |The vec constructor takes either a file or list argument. For a file 25 | argument, columns of numeric data are read from the file. Blank lines 26 | or lines that do not start with a numeric character (0123456789.-) are 27 | skipped. Each column must have the same number of values. For a list 28 | argument, each element of the list is assumed to be a vector of values 29 | (i.e. the list is a list of lists), as shown in the example below. 30 |
31 |The columns of data may be accessed by number (1-N) or by name ("col1" 32 | thru "colN"). 33 |
34 |The get() and write() methods extract the numeric vectors of data. 35 |
36 |Usage: 37 |
38 |v = vec("file1") read in numeric vectors from a file
39 | v = vec(array) array = list of numeric vectors
40 |
41 | skip blank lines and lines that start with non-numeric characters 42 | example array with 2 vecs = [[1,2,3,4,5], [10,20,30,40,50]] 43 | assigns names = "col1", "col2", etc 44 |45 |
nvec = v.nvec # of vectors
46 | nlen = v.nlen lengths of vectors
47 | names = v.names list of vector names
48 | x,y,... = l.get(1,"col2",...) return one or more vectors of values
49 | l.write("file.txt") write all vectors to a file
50 | l.write("file.txt","col1",7,...) write listed vectors to a file
51 |
52 | get and write allow abbreviated (uniquely) vector names or digits (1-Nvec) 53 |54 |
Related tools: 55 |
56 | 58 |Prerequisites: none 59 |
60 | 61 | -------------------------------------------------------------------------------- /scripts/distance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: distance.py 4 | # Purpose: check if any atom pairs are closer than specified distance 5 | # Syntax: distance.py maxcut dump.file1 dump.file2 ... 6 | # maxcut = flag atoms which are less than this distance apart 7 | # Example: distance.py 0.95 dump.file1 8 | # Author: Paul Crozier (Sandia) 9 | 10 | # print out 2 atoms less than maxcut apart (with PBC) 11 | 12 | from math import sqrt 13 | 14 | if len(argv) < 3: 15 | raise StandardError,"distance.py maxcut dump.file1 dump.file2 ..." 16 | 17 | maxcut = float(argv[1]) 18 | maxcut_sq = maxcut*maxcut 19 | 20 | files = ' '.join(argv[2:]) # dump files 21 | d = dump(files,0) 22 | d.map(1,"id",2,"type",3,"x",4,"y",5,"z") 23 | 24 | while 1: 25 | time = d.next() 26 | if time < 0: break 27 | d.unscale(time) 28 | 29 | box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo, 30 | d.snaps[-1].xhi,d.snaps[-1].yhi,d.snaps[-1].zhi) 31 | d.aselect.all(time) 32 | id,type,x,y,z = d.vecs(time,"id","type","x","y","z") 33 | n = len(x) 34 | 35 | xprd = box[3] - box[0] 36 | yprd = box[4] - box[1] 37 | zprd = box[5] - box[2] 38 | 39 | for i in xrange(n): 40 | for j in xrange(i+1,n): 41 | 42 | delx = x[j] - x[i] 43 | if abs(delx) > 0.5*xprd: 44 | if delx < 0.0: 45 | delx += xprd 46 | else: 47 | delx -= xprd 48 | if (delx*delx < maxcut_sq): 49 | 50 | dely = y[j] - y[i] 51 | if abs(dely) > 0.5*yprd: 52 | if dely < 0.0: 53 | dely += yprd 54 | else: 55 | dely -= yprd 56 | if ((dely*dely + delx*delx) < maxcut_sq): 57 | 58 | delz = z[j] - z[i] 59 | if abs(delz) > 0.5*zprd: 60 | if delz < 0.0: 61 | delz += zprd 62 | else: 63 | delz -= zprd 64 | 65 | rsq = delx*delx + dely*dely + delz*delz 66 | 67 | if rsq < maxcut_sq: 68 | print "time = %d, id[i] = %d, id[j] = %d," \ 69 | " type[i] = %d, type[j] = %d, distance = %g" % \ 70 | (time, id[i], id[j], type[i], type[j], sqrt(rsq)) 71 | 72 | d.tselect.none() 73 | d.tselect.one(time) 74 | print "timestep = ", time 75 | d.delete() 76 | -------------------------------------------------------------------------------- /doc/cfg.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Convert LAMMPS snapshots to AtomEye CFG format. 17 |
18 |Description: 19 |
20 |The cfg tool converts atom snapshots in a LAMMPS dump or data file to 21 | the CFG format used by the AtomEye visualization tool. 22 |
23 | 24 | 25 |The cfg constructor takes an object that stores atom snapshots 26 | (dump, data) as its first argument. The atom 27 | snapshots must have "id", "type", "x", "y", and "z" defined; see the 28 | map() methods of those tools. 29 |
30 |The one(), many(), and single() methods convert specific snapshots to 31 | the CFG format and write them out. Optionally, a file prefix for the 32 | CFG output files can also be specified. A ".cfg" suffix will be 33 | appended to all output files. 34 |
35 |If your atom snapshots are not sorted by atom ID (e.g. because they 36 | were written out by a parallel LAMMPS run), then you may want to sort 37 | them before converting them to CFG files with this tool. This can be 38 | done by "d = dump("tmp.dump"); d.sort()". This is because AtomEye 39 | does not use atom IDs directly but infers an ID by the order of atoms 40 | as they appear in the CFG file. 41 |
42 |Usage: 43 |
44 |c = cfg(d) d = object containing atom coords (dump, data) 45 |46 |
c.one() write all snapshots to tmp.cfg
47 | c.one("new") write all snapshots to new.cfg
48 | c.many() write snapshots to tmp0000.cfg, tmp0001.cfg, etc
49 | c.many("new") write snapshots to new0000.cfg, new0001.cfg, etc
50 | c.single(N) write snapshot for timestep N to tmp.cfg
51 | c.single(N,"file") write snapshot for timestep N to file.cfg
52 |
53 | Related tools: 54 |
55 |data, dump, ensight, 56 | vtk, xyz 57 |
58 |Prerequisites: none 59 |
60 | 61 | -------------------------------------------------------------------------------- /doc/pair.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | pair tool :h3 10 | 11 | [Purpose:] 12 | 13 | Compute LAMMPS pairwise energies. 14 | 15 | [Description:] 16 | 17 | The pair tool computes a pairwise energy between 2 particles using a 18 | LAMMPS molecular dynamics force field. Thus it can be used in an 19 | analysis script to compute energies between groups of atoms from a 20 | LAMMPS snapshot file. 21 | 22 | The pair constructor specifies the force field style. Only some of 23 | the LAMMPS pair styles are currently included in this tool, but new 24 | styles can easily be added. Code from the LAMMPS pair*.cpp file needs 25 | to be re-coded in Python to make this work. 26 | 27 | The coeff() method reads the pairwise coefficients for the force field 28 | from a data file object (see the "data"_data.html tool). The init() 29 | method does pre-computations for the force field parameters needed by 30 | the single() method which does a pairwise computation between two 31 | atoms of type = itype,jtype separated by a squared distance rsq. The 32 | arguments for init() and single() can be different for a particular 33 | force field style. When you write the init() and single() methods for 34 | a new style, you can define what arguments are needed. 35 | 36 | [Usage:] 37 | 38 | p = pair("lj/charmm/coul/charmm") create pair object for specific pair style :pre 39 | 40 | available styles: lj/cut, lj/cut/coul/cut, lj/charmm/coul/charmm :pre 41 | 42 | p.coeff(d) extract pairwise coeffs from data object 43 | p.init(cut1,cut2,...) setup based on coeffs and cutoffs :pre 44 | 45 | init args are specific to pair style: 46 | lj/cut = cutlj 47 | lj/cut/coul/cut = cutlj,cut_coul (cut_coul optional) 48 | lj/charmm/coul/charmm = cutlj_inner,cutlj,cutcoul_inner,cut_coul 49 | (last 2 optional) :pre 50 | 51 | e_vdwl,e_coul = p.single(rsq,itype,jtype,q1,q2,...) compute LJ/Coul energy :pre 52 | 53 | pairwise energy between 2 atoms at distance rsq with their attributes 54 | args are specific to pair style: 55 | lj/cut = rsq,itype,jtype 56 | lj/cut/coul/cut = rsq,itype,jtype,q1,q2 57 | lj/charmm/coul/charmm = rsq,itype,jtype,q1,q2 :pre 58 | 59 | [Related tools:] 60 | 61 | "data"_data.html 62 | 63 | [Prerequisites:] none 64 | -------------------------------------------------------------------------------- /scripts/density.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: density.py 4 | # Purpose: binned atom density by atom type 5 | # Syntax: density.py x/y/z nbin outfile files ... 6 | # x/y/z = get density distribution along this axis 7 | # nbin = # of bins in desired direction 8 | # outfile = file to write flux stats to 9 | # files = series of dump files 10 | # Example: density.py z 100 dens.out dump.* 11 | # Author: Paul Crozier (Sandia) 12 | 13 | # enable script to run from Python directly w/out Pizza.py 14 | 15 | import sys 16 | from dump import dump 17 | if not globals().has_key("argv"): argv = sys.argv 18 | 19 | # main script 20 | 21 | if len(argv) < 5: 22 | raise StandardError, "Syntax: density.py x/y/z nbin outfile files ..." 23 | 24 | direction = argv[1] 25 | nbins = int(argv[2]) 26 | outfile = argv[3] 27 | files = ' '.join(argv[4:]) 28 | 29 | # read snapshots one-at-a-time 30 | 31 | d = dump(files,0) 32 | d.map(1,"id",2,"type",3,"x",4,"y",5,"z") 33 | 34 | first = 1 35 | nsnaps = 0 36 | while 1: 37 | time = d.next() 38 | if time == -1: break 39 | 40 | if first: 41 | tmp,ntypes = d.minmax("type") 42 | ntypes = int(ntypes) 43 | bin = nbins * [0] 44 | for i in xrange(nbins): bin[i] = ntypes * [0] 45 | first = 0 46 | 47 | box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo, 48 | d.snaps[-1].xhi,d.snaps[-1].yhi,d.snaps[-1].zhi) 49 | vol = (box[3] - box[0]) * (box[4] - box[1]) * (box[5] - box[2]) 50 | 51 | if direction == "x": type,x = d.vecs(time,"type","x") 52 | elif direction == "y": type,x = d.vecs(time,"type","y") 53 | elif direction == "z": type,x = d.vecs(time,"type","z") 54 | 55 | type = map(int,type) 56 | natoms = len(type) 57 | for i in xrange(natoms): type[i] -= 1 58 | 59 | for i in xrange(natoms): 60 | ibin = int(nbins*x[i] + 0.5) 61 | if (ibin < 0): ibin += nbins 62 | if (ibin > nbins-1): ibin -= nbins 63 | bin[ibin][type[i]] += nbins/vol 64 | nsnaps += 1 65 | print time, 66 | 67 | print 68 | print "Printing ", direction, "-directional density distribution in mol/L to",outfile 69 | conversion = 1660.53873 # convert from atoms/Angs^3 to mol/L 70 | 71 | fp = open(outfile,"w") 72 | for i in xrange(nbins): 73 | print >>fp, float(i)/float(nbins), 74 | for j in xrange(ntypes): 75 | print >>fp, conversion*bin[i][j]/nsnaps, 76 | print >>fp 77 | fp.close() 78 | -------------------------------------------------------------------------------- /doc/Section_examples.html: -------------------------------------------------------------------------------- 1 | 2 |The Pizza.py distribution includes 2 sets of example scripts. A 17 | listing of included scripts is given on the Pizza.py WWW 18 | site. 19 |
20 | 21 | 22 |(A) The examples directory has a README file and a variety of scripts. 23 | For each tool in Pizza.py there is a test_tool.py script that invokes 24 | the tool on a simple data set (from the files sub-directory) and 25 | exercises various tool methods. These scripts are meant to illustrate 26 | how the tool is used. 27 |
28 |Assuming pizza.py is in your path, each of the test scripts can be run 29 | from within the examples directory by typing one of these lines (from 30 | the shell or from within Pizza.py): 31 |
32 |% pizza.py -f test_animate.py 33 | > @run test_animate.py 34 |35 |
The remaining scripts in the examples directory illustrate how to do 36 | various tasks in Pizza.py. They are not meant to be generically 37 | useful nor are they well documented. Rather they are illustrations of 38 | how to do some specific task quickly and straightforwardly. Most of 39 | these scripts are not meant to be run by other users, since their data 40 | files are not included. 41 |
42 |(B) The scripts directory contains several scripts you may find useful 43 | either to use directly or to modify to create a new script for your 44 | purposes. 45 |
46 |The top of each script file describes its purpose and syntax. That 47 | information can be be accessed from within Pizza.py by typing "??" or 48 | "? name.py" or "?? name.py". 49 |
50 |As explained in this section, any file in 51 | the scripts directory can be run from the directory where your data 52 | lives, by typing a line appropriate to the script's syntax, e.g. 53 |
54 |% pizza.py -f movie.py svg 60 135 dump.protein from the shell 55 | > @run movie.py svg 60 135 dump.protein from Pizza.py 56 |57 | 58 | -------------------------------------------------------------------------------- /examples/files/vec.txt: -------------------------------------------------------------------------------- 1 | # test file of column data 2 | Step Temperature E_pair E_bond E_total Pressure Volume 3 | 0 1.0019297 0 0 0.68645902 0.47826346 733.92473 4 | 1000 1 -0.3541344 0 0.3310025 1.471929 788.80874 5 | 2000 1 -0.40581755 0 0.27931935 1.3444013 815.07966 6 | 3000 1 -0.53487842 0 0.15025847 1.5881028 838.85908 7 | 4000 1 -0.56788721 0 0.11724969 1.5870075 867.65296 8 | 5000 1 -0.49969634 0 0.18544056 1.3461368 897.39498 9 | 6000 1 -0.46128743 0 0.22384946 1.2535238 916.0006 10 | 7000 1 -0.44495472 0 0.24018217 1.2604379 923.45772 11 | 8000 1 -0.43113095 0 0.25400595 1.3020687 922.74025 12 | 13 | # comment in middle of data 14 | 15 | 9000 1 -0.37283611 0 0.31230079 1.0383053 926.35044 16 | 10000 1 -0.41317676 0 0.27196014 1.0430468 923.77242 17 | 11000 1 -0.39163654 0 0.29350036 1.1417985 924.17464 18 | 12000 1 -0.40243311 0 0.28270378 1.1857218 926.0797 19 | 13000 1 -0.39552697 0 0.28960993 1.0909948 930.73504 20 | 14000 1 -0.38651967 0 0.29861723 1.019887 932.46408 21 | 15000 1 -0.36137982 0 0.32375708 1.0862526 934.52524 22 | 16000 1 -0.38895837 0 0.29617853 1.0782077 937.54986 23 | 17000 1 -0.36593408 0 0.31920282 1.0433347 937.86368 24 | 18000 1 -0.36862138 0 0.31651552 1.0541325 936.44677 25 | 19000 1 -0.34653171 0 0.33860519 1.0383193 936.06753 26 | 20000 1 -0.4198566 0 0.26528029 1.1931375 929.06482 27 | 21000 1 -0.37716741 0 0.30796949 1.0620287 933.67326 28 | 22000 1 -0.39545011 0 0.28968679 1.0645021 933.58553 29 | 23000 1 -0.36365319 0 0.3214837 1.049493 933.6992 30 | 24000 1 -0.35620009 0 0.3289368 1.0211735 935.87224 31 | 25000 1 -0.39356635 0 0.29157055 0.99663982 935.394 32 | 33 | end of data 34 | -------------------------------------------------------------------------------- /src/histo.py: -------------------------------------------------------------------------------- 1 | # Pizza.py toolkit, www.cs.sandia.gov/~sjplimp/pizza.html 2 | # Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories 3 | # 4 | # Copyright (2005) Sandia Corporation. Under the terms of Contract 5 | # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 6 | # certain rights in this software. This software is distributed under 7 | # the GNU General Public License. 8 | 9 | # histo tool 10 | 11 | oneline = "Particle density histogram from a dump" 12 | 13 | docstr = """ 14 | h = histo(d) d = dump/cdump object 15 | 16 | x,y = h.compute('x',N,lo,hi) compute histogram in dim with N bins 17 | 18 | lo/hi are optional, if not used histo will be over entire box 19 | """ 20 | 21 | # History 22 | # 12/05, Steve Plimpton (SNL): original version 23 | 24 | # ToDo list 25 | 26 | # Variables 27 | # data = dump object 28 | 29 | # Imports and external programs 30 | 31 | # Class definition 32 | 33 | class histo: 34 | 35 | # -------------------------------------------------------------------- 36 | 37 | def __init__(self,data): 38 | self.data = data 39 | 40 | # -------------------------------------------------------------------- 41 | 42 | def compute(self,dim,nbins,lo=None,hi=None): 43 | if dim == 'x': idim = 2 44 | elif dim == 'y': idim = 3 45 | elif dim == 'z': idim = 4 46 | else: raise StandardError,"illegal dim value" 47 | 48 | y = nbins*[0] 49 | 50 | count = 0 51 | n = flag = 0 52 | while 1: 53 | which,time,flag = self.data.iterator(flag) 54 | if flag == -1: break 55 | time,box,atoms,bonds,tris,lines = self.data.viz(which) 56 | 57 | if not lo: 58 | if dim == 'x': 59 | lo = box[0] 60 | hi = box[3] 61 | elif dim == 'y': 62 | lo = box[1] 63 | hi = box[4] 64 | elif dim == 'z': 65 | lo = box[2] 66 | hi = box[5] 67 | 68 | delta = (hi-lo) / nbins; 69 | invdelta = 1.0/delta 70 | 71 | for atom in atoms: 72 | coord = atom[idim] 73 | ibin = int((coord-lo) * invdelta) 74 | if ibin < 0 or ibin >= nbins: continue 75 | y[ibin] += 1 76 | count += 1 77 | 78 | n += 1 79 | 80 | x = nbins*[0] 81 | for i in xrange(nbins): x[i] = (i+0.5)*delta 82 | 83 | print "histogram snapshots = ",n 84 | print "histogram counts (per snap) = %d (%g)" % (count,float(count)/n) 85 | print "histogram bounds = ",lo,hi 86 | return x,y 87 | -------------------------------------------------------------------------------- /doc/log.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | log tool :h3 10 | 11 | [Purpose:] 12 | 13 | Read LAMMPS log files and extract thermodynamic data. 14 | 15 | [Description:] 16 | 17 | Read one or more LAMMPS log files and combine their thermodynamic data 18 | into long, named vectors (versus time). The vectors can be used in 19 | Python for further processing and plotting, or they can be output to a 20 | file. 21 | 22 | The log constructor reads one or more log files. If 2 arguments are 23 | specified, a single file is specified, and it can be read 24 | incrementally (e.g. as it is created) by the next() method. 25 | 26 | The nvec, nlen, and names values give the # of vectors, their length, 27 | and names. The get() method returns one of more vectors as a Python 28 | list. The write() method outputs the numeric vectors to a file. 29 | 30 | [Usage:] 31 | 32 | l = log("file1") read in one or more log files 33 | l = log("log1 log2.gz") can be gzipped 34 | l = log("file*") wildcard expands to multiple files 35 | l = log("log.lammps",0) two args = store filename, but don't read :pre 36 | 37 | incomplete and duplicate thermo entries are deleted 38 | skip applied within individual files, def = 1 (no skip) :pre 39 | 40 | time = l.next() read new thermo info from file :pre 41 | 42 | used with 2-argument constructor to allow reading thermo incrementally 43 | return time stamp of last thermo read 44 | return -1 if no new thermo since last read :pre 45 | 46 | l.skip = 2 only keep log data for every Nth run (def=1) :pre 47 | 48 | applied within single log files 49 | use as follows: 50 | l = log(file,0) 51 | l.skip = 2 52 | l.read_all() :pre 53 | 54 | nvec = l.nvec # of vectors of thermo info 55 | nlen = l.nlen length of each vectors 56 | names = l.names list of vector names 57 | t,pe,... = l.get("Time","KE",...) return one or more vectors of values 58 | l.write("file.txt") write all vectors to a file 59 | l.write("file.txt","Time","PE",...) write listed vectors to a file :pre 60 | 61 | get and write allow abbreviated (uniquely) vector names :pre 62 | 63 | [Related tools:] 64 | 65 | "olog"_olog.html, "plotview"_plotview.html, "gnu"_gnu.html, 66 | "matlab"_matlab.html 67 | 68 | [Prerequisites:] none 69 | -------------------------------------------------------------------------------- /doc/plotview.html: -------------------------------------------------------------------------------- 1 | 2 |
Purpose: 15 |
16 |Plot multiple vectors from a data set. 17 |
18 |Description: 19 |
20 |The plotview tool displays a GUI for showing a series of plots of 21 | vectors stored in another Pizza.py tool. Individual plots can be 22 | displayed or hidden or saved to a file. 23 |
24 |The plotview constructor creates the GUI and takes a data object 25 | (log, vec) and a plot object (gnu, 26 | matlab) as arguments. 27 |
28 |The vectors in the data object are converted to individual plots. The 29 | 2nd thru Nth vectors are each plotted against the 1st vector to create 30 | N-1 plots. One or more plots can be displayed simultaneously (right 31 | buttons in GUI), but only one is selected at a time (left buttons in 32 | GUI). The yes(), no(), and select() methods perform the same function 33 | as the GUI buttons. 34 |
35 |The currently selected plot can be modified (title, range, etc) 36 | by the methods of the plot object. 37 |
38 |The file() and save() methods (or corresponding GUI widgets) save the 39 | currently selected plot to a PostScript file. 40 |
41 |Usage: 42 |
43 |p = plotview(d,pl) create GUI for viewing plots 44 |45 |
d = Pizza.py object that contains vectors (log, vec) 46 | pl = Pizza.py plotting object (gnu, matlab) 47 |48 |
p.select(2) select one plot as current (1-N) 49 | p.yes(3) toggle one plot's visibility 50 | p.no(3) 51 |52 |
only one plot is selected at a time 53 | multiple plots can be visible at same time 54 | select is same as clicking on left-side radio-button 55 | yes/no is same as clicking on right-side checkbox 56 |57 |
p.x = "Time" which vector is X vector (1st vec by default)
58 | p.file("pressure") filename prefix for saving a plot
59 | p.save() save currently selected plot to file.eps
60 |
61 | Related tools: 62 |
63 | 65 |Prerequisites: 66 |
67 |Python Tkinter package. 68 |
69 | 70 | -------------------------------------------------------------------------------- /scripts/flux.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: flux.py 4 | # Purpose: flux of atoms through a user-defined plane 5 | # Syntax: flux.py x/y/z plane outfile files ... 6 | # x/y/z = measure flux in x, y, or z direction 7 | # plane = plane where flux is measured, fraction of L from 0 to 1 8 | # outfile = file to write flux stats to 9 | # files = series of dump files 10 | # Example: flux.py z 0.5 flux.out dump.* 11 | # Author: Paul Crozier (Sandia) 12 | 13 | # enable script to run from Python directly w/out Pizza.py 14 | 15 | import sys 16 | from dump import dump 17 | if not globals().has_key("argv"): argv = sys.argv 18 | 19 | # main script 20 | 21 | if len(argv) < 5: 22 | raise StandardError, "Syntax: flux.py x/y/z plane outfile files ..." 23 | 24 | direction = argv[1] 25 | scaled_plane = float(argv[2]) 26 | outfile = argv[3] 27 | files = ' '.join(argv[4:]) 28 | d = dump(files) 29 | d.unwrap() 30 | tmp,ntypes = d.minmax("type") 31 | ntypes = int(ntypes) 32 | ntypes += 1 33 | 34 | # loop over snapshots and compute net flux vs. first snapshot 35 | 36 | f = open(outfile,"w") 37 | 38 | jconfig = crossings = 0 39 | flag = 0 40 | 41 | while 1: 42 | which,time,flag = d.iterator(flag) 43 | if flag == -1: break 44 | 45 | if direction == "x": 46 | id,type,x = d.vecs(time,"id","type","x") 47 | lo = d.snaps[which].xlo 48 | hi = d.snaps[which].xhi 49 | elif direction == "y": 50 | id,type,x = d.vecs(time,"id","type","y") 51 | lo = d.snaps[which].ylo 52 | hi = d.snaps[which].yhi 53 | elif direction == "z": 54 | id,type,x = d.vecs(time,"id","type","z") 55 | lo = d.snaps[which].zlo 56 | hi = d.snaps[which].zhi 57 | 58 | prd = hi - lo 59 | plane = lo + scaled_plane*prd 60 | 61 | print time, 62 | sys.stdout.flush() 63 | 64 | natoms = len(x) 65 | if jconfig == 0: x_initial = (natoms+1) * [0] 66 | jconfig += 1 67 | 68 | typeflux = ntypes * [0] 69 | 70 | for i in xrange(natoms): 71 | id[i] = int(id[i]) 72 | type[i] = int(type[i]) 73 | if jconfig == 1: x_initial[id[i]] = x[i] 74 | if x_initial[id[i]] < plane and x[i] > plane : 75 | crossings = int((x[i] - plane)/prd) + 1 76 | typeflux[type[i]] += crossings 77 | elif x_initial[id[i]] > plane and x[i] < plane : 78 | crossings = int((plane - x[i])/prd) + 1 79 | typeflux[type[i]] -= crossings 80 | 81 | print >>f,time, 82 | for j in xrange(ntypes-1): 83 | print >>f,typeflux[j+1], 84 | print >>f 85 | print 86 | 87 | f.close() 88 | -------------------------------------------------------------------------------- /doc/pair.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Compute LAMMPS pairwise energies. 17 |
18 |Description: 19 |
20 |The pair tool computes a pairwise energy between 2 particles using a 21 | LAMMPS molecular dynamics force field. Thus it can be used in an 22 | analysis script to compute energies between groups of atoms from a 23 | LAMMPS snapshot file. 24 |
25 |The pair constructor specifies the force field style. Only some of 26 | the LAMMPS pair styles are currently included in this tool, but new 27 | styles can easily be added. Code from the LAMMPS pair*.cpp file needs 28 | to be re-coded in Python to make this work. 29 |
30 |The coeff() method reads the pairwise coefficients for the force field 31 | from a data file object (see the data tool). The init() 32 | method does pre-computations for the force field parameters needed by 33 | the single() method which does a pairwise computation between two 34 | atoms of type = itype,jtype separated by a squared distance rsq. The 35 | arguments for init() and single() can be different for a particular 36 | force field style. When you write the init() and single() methods for 37 | a new style, you can define what arguments are needed. 38 |
39 |Usage: 40 |
41 |p = pair("lj/charmm/coul/charmm") create pair object for specific pair style
42 |
43 | available styles: lj/cut, lj/cut/coul/cut, lj/charmm/coul/charmm 44 |45 |
p.coeff(d) extract pairwise coeffs from data object 46 | p.init(cut1,cut2,...) setup based on coeffs and cutoffs 47 |48 |
init args are specific to pair style: 49 | lj/cut = cutlj 50 | lj/cut/coul/cut = cutlj,cut_coul (cut_coul optional) 51 | lj/charmm/coul/charmm = cutlj_inner,cutlj,cutcoul_inner,cut_coul 52 | (last 2 optional) 53 |54 |
e_vdwl,e_coul = p.single(rsq,itype,jtype,q1,q2,...) compute LJ/Coul energy 55 |56 |
pairwise energy between 2 atoms at distance rsq with their attributes 57 | args are specific to pair style: 58 | lj/cut = rsq,itype,jtype 59 | lj/cut/coul/cut = rsq,itype,jtype,q1,q2 60 | lj/charmm/coul/charmm = rsq,itype,jtype,q1,q2 61 |62 |
Related tools: 63 |
64 |data 65 |
66 |Prerequisites: none 67 |
68 | 69 | -------------------------------------------------------------------------------- /doc/chain.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | chain tool :h3 10 | 11 | [Purpose:] 12 | 13 | Create bead-spring chains for LAMMPS input. 14 | 15 | [Description:] 16 | 17 | The chain tool creates random, overlapping bead-spring (FENE) chains 18 | and writes them out as a LAMMPS data file. They need to be simulated 19 | with a soft potential in LAMMPS to un-overlap them before they form 20 | a proper melt. 21 | 22 | The chain constructor uses the total number of monomers and the 23 | Lennard-Jones reduced density to create a simulation box of the 24 | appropriate size. Optionally, the box shape can also be specified. 25 | 26 | The build() method creates N chains, each with M monomers. It can be 27 | invoked multiple times to create sets of chains with different 28 | properties. The starting point of each chain is chosen randomly, as 29 | is the position of subsequent monomers. The seed value sets the 30 | random number generator used for coordinate generation. 31 | 32 | The mtype, btype, blen, and dmin settings affect how the chain and its 33 | monomers are created. Dmin is the minimum distance allowed between a 34 | new monomer and the monomer two before it, so it determines the 35 | stiffness of the chain. Each monomer is assigned a molecule ID as it 36 | is created, in accord with the id setting. 37 | 38 | Once N total monomers have been created, the ensemble of chains is 39 | written to a LAMMPS data file via the write() method. 40 | 41 | [Usage:] 42 | 43 | c = chain(N,rho) setup box with N monomers at reduced density rho 44 | c = chain(N,rho,1,1,2) x,y,z = aspect ratio of box (def = 1,1,1) :pre 45 | 46 | c.seed = 48379 set random # seed (def = 12345) 47 | c.mtype = 2 set type of monomers (def = 1) 48 | c.btype = 1 set type of bonds (def = 1) 49 | c.blen = 0.97 set length of bonds (def = 0.97) 50 | c.dmin = 1.02 set min dist from i-1 to i+1 site (def = 1.02) :pre 51 | 52 | c.id = "chain" set molecule ID to chain # (default) 53 | c.id = "end1" set molecule ID to count from one end of chain 54 | c.id = "end2" set molecule ID to count from either end of chain :pre 55 | 56 | c.build(100,10) create 100 chains, each of length 10 :pre 57 | 58 | can be invoked multiple times interleaved with different settings 59 | must fill box with total of N monomers :pre 60 | 61 | c.write("data.file") write out all built chains to LAMMPS data file :pre 62 | 63 | [Related tools:] 64 | 65 | "data"_data.html, "patch"_patch.html 66 | 67 | [Prerequisites:] none 68 | -------------------------------------------------------------------------------- /doc/log.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Read LAMMPS log files and extract thermodynamic data. 17 |
18 |Description: 19 |
20 |Read one or more LAMMPS log files and combine their thermodynamic data 21 | into long, named vectors (versus time). The vectors can be used in 22 | Python for further processing and plotting, or they can be output to a 23 | file. 24 |
25 |The log constructor reads one or more log files. If 2 arguments are 26 | specified, a single file is specified, and it can be read 27 | incrementally (e.g. as it is created) by the next() method. 28 |
29 |The nvec, nlen, and names values give the # of vectors, their length, 30 | and names. The get() method returns one of more vectors as a Python 31 | list. The write() method outputs the numeric vectors to a file. 32 |
33 |Usage: 34 |
35 |l = log("file1") read in one or more log files
36 | l = log("log1 log2.gz") can be gzipped
37 | l = log("file*") wildcard expands to multiple files
38 | l = log("log.lammps",0) two args = store filename, but don't read
39 |
40 | incomplete and duplicate thermo entries are deleted 41 | skip applied within individual files, def = 1 (no skip) 42 |43 |
time = l.next() read new thermo info from file 44 |45 |
used with 2-argument constructor to allow reading thermo incrementally 46 | return time stamp of last thermo read 47 | return -1 if no new thermo since last read 48 |49 |
l.skip = 2 only keep log data for every Nth run (def=1) 50 |51 |
applied within single log files 52 | use as follows: 53 | l = log(file,0) 54 | l.skip = 2 55 | l.read_all() 56 |57 |
nvec = l.nvec # of vectors of thermo info
58 | nlen = l.nlen length of each vectors
59 | names = l.names list of vector names
60 | t,pe,... = l.get("Time","KE",...) return one or more vectors of values
61 | l.write("file.txt") write all vectors to a file
62 | l.write("file.txt","Time","PE",...) write listed vectors to a file
63 |
64 | get and write allow abbreviated (uniquely) vector names 65 |66 |
Related tools: 67 |
68 |olog, plotview, gnu, 69 | matlab 70 |
71 |Prerequisites: none 72 |
73 | 74 | -------------------------------------------------------------------------------- /doc/chain.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Create bead-spring chains for LAMMPS input. 17 |
18 |Description: 19 |
20 |The chain tool creates random, overlapping bead-spring (FENE) chains 21 | and writes them out as a LAMMPS data file. They need to be simulated 22 | with a soft potential in LAMMPS to un-overlap them before they form 23 | a proper melt. 24 |
25 |The chain constructor uses the total number of monomers and the 26 | Lennard-Jones reduced density to create a simulation box of the 27 | appropriate size. Optionally, the box shape can also be specified. 28 |
29 |The build() method creates N chains, each with M monomers. It can be 30 | invoked multiple times to create sets of chains with different 31 | properties. The starting point of each chain is chosen randomly, as 32 | is the position of subsequent monomers. The seed value sets the 33 | random number generator used for coordinate generation. 34 |
35 |The mtype, btype, blen, and dmin settings affect how the chain and its 36 | monomers are created. Dmin is the minimum distance allowed between a 37 | new monomer and the monomer two before it, so it determines the 38 | stiffness of the chain. Each monomer is assigned a molecule ID as it 39 | is created, in accord with the id setting. 40 |
41 |Once N total monomers have been created, the ensemble of chains is 42 | written to a LAMMPS data file via the write() method. 43 |
44 |Usage: 45 |
46 |c = chain(N,rho) setup box with N monomers at reduced density rho 47 | c = chain(N,rho,1,1,2) x,y,z = aspect ratio of box (def = 1,1,1) 48 |49 |
c.seed = 48379 set random # seed (def = 12345) 50 | c.mtype = 2 set type of monomers (def = 1) 51 | c.btype = 1 set type of bonds (def = 1) 52 | c.blen = 0.97 set length of bonds (def = 0.97) 53 | c.dmin = 1.02 set min dist from i-1 to i+1 site (def = 1.02) 54 |55 |
c.id = "chain" set molecule ID to chain # (default) 56 | c.id = "end1" set molecule ID to count from one end of chain 57 | c.id = "end2" set molecule ID to count from either end of chain 58 |59 |
c.build(100,10) create 100 chains, each of length 10 60 |61 |
can be invoked multiple times interleaved with different settings 62 | must fill box with total of N monomers 63 |64 |
c.write("data.file") write out all built chains to LAMMPS data file
65 |
66 | Related tools: 67 |
68 | 70 |Prerequisites: none 71 |
72 | 73 | -------------------------------------------------------------------------------- /doc/rasmol.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | rasmol tool :h3 10 | 11 | [Purpose:] 12 | 13 | 3d visualization via RasMol program. 14 | 15 | [Description:] 16 | 17 | The rasmol tool is a wrapper on the "RasMol"_http://www.openrasmol.org 18 | visualization program. RasMol is open source software and runs on 19 | many platforms. The link above is for the Open Rasmol WWW site, not 20 | the Protein Explorer WWW site. Protein Explorer is a derivative of 21 | RasMol and runs primarily on Windows machines within a browser. This 22 | Pizza.py tool wraps the original RasMol program, not Protein Explorer. 23 | 24 | The rasmol constructor takes a "pdbfile"_pdbfile.html object as its 25 | argument which produces PDB files that RasMol reads in. The pdbfile 26 | object can produce PDB files from a LAMMPS dump or data file, as well 27 | as in other ways. 28 | 29 | The show() method runs RasMol on the atoms of snapshot N (converted to 30 | a PDB file) and displays the resulting image stored as image.gif. 31 | Either a default RasMol script or one you specify is used to format 32 | the RasMol image. The all() method loops thru all selected snapshots 33 | and runs RasMol on each one. The resulting image files are saved to 34 | image0000.gif, image0001.gif, etc. The prefix "image" can be changed 35 | via the file setting. 36 | 37 | A RasMol script can be created by running RasMol itself (outside of 38 | Pizza.py), typing commands or choosing menu options to format the 39 | display as desired, then typing "write script filename". 40 | Alternatively the run() method will do this for you. It runs RasMol 41 | on snapshot N and lets you interact with RasMol directly either via 42 | typing or mouse operations in the RasMol window. When you type "quit" 43 | or "exit" the script file will be saved (do not exit via the Rasmol 44 | menu). 45 | 46 | [Usage:] 47 | 48 | r = rasmol(p) create RasMol wrapper for pdb object p :pre 49 | 50 | r.file = "image" file prefix for created images (def = "image") :pre 51 | 52 | r.show(N) show snapshot at timestep N with default script 53 | r.show(N,"my.rasmol") use file as RasMol script :pre 54 | 55 | r.all() make images of all selected snapshots with def script 56 | r.all("my.rasmol") use file as RasMol script :pre 57 | 58 | r.run(N) run RasMol interactivly on snapshot N 59 | r.run(N,"new.rasmol") adjust via mouse or RasMol commands 60 | r.run(N,"new.rasmol","old.rasmol") type quit to save RasMol script file :pre 61 | 62 | if 2 args, 2nd arg is new script file, else save to "tmp.rasmol" 63 | if 3 args, 3rd arg is initial script file, else use default script :pre 64 | 65 | [Related tools:] 66 | 67 | "dump"_dump.html, "gl"_gl.html, "pdbfile"_pdbfile.html, 68 | "raster"_raster.html, "svg"_svg.html 69 | 70 | [Prerequisites:] 71 | 72 | The RasMol program. 73 | -------------------------------------------------------------------------------- /doc/ensight.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | ensight tool :h3 10 | 11 | [Purpose:] 12 | 13 | Convert LAMMPS snapshots or meshes to Ensight format. 14 | 15 | [Description:] 16 | 17 | The ensight tool converts atom snapshots in a LAMMPS dump or data file 18 | or mesh data from a mesh file to the format used by the "Ensight 19 | visualization package"_ensight. See the "dump"_dump.html or 20 | "mdump"_mdump.html tools for info about the format of these files and 21 | what data they contain. 22 | 23 | :link(ensight,http://www.ensight.com) 24 | 25 | The ensight constructor takes an object that stores atom or mesh 26 | snapshots ("dump"_dump.html, "data"_data.html) as its first argument. 27 | The atom snapshots must have "id", "type", "x", "y", and "z" defined; 28 | see the map() methods of those tools. 29 | 30 | The one(), many(), and single() methods convert specific snapshots to 31 | Ensight format and write them out. These methods take a file prefix 32 | as an optional first argument; the prefix "tmp" will be used if not 33 | specified. These methods all create a prefix.case file which is used 34 | by Ensight to define the format and list all associated files. One or 35 | more prefix*.xyz files are also produced which contain atom 36 | coordinates sorted by atom type. If additional pairs of arguments are 37 | specified, attributes from the shapshot data (atoms or elements) can 38 | be written into Ensight variable files, and used by Ensight as display 39 | attributes for the atoms or mesh elements. 40 | 41 | [Usage:] 42 | 43 | e = ensight(d) d = object with atoms or elements (dump,data,mdump) 44 | e.change = 1 set to 1 if element nodal xyz change with time (def = 0) 45 | e.maxtype = 10 max particle type, set if query to data will be bad :pre 46 | 47 | e.one() 48 | e.one("new") 49 | e.one("cns","Centro","eng","Energy") 50 | e.one("new","cns","Centro","eng","Energy") 51 | write all snapshots as an Ensight data set 52 | Ensight header file = tmp.case (no 1st arg) or new.case 53 | Ensight coord file = tmp.xyz or new.xyz 54 | additional pairs of args create auxiliary files: 55 | tmp.cns, tmp.eng or new.cns, new.eng 56 | cns,eng = column name in dump file and file name suffix 57 | Centro,Energy = Ensight name for the variable :pre 58 | 59 | e.increment() same args as one(), but process dump out-of-core :pre 60 | 61 | e.many() same args as one(), but create multiple Ensight files 62 | tmp0000.xyz, tmp0001.xyz, etc 63 | new0000.cns, new0001.cns, etc 64 | new0000.eng, new0001.eng, etc :pre 65 | 66 | e.single(N) same args as one() prepended by N, but write a single snap :pre 67 | 68 | [Related tools:] 69 | 70 | "cfg"_cfg.html, "data"_data.html, "dump"_dump.html, 71 | "mdump"_mdump.html, "vtk"_vtk.html, "xyz"_xyz.html 72 | 73 | [Prerequisites:] none 74 | -------------------------------------------------------------------------------- /scripts/density_area.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: density_area.py 4 | # Purpose: binned atom density by atom type and running area under the curve 5 | # Syntax: density.py x/y/z nbin outfile files ... 6 | # x/y/z = get density distribution along this axis 7 | # nbin = # of bins in desired direction 8 | # outfile = file to write flux stats to 9 | # files = series of dump files 10 | # Example: density_area.py z 100 dens.out dump.* 11 | # Author: Paul Crozier (Sandia). 12 | # Modified by Jeff Greathouse (Sandia) to include 13 | # calculation of area under the curve 14 | 15 | # enable script to run from Python directly w/out Pizza.py 16 | 17 | import sys 18 | from dump import dump 19 | if not globals().has_key("argv"): argv = sys.argv 20 | 21 | # main script 22 | 23 | if len(argv) < 5: 24 | raise StandardError, "Syntax: density.py x/y/z nbin outfile files ..." 25 | 26 | direction = argv[1] 27 | nbins = int(argv[2]) 28 | outfile = argv[3] 29 | files = ' '.join(argv[4:]) 30 | 31 | # read snapshots one-at-a-time 32 | 33 | d = dump(files,0) 34 | d.map(1,"id",2,"type",3,"x",4,"y",5,"z") 35 | 36 | first = 1 37 | nsnaps = 0 38 | ntypes = 0 39 | while 1: 40 | time = d.next() 41 | if time == -1: break 42 | 43 | if first: 44 | tmp,ntypes = d.minmax("type") 45 | ntypes = int(ntypes) 46 | bin = nbins * [0] 47 | for i in xrange(nbins): bin[i] = ntypes * [0] 48 | first = 0 49 | 50 | box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo, 51 | d.snaps[-1].xhi,d.snaps[-1].yhi,d.snaps[-1].zhi) 52 | vol = (box[3] - box[0]) * (box[4] - box[1]) * (box[5] - box[2]) 53 | 54 | if direction == "x": type,x = d.vecs(time,"type","x") 55 | elif direction == "y": type,x = d.vecs(time,"type","y") 56 | elif direction == "z": type,x = d.vecs(time,"type","z") 57 | 58 | type = map(int,type) 59 | natoms = len(type) 60 | for i in xrange(natoms): type[i] -= 1 61 | 62 | for i in xrange(natoms): 63 | ibin = int(nbins*x[i] + 0.5) 64 | if (ibin < 0): ibin += nbins 65 | if (ibin > nbins-1): ibin -= nbins 66 | bin[ibin][type[i]] += nbins/vol 67 | nsnaps += 1 68 | print time, 69 | 70 | print 71 | print "Printing ",direction,"-directional density distribution in mol/L to", \ 72 | outfile 73 | conversion = 1660.53873 # convert from atoms/Angs^3 to mol/L 74 | 75 | # Output as x, density_1, area_1, ... 76 | 77 | fp = open(outfile,"w") 78 | first = 1 79 | xden = nbins * [0] 80 | yden = nbins * [0] 81 | for i in xrange(nbins): yden[i] = ntypes * [0] 82 | sum = ntypes * [0] 83 | for i in xrange(nbins): 84 | xden[i] = float(i)/float(nbins) 85 | print >>fp, xden[i], 86 | if first: 87 | for j in xrange(ntypes): 88 | yden[i][j] = conversion*bin[i][j]/nsnaps 89 | print >>fp, yden[i][j], sum[j], 90 | first = 0 91 | else: 92 | for j in xrange(ntypes): 93 | yden[i][j] = conversion*bin[i][j]/nsnaps 94 | sum[j] += 0.5 * (xden[i] - xden[i-1]) * (yden[i][j] + yden[i-1][j]) 95 | print >>fp, yden[i][j], sum[j], 96 | print >>fp 97 | fp.close() 98 | -------------------------------------------------------------------------------- /examples/group_energy.py: -------------------------------------------------------------------------------- 1 | # compute pairwise energy between 2 groups of atoms 2 | 3 | # Syntax: group_energy.py data.file dump.file1 dump.file2 ... 4 | # Author: Paul Crozier (Sandia) 5 | 6 | # return distance sq between 2 atoms with PBC 7 | 8 | def distance(box,x1,y1,z1,x2,y2,z2): 9 | 10 | delx = x2 - x1 11 | dely = y2 - y1 12 | delz = z2 - z1 13 | 14 | xprd = box[3] - box[0] 15 | yprd = box[4] - box[1] 16 | zprd = box[5] - box[2] 17 | 18 | if abs(delx) > 0.5*xprd: 19 | if delx < 0.0: 20 | delx += xprd 21 | else: 22 | delx -= xprd 23 | if abs(dely) > 0.5*yprd: 24 | if dely < 0.0: 25 | dely += yprd 26 | else: 27 | dely -= yprd 28 | if abs(delz) > 0.5*zprd: 29 | if delz < 0.0: 30 | delz += zprd 31 | else: 32 | delz -= zprd 33 | 34 | distsq = delx*delx + dely*dely + delz*delz 35 | return distsq 36 | 37 | # main script 38 | 39 | if len(argv) < 3: 40 | raise StandardError,"group_energy.py data.file dump.file1 dump.file2 ..." 41 | 42 | dt = data(argv[1]) # data file 43 | q = dt.get("Atoms",4) 44 | 45 | files = ' '.join(argv[2:]) # dump files 46 | d = dump(files,0) 47 | d.map(1,"id",2,"type",3,"x",4,"y",5,"z") 48 | 49 | p = pair("lj/charmm/coul/charmm") 50 | p.coeff(dt) 51 | 52 | cut1 = 8.0 # potential cutoffs 53 | cut2 = 10.0 54 | cut3 = 8.0 55 | cut4 = 10.0 56 | p.init(cut1,cut2,cut3,cut4) 57 | 58 | maxcut = cut1 59 | if cut2 > maxcut: maxcut = cut2 60 | if cut3 > maxcut: maxcut = cut3 61 | if cut4 > maxcut: maxcut = cut4 62 | maxcut_sq = maxcut*maxcut 63 | 64 | while 1: 65 | time = d.next() 66 | if time < 0: break 67 | d.unscale(time) 68 | 69 | box = (d.snaps[0].xlo,d.snaps[0].ylo,d.snaps[0].zlo, 70 | d.snaps[0].xhi,d.snaps[0].yhi,d.snaps[0].zhi) 71 | d.aselect.all(time) 72 | d.aselect.test("$id >= 14306 and $id <= 14516",time) # 1st group 73 | id1,type1,x1,y1,z1 = d.vecs(time,"id","type","x","y","z") 74 | d.aselect.all(time) # 2nd group 75 | d.aselect.test("$id >= 1 and $id <= 7243 or $id >= 7274 and $id <= 14283", 76 | time) 77 | id2,type2,x2,y2,z2 = d.vecs(time,"id","type","x","y","z") 78 | id1 = map(int,id1) 79 | id2 = map(int,id2) 80 | type1 = map(int,type1) 81 | type2 = map(int,type2) 82 | n1 = len(type1) 83 | n2 = len(type2) 84 | for i in xrange(n1): 85 | id1[i] -= 1 86 | type1[i] -= 1 87 | for i in xrange(n2): 88 | id2[i] -= 1 89 | type2[i] -= 1 90 | 91 | e_coul_sum = 0.0 92 | e_vdwl_sum = 0.0 93 | for i in xrange(n1): 94 | typei = type1[i] 95 | qi = q[id1[i]] 96 | for j in xrange(n2): 97 | rsq = distance(box,x1[i],y1[i],z1[i],x2[j],y2[j],z2[j]) 98 | if rsq < maxcut_sq: 99 | eng_coul,eng_vdwl = p.single(rsq,typei,type2[j],qi,q[id2[j]]) 100 | e_coul_sum += eng_coul 101 | e_vdwl_sum += eng_vdwl 102 | print "eng_coul = %g at timestep %d" % (e_coul_sum,time) 103 | print "eng_vdwl = %g at timestep %d" % (e_vdwl_sum,time) 104 | 105 | d.tselect.none() 106 | d.tselect.one(time) 107 | d.delete() 108 | -------------------------------------------------------------------------------- /doc/olog.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | olog tool :h3 10 | 11 | [Purpose:] 12 | 13 | Read other log files (ChemCell, SPPARKS, SPARTA) and extract time-series data. 14 | 15 | [Description:] 16 | 17 | Read one or more log files from other programs (besides LAMMPS) and 18 | combine their species statistical data into long, named vectors 19 | (versus time). The vectors can be used in Python for further 20 | processing and plotting, or they can be output to a file. 21 | 22 | This tool will work from log files from the Sandia ChemCell, SPPARKS, 23 | and SPARTA packages. For LAMMPS log files, see the "log"_log.html 24 | tool. 25 | 26 | The only difference between the log files of those programs, so far as 27 | this tool is concerned is the line that delimits the start of the 28 | sections that contain time-series data. This can be set via the 29 | second argument in the constructor, as documented below. For ChemCell 30 | and SPARTA, the default string "Step" can be used. For SPPARKS, the 31 | string "Time" will work. Note that SPARTA can change the text in the 32 | line that starts a section of time-series data. In this case a start 33 | string specific to the log file must be used. 34 | 35 | The log constructor reads one or more log files. The names of these 36 | one or more files are listed in the 1st argument. The 2nd argument is 37 | a string with text that begins the line that delimits the start of 38 | sections that contain time-series data, as explained above. If a 3rd 39 | argument is specified, then a single file should be specified as the 40 | 1st argument, and it is assumed to contain data for multiple runs, 41 | which are averaged. 42 | 43 | The nvec, nlen, and names values give the # of vectors, their length, 44 | and names. The get() method returns one of more vectors as a Python 45 | list. The write() method outputs the numeric vectors to a file. 46 | 47 | [Usage:] 48 | 49 | o = olog("file1") read in one or more log files 50 | o = olog("log1 log2.gz") can be gzipped 51 | o = olog("file*") wildcard expands to multiple files 52 | o = olog("log.spparks","Time") 2nd arg = start string for time section 53 | o = olog("log.cell","",0) 3rd arg = average all runs :pre 54 | 55 | incomplete and duplicate thermo entries are deleted 56 | if specify 2nd arg, it delimits a time section 57 | no 2nd arg or empty string, use default = "Step" 58 | if specify any 3rd arg, average all runs, assume all start at time 0 :pre 59 | 60 | nvec = o.nvec # of vectors of thermo info 61 | nlen = o.nlen length of each vectors 62 | names = o.names list of vector names 63 | a,b,... = o.get("A","B",...) return one or more vectors of values 64 | o.write("file.txt") write all vectors to a file 65 | o.write("file.txt","A","B",...) write listed vectors to a file :pre 66 | 67 | get and write allow abbreviated (uniquely) vector names :pre 68 | 69 | [Related tools:] 70 | 71 | "plotview"_plotview.html, "gnu"_gnu.html, "log"_log.html, 72 | "matlab"_matlab.html 73 | 74 | [Prerequisites:] none 75 | -------------------------------------------------------------------------------- /doc/rasmol.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |3d visualization via RasMol program. 17 |
18 |Description: 19 |
20 |The rasmol tool is a wrapper on the RasMol 21 | visualization program. RasMol is open source software and runs on 22 | many platforms. The link above is for the Open Rasmol WWW site, not 23 | the Protein Explorer WWW site. Protein Explorer is a derivative of 24 | RasMol and runs primarily on Windows machines within a browser. This 25 | Pizza.py tool wraps the original RasMol program, not Protein Explorer. 26 |
27 |The rasmol constructor takes a pdbfile object as its 28 | argument which produces PDB files that RasMol reads in. The pdbfile 29 | object can produce PDB files from a LAMMPS dump or data file, as well 30 | as in other ways. 31 |
32 |The show() method runs RasMol on the atoms of snapshot N (converted to 33 | a PDB file) and displays the resulting image stored as image.gif. 34 | Either a default RasMol script or one you specify is used to format 35 | the RasMol image. The all() method loops thru all selected snapshots 36 | and runs RasMol on each one. The resulting image files are saved to 37 | image0000.gif, image0001.gif, etc. The prefix "image" can be changed 38 | via the file setting. 39 |
40 |A RasMol script can be created by running RasMol itself (outside of 41 | Pizza.py), typing commands or choosing menu options to format the 42 | display as desired, then typing "write script filename". 43 | Alternatively the run() method will do this for you. It runs RasMol 44 | on snapshot N and lets you interact with RasMol directly either via 45 | typing or mouse operations in the RasMol window. When you type "quit" 46 | or "exit" the script file will be saved (do not exit via the Rasmol 47 | menu). 48 |
49 |Usage: 50 |
51 |r = rasmol(p) create RasMol wrapper for pdb object p 52 |53 |
r.file = "image" file prefix for created images (def = "image") 54 |55 |
r.show(N) show snapshot at timestep N with default script 56 | r.show(N,"my.rasmol") use file as RasMol script 57 |58 |
r.all() make images of all selected snapshots with def script
59 | r.all("my.rasmol") use file as RasMol script
60 |
61 | r.run(N) run RasMol interactivly on snapshot N 62 | r.run(N,"new.rasmol") adjust via mouse or RasMol commands 63 | r.run(N,"new.rasmol","old.rasmol") type quit to save RasMol script file 64 |65 |
if 2 args, 2nd arg is new script file, else save to "tmp.rasmol" 66 | if 3 args, 3rd arg is initial script file, else use default script 67 |68 |
Related tools: 69 |
70 |dump, gl, pdbfile, 71 | raster, svg 72 |
73 |Prerequisites: 74 |
75 |The RasMol program. 76 |
77 | 78 | -------------------------------------------------------------------------------- /scripts/cluster.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: cluster.py 4 | # Purpose: histogram of cluster size of type2 atoms near type1 5 | # Syntax: cluster.py type1 type2 cutoff nbin dump.1 dump.2 ... 6 | # type1,type2 = atom types (1-N) 7 | # cutoff = only consider atom pairs within distance cutoff 8 | # nbin = # of bins for histogram 9 | # files = series of dump files 10 | # Example: cluster.py 1 5 2.0 10 dump.* 11 | # Author: Steve Plimpton (Sandia) 12 | 13 | # for all snapshots, for each type1 atom, count # of type2 atoms within cutoff 14 | # will be very slow (N^2) if are too many type1 atoms 15 | 16 | # enable script to run from Python directly w/out Pizza.py 17 | 18 | import sys 19 | from dump import dump 20 | from gnu import gnu 21 | if not globals().has_key("argv"): argv = sys.argv 22 | 23 | # main script 24 | 25 | # function to compute distance sq between 2 atoms with PBC 26 | 27 | def distance(atom1,atom2,box): 28 | x1 = atom1[2] 29 | y1 = atom1[3] 30 | z1 = atom1[4] 31 | x2 = atom2[2] 32 | y2 = atom2[3] 33 | z2 = atom2[4] 34 | 35 | delx = x2 - x1 36 | dely = y2 - y1 37 | delz = z2 - z1 38 | 39 | xprd = box[3] - box[0] 40 | yprd = box[4] - box[1] 41 | zprd = box[5] - box[2] 42 | 43 | if abs(delx) > 0.5*xprd: 44 | if delx < 0.0: 45 | delx += xprd 46 | else: 47 | delx -= xprd 48 | if abs(dely) > 0.5*yprd: 49 | if dely < 0.0: 50 | dely += yprd 51 | else: 52 | dely -= yprd 53 | if abs(delz) > 0.5*zprd: 54 | if delz < 0.0: 55 | delz += zprd 56 | else: 57 | delz -= zprd 58 | 59 | distsq = delx*delx + dely*dely + delz*delz 60 | return distsq 61 | 62 | # main script 63 | 64 | if len(argv) < 6: 65 | raise StandardError,"cluster.py type1 type2 cutoff nbin dump.1 dump.2 ..." 66 | 67 | type1 = int(argv[1]) 68 | type2 = int(argv[2]) 69 | cutoff = float(argv[3]) 70 | nbin = int(argv[4]) 71 | files = ' '.join(argv[5:]) 72 | 73 | # read in dump file(s) and select only type1 or type2 atoms 74 | 75 | d = dump(files) 76 | d.aselect.test("$type == %d or $type == %d" % (type1,type2)) 77 | 78 | # loop over snapshots 79 | # viz returns list of atoms in one snapshot 80 | 81 | cutsq = cutoff*cutoff 82 | cluster = nbin*[0] 83 | 84 | print "Clustering ..." 85 | 86 | flag = 0 87 | while 1: 88 | which,time,flag = d.iterator(flag) 89 | if flag == -1: break 90 | time,box,atoms,bonds,tris = d.viz(which) 91 | print time, 92 | sys.stdout.flush() 93 | 94 | # loop over all type1 atoms 95 | 96 | n = len(atoms) 97 | for i in xrange(n): 98 | itype = atoms[i][1] 99 | if itype != type1: continue 100 | ncount = 0 101 | 102 | # loop over all type2 atoms 103 | # increment cluster count if distance is within cutoff 104 | 105 | for j in xrange(n): 106 | jtype = atoms[j][1] 107 | if jtype != type2 or i == j: continue 108 | distsq = distance(atoms[i],atoms[j],box) 109 | if distsq < cutsq: ncount += 1 110 | 111 | # increment histogram count 112 | 113 | if ncount >= nbin: cluster[nbin-1] += 1 114 | else: cluster[ncount] += 1 115 | 116 | print 117 | print "Cluster size and count:" 118 | for i in range(nbin): print i,cluster[i] 119 | 120 | # comment out if don't want plot 121 | 122 | #g = gnu() 123 | #g.plot(range(nbin),cluster) 124 | -------------------------------------------------------------------------------- /doc/vcr.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | vcr tool :h3 10 | 11 | [Purpose:] 12 | 13 | VCR-style GUI for 3d interactive OpenGL visualization. 14 | 15 | [Description:] 16 | 17 | The vcr tool displays a GUI to do 3d interactive visualization of 18 | LAMMPS snapshots or data files. It is a wrapper on the "gl"_gl.html 19 | tool which draws the individual images in OpenGL windows 20 | 21 | The vcr constructor creates the GUI. Note that multiple OpenGL 22 | windows can be run by the same GUI so that multiple views of the same 23 | data set can be manipulated simultaneously (or views of different data 24 | sets so long as they have the same # of snapshots). 25 | 26 | The view can be controlled by the GUI widgets or by invoking the tool 27 | methods: play(), stop(), axis(), etc. The frame slider can be dragged 28 | to view a desired frame. The mouse can also be used in the OpenGL 29 | window to translage, rotate, or zoom the scene. The clipping sliders 30 | or methods can be used to narrow the view of displayed data, though 31 | their interactivity can be slow for scenes with lots of data. 32 | 33 | The reload() method is needed if you change the selection attributes 34 | of the underlying data assigned to the "gl"_gl.html tool, such as via 35 | the "dump"_dump.html tool's methods. These changes will not be 36 | visible in the OpenGL windows until the data is reloaded. 37 | 38 | The save() method will save the current OpenGL window contents 39 | to a PNG file. If multiple OpenGL windows are being used, multiple 40 | files will be created. The save-all checkbox or method will store one 41 | file per snapshot if the Play or Back buttons are used to start an 42 | animation. 43 | 44 | [Usage:] 45 | 46 | v = vcr(gl1,gl2,...) start vcr GUI with one or more gl windows 47 | v.add(gl) add a gl window to vcr GUI :pre 48 | 49 | Actions (same as GUI widgets): :pre 50 | 51 | v.first() go to first frame 52 | v.prev() go to previous frame 53 | v.back() play backwards from current frame to start 54 | v.stop() stop on current frame 55 | v.play() play from current frame to end 56 | v.next() go to next frame 57 | v.last() go to last frame :pre 58 | 59 | v.frame(31) set frame slider 60 | v.delay(0.4) set delay slider 61 | v.q(5) set quality slider :pre 62 | 63 | v.xaxis() view scene from x axis 64 | v.yaxis() view scene from y axis 65 | v.zaxis() view scene from z axis 66 | v.box() toggle bounding box 67 | v.axis() toggle display of xyz axes 68 | v.norm() recenter and resize the view 69 | v.ortho() toggle ortho/perspective button 70 | v.reload() reload all frames from gl viewer data files :pre 71 | 72 | v.clipxlo(0.2) clip scene at x lo fraction of box 73 | v.clipxhi(1.0) clip at x hi 74 | v.clipylo(0.2) clip in y 75 | v.clipyhi(1.0) 76 | v.clipzlo(0.2) clip in z 77 | v.clipzhi(1.0) :pre 78 | 79 | v.save() save current scene to file.png 80 | v.file("image") set filename 81 | v.saveall() toggle save-all checkbox :pre 82 | 83 | [Related tools:] 84 | 85 | "animate"_animate.html, "gl"_gl.html 86 | 87 | [Prerequisites:] 88 | 89 | Python Tkinter package. 90 | -------------------------------------------------------------------------------- /doc/ensight.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Convert LAMMPS snapshots or meshes to Ensight format. 17 |
18 |Description: 19 |
20 |The ensight tool converts atom snapshots in a LAMMPS dump or data file 21 | or mesh data from a mesh file to the format used by the Ensight 22 | visualization package. See the dump or 23 | mdump tools for info about the format of these files and 24 | what data they contain. 25 |
26 | 27 | 28 |The ensight constructor takes an object that stores atom or mesh 29 | snapshots (dump, data) as its first argument. 30 | The atom snapshots must have "id", "type", "x", "y", and "z" defined; 31 | see the map() methods of those tools. 32 |
33 |The one(), many(), and single() methods convert specific snapshots to 34 | Ensight format and write them out. These methods take a file prefix 35 | as an optional first argument; the prefix "tmp" will be used if not 36 | specified. These methods all create a prefix.case file which is used 37 | by Ensight to define the format and list all associated files. One or 38 | more prefix*.xyz files are also produced which contain atom 39 | coordinates sorted by atom type. If additional pairs of arguments are 40 | specified, attributes from the shapshot data (atoms or elements) can 41 | be written into Ensight variable files, and used by Ensight as display 42 | attributes for the atoms or mesh elements. 43 |
44 |Usage: 45 |
46 |e = ensight(d) d = object with atoms or elements (dump,data,mdump) 47 | e.change = 1 set to 1 if element nodal xyz change with time (def = 0) 48 | e.maxtype = 10 max particle type, set if query to data will be bad 49 |50 |
e.one()
51 | e.one("new")
52 | e.one("cns","Centro","eng","Energy")
53 | e.one("new","cns","Centro","eng","Energy")
54 | write all snapshots as an Ensight data set
55 | Ensight header file = tmp.case (no 1st arg) or new.case
56 | Ensight coord file = tmp.xyz or new.xyz
57 | additional pairs of args create auxiliary files:
58 | tmp.cns, tmp.eng or new.cns, new.eng
59 | cns,eng = column name in dump file and file name suffix
60 | Centro,Energy = Ensight name for the variable
61 |
62 | e.increment() same args as one(), but process dump out-of-core 63 |64 |
e.many() same args as one(), but create multiple Ensight files 65 | tmp0000.xyz, tmp0001.xyz, etc 66 | new0000.cns, new0001.cns, etc 67 | new0000.eng, new0001.eng, etc 68 |69 |
e.single(N) same args as one() prepended by N, but write a single snap 70 |71 |
Related tools: 72 |
73 |cfg, data, dump, 74 | mdump, vtk, xyz 75 |
76 |Prerequisites: none 77 |
78 | 79 | -------------------------------------------------------------------------------- /doc/olog.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Read other log files (ChemCell, SPPARKS, SPARTA) and extract time-series data. 17 |
18 |Description: 19 |
20 |Read one or more log files from other programs (besides LAMMPS) and 21 | combine their species statistical data into long, named vectors 22 | (versus time). The vectors can be used in Python for further 23 | processing and plotting, or they can be output to a file. 24 |
25 |This tool will work from log files from the Sandia ChemCell, SPPARKS, 26 | and SPARTA packages. For LAMMPS log files, see the log 27 | tool. 28 |
29 |The only difference between the log files of those programs, so far as 30 | this tool is concerned is the line that delimits the start of the 31 | sections that contain time-series data. This can be set via the 32 | second argument in the constructor, as documented below. For ChemCell 33 | and SPARTA, the default string "Step" can be used. For SPPARKS, the 34 | string "Time" will work. Note that SPARTA can change the text in the 35 | line that starts a section of time-series data. In this case a start 36 | string specific to the log file must be used. 37 |
38 |The log constructor reads one or more log files. The names of these 39 | one or more files are listed in the 1st argument. The 2nd argument is 40 | a string with text that begins the line that delimits the start of 41 | sections that contain time-series data, as explained above. If a 3rd 42 | argument is specified, then a single file should be specified as the 43 | 1st argument, and it is assumed to contain data for multiple runs, 44 | which are averaged. 45 |
46 |The nvec, nlen, and names values give the # of vectors, their length, 47 | and names. The get() method returns one of more vectors as a Python 48 | list. The write() method outputs the numeric vectors to a file. 49 |
50 |Usage: 51 |
52 |o = olog("file1") read in one or more log files
53 | o = olog("log1 log2.gz") can be gzipped
54 | o = olog("file*") wildcard expands to multiple files
55 | o = olog("log.spparks","Time") 2nd arg = start string for time section
56 | o = olog("log.cell","",0) 3rd arg = average all runs
57 |
58 | incomplete and duplicate thermo entries are deleted 59 | if specify 2nd arg, it delimits a time section 60 | no 2nd arg or empty string, use default = "Step" 61 | if specify any 3rd arg, average all runs, assume all start at time 0 62 |63 |
nvec = o.nvec # of vectors of thermo info
64 | nlen = o.nlen length of each vectors
65 | names = o.names list of vector names
66 | a,b,... = o.get("A","B",...) return one or more vectors of values
67 | o.write("file.txt") write all vectors to a file
68 | o.write("file.txt","A","B",...) write listed vectors to a file
69 |
70 | get and write allow abbreviated (uniquely) vector names 71 |72 |
Related tools: 73 |
74 |plotview, gnu, log, 75 | matlab 76 |
77 |Prerequisites: none 78 |
79 | 80 | -------------------------------------------------------------------------------- /scripts/bond_distribute.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: bond_distribute.py 4 | # Purpose: binned bond length distributions by bond type 5 | # Syntax: bond_distribute.py datafile nbin rmin rmax outfile files ... 6 | # datafile = lammps data file 7 | # nbin = # of bins per bond type 8 | # rmin = min expected bond length 9 | # rmax = max expected bond length 10 | # outfile = file to write stats to 11 | # files = series of dump files 12 | # Example: bond_distribute.py pore.data 1000 1.5 1.85 bonds.out pore.dump.1 13 | # Author: Paul Crozier (Sandia) 14 | 15 | # enable script to run from Python directly w/out Pizza.py 16 | 17 | import sys 18 | from dump import dump 19 | from math import sqrt 20 | if not globals().has_key("argv"): argv = sys.argv 21 | 22 | # main script 23 | 24 | if len(argv) < 7: 25 | raise StandardError, \ 26 | "Syntax: bond_distribute.py datafile nbin rmin rmax outfile files ..." 27 | 28 | dt = data(argv[1]) 29 | nbins = int(argv[2]) 30 | rmin = float(argv[3]) 31 | rmax = float(argv[4]) 32 | outfile = argv[5] 33 | files = ' '.join(argv[6:]) 34 | 35 | # get the bonds from the data file 36 | 37 | bond = dt.get("Bonds") 38 | nbonds = len(bond) 39 | btype = nbonds * [0] 40 | iatom = nbonds * [0] 41 | jatom = nbonds * [0] 42 | for i in xrange(nbonds): 43 | btype[i] = int(bond[i][1] - 1) 44 | iatom[i] = int(bond[i][2] - 1) 45 | jatom[i] = int(bond[i][3] - 1) 46 | 47 | ntypes = 0 48 | for i in xrange(nbonds): ntypes = max(bond[i][1],ntypes) 49 | ntypes = int(ntypes) 50 | ncount = ntypes * [0] 51 | bin = nbins * [0] 52 | for i in xrange(nbins): 53 | bin[i] = ntypes * [0] 54 | 55 | # read snapshots one-at-a-time 56 | 57 | d = dump(files,0) 58 | d.map(1,"id",2,"type",3,"x",4,"y",5,"z") 59 | 60 | while 1: 61 | time = d.next() 62 | if time == -1: break 63 | 64 | box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo, 65 | d.snaps[-1].xhi,d.snaps[-1].yhi,d.snaps[-1].zhi) 66 | 67 | xprd = box[3] - box[0] 68 | yprd = box[4] - box[1] 69 | zprd = box[5] - box[2] 70 | 71 | d.unscale() 72 | d.sort() 73 | x,y,z = d.vecs(time,"x","y","z") 74 | 75 | for i in xrange(nbonds): 76 | 77 | delx = x[jatom[i]] - x[iatom[i]] 78 | dely = y[jatom[i]] - y[iatom[i]] 79 | delz = z[jatom[i]] - z[iatom[i]] 80 | 81 | if abs(delx) > 0.5*xprd: 82 | if delx < 0.0: 83 | delx += xprd 84 | else: 85 | delx -= xprd 86 | if abs(dely) > 0.5*yprd: 87 | if dely < 0.0: 88 | dely += yprd 89 | else: 90 | dely -= yprd 91 | if abs(delz) > 0.5*zprd: 92 | if delz < 0.0: 93 | delz += zprd 94 | else: 95 | delz -= zprd 96 | 97 | r = sqrt(delx*delx + dely*dely + delz*delz) 98 | 99 | ibin = int(nbins*(r - rmin)/(rmax - rmin) + 0.5) 100 | if ((ibin >= 0) and (ibin <= nbins-1)): 101 | bin[ibin][btype[i]] += nbins 102 | ncount[btype[i]] += 1 103 | else: 104 | print "Warning: bond distance outside specified range" 105 | print "Bond type:", btype[i]+1 106 | print "Bond number:", i 107 | print time, 108 | 109 | print 110 | print "Printing bond distance normalized distribution to",outfile 111 | 112 | fp = open(outfile,"w") 113 | rrange = rmax - rmin 114 | for i in xrange(nbins): 115 | print >>fp, rmin + rrange*float(i)/float(nbins), 116 | for j in xrange(ntypes): 117 | if (ncount[j] > 0): 118 | print >>fp, float(bin[i][j])/float(ncount[j])/rrange, 119 | else: 120 | print >>fp, 0.0, 121 | print >>fp 122 | fp.close() 123 | -------------------------------------------------------------------------------- /doc/vcr.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |VCR-style GUI for 3d interactive OpenGL visualization. 17 |
18 |Description: 19 |
20 |The vcr tool displays a GUI to do 3d interactive visualization of 21 | LAMMPS snapshots or data files. It is a wrapper on the gl 22 | tool which draws the individual images in OpenGL windows 23 |
24 |The vcr constructor creates the GUI. Note that multiple OpenGL 25 | windows can be run by the same GUI so that multiple views of the same 26 | data set can be manipulated simultaneously (or views of different data 27 | sets so long as they have the same # of snapshots). 28 |
29 |The view can be controlled by the GUI widgets or by invoking the tool 30 | methods: play(), stop(), axis(), etc. The frame slider can be dragged 31 | to view a desired frame. The mouse can also be used in the OpenGL 32 | window to translage, rotate, or zoom the scene. The clipping sliders 33 | or methods can be used to narrow the view of displayed data, though 34 | their interactivity can be slow for scenes with lots of data. 35 |
36 |The reload() method is needed if you change the selection attributes 37 | of the underlying data assigned to the gl tool, such as via 38 | the dump tool's methods. These changes will not be 39 | visible in the OpenGL windows until the data is reloaded. 40 |
41 |The save() method will save the current OpenGL window contents 42 | to a PNG file. If multiple OpenGL windows are being used, multiple 43 | files will be created. The save-all checkbox or method will store one 44 | file per snapshot if the Play or Back buttons are used to start an 45 | animation. 46 |
47 |Usage: 48 |
49 |v = vcr(gl1,gl2,...) start vcr GUI with one or more gl windows 50 | v.add(gl) add a gl window to vcr GUI 51 |52 |
Actions (same as GUI widgets): 53 |54 |
v.first() go to first frame 55 | v.prev() go to previous frame 56 | v.back() play backwards from current frame to start 57 | v.stop() stop on current frame 58 | v.play() play from current frame to end 59 | v.next() go to next frame 60 | v.last() go to last frame 61 |62 |
v.frame(31) set frame slider 63 | v.delay(0.4) set delay slider 64 | v.q(5) set quality slider 65 |66 |
v.xaxis() view scene from x axis 67 | v.yaxis() view scene from y axis 68 | v.zaxis() view scene from z axis 69 | v.box() toggle bounding box 70 | v.axis() toggle display of xyz axes 71 | v.norm() recenter and resize the view 72 | v.ortho() toggle ortho/perspective button 73 | v.reload() reload all frames from gl viewer data files 74 |75 |
v.clipxlo(0.2) clip scene at x lo fraction of box 76 | v.clipxhi(1.0) clip at x hi 77 | v.clipylo(0.2) clip in y 78 | v.clipyhi(1.0) 79 | v.clipzlo(0.2) clip in z 80 | v.clipzhi(1.0) 81 |82 |
v.save() save current scene to file.png
83 | v.file("image") set filename
84 | v.saveall() toggle save-all checkbox
85 |
86 | Related tools: 87 |
88 | 90 |Prerequisites: 91 |
92 |Python Tkinter package. 93 |
94 | 95 | -------------------------------------------------------------------------------- /doc/bdump.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | bdump tool :h3 10 | 11 | [Purpose:] 12 | 13 | Read dump files with bond info. 14 | 15 | [Description:] 16 | 17 | The bdump tool reads one or more LAMMPS dump files, and stores their 18 | contents as a series of snapshots with 2d arrays of atom attributes. 19 | It is assumed that each entry contains info for a bond in a LAMMPS 20 | simulation as is typically written by the dump local command in 21 | LAMMPS. Other tools use bdump objects to extract bond info for 22 | visualization, like the dump tool via its extra() method. 23 | 24 | The constructor method is passed a string containing one or more dump 25 | filenames. They can be listed in any order since snapshots are sorted 26 | by timestep after they are read and duplicate snapshots (with the same 27 | time stamp) are deleted. If a 2nd argument is specified, the files 28 | are not immediately read, but snapshots can be read one-at-a-time by 29 | the next() method. 30 | 31 | The map() method assigns names to columns of attributes. The 32 | id,type,atom1,atom2 names must be assigned in order for bond info to 33 | be extracted. 34 | 35 | The viz() method is called by Pizza.py tools that visualize snapshots 36 | of atoms (e.g. gl, raster, svg tools). 37 | 38 | :line 39 | 40 | Normally, "LAMMPS"_http://lammps.sandia.gov creates the dump files 41 | read in by this tool. If you want to create them yourself, the format 42 | of LAMMPS dump local files is simple. Each snapshot is formatted as 43 | follows: 44 | 45 | ITEM: TIMESTEP 46 | 100 47 | ITEM: NUMBER OF ENTRIES 48 | 32 49 | ITEM: ENTRIES 50 | 1 1 5 10 51 | 2 1 11 45 52 | 3 2 6 8 53 | ... 54 | N -3 23 456 :pre 55 | 56 | There are N lines following "ITEM: ENTRIES" where N is the number of 57 | entries. Entries do not have to be listed in any particular order. 58 | There can be a different number of entries in each snapshot. Each 59 | line must contain the bond ID, type, and the 2 atom IDs of the atoms 60 | in the bond, as specified by the map() command. 61 | 62 | :line 63 | 64 | [Usage:] 65 | 66 | b = bdump("dump.one") read in one or more dump files 67 | b = bdump("dump.1 dump.2.gz") can be gzipped 68 | b = bdump("dump.*") wildcard expands to multiple files 69 | b = bdump("dump.*",0) two args = store filenames, but don't read :pre 70 | 71 | incomplete and duplicate snapshots are deleted 72 | no column name assignment is performed :pre 73 | 74 | time = b.next() read next snapshot from dump files :pre 75 | 76 | used with 2-argument constructor to allow reading snapshots one-at-a-time 77 | snapshot will be skipped only if another snapshot has same time stamp 78 | return time stamp of snapshot read 79 | return -1 if no snapshots left or last snapshot is incomplete 80 | no column name assignment is performed :pre 81 | 82 | b.map(1,"id",3,"x") assign names to atom columns (1-N) :pre 83 | 84 | must assign id,type,atom1,atom2 :pre 85 | 86 | time,box,atoms,bonds,tris,lines = b.viz(index) return list of viz objects :pre 87 | 88 | viz() returns line info for specified timestep index 89 | can also call as viz(time,1) and will find index of preceding snapshot 90 | time = timestep value 91 | box = NULL 92 | atoms = NULL 93 | bonds = id,type,atom1,atom2 for each line as 2d array 94 | tris = NULL 95 | lines = NULL :pre 96 | 97 | [Related tools:] 98 | 99 | "dump"_dump.html, "gl"_gl.html, "raster"_raster.html, "svg"_svg.html 100 | 101 | [Prerequisites:] 102 | 103 | Numeric or NumPy Python packages. Gunzip command (if you want to read 104 | gzipped files). 105 | -------------------------------------------------------------------------------- /src/DEFAULTS.py: -------------------------------------------------------------------------------- 1 | # Pizza.py toolkit, www.cs.sandia.gov/~sjplimp/pizza.html 2 | # Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories 3 | # 4 | # Copyright (2005) Sandia Corporation. Under the terms of Contract 5 | # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 6 | # certain rights in this software. This software is distributed under 7 | # the GNU General Public License. 8 | 9 | # -------------- 10 | # -------------- 11 | 12 | # 3 variables used by Pizza.py 13 | # to use TOOLS or SCRIPTS, edit and uncomment the line 14 | # to use EXCLUDE, add to the existing list 15 | 16 | # TOOLS = list of extra directories that contain Pizza.py tools 17 | # Pizza.py will load all *.py files as tools from TOOLS dirs, then pizza/src 18 | # this ordering means your tool can override a Pizza.py tool of the same name 19 | # SCRIPTS = list of extra directories that contain Pizza.py scripts 20 | # Pizza.py will look in working dir, SCRIPTS dirs, then pizza/scripts 21 | # this ordering means your script can override a Pizza.py script of same name 22 | # EXCLUDE = Python files to NOT load as tools when Pizza.py starts 23 | # typically done for auxiliary Python files that are not tools 24 | # any non-tool Python files from your TOOLS dirs should be added to list 25 | 26 | #PIZZA_TOOLS = ["~/mystuff/new_pizza_tools"] 27 | #PIZZA_SCRIPTS = ["~/mystuff/new_pizza_scripts"] 28 | PIZZA_EXCLUDE = ["pizza", "DEFAULTS", "vizinfo"] 29 | 30 | # -------------- 31 | # -------------- 32 | 33 | # Pathname for programs executed by various Pizza.py tools 34 | 35 | # if you don't use a tool, it's settings can be ignored 36 | # the default values are program names with no path 37 | # to use a default value, the executable must therefore be in your path 38 | # to change a default, uncomment and edit the PIZZA variable line 39 | 40 | # -------------- 41 | 42 | # ImageMagick programs to manipulate image files 43 | # DISPLAY = program to view GIF, PNG, SVG files 44 | # tools that use it: rasmol, raster, svg 45 | # CONVERT = program to convert one image format to another 46 | # MONTAGE = program to stitch 2 images together 47 | # tools that use it: image 48 | 49 | #PIZZA_DISPLAY = "/usr/bin/display" 50 | #PIZZA_CONVERT = "/usr/bin/convert" 51 | #PIZZA_MONTAGE = "/usr/bin/montage" 52 | 53 | # -------------- 54 | 55 | # GNUPLOT = the GnuPlot plotting package 56 | # GNUTERM = terminal setting used by GnuPlot 57 | # tools that use it: gnu 58 | 59 | #PIZZA_GNUPLOT = "gnuplot" 60 | #PIZZA_GNUTERM = "x11" 61 | #PIZZA_GNUTERM = "aqua" # for Macs with Aquaterm installed 62 | 63 | # -------------- 64 | 65 | # GUNZIP = program to uncompress gzipped files 66 | # tools that use it: data dump log 67 | 68 | #PIZZA_GUNZIP = "gunzip" 69 | 70 | # -------------- 71 | 72 | # LABEL3D = program to put a label on a Raster3D image 73 | # RENDER = the Raster3D visualization rendering engine 74 | # tools that use it: raster 75 | 76 | #PIZZA_LABEL3D = "label3d" 77 | #PIZZA_RENDER = "render" 78 | 79 | # -------------- 80 | 81 | # MATLAB = the MatLab numerical analysis and plotting package 82 | # tools that use it: matlab 83 | 84 | #PIZZA_MATLAB = "matlab -nosplash -nodesktop -nojvm" 85 | 86 | # -------------- 87 | 88 | # RASMOL = the RasMol visualization package 89 | # tools that use it: rasmol 90 | 91 | #PIZZA_RASMOL = "rasmol" 92 | 93 | # -------------- 94 | 95 | # VMD = the VMD visualization package 96 | # tools that use it: vmd 97 | 98 | #PIZZA_VMDNAME = "vmd" # good settings for a Linux box 99 | #PIZZA_VMDDIR = "/usr/local/lib/vmd" 100 | #PIZZA_VMDDEV = "win" 101 | #PIZZA_VMDARCH = "LINUX" 102 | 103 | #PIZZA_VMDNAME = "vmd" # good settings for a Mac 104 | #PIZZA_VMDDIR = "/Applications/VMD\ 1.8.7.app/Contents/vmd" 105 | #PIZZA_VMDDEV = "win" 106 | #PIZZA_VMDARCH = "MACOSXX86" 107 | -------------------------------------------------------------------------------- /src/xyz.py: -------------------------------------------------------------------------------- 1 | # Pizza.py toolkit, www.cs.sandia.gov/~sjplimp/pizza.html 2 | # Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories 3 | # 4 | # Copyright (2005) Sandia Corporation. Under the terms of Contract 5 | # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 6 | # certain rights in this software. This software is distributed under 7 | # the GNU General Public License. 8 | 9 | # xyz tool 10 | 11 | oneline = "Convert LAMMPS snapshots to XYZ format" 12 | 13 | docstr = """ 14 | x = xyz(d) d = object containing atom coords (dump, data) 15 | 16 | x.one() write all snapshots to tmp.xyz 17 | x.one("new") write all snapshots to new.xyz 18 | x.many() write snapshots to tmp0000.xyz, tmp0001.xyz, etc 19 | x.many("new") write snapshots to new0000.xyz, new0001.xyz, etc 20 | x.single(N) write snapshot for timestep N to tmp.xyz 21 | x.single(N,"file") write snapshot for timestep N to file.xyz 22 | """ 23 | 24 | # History 25 | # 8/05, Steve Plimpton (SNL): original version 26 | 27 | # ToDo list 28 | 29 | # Variables 30 | # data = data file to read from 31 | 32 | # Imports and external programs 33 | 34 | import sys 35 | 36 | # Class definition 37 | 38 | class xyz: 39 | 40 | # -------------------------------------------------------------------- 41 | 42 | def __init__(self,data): 43 | self.data = data 44 | 45 | # -------------------------------------------------------------------- 46 | 47 | def one(self,*args): 48 | if len(args) == 0: file = "tmp.xyz" 49 | elif args[0][-4:] == ".xyz": file = args[0] 50 | else: file = args[0] + ".xyz" 51 | 52 | f = open(file,"w") 53 | n = flag = 0 54 | while 1: 55 | which,time,flag = self.data.iterator(flag) 56 | if flag == -1: break 57 | time,box,atoms,bonds,tris,lines = self.data.viz(which) 58 | 59 | print >>f,len(atoms) 60 | print >>f,"Atoms" 61 | for atom in atoms: 62 | itype = int(atom[1]) 63 | print >>f,itype,atom[2],atom[3],atom[4] 64 | 65 | print time, 66 | sys.stdout.flush() 67 | n += 1 68 | 69 | f.close() 70 | print "\nwrote %d snapshots to %s in XYZ format" % (n,file) 71 | 72 | # -------------------------------------------------------------------- 73 | 74 | def many(self,*args): 75 | if len(args) == 0: root = "tmp" 76 | else: root = args[0] 77 | 78 | n = flag = 0 79 | while 1: 80 | which,time,flag = self.data.iterator(flag) 81 | if flag == -1: break 82 | time,box,atoms,bonds,tris,lines = self.data.viz(which) 83 | 84 | if n < 10: 85 | file = root + "000" + str(n) 86 | elif n < 100: 87 | file = root + "00" + str(n) 88 | elif n < 1000: 89 | file = root + "0" + str(n) 90 | else: 91 | file = root + str(n) 92 | file += ".xyz" 93 | f = open(file,"w") 94 | print >>f,len(atoms) 95 | print >>f,"Atoms" 96 | for atom in atoms: 97 | itype = int(atom[1]) 98 | print >>f,itype,atom[2],atom[3],atom[4] 99 | print time, 100 | sys.stdout.flush() 101 | f.close() 102 | n += 1 103 | 104 | print "\nwrote %s snapshots in XYZ format" % n 105 | 106 | # -------------------------------------------------------------------- 107 | 108 | def single(self,time,*args): 109 | if len(args) == 0: file = "tmp.xyz" 110 | elif args[0][-4:] == ".xyz": file = args[0] 111 | else: file = args[0] + ".xyz" 112 | 113 | which = self.data.findtime(time) 114 | time,box,atoms,bonds,tris,lines = self.data.viz(which) 115 | f = open(file,"w") 116 | print >>f,len(atoms) 117 | print >>f,"Atoms" 118 | for atom in atoms: 119 | itype = int(atom[1]) 120 | print >>f,itype,atom[2],atom[3],atom[4] 121 | f.close() 122 | -------------------------------------------------------------------------------- /doc/image.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | image tool :h3 10 | 11 | [Purpose:] 12 | 13 | View and manipulate images. 14 | 15 | [Description:] 16 | 17 | The image tool can be used to display image files or convert them to 18 | other formats via the ImageMagick tools (or alternate tools if 19 | specified in the DEFAULTS.py file). 20 | 21 | The image constructor creates a GUI to view a set of image files as a 22 | palette of thumbnail-size images. Each thumbnail can be clicked on to 23 | view the full-size image. Clicking on the full-size image removes it. 24 | The view() method does the same operation for a new set of files. 25 | 26 | The convert() method invokes the ImageMagick "convert" command to 27 | convert an image file to a different format. If both arguments have a 28 | wildcard character, one conversion is done for each file in the 1st 29 | argument to create a file in the 2nd argument, e.g. "convert 30 | image0012.svg new0012.png". If either argument has no wildcard, one 31 | "convert" command is issued using both arguments. This form can be 32 | used to create a movie file, e.g. "convert *.png ligand.mpg". 33 | 34 | The montage() method invokes the ImageMagick "montage" command to 35 | combine 2 image files to create a 3rd. If all 3 arguments have a 36 | wildcard character, one montage is created for each file in the 1st 37 | argument, paired with one file in the 2nd argument, e.g. "montage 38 | image0012.svg plot0012.eps combine0012.png". For this to work, the 39 | 1st arguments must each expand to the same number of files. If any of 40 | the 3 arguments does not have a wildcard, one "montage" command is 41 | issued using all 3 arguements. 42 | 43 | Image files can be in any format (PNG, GIF, JPG, etc) recognized by 44 | the Python Image Library (PIL) installed in your Python or by 45 | ImageMagick. Various Pizza.py visualization tools (raster, deja, 46 | rasmol, etc) create such image files. If a particular image format 47 | fails to load, your PIL installation was linked without support for 48 | that format. Rebuild PIL, and follow the install instructions 49 | included in its top directory. 50 | 51 | [Usage:] 52 | 53 | i = image("my1.gif my2.gif") display thumbnails of matching images 54 | i = image("*.png *.gif") wildcards allowed 55 | i = image("*.png *.gif",0) 2nd arg = sort filenames, 0 = no sort, def = 1 56 | i = image("") blank string matches all image suffixes 57 | i = image() no display window opened if no arg :pre 58 | 59 | image suffixes for blank string = *.png, *.bmp, *.gif, *.tiff, *.tif 60 | click on a thumbnail to view it full-size 61 | click on thumbnail again to remove full-sized version :pre 62 | 63 | i.view("*.png *.gif") display thumbnails of matching images :pre 64 | 65 | view arg is same as constructor arg :pre 66 | 67 | i.convert("image*.svg","new*.png") each SVG file to PNG 68 | i.convert("image*.svg","new*.jpg","-quality 50") 3rd arg is switch 69 | i.convert("image*.png","movie.mpg") all PNGs to MPG movie 70 | i.convert("image*.png","movie.mpg","-resize 128x128") 3rd arg is switch 71 | i.montage("","image*.png","plot*.png","two*.png") image + plot = two 72 | i.montage("-geometry 512x512","i*.png","new.png") 1st arg is switch :pre 73 | 74 | convert with 2 wildcard args loops over 1st set of files to make 2nd set 75 | convert with not all wildcard args will issue single convert command 76 | montage with all wildcard args loops over 1st set of files, 77 | combines with one file from other sets, to make last set of files 78 | montage with not all wildcard args will issue single montage command :pre 79 | 80 | [Related tools:] 81 | 82 | "raster"_raster.html, "rasmol"_rasmol.html, "animate"_animate.html 83 | 84 | [Prerequisites:] 85 | 86 | Python Tkinter, Pmw, and PIL packages. ImageMagick convert and 87 | montage commands or equivalent. 88 | -------------------------------------------------------------------------------- /doc/bdump.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Read dump files with bond info. 17 |
18 |Description: 19 |
20 |The bdump tool reads one or more LAMMPS dump files, and stores their 21 | contents as a series of snapshots with 2d arrays of atom attributes. 22 | It is assumed that each entry contains info for a bond in a LAMMPS 23 | simulation as is typically written by the dump local command in 24 | LAMMPS. Other tools use bdump objects to extract bond info for 25 | visualization, like the dump tool via its extra() method. 26 |
27 |The constructor method is passed a string containing one or more dump 28 | filenames. They can be listed in any order since snapshots are sorted 29 | by timestep after they are read and duplicate snapshots (with the same 30 | time stamp) are deleted. If a 2nd argument is specified, the files 31 | are not immediately read, but snapshots can be read one-at-a-time by 32 | the next() method. 33 |
34 |The map() method assigns names to columns of attributes. The 35 | id,type,atom1,atom2 names must be assigned in order for bond info to 36 | be extracted. 37 |
38 |The viz() method is called by Pizza.py tools that visualize snapshots 39 | of atoms (e.g. gl, raster, svg tools). 40 |
41 |Normally, LAMMPS creates the dump files 44 | read in by this tool. If you want to create them yourself, the format 45 | of LAMMPS dump local files is simple. Each snapshot is formatted as 46 | follows: 47 |
48 |ITEM: TIMESTEP 49 | 100 50 | ITEM: NUMBER OF ENTRIES 51 | 32 52 | ITEM: ENTRIES 53 | 1 1 5 10 54 | 2 1 11 45 55 | 3 2 6 8 56 | ... 57 | N -3 23 456 58 |59 |
There are N lines following "ITEM: ENTRIES" where N is the number of 60 | entries. Entries do not have to be listed in any particular order. 61 | There can be a different number of entries in each snapshot. Each 62 | line must contain the bond ID, type, and the 2 atom IDs of the atoms 63 | in the bond, as specified by the map() command. 64 |
65 |Usage: 68 |
69 |b = bdump("dump.one") read in one or more dump files
70 | b = bdump("dump.1 dump.2.gz") can be gzipped
71 | b = bdump("dump.*") wildcard expands to multiple files
72 | b = bdump("dump.*",0) two args = store filenames, but don't read
73 |
74 | incomplete and duplicate snapshots are deleted 75 | no column name assignment is performed 76 |77 |
time = b.next() read next snapshot from dump files 78 |79 |
used with 2-argument constructor to allow reading snapshots one-at-a-time 80 | snapshot will be skipped only if another snapshot has same time stamp 81 | return time stamp of snapshot read 82 | return -1 if no snapshots left or last snapshot is incomplete 83 | no column name assignment is performed 84 |85 |
b.map(1,"id",3,"x") assign names to atom columns (1-N) 86 |87 |
must assign id,type,atom1,atom2 88 |89 |
time,box,atoms,bonds,tris,lines = b.viz(index) return list of viz objects 90 |91 |
viz() returns line info for specified timestep index 92 | can also call as viz(time,1) and will find index of preceding snapshot 93 | time = timestep value 94 | box = NULL 95 | atoms = NULL 96 | bonds = id,type,atom1,atom2 for each line as 2d array 97 | tris = NULL 98 | lines = NULL 99 |100 |
Related tools: 101 |
102 | 104 |Prerequisites: 105 |
106 |Numeric or NumPy Python packages. Gunzip command (if you want to read 107 | gzipped files). 108 |
109 | 110 | -------------------------------------------------------------------------------- /doc/data.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | data tool :h3 10 | 11 | [Purpose:] 12 | 13 | Read, write, manipulate LAMMPS data files. 14 | 15 | [Description:] 16 | 17 | The data tool reads and writes LAMMPS data files. It also allows 18 | their content to be accessed or modified. 19 | 20 | The data constructor reads in the specified LAMMPS data file. With no 21 | argument, an empty data object is created which can have fields added 22 | to it later, and then be written out. 23 | 24 | The map() method assigns names to different atom attributes by their 25 | column number (1-N). The get() method extracts columns of information 26 | from the specified section of the data file. 27 | 28 | The title, headers, and sections variables can be set directly. The 29 | header values correspond to one-line definition that appear at the top 30 | of the data file. The box size values should be set to a Python 31 | tuple, e.g. 32 | 33 | d.headers\["xlo xhi"\] = (-30, 30) :pre 34 | 35 | The section value should be a list of text lines, each of which 36 | includes a newline at the end. 37 | 38 | The delete() method deletes a header or entire section of the data 39 | file. The replace() method allows one column of a section to be 40 | replaced with a vector of new values. The newxyz() methods replaces 41 | the xyz coords of the "Atoms" section of the data file with xyz values 42 | from the Nth snapshot of a dump object containing snapshots. 43 | 44 | The iterator() and viz() methods are called by Pizza.py tools that 45 | visualize snapshots of atoms (e.g. raster, svg tools). A data file 46 | can be visualzed similarly to snapshots from a dump file. In the case 47 | of a data file, there is only a single snapshot with index 0. 48 | 49 | The write() method outputs a LAMMPS data file. 50 | 51 | [Usage:] 52 | 53 | d = data("data.poly") read a LAMMPS data file, can be gzipped 54 | d = data() create an empty data file :pre 55 | 56 | d.map(1,"id",3,"x") assign names to atom columns (1-N) :pre 57 | 58 | coeffs = d.get("Pair Coeffs") extract info from data file section 59 | q = d.get("Atoms",4) :pre 60 | 61 | 1 arg = all columns returned as 2d array of floats 62 | 2 args = Nth column returned as vector of floats :pre 63 | 64 | d.reorder("Atoms",1,3,2,4,5) reorder columns (1-N) in a data file section :pre 65 | 66 | 1,3,2,4,5 = new order of previous columns, can delete columns this way :pre 67 | 68 | d.title = "My LAMMPS data file" set title of the data file 69 | d.headers\["atoms"\] = 1500 set a header value 70 | d.sections\["Bonds"\] = lines set a section to list of lines (with newlines) 71 | d.delete("bonds") delete a keyword or section of data file 72 | d.delete("Bonds") 73 | d.replace("Atoms",5,vec) replace Nth column of section with vector 74 | d.newxyz(dmp,1000) replace xyz in Atoms with xyz of snapshot N :pre 75 | 76 | newxyz assumes id,x,y,z are defined in both data and dump files 77 | also replaces ix,iy,iz if they are defined :pre 78 | 79 | index,time,flag = d.iterator(0/1) loop over single data file snapshot 80 | time,box,atoms,bonds,tris,lines = d.viz(index) return list of viz objects :pre 81 | 82 | iterator() and viz() are compatible with equivalent dump calls 83 | iterator() called with arg = 0 first time, with arg = 1 on subsequent calls 84 | index = timestep index within dump object (only 0 for data file) 85 | time = timestep value (only 0 for data file) 86 | flag = -1 when iteration is done, 1 otherwise 87 | viz() returns info for specified timestep index (must be 0) 88 | time = 0 89 | box = \[xlo,ylo,zlo,xhi,yhi,zhi\] 90 | atoms = id,type,x,y,z for each atom as 2d array 91 | bonds = id,type,x1,y1,z1,x2,y2,z2,t1,t2 for each bond as 2d array 92 | NULL if bonds do not exist 93 | tris = NULL 94 | lines = NULL :pre 95 | 96 | d.write("data.new") write a LAMMPS data file :pre 97 | 98 | [Related tools:] 99 | 100 | "gl"_gl.html, "raster"_raster.html, "svg"_svg.html 101 | 102 | [Prerequisites:] none 103 | -------------------------------------------------------------------------------- /doc/image.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |View and manipulate images. 17 |
18 |Description: 19 |
20 |The image tool can be used to display image files or convert them to 21 | other formats via the ImageMagick tools (or alternate tools if 22 | specified in the DEFAULTS.py file). 23 |
24 |The image constructor creates a GUI to view a set of image files as a 25 | palette of thumbnail-size images. Each thumbnail can be clicked on to 26 | view the full-size image. Clicking on the full-size image removes it. 27 | The view() method does the same operation for a new set of files. 28 |
29 |The convert() method invokes the ImageMagick "convert" command to 30 | convert an image file to a different format. If both arguments have a 31 | wildcard character, one conversion is done for each file in the 1st 32 | argument to create a file in the 2nd argument, e.g. "convert 33 | image0012.svg new0012.png". If either argument has no wildcard, one 34 | "convert" command is issued using both arguments. This form can be 35 | used to create a movie file, e.g. "convert *.png ligand.mpg". 36 |
37 |The montage() method invokes the ImageMagick "montage" command to 38 | combine 2 image files to create a 3rd. If all 3 arguments have a 39 | wildcard character, one montage is created for each file in the 1st 40 | argument, paired with one file in the 2nd argument, e.g. "montage 41 | image0012.svg plot0012.eps combine0012.png". For this to work, the 42 | 1st arguments must each expand to the same number of files. If any of 43 | the 3 arguments does not have a wildcard, one "montage" command is 44 | issued using all 3 arguements. 45 |
46 |Image files can be in any format (PNG, GIF, JPG, etc) recognized by 47 | the Python Image Library (PIL) installed in your Python or by 48 | ImageMagick. Various Pizza.py visualization tools (raster, deja, 49 | rasmol, etc) create such image files. If a particular image format 50 | fails to load, your PIL installation was linked without support for 51 | that format. Rebuild PIL, and follow the install instructions 52 | included in its top directory. 53 |
54 |Usage: 55 |
56 |i = image("my1.gif my2.gif") display thumbnails of matching images
57 | i = image("*.png *.gif") wildcards allowed
58 | i = image("*.png *.gif",0) 2nd arg = sort filenames, 0 = no sort, def = 1
59 | i = image("") blank string matches all image suffixes
60 | i = image() no display window opened if no arg
61 |
62 | image suffixes for blank string = *.png, *.bmp, *.gif, *.tiff, *.tif 63 | click on a thumbnail to view it full-size 64 | click on thumbnail again to remove full-sized version 65 |66 |
i.view("*.png *.gif") display thumbnails of matching images
67 |
68 | view arg is same as constructor arg 69 |70 |
i.convert("image*.svg","new*.png") each SVG file to PNG
71 | i.convert("image*.svg","new*.jpg","-quality 50") 3rd arg is switch
72 | i.convert("image*.png","movie.mpg") all PNGs to MPG movie
73 | i.convert("image*.png","movie.mpg","-resize 128x128") 3rd arg is switch
74 | i.montage("","image*.png","plot*.png","two*.png") image + plot = two
75 | i.montage("-geometry 512x512","i*.png","new.png") 1st arg is switch
76 |
77 | convert with 2 wildcard args loops over 1st set of files to make 2nd set 78 | convert with not all wildcard args will issue single convert command 79 | montage with all wildcard args loops over 1st set of files, 80 | combines with one file from other sets, to make last set of files 81 | montage with not all wildcard args will issue single montage command 82 |83 |
Related tools: 84 |
85 | 87 |Prerequisites: 88 |
89 |Python Tkinter, Pmw, and PIL packages. ImageMagick convert and 90 | montage commands or equivalent. 91 |
92 | 93 | -------------------------------------------------------------------------------- /doc/pdbfile.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | pdbfile tool :h3 10 | 11 | [Purpose:] 12 | 13 | Read, write PDB files in combo with LAMMPS snapshots. 14 | 15 | [Description:] 16 | 17 | The pdbfile tool reads in PDB (Protein Data Bank) files of protein 18 | coordinates and uses them in conjunction with LAMMPS snapshots in 19 | various ways. The PDB format is commonly used by various 20 | vizualization and analysis programs. 21 | 22 | The pdbfile constructor takes a string argument listing one or more 23 | PDB filenames and a data argument with LAMMPS atom information 24 | ("data"_data.html or "dump"_dump.html object). The atom snapshots 25 | must have "id", "type", "x", "y", and "z" defined; see the map() 26 | methods of those tools. 27 | 28 | Both arguments to the constructor are optional, as described below. 29 | If a single PDB file is given as a constructor argument, and it is 4 30 | letters long, and it does not exist on your system, then it is treated 31 | as a PDB identifier and the matching PDB file is downloaded from a PDB 32 | repository on the WWW to your machine. 33 | 34 | The one(), many(), and single() methods write out PDB files in various 35 | manners, depending on the 1 or 2 arguments used in the constructor. 36 | If only a string was specified (no data object), the specified PDB 37 | files are written out as-is. Thus the one() method concatenates the 38 | files together. If only a data object was specified (no string of PDB 39 | files), then PDB files in a generic format (Lennard-Jones atoms) are 40 | created. If both arguments are specified, then only a single PDB file 41 | can be listed. It is treated as a template file, and the atom 42 | coordinates in the data object replace the atom coordinates in the 43 | template PDB file to create a series of new PDB files. This 44 | replacement is only done for selected atoms (in the dump object) and 45 | for atom IDs that appear in the PDB file. 46 | 47 | The iterator() method is called by the "rasmol"_rasmol.html tool to 48 | create a series of PDB files for visualization purposes. 49 | 50 | [Usage:] 51 | 52 | p = pdbfile("3CRO") create pdb object from PDB file or WWW 53 | p = pdbfile("pep1 pep2") read in multiple PDB files 54 | p = pdbfile("pep*") can use wildcards 55 | p = pdbfile(d) read in snapshot data with no PDB file 56 | p = pdbfile("3CRO",d) read in single PDB file with snapshot data :pre 57 | 58 | string arg contains one or more PDB files 59 | don't need .pdb suffix except wildcard must expand to file.pdb 60 | if only one 4-char file specified and it is not found, 61 | it will be downloaded from http://www.rcsb.org as 3CRO.pdb 62 | d arg is object with atom coordinates (dump, data) :pre 63 | 64 | p.one() write all output as one big PDB file to tmp.pdb 65 | p.one("mine") write to mine.pdb 66 | p.many() write one PDB file per snapshot: tmp0000.pdb, ... 67 | p.many("mine") write as mine0000.pdb, mine0001.pdb, ... 68 | p.single(N) write timestamp N as tmp.pdb 69 | p.single(N,"new") write as new.pdb :pre 70 | 71 | how new PDB files are created depends on constructor inputs: 72 | if no d: one new PDB file for each file in string arg (just a copy) 73 | if only d specified: one new PDB file per snapshot in generic format 74 | if one file in str arg and d: one new PDB file per snapshot 75 | using input PDB file as template 76 | multiple input PDB files with a d is not allowed :pre 77 | 78 | index,time,flag = p.iterator(0) 79 | index,time,flag = p.iterator(1) :pre 80 | 81 | iterator = loop over number of PDB files 82 | call first time with arg = 0, thereafter with arg = 1 83 | N = length = # of snapshots or # of input PDB files 84 | index = index of snapshot or input PDB file (0 to N-1) 85 | time = timestep value (time stamp for snapshot, index for multiple PDB) 86 | flag = -1 when iteration is done, 1 otherwise 87 | typically call p.single(time) in iterated loop to write out one PDB file :pre 88 | 89 | [Related tools:] 90 | 91 | "data"_data.html, "dump"_dump.html, "rasmol"_rasmol.html 92 | 93 | [Prerequisites:] none 94 | -------------------------------------------------------------------------------- /doc/ldump.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | ldump tool :h3 10 | 11 | [Purpose:] 12 | 13 | Read dump files with line segment info. 14 | 15 | [Description:] 16 | 17 | The ldump tool reads one or more LAMMPS dump files, and stores their 18 | contents as a series of snapshots with 2d arrays of atom attributes. 19 | It is assumed that each atom contains line segment info from a 2d 20 | LAMMPS simulation using atom_style line. Other tools use ldump 21 | objects to extract line segment info for visualization, like the dump 22 | tool via its extra() method. 23 | 24 | The constructor method is passed a string containing one or more dump 25 | filenames. They can be listed in any order since snapshots are sorted 26 | by timestep after they are read and duplicate snapshots (with the same 27 | time stamp) are deleted. If a 2nd argument is specified, the files 28 | are not immediately read, but snapshots can be read one-at-a-time by 29 | the next() method. 30 | 31 | The map() method assigns names to columns of atom attributes. 32 | The id,type,end1x,end1y,end2x,end2y names must be assigned 33 | in order for line segment info to be extracted. 34 | 35 | The viz() method is called by Pizza.py tools that visualize snapshots 36 | of atoms (e.g. gl, raster, svg tools). 37 | 38 | :line 39 | 40 | Normally, "LAMMPS"_http://lammps.sandia.gov creates the dump files 41 | read in by this tool. If you want to create them yourself, the format 42 | of LAMMPS dump files is simple. Each snapshot is formatted as 43 | follows: 44 | 45 | ITEM: TIMESTEP 46 | 100 47 | ITEM: NUMBER OF ATOMS 48 | 32 49 | ITEM: BOX BOUNDS 50 | 0 3.35919 51 | 0 3.35919 52 | 0 7.50 53 | ITEM: ATOMS 54 | 1 1 0 0 0 55 | 2 1 0.25 0.25 0 56 | 3 1 0.25 0 0.25 57 | ... 58 | N 3 0.7 0.5 0.6 :pre 59 | 60 | The box bounds are listed as xlo xhi on the 1st line, ylo yhi on the 61 | next line, zlo zhi on the last. There are N lines following "ITEM: 62 | ATOMS" where N is the number of atoms. Atoms do not have to be listed 63 | in any particular order. There can be a different number of atoms in 64 | each snapshot. Each line must contain the atom ID, type, and the end 65 | points of the associated line segment, as specified by the map() 66 | command. 67 | 68 | :line 69 | 70 | [Usage:] 71 | 72 | l = ldump("dump.one") read in one or more dump files 73 | l = ldump("dump.1 dump.2.gz") can be gzipped 74 | l = ldump("dump.*") wildcard expands to multiple files 75 | l = ldump("dump.*",0) two args = store filenames, but don't read :pre 76 | 77 | incomplete and duplicate snapshots are deleted 78 | no column name assignment is performed :pre 79 | 80 | time = l.next() read next snapshot from dump files :pre 81 | 82 | used with 2-argument constructor to allow reading snapshots one-at-a-time 83 | snapshot will be skipped only if another snapshot has same time stamp 84 | return time stamp of snapshot read 85 | return -1 if no snapshots left or last snapshot is incomplete 86 | no column name assignment is performed :pre 87 | 88 | l.map(1,"id",3,"x") assign names to atom columns (1-N) :pre 89 | 90 | must assign id,type,end1x,end1y,end2x,end2y :pre 91 | 92 | time,box,atoms,bonds,tris,lines = l.viz(index) return list of viz objects :pre 93 | 94 | viz() returns line info for specified timestep index 95 | can also call as viz(time,1) and will find index of preceding snapshot 96 | time = timestep value 97 | box = \\[xlo,ylo,zlo,xhi,yhi,zhi\\] 98 | atoms = NULL 99 | bonds = NULL 100 | tris = NULL 101 | lines = id,type,x1,y1,z1,x2,y2,z2 for each line as 2d array 102 | id,type are from associated atom :pre 103 | 104 | l.owrap(...) wrap lines to same image as their atoms :pre 105 | 106 | owrap() is called by dump tool's owrap() 107 | useful for wrapping all molecule's atoms/lines the same so it is contiguous :pre 108 | 109 | [Related tools:] 110 | 111 | "dump"_dump.html, "gl"_gl.html, "raster"_raster.html, "svg"_svg.html 112 | 113 | [Prerequisites:] 114 | 115 | Numeric or NumPy Python packages. Gunzip command (if you want to read 116 | gzipped files). 117 | -------------------------------------------------------------------------------- /doc/Section_extend.txt: -------------------------------------------------------------------------------- 1 | "Previous Section"_Section_tools.html - "Pizza.py WWW Site"_pws - 2 | "Pizza.py Documentation"_pd - "Pizza.py Tools"_pt :c 3 | 4 | :link(pws,http://pizza.sandia.gov) 5 | :link(pd,Manual.html) 6 | :link(pt,Section_tools.html) 7 | 8 | :line 9 | 10 | 6. Extending Pizza.py :h3 11 | 12 | Pizza.py can easily be extended in several ways: 13 | 14 | fix a bug 15 | make a tool method faster or cleaner 16 | add a new method or setting to a tool 17 | add a new tool 18 | add a generically useful script to the scripts dir 19 | add a script that does something interesting to the examples dir 20 | send a picture or movie you made with Pizza.py for the "WWW page"_pws. :ol 21 | 22 | You might be able to do (2) because you're better with Python than we 23 | are! Note that generally, we've opted for simplicity versus speed in 24 | writing the tools, unless the operation is very costly. An example of 25 | something I'd like to speed up is the reading of large dump files in 26 | dump.py. 27 | 28 | Some of the ideas we've had for (3), but haven't gotten around to, are 29 | listed at the top of the src/*.py files as ToDo items. 30 | 31 | If you think your addition will be useful to other Pizza.py users, 32 | email it to sjplimp@sandia.gov and it can be added to the distribution 33 | with an attribution to you, both in the source code and on the 34 | "Pizza.py WWW site"_thanks. 35 | 36 | :link(thanks,http://www.cs.sandia.gov/~sjplimp/pizza/thanks.html) 37 | 38 | :line 39 | 40 | Here are ideas to consider when creating new Pizza.py tools or 41 | scripts: 42 | 43 | (1) For tools, your *.py file should contain a Python class with the 44 | same name as the *.py file since it will be imported into Pizza.py 45 | with a statement like 46 | 47 | from dump import dump :pre 48 | 49 | (2) Your scripts can use methods from Pizza.py classes to make data 50 | analysis easier. E.g. scripts can be written that use the dump tool 51 | to read dump files, then use the iterator calls and vecs() method from 52 | dump.py to loop over snapshots and extract lists of particles for 53 | further computation. See the scripts and examples directories for 54 | examples of this. 55 | 56 | (3) To flag an error in your script or tool and exit back to the 57 | Pizza.py prompt, use a line like: 58 | 59 | raise StandardError,"error message" :pre 60 | 61 | (4) Document your tool be defining the "oneline" and "docstr" 62 | variables at the top of the file. This is what will be printed when 63 | you type "? dump", for example. 64 | 65 | (5) If you intend your tool to interact with other Pizza.py tools, you 66 | should follow the Pizza.py philosophy of having objects be passed as 67 | arguments to the tool methods. If you're creating a tool that is 68 | similar to an existing tool, but a different flavor (e.g. wrapping 69 | another plotting package in addition to MatLab or GnuPlot), then try 70 | to make the interface similar to the others so all the related tools 71 | can be used interchangeably. 72 | 73 | (6) From the Pizza.py perspective, the difference between a script and 74 | a tool is as follows. A script typically does a specific operation 75 | (with or without arguments). E.g. process a dump file and compute a 76 | quantity. A tool version of the same operation would allow it to 77 | store internal state and persist, or to be packaged in a way that 78 | other tools or scripts can create instances of it and call its 79 | methods. From the Python perspective the code for the 2 cases may not 80 | look very different. The tool version might just be some Python 81 | variables and methods stuck inside a Python class, which is what a 82 | Pizza.py tool basically is. 83 | 84 | (7) The various Pizza.py tools are mostly related to the "LAMMPS" 85 | molecular dynamics or "ChemCell"_ccell cell simulator packages. But 86 | of course you can write Pizza.py tools that have nothing to do with 87 | LAMMPS or ChemCell. If you think they will still be of general 88 | interest to Pizza.py users, you can send them to us to include in the 89 | Pizza.py distribution. Or you can keep the top-level pizza.py file, 90 | throw away the LAMMPS and ChemCell tool files, build your own toolkit 91 | for whatever application you wish, and use or even distribute it 92 | yourself. That's the open-source philosophy. 93 | 94 | :link(lammps,http://www.cs.sandia.gov/~sjplimp/lammps.html) 95 | :link(ccell,http://www.cs.sandia.gov/~sjplimp/chemcell.html) 96 | -------------------------------------------------------------------------------- /doc/tdump.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | tdump tool :h3 10 | 11 | [Purpose:] 12 | 13 | Read dump files with triangle info. 14 | 15 | [Description:] 16 | 17 | The tdump tool reads one or more LAMMPS dump files, and stores their 18 | contents as a series of snapshots with 2d arrays of atom attributes. 19 | It is assumed that each atom contains triangle segment info from a 20 | LAMMPS simulation using atom_style tri. Other tools use tdump objects 21 | to extract triangle info for visualization, like the dump tool via its 22 | extra() method. 23 | 24 | The constructor method is passed a string containing one or more dump 25 | filenames. They can be listed in any order since snapshots are sorted 26 | by timestep after they are read and duplicate snapshots (with the same 27 | time stamp) are deleted. If a 2nd argument is specified, the files 28 | are not immediately read, but snapshots can be read one-at-a-time by 29 | the next() method. 30 | 31 | The map() method assigns names to columns of atom attributes. The 32 | id,type, corner1x,corner1y,corner1z, corner2x,corner2y,corner2z, 33 | corner3x,corner3y,corner3z names must be assigned in order for line 34 | segment info to be extracted. 35 | 36 | The viz() method is called by Pizza.py tools that visualize snapshots 37 | of atoms (e.g. gl, raster, svg tools). 38 | 39 | :line 40 | 41 | Normally, "LAMMPS"_http://lammps.sandia.gov creates the dump files 42 | read in by this tool. If you want to create them yourself, the format 43 | of LAMMPS dump files is simple. Each snapshot is formatted as 44 | follows: 45 | 46 | ITEM: TIMESTEP 47 | 100 48 | ITEM: NUMBER OF ATOMS 49 | 32 50 | ITEM: BOX BOUNDS 51 | 0 3.35919 52 | 0 3.35919 53 | 0 7.50 54 | ITEM: ATOMS 55 | 1 1 0 0 0 56 | 2 1 0.25 0.25 0 57 | 3 1 0.25 0 0.25 58 | ... 59 | N 3 0.7 0.5 0.6 :pre 60 | 61 | The box bounds are listed as xlo xhi on the 1st line, ylo yhi on the 62 | next line, zlo zhi on the last. There are N lines following "ITEM: 63 | ATOMS" where N is the number of atoms. Atoms do not have to be listed 64 | in any particular order. There can be a different number of atoms in 65 | each snapshot. Each line must contain the atom ID, type, and the end 66 | points of the associated line segment, as specified by the map() 67 | command. 68 | 69 | :line 70 | 71 | [Usage:] 72 | 73 | t = tdump("dump.one") read in one or more dump files 74 | t = tdump("dump.1 dump.2.gz") can be gzipped 75 | t = tdump("dump.*") wildcard expands to multiple files 76 | t = tdump("dump.*",0) two args = store filenames, but don't read :pre 77 | 78 | incomplete and duplicate snapshots are deleted 79 | no column name assignment is performed :pre 80 | 81 | time = t.next() read next snapshot from dump files :pre 82 | 83 | used with 2-argument constructor to allow reading snapshots one-at-a-time 84 | snapshot will be skipped only if another snapshot has same time stamp 85 | return time stamp of snapshot read 86 | return -1 if no snapshots left or last snapshot is incomplete 87 | no column name assignment is performed :pre 88 | 89 | t.map(1,"id",3,"x") assign names to atom columns (1-N) :pre 90 | 91 | must assign id,type,corner1x,corner1y,corner1z,corner2x,corner2y,corner2z,corner3x,corner3y,corner3z :pre 92 | 93 | time,box,atoms,bonds,tris,lines = t.viz(index) return list of viz objects :pre 94 | 95 | viz() returns line info for specified timestep index 96 | can also call as viz(time,1) and will find index of preceding snapshot 97 | time = timestep value 98 | box = \\[xlo,ylo,zlo,xhi,yhi,zhi\\] 99 | atoms = NULL 100 | bonds = NULL 101 | tris = id,type,x1,y1,z1,x2,y2,z2,x3,y3,z3 for each tri as 2d array 102 | id,type are from associated atom 103 | lines = NULL :pre 104 | 105 | t.owrap(...) wrap tris to same image as their atoms :pre 106 | 107 | owrap() is called by dump tool's owrap() 108 | useful for wrapping all molecule's atoms/tris the same so it is contiguous :pre 109 | 110 | [Related tools:] 111 | 112 | "dump"_dump.html, "gl"_gl.html, "raster"_raster.html, "svg"_svg.html 113 | 114 | [Prerequisites:] 115 | 116 | Numeric or NumPy Python packages. Gunzip command (if you want to read 117 | gzipped files). 118 | -------------------------------------------------------------------------------- /doc/Section_tools.txt: -------------------------------------------------------------------------------- 1 | "Previous Section"_Section_basics.html - "Pizza.py WWW Site"_pws - 2 | "Pizza.py Documentation"_pd - "Pizza.py Tools"_pt - "Next 3 | Section"_Section_examples.html :c 4 | 5 | :link(pws,http://pizza.sandia.gov) 6 | :link(pd,Manual.html) 7 | :link(pt,Section_tools.html) 8 | 9 | :line 10 | 11 | 4. Tools within Pizza.py :h3 12 | 13 | "Th previous section"_Section_basics.html#3_4 describes how Pizza.py 14 | tools are used in Pizza.py. 15 | 16 | Help on the syntax for invoking a tool and using its methods and 17 | settings can be accessed interactively within Pizza.py itself by 18 | typing "? tool" or "?? tool". Typing "??" gives a one-line 19 | description of each tool. 20 | 21 | These are the different categories of Pizza.py tools: 22 | 23 | LAMMPS in/out files: chain, data, dump, log, patch, bdump, ldump, tdump 24 | ChemCell in/out files: cdata, olog, dump 25 | SPPARKS in/out files: olog, dump 26 | SPARTA in/out files: sdata, olog, dump 27 | Visualization: gl, rasmol, raster, svg, vmd 28 | File conversion: cfg, ensight, pdbfile, vtk, xyz 29 | GUI wrappers: animate, image, plotview, vcr 30 | Plotting: gnu, matlab 31 | Miscellaneous: histo, mdump, pair, vec :tb(s=:) 32 | 33 | Within the plotting and viz categories, individual tools share many 34 | common methods, so the tools can often be used interchangeably. For 35 | example, the same script can produce an animation using either 36 | Raster3d or SVG to generate the movie frames, by simply changing the 37 | line that creates the visualizer object, or by passing the object into 38 | the script as an argument. 39 | 40 | This is the complete list of tools in Pizza.py; the link is to each 41 | tool's documentation page. 42 | 43 | "animate.py"_animate.html; Animate a series of image files 44 | "bdump.py"_bdump.html; Read LAMMPS dump local files with bond info 45 | "cdata.py"_data.html; Read, write, manipulate "Chemcell"_ccell data files 46 | "chain.py"_chain.html; Create bead-spring chains for LAMMPS input 47 | "cfg.py"_cfg.html; Convert LAMMPS snapshots to CFG format 48 | "data.py"_data.html; Read, write, manipulate LAMMPS data files 49 | "dump.py"_dump.html; Read, write, manipulate dump files and particle attributes 50 | "ensight.py"_ensight.html; Convert LAMMPS snapshots to "Ensight"_ensight format 51 | "gl.py"_gl.html; 3d interactive visualization via OpenGL 52 | "gnu.py"_gnu.html; Create plots via "GnuPlot"_gnuplot plotting program 53 | "histo.py"_histo.html; Particle density histogram from a dump 54 | "image.py"_image.html; View and manipulate images 55 | "ldump.py"_ldump.html; Read LAMMPS dump files with line info 56 | "log.py"_log.html; Read LAMMPS log files and extract thermodynamic data 57 | "matlab.py"_matlab.html; Create plots via "MatLab"_matlab numerical analysis program 58 | "mdump.py"_mdump.html; Read, write, manipulate mesh dump files 59 | "olog.py"_olog.html; Read other log files (ChemCell, SPPARKS, SPARTA) and extract time-series data 60 | "pair.py"_pair.html; Compute LAMMPS pairwise energies 61 | "patch.py"_patch.html; Create patchy Lennard-Jones particles for LAMMPS input 62 | "pdbfile.py"_pdbfile.html; Read, write PDB files in combo with LAMMPS snapshots 63 | "plotview.py"_plotview.html; Plot multiple vectors from a data set 64 | "rasmol.py"_rasmol.html; 3d visualization via "RasMol"_rasmol program 65 | "raster.py"_raster.html; 3d visualization via "Raster3d"_raster3d program 66 | "sdata.py"_sdata.html; Read, write, manipulate "SPARTA"_sparta surface files 67 | "svg.py"_svg.html; 3d visualization via "SVG"_svg files 68 | "tdump.py"_tdump.html; Read LAMMPS dump files with triangle info 69 | "vcr.py"_vcr.html; VCR-style GUI for 3d interactive OpenGL visualization 70 | "vec.py"_vec.html; Create numeric vectors from columns in file or list of vecs 71 | "vtk.py"_vtk.html; Convert LAMMPS snapshots to VTK format 72 | "vmd.py"_vmd.html; Wrapper on "VMD visualization package"_vmd 73 | "xyz.py"_xyz.html; Convert LAMMPS snapshots to XYZ format :tb(s=;) 74 | 75 | :link(gnuplot,http://www.gnuplot.info) 76 | :link(matlab,http://www.mathworks.com) 77 | :link(rasmol,http://www.openrasmol.org) 78 | :link(raster3d,http://www.bmsc.washington.edu/raster3d/raster3d.html) 79 | :link(svg,http://www.w3.org/Graphics/SVG) 80 | :link(ensight,http://www.ensight.com) 81 | :link(ccell,http://www.cs.sandia.gov/~sjplimp/cell.html) 82 | :link(vmd,http://www.ks.uiuc.edu/Research/vmd) 83 | 84 | This diagram represents the different ways tools can be interconnected 85 | by Pizza.py. Tools within the same red box are tools that are 86 | (roughly) interchangeable. 87 | 88 | :c,image(tools.jpg) 89 | -------------------------------------------------------------------------------- /doc/data.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Read, write, manipulate LAMMPS data files. 17 |
18 |Description: 19 |
20 |The data tool reads and writes LAMMPS data files. It also allows 21 | their content to be accessed or modified. 22 |
23 |The data constructor reads in the specified LAMMPS data file. With no 24 | argument, an empty data object is created which can have fields added 25 | to it later, and then be written out. 26 |
27 |The map() method assigns names to different atom attributes by their 28 | column number (1-N). The get() method extracts columns of information 29 | from the specified section of the data file. 30 |
31 |The title, headers, and sections variables can be set directly. The 32 | header values correspond to one-line definition that appear at the top 33 | of the data file. The box size values should be set to a Python 34 | tuple, e.g. 35 |
36 |d.headers["xlo xhi"] = (-30, 30) 37 |38 |
The section value should be a list of text lines, each of which 39 | includes a newline at the end. 40 |
41 |The delete() method deletes a header or entire section of the data 42 | file. The replace() method allows one column of a section to be 43 | replaced with a vector of new values. The newxyz() methods replaces 44 | the xyz coords of the "Atoms" section of the data file with xyz values 45 | from the Nth snapshot of a dump object containing snapshots. 46 |
47 |The iterator() and viz() methods are called by Pizza.py tools that 48 | visualize snapshots of atoms (e.g. raster, svg tools). A data file 49 | can be visualzed similarly to snapshots from a dump file. In the case 50 | of a data file, there is only a single snapshot with index 0. 51 |
52 |The write() method outputs a LAMMPS data file. 53 |
54 |Usage: 55 |
56 |d = data("data.poly") read a LAMMPS data file, can be gzipped
57 | d = data() create an empty data file
58 |
59 | d.map(1,"id",3,"x") assign names to atom columns (1-N) 60 |61 |
coeffs = d.get("Pair Coeffs") extract info from data file section
62 | q = d.get("Atoms",4)
63 |
64 | 1 arg = all columns returned as 2d array of floats 65 | 2 args = Nth column returned as vector of floats 66 |67 |
d.reorder("Atoms",1,3,2,4,5) reorder columns (1-N) in a data file section
68 |
69 | 1,3,2,4,5 = new order of previous columns, can delete columns this way 70 |71 |
d.title = "My LAMMPS data file" set title of the data file
72 | d.headers["atoms"] = 1500 set a header value
73 | d.sections["Bonds"] = lines set a section to list of lines (with newlines)
74 | d.delete("bonds") delete a keyword or section of data file
75 | d.delete("Bonds")
76 | d.replace("Atoms",5,vec) replace Nth column of section with vector
77 | d.newxyz(dmp,1000) replace xyz in Atoms with xyz of snapshot N
78 |
79 | newxyz assumes id,x,y,z are defined in both data and dump files 80 | also replaces ix,iy,iz if they are defined 81 |82 |
index,time,flag = d.iterator(0/1) loop over single data file snapshot 83 | time,box,atoms,bonds,tris,lines = d.viz(index) return list of viz objects 84 |85 |
iterator() and viz() are compatible with equivalent dump calls 86 | iterator() called with arg = 0 first time, with arg = 1 on subsequent calls 87 | index = timestep index within dump object (only 0 for data file) 88 | time = timestep value (only 0 for data file) 89 | flag = -1 when iteration is done, 1 otherwise 90 | viz() returns info for specified timestep index (must be 0) 91 | time = 0 92 | box = [xlo,ylo,zlo,xhi,yhi,zhi] 93 | atoms = id,type,x,y,z for each atom as 2d array 94 | bonds = id,type,x1,y1,z1,x2,y2,z2,t1,t2 for each bond as 2d array 95 | NULL if bonds do not exist 96 | tris = NULL 97 | lines = NULL 98 |99 |
d.write("data.new") write a LAMMPS data file
100 |
101 | Related tools: 102 |
103 | 105 |Prerequisites: none 106 |
107 | 108 | -------------------------------------------------------------------------------- /doc/pdbfile.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Read, write PDB files in combo with LAMMPS snapshots. 17 |
18 |Description: 19 |
20 |The pdbfile tool reads in PDB (Protein Data Bank) files of protein 21 | coordinates and uses them in conjunction with LAMMPS snapshots in 22 | various ways. The PDB format is commonly used by various 23 | vizualization and analysis programs. 24 |
25 |The pdbfile constructor takes a string argument listing one or more 26 | PDB filenames and a data argument with LAMMPS atom information 27 | (data or dump object). The atom snapshots 28 | must have "id", "type", "x", "y", and "z" defined; see the map() 29 | methods of those tools. 30 |
31 |Both arguments to the constructor are optional, as described below. 32 | If a single PDB file is given as a constructor argument, and it is 4 33 | letters long, and it does not exist on your system, then it is treated 34 | as a PDB identifier and the matching PDB file is downloaded from a PDB 35 | repository on the WWW to your machine. 36 |
37 |The one(), many(), and single() methods write out PDB files in various 38 | manners, depending on the 1 or 2 arguments used in the constructor. 39 | If only a string was specified (no data object), the specified PDB 40 | files are written out as-is. Thus the one() method concatenates the 41 | files together. If only a data object was specified (no string of PDB 42 | files), then PDB files in a generic format (Lennard-Jones atoms) are 43 | created. If both arguments are specified, then only a single PDB file 44 | can be listed. It is treated as a template file, and the atom 45 | coordinates in the data object replace the atom coordinates in the 46 | template PDB file to create a series of new PDB files. This 47 | replacement is only done for selected atoms (in the dump object) and 48 | for atom IDs that appear in the PDB file. 49 |
50 |The iterator() method is called by the rasmol tool to 51 | create a series of PDB files for visualization purposes. 52 |
53 |Usage: 54 |
55 |p = pdbfile("3CRO") create pdb object from PDB file or WWW
56 | p = pdbfile("pep1 pep2") read in multiple PDB files
57 | p = pdbfile("pep*") can use wildcards
58 | p = pdbfile(d) read in snapshot data with no PDB file
59 | p = pdbfile("3CRO",d) read in single PDB file with snapshot data
60 |
61 | string arg contains one or more PDB files 62 | don't need .pdb suffix except wildcard must expand to file.pdb 63 | if only one 4-char file specified and it is not found, 64 | it will be downloaded from http://www.rcsb.org as 3CRO.pdb 65 | d arg is object with atom coordinates (dump, data) 66 |67 |
p.one() write all output as one big PDB file to tmp.pdb
68 | p.one("mine") write to mine.pdb
69 | p.many() write one PDB file per snapshot: tmp0000.pdb, ...
70 | p.many("mine") write as mine0000.pdb, mine0001.pdb, ...
71 | p.single(N) write timestamp N as tmp.pdb
72 | p.single(N,"new") write as new.pdb
73 |
74 | how new PDB files are created depends on constructor inputs: 75 | if no d: one new PDB file for each file in string arg (just a copy) 76 | if only d specified: one new PDB file per snapshot in generic format 77 | if one file in str arg and d: one new PDB file per snapshot 78 | using input PDB file as template 79 | multiple input PDB files with a d is not allowed 80 |81 |
index,time,flag = p.iterator(0) 82 | index,time,flag = p.iterator(1) 83 |84 |
iterator = loop over number of PDB files 85 | call first time with arg = 0, thereafter with arg = 1 86 | N = length = # of snapshots or # of input PDB files 87 | index = index of snapshot or input PDB file (0 to N-1) 88 | time = timestep value (time stamp for snapshot, index for multiple PDB) 89 | flag = -1 when iteration is done, 1 otherwise 90 | typically call p.single(time) in iterated loop to write out one PDB file 91 |92 |
Related tools: 93 |
94 | 96 |Prerequisites: none 97 |
98 | 99 | -------------------------------------------------------------------------------- /doc/Section_extend.html: -------------------------------------------------------------------------------- 1 | 2 |Pizza.py can easily be extended in several ways: 16 |
17 |You might be able to do (2) because you're better with Python than we 26 | are! Note that generally, we've opted for simplicity versus speed in 27 | writing the tools, unless the operation is very costly. An example of 28 | something I'd like to speed up is the reading of large dump files in 29 | dump.py. 30 |
31 |Some of the ideas we've had for (3), but haven't gotten around to, are 32 | listed at the top of the src/*.py files as ToDo items. 33 |
34 |If you think your addition will be useful to other Pizza.py users, 35 | email it to sjplimp@sandia.gov and it can be added to the distribution 36 | with an attribution to you, both in the source code and on the 37 | Pizza.py WWW site. 38 |
39 | 40 | 41 |Here are ideas to consider when creating new Pizza.py tools or 44 | scripts: 45 |
46 |(1) For tools, your *.py file should contain a Python class with the 47 | same name as the *.py file since it will be imported into Pizza.py 48 | with a statement like 49 |
50 |from dump import dump 51 |52 |
(2) Your scripts can use methods from Pizza.py classes to make data 53 | analysis easier. E.g. scripts can be written that use the dump tool 54 | to read dump files, then use the iterator calls and vecs() method from 55 | dump.py to loop over snapshots and extract lists of particles for 56 | further computation. See the scripts and examples directories for 57 | examples of this. 58 |
59 |(3) To flag an error in your script or tool and exit back to the 60 | Pizza.py prompt, use a line like: 61 |
62 |raise StandardError,"error message" 63 |64 |
(4) Document your tool be defining the "oneline" and "docstr" 65 | variables at the top of the file. This is what will be printed when 66 | you type "? dump", for example. 67 |
68 |(5) If you intend your tool to interact with other Pizza.py tools, you 69 | should follow the Pizza.py philosophy of having objects be passed as 70 | arguments to the tool methods. If you're creating a tool that is 71 | similar to an existing tool, but a different flavor (e.g. wrapping 72 | another plotting package in addition to MatLab or GnuPlot), then try 73 | to make the interface similar to the others so all the related tools 74 | can be used interchangeably. 75 |
76 |(6) From the Pizza.py perspective, the difference between a script and 77 | a tool is as follows. A script typically does a specific operation 78 | (with or without arguments). E.g. process a dump file and compute a 79 | quantity. A tool version of the same operation would allow it to 80 | store internal state and persist, or to be packaged in a way that 81 | other tools or scripts can create instances of it and call its 82 | methods. From the Python perspective the code for the 2 cases may not 83 | look very different. The tool version might just be some Python 84 | variables and methods stuck inside a Python class, which is what a 85 | Pizza.py tool basically is. 86 |
87 |(7) The various Pizza.py tools are mostly related to the "LAMMPS" 88 | molecular dynamics or ChemCell cell simulator packages. But 89 | of course you can write Pizza.py tools that have nothing to do with 90 | LAMMPS or ChemCell. If you think they will still be of general 91 | interest to Pizza.py users, you can send them to us to include in the 92 | Pizza.py distribution. Or you can keep the top-level pizza.py file, 93 | throw away the LAMMPS and ChemCell tool files, build your own toolkit 94 | for whatever application you wish, and use or even distribute it 95 | yourself. That's the open-source philosophy. 96 |
97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /doc/ldump.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Read dump files with line segment info. 17 |
18 |Description: 19 |
20 |The ldump tool reads one or more LAMMPS dump files, and stores their 21 | contents as a series of snapshots with 2d arrays of atom attributes. 22 | It is assumed that each atom contains line segment info from a 2d 23 | LAMMPS simulation using atom_style line. Other tools use ldump 24 | objects to extract line segment info for visualization, like the dump 25 | tool via its extra() method. 26 |
27 |The constructor method is passed a string containing one or more dump 28 | filenames. They can be listed in any order since snapshots are sorted 29 | by timestep after they are read and duplicate snapshots (with the same 30 | time stamp) are deleted. If a 2nd argument is specified, the files 31 | are not immediately read, but snapshots can be read one-at-a-time by 32 | the next() method. 33 |
34 |The map() method assigns names to columns of atom attributes. 35 | The id,type,end1x,end1y,end2x,end2y names must be assigned 36 | in order for line segment info to be extracted. 37 |
38 |The viz() method is called by Pizza.py tools that visualize snapshots 39 | of atoms (e.g. gl, raster, svg tools). 40 |
41 |Normally, LAMMPS creates the dump files 44 | read in by this tool. If you want to create them yourself, the format 45 | of LAMMPS dump files is simple. Each snapshot is formatted as 46 | follows: 47 |
48 |ITEM: TIMESTEP 49 | 100 50 | ITEM: NUMBER OF ATOMS 51 | 32 52 | ITEM: BOX BOUNDS 53 | 0 3.35919 54 | 0 3.35919 55 | 0 7.50 56 | ITEM: ATOMS 57 | 1 1 0 0 0 58 | 2 1 0.25 0.25 0 59 | 3 1 0.25 0 0.25 60 | ... 61 | N 3 0.7 0.5 0.6 62 |63 |
The box bounds are listed as xlo xhi on the 1st line, ylo yhi on the 64 | next line, zlo zhi on the last. There are N lines following "ITEM: 65 | ATOMS" where N is the number of atoms. Atoms do not have to be listed 66 | in any particular order. There can be a different number of atoms in 67 | each snapshot. Each line must contain the atom ID, type, and the end 68 | points of the associated line segment, as specified by the map() 69 | command. 70 |
71 |Usage: 74 |
75 |l = ldump("dump.one") read in one or more dump files
76 | l = ldump("dump.1 dump.2.gz") can be gzipped
77 | l = ldump("dump.*") wildcard expands to multiple files
78 | l = ldump("dump.*",0) two args = store filenames, but don't read
79 |
80 | incomplete and duplicate snapshots are deleted 81 | no column name assignment is performed 82 |83 |
time = l.next() read next snapshot from dump files 84 |85 |
used with 2-argument constructor to allow reading snapshots one-at-a-time 86 | snapshot will be skipped only if another snapshot has same time stamp 87 | return time stamp of snapshot read 88 | return -1 if no snapshots left or last snapshot is incomplete 89 | no column name assignment is performed 90 |91 |
l.map(1,"id",3,"x") assign names to atom columns (1-N) 92 |93 |
must assign id,type,end1x,end1y,end2x,end2y 94 |95 |
time,box,atoms,bonds,tris,lines = l.viz(index) return list of viz objects 96 |97 |
viz() returns line info for specified timestep index 98 | can also call as viz(time,1) and will find index of preceding snapshot 99 | time = timestep value 100 | box = \[xlo,ylo,zlo,xhi,yhi,zhi\] 101 | atoms = NULL 102 | bonds = NULL 103 | tris = NULL 104 | lines = id,type,x1,y1,z1,x2,y2,z2 for each line as 2d array 105 | id,type are from associated atom 106 |107 |
l.owrap(...) wrap lines to same image as their atoms 108 |109 |
owrap() is called by dump tool's owrap() 110 | useful for wrapping all molecule's atoms/lines the same so it is contiguous 111 |112 |
Related tools: 113 |
114 | 116 |Prerequisites: 117 |
118 |Numeric or NumPy Python packages. Gunzip command (if you want to read 119 | gzipped files). 120 |
121 | 122 | -------------------------------------------------------------------------------- /doc/gnu.txt: -------------------------------------------------------------------------------- 1 | "Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c 2 | 3 | :link(pws,http://pizza.sandia.gov) 4 | :link(pd,Manual.html) 5 | :link(pc,Section_tools.html) 6 | 7 | :line 8 | 9 | gnu tool :h3 10 | 11 | [Purpose:] 12 | 13 | Create plots via GnuPlot plotting program. 14 | 15 | [Description:] 16 | 17 | The gnu tool is a wrapper on the "GnuPlot"_http://www.gnuplot.info/ 18 | plotting package. GnuPlot is open source software and runs on any 19 | platform. 20 | 21 | The gnu constructor launches GnuPlot as a process which the gnu tool 22 | sends commands to. The GnuPlot process can be killed via the stop() 23 | method, though this is typically unnecessary. 24 | 25 | The plot() method plots a single vector against a linear index or 26 | pairs of vectors against each other. The pairs of vectors are written 27 | to files and read-in by GnuPlot's plot command. 28 | 29 | The mplot() method creates a series of plots and saves them each to a 30 | numbered file. Each file is a plot of an increasing portion of the 31 | vector(s). This can be used to make an animation of a plot. 32 | 33 | The enter() method can be used to interact with GnuPlot directly. 34 | Each subsequent line you type is a GnuPlot command, until you type 35 | "quit" or "exit" to return to Pizza.py. Single GnuPlot commands can 36 | be issued as string arguments to the gnu tool. 37 | 38 | The export() method writes numeric data as columns to text files, so 39 | that GnuPlot can read them via its "plot" command. 40 | 41 | Mutliple windows can be displayed, plotted to, and manipulated using 42 | the select() and hide() methods. The save() method writes the 43 | currently selected plot to a PostScript file. 44 | 45 | The remaining methods (aspect, title, xrange, etc) set attributes of 46 | the currently selected plot. The erase() method resets all attributes 47 | to their default values. 48 | 49 | [Usage:] 50 | 51 | g = gnu() start up GnuPlot 52 | g.stop() shut down GnuPlot process :pre 53 | 54 | g.plot(a) plot vector A against linear index 55 | g.plot(a,b) plot B against A 56 | g.plot(a,b,c,d,...) plot B against A, D against C, etc 57 | g.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc :pre 58 | 59 | each plot argument can be a tuple, list, or Numeric/NumPy vector 60 | mplot loops over range(M,N,S) and create one plot per iteration 61 | last args are same as list of vectors for plot(), e.g. 1, 2, 4 vectors 62 | each plot is made from a portion of the vectors, depending on loop index i 63 | Ith plot is of b\[0:i\] vs a\[0:i\], etc 64 | series of plots saved as file0000.eps, file0001.eps, etc 65 | if use xrange(),yrange() then plot axes will be same for all plots :pre 66 | 67 | g("plot 'file.dat' using 2:3 with lines") execute string in GnuPlot :pre 68 | 69 | g.enter() enter GnuPlot shell 70 | gnuplot> plot sin(x) with lines type commands directly to GnuPlot 71 | gnuplot> exit, quit exit GnuPlot shell :pre 72 | 73 | g.export("data",range(100),a,...) create file with columns of numbers :pre 74 | 75 | all vectors must be of equal length 76 | could plot from file with GnuPlot command: plot 'data' using 1:2 with lines :pre 77 | 78 | g.select(N) figure N becomes the current plot :pre 79 | 80 | subsequent commands apply to this plot :pre 81 | 82 | g.hide(N) delete window for figure N 83 | g.save("file") save current plot as file.eps :pre 84 | 85 | Set attributes for current plot: :pre 86 | 87 | g.erase() reset all attributes to default values 88 | g.aspect(1.3) aspect ratio 89 | g.xtitle("Time") x axis text 90 | g.ytitle("Energy") y axis text 91 | g.title("My Plot") title text 92 | g.title("title","x","y") title, x axis, y axis text 93 | g.xrange(xmin,xmax) x axis range 94 | g.xrange() default x axis range 95 | g.yrange(ymin,ymax) y axis range 96 | g.yrange() default y axis range 97 | g.xlog() toggle x axis between linear and log 98 | g.ylog() toggle y axis between linear and log 99 | g.label(x,y,"text") place label at x,y coords 100 | g.curve(N,'r') set color of curve N :pre 101 | 102 | colors: 'k' = black, 'r' = red, 'g' = green, 'b' = blue 103 | 'm' = magenta, 'c' = cyan, 'y' = yellow :pre 104 | 105 | [Related tools:] 106 | 107 | "matlab"_matlab.html, "plotview"_plotview.html 108 | 109 | [Prerequisites:] 110 | 111 | GnuPlot plotting package. 112 | -------------------------------------------------------------------------------- /scripts/angle_distribute.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Script: angle_distribute.py 4 | # Purpose: binned angle distributions by angle type 5 | # Syntax: angle_distribute.py datafile nbin theta_min theta_max outfile files ... 6 | # datafile = lammps data file 7 | # nbin = # of bins per angle type 8 | # theta_min = min expected angle 9 | # theta_max = max expected angle length 10 | # outfile = file to write stats to 11 | # files = series of dump files 12 | # Example: angle_distribute.py pore.data 1000 110. 120. angles.out pore.dump.1 13 | # Author: Paul Crozier (Sandia) 14 | 15 | # enable script to run from Python directly w/out Pizza.py 16 | 17 | import sys 18 | from dump import dump 19 | from math import sqrt,acos,atan 20 | if not globals().has_key("argv"): argv = sys.argv 21 | 22 | # main script 23 | 24 | if len(argv) < 7: 25 | raise StandardError, \ 26 | "Syntax: angle_distribute.py datafile nbin theta_min theta_max outfile files ..." 27 | 28 | dt = data(argv[1]) 29 | nbins = int(argv[2]) 30 | theta_min = float(argv[3]) 31 | theta_max = float(argv[4]) 32 | outfile = argv[5] 33 | files = ' '.join(argv[6:]) 34 | 35 | # get the angles from the data file 36 | 37 | angle = dt.get("Angles") 38 | nangles = len(angle) 39 | atype = nangles * [0] 40 | iatom = nangles * [0] 41 | jatom = nangles * [0] 42 | katom = nangles * [0] 43 | for i in xrange(nangles): 44 | atype[i] = int(angle[i][1] - 1) 45 | iatom[i] = int(angle[i][2] - 1) 46 | jatom[i] = int(angle[i][3] - 1) 47 | katom[i] = int(angle[i][4] - 1) 48 | 49 | ntypes = 0 50 | for i in xrange(nangles): ntypes = max(angle[i][1],ntypes) 51 | ntypes = int(ntypes) 52 | ncount = ntypes * [0] 53 | bin = nbins * [0] 54 | for i in xrange(nbins): 55 | bin[i] = ntypes * [0] 56 | 57 | # read snapshots one-at-a-time 58 | 59 | d = dump(files,0) 60 | d.map(1,"id",2,"type",3,"x",4,"y",5,"z") 61 | 62 | PI = 4.0*atan(1.0) 63 | 64 | while 1: 65 | time = d.next() 66 | if time == -1: break 67 | 68 | box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo, 69 | d.snaps[-1].xhi,d.snaps[-1].yhi,d.snaps[-1].zhi) 70 | 71 | xprd = box[3] - box[0] 72 | yprd = box[4] - box[1] 73 | zprd = box[5] - box[2] 74 | 75 | d.unscale() 76 | d.sort() 77 | x,y,z = d.vecs(time,"x","y","z") 78 | 79 | for i in xrange(nangles): 80 | 81 | delx1 = x[iatom[i]] - x[jatom[i]] 82 | dely1 = y[iatom[i]] - y[jatom[i]] 83 | delz1 = z[iatom[i]] - z[jatom[i]] 84 | 85 | if abs(delx1) > 0.5*xprd: 86 | if delx1 < 0.0: 87 | delx1 += xprd 88 | else: 89 | delx1 -= xprd 90 | if abs(dely1) > 0.5*yprd: 91 | if dely1 < 0.0: 92 | dely1 += yprd 93 | else: 94 | dely1 -= yprd 95 | if abs(delz1) > 0.5*zprd: 96 | if delz1 < 0.0: 97 | delz1 += zprd 98 | else: 99 | delz1 -= zprd 100 | 101 | r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1) 102 | 103 | delx2 = x[katom[i]] - x[jatom[i]] 104 | dely2 = y[katom[i]] - y[jatom[i]] 105 | delz2 = z[katom[i]] - z[jatom[i]] 106 | 107 | if abs(delx2) > 0.5*xprd: 108 | if delx2 < 0.0: 109 | delx2 += xprd 110 | else: 111 | delx2 -= xprd 112 | if abs(dely2) > 0.5*yprd: 113 | if dely2 < 0.0: 114 | dely2 += yprd 115 | else: 116 | dely2 -= yprd 117 | if abs(delz2) > 0.5*zprd: 118 | if delz2 < 0.0: 119 | delz2 += zprd 120 | else: 121 | delz2 -= zprd 122 | 123 | r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2) 124 | 125 | c = delx1*delx2 + dely1*dely2 + delz1*delz2 126 | c /= r1*r2 127 | 128 | if (c > 1.0): c = 1.0 129 | if (c < -1.0): c = -1.0 130 | 131 | theta = 180.0*acos(c)/PI 132 | 133 | ibin = int(nbins*(theta - theta_min)/(theta_max - theta_min) + 0.5) 134 | if ((ibin >= 0) and (ibin <= nbins-1)): 135 | bin[ibin][atype[i]] += nbins 136 | ncount[atype[i]] += 1 137 | else: 138 | print "Warning: angle outside specified range" 139 | print "angle type:", atype[i]+1 140 | print "angle number:", i 141 | print time, 142 | 143 | print 144 | print "Printing normalized angle distributions to",outfile 145 | 146 | fp = open(outfile,"w") 147 | theta_range = theta_max - theta_min 148 | for i in xrange(nbins): 149 | print >>fp, theta_min + theta_range*float(i)/float(nbins), 150 | for j in xrange(ntypes): 151 | if (ncount[j] > 0): 152 | print >>fp, float(bin[i][j])/float(ncount[j])/theta_range, 153 | else: 154 | print >>fp, 0.0, 155 | print >>fp 156 | fp.close() 157 | -------------------------------------------------------------------------------- /doc/tdump.html: -------------------------------------------------------------------------------- 1 | 2 |Purpose: 15 |
16 |Read dump files with triangle info. 17 |
18 |Description: 19 |
20 |The tdump tool reads one or more LAMMPS dump files, and stores their 21 | contents as a series of snapshots with 2d arrays of atom attributes. 22 | It is assumed that each atom contains triangle segment info from a 23 | LAMMPS simulation using atom_style tri. Other tools use tdump objects 24 | to extract triangle info for visualization, like the dump tool via its 25 | extra() method. 26 |
27 |The constructor method is passed a string containing one or more dump 28 | filenames. They can be listed in any order since snapshots are sorted 29 | by timestep after they are read and duplicate snapshots (with the same 30 | time stamp) are deleted. If a 2nd argument is specified, the files 31 | are not immediately read, but snapshots can be read one-at-a-time by 32 | the next() method. 33 |
34 |The map() method assigns names to columns of atom attributes. The 35 | id,type, corner1x,corner1y,corner1z, corner2x,corner2y,corner2z, 36 | corner3x,corner3y,corner3z names must be assigned in order for line 37 | segment info to be extracted. 38 |
39 |The viz() method is called by Pizza.py tools that visualize snapshots 40 | of atoms (e.g. gl, raster, svg tools). 41 |
42 |Normally, LAMMPS creates the dump files 45 | read in by this tool. If you want to create them yourself, the format 46 | of LAMMPS dump files is simple. Each snapshot is formatted as 47 | follows: 48 |
49 |ITEM: TIMESTEP 50 | 100 51 | ITEM: NUMBER OF ATOMS 52 | 32 53 | ITEM: BOX BOUNDS 54 | 0 3.35919 55 | 0 3.35919 56 | 0 7.50 57 | ITEM: ATOMS 58 | 1 1 0 0 0 59 | 2 1 0.25 0.25 0 60 | 3 1 0.25 0 0.25 61 | ... 62 | N 3 0.7 0.5 0.6 63 |64 |
The box bounds are listed as xlo xhi on the 1st line, ylo yhi on the 65 | next line, zlo zhi on the last. There are N lines following "ITEM: 66 | ATOMS" where N is the number of atoms. Atoms do not have to be listed 67 | in any particular order. There can be a different number of atoms in 68 | each snapshot. Each line must contain the atom ID, type, and the end 69 | points of the associated line segment, as specified by the map() 70 | command. 71 |
72 |Usage: 75 |
76 |t = tdump("dump.one") read in one or more dump files
77 | t = tdump("dump.1 dump.2.gz") can be gzipped
78 | t = tdump("dump.*") wildcard expands to multiple files
79 | t = tdump("dump.*",0) two args = store filenames, but don't read
80 |
81 | incomplete and duplicate snapshots are deleted 82 | no column name assignment is performed 83 |84 |
time = t.next() read next snapshot from dump files 85 |86 |
used with 2-argument constructor to allow reading snapshots one-at-a-time 87 | snapshot will be skipped only if another snapshot has same time stamp 88 | return time stamp of snapshot read 89 | return -1 if no snapshots left or last snapshot is incomplete 90 | no column name assignment is performed 91 |92 |
t.map(1,"id",3,"x") assign names to atom columns (1-N) 93 |94 |
must assign id,type,corner1x,corner1y,corner1z,corner2x,corner2y,corner2z,corner3x,corner3y,corner3z 95 |96 |
time,box,atoms,bonds,tris,lines = t.viz(index) return list of viz objects 97 |98 |
viz() returns line info for specified timestep index 99 | can also call as viz(time,1) and will find index of preceding snapshot 100 | time = timestep value 101 | box = \[xlo,ylo,zlo,xhi,yhi,zhi\] 102 | atoms = NULL 103 | bonds = NULL 104 | tris = id,type,x1,y1,z1,x2,y2,z2,x3,y3,z3 for each tri as 2d array 105 | id,type are from associated atom 106 | lines = NULL 107 |108 |
t.owrap(...) wrap tris to same image as their atoms 109 |110 |
owrap() is called by dump tool's owrap() 111 | useful for wrapping all molecule's atoms/tris the same so it is contiguous 112 |113 |
Related tools: 114 |
115 | 117 |Prerequisites: 118 |
119 |Numeric or NumPy Python packages. Gunzip command (if you want to read 120 | gzipped files). 121 |
122 | 123 | --------------------------------------------------------------------------------