def rdfExtend(rdfX, rdfY, ndens, rmax=50.0, Niter=5, T=100.0, rm=2.5, eps=-1, 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([r for r in rdfX]) rdfY = list(rdfY[:len(rdfX)]) 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 j in rdfY + [1.0 for i in hrx[len(rdfY):]]]) phi = [ eps * ((rm / r)**12 - 2 * (rm / r)**6) if r > 0 else eps * ((rm / 1E-10)**12 - 2 * (rm / 1E-10)**6) for r in hrx ] 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]) for k in range(Niter): qrp = calc_qpr_rltcut(icut, ndens, hrx, hry, cr, qr, qrp) qrp = calc_qpr_rgtcut(icut, ndens, hrx, hry, cr, qr, qrp) qrp = superSmooth(hrx, qrp, sigma=0.1) qr = calc_qr(icut, ndens, hrx, hry, cr, qr, qrp) hry = calc_hr_rgtcut(icut, ndens, hrx, hry, cr, qr, qrp) cr = calc_cr_rgtcut(icut, ndens, hrx, hry, cr, qr, qrp, phi, beta, PY) calc_hr(len(hrx), ndens, hrx, hry, cr, qr, qrp) grExtended = np.array([i + 1.0 for i in hry]) f = open("/home/acadien/Dropbox/ozsf%d.dat" % rrcut, "w") a = map(lambda x: "%f %f\n" % (x[0], x[1]), zip(hrx, grExtended)) f.writelines(a) f.close() f = open("/home/acadien/Dropbox/qrpsf%d.dat" % rrcut, "w") a = map(lambda x: "%f %f\n" % (x[0], x[1]), zip(hrx, qrp)) f.writelines(a) f.close() return hrx, grExtended
def rdfExtend(rdfX,rdfY,ndens,rmax=50.0,Niter=5,T=100.0,rm=2.5,eps=-1,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([r for r in rdfX]) rdfY=list(rdfY[:len(rdfX)]) 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 j in rdfY + [1.0 for i in hrx[len(rdfY):]]]) phi=[eps*((rm/r)**12-2*(rm/r)**6) if r>0 else eps*((rm/1E-10)**12-2*(rm/1E-10)**6) for r in hrx] 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]) for k in range(Niter): qrp = calc_qpr_rltcut(icut,ndens,hrx,hry,cr,qr,qrp) qrp = calc_qpr_rgtcut(icut,ndens,hrx,hry,cr,qr,qrp) qrp = superSmooth(hrx,qrp,sigma=0.1) qr = calc_qr (icut,ndens,hrx,hry,cr,qr,qrp) hry = calc_hr_rgtcut (icut,ndens,hrx,hry,cr,qr,qrp) cr = calc_cr_rgtcut (icut,ndens,hrx,hry,cr,qr,qrp,phi,beta,PY) calc_hr(len(hrx),ndens,hrx,hry,cr,qr,qrp) grExtended = np.array([i+1.0 for i in hry]) f= open("/home/acadien/Dropbox/ozsf%d.dat"%rrcut,"w") a=map(lambda x:"%f %f\n"%(x[0],x[1]),zip(hrx,grExtended)) f.writelines(a) f.close() f= open("/home/acadien/Dropbox/qrpsf%d.dat"%rrcut,"w") a=map(lambda x:"%f %f\n"%(x[0],x[1]),zip(hrx,qrp)) f.writelines(a) f.close() return hrx,grExtended
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: xdata = range(len(ydata)) 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]
if xCol==-1: xdata=range(len(ydata)) 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]