24小时热门版块排行榜    

Znn3bq.jpeg
查看: 2695  |  回复: 16
【奖励】 本帖被评价13次,作者锐利的碎片增加金币 10
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

锐利的碎片

木虫 (正式写手)


[资源] 【原创】处理elk能带的程序

自己写的用python处理elk能带的程序
回复此楼

» 收录本帖的淘帖专辑推荐

材料计算模拟实用技巧 第一性原理计算辅助工具

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

liangpei

木虫 (职业作家)


★★★ 三星级,支持鼓励

这个程序是支持wien2k还是vasp的》》》
7楼2011-08-19 10:29:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 17 个回答

锐利的碎片

木虫 (正式写手)


用面向对象重新写了一遍程序,现在只写了elk的类,处理其他程序(比如vasp)结果的程序可以很方便的加进来。主程序部分没写,这个应该没有多难。
CODE:
class Band():
    def write_data(self):
        if self.nspin==1:
            fout=file('band.data','w')
            for i in range(self.ndiv):
                fout.write("%12.8f "%self.band[0][i])
                for j in range(self.nband):
                    fout.write("%12.8f "%self.band[j+1][i])
                fout.write('\n')
            fout.close()
        elif self.nspin==2:
            foutup=file('bandup.data','w')
            foutdn=file('banddn.data','w')
            for i in range(self.ndiv):
                foutup.write("%12.8f "%self.band[0][i])
                foutdn.write("%12.8f "%self.band[0][i])
                for j in range(self.nband/2):
                    foutup.write("%12.8f "%self.band[j+1][i])
                foutup.write('\n')
                for j in range(self.nband/2,self.nband):
                    foutdn.write("%12.8f "%self.band[j+1][i])
                foutdn.write('\n')
            foutup.close()
            foutdn.close()

    def view_band(self,emin,emax,title,xlabel,ylabel):
        import numpy as np
        import matplotlib.pyplot as plt
        #plot setup
        plt.title(title)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        plt.xlim(self.kpos[0],self.kpos[-1])
        plt.ylim(emin,emax)
        plt.xticks(self.kpos,self.kpname)
        plt.grid(linestyle='-')
        plt.gca().xaxis.grid(True)
        plt.gca().yaxis.grid(False)
        #plot bands
        for i in range(self.nband):
            x=self.band[0]
            y=self.band[i+1]
            if np.min(y)emax:
                continue
            else:
                if self.nspin==1:
                    plt.plot(x,y,'r-')
                elif self.nspin==2:
                    if i                         plt.plot(x,y,'r-')
                    else:
                        plt.plot(x,y,'b--')
        plt.plot([self.kpos[0],self.kpos[-1]],[0.0,0.0],\
                 color='black',linestyle='--')
        plt.text(0.0,0.1,r'$E_F$=%6.3f eV'%self.fermi)
        plt.show()

class ElkBand(Band):
    def __init__(self):
        import sys
        import numpy as np
        try:
            fmain=file('elk.in','r')
            fpos=file('BANDLINES.OUT','r')
            fband=file('BAND.OUT','r')
            ffermi=file('EFERMI.OUT','r')
        except IOError:
            print 'Error in open nessary inputs. Check your input file'
            sys.exit()
        # initalize
        self.kpname=[] #names of kpoints
        self.kpos=[] #positions of special kpoints in G space
        self.nspin=1 #number of spins
        self.nband=0 #number of band
        self.band=[] #banddata
        # get self.nspin self.kpname self.nkp(number of special kpoints)
        # self.ndiv
        while True:
            tmp=fmain.readline()
            if len(tmp)==0:
                break
            if tmp.strip()=='spinpol':
                if fmain.readline().strip()=='.true.':
                    self.nspin=2
            if tmp.strip()=='plot1d':
                self.nkp,self.ndiv=fmain.readline().split()[0:2]
                self.nkp=int(self.nkp)
                self.ndiv=int(self.ndiv)
                for i in range(self.nkp):
                    self.kpname.append('$'+str(fmain.readline().split()[3])+'$')
        # get self.kpos
        while True:
            tmp=fpos.readline()
            if len(tmp)==0:
                break
            self.kpos.append(float(tmp.split()[0]))
            fpos.readline()
            fpos.readline()
        # get self.fermi
        self.fermi=27.2114*float(ffermi.readline().strip())
        # get self.nband self.band
        while True:
            tmp=fband.readline()
            if len(tmp)==0:
                break
            if len(tmp.strip())==0 and len(tmp)!=0:
                self.nband=self.nband+1
        rawband=np.loadtxt('BAND.OUT')
        kp=rawband[0:self.ndiv,0]
        self.band.append(kp)
        for i in range(self.nband):
            eig=27.2114*rawband[i*self.ndiv:(i+1)*self.ndiv,1]
            self.band.append(eig)
        #close files
        fmain.close()
        fpos.close()
        fband.close()
        ffermi.close()

    def write_data(self):
        Band.write_data(self)

    def view_band(self,emin=-10.0,emax=15.0,title='Band Plot',\
                 xlabel='K-Path',ylabel='Energy / eV'):
        Band.view_band(self,emin,emax,title,xlabel,ylabel)

