def plotting(rbins, rdist): pl.plot(rbins, rdist) pl.ylabel(r"$P \left (Q_%d \right )" % l) pl.xlabel(r"$Q_%d$" % l) pl.title("Bond Orientation | File:%s | Step:%s" % (sys.argv[1], head.split()[-1])) pr.prshow("bondOrientation.png")
avgy=[i/count for i in avgy] pl.plot(avgx,avgy) """ #Still figuring this one out... if switches["-saveData"]: data=label[xCol] + " " + label[yCol] + "\n" for x,y in zip(avgx,avgy): data+=str(x)+" "+str(y)+"\n" open("lazy.data","w").write(data) """ if not switches["-noLeg"]: pl.legend(loc=0) pl.gca().autoscale_view(True,True,True) if switches["-title"]: pl.title(switches["-title"]) if switches["-xlabel"]: pl.xlabel(switches["-xlabel"]) if switches["-ylabel"]: pl.ylabel(switches["-ylabel"]) if switches["-saveFig"]: pl.savefig("lazy.png") print "Wrote file lazy.png" else: pr.prshow("lazy.png")
print orderVals for i,(ov,r) in enumerate(orderVals): print poscarNames[i],"\t\t",sum(ov)/len(ov) elif op=="TN": print "Average Translational Order <tao> =" for i,ov in enumerate(orderVals): print poscarNames[i],"\t\t",sum(ov) elif op=="CN": hd,rcuts=zip(*orderVals) pl.hist(hd,bins=range(0,16),normed=True,histtype='bar',align='left',rwidth=0.8) for i,ov in enumerate(orderVals): cn=float(sum(ov[0]))/len(ov[0]) print "Average CN (%s):"%poscarNames[i],cn labels.append("CN%3.3f rcut%3.3f %s"%(cn,rcuts[i],poscarNames[i])) pl.xlabel(xylabels["CN"][0]) pl.ylabel(xylabels["CN"][1]) if args.averageFlag: pl.legend(["Average "+" ".join(poscarNames)],loc=0,fontsize=10) else: if len(labels)>0: pl.legend(labels,loc=0,fontsize=10) else: pl.legend(poscarNames,loc=0,fontsize=10) #Don't plot for some values if op not in ["TN","TET"]: pr.prshow("%s_chart_%s.png"%(sys.argv[1],op))
for z in zip(enGrid, ocGrid[i]): print "%f %f\n" % (z[0], z[1]) if orb != porb: if orb == "t": temp = "total" else: temp = orb pl.plot(enGrid, ocGrid[i], label=temp, color=c, lw=2) else: pl.plot(enGrid, ocGrid[i], color=c, lw=2) porb = orb pl.xlabel("Energy (in eV)") pl.ylabel("DOS") pl.legend() pr.prshow("DOS_from%s" % procarfile) elif yvals == "kp": for kp in range(len(kpoints)): pl.figure() for i in range(Norbs): orb = olabels[i][0] if orb == "s": c = "blue" elif orb == "p": c = "green" elif orb == "d": c = "purple" elif orb == "f": c = "red" elif orb == "t":
mxy = 0 mny = 0 for lmpx, lmpy, lmpname in zip(lmpxs, lmpys, lmpnames): pl.plot(lmpx[i], lmpy[i], label=lmpname) if i > 0: g = [k for k in range(len(lmpx[i])) if lmpx[i][k] < 1.5][-1] mxy = max([mxy, max(lmpy[i][g:])]) mny = min([mny, min(lmpy[i][g:])]) pl.xlim([1.4, 6]) pl.ylim([mny * 1.2, mxy * 1.2]) if pf: pl.xlim(xlims) pl.ylim(ylims) if i == 2: pl.ylim([0, 2]) pl.ylabel(var) pl.legend(loc=0, fontsize='small') #pl.subplot(326) #pl.plot(lmpx[0],[i-j for i,j in zip(lmpys[0][4],lmpys[1][4])]) #pl.legend() #pl.savefig("/home/acadien/Dropbox/stuff%s.png"%var) pl.tight_layout() pr.prshow("lammpsPotential.png") #pl.show()
strsy = list() strsz = list() count = 0 for line in outcar: if "in kB" in line: #print line.split("in kB")[1].strip() [sx, sy, sz] = [float(i) for i in line.split("in kB")[1].split()[:3]] strsx.append(sx) strsy.append(sy) strsz.append(sz) #The average Stress strsavg = [(strsx[i] + strsy[i] + strsz[i]) / 3 for i in range(len(strsx))] #A windowed average winavg = windowAvg(strsavg, n=3) #Plotting pl.figure() pl.plot(strsx, ls='--') pl.plot(strsy, ls='--') pl.plot(strsz, ls='--') pl.plot(strsavg) pl.plot(winavg, c="black", lw=2) pl.legend(["StressX", "StressY", "StressZ", "Avg", "Windowed Avg"], loc=0) pl.xlabel("Timestep") pl.ylabel("Stress (kB)") pl.title(sys.argv[1]) pr.prshow("outcarStressTime.png")
logTime = list() isfs = list() for isfSline in open(isfsFile,"r").readlines(): try: a = map(float,isfSline.split()) t = a.pop(0) i = sum(a)/len(a) except ValueError: continue logTime.append(t) isfs.append(i) import pylab as pl pl.semilogx(logTime,isfs) pr.prshow() exit(0) N = len(logTime) m = max(logTime) linTime = logTime#[float(i)*m/N for i in range(N)] linISFs = isfs#interp1d(logTime,isfs,linTime) T = m/N xf = np.linspace(0,0.5/T, N/2) yf = fftpack.fft(linISFs) pl.semilogx(xf, yf[:N/2]) #pl.semilogx(xf, np.imag(yf[:len(isfs)/2])*xf/len(isfs)) pr.prshow()
if xSmoothEnable or ySmoothEnable: if not switches["-noGhost"]: if colors==None: cp, = pl.plot(xdata,ydata,alpha=0.4,zorder=1) cc = cp.get_color() else: pl.plot(xdata,ydata,alpha=0.4,zorder=1,c=cc) if xSmoothEnable and ySmoothEnable: pl.plot(xdataSmooth,ydataSmooth,c=cc,lw=2,alpha=1.0,label=fnames[i]) elif ySmoothEnable: pl.plot(xdata,ydataSmooth,c=cc,lw=2,alpha=1.0,label=fnames[i]) elif xSmoothEnable: pl.plot(xdataSmooth,ydata,c=cc,lw=2,alpha=1.0,label=fnames[i]) else: pl.plot(xdata,ydata,lw=1.5,c=cc,label=fnames[i]) if switches["-avg"]: avgy=[i/count for i in avgy] pl.plot(avgx,avgy) if switches["-saveData"]: data=label[xCol] + " " + label[yCol] + "\n" for x,y in zip(avgx,avgy): data+=str(x)+" "+str(y)+"\n" open("plot2.data","w").write(data) if not switches["-noleg"]: pl.legend(loc=0) pr.prshow("plot2.png")
print "Average Translational Order <tao> =" for i, ov in enumerate(orderVals): print poscarNames[i], "\t\t", sum(ov) elif op == "CN": hd, rcuts = zip(*orderVals) pl.hist(hd, bins=range(0, 16), normed=True, histtype='bar', align='left', rwidth=0.8) for i, ov in enumerate(orderVals): cn = float(sum(ov[0])) / len(ov[0]) print "Average CN (%s):" % poscarNames[i], cn labels.append("CN%3.3f rcut%3.3f %s" % (cn, rcuts[i], poscarNames[i])) pl.xlabel(xylabels["CN"][0]) pl.ylabel(xylabels["CN"][1]) if args.averageFlag: pl.legend(["Average " + " ".join(poscarNames)], loc=0, fontsize=10) else: if len(labels) > 0: pl.legend(labels, loc=0, fontsize=10) else: pl.legend(poscarNames, loc=0, fontsize=10) #Don't plot for some values if op not in ["TN", "TET"]: pr.prshow("%s_chart_%s.png" % (sys.argv[1], op))
print "Defects: ",len(defectDelE) print "Melt/Quench: ",len(meltDelE) print "Feedback: ",len(feedDelE) print "Elastic: ",len(strainDelE) print "SlowQ: ",len(slowDelE) labels=["EOS","Melt","Feedback","Defects","Elastic","SlowQ"] toHist = [i for i in [eosDelE,meltDelE,feedDelE,defectDelE,strainDelE,slowDelE] if len(i)>0] toLabel = [labels[j] for j,i in enumerate([eosDelE,meltDelE,feedDelE,defectDelE,strainDelE,slowDelE]) if len(i)>0] pl.hist(toHist,20,label=toLabel,histtype='barstacked',fill=True) else: pl.hist(absdelE,20) pl.xlabel("$|\Delta E|$") pl.ylabel("count") pl.legend(loc=0) print "Worst fits: \ncnt %-48.48s |delE|"%"config#" cnt=0 for i,val in enumerate(reversed(sorted(absdelE))): if val<mxerr: break if fdb!=-1: print "%4d, %-50.50s, %f"%(absdelE.index(val),fdb[absdelE.index(val)],val) else: print i," ",absdelE.index(val)," \t",val cnt=i print "\n%d configurations with error above %f"%(cnt,mxerr) pr.prshow("energyErrorHist.png") #pl.savefig("/home/acadien/Dropbox/GeData/hist_energy_error.png")
toHistL = [ j for i, j in zip([eosDelS, meltDelS, feedDelS, defectDelS, strainDelS, slowDelS], ["EOS", "Melt", "Feedback", "Defects", "Elastic", "SlowQ"]) if len(i) > 0 ] pl.hist(toHist, 20, label=toHistL, histtype='barstacked', fill=True) else: pl.hist(absdelS, 20) pl.xlabel("$|\Delta S|$") pl.ylabel("count") pl.legend(loc=0) print "Worst fits: \ncnt %-38.38s dirN |delS|" % "config#" cnt = 0 for i, val in enumerate(reversed(sorted(absdelS))): if val < mxerr: break if fdb != -1: ix = absdelS.index(val) print "%4d, %-40.40s %-3.3s | %f" % (ix, fdb[int( ix / 6)], stressDirn[ix % 6], absdelS[ix]) else: print i, " ", absdelS.index(val) / 6, " \t", val cnt = i print "\n%d configurations with error above %f" % (cnt, mxerr) pr.prshow("stressErrorHist.png") #pl.savefig("/home/acadien/Dropbox/GeData/hist_energy_error.png")
lydata[2]=map(float,lmpdata[nrho+nr:nrho+2*nr]) lydata[2]=[lydata[2][i]/(lxdata[2][i]+1E-20) for i in range(nr)] lxdata[3]=map(lambda x:x*dr,range(nr)) #u lydata[3]=map(float,lmpdata[nrho+2*nr:nrho+3*nr]) lxdata[4]=map(lambda x:x*dr,range(nr)) #w lydata[4]=map(float,lmpdata[nrho+3*nr:nrho+4*nr]) print lxdata[2] #print "Variable : minval - maxval" pl.figure(figsize=(9,6)) for i,var in enumerate(varnames): pl.subplot(321+i) pl.scatter(datax[i],datay[i]) xlims=pl.xlim() ylims=pl.ylim() pl.plot(lxdata[i],lydata[i],label=var) pl.xlim(xlims) pl.ylim(ylims) #pl.ylim([ylims[0]/20,ylims[1]/50]) # prit "%3.3s : %4.4e - %4.4e"%(var,min(datay[i]),max(datay[i])) pl.legend(loc=0) #pl.legend() #pl.savefig("/home/acadien/Dropbox/stuff%s.png"%var) pl.legend(loc=0) pr.prshow("SampledPotential.eps") #pl.show()
print "Feedback: ",len(feedDelS) print "Defects: ",len(defectDelS) print "Elastic: ",len(strainDelS) print "SlowQ: ",len(slowDelS) toHist = [i for i in [eosDelS,meltDelS,feedDelS,defectDelS,strainDelS,slowDelS] if len(i)>0] toHistL = [j for i,j in zip([eosDelS,meltDelS,feedDelS,defectDelS,strainDelS,slowDelS],["EOS","Melt","Feedback","Defects","Elastic","SlowQ"]) if len(i)>0] pl.hist(toHist,20,label=toHistL,histtype='barstacked',fill=True) else: pl.hist(absdelS,20) pl.xlabel("$|\Delta S|$") pl.ylabel("count") pl.legend(loc=0) print "Worst fits: \ncnt %-38.38s dirN |delS|"%"config#" cnt=0 for i,val in enumerate(reversed(sorted(absdelS))): if val<mxerr: break if fdb!=-1: ix=absdelS.index(val) print "%4d, %-40.40s %-3.3s | %f"%(ix,fdb[int(ix/6)],stressDirn[ix%6],absdelS[ix]) else: print i," ",absdelS.index(val)/6," \t",val cnt=i print "\n%d configurations with error above %f"%(cnt,mxerr) pr.prshow("stressErrorHist.png") #pl.savefig("/home/acadien/Dropbox/GeData/hist_energy_error.png")
elif orb == 'f': c = 'red' elif orb == 't': c = 'black' if orb != porb: if orb == 't': temp = 'total' else: temp = orb pl.plot(enGrid, ocGrid[i], label=temp, color=c) else: pl.plot(enGrid, ocGrid[i], color=c) porb = orb pl.xlabel("Energy (in eV)") pl.ylabel("DOS") pl.legend() pr.prshow("DOS_from%s" % procarfile) elif yvals == 'kp': for kp in range(len(kpoints)): pl.figure() for i in range(Norbs): orb = olabels[i][0] if orb == 's': c = 'blue' elif orb == 'p': c = 'green' elif orb == 'd': c = 'purple' elif orb == 'f': c = 'red' elif orb == 't':
lxdata[2] = map(lambda x: x * dr, range(nr)) #phi lydata[2] = map(float, lmpdata[nrho + nr:nrho + 2 * nr]) lydata[2] = [lydata[2][i] / (lxdata[2][i] + 1E-20) for i in range(nr)] lxdata[3] = map(lambda x: x * dr, range(nr)) #u lydata[3] = map(float, lmpdata[nrho + 2 * nr:nrho + 3 * nr]) lxdata[4] = map(lambda x: x * dr, range(nr)) #w lydata[4] = map(float, lmpdata[nrho + 3 * nr:nrho + 4 * nr]) print lxdata[2] #print "Variable : minval - maxval" pl.figure(figsize=(9, 6)) for i, var in enumerate(varnames): pl.subplot(321 + i) pl.scatter(datax[i], datay[i]) xlims = pl.xlim() ylims = pl.ylim() pl.plot(lxdata[i], lydata[i], label=var) pl.xlim(xlims) pl.ylim(ylims) #pl.ylim([ylims[0]/20,ylims[1]/50]) # prit "%3.3s : %4.4e - %4.4e"%(var,min(datay[i]),max(datay[i])) pl.legend(loc=0) #pl.legend() #pl.savefig("/home/acadien/Dropbox/stuff%s.png"%var) pl.legend(loc=0) pr.prshow("SampledPotential.eps") #pl.show()
mxy=0 mny=0 for lmpx,lmpy,lmpname in zip(lmpxs,lmpys,lmpnames): pl.plot(lmpx[i],lmpy[i],label=lmpname) if i>0: g=[k for k in range(len(lmpx[i])) if lmpx[i][k]<1.5][-1] mxy=max([mxy,max(lmpy[i][g:])]) mny=min([mny,min(lmpy[i][g:])]) pl.xlim([1.4,6]) pl.ylim([mny*1.2,mxy*1.2]) if pf: pl.xlim(xlims) pl.ylim(ylims) if i==2: pl.ylim([0,2]) pl.ylabel(var) pl.legend(loc=0,fontsize='small') #pl.subplot(326) #pl.plot(lmpx[0],[i-j for i,j in zip(lmpys[0][4],lmpys[1][4])]) #pl.legend() #pl.savefig("/home/acadien/Dropbox/stuff%s.png"%var) pl.tight_layout() pr.prshow("lammpsPotential.png") #pl.show()
strsy=list() strsz=list() count=0 for line in outcar: if "in kB" in line: #print line.split("in kB")[1].strip() [sx,sy,sz]=[float(i) for i in line.split("in kB")[1].split()[:3]] strsx.append(sx) strsy.append(sy) strsz.append(sz) #The average Stress strsavg=[(strsx[i]+strsy[i]+strsz[i])/3 for i in range(len(strsx))] #A windowed average winavg=windowAvg(strsavg,n=3) #Plotting pl.figure() pl.plot(strsx,ls='--') pl.plot(strsy,ls='--') pl.plot(strsz,ls='--') pl.plot(strsavg) pl.plot(winavg,c="black",lw=2) pl.legend(["StressX","StressY","StressZ","Avg","Windowed Avg"],loc=0) pl.xlabel("Timestep") pl.ylabel("Stress (kB)") pl.title(sys.argv[1]) pr.prshow("outcarStressTime.png")
def plotting(rbins, rdist): pl.plot(rbins, rdist) pl.xlabel("radius ($\AA$)") pl.ylabel("g(r)") pl.title("RDF | File:%s | Step:%s" % (sys.argv[1], head.split()[-1])) pr.prshow("RDF_lammps.png")
def plotting(rbins,rdist): pl.plot(rbins,rdist) pl.xlabel("radius ($\AA$)") pl.ylabel("g(r)") pl.title("RDF | File:%s | Step:%s"%(sys.argv[1],head.split()[-1])) pr.prshow("RDF_lammps.png")
""" pl.subplot(312) pl.plot(rmsdAvg,label="AvgRMSD") pl.plot(slowRMSDAvg,label="SlowAvgRMSD") pl.plot(fastRMSDAvg,label="FastAvgRMSD") for i in fastAtoms: pl.plot(i) pl.legend(loc=0) pl.subplot(313) pl.scatter(range(nIon),jumpedFlag10) pl.xlim([0,nIon]) """ nJumped = sum([1 for i in jumpedFlag50 if i > 0]) print "%d: %d / %d" % (50, nJumped, nIon) nJumped = sum([1 for i in jumpedFlag100 if i > 0]) print "%d: %d / %d" % (100, nJumped, nIon) nJumped = sum([1 for i in jumpedFlag200 if i > 0]) print "%d: %d / %d" % (200, nJumped, nIon) nJumped = sum([1 for i in jumpedFlag300 if i > 0]) print "%d: %d / %d" % (300, nJumped, nIon) nJumped = sum([1 for i in jumpedFlag400 if i > 0]) print "%d: %d / %d" % (400, nJumped, nIon) nJumped = sum([1 for i in jumpedFlag500 if i > 0]) print "%d: %d / %d" % (500, nJumped, nIon) nJumped = sum([1 for i in jumpedFlag1000 if i > 0]) print "%d: %d / %d" % (1000, nJumped, nIon) pr.prshow()
def plotting(rbins,rdist): pl.plot(rbins,rdist) pl.ylabel(r"$P \left (Q_%d \right )"%l) pl.xlabel(r"$Q_%d$"%l) pl.title("Bond Orientation | File:%s | Step:%s"%(sys.argv[1],head.split()[-1])) pr.prshow("bondOrientation.png")
pl.legend(loc=0, fontsize=12) # pl.subplot(subs+2) pl.figure(figsize=(20, 12)) dictScatter(Vpressures, Venergies, phases) if lmppot != -1: dictPlot(Lpressures, Lenergies, phases, "-", 1.5) pl.xlabel("Pressure ($GPa$)", size=17) pl.ylabel("Energy ($eV / atom$)", size=17) pl.ylim([-4.55, -3]) pl.xlim([-15, 50]) pl.legend(loc=0, fontsize=12) # dictScatterInset(Vpressures,Venergies,phases,xlim=[-20,20],ylim=[-8,-7.5], xticks=[-20,0,20], yticks=[-8,-7.5]) # pr.prshow("EOS_PE.png") pr.prshow("EOS_PVol.png") exit(0) # pl.subplot(subs+3) pl.figure() dictScatter(Vpressures, Venthalpies, phases) # pl.xlim([0,500]) # pl.ylim([-8.5,-2]) if lmppot != -1: dictPlot(Lpressures, Lenthalpies, phases, "-", 1.5) pl.xlabel("Pressure ($GPa$)", size=17) pl.ylabel("Enthalpy ($eV / atom$)", size=17) pl.legend(loc=0, fontsize=12) # dictScatterInset(Vpressures,Venergies,phases,xlim=[0,100],ylim=[-8,-7], xticks=[0,20,40,60,80,100], yticks=[-8,-7]) # pr.prshow("EOS_PH.png") # pl.subplot(subs+4)
elif ySmoothEnable: pl.plot(xdata, ydataSmooth, c=cc, lw=2, alpha=1.0, label=fnames[i]) elif xSmoothEnable: pl.plot(xdataSmooth, ydata, c=cc, lw=2, alpha=1.0, label=fnames[i]) else: pl.plot(xdata, ydata, lw=1.5, c=cc, label=fnames[i]) if switches["-avg"]: avgy = [i / count for i in avgy] pl.plot(avgx, avgy) if switches["-saveData"]: data = label[xCol] + " " + label[yCol] + "\n" for x, y in zip(avgx, avgy): data += str(x) + " " + str(y) + "\n" open("plot2.data", "w").write(data) if not switches["-noleg"]: pl.legend(loc=0) pr.prshow("plot2.png")
pl.xlabel("Volume ($\AA^3 / atom$)", size=17) pl.ylabel("Energy ($eV / atom$)", size=17) pl.legend(loc=0, fontsize=12) #pl.subplot(subs+2) pl.figure(figsize=(20, 12)) dictScatter(Vpressures, Venergies, phases) if lmppot != -1: dictPlot(Lpressures, Lenergies, phases, "-", 1.5) pl.xlabel("Pressure ($GPa$)", size=17) pl.ylabel("Energy ($eV / atom$)", size=17) pl.ylim([-4.55, -3]) pl.xlim([-15, 50]) pl.legend(loc=0, fontsize=12) #dictScatterInset(Vpressures,Venergies,phases,xlim=[-20,20],ylim=[-8,-7.5], xticks=[-20,0,20], yticks=[-8,-7.5]) #pr.prshow("EOS_PE.png") pr.prshow("EOS_PVol.png") exit(0) #pl.subplot(subs+3) pl.figure() dictScatter(Vpressures, Venthalpies, phases) #pl.xlim([0,500]) #pl.ylim([-8.5,-2]) if lmppot != -1: dictPlot(Lpressures, Lenthalpies, phases, "-", 1.5) pl.xlabel("Pressure ($GPa$)", size=17) pl.ylabel("Enthalpy ($eV / atom$)", size=17) pl.legend(loc=0, fontsize=12) #dictScatterInset(Vpressures,Venergies,phases,xlim=[0,100],ylim=[-8,-7], xticks=[0,20,40,60,80,100], yticks=[-8,-7]) #pr.prshow("EOS_PH.png") #pl.subplot(subs+4) pl.figure()