Example #1
0
def generateRCut(atoms,basis,debug=False):
    #Set rcut to be the first minimum of g(r)
    rvals,gr = rdf_periodic(atoms,basis,cutoff=6.0)

    #Smoothed G(r)
    sgr=windowAvg(gr,n=25).tolist()
    #derivative of smoothed-G(r)
    dsgr = windowAvg(windowAvg([(sgr[i+1]-sgr[i])/(rvals[1]-rvals[0]) for i in range(len(sgr)-1)],n=50),n=20).tolist()#[47:]+[0]*47
    
    #Find the first minima by searching for the first 2 maxima and finding the minima between the two
    #More robust version uses first point at which the first derivative becomes positive after the first peak
    first_neg = [i for i,v in enumerate(dsgr) if v<0][0]
    first_peak = sgr.index(max(sgr[:first_neg]))
    rindex = first_neg + [i for i,v in enumerate(dsgr[first_neg:]) if v>=0][0]
    rcut = rvals[rindex]

     #Should probably check out this plot before continuing
    if debug:
        print rcut
        pl.plot(rvals,[i for i in sgr],lw=3,c="green",label="Smooth G(r)")
        pl.plot(rvals[1:],dsgr,c="red",label="Smooth G'(r)")
        pl.plot([rcut,rcut],[min(gr),max(gr)],lw=3,c="black",label="rcut")
        pl.plot(rvals,gr,c="blue",label="G(r)")
        pl.legend(loc=0)
        pl.show()
        
    return rcut
Example #2
0
        else:
            xdata = fdata[xCol]

        #Smoothing:
        xSmoothEnable = xSmoothEnables[i]
        ySmoothEnable = ySmoothEnables[i]
        xWAN = xWANs[i]
        yWAN = yWANs[i]
        xdataSmooth = []
        ydataSmooth = []

        if xSmoothEnable:
            if switches["-gauss"]:
                xdataSmooth = superSmooth(xdata, ydata, xWAN / 100.0)
            else:
                xdataSmooth = windowAvg(xdata, xWAN)
        if ySmoothEnable:
            if switches["-gauss"]:
                ydataSmooth = superSmooth(xdata, ydata, yWAN / 100.0)
            else:
                ydataSmooth = windowAvg(ydata, yWAN)

        #Correct for window offset, average introduces extra points that need to be chopped off
        if not switches["-gauss"] and xSmoothEnable or ySmoothEnable:
            WAN = max(xWAN, yWAN)
            xdataSmooth = xdataSmooth[WAN / 2 + 1:WAN / -2]
            ydataSmooth = ydataSmooth[WAN / 2 + 1:WAN / -2]
            xdata = xdata[WAN / 2 + 1:WAN / -2]
            ydata = ydata[WAN / 2 + 1:WAN / -2]

        #Scaling - multiply by constant
Example #3
0
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")
Example #4
0
    zBinLow = [i*delz+zmin for i in range(nSlices-1)]
    zVals = [0.]*nSlices
    zCount = [0]*nSlices

    #Loop over atoms and bin orderParameter based on z-coordinate of atom
    az=[i%zmax for i in az]
    for a,atomZ in enumerate(az):
        i = sum([1 for zLow in zBinLow if atomZ > zLow])
        zCount[i] += 1
        zVals[i] += ops[a]

    #window average and eliminate 0's
    zBins,zVals = map(list,zip(*[[b,z/c] for z,c,b in zip(zVals,zCount,zBins) if c!=0]))
    if zBins[0]!=0:
        
        zBins=[0]+zBins
        zVals=[zVals[-1]]+zVals
    zValsAvg=windowAvg(zVals[-3:]+zVals+zVals[:3],5)[3:-3]

    #plot
    pl.figure()
    pl.plot(zBins,zVals)
    pl.plot(zBins,zValsAvg)
    pl.xlabel("Z")
    pl.ylabel(op)
    pl.xlim(zmin,zmax)
    pl.draw()
    pl.show()

prm.prmshow(fname="POSCAR.png")
Example #5
0
        else:
            xdata=fdata[xCol]

        #Smoothing:
        xSmoothEnable=xSmoothEnables[i]
        ySmoothEnable=ySmoothEnables[i]
        xWAN=xWANs[i]
        yWAN=yWANs[i]
        xdataSmooth=[]
        ydataSmooth=[]

        if xSmoothEnable:
            if switches["-gauss"]:
                xdataSmooth=superSmooth(xdata,ydata,xWAN/100.0)
            else:
                xdataSmooth=windowAvg(xdata,xWAN)
        if ySmoothEnable:
            if switches["-gauss"]:
                ydataSmooth=superSmooth(xdata,ydata,yWAN/100.0)
            else:
                ydataSmooth=windowAvg(ydata,yWAN)

        #Correct for window offset, average introduces extra points that need to be chopped off
        if not switches["-gauss"] and xSmoothEnable or ySmoothEnable: 
            WAN=max(xWAN,yWAN)
            xdataSmooth=xdataSmooth[WAN/2+1:WAN/-2]
            ydataSmooth=ydataSmooth[WAN/2+1:WAN/-2]
            xdata=xdata[WAN/2+1:WAN/-2]
            ydata=ydata[WAN/2+1:WAN/-2]

        #Scaling - multiply by constant
Example #6
0
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")
Example #7
0
    zBinLow = [i*delz+zmin for i in range(nSlices-1)]
    zVals = [0.]*nSlices
    zCount = [0]*nSlices

    #Loop over atoms and bin orderParameter based on z-coordinate of atom
    az=[i%zmax for i in az]
    for a,atomZ in enumerate(az):
        i = sum([1 for zLow in zBinLow if atomZ > zLow])
        zCount[i] += 1
        zVals[i] += ops[a]

    #window average and eliminate 0's
    zBins,zVals = map(list,zip(*[[b,z/c] for z,c,b in zip(zVals,zCount,zBins) if c!=0]))
    if zBins[0]!=0:
        
        zBins=[0]+zBins
        zVals=[zVals[-1]]+zVals
    zValsAvg=datatools.windowAvg(zVals[-3:]+zVals+zVals[:3],5)[3:-3]

    #plot
    pl.figure()
    pl.plot(zBins,zVals)
    pl.plot(zBins,zValsAvg)
    pl.xlabel("Z")
    pl.ylabel(op)
    pl.xlim(zmin,zmax)
    pl.draw()
    pl.show()

prm.prmshow(fname="plot3.png")