def rdfExtend(rdfX,rdfY,ndens,rmax=50.0,Niter=5,T=300.0,rm=2.5,epsilon=-1E-10,damped=True,PY=True): #rm and eps are parameters for the LJ (used as the PY closure) #T is the temperature for the energy, effects smoothing near the transition point #PY selects the Percus Yevick Closure for C(r), if false, the HNC criterion are used. rdfX=list(rdfX)[:-10] rdfY=list(rdfY)[:-10] drx = rdfX[1]-rdfX[0] n = int(np.ceil(rmax/drx)) hrx = np.array([i*drx for i in range(n)]) hry = np.array([(j-1.0) for d,j in enumerate(rdfY + [1.0 for i in hrx[len(rdfY):]])]) phi=[ epsilon*((rm/r)**12-2*(rm/r)**6) if r>0 else 0.0 for r in hrx] #else eps*((rm/1E-10)**12-2*(rm/1E-10)**6) for r in hrx] #import pylab as pl #pl.plot(hrx,phi) #pl.ylim(-10,100) #pl.show() #exit(0) beta = 1.0/8.6173324e-05/T icut = len(rdfX) cr = np.array([0.0 for i in hry]) qr = np.array([0.0 for i in hry]) qrp = np.array([0.0 for i in hry]) hrlast = np.array(hry) qrplast = np.zeros(len(hry)) Lmax=10.0 qbins=1024 minq,maxq,dq=0,Lmax,Lmax/qbins qs=[i*dq+minq for i in range(qbins)] qs[0]=1E-10 PY=True eta = 0.2 qs=[i/100.0 for i in range(1,1000)] import pylab as pl kbreak=20 for k in range(Niter): if k==kbreak: break qrp = calc_qpr_rltcut(icut,ndens,hrx,hry,cr,qr,qrp) qrp = calc_qpr_rgtcut(icut,ndens,hrx,hry,cr,qr,qrp) qrp = eta*qrp + (1-eta)*qrplast qr = calc_qr (icut,ndens,hrx,hry,cr,qr,qrp) hry = calc_hr_rgtcut (icut,ndens,hrx,hry,cr,qr,qrp) cr = calc_cr (icut,ndens,hrx,hry,cr,qr,qrp,phi,beta,PY) #hry2 = calc_hr (icut,ndens,hrx,hry,cr,qr,qrp) sq = calcSq(ndens,hrx,hry,qs) #pl.plot(hrx,hry,label=str(k),c=vizSpec(float(k)/kbreak)) pl.plot(qs,sq,label=str(k),c=vizSpec(float(k)/kbreak)) err = np.power((hrlast-hry),2).sum() print "step %d, error %f"%(k,err) if err>100: break hrlast = np.array(hry) qrplast = np.array(qrp) pl.legend(loc=0) pl.show() exit(0) qrp = superSmooth(hrx,qrp,sigma=0.1) calc_hr(len(hrx),ndens,hrx,hry,cr,qr,qrp) pl.plot(hrx,hry,c="black",lw=2) grExtended = np.array([i+1.0 for i in hry]) return cr,hrx,grExtended
if xCol != -1: pl.xlabel(label[xCol]) pl.ylabel(label[yCol]) if switches["-hist"]: pl.xlabel(label[yCol]) pl.ylabel("count") if switches["-3d"]: if colors == None: ax.plot(xdata, ydata, zs=i, lw=1.5) else: ax.plot(xdata, ydata, zs=i, lw=2, c=vizSpec(float(i) / len(fnames))) elif switches["-hist"]: mn = min(ydata) mx = max(ydata) dely = (mx - mn) / nbins ybins = [i * dely + mn for i in range(0, nbins + 1)] yvals = np.bincount([(y - mn) / (mx - mn) * nbins for y in ydata]).tolist() if switches["-avg"]: avgy += np.array(yvals) count += 1 else: pl.plot(ybins, yvals) elif switches["-avg"]:
mn=min(ydata) mx=max(ydata) if i==0 and len(label)==len(fdata): if xCol!=-1: pl.xlabel( label[xCol] ) pl.ylabel( label[yCol] ) if switches["-hist"]: pl.xlabel( label[yCol] ) pl.ylabel("count") if switches["-3d"]: if colors==None: ax.plot(xdata,ydata,zs=i,lw=1.5) else: ax.plot(xdata,ydata,zs=i,lw=2,c=vizSpec(float(i)/len(fnames))) elif switches["-hist"]: mn=min(ydata) mx=max(ydata) dely=(mx-mn)/nbins ybins=[i*dely+mn for i in range(0,nbins+1)] yvals=np.bincount([(y-mn)/(mx-mn)*nbins for y in ydata]).tolist() if switches["-avg"]: avgy+=np.array(yvals) count+=1 else: pl.plot(ybins,yvals) elif switches["-avg"]: if len(avgy)!=len(ydata):
print "Not all data is the same length, unable to average lists of different lengths." exit(0) if ySmoothEnable: avgy+=np.array(ydataSmooth) else: avgy+=np.array(ydata) count+=1 elif switches["-scatter"]: if xSmoothEnable: xdata=xdataSmooth if ySmoothEnable: ydata=ydataSmooth nPoints = int(switches["-scatter"]) pl.scatter(xdata[::nPoints],ydata[::nPoints],lw=0.1,label=fileNames[i],facecolor=vizSpec(float(i)/max((nFileNames-1),1) )) else: #Regular plot, multiple lines cc=vizSpec(float(i)/max(nFileNames-1,1) ) if xSmoothEnable: xdata=xdataSmooth if ySmoothEnable: ydata=ydataSmooth pl.plot(xdata,ydata,lw=1.5,c=cc,label=fileNames[i],alpha=alpha) if switches["-avg"]: avgy=[i/count for i in avgy] pl.plot(avgx,avgy)
if nEvolve != None: [xs,ys]=zip(*orderVals) xs=xs[0] nSamples=len(ys) nDel=nSamples/nEvolve yEvs=list() lablel=list() for i in range(nEvolve): start, finish = i*nDel, (i+1)*nDel labels.append(str(start)+" - "+str(finish)) yEvs.append(map(lambda x: sum(x)/len(x),zip(*ys[start:finish]))) if not(stagger): for i in range(nEvolve): pl.plot(xs,yEvs[i],color=vizSpec(i/float(nEvolve))) else: yDel=( max(map(max,yEvs)) - min(map(min,yEvs)) )/2. for i in range(nEvolve): yvals=[y+yDel*i for y in yEvs[i]] pl.plot(xs,yvals,color=vizSpec(i/float(nEvolve))) pl.text((max(xs)-min(xs))*0.8,yDel*(i+0.2),labels[i]) pl.yticks([]) pl.xlabel(xylabels[op][0]) pl.ylabel(xylabels[op][1]) pr.prshow("%s_chart_evolve.png"%op) exit(0) if args.averageFlag: if op not in ["BO","CN","TN","TET"]: t = zip(*[orderVals[i][1] for i in range(len(orderVals))])
if nEvolve != None: [xs, ys] = zip(*orderVals) xs = xs[0] nSamples = len(ys) nDel = nSamples / nEvolve yEvs = list() lablel = list() for i in range(nEvolve): start, finish = i * nDel, (i + 1) * nDel labels.append(str(start) + " - " + str(finish)) yEvs.append(map(lambda x: sum(x) / len(x), zip(*ys[start:finish]))) if not (stagger): for i in range(nEvolve): pl.plot(xs, yEvs[i], color=vizSpec(i / float(nEvolve))) else: yDel = (max(map(max, yEvs)) - min(map(min, yEvs))) / 2. for i in range(nEvolve): yvals = [y + yDel * i for y in yEvs[i]] pl.plot(xs, yvals, color=vizSpec(i / float(nEvolve))) pl.text((max(xs) - min(xs)) * 0.8, yDel * (i + 0.2), labels[i]) pl.yticks([]) pl.xlabel(xylabels[op][0]) pl.ylabel(xylabels[op][1]) pr.prshow("%s_chart_evolve.png" % op) exit(0) if args.averageFlag: if op not in ["BO", "CN", "TN", "TET"]: t = zip(*[orderVals[i][1] for i in range(len(orderVals))])