def read(self,filepath): print 'reading Procar', lines = nstrip(readfile(filepath)) self.nk = int(lines[1].split(':')[1].split()[0]) self.nbands = int(lines[1].split(':')[2].split()[0]) self.nions = int(lines[1].split(':')[3]) #initialize self.kvecs = zeros((3,self.nk),dtype = float) self.kweights = zeros((self.nk),dtype = float) self.ener = zeros((self.nk, self.nbands, self.nspin),dtype = float) self.occ = zeros((self.nk, self.nbands,self.nspin),dtype = float) self.weights = zeros((self.nk,self.nbands,self.nions,len(self.orbs),self.nspin),dtype = float) #read weights ipos = 2 for ispin in range(self.nspin): ipos += 1; # print 'ipos for spin %i: %i' % (ispin,ipos) for ik in range(self.nk): self.kvecs[:,ik] = lines[ipos].split()[3:6] self.kweights[ik] = float(lines[ipos].split()[8]) ipos += 2 for ib in range(self.nbands): self.ener[ik,ib,ispin] = float(lines[ipos].split()[4]) self.occ[ik,ib,ispin] = float(lines[ipos].split()[7]) ipos += 3 for i in range(self.nions): if mod(ipos,1e4)==0: print '-', #progress bar tempw = lines[ipos].split()[1:self.norbs+1] self.weights[ik,ib,i,:,ispin] = tempw ipos += 1 ipos += 2 ipos += 1 print
def rd_ibzkpt(self,dir): #only extracts the kpoint vectors self.vecs = zeros((3,self.nk),dtype = float64) lines = nstrip(readfile(dir+'IBZKPT')) nk2 = int(lines[1].split()[0]) if nk2 != self.nk: print nk2,self.nk, 'Warning! Nkpts in IBZKPTS differs from this program''s' for ik in range(self.nk): self.vecs[:,ik] = lines[ik+3].split()[:3] #don't read weights'
def get_eigen(self,dir): lines = nstrip(readfile(dir+'eigenv')) self.nk = int(lines[0].split()[0]) self.nbands = int(lines[0].split()[1]) self.ener = zeros((self.nk,self.nbands),dtype = float64) for ik in range(self.nk): for ib in range(self.nbands): self.ener[ik,ib] = lines[ik+1].split()[ib+1]
def get_tetweights(self,dir): lines = nstrip(readfile(dir+'tetwgt')) self.ntet = int(lines[0].split()[0]) self.nbands = int(lines[0].split()[1]) # nspin = int(lines[0][2]) #haven't added spin yet self.fwgt = zeros((self.ntet,self.nbands),dtype = float64) for it in range(self.ntet): for ib in range(self.nbands): self.fwgt[it,ib] = lines[it+1].split()[ib+1] #First line and first column are not weights
def rd_ibzkpt(self,dir): #only extracts the tets ids self.idk = zeros((4,self.ntet),dtype = int) self.vwgt = zeros(self.ntet,dtype = float64) lines = nstrip(readfile(dir+'IBZKPT')) nk = int(lines[1].split()[0]) ntet2 = int(lines[4+nk].split()[0]) self.volscale = float(lines[4+nk].split()[1]) print 'VASP volume scale', self.volscale if ntet2 != self.ntet: print 'Warning! NTET in IBZKPTS differs from this program''s' for it in range(self.ntet): self.vwgt[it] = lines[5+nk+it].split()[0] self.idk[:,it] = lines[5+nk+it].split()[1:] self.idk = self.idk -1 #(converting from Fortran counting to python)
def get_tetvecs(self,dir): lines = nstrip(readfile(dir+'tetvecs')) self.vecs = zeros((3,4,self.ntet),dtype = float64) self.vol = zeros(self.ntet,dtype = float64) print shape(self.vecs) for it in range(self.ntet): for ic in range(4): print it, ic,lines[5*it+ic+1] self.vecs[:,ic,it] = lines[5*it+ic+1].split() va = self.vecs[:,1,it]-self.vecs[:,0,it] vb = self.vecs[:,2,it]-self.vecs[:,0,it] vc = self.vecs[:,3,it]-self.vecs[:,0,it] self.vol[it] = abs(dot(va,cross(vb,vc))/2.0)
def incar(self,dir): print 'reading ISPIN and LORBIT from INCAR' lines = nstrip(readfile(dir+'INCAR')) for line in lines: if ('ISPIN' in line) or ('ispin' in line): self.nspin = int(line.split('=')[1]) if ('LORBIT' in line) or ('lorbit' in line): lorbit = int(line.split('=')[1]) if lorbit in [0,10]: #no lm decomposition self.orbs = ['s','p','d'] elif lorbit in [1,2,11,12]: self.orbs = ['s','py','pz','px','dxy','dyz','dz2','dxz','dx2'] else: sys.exit('Unrecognized LORBIT in INCAR') self.norbs = len(self.orbs)
def incar(self, dir): print 'reading ISPIN and LORBIT from INCAR' lines = nstrip(readfile(dir + 'INCAR')) for line in lines: if ('ISPIN' in line) or ('ispin' in line): self.nspin = int(line.split('=')[1]) if ('LORBIT' in line) or ('lorbit' in line): lorbit = int(line.split('=')[1]) if lorbit in [0, 10]: #no lm decomposition self.orbs = ['s', 'p', 'd'] elif lorbit in [1, 2, 11, 12]: self.orbs = [ 's', 'py', 'pz', 'px', 'dxy', 'dyz', 'dz2', 'dxz', 'dx2' ] else: sys.exit('Unrecognized LORBIT in INCAR') self.norbs = len(self.orbs)
def read(self, filepath): print 'reading Procar', lines = nstrip(readfile(filepath)) self.nk = int(lines[1].split(':')[1].split()[0]) self.nbands = int(lines[1].split(':')[2].split()[0]) self.nions = int(lines[1].split(':')[3]) #initialize self.kvecs = zeros((3, self.nk), dtype=float) self.kweights = zeros((self.nk), dtype=float) self.ener = zeros((self.nk, self.nbands, self.nspin), dtype=float) self.occ = zeros((self.nk, self.nbands, self.nspin), dtype=float) self.weights = zeros( (self.nk, self.nbands, self.nions, len(self.orbs), self.nspin), dtype=float) #read weights ipos = 2 for ispin in range(self.nspin): ipos += 1 # print 'ipos for spin %i: %i' % (ispin,ipos) for ik in range(self.nk): self.kvecs[:, ik] = lines[ipos].split()[3:6] self.kweights[ik] = float(lines[ipos].split()[8]) ipos += 2 for ib in range(self.nbands): self.ener[ik, ib, ispin] = float(lines[ipos].split()[4]) self.occ[ik, ib, ispin] = float(lines[ipos].split()[7]) ipos += 3 for i in range(self.nions): if mod(ipos, 1e4) == 0: print '-', #progress bar tempw = lines[ipos].split()[1:self.norbs + 1] self.weights[ik, ib, i, :, ispin] = tempw ipos += 1 ipos += 2 ipos += 1 print
deviations = abs(parts - means) + 1e-16 #last term to handle zero entries #print'deviations';print deviations try: file2 = open('lattype', 'r') lattype = file2.read() file2.close() except: lattype = '' ################# summary ################# outfile = open('vary_N.csv', 'w') outfile.write('pf,energy,el converged, el steps, Nkpoints, NIBZ,cputime(min\n') #os.chdir(mainDir) file = open(maindir + 'names', 'r') names = nstrip(file.readlines()) file.close() file = open(maindir + 'energies', 'r') energies = nstrip(file.readlines()) file.close() file = open(maindir + 'Nk', 'r') Nk = nstrip(file.readlines()) file.close() file = open(maindir + 'NkIBZ', 'r') NkIBZ = nstrip(file.readlines()) file.close() file = open(maindir + 'elsteps', 'r')
writeElConverge(dirsfull) writeElSteps(dirsfull) writeCPUtime(dirsfull) parts = enerparts(dirsfull) dets = getdata(dirsfull,'detL') #supercell volume in terms of unit cell volume dets = [float(dets[i]) for i in range(len(dets))] NkfullBZ = getdata(dirsfull,'detM') #Nk without symmetry reduction lattypes = getdata(dirsfull,'lattype') ms = array(getms(dirsfull),dtype = int) filesstructselect = sorted([f for f in os.listdir(os.getcwd())]) #os.chdir(mainDir) file = open(tempdir+'energies','r') energies = nstrip(file.readlines()) file.close() os.system('mv %s %s' % ('energies', 'energies'+structi)) file = open(tempdir+'efermi','r') efermis = nstrip(file.readlines()) file.close() os.system('mv %s %s' % ('efermi', 'efermi'+structi)) file = open(tempdir+'NkIBZ','r') NkIBZ = nstrip(file.readlines()) file.close() os.system('mv %s %s' % ('NkIBZ', 'NkIBZ'+structi)) file = open(tempdir+'elsteps','r') elsteps = nstrip(file.readlines())
#print'means';print means deviations = abs(parts - means) + 1e-16 #last term to handle zero entries #print'deviations';print deviations try: file2 = open('lattype','r'); lattype = file2.read(); file2.close() except: lattype = '' ################# summary ################# outfile = open('vary_pf.csv','w') outfile.write('pf,energy,el converged, el steps, Nkpoints, NIBZ,cputime(min\n') #os.chdir(mainDir) file = open(maindir+'names','r') names = nstrip(file.readlines()) file.close() file = open(maindir+'energies','r') energies = nstrip(file.readlines()) file.close() file = open(maindir+'Nk','r') Nk = nstrip(file.readlines()) file.close() file = open(maindir+'NkIBZ','r') NkIBZ = nstrip(file.readlines()) file.close() file = open(maindir+'elsteps','r')