usage() print "Error parsing rcut args" exit(0) outcarFile=sys.argv[1] try: num=sys.argv[1].split("_")[1] except IndexError: num=None refStructure=None 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)
else: usage() exit(0) #Parse POSCAR j=0 if "POSCAR" in configFile or "CONTCAR" in configFile: poscar=open(configFile,"r").readlines() [basis,atypes,atoms,head,poscar] = poscarIO.read(poscar) types=list() for i in atypes: types+=[j+1]*i j+=1 elif "OUTCAR" in configFile: TE,stress,basis,atoms,forces,types = outcarIO.outcarReadConfig(configFile,Nconfig) #Parse LAMMPS DUMP else: basis,types,atoms = lammpsIO.readConfig(configFile,Nconfig) ax,ay,az=map(np.array,zip(*atoms)) v1,v2,v3=basis if rectifyFlag: ax,ay,az = ax%v1[0], ay%v2[1], az%v3[2] fig=mlab.figure(bgcolor=(0.8,0.8,0.8)) #Set default rcut value for tetrahedral ordering if op=="TET" and rcut==None:
#====================================================== # Gather the order parameters #====================================================== orderVals=list() for pn in fileNames: if "POSCAR" in pn or "CONTCAR" in pn:#fileNames[0]: poscar=open(pn,"r").readlines() [basis,atypes,atoms,head,poscar] = poscarIO.read(poscar) orderVals.append(orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) elif "OUTCAR" in pn: if len(cfgNums)==1: TE,stress,basis,atoms,forces,types = outcarIO.outcarReadConfig(pn,cfgNums) orderVals.append( orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) else: TEs,stresss,basiss,atomss,forcess,typess = outcarIO.outcarReadConfig(pn,cfgNums) for basis,atoms in zip(basiss,atomss): orderVals.append(orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) else: #LAMMPS DUMP if len(cfgNums)==1: basis,types,atoms = lammpsIO.readConfig(pn,cfgNums) orderVals.append( orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) else: basiss,types,atomss = lammpsIO.readConfig(pn,cfgNums)
#grep to check for PREC = high command, if not present spit out error and quit. precResults = subprocess.check_output("grep PREC %s"%ocfile,shell=True).split("=")[1].split()[0] if precResults not in ["high","High"]: print "Error: VASP Simulation not performed with \'high\' precision." exit(0) #get the force configuration number (the total number of configs in the forcefil) dbcnfgcnt=0 #Force Data Base Configuration Counter for line in fordb: if "#N" in line[0:2]: dbcnfgcnt+=1 fordb.close() fordb = open(forcefil,"a") TE,stress,basis,atoms,forces,types=outcarReadConfig(ocfile,grabconfig) stress=[i/160.2 for i in stress] #Change atoms to be in cartesian coords instead of fractional #bT=basis.T #atoms=[bT.dot(atom) for atom in atoms] natom=len(atoms) #Number of atoms, use force, header if scaleEnable: line="#N\t%d 1 ifconf=%d Taken From:%s Config:#%d\n"%\ (natom,dbcnfgcnt,os.getcwd()+"/"+ocfile,grabconfig) else: line="#N\t%d 1 ifconf=%d Taken From:%s Config:#%d scaleEnable0\n"%\ (natom,dbcnfgcnt,os.getcwd()+"/"+ocfile,grabconfig)
try: num = sys.argv[1].split("_")[1] except IndexError: num = None refStructure = None if len(sys.argv) == 3: refStructure = int(sys.argv[2]) delT, msdAtom = outcarMeanSquareDisplaceAtom(outcarFile, refStructure) pl.figure() for atom in range(msdAtom.shape[0]): pl.plot(delT, msdAtom[atom]) dummy, dummy, basis, atoms, forces, types = outcarIO.outcarReadConfig( outcarFile, -1) from mayavi import mlab ax, ay, az = atoms.T ops = msdAtom.T[-1] v1, v2, v3 = basis #Box... bleh I hate this code. mlab.plot3d([0, v1[0], v1[0] + v2[0], v2[0], 0, v3[0]], [0, v1[1], v1[1] + v2[1], v2[1], 0, v3[1]], [0, v1[2], v1[2] + v2[2], v2[2], 0, v3[2]], color=(0, 0, 0), line_width=0.5) mlab.plot3d( [v3[0], v3[0] + v1[0], v3[0] + v2[0] + v1[0], v3[0] + v2[0], v3[0]], [v3[1], v3[1] + v1[1], v3[1] + v2[1] + v1[1], v3[1] + v2[1], v3[1]],
usage() exit(0) #Parse POSCAR j=0 if "POSCAR" in configFile or "CONTCAR" in configFile: poscar=open(configFile,"r").readlines() [basis,atypes,atoms,head,poscar] = poscarIO.read(poscar) types=list() for i in atypes: types+=[j+1]*i j+=1 #Parse OUTCAR elif "OUTCAR" in configFile: TE,stress,basis,atoms,forces,types = outcarIO.outcarReadConfig(configFile,Nconfig) #Parse LAMMPS else: basis,types,atoms = lammpsIO.readConfig(configFile,Nconfig) ax,ay,az=map(np.array,zip(*atoms)) nAtom = len(ax) v1,v2,v3=basis if shiftFlag: atoms = [[a[0]+v1[0]/2.,a[1]+v2[1]/2.,a[2]+v3[2]/2.55] for a in atoms] rectifyFlag = True if rectifyFlag: atoms = np.array(atoms) #unrectified for orderParam calculations.
usage() print "Error parsing rcut args" exit(0) outcarFile = sys.argv[1] try: num = sys.argv[1].split("_")[1] except IndexError: num = None refStructure = None 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
#====================================================== # Gather the order parameters #====================================================== orderVals = list() for pn in fileNames: if "POSCAR" in pn or "CONTCAR" in pn: #fileNames[0]: poscar = open(pn, "r").readlines() [basis, atypes, atoms, head, poscar] = poscarIO.read(poscar) orderVals.append(orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) elif "OUTCAR" in pn: if len(cfgNums) == 1: TE, stress, basis, atoms, forces, types = outcarIO.outcarReadConfig( pn, cfgNums) orderVals.append( orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) else: TEs, stresss, basiss, atomss, forcess, typess = outcarIO.outcarReadConfig( pn, cfgNums) for basis, atoms in zip(basiss, atomss): orderVals.append(orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) else: #LAMMPS DUMP if len(cfgNums) == 1: basis, types, atoms = lammpsIO.readConfig(pn, cfgNums) orderVals.append( orderParams[op]( \ array(atoms),array(basis),l=lval,neighbs=neighbs,rcut=args.rcut,debug=args.debug)) else:
num=sys.argv[1].split("_")[1] except IndexError: num=None refStructure=None if len(sys.argv)==3: refStructure=int(sys.argv[2]) delT,msdAtom=outcarMeanSquareDisplaceAtom(outcarFile,refStructure) pl.figure() for atom in range(msdAtom.shape[0]): pl.plot(delT,msdAtom[atom]) dummy,dummy,basis,atoms,forces,types=outcarIO.outcarReadConfig(outcarFile,-1) from mayavi import mlab ax,ay,az=atoms.T ops=msdAtom.T[-1] v1,v2,v3=basis #Box... bleh I hate this code. mlab.plot3d([0,v1[0],v1[0]+v2[0],v2[0],0,v3[0]],[0,v1[1],v1[1]+v2[1],v2[1],0,v3[1]],[0,v1[2],v1[2]+v2[2],v2[2],0,v3[2]],color=(0,0,0),line_width=0.5) mlab.plot3d([v3[0],v3[0]+v1[0],v3[0]+v2[0]+v1[0],v3[0]+v2[0],v3[0]],[v3[1],v3[1]+v1[1],v3[1]+v2[1]+v1[1],v3[1]+v2[1],v3[1]],[v3[2],v3[2]+v1[2],v3[2]+v2[2]+v1[2],v3[2]+v2[2],v3[2]],color=(0,0,0),line_width=0.5) mlab.plot3d([v1[0],v1[0]+v3[0]],[v1[1],v1[1]+v3[1]],[v1[2],v1[2]+v3[2]],color=(0,0,0),line_width=0.5) mlab.plot3d([v2[0],v2[0]+v3[0]],[v2[1],v2[1]+v3[1]],[v2[2],v2[2]+v3[2]],color=(0,0,0),line_width=0.5) mlab.plot3d([v1[0]+v2[0],v1[0]+v2[0]+v3[0]],[v1[1]+v2[1],v1[1]+v2[1]+v3[1]],[v1[2]+v2[2],v1[2]+v2[2]+v3[2]],color=(0,0,0),line_width=0.5) #Atoms mp3d = mlab.points3d(ax,ay,az,ops,colormap='gist_earth',scale_factor=1.9,scale_mode='none',resolution=25)