[ Last edited by 锐利的碎片 on 2011-2-26 at 12:17 ]
2楼2011-02-26 09:15:54
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
支持原创,赞一个,顶!!
4楼2011-02-26 13:26:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

lixiao85

银虫 (小有名气)


★★★★★ 五星级,优秀推荐

或许以后能用上
5楼2011-02-26 14:49:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
简单回复
xh5128楼
2012-01-06 07:17   回复  
五星好评  顶一下,感谢分享!
tanloer9楼
2012-02-13 15:28   回复  
五星好评  顶一下,感谢分享!
mink10楼
2014-06-18 07:40   回复  
五星好评  顶一下,感谢分享!
102424790011楼
2014-07-03 21:32   回复  
五星好评  顶一下,感谢分享!
zwynu12楼
2014-09-24 21:57   回复  
五星好评  顶一下,感谢分享!
Toapollo13楼
2015-03-28 20:58   回复  
三星好评  顶一下,感谢分享!
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 通信工程求调剂!!! +4 zlb770521 2026-04-14 4/200 2026-04-14 18:19 by lbsjt
[考研] 一志愿中国科学院上海有机所,有机化学356分找调剂 +12 Nadiums 2026-04-09 13/650 2026-04-14 17:54 by lhj2009
[考研] 071000生物学调剂求助 +18 zzzzwww 2026-04-09 21/1050 2026-04-14 15:39 by zs92450
[考研] 279求调剂 +12 张番茄不炒蛋 2026-04-11 12/600 2026-04-14 15:38 by zs92450
[考研] 求调剂 +20 MAX怅惘 2026-04-09 22/1100 2026-04-14 14:57 by 独醉梦孤城
[考研] 085408光电信息工程专硕355一志愿长春光机所调剂 +6 王ymaa 2026-04-13 13/650 2026-04-14 11:33 by 王ymaa
[考研] 求调剂288 +7 ioodiiij 2026-04-10 9/450 2026-04-13 08:33 by Hayaay
[考研] 一志愿0807 数一英一 313 有没有二轮调剂 +12 emokidd 2026-04-08 13/650 2026-04-13 08:32 by lhj2009
[考研] 2本,初试303,0860求调剂 +6 floriea 2026-04-12 8/400 2026-04-12 18:13 by zhouxiaoyu
[考研] 电气专硕320求调剂 +6 小麻子111 2026-04-10 6/300 2026-04-12 10:54 by lemon6009
[考研] 303求调剂 +14 SereinQ 2026-04-10 15/750 2026-04-11 20:43 by 蓝云思雨
[考研] 085400 328分 求调剂 +10 喂你一个大橙子 2026-04-09 14/700 2026-04-11 19:53 by lqspecial
[考研] 311求调剂 +13 xyp想读书 2026-04-10 14/700 2026-04-11 09:41 by 猪会飞
[考研] 368求调剂 +3 17385968172 2026-04-10 3/150 2026-04-10 20:12 by 电子奥德彪
[考研] 085800 能源动力求调剂 +6 阿biu啊啊啊啊啊 2026-04-10 6/300 2026-04-10 15:03 by hemengdong
[考研] 已调剂 +18 柴郡猫_ 2026-04-09 19/950 2026-04-09 22:10 by 柴郡猫_
[考研] 一志愿中科院105500专业总分315求调剂 +6 lallalh 2026-04-09 7/350 2026-04-09 17:51 by lallalh
[考研] 085501机械英二77总分294求调剂,接受跨专业学习 +6 守法公民亓纪 2026-04-08 6/300 2026-04-09 15:55 by wp06
[考研] 349学科化学045106求调剂,化学类都可以 +8 保好懂懂 2026-04-08 8/400 2026-04-09 14:03 by xulei3024
[考研] 0860004 求调剂 309分 +6 Yin DY 2026-04-09 6/300 2026-04-09 10:19 by 啊李999
信息提示
请填处理意见