Again, convert set of .xyz files into .data files to feed LAMMPS with.
This time I did it in Python and man, that was easier!
#!/usr/bin/env python
import sys, math
try:
infilename = sys.argv[1]; outfilename =sys.argv[2]
except:
print ("Error\nUsage:", sys.argv[0], "infile outfile"); sys.exit(1)
ifile = open(infilename, 'r')
ofile = open(outfilename, 'w')
xlo=0.
xhi=0.
atomtypes= 1
lines=ifile.readlines()
for line in lines:
pair=line.split()
if (line==lines[0]):
N=int(pair[0])
if (len(pair)==4 and pair[0][0]!='#'):
if (float(pair[1])>xhi):
xhi=float(pair[1])
if (float(pair[1])<xlo):
xlo=float(pair[1])
ofile.write("\n")
ofile.write ("%d atoms\n" %N)
ofile.write ("1 atom types\n")
ofile.write ("%g %g xlo xhi\n" %(xlo-20.,xhi+20.))
ofile.write ("%g %g ylo yhi\n" %(xlo-20.,xhi+20.))
ofile.write ("%g %g zlo zhi\n" %(xlo-20.,xhi+20.))
ofile.write("\nAtoms\n\n")
for i in range(2, len(lines)):
ofile.write (str(i-1) +" "+ lines[i])
print (xlo, xhi)
Nessun commento:
Posta un commento