more python 3 compatibility
This commit is contained in:
@ -16,7 +16,7 @@ from dump import dump
|
||||
from cfg import cfg
|
||||
|
||||
if len(sys.argv) != 8:
|
||||
raise StandardError, "Syntax: dump2cfg.py dumpfile Nid Ntype Nx Ny Nz cfgfile"
|
||||
sys.exit("Syntax: dump2cfg.py dumpfile Nid Ntype Nx Ny Nz cfgfile")
|
||||
|
||||
dumpfile = sys.argv[1]
|
||||
nid = int(sys.argv[2])
|
||||
|
||||
@ -18,7 +18,7 @@ from dump import dump
|
||||
from pdbfile import pdbfile
|
||||
|
||||
if len(sys.argv) != 8 and len(sys.argv) != 9:
|
||||
raise StandardError, "Syntax: dump2pdb.py dumpfile Nid Ntype Nx Ny Nz pdbfile template"
|
||||
sys.exit("Syntax: dump2pdb.py dumpfile Nid Ntype Nx Ny Nz pdbfile template")
|
||||
|
||||
dumpfile = sys.argv[1]
|
||||
nid = int(sys.argv[2])
|
||||
|
||||
@ -16,7 +16,7 @@ from dump import dump
|
||||
from xyz import xyz
|
||||
|
||||
if len(sys.argv) != 8:
|
||||
raise StandardError, "Syntax: dump2xyz.py dumpfile Nid Ntype Nx Ny Nz xyzfile"
|
||||
sys.exit("Syntax: dump2xyz.py dumpfile Nid Ntype Nx Ny Nz xyzfile")
|
||||
|
||||
dumpfile = sys.argv[1]
|
||||
nid = int(sys.argv[2])
|
||||
|
||||
@ -14,7 +14,7 @@ sys.path.append(path)
|
||||
from dump import dump
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
raise StandardError, "Syntax: dumpsort.py oldfile N newfile"
|
||||
sys.exit("Syntax: dumpsort.py oldfile N newfile")
|
||||
|
||||
oldfile = sys.argv[1]
|
||||
ncolumn = int(sys.argv[2])
|
||||
|
||||
@ -38,8 +38,7 @@ while iarg < narg:
|
||||
else: break
|
||||
|
||||
if iarg < narg or not outfile or not rfiles:
|
||||
print "Syntax: neb_combine.py -o outfile -b backfile -r dump1 dump2 ..."
|
||||
sys.exit()
|
||||
sys.exit("Syntax: neb_combine.py -o outfile -b backfile -r dump1 dump2 ...")
|
||||
|
||||
if os.path.exists(outfile): os.remove(outfile)
|
||||
|
||||
|
||||
@ -38,8 +38,7 @@ while iarg < narg:
|
||||
else: break
|
||||
|
||||
if iarg < narg or not outfile or not rfiles:
|
||||
print "Syntax: neb_final.py -o outfile -b backfile -r dump1 dump2 ..."
|
||||
sys.exit()
|
||||
sys.exit("Syntax: neb_final.py -o outfile -b backfile -r dump1 dump2 ...")
|
||||
|
||||
if os.path.exists(outfile): os.remove(outfile)
|
||||
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# cfg tool
|
||||
|
||||
oneline = "Convert LAMMPS snapshots to AtomEye CFG format"
|
||||
@ -65,33 +67,33 @@ class cfg:
|
||||
ylen = box[4]-box[1]
|
||||
zlen = box[5]-box[2]
|
||||
|
||||
print >>f,"Number of particles = %d " % len(atoms)
|
||||
print >>f,"# Timestep %d \n#\nA = 1.0 Angstrom" % time
|
||||
print >>f,"H0(1,1) = %20.10f A " % xlen
|
||||
print >>f,"H0(1,2) = 0.0 A "
|
||||
print >>f,"H0(1,3) = 0.0 A "
|
||||
print >>f,"H0(2,1) = 0.0 A "
|
||||
print >>f,"H0(2,2) = %20.10f A " % ylen
|
||||
print >>f,"H0(2,3) = 0.0 A "
|
||||
print >>f,"H0(3,1) = 0.0 A "
|
||||
print >>f,"H0(3,2) = 0.0 A "
|
||||
print >>f,"H0(3,3) = %20.10f A " % zlen
|
||||
print >>f,"#"
|
||||
print("Number of particles = %d " % len(atoms), file=f)
|
||||
print("# Timestep %d \n#\nA = 1.0 Angstrom" % time, file=f)
|
||||
print("H0(1,1) = %20.10f A " % xlen, file=f)
|
||||
print("H0(1,2) = 0.0 A ", file=f)
|
||||
print("H0(1,3) = 0.0 A ", file=f)
|
||||
print("H0(2,1) = 0.0 A ", file=f)
|
||||
print("H0(2,2) = %20.10f A " % ylen, file=f)
|
||||
print("H0(2,3) = 0.0 A ", file=f)
|
||||
print("H0(3,1) = 0.0 A ", file=f)
|
||||
print("H0(3,2) = 0.0 A ", file=f)
|
||||
print("H0(3,3) = %20.10f A " % zlen, file=f)
|
||||
print("#", file=f)
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
yfrac = (atom[3]-box[1])/ylen
|
||||
zfrac = (atom[4]-box[2])/zlen
|
||||
# print >>f,"1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7])
|
||||
print >>f,"1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac)
|
||||
# print("1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7]), file=f)
|
||||
print("1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac), file=f)
|
||||
|
||||
print time,
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
|
||||
f.close()
|
||||
print "\nwrote %d snapshots to %s in CFG format" % (n,file)
|
||||
print("\nwrote %d snapshots to %s in CFG format" % (n,file))
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -120,33 +122,33 @@ class cfg:
|
||||
ylen = box[4]-box[1]
|
||||
zlen = box[5]-box[2]
|
||||
|
||||
print >>f,"Number of particles = %d " % len(atoms)
|
||||
print >>f,"# Timestep %d \n#\nA = 1.0 Angstrom" % time
|
||||
print >>f,"H0(1,1) = %20.10f A " % xlen
|
||||
print >>f,"H0(1,2) = 0.0 A "
|
||||
print >>f,"H0(1,3) = 0.0 A "
|
||||
print >>f,"H0(2,1) = 0.0 A "
|
||||
print >>f,"H0(2,2) = %20.10f A " % ylen
|
||||
print >>f,"H0(2,3) = 0.0 A "
|
||||
print >>f,"H0(3,1) = 0.0 A "
|
||||
print >>f,"H0(3,2) = 0.0 A "
|
||||
print >>f,"H0(3,3) = %20.10f A " % zlen
|
||||
print >>f,"#"
|
||||
print("Number of particles = %d " % len(atoms), file=f)
|
||||
print("# Timestep %d \n#\nA = 1.0 Angstrom" % time, file=f)
|
||||
print("H0(1,1) = %20.10f A " % xlen, file=f)
|
||||
print("H0(1,2) = 0.0 A ", file=f)
|
||||
print("H0(1,3) = 0.0 A ", file=f)
|
||||
print("H0(2,1) = 0.0 A ", file=f)
|
||||
print("H0(2,2) = %20.10f A " % ylen, file=f)
|
||||
print("H0(2,3) = 0.0 A ", file=f)
|
||||
print("H0(3,1) = 0.0 A ", file=f)
|
||||
print("H0(3,2) = 0.0 A ", file=f)
|
||||
print("H0(3,3) = %20.10f A " % zlen, file=f)
|
||||
print("#", file=f)
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
yfrac = (atom[3]-box[1])/ylen
|
||||
zfrac = (atom[4]-box[2])/zlen
|
||||
# print >>f,"1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7])
|
||||
print >>f,"1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac)
|
||||
# print("1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7]), file=f)
|
||||
print("1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac), file=f)
|
||||
|
||||
print time,
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
f.close()
|
||||
n += 1
|
||||
|
||||
print "\nwrote %s snapshots in CFG format" % n
|
||||
print("\nwrote %s snapshots in CFG format" % n)
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -163,25 +165,25 @@ class cfg:
|
||||
ylen = box[4]-box[1]
|
||||
zlen = box[5]-box[2]
|
||||
|
||||
print >>f,"Number of particles = %d " % len(atoms)
|
||||
print >>f,"# Timestep %d \n#\nA = 1.0 Angstrom" % time
|
||||
print >>f,"H0(1,1) = %20.10f A " % xlen
|
||||
print >>f,"H0(1,2) = 0.0 A "
|
||||
print >>f,"H0(1,3) = 0.0 A "
|
||||
print >>f,"H0(2,1) = 0.0 A "
|
||||
print >>f,"H0(2,2) = %20.10f A " % ylen
|
||||
print >>f,"H0(2,3) = 0.0 A "
|
||||
print >>f,"H0(3,1) = 0.0 A "
|
||||
print >>f,"H0(3,2) = 0.0 A "
|
||||
print >>f,"H0(3,3) = %20.10f A " % zlen
|
||||
print >>f,"#"
|
||||
print("Number of particles = %d " % len(atoms), file=f)
|
||||
print("# Timestep %d \n#\nA = 1.0 Angstrom" % time, file=f)
|
||||
print("H0(1,1) = %20.10f A " % xlen, file=f)
|
||||
print("H0(1,2) = 0.0 A ", file=f)
|
||||
print("H0(1,3) = 0.0 A ", file=f)
|
||||
print("H0(2,1) = 0.0 A ", file=f)
|
||||
print("H0(2,2) = %20.10f A " % ylen, file=f)
|
||||
print("H0(2,3) = 0.0 A ", file=f)
|
||||
print("H0(3,1) = 0.0 A ", file=f)
|
||||
print("H0(3,2) = 0.0 A ", file=f)
|
||||
print("H0(3,3) = %20.10f A " % zlen, file=f)
|
||||
print("#", file=f)
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
yfrac = (atom[3]-box[1])/ylen
|
||||
zfrac = (atom[4]-box[2])/zlen
|
||||
# print >>f,"1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7])
|
||||
print >>f,"1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac)
|
||||
# print("1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7]), file=f)
|
||||
print("1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac), file=f)
|
||||
|
||||
f.close()
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# xyz tool
|
||||
|
||||
oneline = "Convert LAMMPS snapshots to XYZ format"
|
||||
@ -56,18 +58,18 @@ class xyz:
|
||||
if flag == -1: break
|
||||
time,box,atoms,bonds,tris,lines = self.data.viz(which)
|
||||
|
||||
print >>f,len(atoms)
|
||||
print >>f,"Atoms"
|
||||
print(len(atoms), file=f)
|
||||
print("Atoms", file=f)
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
print >>f,itype,atom[2],atom[3],atom[4]
|
||||
print(itype,atom[2],atom[3],atom[4], file=f)
|
||||
|
||||
print time,
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
|
||||
f.close()
|
||||
print "\nwrote %d snapshots to %s in XYZ format" % (n,file)
|
||||
print("\nwrote %d snapshots to %s in XYZ format" % (n,file))
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -91,17 +93,17 @@ class xyz:
|
||||
file = root + str(n)
|
||||
file += ".xyz"
|
||||
f = open(file,"w")
|
||||
print >>f,len(atoms)
|
||||
print >>f,"Atoms"
|
||||
print(len(atoms), file=f)
|
||||
print("Atoms", file=f)
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
print >>f,itype,atom[2],atom[3],atom[4]
|
||||
print time,
|
||||
print(itype,atom[2],atom[3],atom[4], file=f)
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
f.close()
|
||||
n += 1
|
||||
|
||||
print "\nwrote %s snapshots in XYZ format" % n
|
||||
print("\nwrote %s snapshots in XYZ format" % n)
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -113,9 +115,9 @@ class xyz:
|
||||
which = self.data.findtime(time)
|
||||
time,box,atoms,bonds,tris,lines = self.data.viz(which)
|
||||
f = open(file,"w")
|
||||
print >>f,len(atoms)
|
||||
print >>f,"Atoms"
|
||||
print(len(atoms), file=f)
|
||||
print("Atoms", file=f)
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
print >>f,itype,atom[2],atom[3],atom[4]
|
||||
print(itype,atom[2],atom[3],atom[4], file=f)
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user