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 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 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 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 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 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 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)")
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') pl.set_ylabel('Probability Density') pl.set_xlim([0, 1.0]) setLegend(pl) pl = oldpl.subplot(2, 2, 2) #with fig('young_distribution.png'): dx = p0[1] - p0[0] pl.bar(p0[1:], u0, alpha=.5, width=dx) pl.set_xlabel('Young\'s Modulous (GPa/m)') pl.set_ylabel('Probability Density') pl.set_xlim([0, 400]) pl = oldpl.subplot(2, 2, 3) #with fig('drop_times_dist.png'): pl.hist(pp, bins=20, range=(.5, 9.5), facecolor='gray')
# -*- 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])
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))
# 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])
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 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): 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('..')
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 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)