start porting some LAMMPS python module examples to python3 with compatibility to python2

This commit is contained in:
Axel Kohlmeyer
2016-07-19 16:59:57 -04:00
parent ec9c9a235a
commit 21ea3ccfb7
18 changed files with 148 additions and 109 deletions

View File

@ -6,13 +6,14 @@
# Syntax: demo.py
# uses in.demo as LAMMPS input script
from __future__ import print_function
import sys
# parse command line
argv = sys.argv
if len(argv) != 1:
print "Syntax: demo.py"
print("Syntax: demo.py")
sys.exit()
from lammps import lammps
@ -22,29 +23,29 @@ lmp = lammps()
lmp.file("in.demo")
print "\nPython output:"
print("\nPython output:")
natoms = lmp.extract_global("natoms",0)
mass = lmp.extract_atom("mass",2)
x = lmp.extract_atom("x",3)
print "Natoms, mass, x[0][0] coord =",natoms,mass[1],x[0][0]
print("Natoms, mass, x[0][0] coord =",natoms,mass[1],x[0][0])
temp = lmp.extract_compute("thermo_temp",0,0)
print "Temperature from compute =",temp
print("Temperature from compute =",temp)
eng = lmp.extract_variable("eng",None,0)
print "Energy from equal-style variable =",eng
print("Energy from equal-style variable =",eng)
vy = lmp.extract_variable("vy","all",1)
print "Velocity component from atom-style variable =",vy[1]
print("Velocity component from atom-style variable =",vy[1])
natoms = lmp.get_natoms()
print "Natoms from get_natoms =",natoms
print("Natoms from get_natoms =",natoms)
xc = lmp.gather_atoms("x",1,3)
print "Global coords from gather_atoms =",xc[0],xc[1],xc[31]
print("Global coords from gather_atoms =",xc[0],xc[1],xc[31])
xc[0] = xc[0] + 1.0
lmp.scatter_atoms("x",1,3,xc)
print "Changed x[0][0] via scatter_atoms =",x[0][0]
print("Changed x[0][0] via scatter_atoms =",x[0][0])

View File

@ -10,6 +10,7 @@
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
# because I can't seem to do a MPI-style broadcast in Pypar
from __future__ import print_function
import sys,time
# methods called by GUI
@ -31,7 +32,7 @@ def quit():
argv = sys.argv
if len(argv) != 3:
print "Syntax: gui.py in.lammps Nfreq"
print("Syntax: gui.py in.lammps Nfreq")
sys.exit()
infile = sys.argv[1]
@ -60,7 +61,10 @@ runflag = 0
temptarget = 1.0
if me == 0:
from Tkinter import *
try:
from Tkinter import *
except:
from tkinter import *
tkroot = Tk()
tkroot.withdraw()
root = Toplevel(tkroot)
@ -108,5 +112,5 @@ while 1:
time.sleep(0.01)
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -6,6 +6,7 @@
# Syntax: mc.py in.mc
# in.mc = LAMMPS input script
from __future__ import print_function
import sys,random,math
# set these parameters
@ -21,7 +22,7 @@ random.seed(27848)
argv = sys.argv
if len(argv) != 2:
print "Syntax: mc.py in.mc"
print("Syntax: mc.py in.mc")
sys.exit()
infile = sys.argv[1]
@ -50,7 +51,7 @@ lmp.command("variable emin equal $e")
x = lmp.extract_atom("x",3)
for i in xrange(natoms):
for i in range(natoms):
x[i][0] += deltaperturb * (2*random.random()-1)
x[i][1] += deltaperturb * (2*random.random()-1)
@ -68,7 +69,7 @@ estart = lmp.extract_compute("thermo_pe",0,0) / natoms
elast = estart
naccept = 0
for i in xrange(nloop):
for i in range(nloop):
iatom = random.randrange(0,natoms)
x0 = x[iatom][0]
y0 = x[iatom][1]
@ -100,9 +101,9 @@ nbuild = lmp.extract_variable("nbuild",None,0)
lmp.command("run 0")
estop = lmp.extract_compute("thermo_pe",0,0) / natoms
print "MC stats:"
print " starting energy =",estart
print " final energy =",estop
print " minimum energy of perfect lattice =",emin
print " accepted MC moves =",naccept
print " neighbor list rebuilds =",nbuild
print("MC stats:")
print(" starting energy =",estart)
print(" final energy =",estop)
print(" minimum energy of perfect lattice =",emin)
print(" accepted MC moves =",naccept)
print(" neighbor list rebuilds =",nbuild)

