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 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 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])
# -*- 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])
# 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])
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 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")
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)
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 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')