예제 #1
0
파일: dos.py 프로젝트: xiexingzhu/aces
def plot_smooth():
    df = pd.read_csv("VDOS.txt", sep=r"[ \t]", engine="python")
    freq, ave = getDos(df['Freq_THz'], df['vdos_av'])
    dp = pd.DataFrame()
    dp['Freq_THz'] = freq
    dp["vdos_av"] = ave
    dp.to_csv('smooth_dos.txt', sep='\t', index=False, float_format="%f")
    plot((freq, 'Frequency(THz)'), (ave, 'Phonon Density of states'),
         "smooth_dos.png",
         grid=True)

    alldos = [df['vdos_x'], df['vdos_y'], df['vdos_z']]
    filter = getFilter(alldos)
    dp = pd.DataFrame()
    freq, ave = getDos(df['Freq_THz'], df['vdos_x'], filter)
    dp['Freq_x'] = freq
    dp["vdos_x"] = ave
    freq, ave = getDos(df['Freq_THz'], df['vdos_y'], filter)
    dp['Freq_y'] = freq
    dp["vdos_y"] = ave
    freq, ave = getDos(df['Freq_THz'], df['vdos_z'], filter)
    dp['Freq_z'] = freq
    dp["vdos_z"] = ave
    dp.to_csv('smooth_dosxyz.txt', sep='\t', index=False, float_format="%f")
    series(xlabel='Frequency(THz)',
           ylabel='Phonon Density of States',
           datas=[(dp['Freq_x'], dp["vdos_x"], "dos_x"),
                  (dp['Freq_y'], dp["vdos_y"], "dos_y"),
                  (dp['Freq_z'], dp["vdos_z"], "dos_z")],
           filename='smooth_dosxyz.png',
           grid=True)
예제 #2
0
    def draw_tau(self):
        try:

            w = get_w_final('..')
            q = get_qpoints('..')
            omega = get_omega('..')
            tau = get_tau('..')
            plot(
                (omega.flatten(), 'Frequency (THz)'), (w.flatten(),
                                                       'Scatter Rate (THz)'),
                'scatter_freq.png',
                grid=True,
                scatter=True,
                logy=True)
            plot(
                (omega.flatten(), 'Frequency (THz)'), (tau.flatten(),
                                                       'Relaxation Time (ps)'),
                'tau_freq.png',
                grid=True,
                scatter=True,
                logy=True)
            to_txt(['freq', 'tau'],
                   np.c_[omega.flatten(), tau.flatten()], 'tao_freq.txt')
            r = []
            for i, qq in enumerate(q):
                c = tau[i]
                d = omega[i]
                for j, cc in enumerate(c):
                    r.append([qq[0], qq[1], qq[2], d[j], c[j]])
            to_txt(['q1', 'q2', 'q3', 'f(THz)', 'tao(ps)'], r, 'q_tao.txt')
        except Exception as e:
            pass
예제 #3
0
파일: mdTc.py 프로젝트: xiexingzhu/aces
    def correlation(self):
        m = self.m
        if not exists("jin.npy"):
            print "loading jin.txt"
            j = np.loadtxt('jin.txt', skiprows=2)[:, 1]
            np.save('jin.npy', j)
        j = np.load('jin.npy')
        print "loaded"
        n = len(j)
        if not exists("jj0.npy"):

            jj0 = acf(j)[:n / 2 + 1]
            np.save('jj0.npy', jj0)
        jj0 = np.load('jj0.npy')[:m.aveRate]

        xlo, xhi, ylo, yhi, zlo, zhi, lx, ly, lz = m.box
        v = lx * ly * lz
        factor = m.corRate * m.timestep / (v * m.kb * m.T *
                                           m.T) * m.zfactor * m.tcfactor
        x = range(len(jj0))
        plot([x, 'Correlation Time (ps)'],
             [jj0, 'Heat Flut Correlation Function'], 'acf.png')
        plot([x, 'Correlation Time (ps)'],
             [jj0.cumsum() * factor, 'Thermal Conductivity (W/mK)'],
             'kappa.png')
예제 #4
0
파일: phonts.py 프로젝트: vanceeasleaf/aces
    def post(self):
        a = np.loadtxt('freq.dat')
        ks = a[:, 1:4]
        omega = a[:, 4:]
        b = np.loadtxt('phon_lifetime.dat')
        tao = b[:len(ks), 4:]

        v = np.loadtxt(open('group_vel.dat'))[:, 4:]
        n, m = v.shape
        v = v.reshape([n, m / 3, 3])
        v = np.linalg.norm(v, axis=2)
        plot(
            (omega.flatten(), 'Frequency (THz)'), (v.flatten(),
                                                   'Group Velocity (nm/ps)'),
            'v_freq.png',
            grid=True,
            scatter=True)
        tl.to_txt(['freq', 'vg'],
                  np.c_[omega.flatten(), v.flatten()], 'v_freq.txt')
        plot(
            (omega.flatten(), 'Frequency (THz)'), (tao.flatten(),
                                                   'Relaxation Time (ps)'),
            'tao_freq.png',
            grid=True,
            scatter=True,
            logy=True)