View File

@ -179,6 +179,8 @@ d.extra(data) extract bond/tri/line list from data
# Imports and external programs
from __future__ import print_function
import sys, commands, re, glob, types
from os import popen
from math import * # any function could be used by set()
@ -324,7 +326,7 @@ class dump:
snap = self.snaps[self.nsnaps]
snap.tselect = 1
snap.nselect = snap.natoms
for i in xrange(snap.natoms): snap.aselect[i] = 1
for i in range(snap.natoms): snap.aselect[i] = 1
self.nsnaps += 1
self.nselect += 1
@ -370,14 +372,14 @@ class dump:
if snap.natoms:
words = f.readline().split()
ncol = len(words)
for i in xrange(1,snap.natoms):
for i in range(1,snap.natoms):
words += f.readline().split()
floats = map(float,words)
if oldnumeric: atoms = np.zeros((snap.natoms,ncol),np.Float)
else: atoms = np.zeros((snap.natoms,ncol),np.float)
start = 0
stop = ncol
for i in xrange(snap.natoms):
for i in range(snap.natoms):
atoms[i] = floats[start:stop]
start = stop
stop += ncol
@ -554,9 +556,9 @@ class dump:
zprd = snap.zhi - snap.zlo
atoms = snap.atoms
ids = {}
for i in xrange(snap.natoms):
for i in range(snap.natoms):
ids[atoms[i][id]] = i
for i in xrange(snap.natoms):
for i in range(snap.natoms):
j = ids[atoms[i][iother]]
atoms[i][x] += (atoms[i][ix]-atoms[j][ix])*xprd
atoms[i][y] += (atoms[i][iy]-atoms[j][iy])*yprd
@ -570,7 +572,7 @@ class dump:
pairs = self.names.items()
values = self.names.values()
str = ""
for i in xrange(ncol):
for i in range(ncol):
if i in values: str += pairs[values.index(i)][0] + ' '
return str
@ -602,7 +604,7 @@ class dump:
atoms = snap.atoms
ids = atoms[:,id]
ordering = np.argsort(ids)
for i in xrange(len(atoms[0])):
for i in range(len(atoms[0])):
atoms[:,i] = np.take(atoms[:,i],ordering)
# --------------------------------------------------------------------
@ -630,10 +632,10 @@ class dump:
atoms = snap.atoms
nvalues = len(atoms[0])
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
line = ""
for j in xrange(nvalues):
for j in range(nvalues):
if (j < 2):
line += str(int(atoms[i][j])) + " "
else:
@ -666,10 +668,10 @@ class dump:
atoms = snap.atoms
nvalues = len(atoms[0])
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
line = ""
for j in xrange(nvalues):
for j in range(nvalues):
if (j < 2):
line += str(int(atoms[i][j])) + " "
else:
@ -688,7 +690,7 @@ class dump:
for snap in self.snaps:
if not snap.tselect: continue
atoms = snap.atoms
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
if atoms[i][icol] < min: min = atoms[i][icol]
if atoms[i][icol] > max: max = atoms[i][icol]
@ -715,7 +717,7 @@ class dump:
for snap in self.snaps:
if not snap.tselect: continue
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if snap.aselect[i]: exec ceq
# --------------------------------------------------------------------
@ -733,7 +735,7 @@ class dump:
raise StandardError,"vec length does not match # of selected atoms"
atoms = snap.atoms
m = 0
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if snap.aselect[i]:
atoms[i][icol] = vec[m]
m += 1
@ -746,12 +748,12 @@ class dump:
icol = self.names[col]
id = self.names["id"]
ids = {}
for i in xrange(self.snaps[istep].natoms):
for i in range(self.snaps[istep].natoms):
ids[self.snaps[istep].atoms[i][id]] = i
for snap in self.snaps:
if not snap.tselect: continue
atoms = snap.atoms
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
j = ids[atoms[i][id]]
atoms[i][icol] = self.snaps[istep].atoms[j][icol]
@ -772,7 +774,7 @@ class dump:
for snap in self.snaps:
if not snap.tselect: continue
atoms = snap.atoms
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
ivalue = int((atoms[i][iold] - min) * invdelta) + 1
if ivalue > n: ivalue = n
@ -809,11 +811,11 @@ class dump:
for snap in self.snaps:
if not snap.tselect: continue
atoms = snap.atoms
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if atoms[i][id] == n: break
if atoms[i][id] != n:
raise StandardError, "could not find atom ID in snapshot"
for j in xrange(ncol):
for j in range(ncol):
values[j][m] = atoms[i][columns[j]]
m += 1
@ -836,9 +838,9 @@ class dump:
ncol = len(columns)
m = 0
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
for j in xrange(ncol):
for j in range(ncol):
values[j][m] = snap.atoms[i][columns[j]]
m += 1
@ -887,7 +889,7 @@ class dump:
def iterator(self,flag):
start = 0
if flag: start = self.iterate + 1
for i in xrange(start,self.nsnaps):
for i in range(start,self.nsnaps):
if self.snaps[i].tselect:
self.iterate = i
return i,self.snaps[i].time,1
@ -912,7 +914,7 @@ class dump:
# need Numeric/Numpy mode here
atoms = []
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
atom = snap.atoms[i]
atoms.append([atom[id],atom[type],atom[x],atom[y],atom[z]])
@ -927,7 +929,7 @@ class dump:
bonds = []
if self.bondflag:
alist = {}
for i in xrange(len(atoms)): alist[int(atoms[i][0])] = i
for i in range(len(atoms)): alist[int(atoms[i][0])] = i
for bond in self.bondlist:
try:
i = alist[bond[2]]
@ -953,7 +955,7 @@ class dump:
# --------------------------------------------------------------------
def findtime(self,n):
for i in xrange(self.nsnaps):
for i in range(self.nsnaps):
if self.snaps[i].time == n: return i
raise StandardError, "no step %d exists" % n
@ -982,7 +984,7 @@ class dump:
for snap in self.snaps:
if not snap.tselect: continue
atoms = snap.atoms
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
if atoms[i][icol] > max: max = atoms[i][icol]
return int(max)
@ -1008,7 +1010,7 @@ class dump:
words = f.readline().split()
ncol = len(words)
for i in xrange(1,nbonds):
for i in range(1,nbonds):
words += f.readline().split()
f.close()
@ -1019,7 +1021,7 @@ class dump:
ints = [abs(int(value)) for value in words]
start = 0
stop = 4
for i in xrange(nbonds):
for i in range(nbonds):
bondlist[i] = ints[start:stop]
start += ncol
stop += ncol
@ -1149,7 +1151,7 @@ class tselect:
snaps = data.snaps
cmd = "flag = " + teststr.replace("$t","snaps[i].time")
ccmd = compile(cmd,'','single')
for i in xrange(data.nsnaps):
for i in range(data.nsnaps):
if not snaps[i].tselect: continue
exec ccmd
if not flag:
@ -1173,12 +1175,12 @@ class aselect:
if len(args) == 0: # all selected timesteps
for snap in data.snaps:
if not snap.tselect: continue
for i in xrange(snap.natoms): snap.aselect[i] = 1
for i in range(snap.natoms): snap.aselect[i] = 1
snap.nselect = snap.natoms
else: # one timestep
n = data.findtime(args[0])
snap = data.snaps[n]
for i in xrange(snap.natoms): snap.aselect[i] = 1
for i in range(snap.natoms): snap.aselect[i] = 1
snap.nselect = snap.natoms
# --------------------------------------------------------------------
@ -1201,18 +1203,18 @@ class aselect:
if len(args) == 0: # all selected timesteps
for snap in data.snaps:
if not snap.tselect: continue
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
exec ccmd
if not flag:
snap.aselect[i] = 0
snap.nselect -= 1
for i in xrange(data.nsnaps):
for i in range(data.nsnaps):
if data.snaps[i].tselect:
print "%d atoms of %d selected in first step %d" % \
(data.snaps[i].nselect,data.snaps[i].natoms,data.snaps[i].time)
break
for i in xrange(data.nsnaps-1,-1,-1):
for i in range(data.nsnaps-1,-1,-1):
if data.snaps[i].tselect:
print "%d atoms of %d selected in last step %d" % \
(data.snaps[i].nselect,data.snaps[i].natoms,data.snaps[i].time)
@ -1221,7 +1223,7 @@ class aselect:
else: # one timestep
n = data.findtime(args[0])
snap = data.snaps[n]
for i in xrange(snap.natoms):
for i in range(snap.natoms):
if not snap.aselect[i]: continue
exec ccmd
if not flag:

