sh2Enable = True sys.argv.pop(i) #Parse Args inputFile = sys.argv[1] isfType = "total" if sys.argv[2][0] in ['s','S']: isfType = "self" else: isfType = "total" criteria = sys.argv[3] criteFile = sys.argv[4] configIterator = parserGens.parseEnsemble(criteFile) crTime = array([cr for cr in configIterator][-1]) criteriaTxt = criteria.replace("gt",">") criteriaTxt = criteria.replace("lt","<") if scale == None: if "OUTCAR" in inputFile: scale = 5E-15 #5fs (potim=5) else: scale = 0.001E-12 #0.001ps (default for units = metal) if logtEnable: header = "#Generated by %s using file %s\n log(t) ISF \n"%(sys.argv[0].split("/")[-1],inputFile) else: header = "#Generated by %s using file %s\n t(ps) ISF \n"%(sys.argv[0].split("/")[-1],inputFile)
sys.argv.remove("-logt") logtEnable = True if "-scale" in sys.argv: i = sys.argv.index("-scale") scale = float(sys.argv[i+1]) sys.argv.pop(i) sys.argv.pop(i) if "-nStep" in sys.argv: i = sys.argv.index("-nStep") nStep = int(sys.argv[i+1]) sys.argv.pop(i) sys.argv.pop(i) inputFile = sys.argv[1] criteria = sys.argv[3] configIterator = parserGens.parseEnsemble(inputFile+".rmsd") rmsdTime = array([rmsd for rmsd in configIterator][-1]) isfType = "total" if sys.argv[2][0] in ['s','S']: isfType = "self" else: isfType = "total" if scale == None: if "OUTCAR" in inputFile: scale = 5E-15 #5fs (potim=5) else: scale = 0.001E-12 #0.001ps (default for units = metal) if "OUTCAR" in inputFile:
import lammpsIO import parserGens import utils possibleSuffix = [".rmsd",".cn",".tetra",".rmsd50",".rmsd100",".rmsd1000",".rmsd5000",".rmsd10000",".2shelltetra",".2shellcn",".2shellrmsd100",".tetra.avg1000",".tetra.avg5000",".tetra.avg100",".tetra.avg500"] utils.usage(["<outcar,lamps dump>"],1,1,"Note: Automatically looks for <OUTCAR/dump.suffix> for per atom ensembles. to include in the dump") fname = sys.argv[1] 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:
utils.usage(["<.ensembleFile>","<window size (int or all)>"],2,2) inputFile = sys.argv[1] possibleSuffixes = [".tetra",".rmsd",".cn"] if not any([suffix for suffix in possibleSuffixes if suffix in inputFile]): print "wrong input file dummy." exit(0) windowSize = sys.argv[2] outputFile = inputFile+".avg"+windowSize #assume first line is a header head = open(inputFile,"r").readline() configIterator = parserGens.parseEnsemble(inputFile,keepAvg=True) ops = zip(*[a for a in configIterator]) if windowSize == "all": opAvg = [sum(op)/len(op) for op in ops] opLines = [" ".join(map(str,opAvg))+"\n"] else: windowSize = int(windowSize) opAvg = zip(*[datatools.wsmooth(atet,windowSize) for atet in ops]) opLines = [" ".join(map(str,line))+"\n" for line in opAvg] out = open(outputFile,"w") out.write(head) out.writelines(opLines)
#!/usr/bin/python import sys import itertools #mine import utils,parserGens,datatools utils.usage(["<file.neighbs>","<ensemble file (tetra, cn, rmsd, w/e)>"],2,2) neighbFile = sys.argv[1] ensembFile = sys.argv[2] neighbGen = parserGens.parseNeighbor(neighbFile) ensembGen = parserGens.parseEnsemble(ensembFile) #secondShellEnsemb=list() efp = ensembFile.split(".") outfile = ".".join(efp[0:-1]) + ".2shell" + efp[-1] out = open(outfile,"w") out.write("2ndShellAvg%s 2ndShellPerAtom%s\n"%(efp[1],efp[1])) stopFlag=False for ensembG,neighbG in itertools.izip(ensembGen,neighbGen): secondShellEnsemb = list() for a,firstNeighbs in enumerate(neighbG): secondNeighbs = [neighbG[i] for i in firstNeighbs] totalNeighb = set(datatools.flatten([firstNeighbs]+secondNeighbs)) N = len(totalNeighb) if N==0: secondShellEnsemb.append(ensembG[a])
if __name__ == "__main__": utils.usage(["<dump.dat or OUTCAR>", "<'s'-self 'd'-distinct or 't'-total'>, default total"], 1, 3) RMAX = 10.0 plotEnable = True logtEnable = False if "-noPlot" in sys.argv: sys.argv.remove("-noPlot") plotEnable = False if "-logt" in sys.argv: sys.argv.remove("-logt") logtEnable = True inputFile = sys.argv[1] configIterator = parserGens.parseEnsemble(inputFile + ".tetra") tetraTime = array([tetra for tetra in configIterator]) # steps = map(int,sys.argv[2].split(",")) isfType = "total" if sys.argv[2][0] in ["s", "S"]: isfType = "self" else: isfType = "total" if "OUTCAR" in inputFile: ocarFile = inputFile atomByteNums = outcarIO.atomBytes(ocarFile) nAtom = outcarIO.nAtoms(ocarFile) basis = outcarIO.basis(ocarFile)