header = "#Generated by %s using file %s\n t(ps) ISF \n"%(sys.argv[0].split("/")[-1],inputFile) if "OUTCAR" in inputFile: ocarFile = inputFile atomByteNums = outcarIO.atomBytes(ocarFile) nAtom = outcarIO.nAtoms(ocarFile) basis = outcarIO.basis(ocarFile) configIterator = parserGens.parseOutcarAtoms(atomByteNums,ocarFile,nAtom) atomsTime = [array(atoms) for atoms in configIterator] atomsTime = unwrap(atomsTime,basis) else: lmpFile = inputFile atomByteNums = lammpsIO.atomsBytes(lmpFile) nAtom = lammpsIO.nAtoms(lmpFile) basis = lammpsIO.basis(lmpFile) bounds=[[0,basis[0][0]],[0,basis[1][1]],[0,basis[2][2]]] configIterator = parserGens.parseLammpsAtoms(atomByteNums,lmpFile,nAtom) atomsTime = [array(atoms) for atoms in configIterator] bounds=[[0,basis[0][0]],[0,basis[1][1]],[0,basis[2][2]]] if len(crTime)+1 == nAtom: crTime=crTime[1:] #chop off the average if necessary if sh2Enable: rcut = 3.1 neighbs = secondShell( neighbors(array(atomsTime[-1]),bounds,rcut) ) ns = map(len,neighbs) crTime = [sum([crTime[j] for j in neighbs[i]])/ns[i] if ns[i]>0 else crTime[i] for i in range(len(neighbs))]
dumpFilename = fname+"lmp.dump" possibleSuffix = [i for i in possibleSuffix if os.path.isfile(fname+i)] print possibleSuffix ensembleHead = " ".join([i.strip(".") for i in possibleSuffix]) ensembles = None if len(possibleSuffix)>0: ensembles = [parserGens.parseEnsemble(fname+i) for i in possibleSuffix] if "OUTCAR" in fname: nAtoms = outcarIO.nAtoms(fname) basis = array(map(array,outcarIO.basis(fname))) bounds = [[0,basis[0][0]],[0,basis[1][1]],[0,basis[2][2]]] types = outcarIO.types(fname) #Find the starting locations of atomic data in outcarfile grepResults = subprocess.check_output("grep -b POSITION %s"%fname,shell=True).split("\n") bytenums=[int(i.split(":")[0]) for i in grepResults if len(i)>2] outcarParsed = parserGens.parseOutcarAtoms(bytenums,fname,nAtoms) lammpsIO.writeDump(dumpFilename,basis,types,outcarParsed,ensembles,ensembleHead) else: nAtoms = lammpsIO.nAtoms(fname) basis = lammpsIO.basis(fname) bounds = [[0,basis[0][0]],[0,basis[1][1]],[0,basis[2][2]]] b = lammpsIO.atomsBytes(fname) dummy,types = lammpsIO.parseAtoms(fname,b[0],nAtoms,basis) dumpParsed = parserGens.parseLammpsAtoms(b,fname,nAtoms) lammpsIO.writeDump(dumpFilename,basis,types,dumpParsed,ensembles,ensembleHead)