def kkappa(self): dirs=ls('shengold*') from aces.scanf import sscanf from aces.graph import fig,pl import matplotlib as mpl mpl.rcParams['axes.color_cycle']=['#e24a33','#2A749A','#988ed5'] us=[] for d in dirs: f=shell_exec('grep ngrid %s/CONTROL'%d) ks=sscanf(f," ngrid(:)=%d %d %d") f=np.loadtxt('%s/BTE.kappa_tensor'%d) print ks if len(f.shape)==2: x=f[-1] else: x=f x=x[1:].reshape([3,3]) print x us.append([ks,x]) with fig('kkappa_64nn.png',legend=True): p1=filter(lambda u: u[0][0]==64,us) k1=[] k2=[] k3=[] ks=[] for u in p1: ks.append(u[0][1]) k1.append(u[1][0,0]) k2.append(u[1][1,1]) k3.append(u[1][2,2]) f=np.argsort(ks) ks=np.array(ks)[f];k1=np.array(k1)[f];k2=np.array(k2)[f];k3=np.array(k3)[f]; pl.plot(ks,k1,markersize=30,linestyle='--',markeredgecolor='w',marker=".",label="${\kappa_{xx}}$") pl.plot(ks,k2,markersize=15,linestyle='--',markeredgecolor='w',marker="v",label="${\kappa_{yy}}$") pl.plot(ks,k3,markersize=15,linestyle='--',markeredgecolor='w',marker="^",label="${\kappa_{zz}}$") pl.ylim([0,0.35]) pl.xlim([0,np.array(ks).max()+1]) pl.xlabel("$Nq_y$ and $Nq_z$") pl.ylabel("Themal Conductivity (W/mK)") with fig('kkappa_n44.png',legend=True): p1=filter(lambda u: u[0][1]==4,us) k1=[] k2=[] k3=[] ks=[] for u in p1: ks.append(u[0][0]) k1.append(u[1][0,0]) k2.append(u[1][1,1]) k3.append(u[1][2,2]) f=np.argsort(ks) ks=np.array(ks)[f];k1=np.array(k1)[f];k2=np.array(k2)[f];k3=np.array(k3)[f]; pl.plot(ks,k1,markersize=30,linestyle='--',markeredgecolor='w',marker=".",label="${\kappa_{xx}}$") pl.plot(ks,k2,markersize=15,linestyle='--',markeredgecolor='w',marker="v",label="${\kappa_{yy}}$") pl.plot(ks,k3,markersize=15,linestyle='--',markeredgecolor='w',marker="^",label="${\kappa_{zz}}$") pl.ylim([0,0.35]) pl.xlim([0,np.array(ks).max()+100]) pl.xlabel("$Nq_x$") pl.ylabel("Themal Conductivity (W/mK)")
def vtao(self): #group velocity vs. tao using old version of shengbte w=np.loadtxt('BTE.w_final') w=np.abs(w) omega=np.loadtxt('BTE.omega')/(2.0*np.pi) w[omega<omega.flatten().max()*0.005]=float('nan') tao=1.0/w+1e-6 v=np.loadtxt(open('BTE.v')) n,m=v.shape v=v.reshape([n,3,m/3]) v=np.linalg.norm(v,axis=1) l=v*tao l[l<1e-6]=None with fig('tao_v.png'): pl.semilogy(v.flatten(),tao.flatten(),linestyle='.',marker='.',color='r',markersize =5) pl.xlabel('Group Velocity (nm/ps)') pl.ylabel('Relaxation Time (ps)') pl.grid(True) with fig('tao_l.png'): pl.loglog(l.flatten(),tao.flatten(),linestyle='.',marker='.',color='r',markersize =5) pl.xlabel('Mean Free Path (nm)') pl.ylabel('Relaxation Time (ps)') pl.grid(True) with fig('v_l.png'): pl.semilogy(v.flatten(),l.flatten(),linestyle='.',marker='.',color='r',markersize =5) pl.xlabel('Group Velocity (nm/ps)') pl.ylabel('Mean Free Path (nm)') pl.grid(True)
def kmfp(self): def ff(p,x): #return p[0]*(1.0-np.exp(-x**p[2]/p[1])) return 1.0/(p[1]/x+1/p[0])-p[2] #return p[0]*p[1]**x def fit(x,z,p0,tt): def errorfunc(p,x,z): return tt(p,x)-z from scipy.optimize import leastsq solp, ier = leastsq(errorfunc, p0, args=(x,z), Dfun=None, full_output=False, ftol=1e-9, xtol=1e-9, maxfev=100000, epsfcn=1e-10, factor=0.1) return solp dirs=ls('shengold*') from aces.scanf import sscanf from aces.graph import fig,pl us=[] for d in dirs: f=shell_exec('grep ngrid %s/CONTROL'%d) ks=sscanf(f," ngrid(:)=%d %d %d") if(ks[1]!=4):continue f=np.loadtxt('%s/BTE.cumulative_kappa_scalar'%d) us.append([ks,f]) with fig('reduce_mfp.png',legend=True,ncol=1): for i,u in enumerate(us): if i <3:continue ks,f=u x,y=f[:,0],f[:,1] pl.semilogx(x,y,label="Nx= %d "%ks[0],linewidth=2) ks,f=us[-1] x,y=f[:,0],f[:,1] #fil=(x>0) #p=fit(x[fil],y[fil],[1,1,1],ff) #y1=ff(p,x) #pl.semilogx(x,y1,label="fit of Nx= %d "%ks[0],linewidth=2) pl.xlabel('Cutoff Mean Free Path for Phonons (Angstrom)') pl.ylabel('Thermal Conductivity (W/mK)') pl.grid(True) with fig('kappa_inv_mpf_inv.png',legend=True,ncol=1): ks,f=us[-1] fil=x>.5 x,y=f[fil,0],f[fil,1] xx=1/x;yy=1/y pl.plot(xx,yy,linewidth=3,c='red',label="Nx=1024") def ll(p,x): return p[0]*x+p[1] fil=xx>xx.max()/4 p=fit(xx[fil],yy[fil],[1,1,1],ll) pl.plot(xx,ll(p,xx),lw=3,ls='dashed',label="Fitted") pl.xlabel('1/L (1/Angstrom)') pl.ylabel('$1/\\kappa_L$ (mK/W)') pl.grid(True)
def drawdos(self): from aces.ElectronicDOS.electronicdos import ElectronicDOS doscar = ElectronicDOS() # orbital_dos = doscar.sum_ms_dos() # Create a list of each atom type to sum over. # type_list = [] # n = 0 # for i in range(len(doscar.unit_cell.atom_types)): # type_list.append([]) # for j in range(doscar.unit_cell.atom_types[i]): # type_list[i].append(n) # n += 1 # Sum dos over sets of atoms. # partial_dos = doscar.sum_site_dos(type_list,orbital_dos) dos = doscar.write_dos([doscar.tot_dos]) tl.write(dos, 'dos.txt') dos = np.loadtxt('dos.txt') f = tl.shell_exec("grep fermi OUTCAR|tail -1") from aces.scanf import sscanf f = sscanf(f, "E-fermi : %f XC(G=0):") with fig("dos.png"): pl.xlabel("Energy-Ef (eV)") pl.ylabel("DOS") pl.plot(dos[:, 0] - f, dos[:, 1], lw=2) pl.xlim([-4, 4])
def drawdos(self): from aces.ElectronicDOS.electronicdos import ElectronicDOS doscar = ElectronicDOS() #orbital_dos = doscar.sum_ms_dos() ## Create a list of each atom type to sum over. #type_list = [] #n = 0 #for i in range(len(doscar.unit_cell.atom_types)): # type_list.append([]) # for j in range(doscar.unit_cell.atom_types[i]): # type_list[i].append(n) # n += 1 ## Sum dos over sets of atoms. #partial_dos = doscar.sum_site_dos(type_list,orbital_dos) dos = doscar.write_dos([doscar.tot_dos]) write(dos, 'dos.txt') dos = np.loadtxt('dos.txt') f = shell_exec("grep fermi OUTCAR|tail -1") from aces.scanf import sscanf f = sscanf(f, "E-fermi : %f XC(G=0):") with fig("dos.png"): pl.xlabel("Energy-Ef (eV)") pl.ylabel("DOS") pl.plot(dos[:, 0] - f, dos[:, 1], lw=2) pl.xlim([-4, 4])
def grtao(self): cd('T300K') # 画格林艾森系数与驰豫时间的关系 w = np.loadtxt('BTE.w_final')[:, 1] w = np.abs(w) q = np.loadtxt(open('../BTE.qpoints')) n = len(q) w = w.T.reshape([-1, n]) w = np.einsum('jk->kj', w) w.flags.writeable = True omega = np.loadtxt('../BTE.omega') / (2.0 * np.pi) w[omega < omega.flatten().max() * 0.005] = float('nan') tao = 1.0 / w + 1e-6 g = np.loadtxt('../BTE.gruneisen') with fig("gruneisen_tao.png"): pl.semilogy( g.flatten(), tao.flatten(), ls='.', marker='.', color='r', markersize=10) pl.ylabel('Relaxation Time (ps)') pl.xlabel('Gruneisen Coeffecient') pl.xlim([-10, 5]) pl.ylim([0, 1e4])
def taoth(self): #tao vs. direction in xy plane using old version of shengbte w=np.loadtxt('BTE.w_final') w=np.abs(w) omega=np.loadtxt('BTE.omega')/(2.0*np.pi) w[omega<omega.flatten().max()*0.005]=float('nan') tao=1.0/w+1e-6 tao[tao>10000]=0 tao=np.nan_to_num(tao) u=self.getQFmap() tao=tao[u] #为了限制q点在BZ,必须自己重新来 #qpoints_full=np.loadtxt('BTE.qpoints_full') #q=qpoints_full[:,-3:] q=self.getQ() with fig('tao_th.png'): ax = pl.subplot(111, projection='polar') N=100 th=np.linspace(0,1,N)*np.pi*2.0-np.pi r=np.zeros_like(th) r1=np.zeros_like(th) theta=np.arctan2(q[:,1],q[:,0]) for i in np.arange(1): for j,tt in enumerate(th): if j==len(th)-1: fil=(theta>=tt) else: fil=(theta>=tt) *(theta<th[j+1]) r[j]=np.nan_to_num(tao[fil].mean()) r1[j]=np.nan_to_num(fil.sum()) c = pl.plot(th, r,lw=2) #pl.plot(th, r1,lw=2) #c.set_alpha(0.75) #pl.semilogy(q[:,0].flatten(),tao[:,i].flatten(),linestyle='.',marker='.',color='r',markersize =5) pl.grid(True)
def vtao(self): # group velocity vs. tao using old version of shengbte w = np.loadtxt('BTE.w_final') w = np.abs(w) omega = np.loadtxt('BTE.omega') / (2.0 * np.pi) w[omega < omega.flatten().max() * 0.005] = float('nan') tao = 1.0 / w + 1e-6 v = np.loadtxt(open('BTE.v')) n, m = v.shape v = v.reshape([n, 3, m / 3]) v = np.linalg.norm(v, axis=1) l = v * tao l[l < 1e-6] = None with fig('tao_v.png'): pl.semilogy( v.flatten(), tao.flatten(), linestyle='.', marker='.', color='r', markersize=5) pl.xlabel('Group Velocity (nm/ps)') pl.ylabel('Relaxation Time (ps)') pl.grid(True) with fig('tao_l.png'): pl.loglog( l.flatten(), tao.flatten(), linestyle='.', marker='.', color='r', markersize=5) pl.xlabel('Mean Free Path (nm)') pl.ylabel('Relaxation Time (ps)') pl.grid(True) with fig('v_l.png'): pl.semilogy( v.flatten(), l.flatten(), linestyle='.', marker='.', color='r', markersize=5) pl.xlabel('Group Velocity (nm/ps)') pl.ylabel('Mean Free Path (nm)') pl.grid(True)
def postbol(self): seebeck = np.loadtxt("diam_seebeck.dat", skiprows=2) ef = self.getfermi() mu = seebeck[:, 0] - ef filter = (mu < 2) * (mu > -2) mu = mu[filter] seebeck = seebeck[filter] s1 = seebeck[:, 2] s2 = seebeck[:, 6] s3 = seebeck[:, 10] from aces.graph import fig, pl with fig("Seebeck.png", legend=True): pl.plot(mu, s1, label="Sxx") pl.plot(mu, s2, label="Syy") pl.plot(mu, s3, label="Szz") pl.xlabel("$\mu$-Ef (eV)") pl.ylabel("Seebeck Coefficient (V/K)") sigma = np.loadtxt("diam_elcond.dat") sigma = sigma[filter] with fig("Sigma.png", legend=True): pl.plot(mu, sigma[:, 2], label="$\sigma$ xx") pl.plot(mu, sigma[:, 4], label="$\sigma$ yy") pl.plot(mu, sigma[:, 7], label="$\sigma$ zz") pl.xlabel("$\mu$-Ef (eV)") pl.ylabel("Electrical conductivity (1/$\Omega$/m)") kappa = np.loadtxt("diam_kappa.dat") kappa = kappa[filter] with fig("kappa.png", legend=True): pl.plot(mu, kappa[:, 2], label="$\kappa$ xx") pl.plot(mu, kappa[:, 4], label="$\kappa$ yy") pl.plot(mu, kappa[:, 7], label="$\kappa$ zz") pl.xlabel("$\mu$-Ef (eV)") pl.ylabel("Thermal Conductivity (W/m/K)") with fig("powerfactor.png", legend=True): pl.plot(mu, sigma[:, 2] * s1 * s1, label="Pxx") pl.plot(mu, sigma[:, 4] * s2 * s2, label="Pyy") pl.plot(mu, sigma[:, 7] * s3 * s3, label="Pzz") pl.xlabel("$\mu$-Ef (eV)") pl.ylabel("Power Factor ") dos = np.loadtxt("diam_boltzdos.dat") with fig("boltzdos.png"): pl.plot(dos[:, 0], dos[:, 1]) pl.xlabel("E-Ef (eV)") pl.ylabel("Electron Density of States (arbitrary unit)")
def getmsd(): allpos = np.load('allpos.npy') r = allpos - allpos[0] r_atom = np.linalg.norm(r, axis=2) r = r_atom.mean(axis=1) f = open("msd.txt", 'w') for i, x in enumerate(r): print >>f, "%.3f\t%.3f" % (i * 0.25, x) with fig('msd.png'): pl.plot(np.arange(len(r)) * .25, r)
def getmsd(): allpos = np.load('allpos.npy') r = allpos - allpos[0] r_atom = np.linalg.norm(r, axis=2) r = r_atom.mean(axis=1) f = open("msd.txt", 'w') for i, x in enumerate(r): print >> f, "%.3f\t%.3f" % (i * 0.25, x) with fig('msd.png'): pl.plot(np.arange(len(r)) * .25, r)
def post(self): file = ls("*.trace")[0] d = np.loadtxt(file, skiprows=1) d[:, 0] -= self.get_outfermi() d[:, 0] *= 13.6 T = np.unique(d[:, 1]) T = [300] with fig("Seebeck.png"): pl.xlabel("Energy (eV)") pl.ylabel("Seebeck Coefficient ($\mu$V/K)") for t in [T[-1]]: idx = d[:, 1] == t pl.plot(d[idx, 0], d[idx, 4], label="T=" + str(t)) with fig("kappa.png"): pl.xlabel("Energy (eV)") pl.ylabel("Electronic Thermal Conductivity (W/mK)") for t in [T[-1]]: idx = d[:, 1] == t pl.plot(d[idx, 0], d[idx, 7], label="T=" + str(t)) with fig("powerfactor.png"): pl.xlabel("Energy (eV)") pl.ylabel("$S^{2}\sigma/\\tau $") for t in [T[-1]]: idx = d[:, 1] == t S = d[idx, 4] sigma = d[idx, 5] pl.plot(d[idx, 0], S * S * sigma, label="T=" + str(t)) with fig("sigma.png"): pl.xlabel("Energy (eV)") pl.ylabel("$sigma/\\tau $") for t in [T[-1]]: idx = d[:, 1] == t sigma = d[idx, 5] pl.plot(d[idx, 0], sigma, label="T=" + str(t)) with fig("Rh-n.png"): pl.xlabel("Energy (eV)") pl.ylabel("$sigma/\\tau $") for t in [T[-1]]: idx = d[:, 1] == t Rh = d[idx, 6] n = d[idx, 2] pl.plot(d[idx, 0], 1 / Rh, label="T=" + str(t)) pl.plot(d[idx, 0], n, label="T=" + str(t))
def post(self): file = tl.ls("*.trace")[0] d = np.loadtxt(file, skiprows=1) d[:, 0] -= self.get_outfermi() d[:, 0] *= 13.6 T = np.unique(d[:, 1]) T = [300] with fig("Seebeck.png"): pl.xlabel("Energy (eV)") pl.ylabel("Seebeck Coefficient ($\mu$V/K)") for t in [T[-1]]: idx = d[:, 1] == t pl.plot(d[idx, 0], d[idx, 4], label="T=" + str(t)) with fig("kappa.png"): pl.xlabel("Energy (eV)") pl.ylabel("Electronic Thermal Conductivity (W/mK)") for t in [T[-1]]: idx = d[:, 1] == t pl.plot(d[idx, 0], d[idx, 7], label="T=" + str(t)) with fig("powerfactor.png"): pl.xlabel("Energy (eV)") pl.ylabel("$S^{2}\sigma/\\tau $") for t in [T[-1]]: idx = d[:, 1] == t S = d[idx, 4] sigma = d[idx, 5] pl.plot(d[idx, 0], S * S * sigma, label="T=" + str(t)) with fig("sigma.png"): pl.xlabel("Energy (eV)") pl.ylabel("$sigma/\\tau $") for t in [T[-1]]: idx = d[:, 1] == t sigma = d[idx, 5] pl.plot(d[idx, 0], sigma, label="T=" + str(t)) with fig("Rh-n.png"): pl.xlabel("Energy (eV)") pl.ylabel("$sigma/\\tau $") for t in [T[-1]]: idx = d[:, 1] == t Rh = d[idx, 6] n = d[idx, 2] pl.plot(d[idx, 0], 1 / Rh, label="T=" + str(t)) pl.plot(d[idx, 0], n, label="T=" + str(t))
def postT(self): a = np.loadtxt("BTE.KappaTensorVsT_CONV") with fig('T_kappa.png', legend=True): ts = a[:, 0] fil = ts <= 800 k1 = a[fil, 1] k2 = a[fil, 5] k3 = a[fil, 9] ts = a[fil, 0] pl.plot(ts, k1, lw=2, label="${\kappa_{xx}}$") pl.plot(ts, k2, lw=2, label="${\kappa_{yy}}$") pl.plot(ts, k3, lw=2, label="${\kappa_{zz}}$") pl.xlabel("Tempeature (K)") pl.ylabel('Thermal Conductivity (W/mK)')
def drawpr(self): pr() # plot xs = [] ys = [] for line in open('pr.txt'): x, y = map(float, line.split()) xs.append(x) ys.append(y) write("%s" % (sum(ys) / len(ys)), "ave_pr.txt") with fig('Paticipation_ratio.png'): pl.plot(xs, ys, '.', color='red') pl.ylim([0.0, 1.0]) pl.xlabel('Frequency (THz)') pl.ylabel('Paticipation Ratio')
def kappat(self): a = np.loadtxt("BTE.KappaTensorVsT_CONV") import matplotlib as mpl mpl.rcParams['axes.color_cycle'] = ['#e24a33', '#2A749A', '#988ed5'] with fig('T_kappa.png', legend=True): ts = a[:, 0] fil = ts <= 800 ts = a[fil, 0] k1 = 1.0 / 3 * (a[fil, 1] + a[fil, 5] + a[fil, 9]) pl.plot(ts, k1, lw=3, label="Iso-Phonon") pl.xlabel("Tempeature (K)") pl.ylabel('Thermal Conductivity (W/mK)') file = ls("*.trace")[0] d = np.loadtxt(file, skiprows=1) idx = d[:, 0] == d[np.abs(np.unique(d[:, 0])).argmin(), 0] tao = 2.93e-14 pl.plot(d[idx, 1], d[idx, 7] * tao, lw=3, label="Iso-Electron") pl.xlim([200, 800])
def kappat(self): a = np.loadtxt("BTE.KappaTensorVsT_CONV") import matplotlib as mpl mpl.rcParams['axes.color_cycle'] = ['#e24a33', '#2A749A', '#988ed5'] with fig('T_kappa.png', legend=True): ts = a[:, 0] fil = ts <= 800 ts = a[fil, 0] k1 = 1.0 / 3 * (a[fil, 1] + a[fil, 5] + a[fil, 9]) pl.plot(ts, k1, lw=3, label="Iso-Phonon") pl.xlabel("Tempeature (K)") pl.ylabel('Thermal Conductivity (W/mK)') file = tl.ls("*.trace")[0] d = np.loadtxt(file, skiprows=1) idx = d[:, 0] == d[np.abs(np.unique(d[:, 0])).argmin(), 0] tao = 2.93e-14 pl.plot(d[idx, 1], d[idx, 7] * tao, lw=3, label="Iso-Electron") pl.xlim([200, 800])
def reducemsd(): msd = np.loadtxt('600K/msd.txt') time = msd[:, 0] aa = [] aa.append(np.loadtxt('msd.txt')[:500, 1]) aa.append(np.loadtxt('600K/msd.txt')[:, 1]) aa.append(np.loadtxt('700K/msd.txt')[:, 1]) aa.append(np.loadtxt('800K/msd.txt')[:, 1]) aa.append(np.loadtxt('900K/msd.txt')[:, 1]) aa = np.array(aa) ll = [300, 600, 700, 800, 900] import matplotlib matplotlib.rcParams['legend.fontsize'] = 12 with fig('msd_T.png', legend=True): for i, x in enumerate(aa): pl.plot(time, x, lw=2, label="%sK" % ll[i]) pl.xlabel("Time (fs)") pl.ylabel("Mean Square Displacement (Angstrom)")
def oldT(self): from aces.graph import fig,pl import matplotlib as mpl mpl.rcParams['axes.color_cycle']=['#e24a33','#2A749A','#988ed5'] ts=np.arange(200,801,100) a=[] for dir in ts: print dir x=np.loadtxt("12844."+str(dir)+"K/BTE.kappa_tensor") a.append(x) a=np.array(a) with fig('T_kappa.png',legend=True): k1=a[:,1] k2=a[:,5] k3=a[:,9] pl.plot(ts,k1,lw=3,markersize=30,linestyle='--',markeredgecolor='w',marker=".",label="${\kappa_{xx}}$") pl.plot(ts,k2,lw=3,markersize=15,linestyle='--',markeredgecolor='w',marker="v",label="${\kappa_{yy}}$") pl.plot(ts,k3,lw=3,markersize=15,linestyle='--',markeredgecolor='w',marker="^",label="${\kappa_{zz}}$") pl.xlabel("Tempeature (K)") pl.ylabel('Thermal Conductivity (W/mK)') pl.xlim([200,800])
def taoth(self): # tao vs. direction in xy plane using old version of shengbte w = np.loadtxt('BTE.w_final') w = np.abs(w) omega = np.loadtxt('BTE.omega') / (2.0 * np.pi) w[omega < omega.flatten().max() * 0.005] = float('nan') tao = 1.0 / w + 1e-6 tao[tao > 10000] = 0 tao = np.nan_to_num(tao) u = self.getQFmap() tao = tao[u] # 为了限制q点在BZ,必须自己重新来 # qpoints_full=np.loadtxt('BTE.qpoints_full') # q=qpoints_full[:,-3:] q = self.getQ() with fig('tao_th.png'): # ax = pl.subplot(111, projection='polar') N = 100 th = np.linspace(0, 1, N) * np.pi * 2.0 - np.pi r = np.zeros_like(th) r1 = np.zeros_like(th) theta = np.arctan2(q[:, 1], q[:, 0]) for i in np.arange(1): for j, tt in enumerate(th): if j == len(th) - 1: fil = (theta >= tt) else: fil = (theta >= tt) * (theta < th[j + 1]) r[j] = np.nan_to_num(tao[fil].mean()) r1[j] = np.nan_to_num(fil.sum()) # c = pl.plot(th, r, lw=2) # pl.plot(th, r1,lw=2) # c.set_alpha(0.75) # pl.semilogy(q[:,0].flatten(),tao[:,i].flatten() # ,linestyle='.',marker='.',color='r',markersize =5) pl.grid(True)
# -*- coding: utf-8 -*- # @Author: YangZhou # @Date: 2017-06-30 15:31:06 # @Last Modified by: YangZhou # @Last Modified time: 2017-06-30 15:49:41 import pandas as pd from aces.graph import fig, pl, setLegend df = pd.read_csv("dos/knot/0/region_dos.txt", sep=r"[ \t]", engine="python") npair = len(df.columns) / 2 datas = [] for i in range(npair): rname = df.columns[i * 2][5:] datas.append((df['freq_' + rname], df['dos_' + rname], "region:" + rname)) dc = pd.read_csv("dos/knot/0/graphenedos.txt", sep=r"[ \t]", engine="python") datas.append((dc[dc.columns[0]], dc[dc.columns[1]], 'GNR')) with fig("dos.eps", figsize=(10, 6)): for d in datas: pl.plot(d[0], d[1], label=d[2]) setLegend(pl) pl.xlabel("Frequency (THz)") pl.ylabel("Phonon Density of States") pl.xlim([0, 60])
kapitza = [] i = -1 for dT in range(0, 60, 10): i += 1 p = np.loadtxt(str(i) + '/tempAve.txt', skiprows=1) data.append([p[:, 1], p[:, 3], 'dT=' + str(dT)]) dataT = p[30, 3] - p[20, 3] j = (p[:, 4] * p[:, 2]).sum() / p[:, 2].sum() kapitza.append([dT, np.abs(j) / dataT]) kapitza = np.array(kapitza) from aces.graph import series, plot, fig, pl series(xlabel='x (Angstrom)', ylabel='Temperature (K)', datas=data, filename='profile.png') with fig('kapitza.png'): x = kapitza[:, 0] y = kapitza[:, 1] pl.plot(x, y, marker='v', ms=12, mec='b', mfc='w', mfcalt="w", mew=1.5, linewidth=1) pl.xlabel('dT(K)') pl.ylabel('Kapitza Conductance (W/m2K)') pl.xlim([-5, 55]) #plot([kapitza[:,0],'dT(K)'],[kapitza[:,1],'Kapitza Conductance (W/m2K)'],'kapitza.png')
def plotchg(): ch = getcharge() with fig("chg.png"): pl.imshow(ch[0])
# ylabel='Stress (GPa)', # datas=datas # ,linewidth=1 # ,filename='stress_strain.png',legend=False,grid=True) s = [] for i, u in enumerate(c): if not len(u) == len(c[0]): print i continue s.append(u) s = np.array(s) x = s[0, :, 0] y = s[:, :, 1].mean(axis=0) dy = s[:, :, 1].std(axis=0) y1 = y + dy / 2.0 y2 = y - dy / 2.0 with fig("ave_stress.png"): pl.fill_between(x, y1, y2, color="#cccccc") pl.plot(x, y, lw=2, color='r') pl.xlabel('Strain') pl.ylabel('Stress (GPa)') pl.xlim([0, 0.8]) pl.ylim([0, 21]) with fig('stress_strain.png'): for y in s[:, :, 1]: pl.plot(x, y, color="black", alpha=0.01) pl.xlabel('Strain') pl.ylabel('Stress (GPa)') pl.xlim([0, 0.8]) pl.ylim([0, 30])
k, = sscanf(p, 'kappa_src=%f') kappa.append([lx, strain, k]) i = -1 for lx, procs, nodes in [(180, 12, 1)]: for j in range(N): continue i += 1 dir = "sl/lx2/" + str(i) strain = 0.05 * j / N p = tl.shell_exec('tail -1 %s/result.txt' % dir) k, = sscanf(p, 'kappa_src=%f') kappa.append([lx, strain, k]) kappa = np.array(kappa) ms = ['D', 'o', 'x', 's', '^', 'p', '.', '+'] with fig('tc_lx.eps', legend=False, figsize=(10, 6)): axis = pl.subplot(1, 2, 1) strains = np.unique(kappa[:, 1]) i = -1 for s in strains: i += 1 filter = kappa[:, 1] == s x = kappa[filter, 0] y = kappa[filter, 2] axis.plot(x, y, marker=ms[i], ms=8, mec=None, mfc='w',
n = len(d) m = len(d[0][0]) ss = np.zeros([n, m]) i = -1 for s, v in d: i += 1 m = len(s) ss[i, :m] = s[:, 1] ss = np.abs(ss) < .5 kk = ss.sum(axis=0) s = d[0][0] x = s[:, 0] y = kk.astype(np.float) / len(d) from aces.graph import setLegend with fig('drop_position.png', legend=False, ncol=1, figsize=(14, 10)): oldpl = pl pl = oldpl.subplot(2, 2, 1) c = ['g', 'r', 'b', 'orange'] dx = 0.05 for i, serie in enumerate(datas): pl.fill_between(serie[0], 0, serie[1], label=serie[2], linewidth=0, facecolor=c[i], alpha=.5) pl.plot(serie[0], serie[1], label=serie[2], color=c[i], linewidth=2) #pl.bar(serie[0]-dx*.5,serie[1],label=serie[2],color=c[i],alpha = .5,width=dx) pl.set_xlabel('Strain')
# -*- coding: utf-8 -*- # @Author: YangZhou # @Date: 1970-01-01 08:00:00 # @Last Modified by: YangZhou # @Last Modified time: 2017-06-30 15:44:36 from aces.graph import fig, pl import numpy as np with fig('cycle.eps'): fi, axes = pl.subplots(1, 2, sharex=True, figsize=(10, 5)) y = np.loadtxt("strain/circle/right/9/cal_stress.txt", skiprows=1) axes[0].plot(y[:, 0], y[:, 1], color="k", lw=2) axes[0].set_xlabel("Strain") axes[0].set_ylabel("Stress(GPa)") y = np.loadtxt("strain/circle/graphene/0/cal_stress.txt", skiprows=1) axes[1].plot(y[:, 0], y[:, 1], color="k", lw=2) axes[1].set_xlabel("Strain") axes[1].set_ylabel("Stress(GPa)")
def post(self): import matplotlib as mpl mpl.rcParams['axes.color_cycle'] = ['#e24a33', '#2A749A', '#988ed5'] file = tl.ls("*.trace")[0] d = np.loadtxt(file, skiprows=1) head = tl.shell_exec("head -1 %s" % file) if("Ry" in head): d[:, 0] -= self.get_outfermi() d[:, 0] *= 13.6 # T=np.unique(d[:,1]) zz = d[np.abs(np.unique(d[:, 0])).argmin(), 0] Tplot = [200, 300, 700] tao = 2.93e-14 # tao=2.93e-13 # T=[300] with fig("Seebeck.png", legend=True): # pl.style.use('ggplot') pl.xlabel("$\\mu$ (eV)") pl.ylabel("Seebeck Coefficient ($\mu$V/K)") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t pl.plot(d[idx, 0], d[idx, 4], lw=3, label="T=" + str(t) + "K") with fig("kappa.png", legend=True): # W/mK*1/s pl.xlabel("$\\mu$ (eV)") pl.ylabel("Electronic Thermal Conductivity (W/mK)") for t in Tplot: idx = (d[:, 1] == t) * (d[:, 0] <= 1.5) * (d[:, 0] >= -1.5) pl.plot(d[idx, 0], d[idx, 7] * tao, lw=3, label="T=" + str(t) + "K") pl.xlim([-1.5, 1.5]) with fig("kappa_t.png"): pl.xlabel("Temperature (K)") pl.ylabel("Electronic Thermal Conductivity (W/mK)") idx = d[:, 0] == zz pl.plot(d[idx, 1], d[idx, 7] * tao, lw=3) with fig("powerfactor.png", legend=True): pl.xlabel("$\\mu$ (eV)") pl.ylabel("$S^{2}\sigma (mW/mK^2)$") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t S = d[idx, 4] * 1e-6 sigma = d[idx, 5] * tao pl.plot(d[idx, 0], S * S * sigma * 1e3, lw=3, label="T=" + str(t) + "K") try: a = np.loadtxt("BTE.KappaTensorVsT_CONV") k1 = 1.0 / 3 * (a[:, 1] + a[:, 5] + a[:, 9]) with fig("ZT.png", legend=True, ncol=1): pl.xlabel("$\\mu$ (eV)") pl.ylabel("$ZT$") pl.xlim([-1.5, 1.5]) pl.ylim([0, 1.0]) for t in Tplot: idx = d[:, 1] == t fil = a[:, 0] == t tc = k1[fil][0] S = d[idx, 4] * 1e-6 sigma = d[idx, 5] * tao po = S * S * sigma ke = d[idx, 7] * tao pl.plot(d[idx, 0], po * t / (ke + tc), lw=3, label="T=" + str(t) + "K") except Exception as e: print(e) with fig("sigma.png", legend=True): # 1/(ohm m)*1/s pl.xlabel("$\\mu$ (eV)") pl.ylabel("$\\sigma (10^6/\\Omega m) $") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t sigma = d[idx, 5] * tao pl.plot(d[idx, 0], sigma * 1e-6, lw=3, label="T=" + str(t) + "K") with fig("Rh-n.png", legend=True): pl.xlabel("$\\mu$ (eV)") pl.ylabel("$\\sigma/\\tau $") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t Rh = d[idx, 6] n = d[idx, 2] pl.plot(d[idx, 0], 1 / Rh, lw=3, label="Rh,T=" + str(t) + "K") pl.plot(d[idx, 0], n, lw=3, label="nT=" + str(t) + "K")
# -*- coding: utf-8 -*- # @Author: YangZhou # @Date: 2017-06-27 23:39:13 # @Last Modified by: YangZhou # @Last Modified time: 2017-06-27 23:43:11 import numpy as np from aces.graph import fig, pl with fig('transmission.eps'): fi, axes = pl.subplots(figsize=(10, 7)) ax = axes file = "negf/knot/0/transmission.txt" f = np.loadtxt(file, skiprows=1) freq = f[:, 0] trans = f[:, 3] ax.plot(freq, trans, color="r") fi.text(0.5, 0.04, 'Phonon Frequency (THz)', ha='center') fi.text(0.07, 0.5, 'Phonon Transmission', va='center', rotation='vertical') fi.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0, hspace=0)
def postold(self): try: df = pd.read_csv( "BTE.kappa_scalar", sep=r"[ \t]+", header=None, names=['step', 'kappa'], engine='python') ks = np.array(df['kappa']) plot( (np.array(df['step']), 'Iteration Step'), (ks, 'Thermal Conductivity (W/mK)'), 'kappa_scalar.png', grid=True, linewidth=2) except Exception as e: print(e) try: df = pd.read_csv( "BTE.cumulative_kappa_scalar", sep=r"[ \t]+", header=None, names=['l', 'kappa'], engine='python') ks = np.array(df['kappa']) plot( (np.array(df['l']), 'Cutoff Mean Free Path for Phonons (Angstrom)'), (ks, 'Thermal Conductivity (W/mK)'), 'cumulative_kappa_scalar.png', grid=True, linewidth=2, logx=True) except Exception as e: print(e) try: omega = np.loadtxt('BTE.omega') / (2.0 * np.pi) kappa = np.loadtxt('BTE.kappa')[-1, 1:] kappa = np.einsum('jji', kappa.reshape([3, 3, -1])) / 3.0 plot( (np.arange(len(omega[0])), 'Band'), (kappa, 'Thermal Conductivity (W/mK)'), 'kappa_band.png', grid=True, linewidth=2) plot( (np.arange(len(omega[0])), 'Band'), (kappa.cumsum(), 'Thermal Conductivity (W/mK)'), 'cumulative_kappa_band.png', grid=True, linewidth=2) except Exception as e: print(e) try: w = np.loadtxt('BTE.w_final') w = np.abs(w) w[omega < omega.flatten().max() * 0.005] = float('nan') plot( (omega.flatten(), 'Frequency (THz)'), (w.flatten(), 'Scatter Rate (THz)'), 'scatter_freq.png', grid=True, scatter=True, logy=True) tao = 1.0 / w + 1e-6 with fig('tao_freq.png'): pl.semilogy( omega.flatten(), tao.flatten(), linestyle='.', marker='.', color='r', markersize=5) pl.xlabel('Frequency (THz)') pl.ylabel('Relaxation Time (ps)') pl.grid(True) pl.xlim([0, omega.max()]) # pl.ylim([0,tao.flatten().max()]) to_txt(['freq', 'tao'], np.c_[omega.flatten(), tao.flatten()], 'tao_freq.txt') except Exception as e: print(e) """ if not exists('relaxtime'):mkdir('relaxtime') cd('relaxtime') for i,om in enumerate(omega[:6]): print "q : ",i plot((om,'Frequency (THz)'),(tao[i],'Relaxation Time (ps)'), 'tao_freq_q%d.png'%i,grid=True,scatter=True,logx=True,logy=True) cd('..') """ try: v = np.loadtxt(open('BTE.v')) n, m = v.shape v = v.reshape([n, 3, m / 3]) v = np.linalg.norm(v, axis=1) y = (v.flatten(), 'Group Velocity (nm/ps)') plot( (omega.flatten(), 'Frequency (THz)'), y, 'v_freq.png', grid=True, scatter=True) to_txt(['freq', 'vg'], np.c_[omega.flatten(), v.flatten()], 'v_freq.txt') except Exception as e: print(e) try: l = v * tao l[l < 1e-6] = None plot( (omega.flatten(), 'Frequency (THz)'), (l.flatten(), 'Mean Free Path (nm)'), 'lamda_freq.png', grid=True, scatter=True, logy=True, logx=True, xmin=0) to_txt(['freq', 'mfp'], np.c_[omega.flatten(), l.flatten()], 'lamda_freq.txt') except Exception as e: print(e) try: q = np.loadtxt(open('BTE.qpoints')) qnorm = np.linalg.norm(q[:, -3:], axis=1) data = [] n, m = w.shape for i in range(m): data.append([qnorm, w[:, i], 'b']) series( xlabel='|q| (1/nm)', ylabel='Scatter Rate (THz)', datas=data, filename='branchscatter.png', scatter=True, legend=False, logx=True, logy=True) except Exception as e: print(e)
n = len(d) m = len(d[0][0]) ss = np.zeros([n, m]) i = -1 for s, v in d: i += 1 m = len(s) ss[i, :m] = s[:, 1] ss = np.abs(ss) < .5 kk = ss.sum(axis=0) s = d[0][0] x = s[:, 0] y = kk.astype(np.float) / len(d) from aces.graph import setLegend with fig('drop.eps', legend=False, ncol=1, figsize=(10, 6)): oldpl = pl pl = oldpl.subplot(2, 2, 1) c = ['g', 'r', 'b', 'orange'] dx = 0.05 for i, serie in enumerate(datas): pl.fill_between( serie[0], 0, serie[1], label=serie[2], linewidth=0, facecolor=c[i], alpha=.5) pl.plot(serie[0], serie[1], label=serie[2], color=c[i], linewidth=2)
def post(self): cd('T300K') try: df = pd.read_csv( "BTE.kappa_scalar", sep=r"[ \t]+", header=None, names=['step', 'kappa'], engine='python') ks = np.array(df['kappa']) plot( (np.array(df['step']), 'Iteration Step'), (ks, 'Thermal Conductivity (W/mK)'), 'kappa_scalar.png', grid=True, linewidth=2) except Exception as e: print(e) try: df = pd.read_csv( "BTE.cumulative_kappa_scalar", sep=r"[ \t]+", header=None, names=['l', 'kappa'], engine='python') ks = np.array(df['kappa']) plot( (np.array(df['l']), 'Cutoff Mean Free Path for Phonons (Angstrom)'), (ks, 'Thermal Conductivity (W/mK)'), 'cumulative_kappa_scalar.png', grid=True, linewidth=2, logx=True) except Exception as e: print(e) try: omega = np.loadtxt('../BTE.omega') / (2.0 * np.pi) kappa = np.loadtxt('BTE.kappa')[-1, 1:] kappa = np.einsum('jji', kappa.reshape([3, 3, -1])) / 3.0 plot( (np.arange(len(omega[0])), 'Band'), (kappa, 'Thermal Conductivity (W/mK)'), 'kappa_band.png', grid=True, linewidth=2) plot( (np.arange(len(omega[0])), 'Band'), (kappa.cumsum(), 'Thermal Conductivity (W/mK)'), 'cumulative_kappa_band.png', grid=True, linewidth=2) except Exception as e: print(e) try: kappa = np.loadtxt('BTE.cumulative_kappaVsOmega_tensor') with fig("atc_freq.png"): pl.plot(kappa[:, 0], kappa[:, 1], label="${\kappa_{xx}}$") pl.plot(kappa[:, 0], kappa[:, 5], label="${\kappa_{xx}}$") pl.plot(kappa[:, 0], kappa[:, 9], label="${\kappa_{xx}}$") pl.xlabel("Frequency (THz)") pl.ylabel("Cumulative Thermal Conductivity(W/mK)") with fig("tc_freq.png"): pl.plot( kappa[:, 0], np.gradient(kappa[:, 1]), label="${\kappa_{xx}}$") pl.plot( kappa[:, 0], np.gradient(kappa[:, 5]), label="${\kappa_{xx}}$") pl.plot( kappa[:, 0], np.gradient(kappa[:, 9]), label="${\kappa_{xx}}$") pl.xlabel("Frequency (THz)") pl.ylabel("Cumulative Thermal Conductivity(W/mK)") except Exception as e: print(e) try: g = np.loadtxt('../BTE.gruneisen') y = (g.flatten(), 'Gruneisen') plot( (omega.flatten(), 'Frequency (THz)'), y, 'gruneisen_freq.png', grid=True, scatter=True) with fig('gruneisen_freq.png'): pl.scatter( omega.flatten(), g.flatten(), marker='.', color='r', s=50) pl.xlabel('Frequency (THz)') pl.ylabel('Gruneisen Coeffecient') # pl.grid(True) pl.xlim([0, omega.max()]) pl.ylim([-10, 5]) # pl.tick_params(axis='both', which='major', labelsize=14) to_txt(['freq', 'gruneisen'], np.c_[omega.flatten(), g.flatten()], 'gruneisen_freq.txt') g = np.loadtxt('../BTE.P3') with fig('p3_freq.png'): pl.scatter( omega.flatten(), g.flatten() * 1e6, marker='.', color='r', s=50) pl.xlabel('Frequency (THz)') pl.ylabel('P3 $(\\times 10^{-6})$') # pl.grid(True) pl.xlim([0, omega.max()]) pl.ylim([0, g.max() * 1e6]) to_txt(['freq', 'p3'], np.c_[omega.flatten(), g.flatten()], 'p3_freq.txt') except Exception as e: print(e) self.draw_gv() self.draw_branch_scatter() self.draw_tau() cd('..')
i += 1 dir = "sl/nx2/" + str(i) p = np.loadtxt(dir + '/tempAve.txt', skiprows=1) x = np.linspace(0, 1, len(p)) data.append([x, p[:, 3], 'nx=' + str(lx)]) dt = p[10:, 3] - p[:-10, 3] p = tl.shell_exec('tail -1 %s/result.txt' % dir) k, = sscanf(p, 'kappa_src=%f') dt = np.sort(np.abs(dt))[-lx:].mean() kappa.append([lx, k, dt]) data = np.array(data)[::3] kappa = np.array(kappa) with fig('tc_nx.eps', figsize=(10, 6)): # tc-nx axis = pl.subplot(2, 2, 1) x = kappa[:, 0] y = kappa[:, 1] axis.plot( x, y, marker='D', ms=12, mec='b', mfc='w', mfcalt="w", mew=1.5, linewidth=1,
def post(self): import matplotlib as mpl mpl.rcParams['axes.color_cycle'] = ['#e24a33', '#2A749A', '#988ed5'] file = ls("*.trace")[0] d = np.loadtxt(file, skiprows=1) head = shell_exec("head -1 %s" % file) if ("Ry" in head): d[:, 0] -= self.get_outfermi() d[:, 0] *= 13.6 T = np.unique(d[:, 1]) zz = d[np.abs(np.unique(d[:, 0])).argmin(), 0] Tplot = [200, 300, 700] tao = 2.93e-14 #tao=2.93e-13 #T=[300] with fig("Seebeck.png", legend=True): #pl.style.use('ggplot') pl.xlabel("$\\mu$ (eV)") pl.ylabel("Seebeck Coefficient ($\mu$V/K)") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t pl.plot(d[idx, 0], d[idx, 4], lw=3, label="T=" + str(t) + "K") with fig("kappa.png", legend=True): #W/mK*1/s pl.xlabel("$\\mu$ (eV)") pl.ylabel("Electronic Thermal Conductivity (W/mK)") for t in Tplot: idx = (d[:, 1] == t) * (d[:, 0] <= 1.5) * (d[:, 0] >= -1.5) pl.plot(d[idx, 0], d[idx, 7] * tao, lw=3, label="T=" + str(t) + "K") pl.xlim([-1.5, 1.5]) with fig("kappa_t.png"): pl.xlabel("Temperature (K)") pl.ylabel("Electronic Thermal Conductivity (W/mK)") idx = d[:, 0] == zz pl.plot(d[idx, 1], d[idx, 7] * tao, lw=3) with fig("powerfactor.png", legend=True): pl.xlabel("$\\mu$ (eV)") pl.ylabel("$S^{2}\sigma (mW/mK^2)$") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t S = d[idx, 4] * 1e-6 sigma = d[idx, 5] * tao pl.plot(d[idx, 0], S * S * sigma * 1e3, lw=3, label="T=" + str(t) + "K") try: a = np.loadtxt("BTE.KappaTensorVsT_CONV") k1 = 1.0 / 3 * (a[:, 1] + a[:, 5] + a[:, 9]) with fig("ZT.png", legend=True, ncol=1): pl.xlabel("$\\mu$ (eV)") pl.ylabel("$ZT$") pl.xlim([-1.5, 1.5]) pl.ylim([0, 1.0]) for t in Tplot: idx = d[:, 1] == t fil = a[:, 0] == t tc = k1[fil][0] S = d[idx, 4] * 1e-6 sigma = d[idx, 5] * tao po = S * S * sigma ke = d[idx, 7] * tao pl.plot(d[idx, 0], po * t / (ke + tc), lw=3, label="T=" + str(t) + "K") except Exception as e: print e with fig("sigma.png", legend=True): #1/(ohm m)*1/s pl.xlabel("$\\mu$ (eV)") pl.ylabel("$\\sigma (10^6/\\Omega m) $") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t sigma = d[idx, 5] * tao pl.plot(d[idx, 0], sigma * 1e-6, lw=3, label="T=" + str(t) + "K") with fig("Rh-n.png", legend=True): pl.xlabel("$\\mu$ (eV)") pl.ylabel("$\\sigma/\\tau $") pl.xlim([-1.5, 1.5]) for t in Tplot: idx = d[:, 1] == t Rh = d[idx, 6] n = d[idx, 2] pl.plot(d[idx, 0], 1 / Rh, lw=3, label="Rh,T=" + str(t) + "K") pl.plot(d[idx, 0], n, lw=3, label="nT=" + str(t) + "K")
def kmfp(self): def ff(p, x): # return p[0]*(1.0-np.exp(-x**p[2]/p[1])) return 1.0 / (p[1] / x + 1 / p[0]) - p[2] # return p[0]*p[1]**x def fit(x, z, p0, tt): def errorfunc(p, x, z): return tt(p, x) - z from scipy.optimize import leastsq solp, ier = leastsq( errorfunc, p0, args=(x, z), Dfun=None, full_output=False, ftol=1e-9, xtol=1e-9, maxfev=100000, epsfcn=1e-10, factor=0.1) return solp dirs = ls('shengold*') from aces.scanf import sscanf from aces.graph import fig, pl us = [] for d in dirs: f = shell_exec('grep ngrid %s/CONTROL' % d) ks = sscanf(f, " ngrid(:)=%d %d %d") if (ks[1] != 4): continue f = np.loadtxt('%s/BTE.cumulative_kappa_scalar' % d) us.append([ks, f]) with fig('reduce_mfp.png', legend=True, ncol=1): for i, u in enumerate(us): if i < 3: continue ks, f = u x, y = f[:, 0], f[:, 1] pl.semilogx(x, y, label="Nx= %d " % ks[0], linewidth=2) ks, f = us[-1] x, y = f[:, 0], f[:, 1] # fil=(x>0) # p=fit(x[fil],y[fil],[1,1,1],ff) # y1=ff(p,x) # pl.semilogx(x,y1,label="fit of Nx= %d "%ks[0],linewidth=2) pl.xlabel('Cutoff Mean Free Path for Phonons (Angstrom)') pl.ylabel('Thermal Conductivity (W/mK)') pl.grid(True) with fig('kappa_inv_mpf_inv.png', legend=True, ncol=1): ks, f = us[-1] fil = x > .5 x, y = f[fil, 0], f[fil, 1] xx = 1 / x yy = 1 / y pl.plot(xx, yy, linewidth=3, c='red', label="Nx=1024") def ll(p, x): return p[0] * x + p[1] fil = xx > xx.max() / 4 p = fit(xx[fil], yy[fil], [1, 1, 1], ll) pl.plot(xx, ll(p, xx), lw=3, ls='dashed', label="Fitted") pl.xlabel('1/L (1/Angstrom)') pl.ylabel('$1/\\kappa_L$ (mK/W)') pl.grid(True)
def postnew(self): cd('T300K') try: df=pd.read_csv("BTE.kappa_scalar",sep=r"[ \t]+",header=None,names=['step','kappa'],engine='python'); ks=np.array(df['kappa']) plot((np.array(df['step']),'Iteration Step'),(ks,'Thermal Conductivity (W/mK)'),'kappa_scalar.png',grid=True,linewidth=2) except Exception as e: print e try: df=pd.read_csv("BTE.cumulative_kappa_scalar",sep=r"[ \t]+",header=None,names=['l','kappa'],engine='python'); ks=np.array(df['kappa']) plot((np.array(df['l']),'Cutoff Mean Free Path for Phonons (Angstrom)'),(ks,'Thermal Conductivity (W/mK)'),'cumulative_kappa_scalar.png',grid=True,linewidth=2,logx=True) except Exception as e: print e try: omega=np.loadtxt('../BTE.omega')/(2.0*np.pi) kappa=np.loadtxt('BTE.kappa')[-1,1:] kappa=np.einsum('jji',kappa.reshape([3,3,-1]))/3.0 plot((np.arange(len(omega[0])),'Band'),(kappa,'Thermal Conductivity (W/mK)'),'kappa_band.png',grid=True,linewidth=2) plot((np.arange(len(omega[0])),'Band'),(kappa.cumsum(),'Thermal Conductivity (W/mK)'),'cumulative_kappa_band.png',grid=True,linewidth=2) except Exception as e: print e try: w=np.loadtxt('BTE.w_final')[:,1] w=np.abs(w) q=np.loadtxt(open('../BTE.qpoints')) n=len(q) w=w.T.reshape([-1,n]) w=np.einsum('jk->kj',w) w.flags.writeable = True print w.shape,omega.shape w[omega<omega.flatten().max()*0.005]=float('nan') plot((omega.flatten(),'Frequency (THz)'),(w.flatten(),'Scatter Rate (THz)'),'scatter_freq.png',grid=True,scatter=True,logy=True) tao=1.0/w+1e-6 plot((omega.flatten(),'Frequency (THz)'),(tao.flatten(),'Relaxation Time (ps)'),'tao_freq.png',grid=True,scatter=True,logy=True) to_txt(['freq','tao'],np.c_[omega.flatten(),tao.flatten()],'tao_freq.txt') except Exception as e: print e try: v=np.loadtxt(open('../BTE.v')) q=np.loadtxt(open('../BTE.qpoints')) n=len(q) v=v.T.reshape([3,-1,n]) v=np.einsum('ijk->kji',v) v=np.linalg.norm(v,axis=-1) plot((omega.flatten(),'Frequency (THz)'),(v.flatten(),'Group Velocity (nm/ps)'),'v_freq.png',grid=True,scatter=True) to_txt(['freq','vg'],np.c_[omega.flatten(),v.flatten()],'v_freq.txt') l=v*tao plot((omega.flatten(),'Frequency (THz)'),(l.flatten(),'Mean Free Path (nm)'),'lamda_freq.png',grid=True,scatter=True) to_txt(['freq','mfp'],np.c_[omega.flatten(),l.flatten()],'lamda_freq.txt') except Exception as e: print e try: g=np.loadtxt('../BTE.gruneisen') plot((omega.flatten(),'Frequency (THz)'),(g.flatten(),'Gruneisen'),'gruneisen_freq.png',grid=True,scatter=True) with fig('gruneisen_freq.png'): pl.scatter(omega.flatten(),g.flatten(),marker='.',color='r',s =50) pl.xlabel('Frequency (THz)') pl.ylabel('Gruneisen Coeffecient') #pl.grid(True) pl.xlim([0,omega.max()]) pl.ylim([-10,5]) #pl.tick_params(axis='both', which='major', labelsize=14) to_txt(['freq','gruneisen'],np.c_[omega.flatten(),g.flatten()],'gruneisen_freq.txt') g=np.loadtxt('../BTE.P3') with fig('p3_freq.png'): pl.scatter(omega.flatten(),g.flatten()*1e6,marker='.',color='r',s =50) pl.xlabel('Frequency (THz)') pl.ylabel('P3 $(\\times 10^{-6})$') #pl.grid(True) pl.xlim([0,omega.max()]) pl.ylim([0,g.max()*1e6]) to_txt(['freq','p3'],np.c_[omega.flatten(),g.flatten()],'p3_freq.txt') except Exception as e: print e try: q=np.loadtxt(open('../BTE.qpoints')) qnorm=np.linalg.norm(q[:,-3:],axis=1) data=[] n,m=w.shape for i in range(m): data.append([qnorm,w[:,i],'b']) series(xlabel='|q| (1/nm)', ylabel='Scatter Rate (THz)', datas=data, filename='branchscatter.png',scatter=True,legend=False,logx=True,logy=True) except Exception as e: pass cd('..')
def postsheng(self): try: df=pd.read_csv("BTE.kappa_scalar",sep=r"[ \t]+",header=None,names=['step','kappa'],engine='python'); ks=np.array(df['kappa']) plot((np.array(df['step']),'Iteration Step'),(ks,'Thermal Conductivity (W/mK)'),'kappa_scalar.png',grid=True,linewidth=2) except Exception as e: print e try: df=pd.read_csv("BTE.cumulative_kappa_scalar",sep=r"[ \t]+",header=None,names=['l','kappa'],engine='python'); ks=np.array(df['kappa']) plot((np.array(df['l']),'Cutoff Mean Free Path for Phonons (Angstrom)'),(ks,'Thermal Conductivity (W/mK)'),'cumulative_kappa_scalar.png',grid=True,linewidth=2,logx=True) except Exception as e: print e try: omega=np.loadtxt('BTE.omega')/(2.0*np.pi) kappa=np.loadtxt('BTE.kappa')[-1,1:] kappa=np.einsum('jji',kappa.reshape([3,3,-1]))/3.0 plot((np.arange(len(omega[0])),'Band'),(kappa,'Thermal Conductivity (W/mK)'),'kappa_band.png',grid=True,linewidth=2) plot((np.arange(len(omega[0])),'Band'),(kappa.cumsum(),'Thermal Conductivity (W/mK)'),'cumulative_kappa_band.png',grid=True,linewidth=2) except Exception as e: print e try: w=np.loadtxt('BTE.w_final') w=np.abs(w) w[omega<omega.flatten().max()*0.005]=float('nan') plot((omega.flatten(),'Frequency (THz)'),(w.flatten(),'Scatter Rate (THz)'),'scatter_freq.png',grid=True,scatter=True,logy=True) tao=1.0/w+1e-6 with fig('tao_freq.png'): pl.semilogy(omega.flatten(),tao.flatten(),linestyle='.',marker='.',color='r',markersize =5) pl.xlabel('Frequency (THz)') pl.ylabel('Relaxation Time (ps)') pl.grid(True) pl.xlim([0,omega.max()]) #pl.ylim([0,tao.flatten().max()]) to_txt(['freq','tao'],np.c_[omega.flatten(),tao.flatten()],'tao_freq.txt') except Exception as e: print e """ if not exists('relaxtime'):mkdir('relaxtime') cd('relaxtime') for i,om in enumerate(omega[:6]): print "q : ",i plot((om,'Frequency (THz)'),(tao[i],'Relaxation Time (ps)'),'tao_freq_q%d.png'%i,grid=True,scatter=True,logx=True,logy=True) cd('..') """ try: v=np.loadtxt(open('BTE.v')) n,m=v.shape v=v.reshape([n,3,m/3]) v=np.linalg.norm(v,axis=1) plot((omega.flatten(),'Frequency (THz)'),(v.flatten(),'Group Velocity (nm/ps)'),'v_freq.png',grid=True,scatter=True) to_txt(['freq','vg'],np.c_[omega.flatten(),v.flatten()],'v_freq.txt') except Exception as e: print e try: l=v*tao l[l<1e-6]=None plot((omega.flatten(),'Frequency (THz)'),(l.flatten(),'Mean Free Path (nm)'),'lamda_freq.png',grid=True,scatter=True,logy=True,logx=True,xmin=0) to_txt(['freq','mfp'],np.c_[omega.flatten(),l.flatten()],'lamda_freq.txt') except Exception as e: print e try: q=np.loadtxt(open('BTE.qpoints')) qnorm=np.linalg.norm(q[:,-3:],axis=1) data=[] n,m=w.shape for i in range(m): data.append([qnorm,w[:,i],'b']) series(xlabel='|q| (1/nm)', ylabel='Scatter Rate (THz)', datas=data, filename='branchscatter.png',scatter=True,legend=False,logx=True,logy=True) except Exception as e: print e