예제 #5
0
    def draw_gv(self):
        try:
            omega = get_omega('..')
            tau = get_tau('..')
            v = get_v('..')

            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')

            l = v * tau
            y = (l.flatten(), 'Mean Free Path (nm)')
            plot(
                (omega.flatten(), 'Frequency (THz)'),
                y,
                '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)
예제 #6
0
 def drawedos(self):
     fermi = self.getfermi()
     s = np.loadtxt("diam.edos", skiprows=1)
     freq, dos = s[:, 0], s[:, 1]
     freq -= fermi
     plot((freq, 'Electron Energy (eV)'), (dos, 'Density of States'),
          filename='edos.png')
예제 #7
0
파일: strain.py 프로젝트: vanceeasleaf/aces
 def post(self):
     import pandas as pd
     df = pd.read_csv("strain_stress.txt",
                      sep=r"[ \t]",
                      engine="python",
                      skiprows=2,
                      header=None)
     import numpy as np
     df = np.array(df)
     strain = df[:, 1] / df[0, 1] - 1
     # convert to GPa
     # metalE/metalV/(siE/siV)=metalE/siE*siV/metalV=1/u.si.E()*u.si.L()**2
     tl.cd('minimize')
     self.m.postMini()
     tl.cd('..')
     pxx = -df[:, 2] * 1e5 * 1e-9 * self.m.zfactor
     from aces.graph import plot
     plot((strain, 'Strain'), (pxx, 'Stress (GPa)'),
          'stress.png',
          linewidth=2,
          grid=True)
     dp = pd.DataFrame()
     dp['Strain'] = strain
     dp['Stress_GPa'] = pxx
     dp.to_csv('cal_stress.txt', sep='\t', index=False, float_format="%f")
     from scipy import stats
     slope, intercept, r_value, p_value, std_err = stats.linregress(
         strain[:50], pxx[:50])
     self.YoungsModulus = slope
     tl.write(slope, 'YoungsModulus.txt')
예제 #8
0
파일: epw.py 프로젝트: vanceeasleaf/aces
 def drawedos(self):
     fermi = self.getfermi()
     s = np.loadtxt("diam.edos", skiprows=1)
     freq, dos = s[:, 0], s[:, 1]
     freq -= fermi
     plot(
         (freq, 'Electron Energy (eV)'), (dos, 'Density of States'),
         filename='edos.png')
예제 #9
0
파일: phonopy.py 프로젝트: xiexingzhu/aces
	def drawDos(self):
		freq,pdos=self.getpdos()
		datas=[(freq,p,'') for p in pdos.T]
		series('Frequency (THz)','Partial Density of States',
		datas=datas,
		filename='partial_dos.png',legend=False,grid=True)
		
		plot((freq,'Frequency (THz)'),(np.sum(pdos,axis=1),'Density of States'),filename='total_dos.png')
예제 #10
0
	def dumpkappa(self):
		import h5py
		m=self.m
		filename="kappa-m%s.hdf5"%''.join(map(str,m.kpoints))
		f=h5py.File(filename)
		kappa=f['kappa']
		T=f['temperature']
		to_txt(['temperature','kappa'],np.c_[T,kappa[:,0]],'kappa.txt')
		from aces.graph import plot
		plot((np.array(T),'Temperature (K)'),(np.array(kappa),'Thermal Conductivity (W/mK)'),filename='kT.png')
예제 #11
0
 def dumpkappa(self):
     import h5py
     m = self.m
     filename = "kappa-m%s.hdf5" % ''.join(map(str, m.kpoints))
     f = h5py.File(filename)
     kappa = f['kappa']
     T = f['temperature']
     tl.to_txt(['temperature', 'kappa'], np.c_[T, kappa[:, 0]], 'kappa.txt')
     plot(
         (np.array(T), 'Temperature (K)'),
         (np.array(kappa),
          'Thermal Conductivity (W/mK)'),
         filename='kT.png')
예제 #12
0
파일: phonopy.py 프로젝트: xiexingzhu/aces
	def drawV(self):
		data =parseyaml('mesh.yaml')
		file=open("v.txt",'w')
		for phonon in data['phonon']:
			qp=phonon['q-position']
			for band in phonon['band']:
				frequency=band['frequency']
				v=np.array(band['group_velocity'])
				v=np.linalg.norm(v)
				print >>file,"%s\t%f\t%f"%('\t'.join(map(str,qp)),frequency,v)
		file.close()
		v=np.loadtxt('v.txt')
		plot((v[:,3],'Frequency (THz)'),(v[:,4],'Group Velocity (Angstrom/ps)'),'v_freq.png',grid=True,scatter=True)
예제 #13
0
    def drawDos(self):
        freq, pdos = self.getpdos()
        datas = [(freq, p, '') for p in pdos.T]
        series(
            'Frequency (THz)',
            'Partial Density of States',
            datas=datas,
            filename='partial_dos.png',
            legend=False,
            grid=True)

        plot(
            (freq, 'Frequency (THz)'), (np.sum(pdos, axis=1),
                                        'Density of States'),
            filename='total_dos.png')
예제 #14
0
파일: phonopy.py 프로젝트: xiexingzhu/aces
	def getvqpoints(self,q):
		self.generate_vqconf(q)
		passthru(config.phonopy+"--tolerance=1e-4  q.conf")
		data =parseyaml('qpoints.yaml')
		file=open("v.txt",'w')
		for phonon in data['phonon']:
			qp=phonon['q-position']
			for band in phonon['band']:
				frequency=band['frequency']
				v=np.array(band['group_velocity'])
				v=np.linalg.norm(v)
				print >>file,"%s\t%f\t%f"%('\t'.join(map(str,qp)),frequency,v)
		file.close()
		v=np.loadtxt('v.txt')
		plot((v[:,3],'Frequency (THz)'),(v[:,4],'Group Velocity (Angstrom/ps)'),'v_freq.png',grid=True,scatter=True)
예제 #15
0
 def lifetime(self):
     xx = np.loadtxt('linewidth.elself', skiprows=2)
     E = xx[:, 2]
     a = E.argsort()
     h = 4.13566743e-15  # eV s
     h = h * 1000 * 1e12  # meV ps
     pi2 = 3.14159265359 * 2.0
     hbar = h / pi2
     linewidth = xx[:, 3]  # meV
     lifetime = hbar / linewidth
     plot((E[a], 'Electron Energy (eV)'),
          (lifetime[a], 'Electron Lifetime (ps)'),
          filename='linewidth_elself.png')
     hist, bin_edges = np.histogram(E, density=True, bins=200)
     plot((bin_edges[:-1], 'Electron Energy (eV)'),
          (hist, 'Density of States'),
          filename='fine_edos.png')
예제 #16
0
파일: mdTc.py 프로젝트: xiexingzhu/aces
    def reduce(self, n=1, name0=500000):
        name = 'ac' + str(name0) + '.dat'
        m = self.m
        xs = []
        for i in range(n):
            dir = '../%d/' % i
            print dir
            x = np.loadtxt(dir + name)
            xs.append(x[:, 1])
        ts = x[:, 0]
        xs = np.array(xs)
        avexs = xs.mean(axis=0)
        np.savetxt('aveac.txt', np.c_[ts, avexs])

        plot([ts, 'Correlation Time (ps)'],
             [avexs, 'Heat Flut Correlation Function'], 'aveac.png')
        datas = []
        for i in range(n):
            datas.append([ts, xs[i], 'b'])
        series(xlabel='Correlation Time (ps)',
               ylabel='Heat Flut Correlation Function',
               datas=datas,
               filename='ac.png',
               legend=False)
        name = 'tc' + str(name0) + '.dat'
        xs = []
        for i in range(n):
            dir = '../%d/' % i
            print dir
            x = np.loadtxt(dir + name)
            xs.append(x[:, 1])
        ts = x[:, 0]
        xs = np.array(xs)
        avexs = xs.mean(axis=0)
        np.savetxt('avetc.txt', np.c_[ts, avexs])
        plot([ts, 'Correlation Time (ps)'],
             [avexs, 'Thermal Conductivity (W/mK)'], 'avetc.png')
        datas = []
        for i in range(n):
            datas.append([ts, xs[i], 'b'])
        series(xlabel='Correlation Time (ps)',
               ylabel='Thermal Conductivity (W/mK)',
               datas=datas,
               filename='tc.png',
               legend=False)
예제 #17
0
파일: negf.py 프로젝트: xiexingzhu/aces
 def test(self):
     dm = .1
     omega = np.arange(dm, 60, dm)  #THz
     factor = 1e12**2 * 1e-20 * 1e-3 / 1.6e-19 / 6.23e23
     energies = (omega * 2.0 * np.pi)**2 * factor
     #energies=np.arange(0,10,.01)
     h = -np.array((-2, 1, 0, 1, -2, 1, 0, 1, -2)).reshape((3, 3))
     h1 = -np.array((-2, 1, 1, -2)).reshape((2, 2))
     #x=1.0/np.sqrt(2)
     #h1=h=-np.array((-2,x,0,0,x,-1,x,0,0,x,-2,x,0,0,x,-1)).reshape((4,4))
     #energies = np.arange(-3, 3, 0.1)
     calc = TransportCalculator(h=h, h1=h1, energies=energies, dos=True)
     T = calc.get_transmission()
     #print T
     dos = calc.get_dos() * omega
     plot([omega, 'Frequency (THz)'], [T, 'Transmission'],
          'test_green_transmission.png')
     plot([omega, 'Frequency (THz)'], [dos, 'Phonon Density of State'],
          'test_green_dos.png')
예제 #18
0
파일: epw.py 프로젝트: vanceeasleaf/aces
 def lifetime(self):
     xx = np.loadtxt('linewidth.elself', skiprows=2)
     E = xx[:, 2]
     a = E.argsort()
     h = 4.13566743e-15  # eV s
     h = h * 1000 * 1e12  # meV ps
     pi2 = 3.14159265359 * 2.0
     hbar = h / pi2
     linewidth = xx[:, 3]  # meV
     lifetime = hbar / linewidth
     plot(
         (E[a], 'Electron Energy (eV)'), (lifetime[a],
                                          'Electron Lifetime (ps)'),
         filename='linewidth_elself.png')
     hist, bin_edges = np.histogram(E, density=True, bins=200)
     plot(
         (bin_edges[:-1], 'Electron Energy (eV)'), (hist,
                                                    'Density of States'),
         filename='fine_edos.png')
예제 #19
0
 def drawV(self):
     data = parseyaml('mesh.yaml')
     file = open("v.txt", 'w')
     for phonon in data['phonon']:
         qp = phonon['q-position']
         for band in phonon['band']:
             frequency = band['frequency']
             v = np.array(band['group_velocity'])
             v = np.linalg.norm(v)
             print >> file, "%s\t%f\t%f" % ('\t'.join(map(str, qp)),
                                            frequency, v)
     file.close()
     v = np.loadtxt('v.txt')
     plot(
         (v[:, 3], 'Frequency (THz)'), (v[:, 4],
                                        'Group Velocity (Angstrom/ps)'),
         'v_freq.png',
         grid=True,
         scatter=True)
예제 #20
0
 def getvqpoints(self, q):
     self.generate_vqconf(q)
     passthru(config.phonopy + "--tolerance=1e-4  q.conf")
     data = parseyaml('qpoints.yaml')
     file = open("v.txt", 'w')
     for phonon in data['phonon']:
         qp = phonon['q-position']
         for band in phonon['band']:
             frequency = band['frequency']
             v = np.array(band['group_velocity'])
             v = np.linalg.norm(v)
             print >> file, "%s\t%f\t%f" % ('\t'.join(map(str, qp)),
                                            frequency, v)
     file.close()
     v = np.loadtxt('v.txt')
     plot(
         (v[:, 3], 'Frequency (THz)'), (v[:, 4],
                                        'Group Velocity (Angstrom/ps)'),
         'v_freq.png',
         grid=True,
         scatter=True)
예제 #21
0
    def post(self):
        a = np.loadtxt('freq.dat')
        ks = a[:, 1:4]
        omega = a[:, 4:]
        b = np.loadtxt('phon_lifetime.dat')
        tao = b[:len(ks), 4:]

        v = np.loadtxt(open('group_vel.dat'))[:, 4:]
        n, m = v.shape
        v = v.reshape([n, m / 3, 3])
        v = np.linalg.norm(v, axis=2)
        plot((omega.flatten(), 'Frequency (THz)'),
             (v.flatten(), 'Group Velocity (nm/ps)'),
             'v_freq.png',
             grid=True,
             scatter=True)
        tl.to_txt(['freq', 'vg'], np.c_[omega.flatten(),
                                        v.flatten()], 'v_freq.txt')
        plot((omega.flatten(), 'Frequency (THz)'),
             (tao.flatten(), 'Relaxation Time (ps)'),
             'tao_freq.png',
             grid=True,
             scatter=True,
             logy=True)
예제 #22
0
    def post(self):
        # 1eV = 8049 cm^(-1) => 1000emV=8049 cm-1 => cm-1/meV=1000/8049
        # 1cm^(-1) = 3 * 10^(10) hz =>Hz*cm=1/3e10
        # a cm^-1=b THz =>a=b *1e12 Hz*cm
        # a meV = b cm^-1 => a = b cm-1/meV
        # omcm=omega*521.471?
        self.reduce()
        result = self.read('result.txt')
        omega = result[:, 0]
        trans = result[:, 1]
        dos = result[:, 2]
        omcm = omega * 1e12 * 1 / 3e10
        omme = omcm * 1e12 * 6.6260755e-34 / 1.6e-19 * 1000

        T = self.m.T
        centerm = self.preCenter()
        V = np.linalg.det(centerm.atoms.cell)
        c = capacity(omega, T, V)
        j = c * trans / 2.0 / np.pi
        dm = omega[1] - omega[0]
        kappa = j.cumsum() * dm
        to_txt([
            'Frequency (THz)', 'Frequency (cm^-1)', 'Frequency (meV)',
            'Phonon Transmission', 'Phonon Density of State',
            'Mode Capacity (J/m^3/K)', 'Mode Thermal Conductance (W/m^2/K)',
            'Accumulate Thermal Conductance (W/m^2/K)'
        ], np.c_[omega, omcm, omme, trans, dos, c, j, kappa],
               'transmission.txt')

        f = self.read('transmission.txt')
        #from aces.algorithm.smooth import savitzky_golay
        plot([f[:, 0], 'Frequency (THz)'],
             [f[:, 4], 'Phonon Density of State'], 'green_dos.png')
        plot([f[:, 0], 'Frequency (THz)'], [f[:, 3], 'Phonon Transmission'],
             'green_transmission.png')
        #plot([f[:,0],'Frequency (THz)'],[savitzky_golay(f[:,3],11,3),'Phonon Transmission'],'smooth_transmission.png')
        plot([f[:, 0], 'Frequency (THz)'],
             [f[:, 6], 'Mode Thermal Conductance (W/m^2/K)'],
             'green_mode_conductance.png')
예제 #23
0
파일: negf.py 프로젝트: xiexingzhu/aces
    def post(self):
        #1eV = 8049 cm^(-1) => 1000emV=8049 cm-1 => cm-1/meV=1000/8049
        #1cm^(-1) = 3 * 10^(10) hz =>Hz*cm=1/3e10
        #a cm^-1=b THz =>a=b *1e12 Hz*cm
        #a meV = b cm^-1 => a = b cm-1/meV
        #omcm=omega*521.471?
        result = np.loadtxt("result.txt")
        omeage = result[:, 0]
        trans = result[:, 1]
        dos = result[:, 2]
        omcm = omega * 1e12 * 1 / 3e10
        omme = omcm * 1e12 * 6.6260755e-34 / 1.6e-19 * 1000
        w = omega * 1e12 * 2.0 * np.pi
        T = self.m.T
        centerm = self.preCenter()
        V = np.linalg.det(centerm.atoms.cell)
        c = hbar * w * (BE(w, T + 0.005) - BE(w, T - 0.005)) * 100.0 / V * 1e30
        j = c * trans / 2.0 / np.pi
        dm = omega[1] - omega[0]
        kappa = j.cumsum() * dm
        to_txt([
            'Frequency (THz)', 'Frequency (cm^-1)', 'Frequency (meV)',
            'Phonon Transmission', 'Phonon Density of State',
            'Mode Capacity (J/m^3/K)', 'Mode Thermal Conductance (W/m^2/K)',
            'Accumulate Thermal Conductance (W/m^2/K)'
        ], np.c_[omega, omcm, omme, trans, dos, c, j, kappa],
               'transmission.txt')

        f = np.loadtxt('transmission.txt', skiprows=1)
        plot([f[:, 0], 'Frequency (THz)'],
             [f[:, 4], 'Phonon Density of State'], 'green_dos.png')
        plot([f[:, 0], 'Frequency (THz)'], [f[:, 3], 'Phonon Transmission'],
             'green_transmission.png')
        plot([f[:, 0], 'Frequency (THz)'],
             [f[:, 6], 'Mode Thermal Conductance (W/m^2/K)'],
             'green_mode_conductance.png')
예제 #24
0
 def drawpedos(self):
     s = np.loadtxt("diam.edos", skiprows=1)
     freq, dos = s[:, 0], s[:, 1]
     plot((freq, 'Electron Energy (eV)'), (dos, 'Density of States'),
          filename='edos.png')
예제 #25
0
파일: strain.py 프로젝트: vanceeasleaf/aces
datas=[]
import pandas as pd
import numpy as np
from aces.tools import *
youngs=[]
temps=range(200,300,10)
for i in range(10):
	print i
	cd(str(i))
	from aces.App import App
	App().runner.post()
	
	df=pd.read_csv("cal_stress.txt",sep=r"[ \t]",engine="python");
	datas.append([df['Strain'],df['Stress_GPa'],str(temps[i])+'K'	])
	youngs.append(float(read("YoungsModulus.txt")))
	cd('..')
from aces.graph import series,plot
plot((np.array(temps),'Temperature (K)'),(np.array(youngs),'Young\'s Modulus (GPa)'),'youngs.png')
series(xlabel='Strain',
	ylabel='Stress (GPa)',
	datas=datas
	,linewidth=1
	,filename='stress_strain.png',legend=True)
예제 #26
0
		var=abs(s[j+n,1]-s[j+n-1,1])
		if var>2.5 and var>s[j:j+n,1].std():
			if len(v)>0 and j-v[-1]<n:continue
			v.append(j+n)
	return np.array(v)
i=0
for T in range(100,300,40):
	for seed in range(100,110):
		s=np.loadtxt(str(i)+"/cal_stress.txt",skiprows=1)
		v=getBreakStrains(s)
		breakstrains.append(v)
		if abs(s[-1,1])<.5:
			breaktimes.append(len(v)) # break up
		else:
			breaktimes.append(-len(v)) #not break up
		i+=1
		print s[v,0],breaktimes[-1]
for u in s:
	pass

from aces.graph import series,plot

series(xlabel='Strain',
	ylabel='Stress (GPa)',
	datas=datas
	,linewidth=1
	,filename='stress_strain.png',legend=False,grid=True)
x=c[:,0,:].mean(axis=0)
y=c[:,1,:].mean(axis=0)
plot([x,'Strain'],[y,'Stress (GPa)'],filename='ave_stress.png')
예제 #27
0
파일: vdos.py 프로젝트: vanceeasleaf/aces
    def cal_lc(self, r, dr, m):
        from aces.lammpsdata import lammpsdata
        atoms = lammpsdata().set_src('correlation_structure')
        atoms.set_pbc([m.xp, m.yp, m.zp])
        nw = self.totalStep / 2 + 1
        nr = int(r / dr) + 1
        n = len(atoms)
        pos = atoms.positions
        cell = atoms.cell
        symbols = atoms.get_chemical_symbols()
        masses = self.getMassFromLabel(symbols)
        if not tl.exists('g.npz'):
            g = np.zeros([nw, nr], dtype=np.complex)
            ng = np.zeros(nr, dtype=np.int)
            c = self.get_nei(r, dr, pos, cell)
            for i, j, q in c:
                if j == 0:
                    print("center atom:%d/%d" % (i, n))
                aij = np.einsum(
                    'ij,ij->i',
                    self.fourier_atom(i).conjugate(),
                    self.fourier_atom(j))
                aii = np.einsum(
                    'ij,ij->i',
                    self.fourier_atom(i).conjugate(),
                    self.fourier_atom(i))
                ajj = np.einsum(
                    'ij,ij->i',
                    self.fourier_atom(j).conjugate(),
                    self.fourier_atom(j))
                x = aij / np.sqrt(aii * ajj) * np.sqrt(masses[i] * masses[j])
                for ir in q:
                    g[:, ir] += x
                    ng[ir] += 1
            np.savez('g.npz', g=g, ng=ng)
        npz = np.load('g.npz')
        g = npz['g']
        ng = npz['ng']
        rs = (np.arange(nr)) * dr
        rs = rs[:-1]

        def aa(x):
            if x > 0:
                return 1.0 / x
            else:
                return 0.0
        ivr = [aa(x) for x in ng]  # 1.0/4.0/np.pi/rs**2
        g = np.einsum('ij,j->ij', g, ivr)[:, :-1]
        g = (g.conjugate() * g).real
        imshow(g, 'g.png', extent=[0, 1, 0, 1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 20):
            data.append([rs, g[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data, linewidth=2, filename='cpes.png')
        cg = g.cumsum(axis=1)
        imshow(cg, 'cg.png', extent=[0, 1, 0, 1])
        cg = np.einsum('ij,i->ij', cg, 1.0 / cg[:, -1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 10):
            data.append([rs, cg[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data, linewidth=2, filename='cges.png')
        lc = ((cg < 0.80).sum(axis=1)) * dr
        x = np.linspace(0, 1, self.totalStep / 2 + 1) * 1 / 2.0 / self.timestep
        plot([x, 'Frequency (THz)'], [lc, 'Coherence length(A)'], 'coherence.png')
        return lc
예제 #28
0
    def cal_lc(self, r, dr, m):
        from aces.lammpsdata import lammpsdata
        atoms = lammpsdata().set_src('correlation_structure')
        atoms.set_pbc([m.xp, m.yp, m.zp])
        nw = self.totalStep / 2 + 1
        nr = int(r / dr) + 1
        n = len(atoms)
        dis = atoms.get_all_distances(mic=True)
        pos = atoms.positions
        cell = atoms.cell
        symbols = atoms.get_chemical_symbols()
        masses = self.getMassFromLabel(symbols)
        if not exists('g.npz'):
            g = np.zeros([nw, nr], dtype=np.complex)
            ng = np.zeros(nr, dtype=np.int)
            c = self.get_nei(r, dr, pos, cell)
            for i, j, q in c:
                if j == 0:
                    print "center atom:%d/%d" % (i, n)
                aij = np.einsum('ij,ij->i',
                                self.fourier_atom(i).conjugate(),
                                self.fourier_atom(j))
                aii = np.einsum('ij,ij->i',
                                self.fourier_atom(i).conjugate(),
                                self.fourier_atom(i))
                ajj = np.einsum('ij,ij->i',
                                self.fourier_atom(j).conjugate(),
                                self.fourier_atom(j))
                x = aij / np.sqrt(aii * ajj) * np.sqrt(masses[i] * masses[j])
                for ir in q:
                    g[:, ir] += x
                    ng[ir] += 1
            np.savez('g.npz', g=g, ng=ng)
        npz = np.load('g.npz')
        g = npz['g']
        ng = npz['ng']
        rs = (np.arange(nr)) * dr
        rs = rs[:-1]

        def aa(x):
            if x > 0: return 1.0 / x
            else: return 0.0

        ivr = [aa(x) for x in ng]  #1.0/4.0/np.pi/rs**2
        g = np.einsum('ij,j->ij', g, ivr)[:, :-1]
        g = (g.conjugate() * g).real
        imshow(g, 'g.png', extent=[0, 1, 0, 1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 20):
            data.append([rs, g[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data,
               linewidth=2,
               filename='cpes.png')
        cg = g.cumsum(axis=1)
        imshow(cg, 'cg.png', extent=[0, 1, 0, 1])
        cg = np.einsum('ij,i->ij', cg, 1.0 / cg[:, -1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 10):
            data.append([rs, cg[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data,
               linewidth=2,
               filename='cges.png')
        lc = ((cg < 0.80).sum(axis=1)) * dr
        x = np.linspace(0, 1, self.totalStep / 2 + 1) * 1 / 2.0 / self.timestep
        plot([x, 'Frequency (THz)'], [lc, 'Coherence length(A)'],
             'coherence.png')
        return lc
예제 #29
0
파일: epw.py 프로젝트: vanceeasleaf/aces
 def drawDos(self):
     freq, dos = self.readdos()
     freq /= 33.367
     plot(
         (freq, 'Frequency (THz)'), (dos, 'Density of States'),
         filename='total_dos.png')
예제 #30
0
    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('..')
예제 #31
0
	def drawlifetime(self):
		a=np.loadtxt('allnma.txt',skiprows=1)
		om=a[:,3]
		tao=a[:,6]#np.abs(1/a[:,5])
		tao[np.abs(om)<1e-6]=0.0
		n=len(tao)
		
		filter=tao<1e5
		om=om[filter]
		tao=tao[filter]/6.28
		plot((om,'Frequency (THz)'),(tao,'Relaxation Time (ps)'),'tao_freq.png',grid=True,scatter=True,logy=True)
		to_txt(['freq','tao'],np.c_[om,tao],'tao_freq.txt')
		
		v=np.loadtxt('vqpoints/v.txt')[:n,4]
		v=v[filter]
		l=v*tao
		to_txt(['freq','lamda'],np.c_[om[om.argsort()],l[om.argsort()]],'lamda_freq.txt')
	
		plot((om,'Frequency (THz)'),(l,'Mean Free Path (Angstrom)'),'lamda_freq.png',grid=True,scatter=True,logy=True)
		T=self.m.T
		w=om*1e12*2.0*np.pi
		from ase import io 
		atoms=io.read('POSCAR')
		cs=self.m.correlation_supercell

		V=np.linalg.det(atoms.cell*cs)
		m=self.m
		#print m.enforceThick,m.thick,atoms.cell[2,2]
		if m.enforceThick:
			V*=m.thick/atoms.cell[2,2]
		c=hbar*w*(BE(w,T+0.005)-BE(w,T-0.005))*100.0/V*1e30
		to_txt(['freq','capacity(J/K)'],np.c_[om[om.argsort()],c[om.argsort()]],'capacity_freq.txt')
		plot((om[om.argsort()],'Frequency (THz)'),(c[om.argsort()],'Mode Specific Heat (J/K)'),'capacity_freq.png',grid=True,linewidth=2)
		to_txt(['freq','cumsumcapacity'],np.c_[om[om.argsort()],c[om.argsort()].cumsum()],'cumsumcapacity_freq.txt')
		plot((om[om.argsort()],'Frequency (THz)'),(c[om.argsort()].cumsum(),'Acummulate Specific Heat (J/K)'),'cumsumcapacity_freq.png',grid=True,linewidth=2)

		
		k=l*1e-10*c*v*1e-10/1e-12
		to_txt(['freq','kappa'],np.c_[om[om.argsort()],k[om.argsort()]],'kappa_freq.txt')
		plot((om,'Frequency (THz)'),(k,'Mode Themal Conductivity (W/mK)'),'kappa_freq.png',grid=True,scatter=True,logy=True,logx=False)

		to_txt(['freq','cumsumkappa'],np.c_[om[om.argsort()],k[om.argsort()].cumsum()],'cumsumkappa_freq.txt')
		plot((om[om.argsort()],'Frequency (THz)'),(k[om.argsort()].cumsum(),'Acummulate Themal Conductivity (W/mK)'),'cumsumkappa_freq.png',grid=True,linewidth=2)

		to_txt(['lamda','cumsumkappa'],np.c_[l[l.argsort()],k[l.argsort()].cumsum()],'cumsumkappa_lamda.txt')
		plot((l[l.argsort()],'Mean Free Path (Angstrom)'),(k[l.argsort()].cumsum(),'Acummulate Themal Conductivity (W/mK)'),'cumsumkappa_lamda.png',grid=True,linewidth=2)
예제 #32
0
파일: shengbte.py 프로젝트: xiexingzhu/aces
	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	
예제 #33
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)
예제 #34
0
 def drawDos(self):
     freq, dos = self.readdos()
     freq /= 33.367
     plot((freq, 'Frequency (THz)'), (dos, 'Density of States'),
          filename='total_dos.png')
예제 #35
0
파일: mdTc.py 프로젝트: xiexingzhu/aces
 def fftac(self):
     x = np.loadtxt('aveac.txt')
     N = len(x) / 100
     y = np.fft.rfft(x[:, 1])[:N / 2 + 1]
     plot([np.arange(N / 2 + 1), 'Frequency (Thz)'],
          [(y * y.conjugate()).real, 'Power Spectrum '], 'powerspect.png')
예제 #36
0
파일: epw.py 프로젝트: vanceeasleaf/aces
 def drawpedos(self):
     s = np.loadtxt("diam.edos", skiprows=1)
     freq, dos = s[:, 0], s[:, 1]
     plot(
         (freq, 'Electron Energy (eV)'), (dos, 'Density of States'),
         filename='edos.png')
예제 #37
0
파일: shengbte.py 프로젝트: xiexingzhu/aces
	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('..')
import pandas as pd
import numpy as np
from aces.tools import *
youngs = []
temps = np.arange(100, 300, 20)
sel = np.arange(0, 10, 2)
for i in sel:
    print i
    cd(str(i * 2 + 1))
    #from aces.App import App
    #App().runner.post()

    df = pd.read_csv("cal_stress.txt", sep=r"[ \t]", engine="python")
    datas.append([df['Strain'], df['Stress_GPa'], str(temps[i]) + 'K'])
    cd('..')
for i in np.arange(0, 10):
    print i
    cd(str(i * 2))
    youngs.append(float(read("YoungsModulus.txt")))
    cd('..')
from aces.graph import series, plot

series(xlabel='Strain',
       ylabel='Stress (GPa)',
       datas=datas,
       linewidth=1,
       filename='stress_strain.png',
       legend=True,
       grid=True)
plot((np.array(temps), 'Temperature (K)'),
     (np.array(youngs), 'Young\'s Modulus (GPa)'), 'youngs.png')
예제 #39
0
    def drawlifetime(self):
        a = np.loadtxt('allnma.txt', skiprows=1)
        om = a[:, 3]
        tao = a[:, 6]  # np.abs(1/a[:,5])
        tao[np.abs(om) < 1e-6] = 0.0
        n = len(tao)

        filter = tao < 1e5
        om = om[filter]
        tao = tao[filter] / 6.28
        plot(
            (om, 'Frequency (THz)'), (tao, 'Relaxation Time (ps)'),
            'tao_freq.png',
            grid=True,
            scatter=True,
            logy=True)
        tl.to_txt(['freq', 'tao'], np.c_[om, tao], 'tao_freq.txt')

        v = np.loadtxt('vqpoints/v.txt')[:n, 4]
        v = v[filter]
        l = v * tao
        tl.to_txt(['freq', 'lamda'], np.c_[om[om.argsort()], l[om.argsort()]],
                  'lamda_freq.txt')

        plot(
            (om, 'Frequency (THz)'), (l, 'Mean Free Path (Angstrom)'),
            'lamda_freq.png',
            grid=True,
            scatter=True,
            logy=True)
        T = self.m.T
        w = om * 1e12 * 2.0 * np.pi
        from ase import io
        atoms = io.read('POSCAR')
        cs = self.m.correlation_supercell

        V = np.linalg.det(atoms.cell * cs)
        m = self.m
        # print m.enforceThick,m.thick,atoms.cell[2,2]
        if m.enforceThick:
            V *= m.thick / atoms.cell[2, 2]
        c = hbar * w * (BE(w, T + 0.005) - BE(w, T - 0.005)) * 100.0 / V * 1e30
        tl.to_txt(['freq',
                   'capacity(J/K)'], np.c_[om[om.argsort()], c[om.argsort()]],
                  'capacity_freq.txt')
        plot(
            (om[om.argsort()], 'Frequency (THz)'),
            (c[om.argsort()], 'Mode Specific Heat (J/K)'),
            'capacity_freq.png',
            grid=True,
            linewidth=2)
        tl.to_txt(['freq', 'cumsumcapacity'],
                  np.c_[om[om.argsort()], c[om.argsort()].cumsum()],
                  'cumsumcapacity_freq.txt')
        plot(
            (om[om.argsort()], 'Frequency (THz)'),
            (c[om.argsort()].cumsum(), 'Acummulate Specific Heat (J/K)'),
            'cumsumcapacity_freq.png',
            grid=True,
            linewidth=2)

        k = l * 1e-10 * c * v * 1e-10 / 1e-12
        tl.to_txt(['freq', 'kappa'], np.c_[om[om.argsort()], k[om.argsort()]],
                  'kappa_freq.txt')
        plot(
            (om, 'Frequency (THz)'), (k, 'Mode Themal Conductivity (W/mK)'),
            'kappa_freq.png',
            grid=True,
            scatter=True,
            logy=True,
            logx=False)

        tl.to_txt(['freq', 'cumsumkappa'],
                  np.c_[om[om.argsort()], k[om.argsort()].cumsum()],
                  'cumsumkappa_freq.txt')
        plot(
            (om[om.argsort()], 'Frequency (THz)'),
            (k[om.argsort()].cumsum(),
             'Acummulate Themal Conductivity (W/mK)'),
            'cumsumkappa_freq.png',
            grid=True,
            linewidth=2)

        tl.to_txt(['lamda', 'cumsumkappa'],
                  np.c_[l[l.argsort()], k[l.argsort()].cumsum()],
                  'cumsumkappa_lamda.txt')
        plot(
            (l[l.argsort()], 'Mean Free Path (Angstrom)'),
            (k[l.argsort()].cumsum(), 'Acummulate Themal Conductivity (W/mK)'),
            'cumsumkappa_lamda.png',
            grid=True,
            linewidth=2)