# -*- coding: UTF-8 -*- import numpy as np import pylab as pl import math def readabc(): nKpts=0 eigfile = 'abc.Band' fIn = open(eigfile, 'r') lines = fIn.readlines() Nkpath = 8 #这里填写k点路径上一行的行号 for i in range(3,Nkpath): tmp = lines[i].rstrip().split() nKpts = nKpts+int(tmp[0]) print(nKpts) tmp = lines[0].rstrip().split() nBands = int(tmp[0]) print(nBands) tmp = lines[0].rstrip().split() E_Fermi=float(tmp[2]) print(E_Fermi) data = np.zeros((nKpts, nBands*2+4), dtype=np.float64) for i in range(0,nKpts): tmp = lines[Nkpath+1+i*4].rstrip().split() #自旋向上 tmp1 = lines[Nkpath+3+i*4].rstrip().split() #自旋向下 tmp2 = lines[Nkpath+i*4].rstrip().split() #存储k点路径 data[i][0]=float(i) for k in range(1,4): data[i][k]=tmp2[k] for j in range(0,nBands): # data[i][j+4]=(float(tmp[j])-E_Fermi)*27.211 # data[i][j+nBands+4]=(float(tmp1[j])-E_Fermi)*27.211 # data[i][j+4]=(float(tmp[j])-E_Fermi) # data[i][j+nBands+4]=(float(tmp1[j])-E_Fermi) data[i][j+4]=float(tmp[j]) data[i][j+nBands+4]=float(tmp1[j]) file = open("./"+"abc"+".dat",'w') file.write(str("iK")) file.write(' ') file.write(str("Kx")) file.write(' ') file.write(str("Ky")) file.write(' ') file.write(str("Kz")) file.write(' ') for i in range(1,nBands+1): file.write(str("Band")+str(i)) file.write(' ') for i in range(1,nBands+1): file.write(str("Band")+str(i)) file.write(' ') file.write("\n") for i in range(0,nKpts): for j in range(0,nBands*2+1): file.write(str(data[i,j])) file.write(' ') file.write("\n") file.close() s=-0.1597417 for i in range(0,nKpts): for j in range(0,nBands*2+4): if math.fabs(data[i][j]-s)<0.000001: print(i,j-4+1) #因为band是从1开始的,所以要加1 readabc()
No Comments
Leave a comment Cancel