View File

@ -87,7 +87,7 @@ g.curve(N,'r') set color of curve N
import types, os
try: from DEFAULTS import PIZZA_GNUPLOT
except: PIZZA_GNUPLOT = "gnuplot"
except: PIZZA_GNUPLOT = "gnuplot -p"
try: from DEFAULTS import PIZZA_GNUTERM
except: PIZZA_GNUTERM = "x11"
@ -133,7 +133,7 @@ class gnu:
self.export(file,linear,vectors[0])
self.figures[self.current-1].ncurves = 1
else:
if len(vectors) % 2: raise StandardError,"vectors must come in pairs"
if len(vectors) % 2: raise StandardError("vectors must come in pairs")
for i in range(0,len(vectors),2):
file = self.file + ".%d.%d" % (self.current,i/2+1)
self.export(file,vectors[i],vectors[i+1])
@ -167,11 +167,11 @@ class gnu:
def export(self,filename,*vectors):
n = len(vectors[0])
for vector in vectors:
if len(vector) != n: raise StandardError,"vectors must be same length"
if len(vector) != n: raise StandardError("vectors must be same length")
f = open(filename,'w')
nvec = len(vectors)
for i in xrange(n):
for j in xrange(nvec):
for i in range(n):
for j in range(nvec):
print >>f,vectors[j][i],
print >>f
f.close()

