if len(sys.argv)==3: refStructure=int(sys.argv[2]) #First and last configurations dummy,dummy,basisFirst,atomsFirst,dummy,typesFirst = outcarIO.outcarReadConfig(outcarFile,wantconfig=0) dummy,dummy,basisLast,atomsLast,dummy,typesLast = outcarIO.outcarReadConfig(outcarFile,wantconfig=-1) #MSD delT,msdAtom=outcarMeanSquareDisplaceAtom(outcarFile,refStructure) #TET tetsFirst,rcutFirst=tetrahedral(atomsFirst,basisFirst,rcut=rcut) print "First Tetra/rcut",sum(tetsFirst)/len(tetsFirst),rcutFirst tetsLast,rcutLast=tetrahedral(atomsLast,basisLast,rcut=rcut) print "Last Tetra/rcut",sum(tetsLast)/len(tetsLast),rcutLast #CN cnFirst,rcutFirst=coordinationNumber(atomsFirst,basisFirst,rcut=rcut) print "First CN/rcut",float(sum(cnFirst))/len(cnFirst),rcutFirst cnLast,rcutLast=coordinationNumber(atomsLast,basisLast,rcut=rcut) print "Last CN/rcut",float(sum(cnLast))/len(cnLast),rcutLast wFile = open(outcarFile+".MSDatom","w") wFile.write("#File generated by %s\n"%sys.argv[0].split("/")[-1]) wFile.write("#%d atoms, %5.5f timestep size, %d number of steps\n"%(len(msdAtom),delT[0],len(delT))) wFile.write("msd$(\AA^2)$ tetraFirst tetraLast cnFirst cnLast\n") wFile.writelines([str(n[-1])+" "+str(t1)+" "+str(t2)+" "+str(cn1)+" "+str(cn2)+"\n" for n,t1,t2,cn1,cn2 in zip(msdAtom,tetsFirst,tetsLast,cnFirst,cnLast)]) wFile.close()
bytenums = [int(i.split(":")[0]) for i in grepResults if len(i) > 2] outcar = open(filename, "r") cnOut = open(filename + ".cn", "w") cnOut.write("AverageCN PerAtomCN\n") for i, b in enumerate(bytenums): outcar.seek(b) outcar.readline() outcar.readline() atoms = [ map(float, outcar.readline().split()[:3]) for a in range(nAtoms) ] cn, dummy = orderParam.coordinationNumber(atoms, basis, rcut=rcut) cnAvg = float(sum(cn)) / len(cn) cns = " ".join(map(str, cn)) cnOut.write(str(cnAvg) + " " + cns + "\n") if lammpsFlag: nAtoms = lammpsIO.nAtoms(filename) basisByteNums = lammpsIO.basisBytes(filename) atomsByteNums = lammpsIO.atomsBytes(filename) cnOut = open(filename + ".cn", "w") cnOut.write("AverageCN PerAtomCN\n") for i, (bByte, aByte) in enumerate(zip(basisByteNums, atomsByteNums)): basis = lammpsIO.parseBasis(filename, bByte) atoms, dummy = lammpsIO.parseAtoms(filename, aByte, nAtoms, basis)
#Find the starting locations of atomic data in filename grepResults = subprocess.check_output("grep -b POSITION %s"%filename,shell=True).split("\n") bytenums=[int(i.split(":")[0]) for i in grepResults if len(i)>2] outcar= open(filename,"r") cnOut =open(filename+".cn","w") cnOut.write("AverageCN PerAtomCN\n") for i,b in enumerate(bytenums): outcar.seek(b) outcar.readline() outcar.readline() atoms = [map(float,outcar.readline().split()[:3]) for a in range(nAtoms)] cn,dummy = orderParam.coordinationNumber(atoms,basis,rcut=rcut) cnAvg=float(sum(cn))/len(cn) cns=" ".join(map(str,cn)) cnOut.write(str(cnAvg)+" "+cns+"\n") if lammpsFlag: nAtoms = lammpsIO.nAtoms(filename) basisByteNums = lammpsIO.basisBytes(filename) atomsByteNums = lammpsIO.atomsBytes(filename) cnOut = open(filename+".cn","w") cnOut.write("AverageCN PerAtomCN\n") for i,(bByte,aByte) in enumerate(zip(basisByteNums,atomsByteNums)): basis = lammpsIO.parseBasis(filename,bByte) atoms,dummy = lammpsIO.parseAtoms(filename,aByte,nAtoms,basis)
dummy, dummy, basisFirst, atomsFirst, dummy, typesFirst = outcarIO.outcarReadConfig( outcarFile, wantconfig=0) dummy, dummy, basisLast, atomsLast, dummy, typesLast = outcarIO.outcarReadConfig( outcarFile, wantconfig=-1) #MSD delT, msdAtom = outcarMeanSquareDisplaceAtom(outcarFile, refStructure) #TET tetsFirst, rcutFirst = tetrahedral(atomsFirst, basisFirst, rcut=rcut) print "First Tetra/rcut", sum(tetsFirst) / len(tetsFirst), rcutFirst tetsLast, rcutLast = tetrahedral(atomsLast, basisLast, rcut=rcut) print "Last Tetra/rcut", sum(tetsLast) / len(tetsLast), rcutLast #CN cnFirst, rcutFirst = coordinationNumber(atomsFirst, basisFirst, rcut=rcut) print "First CN/rcut", float(sum(cnFirst)) / len(cnFirst), rcutFirst cnLast, rcutLast = coordinationNumber(atomsLast, basisLast, rcut=rcut) print "Last CN/rcut", float(sum(cnLast)) / len(cnLast), rcutLast wFile = open(outcarFile + ".MSDatom", "w") wFile.write("#File generated by %s\n" % sys.argv[0].split("/")[-1]) wFile.write("#%d atoms, %5.5f timestep size, %d number of steps\n" % (len(msdAtom), delT[0], len(delT))) wFile.write("msd$(\AA^2)$ tetraFirst tetraLast cnFirst cnLast\n") wFile.writelines([ str(n[-1]) + " " + str(t1) + " " + str(t2) + " " + str(cn1) + " " + str(cn2) + "\n" for n, t1, t2, cn1, cn2 in zip( msdAtom, tetsFirst, tetsLast, cnFirst, cnLast)