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')
def prepareBand(self): tl.mkcd('band') # run vasp tl.cp('../minimize/POSCAR', '.') self.m.ismear = -1 self.getVaspRun_vasp() tl.cd('..')
def getbol(self): maindir = tl.pwd() tl.mkcd('bol') self.runscf() self.runnscf() self.runw() tl.cd(maindir)
def profile(self): m = self.m tl.cd('minimize') m.postMini() tl.cd('..') import profile profile.run(**m.__dict__)
def getPhonons(self): maindir = tl.pwd() tl.mkcd('phonons') self.runscf() self.runph() self.collect() tl.cd(maindir)
def getvasprun(self, files): m = self.m maindir = pwd() if m.engine == "vasp": calculator = self.getVaspRun_vasp elif m.engine == "lammps": calculator = self.getVaspRun_lammps self.jm = jobManager() for file in files: print(file) dir = "dirs/dir_" + file mkdir(dir) mv(file, dir + '/POSCAR') cd(dir) calculator() cd(maindir) self.jm.run() if m.th: mkdir(m.pbsname) self.thcode(files, m.pbsname) cp("dirs", m.pbsname) passthru("tar zcf %s.tar.gz %s" % (m.pbsname, m.pbsname)) print('start check') self.jm.check() if m.engine == "lammps1": from multiprocessing.dummy import Pool pool = Pool() pool.map_async(lammpsvasprun, files) pool.close() pool.join()
def getbol(self): maindir = tl.pwd() tl.mkcd('bol') self.runscf() self.runnscf() self.runw() tl.cd(maindir)
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 prepareet(self): atoms = io.read('POSCAR') from pyspglib import spglib s = spglib.get_spacegroup(atoms) from aces.scanf import sscanf sgN = sscanf(s, '%s (%d)')[1] sg = Spacegroup(sgN) atoms.info = {'spacegroup': sg} nelect = self.getNelect(outcar='band/OUTCAR') # The remaining part takes care of writing the files required by # BoltzTraP. bandstructure = vasp2boltz.get_vasp_bandstructure(pathname='band/') tl.mkcd('et') vasp2boltz.write_bandstructure_boltztrap( bandstructure, filename='et.energy') vasp2boltz.write_structure_boltztrap(atoms, filename='et.struct') vasp2boltz.write_intrans_boltztrap( n_electrons=nelect, filename='et.intrans') s = tl.read('et.energy') s = s.replace('HTE', 'et') tl.write(s, 'et.energy') s = tl.read('et.struct') s = s.replace('HTE', 'et') tl.write(s, 'et.struct') tl.cd('..')
def creatmini(self): print('creatmini') tl.mkdir('minimize') tl.cd('minimize') minimize_input(self.m) tl.write(time.strftime('%Y-%m-%d %H:%M:%S'), 'done') tl.cd('..')
def phonopy(self, dir, mm): # if exists(dir+'/FORCE_CONSTANTS'): # return mkcd(dir) self.creatmini(mm) PRunner(mm).generate() cd('..')
def run(self): old = tl.pwd() for job in self.jobs: tl.cd(job.path) job.writepbs() job.submit() tl.cd(old)
def checkMinimize(self): import yaml data = yaml.load(open('disp.yaml').read()) disps = [map(float, a['direction']) for a in data['displacements']] maindir = pwd() dirs = ls('dirs/dir_*') ii = 0 L = np.linalg.norm # d,p,d1,p1=self.m.rot out = open('ccos.txt', 'w') for dir in dirs: cd(dir) f = open('dump.force') for i in range(9): f.next() for b in range(ii): f.next() line = f.next() line = line.split() force = np.array(map(float, line[1:4])) # force=RotateVector(force,d1,-p1) # force=RotateVector(force,d,-p) d = disps[i] ccos = force.dot(d) / L(force) / L(d) ii += 1 print >> out, "%d\t%f" % (ii, ccos) cd(maindir)
def run(self): old = tl.pwd() for job in self.jobs: tl.cd(job.path) job.writepbs() job.submit() tl.cd(old)
def prepareet(self): atoms = io.read('POSCAR') from pyspglib import spglib s = spglib.get_spacegroup(atoms) from aces.scanf import sscanf sgN = sscanf(s, '%s (%d)')[1] sg = Spacegroup(sgN) atoms.info = {'spacegroup': sg} nelect = self.getNelect(outcar='band/OUTCAR') # The remaining part takes care of writing the files required by # BoltzTraP. bandstructure = vasp2boltz.get_vasp_bandstructure(pathname='band/') tl.mkcd('et') vasp2boltz.write_bandstructure_boltztrap(bandstructure, filename='et.energy') vasp2boltz.write_structure_boltztrap(atoms, filename='et.struct') vasp2boltz.write_intrans_boltztrap(n_electrons=nelect, filename='et.intrans') s = tl.read('et.energy') s = s.replace('HTE', 'et') tl.write(s, 'et.energy') s = tl.read('et.struct') s = s.replace('HTE', 'et') tl.write(s, 'et.struct') tl.cd('..')
def getPhonons(self): maindir = tl.pwd() tl.mkcd('phonons') self.runscf() self.runph() self.collect() tl.cd(maindir)
def checkMinimize(self): import yaml data = yaml.load(open('disp.yaml').read()) disps = [map(float, a['direction']) for a in data['displacements']] maindir = pwd() dirs = ls('dirs/dir_*') ii = 0 L = np.linalg.norm # d,p,d1,p1=self.m.rot out = open('ccos.txt', 'w') for dir in dirs: cd(dir) f = open('dump.force') for i in range(9): f.next() for b in range(ii): f.next() line = f.next() line = line.split() force = np.array(map(float, line[1:4])) # force=RotateVector(force,d1,-p1) # force=RotateVector(force,d,-p) d = disps[i] ccos = force.dot(d) / L(force) / L(d) ii += 1 print >> out, "%d\t%f" % (ii, ccos) cd(maindir)
def prepareet(self): fermi = self.get_fermi() nelect = self.get_nelect() tl.mkcd('et') tl.cp('../band/SYMMETRY', '.') tl.cp('../band/EIGENVAL', '.') tl.cp('../band/POSCAR', '.') lpfac = 5 if(self.m.soc): lpfac = 20 s = """VASP 0 1 0 0.0 %f 0.0005 0.40 %f CALC %d BOLTZ .15 800. 50. 0. """ % (fermi, nelect, lpfac) # Format of DOS # iskip (not presently used) idebug setgap shiftgap # Fermilevel (eV, please note), energygrid (Ry),\ # energy span around Fermilevel (Ry), No of electrons # CALC (calculate expansion coeff), NOCALC read from file # lpfac, number of latt-points per k-point # run mode (only BOLTZ is supported) # (efcut) energy range of chemical potential (Ry) # Tmax, temperature grid # energyrange of bands given individual \ # DOS output sig_xxx and dos_xxx (xxx is band number) tl.write(s, "et.intrans") tl.cd('..')
def getvasprun(self, files): m = self.m maindir = pwd() if m.engine == "vasp": calculator = self.getVaspRun_vasp elif m.engine == "lammps": calculator = self.getVaspRun_lammps self.jm = jobManager() for file in files: print(file) dir = "dirs/dir_" + file mkdir(dir) mv(file, dir + '/POSCAR') cd(dir) calculator() cd(maindir) self.jm.run() if m.th: mkdir(m.pbsname) self.thcode(files, m.pbsname) cp("dirs", m.pbsname) passthru("tar zcf %s.tar.gz %s" % (m.pbsname, m.pbsname)) print('start check') self.jm.check() if m.engine == "lammps1": from multiprocessing.dummy import Pool pool = Pool() pool.map_async(lammpsvasprun, files) pool.close() pool.join()
def runet(self): tl.cd('et') m = self.m if(m.soc): tl.passthru(config.x_trans_vasp + " BoltzTrap_vasp -so") else: tl.passthru(config.x_trans_vasp + " BoltzTrap_vasp") tl.cd('..')
def run(name): path=home(name) if not exists(path): workdir=shell_exec('pwd') cd(dirname(path)) passthru("make") cd(workdir) passthru(path)
def prepareBand(self): tl.mkcd('band') # run vasp tl.cp('../POSCAR', '.') self.getVaspRun_vasp() # cp('/home1/xggong/zhouy/tcscripts/sis/ # sis1.1/0/secondorder/dirs/dir_POSCAR-002/EIGENVAL','.') # cp('/home1/xggong/zhouy/tcscripts/ # sis/sis1.1/0/secondorder/dirs/dir_POSCAR-002/OUTCAR','.') tl.cd('..')
def prepareBand(self): tl.mkcd('band') # run vasp tl.cp('../POSCAR', '.') self.getVaspRun_vasp() # cp('/home1/xggong/zhouy/tcscripts/sis/ # sis1.1/0/secondorder/dirs/dir_POSCAR-002/EIGENVAL','.') # cp('/home1/xggong/zhouy/tcscripts/ # sis/sis1.1/0/secondorder/dirs/dir_POSCAR-002/OUTCAR','.') tl.cd('..')
def getV(self): if not exists('groupv'): mkdir('groupv') cd('groupv') cp('../FORCE_CONSTANTS', '.') cp('../POSCAR', '.') cp('../disp.yaml', '.') self.generate_vconf() passthru(config.phonopy + "--tolerance=1e-4 v.conf") self.drawV() cd('..')
def getPotName(self): maindir = tl.pwd() tl.cd(config.qepot) files = tl.ls("*") tl.cd(maindir) import re q = [re.split("[_\.]", a)[0].capitalize() for a in files] u = {} for i, v in enumerate(q): u[v] = files[i] return u
def getV(self): if not exists('groupv'): mkdir('groupv') cd('groupv') cp('../FORCE_CONSTANTS', '.') cp('../POSCAR', '.') cp('../disp.yaml', '.') self.generate_vconf() passthru(config.phonopy + "--tolerance=1e-4 v.conf") self.drawV() cd('..')
def getPotName(self): maindir = tl.pwd() tl.cd(config.qepot) files = tl.ls("*") tl.cd(maindir) import re q = [re.split("[_\.]", a)[0].capitalize() for a in files] u = {} for i, v in enumerate(q): u[v] = files[i] return u
def getepw(self): m = self.m maindir = tl.pwd() tl.mkcd('epw') """为了保证q+k也在k的格点上,必须要求qs*cell*[nk1,nk2,nk3]为整数,即nk=N*nq 否则可能出现Error in routine createkmap (1): """ u = np.array(m.ekpoints) / np.array(m.kpoints) assert np.allclose(np.floor(u + .5), u, rtol=0.01) self.runscf() self.runnscf() self.runepw() tl.cd(maindir)
def runSPOSCAR(self): m = self.m maindir = pwd() file = "SPOSCAR" dir = "dir_" + file mkdir(dir) cp(file, dir + '/POSCAR') cd(dir) if m.engine == "vasp": self.getVaspRun_vasp() if m.engine == "lammps": self.getVaspRun_lammps() cd(maindir)
def runSPOSCAR(self): m = self.m maindir = pwd() file = "SPOSCAR" dir = "dir_" + file mkdir(dir) cp(file, dir + '/POSCAR') cd(dir) if m.engine == "vasp": self.getVaspRun_vasp() if m.engine == "lammps": self.getVaspRun_lammps() cd(maindir)
def getepw(self): m = self.m maindir = tl.pwd() tl.mkcd('epw') """为了保证q+k也在k的格点上,必须要求qs*cell*[nk1,nk2,nk3]为整数,即nk=N*nq 否则可能出现Error in routine createkmap (1): """ u = np.array(m.ekpoints) / np.array(m.kpoints) assert np.allclose(np.floor(u + .5), u, rtol=0.01) self.runscf() self.runnscf() self.runepw() tl.cd(maindir)
def creatmini(self, m): print('creatmini') m.home = pwd() assert m.home != '' mkdir('minimize') cd('minimize') minimize_input(m) write(time.strftime('%Y-%m-%d %H:%M:%S'), 'done') cd('..') if m.engine == "lammps": return m.dump2POSCAR(m.home + '/minimize/range') else: return io.read(m.home + '/minimize/CONTCAR')
def tDisorder(): # disorder degree*/ now = tl.pwd() tl.cd('minimize') tl.mkcd('disorder') disorderLine = tl.shell_exec( "cp %s" % SRCHOME + "/in.disorder .;" + config.lammps + " <in.disorder 2>err 1>log;tail -1 disorder.txt 2>err;") k = disorderLine.split()[1:3] if len(k) == 1: k.append("") disorder, rd = k tl.cd(now) return (disorder, rd)
def generate(self): m = self.m coordination = self.phontsAtoms() content0 = "species %d\n" % (len(m.elements)) + m.phontsmasses + """ D3_cutoff %f kpoints %s 1 delta 0.005 numerical_2der T numerical_3der T iter_steps 3 pdos 0. 70. 200 10. temp 60. 400. 10 AbInitio T F FP_interface LAMMPS #phonons_only T Lattice 1.0 %s end """ % (m.shengcut, m.toString(m.kpoints), coordination) tl.write(content0, 'phonons_input.dat') tl.passthru(config.phonts) # generate many displacement files tl.mkdir('lammps') tl.cd('lammps') content = "units %s\n" % m.units content += """atom_style charge dimension 3 boundary p p p read_data GENERIC %s %s neighbor 1.1 bin neigh_modify every 1 delay 1 check yes dump 1 all custom 1 *.dump id fx fy fz dump_modify 1 format "%%d %%30.20f %%30.20f %%30.20f" dump_modify 1 sort id run 0 """ % (m.masses, m.potential) tl.shell_exec("mv ../*.str .") strs = tl.shell_exec("ls *.str").split("\n") for str in strs: dir = str.replace("str", "dir") tl.mkdir(dir) tl.write(content.replace("GENERIC", str), dir + "/in") tl.mv(str, "%s/%s" % (dir, str)) tl.cd(dir) tl.passthru(config.lammps + " <in >out.dat") tl.cd('..') dirs = tl.shell_exec("ls |grep dir").split("\n") for dir in dirs: print(dir) tl.cp(dir + "/0.dump", "../" + dir.replace("dir", "out")) tl.cp("1.0000.dir/out.dat", "../1.0000.out") tl.cd('..') content0 = content0.replace('AbInitio T F', 'AbInitio F T') tl.write(content0, 'phonons_input.dat') tl.passthru(config.phonts)
def generate(self): m = self.m coordination = self.phontsAtoms() content0 = "species %d\n" % (len(m.elements)) + m.phontsmasses + """ D3_cutoff %f kpoints %s 1 delta 0.005 numerical_2der T numerical_3der T iter_steps 3 pdos 0. 70. 200 10. temp 60. 400. 10 AbInitio T F FP_interface LAMMPS #phonons_only T Lattice 1.0 %s end """ % (m.shengcut, m.toString(m.kpoints), coordination) tl.write(content0, 'phonons_input.dat') tl.passthru(config.phonts) # generate many displacement files tl.mkdir('lammps') tl.cd('lammps') content = "units %s\n" % m.units content += """atom_style charge dimension 3 boundary p p p read_data GENERIC %s %s neighbor 1.1 bin neigh_modify every 1 delay 1 check yes dump 1 all custom 1 *.dump id fx fy fz dump_modify 1 format "%%d %%30.20f %%30.20f %%30.20f" dump_modify 1 sort id run 0 """ % (m.masses, m.potential) tl.shell_exec("mv ../*.str .") strs = tl.shell_exec("ls *.str").split("\n") for str in strs: dir = str.replace("str", "dir") tl.mkdir(dir) tl.write(content.replace("GENERIC", str), dir + "/in") tl.mv(str, "%s/%s" % (dir, str)) tl.cd(dir) tl.passthru(config.lammps + " <in >out.dat") tl.cd('..') dirs = tl.shell_exec("ls |grep dir").split("\n") for dir in dirs: print(dir) tl.cp(dir + "/0.dump", "../" + dir.replace("dir", "out")) tl.cp("1.0000.dir/out.dat", "../1.0000.out") tl.cd('..') content0 = content0.replace('AbInitio T F', 'AbInitio F T') tl.write(content0, 'phonons_input.dat') tl.passthru(config.phonts)
def tDisorder(): # disorder degree*/ now = tl.pwd() tl.cd('minimize') tl.mkcd('disorder') disorderLine = tl.shell_exec( "cp %s" % SRCHOME + "/in.disorder .;" + config.lammps + " <in.disorder 2>err 1>log;tail -1 disorder.txt 2>err;") k = disorderLine.split()[1:3] if len(k) == 1: k.append("") disorder, rd = k tl.cd(now) return (disorder, rd)
def vfc(self): c = self.m.correlation_supercell q = [] u = [int(x / 2) * 2 + 1 for x in c] for i in range(u[0]): for j in range(u[1]): for k in range(u[2]): b = np.array([ float(i - c[0] / 2) / c[0], float(j - c[1] / 2) / c[1], float(k - c[2] / 2) / c[2] ]) q.append(b) m = self.m tl.mkcd('vqpoints') tl.cp('../FORCE_CONSTANTS', '.') tl.cp('../disp.yaml', '.') tl.cp('../POSCAR', '.') Prun(m).getvqpoints(q) tl.cd('..')
def vfc(self): c = self.m.correlation_supercell q = [] u = [int(x / 2) * 2 + 1 for x in c] for i in range(u[0]): for j in range(u[1]): for k in range(u[2]): b = np.array([ float(i - c[0] / 2) / c[0], float(j - c[1] / 2) / c[1], float(k - c[2] / 2) / c[2] ]) q.append(b) m = self.m tl.mkcd('vqpoints') tl.cp('../FORCE_CONSTANTS', '.') tl.cp('../disp.yaml', '.') tl.cp('../POSCAR', '.') Prun(m).getvqpoints(q) tl.cd('..')
def getlead(self): cd('center') left = self.findlead('left') right = self.findlead('right') cd('..') return from aces.io.vasp import writevasp mkcd('leftlead') writevasp(left, 'POSCAR') self.runlead() cd('..') mkcd('rightlead') writevasp(right, 'POSCAR') self.runlead() cd('..')
def ineq(m): now = tl.pwd() species = m.species if not (species in ["CN-small"]): return 0.0 tl.cd('minimize') tl.mkdir('nonequ') tl.cd('nonequ') ie = inequality() nonequ5 = ie.run() tl.cd(now) return nonequ5
def ineq(m): now = tl.pwd() species = m.species if not (species in ["CN-small"]): return 0.0 tl.cd('minimize') tl.mkdir('nonequ') tl.cd('nonequ') ie = inequality() nonequ5 = ie.run() tl.cd(now) return nonequ5
def generate(self): # m = self.m self.minimizePOSCAR() # cp('minimize/POSCAR','.') mkdir('secondorder') cd('secondorder') self.pSecond() self.fc2() cd('..') self.third() self.vasprun3() self.force_constant3() cd('..') self.pSheng() self.runsheng()
def creatmini(self, dir): cur = tl.pwd() tl.mkdir(dir) tl.cd(dir) minimize_input(self.m) tl.cd(cur)
def writeatoms(self, atoms, label='atoms'): tl.mkcd(label) self.watoms(atoms) tl.cd('..')
def runet(self): tl.cd('et') tl.passthru(config.x_trans + " BoltzTraP") tl.cd('..')
def creatmini(self, dir): cur = tl.pwd() tl.mkdir(dir) tl.cd(dir) minimize_input(self.m) tl.cd(cur)
def writeatoms(self, atoms, label='atoms'): tl.mkcd(label) self.watoms(atoms) tl.cd('..')
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 third(self): mkdir('thirdorder') cd('thirdorder') cp('../POSCAR', '.') self.generate_supercells3()
def pSheng(self): mkdir('SHENG') cd('SHENG') cp('../secondorder/FORCE_CONSTANTS', 'FORCE_CONSTANTS_2ND') cp('../thirdorder/FORCE_CONSTANTS_3RD', '.') self.getControl()
fp = open('qloops.txt') dirs = [] for line in fp: obj = json.loads(line) #if not obj['id']%3==0:continue dirs.append(dict(id=obj['id'], latysmall=obj['latysmall'])) import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from aces import tools ys = [] dp = pd.DataFrame() for dir in dirs: tools.cd(str(dir['id'])) df = pd.read_csv("VDOS.txt", sep=r"[ \t]", engine="python") x, y = getDos(df['Freq_THz'], df['vdos_av']) dp['freq'] = x dp["latysmall=%s" % dir['latysmall']] = y tools.cd('..') dp.to_csv('total_dos.txt', sep='\t', index=False, float_format="%f") for dir in dirs: label = "latysmall=%s" % dir['latysmall'] plt.plot(dp['freq'], dp[label], linewidth=1, label=label) plt.grid(True) plt.xlim(min(x), max(x)) plt.xlabel('Frequency(THz)') plt.ylabel('Density of states') plt.legend(loc='best').get_frame().set_alpha(0.0) plt.savefig('smoothVDOS.png', bbox_inches='tight', transparent=True)