View File

@ -10,6 +10,7 @@
# compute-ID = ID of compute that calculates temperature
# (or any other scalar quantity)
from __future__ import print_function
import sys
sys.path.append("./pizza")
from gnu import gnu
@ -18,7 +19,7 @@ from gnu import gnu
argv = sys.argv
if len(argv) != 5:
print "Syntax: plot.py in.lammps Nfreq Nsteps compute-ID"
print("Syntax: plot.py in.lammps Nfreq Nsteps compute-ID")
sys.exit()
infile = sys.argv[1]
@ -71,5 +72,5 @@ while ntimestep < nsteps:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -11,13 +11,14 @@
# in.lammps = LAMMPS input script
# also need to uncomment either Pypar or mpi4py sections below
from __future__ import print_function
import sys
# parse command line
argv = sys.argv
if len(argv) != 2:
print "Syntax: simple.py in.lammps"
print("Syntax: simple.py in.lammps")
sys.exit()
infile = sys.argv[1]
@ -56,13 +57,13 @@ lmp.scatter_atoms("x",1,3,x)
lmp.command("run 1");
f = lmp.extract_atom("f",3)
print "Force on 1 atom via extract_atom: ",f[0][0]
print("Force on 1 atom via extract_atom: ",f[0][0])
fx = lmp.extract_variable("fx","all",1)
print "Force on 1 atom via extract_variable:",fx[0]
print("Force on 1 atom via extract_variable:",fx[0])
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()
# uncomment if running in parallel via mpi4py

View File

