def __init__(self, filename): lm = self.lm = lineManager(filename) self.mesh = sscanf(lm.getLine(0), 'mesh: [ %d, %d, %d ]') self.nqpoint, = sscanf(lm.getLine(1), 'nqpoint: %d') self.natom, = sscanf(lm.getLine(2), 'natom: %d') self.nbranch = 3 * self.natom self.lenatom = 4 self.leneigvec = self.natom * self.lenatom + 1 self.lenbranch = self.leneigvec + 2 self.lenband = self.lenbranch * self.nbranch + 1 self.lenqpoint = self.lenband + 3
def __init__(self, filename): lm = self.lm = lineManager(filename) self.mesh = sscanf(lm.getLine(0), 'mesh: [ %d, %d, %d ]') self.nqpoint, = sscanf(lm.getLine(1), 'nqpoint: %d') self.natom, = sscanf(lm.getLine(2), 'natom: %d') if 'reci' in lm.getLine(3): self.off = 4 else: self.off = 0 self.nbranch = 3 * self.natom self.lenatom = 4 self.leneigvec = self.natom * self.lenatom + 1 self.lenbranch = self.leneigvec + 2 self.lenband = self.lenbranch * self.nbranch + 1 self.lenqpoint = self.lenband + 3
def get_outfermi(self): file = ls("*.outputtrans")[0] a = shell_exec("grep FermiE %s|tail -1" % file) from aces.scanf import sscanf a = sscanf(a, "FermiE: %f.")[0] print "E-fermi=" + str(a) + "Ry" return a
def get_outfermi(self): file = tl.ls("*.outputtrans")[0] a = tl.shell_exec("grep FermiE %s|tail -1" % file) from aces.scanf import sscanf a = sscanf(a, "FermiE: %f.")[0] print("E-fermi=" + str(a) + "Ry") return a
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 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 frequency(self, iqp, ibr, i=False): lm = self.lm iline = self.qposition(iqp, i=True) + 3 + ibr * self.lenbranch + 1 if i: return iline freq, = sscanf(lm.getLine(iline), ' frequency: %f') return freq
def qposition(self, iqp, i=False): lm = self.lm iline = 4 + self.off + iqp * self.lenqpoint if i: return iline return sscanf(lm.getLine(iline), '- q-position: [ %f, %f, %f ]')
def qposition(self, iqp, i=False): lm = self.lm iline = 4 + self.off + iqp * self.lenqpoint if i: return iline return sscanf( lm.getLine(iline), '- q-position: [ %f, %f, %f ]')
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 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 atom(self, iqp, ibr, ia): lm = self.lm pos = np.zeros(3, dtype=np.complex) iline = self.frequency(iqp, ibr, True) + 2 + self.lenatom * ia + 1 lm.moveto(iline) for i in range(3): x1, x2 = sscanf(lm.nextLine(), ' - [ %f, %f ]') pos[i] = x1 + 1j * x2 return pos
def getKlist(self, dir="./"): file = open(dir + "ph.out") q = [] from aces.scanf import sscanf for line in file: if " N xq(1) xq(2) xq(3)" in line: while True: line = file.next().strip() if (line == ""): break k = sscanf(line, "%d %f %f %f")[1:] q.append(k) break assert len(q) > 0 return q
def energyForce(self): self.writeINCAR() m=self.m m.writePOTCAR() s="""A 0 Monkhorst-Pack %s 0 0 0 """%' '.join(map(str,m.mekpoints)) write(s,'KPOINTS') shell_exec(config.mpirun+" %s "%m.cores+config.vasp+' >log.out') try: from lxml import etree except ImportError: print "You need to install python-lxml." vasprun = etree.iterparse("vasprun.xml", tag='varray') forces=self.parseVasprun('forces') stress=self.parseVasprun('stress') c=shell_exec("grep TOTEN OUTCAR|tail -1") from aces.scanf import sscanf energe=sscanf(c,"free energy TOTEN = %f eV")[0] return forces,stress,energy
def get_fermi(self): a = tl.shell_exec("grep fermi band/OUTCAR|tail -1") from aces.scanf import sscanf a = sscanf(a, "E-fermi : %f XC(G=0): %f alpha+bet :%f")[0] print("E-fermi=" + str(a) + "eV") return a
def getfermi(self): a = tl.shell_exec("grep Fermi nscf.out").strip() from aces.scanf import sscanf fermi = sscanf(a, "the Fermi energy is %f ev")[0] return fermi
def get_nelect(self): a = shell_exec("grep NELECT band/OUTCAR|tail -1") from aces.scanf import sscanf a = sscanf(a, "NELECT = %f total number of electrons")[0] print "NELECT=" + str(a) return a
def get_nelect(self): a = tl.shell_exec("grep NELECT band/OUTCAR|tail -1") from aces.scanf import sscanf a = sscanf(a, "NELECT = %f total number of electrons")[0] print("NELECT=" + str(a)) return a
def get_fermi(self): a = shell_exec("grep fermi band/OUTCAR|tail -1") from aces.scanf import sscanf a = sscanf(a, "E-fermi : %f XC(G=0): %f alpha+bet :%f")[0] print "E-fermi=" + str(a) + "eV" return a