mirror of
https://github.com/ParticulateFlow/LPP.git
synced 2025-12-08 06:37:46 +00:00
python 3 compatibility for scripts/*.py files
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python
|
||||
|
||||
# Script: angle_distribute.py
|
||||
# Script: angle_distribute.py
|
||||
# Purpose: binned angle distributions by angle type
|
||||
# Syntax: angle_distribute.py datafile nbin theta_min theta_max outfile files ...
|
||||
# datafile = lammps data file
|
||||
@ -17,15 +17,14 @@
|
||||
import sys
|
||||
from dump import dump
|
||||
from math import sqrt,acos,atan
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 7:
|
||||
raise StandardError, \
|
||||
"Syntax: angle_distribute.py datafile nbin theta_min theta_max outfile files ..."
|
||||
raise Exception("Syntax: angle_distribute.py datafile nbin theta_min theta_max outfile files ...")
|
||||
|
||||
dt = data(argv[1])
|
||||
dt = data(argv[1])
|
||||
nbins = int(argv[2])
|
||||
theta_min = float(argv[3])
|
||||
theta_max = float(argv[4])
|
||||
@ -40,19 +39,19 @@ atype = nangles * [0]
|
||||
iatom = nangles * [0]
|
||||
jatom = nangles * [0]
|
||||
katom = nangles * [0]
|
||||
for i in xrange(nangles):
|
||||
for i in range(nangles):
|
||||
atype[i] = int(angle[i][1] - 1)
|
||||
iatom[i] = int(angle[i][2] - 1)
|
||||
jatom[i] = int(angle[i][3] - 1)
|
||||
katom[i] = int(angle[i][4] - 1)
|
||||
|
||||
ntypes = 0
|
||||
for i in xrange(nangles): ntypes = max(angle[i][1],ntypes)
|
||||
for i in range(nangles): ntypes = max(angle[i][1],ntypes)
|
||||
ntypes = int(ntypes)
|
||||
ncount = ntypes * [0]
|
||||
bin = nbins * [0]
|
||||
for i in xrange(nbins):
|
||||
bin[i] = ntypes * [0]
|
||||
for i in range(nbins):
|
||||
bin[i] = ntypes * [0]
|
||||
|
||||
# read snapshots one-at-a-time
|
||||
|
||||
@ -64,24 +63,24 @@ PI = 4.0*atan(1.0)
|
||||
while 1:
|
||||
time = d.next()
|
||||
if time == -1: break
|
||||
|
||||
|
||||
box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo,
|
||||
d.snaps[-1].xhi,d.snaps[-1].yhi,d.snaps[-1].zhi)
|
||||
|
||||
|
||||
xprd = box[3] - box[0]
|
||||
yprd = box[4] - box[1]
|
||||
yprd = box[4] - box[1]
|
||||
zprd = box[5] - box[2]
|
||||
|
||||
d.unscale()
|
||||
|
||||
d.unscale()
|
||||
d.sort()
|
||||
x,y,z = d.vecs(time,"x","y","z")
|
||||
|
||||
for i in xrange(nangles):
|
||||
|
||||
|
||||
for i in range(nangles):
|
||||
|
||||
delx1 = x[iatom[i]] - x[jatom[i]]
|
||||
dely1 = y[iatom[i]] - y[jatom[i]]
|
||||
delz1 = z[iatom[i]] - z[jatom[i]]
|
||||
|
||||
|
||||
if abs(delx1) > 0.5*xprd:
|
||||
if delx1 < 0.0:
|
||||
delx1 += xprd
|
||||
@ -97,13 +96,13 @@ while 1:
|
||||
delz1 += zprd
|
||||
else:
|
||||
delz1 -= zprd
|
||||
|
||||
|
||||
r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1)
|
||||
|
||||
|
||||
delx2 = x[katom[i]] - x[jatom[i]]
|
||||
dely2 = y[katom[i]] - y[jatom[i]]
|
||||
delz2 = z[katom[i]] - z[jatom[i]]
|
||||
|
||||
|
||||
if abs(delx2) > 0.5*xprd:
|
||||
if delx2 < 0.0:
|
||||
delx2 += xprd
|
||||
@ -119,38 +118,38 @@ while 1:
|
||||
delz2 += zprd
|
||||
else:
|
||||
delz2 -= zprd
|
||||
|
||||
|
||||
r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2)
|
||||
|
||||
|
||||
c = delx1*delx2 + dely1*dely2 + delz1*delz2
|
||||
c /= r1*r2
|
||||
|
||||
|
||||
if (c > 1.0): c = 1.0
|
||||
if (c < -1.0): c = -1.0
|
||||
|
||||
|
||||
theta = 180.0*acos(c)/PI
|
||||
|
||||
|
||||
ibin = int(nbins*(theta - theta_min)/(theta_max - theta_min) + 0.5)
|
||||
if ((ibin >= 0) and (ibin <= nbins-1)):
|
||||
if ((ibin >= 0) and (ibin <= nbins-1)):
|
||||
bin[ibin][atype[i]] += nbins
|
||||
ncount[atype[i]] += 1
|
||||
else:
|
||||
print "Warning: angle outside specified range"
|
||||
print "angle type:", atype[i]+1
|
||||
print "angle number:", i
|
||||
print time,
|
||||
|
||||
print
|
||||
print "Printing normalized angle distributions to",outfile
|
||||
|
||||
print("Warning: angle outside specified range")
|
||||
print("angle type:", atype[i]+1)
|
||||
print("angle number:", i)
|
||||
print(time, end=' ')
|
||||
|
||||
print()
|
||||
print("Printing normalized angle distributions to",outfile)
|
||||
|
||||
fp = open(outfile,"w")
|
||||
theta_range = theta_max - theta_min
|
||||
for i in xrange(nbins):
|
||||
print >>fp, theta_min + theta_range*float(i)/float(nbins),
|
||||
for j in xrange(ntypes):
|
||||
for i in range(nbins):
|
||||
print(theta_min + theta_range*float(i)/float(nbins), end=' ', file=fp)
|
||||
for j in range(ntypes):
|
||||
if (ncount[j] > 0):
|
||||
print >>fp, float(bin[i][j])/float(ncount[j])/theta_range,
|
||||
print(float(bin[i][j])/float(ncount[j])/theta_range, end=' ', file=fp)
|
||||
else:
|
||||
print >>fp, 0.0,
|
||||
print >>fp
|
||||
print(0.0, end=' ', file=fp)
|
||||
print(file=fp)
|
||||
fp.close()
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# Script: block.py
|
||||
# Purpose: thermodynamic block averages from LAMMPS log files
|
||||
# Syntax: block.py nblocks nskip log.1 log.2 ...
|
||||
# nblocks = number of blocks for block averages
|
||||
# nblocks = number of blocks for block averages
|
||||
# nskip = skip first nskip samples in the log file(s)
|
||||
# files = series of log files (LAMMPS thermo one style only)
|
||||
# Example: block.py 10 0 log.*
|
||||
@ -13,12 +13,12 @@
|
||||
|
||||
import sys
|
||||
from log import log
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 4:
|
||||
raise StandardError, "Syntax: block.py nblocks nskip log.1 log.2 ..."
|
||||
raise Exception("Syntax: block.py nblocks nskip log.1 log.2 ...")
|
||||
|
||||
nblocks = int(argv[1])
|
||||
nskip = int(argv[2])
|
||||
@ -35,24 +35,24 @@ if "Volume" in l.names:
|
||||
volume = l.get("Volume")
|
||||
else: vflag = 0
|
||||
|
||||
print "Computing %g block averages" % nblocks
|
||||
print "Skipping first %g samples" % nskip
|
||||
print("Computing %g block averages" % nblocks)
|
||||
print("Skipping first %g samples" % nskip)
|
||||
|
||||
n = len(step)
|
||||
n_per_block = (n-nskip)/nblocks
|
||||
k = nskip
|
||||
temperature_ave = []
|
||||
e_bond_ave = []
|
||||
e_pair_ave = []
|
||||
e_pair_ave = []
|
||||
e_total_ave = []
|
||||
pressure_ave = []
|
||||
volume_ave = []
|
||||
|
||||
print
|
||||
print " Block Samples Temperature E_bond E_pair", \
|
||||
" E_total Pressure Volume"
|
||||
print()
|
||||
print(" Block Samples Temperature E_bond E_pair", \
|
||||
" E_total Pressure Volume")
|
||||
|
||||
for i in xrange(nblocks):
|
||||
for i in range(nblocks):
|
||||
temperature_sum = 0
|
||||
e_bond_sum = 0
|
||||
e_pair_sum = 0
|
||||
@ -60,7 +60,7 @@ for i in xrange(nblocks):
|
||||
pressure_sum = 0
|
||||
volume_sum = 0
|
||||
samples = 0
|
||||
for j in xrange(n_per_block):
|
||||
for j in range(n_per_block):
|
||||
temperature_sum += temperature[k]
|
||||
e_bond_sum += e_bond[k]
|
||||
e_pair_sum += e_pair[k]
|
||||
@ -75,42 +75,42 @@ for i in xrange(nblocks):
|
||||
e_total_ave.append(e_total_sum/samples)
|
||||
pressure_ave.append(pressure_sum/samples)
|
||||
volume_ave.append(volume_sum/samples)
|
||||
print " %5i %10i %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f" % \
|
||||
print(" %5i %10i %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f" % \
|
||||
(i+1, samples, temperature_ave[i], e_bond_ave[i], e_pair_ave[i], \
|
||||
e_total_ave[i], pressure_ave[i], volume_ave[i])
|
||||
e_total_ave[i], pressure_ave[i], volume_ave[i]))
|
||||
|
||||
grand_ave_temperature = 0.0
|
||||
grand_ave_e_bond = 0.0
|
||||
grand_ave_e_pair = 0.0
|
||||
grand_ave_e_total = 0.0
|
||||
grand_ave_pressure = 0.0
|
||||
grand_ave_volume = 0.0
|
||||
grand_ave_volume = 0.0
|
||||
stdev_temperature = 0.0
|
||||
stdev_e_bond = 0.0
|
||||
stdev_e_pair = 0.0
|
||||
stdev_e_total = 0.0
|
||||
stdev_pressure = 0.0
|
||||
stdev_volume = 0.0
|
||||
for i in xrange(nblocks):
|
||||
stdev_volume = 0.0
|
||||
for i in range(nblocks):
|
||||
grand_ave_temperature += temperature_ave[i]
|
||||
grand_ave_e_bond += e_bond_ave[i]
|
||||
grand_ave_e_pair += e_pair_ave[i]
|
||||
grand_ave_e_total += e_total_ave[i]
|
||||
grand_ave_pressure += pressure_ave[i]
|
||||
grand_ave_volume += volume_ave[i]
|
||||
grand_ave_volume += volume_ave[i]
|
||||
grand_ave_temperature /= nblocks
|
||||
grand_ave_e_bond /= nblocks
|
||||
grand_ave_e_pair /= nblocks
|
||||
grand_ave_e_total /= nblocks
|
||||
grand_ave_pressure /= nblocks
|
||||
grand_ave_volume /= nblocks
|
||||
for i in xrange(nblocks):
|
||||
grand_ave_volume /= nblocks
|
||||
for i in range(nblocks):
|
||||
stdev_temperature += (temperature_ave[i] - grand_ave_temperature)* \
|
||||
(temperature_ave[i] - grand_ave_temperature)
|
||||
stdev_e_bond += (e_bond_ave[i] - grand_ave_e_bond)* \
|
||||
(e_bond_ave[i] - grand_ave_e_bond)
|
||||
stdev_e_pair += (e_pair_ave[i] - grand_ave_e_pair)* \
|
||||
(e_pair_ave[i] - grand_ave_e_pair)
|
||||
(e_pair_ave[i] - grand_ave_e_pair)
|
||||
stdev_e_total += (e_total_ave[i] - grand_ave_e_total)* \
|
||||
(e_total_ave[i] - grand_ave_e_total)
|
||||
stdev_pressure += (pressure_ave[i] - grand_ave_pressure)* \
|
||||
@ -123,15 +123,15 @@ stdev_e_bond = sqrt(stdev_e_bond/(nblocks-1))
|
||||
stdev_e_pair = sqrt(stdev_e_pair/(nblocks-1))
|
||||
stdev_e_total = sqrt(stdev_e_total/(nblocks-1))
|
||||
stdev_pressure = sqrt(stdev_pressure/(nblocks-1))
|
||||
stdev_volume = sqrt(stdev_volume/(nblocks-1))
|
||||
stdev_volume = sqrt(stdev_volume/(nblocks-1))
|
||||
|
||||
print " ====================================================", \
|
||||
"==================================="
|
||||
|
||||
print " Ave. %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f" % \
|
||||
print(" ====================================================", \
|
||||
"===================================")
|
||||
|
||||
print(" Ave. %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f" % \
|
||||
(grand_ave_temperature, grand_ave_e_bond, grand_ave_e_pair, \
|
||||
grand_ave_e_total, grand_ave_pressure, grand_ave_volume)
|
||||
|
||||
print " Stdev %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f" % \
|
||||
grand_ave_e_total, grand_ave_pressure, grand_ave_volume))
|
||||
|
||||
print(" Stdev %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f" % \
|
||||
(stdev_temperature, stdev_e_bond, stdev_e_pair, \
|
||||
stdev_e_total, stdev_pressure, stdev_volume)
|
||||
stdev_e_total, stdev_pressure, stdev_volume))
|
||||
|
||||
@ -17,13 +17,12 @@
|
||||
import sys
|
||||
from dump import dump
|
||||
from math import sqrt
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 7:
|
||||
raise StandardError, \
|
||||
"Syntax: bond_distribute.py datafile nbin rmin rmax outfile files ..."
|
||||
raise Exception("Syntax: bond_distribute.py datafile nbin rmin rmax outfile files ...")
|
||||
|
||||
dt = data(argv[1])
|
||||
nbins = int(argv[2])
|
||||
@ -39,17 +38,17 @@ nbonds = len(bond)
|
||||
btype = nbonds * [0]
|
||||
iatom = nbonds * [0]
|
||||
jatom = nbonds * [0]
|
||||
for i in xrange(nbonds):
|
||||
for i in range(nbonds):
|
||||
btype[i] = int(bond[i][1] - 1)
|
||||
iatom[i] = int(bond[i][2] - 1)
|
||||
jatom[i] = int(bond[i][3] - 1)
|
||||
|
||||
ntypes = 0
|
||||
for i in xrange(nbonds): ntypes = max(bond[i][1],ntypes)
|
||||
for i in range(nbonds): ntypes = max(bond[i][1],ntypes)
|
||||
ntypes = int(ntypes)
|
||||
ncount = ntypes * [0]
|
||||
bin = nbins * [0]
|
||||
for i in xrange(nbins):
|
||||
for i in range(nbins):
|
||||
bin[i] = ntypes * [0]
|
||||
|
||||
# read snapshots one-at-a-time
|
||||
@ -72,7 +71,7 @@ while 1:
|
||||
d.sort()
|
||||
x,y,z = d.vecs(time,"x","y","z")
|
||||
|
||||
for i in xrange(nbonds):
|
||||
for i in range(nbonds):
|
||||
|
||||
delx = x[jatom[i]] - x[iatom[i]]
|
||||
dely = y[jatom[i]] - y[iatom[i]]
|
||||
@ -101,22 +100,22 @@ while 1:
|
||||
bin[ibin][btype[i]] += nbins
|
||||
ncount[btype[i]] += 1
|
||||
else:
|
||||
print "Warning: bond distance outside specified range"
|
||||
print "Bond type:", btype[i]+1
|
||||
print "Bond number:", i
|
||||
print time,
|
||||
print("Warning: bond distance outside specified range")
|
||||
print("Bond type:", btype[i]+1)
|
||||
print("Bond number:", i)
|
||||
print(time, end=' ')
|
||||
|
||||
print
|
||||
print "Printing bond distance normalized distribution to",outfile
|
||||
print()
|
||||
print("Printing bond distance normalized distribution to",outfile)
|
||||
|
||||
fp = open(outfile,"w")
|
||||
rrange = rmax - rmin
|
||||
for i in xrange(nbins):
|
||||
print >>fp, rmin + rrange*float(i)/float(nbins),
|
||||
for j in xrange(ntypes):
|
||||
for i in range(nbins):
|
||||
print(rmin + rrange*float(i)/float(nbins), end=' ', file=fp)
|
||||
for j in range(ntypes):
|
||||
if (ncount[j] > 0):
|
||||
print >>fp, float(bin[i][j])/float(ncount[j])/rrange,
|
||||
print(float(bin[i][j])/float(ncount[j])/rrange, end=' ', file=fp)
|
||||
else:
|
||||
print >>fp, 0.0,
|
||||
print >>fp
|
||||
print(0.0, end=' ', file=fp)
|
||||
print(file=fp)
|
||||
fp.close()
|
||||
|
||||
@ -15,18 +15,18 @@ from clog import clog
|
||||
from plotview import plotview
|
||||
from gnu import gnu
|
||||
from matlab import matlab
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 3:
|
||||
raise StandardError, "Syntax: clogview.py gnu/matlab files ..."
|
||||
raise Exception("Syntax: clogview.py gnu/matlab files ...")
|
||||
|
||||
style = argv[1]
|
||||
files = ' '.join(argv[2:])
|
||||
|
||||
c = clog(files)
|
||||
exec "plot = %s()" % style
|
||||
exec("plot = %s()" % style)
|
||||
p = plotview(c,plot)
|
||||
p.x = "Time"
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
import sys
|
||||
from dump import dump
|
||||
from gnu import gnu
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
@ -62,7 +62,7 @@ def distance(atom1,atom2,box):
|
||||
# main script
|
||||
|
||||
if len(argv) < 6:
|
||||
raise StandardError,"cluster.py type1 type2 cutoff nbin dump.1 dump.2 ..."
|
||||
raise Exception("cluster.py type1 type2 cutoff nbin dump.1 dump.2 ...")
|
||||
|
||||
type1 = int(argv[1])
|
||||
type2 = int(argv[2])
|
||||
@ -81,20 +81,20 @@ d.aselect.test("$type == %d or $type == %d" % (type1,type2))
|
||||
cutsq = cutoff*cutoff
|
||||
cluster = nbin*[0]
|
||||
|
||||
print "Clustering ..."
|
||||
print("Clustering ...")
|
||||
|
||||
flag = 0
|
||||
while 1:
|
||||
which,time,flag = d.iterator(flag)
|
||||
if flag == -1: break
|
||||
time,box,atoms,bonds,tris = d.viz(which)
|
||||
print time,
|
||||
print(time, end=' ')
|
||||
sys.stdout.flush()
|
||||
|
||||
# loop over all type1 atoms
|
||||
|
||||
n = len(atoms)
|
||||
for i in xrange(n):
|
||||
for i in range(n):
|
||||
itype = atoms[i][1]
|
||||
if itype != type1: continue
|
||||
ncount = 0
|
||||
@ -102,7 +102,7 @@ while 1:
|
||||
# loop over all type2 atoms
|
||||
# increment cluster count if distance is within cutoff
|
||||
|
||||
for j in xrange(n):
|
||||
for j in range(n):
|
||||
jtype = atoms[j][1]
|
||||
if jtype != type2 or i == j: continue
|
||||
distsq = distance(atoms[i],atoms[j],box)
|
||||
@ -113,9 +113,9 @@ while 1:
|
||||
if ncount >= nbin: cluster[nbin-1] += 1
|
||||
else: cluster[ncount] += 1
|
||||
|
||||
print
|
||||
print "Cluster size and count:"
|
||||
for i in range(nbin): print i,cluster[i]
|
||||
print()
|
||||
print("Cluster size and count:")
|
||||
for i in range(nbin): print(i,cluster[i])
|
||||
|
||||
# comment out if don't want plot
|
||||
|
||||
|
||||
@ -14,12 +14,12 @@
|
||||
|
||||
import sys
|
||||
from dump import dump
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 5:
|
||||
raise StandardError, "Syntax: density.py x/y/z nbin outfile files ..."
|
||||
raise Exception("Syntax: density.py x/y/z nbin outfile files ...")
|
||||
|
||||
direction = argv[1]
|
||||
nbins = int(argv[2])
|
||||
@ -41,7 +41,7 @@ while 1:
|
||||
tmp,ntypes = d.minmax("type")
|
||||
ntypes = int(ntypes)
|
||||
bin = nbins * [0]
|
||||
for i in xrange(nbins): bin[i] = ntypes * [0]
|
||||
for i in range(nbins): bin[i] = ntypes * [0]
|
||||
first = 0
|
||||
|
||||
box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo,
|
||||
@ -52,26 +52,26 @@ while 1:
|
||||
elif direction == "y": type,x = d.vecs(time,"type","y")
|
||||
elif direction == "z": type,x = d.vecs(time,"type","z")
|
||||
|
||||
type = map(int,type)
|
||||
type = list(map(int,type))
|
||||
natoms = len(type)
|
||||
for i in xrange(natoms): type[i] -= 1
|
||||
for i in range(natoms): type[i] -= 1
|
||||
|
||||
for i in xrange(natoms):
|
||||
for i in range(natoms):
|
||||
ibin = int(nbins*x[i] + 0.5)
|
||||
if (ibin < 0): ibin += nbins
|
||||
if (ibin > nbins-1): ibin -= nbins
|
||||
bin[ibin][type[i]] += nbins/vol
|
||||
nsnaps += 1
|
||||
print time,
|
||||
print(time, end=' ')
|
||||
|
||||
print
|
||||
print "Printing ", direction, "-directional density distribution in mol/L to",outfile
|
||||
print()
|
||||
print("Printing ", direction, "-directional density distribution in mol/L to",outfile)
|
||||
conversion = 1660.53873 # convert from atoms/Angs^3 to mol/L
|
||||
|
||||
fp = open(outfile,"w")
|
||||
for i in xrange(nbins):
|
||||
print >>fp, float(i)/float(nbins),
|
||||
for j in xrange(ntypes):
|
||||
print >>fp, conversion*bin[i][j]/nsnaps,
|
||||
print >>fp
|
||||
for i in range(nbins):
|
||||
print(float(i)/float(nbins), end=' ', file=fp)
|
||||
for j in range(ntypes):
|
||||
print(conversion*bin[i][j]/nsnaps, end=' ', file=fp)
|
||||
print(file=fp)
|
||||
fp.close()
|
||||
|
||||
@ -18,12 +18,12 @@
|
||||
import sys
|
||||
import numpy as np
|
||||
from dump import dump
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 5:
|
||||
raise StandardError, "Syntax: density.py x/y/z nbin vmin vmax outfile files ..."
|
||||
raise Exception("Syntax: density.py x/y/z nbin vmin vmax outfile files ...")
|
||||
|
||||
direction = argv[1]
|
||||
nbins = int(argv[2])
|
||||
@ -102,11 +102,11 @@ while 1:
|
||||
zmin = max(zmin,box[0])
|
||||
vol = dx * dy * float(zmax - zmin)
|
||||
|
||||
type = map(int,type)
|
||||
type = list(map(int,type))
|
||||
natoms = len(type)
|
||||
for i in xrange(natoms): type[i] -= 1
|
||||
for i in range(natoms): type[i] -= 1
|
||||
|
||||
for i in xrange(natoms):
|
||||
for i in range(natoms):
|
||||
ibin = int(nbins*x[i])
|
||||
jbin = int(nbins*y[i])
|
||||
zloc = float(z[i])*float(dz)
|
||||
@ -117,10 +117,10 @@ while 1:
|
||||
if (jbin > nbins-1): jbin = nbins - 1
|
||||
bin[jbin][ibin][type[i]] += nbins*nbins/vol
|
||||
nsnaps += 1
|
||||
print time,
|
||||
print(time, end=' ')
|
||||
|
||||
print
|
||||
print "Printing %s-mapped density distribution for %s-slice [%.2f,%.2f] in mol/L to %s" %(bidirect, direction, zmin, zmax, outfile)
|
||||
print()
|
||||
print("Printing %s-mapped density distribution for %s-slice [%.2f,%.2f] in mol/L to %s" %(bidirect, direction, zmin, zmax, outfile))
|
||||
conversion = 1660.53873 # convert from atoms/Angs^3 to mol/L
|
||||
|
||||
fp = open(outfile,"w")
|
||||
@ -129,10 +129,10 @@ fp = open(outfile,"w")
|
||||
# for k in xrange(ntypes):
|
||||
# print >>fp, " %8s " %(k),
|
||||
# print >>fp
|
||||
for i in xrange(nbins):
|
||||
for j in xrange(nbins):
|
||||
print >>fp, " %8.3f %8.3f " %(float(i)/float(nbins)*float(dx)+float(x0), float(j)/float(nbins)*float(dy)+float(y0)),
|
||||
for k in xrange(ntypes):
|
||||
print >>fp, " %8.3f " % (conversion*bin[j][i][k]/nsnaps),
|
||||
print >>fp
|
||||
for i in range(nbins):
|
||||
for j in range(nbins):
|
||||
print(" %8.3f %8.3f " %(float(i)/float(nbins)*float(dx)+float(x0), float(j)/float(nbins)*float(dy)+float(y0)), end=' ', file=fp)
|
||||
for k in range(ntypes):
|
||||
print(" %8.3f " % (conversion*bin[j][i][k]/nsnaps), end=' ', file=fp)
|
||||
print(file=fp)
|
||||
fp.close()
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
|
||||
import sys
|
||||
from dump import dump
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 5:
|
||||
raise StandardError, "Syntax: density.py x/y/z nbin outfile files ..."
|
||||
raise Exception("Syntax: density.py x/y/z nbin outfile files ...")
|
||||
|
||||
direction = argv[1]
|
||||
nbins = int(argv[2])
|
||||
@ -44,7 +44,7 @@ while 1:
|
||||
tmp,ntypes = d.minmax("type")
|
||||
ntypes = int(ntypes)
|
||||
bin = nbins * [0]
|
||||
for i in xrange(nbins): bin[i] = ntypes * [0]
|
||||
for i in range(nbins): bin[i] = ntypes * [0]
|
||||
first = 0
|
||||
|
||||
box = (d.snaps[-1].xlo,d.snaps[-1].ylo,d.snaps[-1].zlo,
|
||||
@ -55,21 +55,21 @@ while 1:
|
||||
elif direction == "y": type,x = d.vecs(time,"type","y")
|
||||
elif direction == "z": type,x = d.vecs(time,"type","z")
|
||||
|
||||
type = map(int,type)
|
||||
type = list(map(int,type))
|
||||
natoms = len(type)
|
||||
for i in xrange(natoms): type[i] -= 1
|
||||
for i in range(natoms): type[i] -= 1
|
||||
|
||||
for i in xrange(natoms):
|
||||
for i in range(natoms):
|
||||
ibin = int(nbins*x[i] + 0.5)
|
||||
if (ibin < 0): ibin += nbins
|
||||
if (ibin > nbins-1): ibin -= nbins
|
||||
bin[ibin][type[i]] += nbins/vol
|
||||
nsnaps += 1
|
||||
print time,
|
||||
print(time, end=' ')
|
||||
|
||||
print
|
||||
print "Printing ",direction,"-directional density distribution in mol/L to", \
|
||||
outfile
|
||||
print()
|
||||
print("Printing ",direction,"-directional density distribution in mol/L to", \
|
||||
outfile)
|
||||
conversion = 1660.53873 # convert from atoms/Angs^3 to mol/L
|
||||
|
||||
# Output as x, density_1, area_1, ...
|
||||
@ -78,20 +78,20 @@ fp = open(outfile,"w")
|
||||
first = 1
|
||||
xden = nbins * [0]
|
||||
yden = nbins * [0]
|
||||
for i in xrange(nbins): yden[i] = ntypes * [0]
|
||||
for i in range(nbins): yden[i] = ntypes * [0]
|
||||
sum = ntypes * [0]
|
||||
for i in xrange(nbins):
|
||||
for i in range(nbins):
|
||||
xden[i] = float(i)/float(nbins)
|
||||
print >>fp, xden[i],
|
||||
print(xden[i], end=' ', file=fp)
|
||||
if first:
|
||||
for j in xrange(ntypes):
|
||||
for j in range(ntypes):
|
||||
yden[i][j] = conversion*bin[i][j]/nsnaps
|
||||
print >>fp, yden[i][j], sum[j],
|
||||
print(yden[i][j], sum[j], end=' ', file=fp)
|
||||
first = 0
|
||||
else:
|
||||
for j in xrange(ntypes):
|
||||
for j in range(ntypes):
|
||||
yden[i][j] = conversion*bin[i][j]/nsnaps
|
||||
sum[j] += 0.5 * (xden[i] - xden[i-1]) * (yden[i][j] + yden[i-1][j])
|
||||
print >>fp, yden[i][j], sum[j],
|
||||
print >>fp
|
||||
print(yden[i][j], sum[j], end=' ', file=fp)
|
||||
print(file=fp)
|
||||
fp.close()
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
from math import sqrt
|
||||
|
||||
if len(argv) < 3:
|
||||
raise StandardError,"distance.py maxcut dump.file1 dump.file2 ..."
|
||||
raise Exception("distance.py maxcut dump.file1 dump.file2 ...")
|
||||
|
||||
maxcut = float(argv[1])
|
||||
maxcut_sq = maxcut*maxcut
|
||||
@ -36,8 +36,8 @@ while 1:
|
||||
yprd = box[4] - box[1]
|
||||
zprd = box[5] - box[2]
|
||||
|
||||
for i in xrange(n):
|
||||
for j in xrange(i+1,n):
|
||||
for i in range(n):
|
||||
for j in range(i+1,n):
|
||||
|
||||
delx = x[j] - x[i]
|
||||
if abs(delx) > 0.5*xprd:
|
||||
@ -65,11 +65,11 @@ while 1:
|
||||
rsq = delx*delx + dely*dely + delz*delz
|
||||
|
||||
if rsq < maxcut_sq:
|
||||
print "time = %d, id[i] = %d, id[j] = %d," \
|
||||
print("time = %d, id[i] = %d, id[j] = %d," \
|
||||
" type[i] = %d, type[j] = %d, distance = %g" % \
|
||||
(time, id[i], id[j], type[i], type[j], sqrt(rsq))
|
||||
(time, id[i], id[j], type[i], type[j], sqrt(rsq)))
|
||||
|
||||
d.tselect.none()
|
||||
d.tselect.one(time)
|
||||
print "timestep = ", time
|
||||
print("timestep = ", time)
|
||||
d.delete()
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
# main script
|
||||
|
||||
if len(argv) < 2:
|
||||
raise StandardError, "Syntax: dview.py dump.1 ..."
|
||||
raise Exception("Syntax: dview.py dump.1 ...")
|
||||
|
||||
files = ' '.join(argv[1:])
|
||||
|
||||
|
||||
@ -13,18 +13,18 @@ import sys
|
||||
from dump import dump
|
||||
|
||||
# w/out Pizza.py these lines need to come before import of gl tool
|
||||
import Tkinter
|
||||
tkroot = Tkinter.Tk()
|
||||
import tkinter
|
||||
tkroot = tkinter.Tk()
|
||||
tkroot.withdraw()
|
||||
|
||||
from gl import gl
|
||||
from vcr import vcr
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 2:
|
||||
raise StandardError, "Syntax: dview.py dump.1 ..."
|
||||
raise Exception("Syntax: dview.py dump.1 ...")
|
||||
|
||||
files = ' '.join(argv[1:])
|
||||
|
||||
|
||||
@ -14,12 +14,12 @@
|
||||
|
||||
import sys
|
||||
from dump import dump
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 5:
|
||||
raise StandardError, "Syntax: flux.py x/y/z plane outfile files ..."
|
||||
raise Exception("Syntax: flux.py x/y/z plane outfile files ...")
|
||||
|
||||
direction = argv[1]
|
||||
scaled_plane = float(argv[2])
|
||||
@ -58,7 +58,7 @@ while 1:
|
||||
prd = hi - lo
|
||||
plane = lo + scaled_plane*prd
|
||||
|
||||
print time,
|
||||
print(time, end=' ')
|
||||
sys.stdout.flush()
|
||||
|
||||
natoms = len(x)
|
||||
@ -67,7 +67,7 @@ while 1:
|
||||
|
||||
typeflux = ntypes * [0]
|
||||
|
||||
for i in xrange(natoms):
|
||||
for i in range(natoms):
|
||||
id[i] = int(id[i])
|
||||
type[i] = int(type[i])
|
||||
if jconfig == 1: x_initial[id[i]] = x[i]
|
||||
@ -78,10 +78,10 @@ while 1:
|
||||
crossings = int((plane - x[i])/prd) + 1
|
||||
typeflux[type[i]] -= crossings
|
||||
|
||||
print >>f,time,
|
||||
for j in xrange(ntypes-1):
|
||||
print >>f,typeflux[j+1],
|
||||
print >>f
|
||||
print
|
||||
print(time, end=' ', file=f)
|
||||
for j in range(ntypes-1):
|
||||
print(typeflux[j+1], end=' ', file=f)
|
||||
print(file=f)
|
||||
print()
|
||||
|
||||
f.close()
|
||||
|
||||
@ -11,10 +11,10 @@
|
||||
|
||||
import sys
|
||||
from animate import animate
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
# this could be done with one-line alias in shell start-up file
|
||||
|
||||
if len(argv) < 2: raise StandardError, "Syntax: iview.py files ..."
|
||||
if len(argv) < 2: raise Exception("Syntax: iview.py files ...")
|
||||
a = animate(' '.join(argv[1:]))
|
||||
|
||||
@ -15,17 +15,17 @@ from log import log
|
||||
from plotview import plotview
|
||||
from gnu import gnu
|
||||
from matlab import matlab
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 3:
|
||||
raise StandardError, "Syntax: logview.py gnu/matlab files ..."
|
||||
raise Exception("Syntax: logview.py gnu/matlab files ...")
|
||||
|
||||
style = argv[1]
|
||||
files = ' '.join(argv[2:])
|
||||
|
||||
lg = log(files)
|
||||
exec "plot = %s()" % style
|
||||
exec("plot = %s()" % style)
|
||||
p = plotview(lg,plot)
|
||||
|
||||
|
||||
@ -15,12 +15,12 @@ import sys
|
||||
from dump import dump
|
||||
from raster import raster
|
||||
from svg import svg
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) < 5:
|
||||
raise StandardError, "Syntax: movie.py raster/svg theta phi dump.1 ..."
|
||||
raise Exception("Syntax: movie.py raster/svg theta phi dump.1 ...")
|
||||
|
||||
style = argv[1]
|
||||
theta = float(argv[2])
|
||||
@ -28,6 +28,6 @@ phi = float(argv[3])
|
||||
files = ' '.join(argv[4:])
|
||||
|
||||
d = dump(files)
|
||||
exec "viz = %s(d)" % style
|
||||
exec("viz = %s(d)" % style)
|
||||
viz.rotate(theta,phi)
|
||||
viz.all()
|
||||
|
||||
@ -14,17 +14,17 @@ import sys
|
||||
from plotview import plotview
|
||||
from gnu import gnu
|
||||
from matlab import matlab
|
||||
if not globals().has_key("argv"): argv = sys.argv
|
||||
if "argv" not in globals(): argv = sys.argv
|
||||
|
||||
# main script
|
||||
|
||||
if len(argv) != 3:
|
||||
raise StandardError, "Syntax: plot.py gnu/matlab file"
|
||||
raise Exception("Syntax: plot.py gnu/matlab file")
|
||||
|
||||
style = argv[1]
|
||||
file = argv[2]
|
||||
|
||||
v = vec(file)
|
||||
exec "plot = %s()" % style
|
||||
exec("plot = %s()" % style)
|
||||
p = plotview(v,plot)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user