@ -7,13 +7,14 @@
# Syntax: split.py in.lammps
# in.lammps = LAMMPS input script
from __future__ import print_function
import sys
# parse command line
argv = sys.argv
if len(argv) != 2:
print "Syntax: simple.py in.lammps"
print("Syntax: simple.py in.lammps")
sys.exit()
infile = sys.argv[1]
@ -57,12 +58,12 @@ if color == 0:
lmp.command("run 1");
f = lmp.extract_atom("f",3)
print "Force on 1 atom via extract_atom: ",f[0][0]
print("Force on 1 atom via extract_atom: ",f[0][0])
fx = lmp.extract_variable("fx","all",1)
print "Force on 1 atom via extract_variable:",fx[0]
print "Proc %d out of %d procs has" % (me,nprocs), lmp
print "Calculation on partition 0 complete"
print("Force on 1 atom via extract_variable:",fx[0])
print("Proc %d out of %d procs has" % (me,nprocs), lmp)
print("Calculation on partition 0 complete")
else:
# could run a 2nd calculation on second partition
@ -71,7 +72,7 @@ else:
import time
time.sleep(2)
print "Calculation on partition 1 complete"
print("Calculation on partition 1 complete")
# shutdown mpi4py

View File

@ -6,13 +6,14 @@
# Syntax: trivial.py in.lammps
# in.lammps = LAMMPS input script
from __future__ import print_function
import sys
# parse command line
argv = sys.argv
if len(argv) != 2:
print "Syntax: trivial.py in.lammps"
print("Syntax: trivial.py in.lammps")
sys.exit()
infile = sys.argv[1]

View File

