add more extensive whitespace checking for fortran and unittests

This commit is contained in:
Axel Kohlmeyer
2022-10-04 04:11:39 -04:00
parent d7d2802061
commit bc6e42a610
12 changed files with 123 additions and 121 deletions

View File

@ -60,7 +60,7 @@ lmp.command("thermo_style custom step v_emin v_elast pe")
lmp.command("run 0") lmp.command("run 0")
x = lmp.extract_atom("x") x = lmp.extract_atom("x")
lmp.command("variable elast equal $e") lmp.command("variable elast equal $e")
estart = lmp.extract_compute("thermo_pe", LMP_STYLE_GLOBAL, LAMMPS_INT) / natoms estart = lmp.extract_compute("thermo_pe", LMP_STYLE_GLOBAL, LAMMPS_INT) / natoms
# loop over Monte Carlo moves # loop over Monte Carlo moves
@ -92,7 +92,7 @@ for i in range(nloop):
else: else:
x[iatom][0] = x0 x[iatom][0] = x0
x[iatom][1] = y0 x[iatom][1] = y0
# final energy and stats # final energy and stats
lmp.command("variable nbuild equal nbuild") lmp.command("variable nbuild equal nbuild")

View File

@ -3,7 +3,7 @@
# #
# Copyright (2005) Sandia Corporation. Under the terms of Contract # Copyright (2005) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under # certain rights in this software. This software is distributed under
# the GNU General Public License. # the GNU General Public License.
# for python3 compatibility # for python3 compatibility
@ -19,8 +19,8 @@ g = gl(d) create OpenGL display for data in d
d = atom snapshot object (dump, data) d = atom snapshot object (dump, data)
g.bg("black") set background color (def = "black") g.bg("black") set background color (def = "black")
g.size(N) set image size to NxN g.size(N) set image size to NxN
g.size(N,M) set image size to NxM g.size(N,M) set image size to NxM
g.rotate(60,135) view from z theta and azimuthal phi (def = 60,30) g.rotate(60,135) view from z theta and azimuthal phi (def = 60,30)
g.shift(x,y) translate by x,y pixels in view window (def = 0,0) g.shift(x,y) translate by x,y pixels in view window (def = 0,0)
g.zoom(0.5) scale image by factor (def = 1) g.zoom(0.5) scale image by factor (def = 1)
@ -30,7 +30,7 @@ g.box(0/1/2,"red",4) set box edge thickness
g.file = "image" file prefix for created images (def = "image") g.file = "image" file prefix for created images (def = "image")
g.show(N) show image of snapshot at timestep N g.show(N) show image of snapshot at timestep N
g.all() make images of all selected snapshots g.all() make images of all selected snapshots
g.all(P) images of all, start file label at P g.all(P) images of all, start file label at P
g.all(N,M,P) make M images of snapshot N, start label at P g.all(N,M,P) make M images of snapshot N, start label at P
@ -43,12 +43,12 @@ g.pan() no pan during all() (default)
g.select = "$x > %g*3.0" string to pass to d.aselect.test() during all() g.select = "$x > %g*3.0" string to pass to d.aselect.test() during all()
g.select = "" no extra aselect (default) g.select = "" no extra aselect (default)
%g varies from 0.0 to 1.0 from beginning to end of all() %g varies from 0.0 to 1.0 from beginning to end of all()
g.acol(2,"green") set atom colors by atom type (1-N) g.acol(2,"green") set atom colors by atom type (1-N)
g.acol([2,4],["red","blue"]) 1st arg = one type or list of types g.acol([2,4],["red","blue"]) 1st arg = one type or list of types
g.acol(0,"blue") 2nd arg = one color or list of colors g.acol(0,"blue") 2nd arg = one color or list of colors
g.acol(range(20),["red","blue"]) if list lengths unequal, interpolate g.acol(range(20),["red","blue"]) if list lengths unequal, interpolate
g.acol(range(10),"loop") assign colors in loop, randomly ordered g.acol(range(10),"loop") assign colors in loop, randomly ordered
@ -58,23 +58,23 @@ g.acol(range(10),"loop") assign colors in loop, randomly ordered
g.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol() g.arad([1,2],[0.5,0.3]) set atom radii, same rules as acol()
g.bcol() set bond color, same args as acol() g.bcol() set bond color, same args as acol()
g.brad() set bond thickness, same args as arad() g.brad() set bond thickness, same args as arad()
g.tcol() set triangle color, same args as acol() g.tcol() set triangle color, same args as acol()
g.tfill() set triangle fill, 0 fill, 1 line, 2 both g.tfill() set triangle fill, 0 fill, 1 line, 2 both
g.lcol() set line color, same args as acol() g.lcol() set line color, same args as acol()
g.lrad() set line thickness, same args as arad() g.lrad() set line thickness, same args as arad()
g.adef() set atom/bond/tri/line properties to default g.adef() set atom/bond/tri/line properties to default
g.bdef() default = "loop" for colors, 0.45 for radii g.bdef() default = "loop" for colors, 0.45 for radii
g.tdef() default = 0.25 for bond/line thickness g.tdef() default = 0.25 for bond/line thickness
g.ldef() default = 0 fill g.ldef() default = 0 fill
by default 100 types are assigned by default 100 types are assigned
if atom/bond/tri/line has type > # defined properties, is an error if atom/bond/tri/line has type > # defined properties, is an error
from vizinfo import colors access color list from vizinfo import colors access color list
print(colors) list defined color names and RGB values print(colors) list defined color names and RGB values
colors["nickname"] = [R,G,B] set new RGB values from 0 to 255 colors["nickname"] = [R,G,B] set new RGB values from 0 to 255
@ -148,7 +148,7 @@ class gl:
self.azphi = 30 self.azphi = 30
self.scale = 1.0 self.scale = 1.0
self.xshift = self.yshift = 0 self.xshift = self.yshift = 0
self.file = "image" self.file = "image"
self.boxflag = 0 self.boxflag = 0
self.bxcol = [1,1,0] self.bxcol = [1,1,0]
@ -165,7 +165,7 @@ class gl:
self.nsides = 10 self.nsides = 10
self.theta_amplify = 2 self.theta_amplify = 2
self.shiny = 2 self.shiny = 2
self.clipflag = 0 self.clipflag = 0
self.clipxlo = self.clipylo = self.clipzlo = 0.0 self.clipxlo = self.clipylo = self.clipzlo = 0.0
self.clipxhi = self.clipyhi = self.clipzhi = 1.0 self.clipxhi = self.clipyhi = self.clipzhi = 1.0
@ -189,7 +189,7 @@ class gl:
self.bdef() self.bdef()
self.tdef() self.tdef()
self.ldef() self.ldef()
self.center = 3*[0] self.center = 3*[0]
self.view = 3*[0] self.view = 3*[0]
self.up = 3*[0] self.up = 3*[0]
@ -211,7 +211,7 @@ class gl:
if not ynew: self.ypixels = self.xpixels if not ynew: self.ypixels = self.xpixels
else: self.ypixels = ynew else: self.ypixels = ynew
self.create_window() self.create_window()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def axis(self,value): def axis(self,value):
@ -223,7 +223,7 @@ class gl:
def create_window(self): def create_window(self):
if self.root: self.root.destroy() if self.root: self.root.destroy()
from __main__ import tkroot from __main__ import tkroot
self.root = Toplevel(tkroot) self.root = Toplevel(tkroot)
self.root.title('Pizza.py gl tool') self.root.title('Pizza.py gl tool')
@ -232,7 +232,7 @@ class gl:
double=1,depth=1) double=1,depth=1)
self.w.pack(expand=YES) self.w.pack(expand=YES)
# self.w.pack(expand=YES,fill=BOTH) # self.w.pack(expand=YES,fill=BOTH)
glViewport(0,0,self.xpixels,self.ypixels) glViewport(0,0,self.xpixels,self.ypixels)
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
@ -247,7 +247,7 @@ class gl:
self.w.parent = self self.w.parent = self
self.w.tkRedraw() self.w.tkRedraw()
tkroot.update_idletasks() # force window to appear tkroot.update_idletasks() # force window to appear
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def clip(self,which,value): def clip(self,which,value):
@ -314,7 +314,7 @@ class gl:
self.up[1] = sin(pi*self.azphi/180) self.up[1] = sin(pi*self.azphi/180)
self.up[2] = 0.0 self.up[2] = 0.0
else: else:
dot = self.view[2] # dot = (0,0,1) . view dot = self.view[2] # dot = (0,0,1) . view
self.up[0] = -dot*self.view[0] # up projected onto v = dot * v self.up[0] = -dot*self.view[0] # up projected onto v = dot * v
self.up[1] = -dot*self.view[1] # up perp to v = up - dot * v self.up[1] = -dot*self.view[1] # up perp to v = up - dot * v
self.up[2] = 1.0 - dot*self.view[2] self.up[2] = 1.0 - dot*self.view[2]
@ -325,7 +325,7 @@ class gl:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# reset ztheta,azphi and thus view,up.right # reset ztheta,azphi and thus view,up.right
# called as function from Pizza.py # called as function from Pizza.py
def rotate(self,ztheta,azphi): def rotate(self,ztheta,azphi):
self.ztheta = ztheta self.ztheta = ztheta
self.azphi = azphi self.azphi = azphi
@ -366,11 +366,11 @@ class gl:
# rotate view,up around axis of rotation = old x new # rotate view,up around axis of rotation = old x new
# right = up x view # right = up x view
# reset ztheta,azphi from view # reset ztheta,azphi from view
def mouse_rotate(self,xnew,ynew,xold,yold): def mouse_rotate(self,xnew,ynew,xold,yold):
# change y pixels to measure from bottom of window instead of top # change y pixels to measure from bottom of window instead of top
yold = self.ypixels - yold yold = self.ypixels - yold
ynew = self.ypixels - ynew ynew = self.ypixels - ynew
@ -407,7 +407,7 @@ class gl:
axis[1] = rot[0]*self.right[1] + rot[1]*self.up[1] + rot[2]*self.view[1] axis[1] = rot[0]*self.right[1] + rot[1]*self.up[1] + rot[2]*self.view[1]
axis[2] = rot[0]*self.right[2] + rot[1]*self.up[2] + rot[2]*self.view[2] axis[2] = rot[0]*self.right[2] + rot[1]*self.up[2] + rot[2]*self.view[2]
axis = vecnorm(axis) axis = vecnorm(axis)
# view is changed by (axis x view) scaled by theta # view is changed by (axis x view) scaled by theta
# up is changed by (axis x up) scaled by theta # up is changed by (axis x up) scaled by theta
# force up to be perp to view via up_perp = up - (up . view) view # force up to be perp to view via up_perp = up - (up . view) view
@ -468,14 +468,14 @@ class gl:
# output: eye = distance to view scene from # output: eye = distance to view scene from
# xto,yto,zto = point to look to # xto,yto,zto = point to look to
# xfrom,yfrom,zfrom = point to look from # xfrom,yfrom,zfrom = point to look from
def setview(self): def setview(self):
if not self.ready: return # no distance since no scene yet if not self.ready: return # no distance since no scene yet
self.eye = 3 * self.distance / self.scale self.eye = 3 * self.distance / self.scale
xfactor = 0.5*self.eye*self.xshift/self.xpixels xfactor = 0.5*self.eye*self.xshift/self.xpixels
yfactor = 0.5*self.eye*self.yshift/self.ypixels yfactor = 0.5*self.eye*self.yshift/self.ypixels
self.xto = self.center[0] - xfactor*self.right[0] - yfactor*self.up[0] self.xto = self.center[0] - xfactor*self.right[0] - yfactor*self.up[0]
self.yto = self.center[1] - xfactor*self.right[1] - yfactor*self.up[1] self.yto = self.center[1] - xfactor*self.right[1] - yfactor*self.up[1]
self.zto = self.center[2] - xfactor*self.right[2] - yfactor*self.up[2] self.zto = self.center[2] - xfactor*self.right[2] - yfactor*self.up[2]
@ -486,7 +486,7 @@ class gl:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# box attributes, also used for triangle lines # box attributes, also used for triangle lines
def box(self,*args): def box(self,*args):
self.boxflag = args[0] self.boxflag = args[0]
if len(args) > 1: if len(args) > 1:
@ -500,7 +500,7 @@ class gl:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# grab all selected snapshots from data object # grab all selected snapshots from data object
# add GL-specific info to each bond # add GL-specific info to each bond
def reload(self): def reload(self):
print("Loading data into gl tool ...") print("Loading data into gl tool ...")
data = self.data data = self.data
@ -529,7 +529,7 @@ class gl:
self.bondframes.append(bonds) self.bondframes.append(bonds)
self.triframes.append(tris) self.triframes.append(tris)
self.lineframes.append(lines) self.lineframes.append(lines)
print(time,end='') print(time,end='')
sys.stdout.flush() sys.stdout.flush()
print() print()
@ -545,11 +545,11 @@ class gl:
def nolabel(self): def nolabel(self):
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.labels = [] self.labels = []
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# show a single snapshot # show a single snapshot
# distance from snapshot box or max box for all selected steps # distance from snapshot box or max box for all selected steps
def show(self,ntime): def show(self,ntime):
data = self.data data = self.data
which = data.findtime(ntime) which = data.findtime(ntime)
@ -571,7 +571,7 @@ class gl:
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
self.save() self.save()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def pan(self,*list): def pan(self,*list):
@ -584,7 +584,7 @@ class gl:
self.ztheta_stop = list[3] self.ztheta_stop = list[3]
self.azphi_stop = list[4] self.azphi_stop = list[4]
self.scale_stop = list[5] self.scale_stop = list[5]
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def all(self,*list): def all(self,*list):
@ -615,7 +615,7 @@ class gl:
if flag == -1: break if flag == -1: break
fraction = float(i) / (ncount-1) fraction = float(i) / (ncount-1)
if self.select != "": if self.select != "":
newstr = self.select % fraction newstr = self.select % fraction
data.aselect.test(newstr,time) data.aselect.test(newstr,time)
@ -653,7 +653,7 @@ class gl:
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
self.save(file) self.save(file)
print(time,end='') print(time,end='')
sys.stdout.flush() sys.stdout.flush()
i += 1 i += 1
@ -731,19 +731,19 @@ class gl:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# draw the GL scene # draw the GL scene
def redraw(self,o): def redraw(self,o):
# clear window to background color # clear window to background color
glClearColor(self.bgcol[0],self.bgcol[1],self.bgcol[2],0) glClearColor(self.bgcol[0],self.bgcol[1],self.bgcol[2],0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# not ready if no scene yet # not ready if no scene yet
if not self.ready: return if not self.ready: return
# set view from eye, distance, 3 lookat vectors (from,to,up) # set view from eye, distance, 3 lookat vectors (from,to,up)
glMatrixMode(GL_PROJECTION) glMatrixMode(GL_PROJECTION)
glLoadIdentity() glLoadIdentity()
if self.orthoflag: if self.orthoflag:
@ -759,14 +759,14 @@ class gl:
# draw scene from display list if caching allowed and list hasn't changed # draw scene from display list if caching allowed and list hasn't changed
# else redraw and store as new display list if caching allowed # else redraw and store as new display list if caching allowed
if self.cache and self.cachelist > 0: glCallList(self.cachelist); if self.cache and self.cachelist > 0: glCallList(self.cachelist);
else: else:
if self.cache: if self.cache:
if self.cachelist < 0: glDeleteLists(-self.cachelist,1) if self.cachelist < 0: glDeleteLists(-self.cachelist,1)
self.cachelist = glGenLists(1) self.cachelist = glGenLists(1)
glNewList(self.cachelist,GL_COMPILE_AND_EXECUTE) glNewList(self.cachelist,GL_COMPILE_AND_EXECUTE)
# draw box, clip-box, xyz axes, lines # draw box, clip-box, xyz axes, lines
glDisable(GL_LIGHTING) glDisable(GL_LIGHTING)
@ -842,7 +842,7 @@ class gl:
if self.tridraw: if self.tridraw:
fillflag = self.vizinfo.tfill[int(self.tridraw[0][1])] fillflag = self.vizinfo.tfill[int(self.tridraw[0][1])]
if fillflag != 1: if fillflag != 1:
if fillflag: if fillflag:
glEnable(GL_POLYGON_OFFSET_FILL) glEnable(GL_POLYGON_OFFSET_FILL)
@ -921,7 +921,7 @@ class gl:
gluCylinder(obj,rad,rad,bond[10],self.nsides,self.nsides) gluCylinder(obj,rad,rad,bond[10],self.nsides,self.nsides)
glPopMatrix() glPopMatrix()
if self.tridraw: if self.tridraw:
fillflag = self.vizinfo.tfill[int(self.tridraw[0][1])] fillflag = self.vizinfo.tfill[int(self.tridraw[0][1])]
if fillflag != 1: if fillflag != 1:
@ -975,7 +975,7 @@ class gl:
glEnd() glEnd()
glEnable(GL_LIGHTING) glEnable(GL_LIGHTING)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
if self.cache: glEndList() if self.cache: glEndList()
glFlush() glFlush()
@ -983,16 +983,16 @@ class gl:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# make new call list for each atom type # make new call list for each atom type
# called when atom color/rad/quality is changed # called when atom color/rad/quality is changed
def make_atom_calllist(self): def make_atom_calllist(self):
# extend calllist array if necessary # extend calllist array if necessary
if self.vizinfo.nacolor > self.nclist: if self.vizinfo.nacolor > self.nclist:
for i in range(self.vizinfo.nacolor-self.nclist): self.calllist.append(0) for i in range(self.vizinfo.nacolor-self.nclist): self.calllist.append(0)
self.nclist = self.vizinfo.nacolor self.nclist = self.vizinfo.nacolor
# create new calllist for each atom type # create new calllist for each atom type
for itype in xrange(1,self.vizinfo.nacolor+1): for itype in xrange(1,self.vizinfo.nacolor+1):
if self.calllist[itype]: glDeleteLists(self.calllist[itype],1) if self.calllist[itype]: glDeleteLists(self.calllist[itype],1)
ilist = glGenLists(1) ilist = glGenLists(1)
@ -1001,12 +1001,12 @@ class gl:
red,green,blue = self.vizinfo.acolor[itype] red,green,blue = self.vizinfo.acolor[itype]
rad = self.vizinfo.arad[itype] rad = self.vizinfo.arad[itype]
glColor3f(red,green,blue); glColor3f(red,green,blue);
# glPointSize(10.0*rad) # glPointSize(10.0*rad)
# glBegin(GL_POINTS) # glBegin(GL_POINTS)
# glVertex3f(0.0,0.0,0.0) # glVertex3f(0.0,0.0,0.0)
# glEnd() # glEnd()
glMaterialfv(GL_FRONT,GL_EMISSION,[red,green,blue,1.0]); glMaterialfv(GL_FRONT,GL_EMISSION,[red,green,blue,1.0]);
glMaterialf(GL_FRONT,GL_SHININESS,self.shiny); glMaterialf(GL_FRONT,GL_SHININESS,self.shiny);
glutSolidSphere(rad,self.nslices,self.nstacks) glutSolidSphere(rad,self.nslices,self.nstacks)
@ -1015,7 +1015,7 @@ class gl:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# augment bond info returned by viz() with info needed for GL draw # augment bond info returned by viz() with info needed for GL draw
# info = length, theta, -dy, dx for bond orientation # info = length, theta, -dy, dx for bond orientation
def bonds_augment(self,bonds): def bonds_augment(self,bonds):
for bond in bonds: for bond in bonds:
dx = bond[5] - bond[2] dx = bond[5] - bond[2]
@ -1046,7 +1046,7 @@ class gl:
glLineWidth(self.bxthick) glLineWidth(self.bxthick)
glColor3f(self.bxcol[0],self.bxcol[1],self.bxcol[2]) glColor3f(self.bxcol[0],self.bxcol[1],self.bxcol[2])
glBegin(GL_LINE_LOOP) glBegin(GL_LINE_LOOP)
glVertex3f(xlo,ylo,zlo) glVertex3f(xlo,ylo,zlo)
glVertex3f(xhi,ylo,zlo) glVertex3f(xhi,ylo,zlo)
@ -1081,7 +1081,7 @@ class gl:
if yhi-ylo > delta: delta = yhi-ylo if yhi-ylo > delta: delta = yhi-ylo
if zhi-zlo > delta: delta = zhi-zlo if zhi-zlo > delta: delta = zhi-zlo
delta *= 0.1 delta *= 0.1
glLineWidth(self.bxthick) glLineWidth(self.bxthick)
glBegin(GL_LINES) glBegin(GL_LINES)
@ -1100,7 +1100,7 @@ class gl:
def save(self,file=None): def save(self,file=None):
self.w.update() # force image on screen to be current before saving it self.w.update() # force image on screen to be current before saving it
pstring = glReadPixels(0,0,self.xpixels,self.ypixels, pstring = glReadPixels(0,0,self.xpixels,self.ypixels,
GL_RGBA,GL_UNSIGNED_BYTE) GL_RGBA,GL_UNSIGNED_BYTE)
snapshot = Image.fromstring("RGBA",(self.xpixels,self.ypixels),pstring) snapshot = Image.fromstring("RGBA",(self.xpixels,self.ypixels),pstring)
@ -1110,14 +1110,14 @@ class gl:
snapshot.save(file + ".png") snapshot.save(file + ".png")
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def adef(self): def adef(self):
self.vizinfo.setcolors("atom",range(100),"loop") self.vizinfo.setcolors("atom",range(100),"loop")
self.vizinfo.setradii("atom",range(100),0.45) self.vizinfo.setradii("atom",range(100),0.45)
self.make_atom_calllist() self.make_atom_calllist()
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def bdef(self): def bdef(self):
@ -1130,14 +1130,14 @@ class gl:
def tdef(self): def tdef(self):
self.vizinfo.setcolors("tri",range(100),"loop") self.vizinfo.setcolors("tri",range(100),"loop")
self.vizinfo.setfills("tri",range(100),0) self.vizinfo.setfills("tri",range(100),0)
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def ldef(self): def ldef(self):
self.vizinfo.setcolors("line",range(100),"loop") self.vizinfo.setcolors("line",range(100),"loop")
self.vizinfo.setradii("line",range(100),0.25) self.vizinfo.setradii("line",range(100),0.25)
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
@ -1149,29 +1149,29 @@ class gl:
self.make_atom_calllist() self.make_atom_calllist()
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def arad(self,atypes,radii): def arad(self,atypes,radii):
self.vizinfo.setradii("atom",atypes,radii) self.vizinfo.setradii("atom",atypes,radii)
self.make_atom_calllist() self.make_atom_calllist()
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def bcol(self,btypes,colors): def bcol(self,btypes,colors):
self.vizinfo.setcolors("bond",btypes,colors) self.vizinfo.setcolors("bond",btypes,colors)
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def brad(self,btypes,radii): def brad(self,btypes,radii):
self.vizinfo.setradii("bond",btypes,radii) self.vizinfo.setradii("bond",btypes,radii)
self.cachelist = -self.cachelist self.cachelist = -self.cachelist
self.w.tkRedraw() self.w.tkRedraw()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def tcol(self,ttypes,colors): def tcol(self,ttypes,colors):
@ -1210,10 +1210,10 @@ class MyOpengl(Opengl):
args = (self,master,cnf) args = (self,master,cnf)
Opengl.__init__(*args,**kw) Opengl.__init__(*args,**kw)
Opengl.autospin_allowed = 0 Opengl.autospin_allowed = 0
# redraw Opengl scene # redraw Opengl scene
# call parent redraw() method # call parent redraw() method
def tkRedraw(self,*dummy): def tkRedraw(self,*dummy):
if not self.initialised: return if not self.initialised: return
self.tk.call(self._w,'makecurrent') self.tk.call(self._w,'makecurrent')
@ -1222,7 +1222,7 @@ class MyOpengl(Opengl):
# left button translate # left button translate
# access parent xshift/yshift and call parent trans() method # access parent xshift/yshift and call parent trans() method
def tkTranslate(self,event): def tkTranslate(self,event):
dx = event.x - self.xmouse dx = event.x - self.xmouse
dy = event.y - self.ymouse dy = event.y - self.ymouse
@ -1242,7 +1242,7 @@ class MyOpengl(Opengl):
# right button zoom # right button zoom
# access parent scale and call parent zoom() method # access parent scale and call parent zoom() method
def tkScale(self,event): def tkScale(self,event):
scale = 1 - 0.01 * (event.y - self.ymouse) scale = 1 - 0.01 * (event.y - self.ymouse)
if scale < 0.001: scale = 0.001 if scale < 0.001: scale = 0.001

View File

@ -3,7 +3,7 @@
# #
# Copyright (2005) Sandia Corporation. Under the terms of Contract # Copyright (2005) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under # certain rights in this software. This software is distributed under
# the GNU General Public License. # the GNU General Public License.
# vizinfo class, not a top-level Pizza.py tool # vizinfo class, not a top-level Pizza.py tool
@ -25,7 +25,7 @@ import types
class vizinfo: class vizinfo:
""" """
Information holder for Pizza.py visualization tools Information holder for Pizza.py visualization tools
acolor,bcolor,tcolor,lcolor = RGB values for each atom/bond/tri/line type acolor,bcolor,tcolor,lcolor = RGB values for each atom/bond/tri/line type
arad = radius of each atom type arad = radius of each atom type
brad,lrad = thickness of each bond/line type brad,lrad = thickness of each bond/line type
@ -41,7 +41,7 @@ class vizinfo:
setfill() = set triangle fill factor setfill() = set triangle fill factor
extend() = grow an array extend() = grow an array
""" """
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def __init__(self): def __init__(self):
@ -57,15 +57,15 @@ class vizinfo:
self.nbcolor = self.nbrad = 0 self.nbcolor = self.nbrad = 0
self.ntcolor = self.ntfill = 0 self.ntcolor = self.ntfill = 0
self.nlcolor = self.nlrad = 0 self.nlcolor = self.nlrad = 0
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# set color RGB for which = atoms, bonds, triangles # set color RGB for which = atoms, bonds, triangles
def setcolors(self,which,ids,rgbs): def setcolors(self,which,ids,rgbs):
# convert args into lists if single values # convert args into lists if single values
# if arg = 0, convert to full-range list # if arg = 0, convert to full-range list
if type(ids) is types.IntType and ids == 0: if type(ids) is types.IntType and ids == 0:
if which == "atom": ids = range(self.nacolor) if which == "atom": ids = range(self.nacolor)
if which == "bond": ids = range(self.nbcolor) if which == "bond": ids = range(self.nbcolor)
@ -101,11 +101,11 @@ class vizinfo:
if max(ids) > self.nlcolor: if max(ids) > self.nlcolor:
self.nlcolor = self.extend(self.lcolor,max(ids)) self.nlcolor = self.extend(self.lcolor,max(ids))
self.nlcolor = self.extend(self.lrad,max(ids)) self.nlcolor = self.extend(self.lrad,max(ids))
# set color for each type # set color for each type
# if list lengths match, set directly, else interpolate # if list lengths match, set directly, else interpolate
# convert final color from 0-255 to 0.0-1.0 # convert final color from 0-255 to 0.0-1.0
ntypes = len(ids) ntypes = len(ids)
nrgbs = len(rgbs) nrgbs = len(rgbs)
@ -135,7 +135,7 @@ class vizinfo:
if which == "bond": self.bcolor[id] = color if which == "bond": self.bcolor[id] = color
if which == "tri": self.tcolor[id] = color if which == "tri": self.tcolor[id] = color
if which == "line": self.lcolor[id] = color if which == "line": self.lcolor[id] = color
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# set radii for which = atoms, bonds, lines # set radii for which = atoms, bonds, lines
@ -143,7 +143,7 @@ class vizinfo:
# convert args into lists if single values # convert args into lists if single values
# if arg = 0, convert to full-range list # if arg = 0, convert to full-range list
if type(ids) is types.IntType and ids == 0: if type(ids) is types.IntType and ids == 0:
if which == "atom": ids = range(self.narad) if which == "atom": ids = range(self.narad)
if which == "bond": ids = range(self.nbrad) if which == "bond": ids = range(self.nbrad)
@ -199,16 +199,16 @@ class vizinfo:
if which == "atom": self.arad[id] = rad if which == "atom": self.arad[id] = rad
if which == "bond": self.brad[id] = rad if which == "bond": self.brad[id] = rad
if which == "line": self.lrad[id] = rad if which == "line": self.lrad[id] = rad
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# set triangle fill style # set triangle fill style
# 0 = fill only, 1 = line only, 2 = fill and line # 0 = fill only, 1 = line only, 2 = fill and line
def setfills(self,which,ids,fills): def setfills(self,which,ids,fills):
# convert args into lists if single values # convert args into lists if single values
# if arg = 0, convert to full-range list # if arg = 0, convert to full-range list
if type(ids) is types.IntType and ids == 0: if type(ids) is types.IntType and ids == 0:
ids = range(self.ntfill) ids = range(self.ntfill)
if type(ids) is not types.ListType and type(ids) is not types.TupleType: if type(ids) is not types.ListType and type(ids) is not types.TupleType:
@ -237,7 +237,7 @@ class vizinfo:
for i in range(len(ids)): self.tfill[ids[i]] = int(fills[i]) for i in range(len(ids)): self.tfill[ids[i]] = int(fills[i])
else: else:
for id in ids: self.tfill[id] = int(fills[0]) for id in ids: self.tfill[id] = int(fills[0])
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def extend(self,array,n): def extend(self,array,n):

View File

@ -3,7 +3,7 @@
# #
# Copyright (2005) Sandia Corporation. Under the terms of Contract # Copyright (2005) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains # DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under # certain rights in this software. This software is distributed under
# the GNU General Public License. # the GNU General Public License.
# for python3 compatibility # for python3 compatibility
@ -20,24 +20,24 @@ from __future__ import print_function
oneline = "Control VMD from python" oneline = "Control VMD from python"
docstr = """ docstr = """
v = vmd() start up VMD v = vmd() start up VMD
v.stop() shut down VMD instance v.stop() shut down VMD instance
v.clear() delete all visualizations v.clear() delete all visualizations
v.rep(style) set default representation style. One of v.rep(style) set default representation style. One of
(Lines|VDW|Licorice|DynamicBonds|Points|CPK) (Lines|VDW|Licorice|DynamicBonds|Points|CPK)
v.new(file[,type]) load new file (default file type 'lammpstrj') v.new(file[,type]) load new file (default file type 'lammpstrj')
v.data(file[,atomstyle]) load new data file (default atom style 'full') v.data(file[,atomstyle]) load new data file (default atom style 'full')
v.replace(file[,type]) replace current frames with new file v.replace(file[,type]) replace current frames with new file
v.append(file[,type]) append file to current frame(s) v.append(file[,type]) append file to current frame(s)
v.set(snap,x,y,z,(True|False)) set coordinates from a pizza.py snapshot to new or current frame v.set(snap,x,y,z,(True|False)) set coordinates from a pizza.py snapshot to new or current frame
v.frame(frame) set current frame v.frame(frame) set current frame
v.flush() flush pending input to VMD and update GUI v.flush() flush pending input to VMD and update GUI
v.read(file) read Tcl script file (e.g. saved state) v.read(file) read Tcl script file (e.g. saved state)
v.enter() enter interactive shell v.enter() enter interactive shell
v.debug([True|False]) display generated VMD script commands? v.debug([True|False]) display generated VMD script commands?
""" """
# History # History
@ -71,7 +71,7 @@ except ImportError:
# Class definition # Class definition
class vmd: class vmd:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
def __init__(self): def __init__(self):
@ -103,7 +103,7 @@ class vmd:
# open pipe to vmd and wait until we have a prompt # open pipe to vmd and wait until we have a prompt
self.VMD = pexpect.spawn(self.vmdexe) self.VMD = pexpect.spawn(self.vmdexe)
self.VMD.expect('vmd >') self.VMD.expect('vmd >')
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# post command to vmd and wait until the prompt returns. # post command to vmd and wait until the prompt returns.
def __call__(self,command): def __call__(self,command):
@ -113,7 +113,7 @@ class vmd:
if self.debugme: if self.debugme:
print("call+result:"+self.VMD.before) print("call+result:"+self.VMD.before)
return return
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# exit VMD # exit VMD
def stop(self): def stop(self):
@ -198,7 +198,7 @@ class vmd:
self.__call__('mol addfile ' + filename + ' mol $tmol type ' + filetype + ' waitfor all') self.__call__('mol addfile ' + filename + ' mol $tmol type ' + filetype + ' waitfor all')
self.__call__('foreach mol [molinfo list] { molinfo $mol set {center_matrix rotate_matrix scale_matrix global_matrix} $viewpoints($mol)}') self.__call__('foreach mol [molinfo list] { molinfo $mol set {center_matrix rotate_matrix scale_matrix global_matrix} $viewpoints($mol)}')
self.flush() self.flush()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# replace all frames of a molecule with those from a given file # replace all frames of a molecule with those from a given file
def update(self,filename,filetype='lammpstrj'): def update(self,filename,filetype='lammpstrj'):
@ -209,7 +209,7 @@ class vmd:
self.__call__('mol addfile ' + filename + ' mol $tmol type ' + filetype + ' waitfor all') self.__call__('mol addfile ' + filename + ' mol $tmol type ' + filetype + ' waitfor all')
self.__call__('foreach mol [molinfo list] {molinfo $mol set {center_matrix rotate_matrix scale_matrix global_matrix} $viewpoints($mol)}') self.__call__('foreach mol [molinfo list] {molinfo $mol set {center_matrix rotate_matrix scale_matrix global_matrix} $viewpoints($mol)}')
self.flush() self.flush()
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# add or overwrite coordinates with coordinates in a snapshot # add or overwrite coordinates with coordinates in a snapshot
def set(self,snap,x,y,z,append=True): def set(self,snap,x,y,z,append=True):

View File

@ -1,4 +1,4 @@
conversion of lammps scripts to python code using PyLammps interface conversion of lammps scripts to python code using PyLammps interface
Example for elastic.py Example for elastic.py
python elastic.py Au.data EAM_Dynamo_Ackland_1987_Au__MO_754413982908_000 Au python elastic.py Au.data EAM_Dynamo_Ackland_1987_Au__MO_754413982908_000 Au

View File

@ -32,7 +32,7 @@ nprocs = comm.Get_size()
if me < nprocs // 2: color = 0 if me < nprocs // 2: color = 0
else: color = 1 else: color = 1
split = comm.Split(color,key=0) split = comm.Split(color,key=0)
if color == 0: if color == 0:
@ -69,12 +69,12 @@ else:
# could run a 2nd calculation on second partition # could run a 2nd calculation on second partition
# with different LAMMPS instance or another code # with different LAMMPS instance or another code
# in this case, just sleep on second partition # in this case, just sleep on second partition
import time import time
time.sleep(2) time.sleep(2)
print("Calculation on partition 1 complete") print("Calculation on partition 1 complete")
# shutdown mpi4py # shutdown mpi4py
comm.Barrier() comm.Barrier()
MPI.Finalize() MPI.Finalize()

View File

@ -50,7 +50,7 @@ ntimestep = 0
if me == 0: if me == 0:
tkroot = None tkroot = None
try: try:
import Tkinter import Tkinter
except: except:
import tkinter as Tkinter import tkinter as Tkinter

View File

@ -63,7 +63,7 @@ if me == 0:
p.single(ntimestep) p.single(ntimestep)
pm.load("tmp.pdb") pm.load("tmp.pdb")
pm.show("spheres","tmp") pm.show("spheres","tmp")
# run nfreq steps at a time w/out pre/post, read dump snapshot, display it # run nfreq steps at a time w/out pre/post, read dump snapshot, display it
while ntimestep < nsteps: while ntimestep < nsteps:
@ -75,7 +75,7 @@ while ntimestep < nsteps:
p.single(ntimestep) p.single(ntimestep)
pm.load("tmp.pdb") pm.load("tmp.pdb")
pm.forward() pm.forward()
lmp.command("run 0 pre no post yes") lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via mpi4py # uncomment if running in parallel via mpi4py

View File

@ -24,11 +24,13 @@ include:
- cmake/** - cmake/**
- doc - doc
- doc/src/** - doc/src/**
- python - fortran/**
- python/**
- src/** - src/**
- lib/** - lib/**
- tools/coding_standard - tools/coding_standard
- tools/python - tools/python
- unittest/**
exclude: exclude:
- lib/colvars/Install.py - lib/colvars/Install.py
- lib/gpu/geryon/file_to_cstr.sh - lib/gpu/geryon/file_to_cstr.sh

View File

@ -100,7 +100,7 @@ FUNCTION f_lammps_with_C_args(argc, argv) BIND(C)
TYPE(c_ptr), INTENT(IN), VALUE :: str TYPE(c_ptr), INTENT(IN), VALUE :: str
INTEGER(c_size_t) :: c_strlen INTEGER(c_size_t) :: c_strlen
END FUNCTION c_strlen END FUNCTION c_strlen
END INTERFACE END INTERFACE
CALL C_F_POINTER(argv, Fargv, [argc]) CALL C_F_POINTER(argv, Fargv, [argc])
DO i = 1, argc DO i = 1, argc
@ -111,7 +111,7 @@ FUNCTION f_lammps_with_C_args(argc, argv) BIND(C)
args(i)(j:j) = Cstr(j) args(i)(j:j) = Cstr(j)
END FORALL END FORALL
END DO END DO
lmp = lammps(args) lmp = lammps(args)
f_lammps_with_C_args = lmp%handle f_lammps_with_C_args = lmp%handle
END FUNCTION f_lammps_with_C_args END FUNCTION f_lammps_with_C_args

View File

@ -138,7 +138,7 @@ class LammpsShell(unittest.TestCase):
for line in lines: for line in lines:
if line.startswith('LAMMPS Shell>'): break if line.startswith('LAMMPS Shell>'): break
idx += 1 idx += 1
self.assertEqual(lines[idx+4],"dimension 2") self.assertEqual(lines[idx+4],"dimension 2")
self.assertEqual(lines[idx+6],"units real") self.assertEqual(lines[idx+6],"units real")
self.assertEqual(lines[idx+8],"dimension 2") self.assertEqual(lines[idx+8],"dimension 2")

View File

@ -16,5 +16,5 @@ double some_double_function(double arg1, int arg2)
return sum; return sum;
} }