@ -8,6 +8,7 @@
# Nfreq = dump and viz shapshot every this many steps
# Nsteps = run for this many steps
from __future__ import print_function
import sys,os
# set this to point to AtomEye version 3 executable
@ -19,7 +20,7 @@ ATOMEYE3 = "/home/sjplimp/tools/atomeye3/A3.i686-20060530 > atomeye.out"
argv = sys.argv
if len(argv) != 4:
print "Syntax: viz_atomeye.py in.lammps Nfreq Nsteps"
print("Syntax: viz_atomeye.py in.lammps Nfreq Nsteps")
sys.exit()
infile = sys.argv[1]
@ -68,5 +69,5 @@ while ntimestep < nsteps:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -8,6 +8,7 @@
# Nfreq = dump and viz shapshot every this many steps
# Nsteps = run for this many steps
from __future__ import print_function
import sys
sys.path.append("./pizza")
@ -15,7 +16,7 @@ sys.path.append("./pizza")
argv = sys.argv
if len(argv) != 4:
print "Syntax: viz_gl.py in.lammps Nfreq Nsteps"
print("Syntax: viz_gl.py in.lammps Nfreq Nsteps")
sys.exit()
infile = sys.argv[1]
@ -48,7 +49,11 @@ ntimestep = 0
# just proc 0 handles reading of dump file and viz
if me == 0:
import Tkinter
tkroot = None
try:
import Tkinter
except:
import tkinter as Tkinter
tkroot = Tkinter.Tk()
tkroot.withdraw()
@ -79,5 +84,5 @@ while ntimestep < nsteps:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -8,6 +8,7 @@
# Nfreq = dump and viz shapshot every this many steps
# Nsteps = run for this many steps
from __future__ import print_function
import sys
sys.path.append("./pizza")
@ -15,7 +16,7 @@ sys.path.append("./pizza")
argv = sys.argv
if len(argv) != 4:
print "Syntax: viz_pymol.py in.lammps Nfreq Nsteps"
print("Syntax: viz_pymol.py in.lammps Nfreq Nsteps")
sys.exit()
infile = sys.argv[1]
@ -78,5 +79,5 @@ while ntimestep < nsteps:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -8,6 +8,7 @@
# Nfreq = dump and viz shapshot every this many steps
# Nsteps = run for this many steps
from __future__ import print_function
import sys
sys.path.append("./pizza")
@ -15,7 +16,7 @@ sys.path.append("./pizza")
argv = sys.argv
if len(argv) != 4:
print "Syntax: viz_vmd.py in.lammps Nfreq Nsteps"
print("Syntax: viz_vmd.py in.lammps Nfreq Nsteps")
sys.exit()
infile = sys.argv[1]
@ -82,10 +83,10 @@ if me == 0:
v.flush()
# uncomment the following, if you want to work with the viz some more.
#v('menu main on')
#print "type quit to terminate."
#print("type quit to terminate.")
#v.enter()
#v.stop()
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -12,6 +12,7 @@
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
# because I can't seem to do a MPI-style broadcast in Pypar
from __future__ import print_function
import sys,os,time
sys.path.append("./pizza")
@ -50,7 +51,7 @@ def update(ntimestep):
argv = sys.argv
if len(argv) != 4:
print "Syntax: vizplotgui_atomeye.py in.lammps Nfreq compute-ID"
print("Syntax: vizplotgui_atomeye.py in.lammps Nfreq compute-ID")
sys.exit()
infile = sys.argv[1]
@ -97,7 +98,10 @@ if me == 0:
# display GUI with run/stop buttons and slider for temperature
if me == 0:
from Tkinter import *
try:
from Tkinter import *
except:
from tkinter import *
tkroot = Tk()
tkroot.withdraw()
root = Toplevel(tkroot)
@ -161,5 +165,5 @@ while 1:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -12,6 +12,7 @@
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
# because I can't seem to do a MPI-style broadcast in Pypar
from __future__ import print_function
import sys,time
sys.path.append("./pizza")
@ -46,7 +47,7 @@ def update(ntimestep):
argv = sys.argv
if len(argv) != 4:
print "Syntax: vizplotgui_gl.py in.lammps Nfreq compute-ID"
print("Syntax: vizplotgui_gl.py in.lammps Nfreq compute-ID")
sys.exit()
infile = sys.argv[1]
@ -86,7 +87,10 @@ temptarget = 1.0
# just proc 0 handles reading of dump file and viz
if me == 0:
from Tkinter import *
try:
from Tkinter import *
except:
from tkinter import *
tkroot = Tk()
tkroot.withdraw()
@ -107,7 +111,10 @@ if me == 0:
# display GUI with run/stop buttons and slider for temperature
if me == 0:
from Tkinter import *
try:
from Tkinter import *
except:
from tkinter import *
tkroot = Tk()
tkroot.withdraw()
root = Toplevel(tkroot)
@ -171,5 +178,5 @@ while 1:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -12,6 +12,7 @@
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
# because I can't seem to do a MPI-style broadcast in Pypar
from __future__ import print_function
import sys,time
sys.path.append("./pizza")
@ -48,7 +49,7 @@ def update(ntimestep):
argv = sys.argv
if len(argv) != 4:
print "Syntax: vizplotgui_pymol.py in.lammps Nfreq compute-ID"
print("Syntax: vizplotgui_pymol.py in.lammps Nfreq compute-ID")
sys.exit()
infile = sys.argv[1]
@ -106,7 +107,10 @@ if me == 0:
# display GUI with run/stop buttons and slider for temperature
if me == 0:
from Tkinter import *
try:
from Tkinter import *
except:
from tkinter import *
tkroot = Tk()
tkroot.withdraw()
root = Toplevel(tkroot)
@ -170,5 +174,5 @@ while 1:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()

View File

@ -12,6 +12,7 @@
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
# because I can't seem to do a MPI-style broadcast in Pypar
from __future__ import print_function
import sys,time
sys.path.append("./pizza")
@ -47,7 +48,7 @@ def update(ntimestep):
argv = sys.argv
if len(argv) != 4:
print "Syntax: vizplotgui_vmd.py in.lammps Nfreq compute-ID"
print("Syntax: vizplotgui_vmd.py in.lammps Nfreq compute-ID")
sys.exit()
infile = sys.argv[1]
@ -105,7 +106,10 @@ if me == 0:
# display GUI with run/stop buttons and slider for temperature
if me == 0:
from Tkinter import *
try:
from Tkinter import *
except:
from tkinter import *
tkroot = Tk()
tkroot.withdraw()
root = Toplevel(tkroot)
@ -169,5 +173,5 @@ while 1:
lmp.command("run 0 pre no post yes")
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
#pypar.finalize()