24小时热门版块排行榜    

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

锐利的碎片

木虫 (正式写手)


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

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

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

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

» 猜你喜欢

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

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
支持原创,赞一个,顶!!
4楼2011-02-26 13:26:03
已阅   回复此楼   关注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的回帖

lixiao85

银虫 (小有名气)


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

或许以后能用上
5楼2011-02-26 14:49:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

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

★★★★★ 五星级
6楼2011-02-26 16:30:45
已阅   回复此楼   关注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   回复  
三星好评  顶一下,感谢分享!
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 297,工科调剂?河南农业大学本科 +11 河南农业大学-能 2026-04-14 11/550 2026-04-15 15:03 by 学员JpLReM
[考研] 297工科调剂? +14 河南农业大学-能 2026-04-13 15/750 2026-04-15 13:25 by 黑科技矿业
[考研] 291分调剂 +9 上岸小莹加油 2026-04-09 10/500 2026-04-15 13:00 by 西北望—风沙
[考研] 289 分105500药学专硕求调剂(找B区学校) +3 白云123456789 2026-04-13 3/150 2026-04-15 12:42 by 西北望—风沙
[考研] 296求调剂 +10 汪!?! 2026-04-09 11/550 2026-04-15 09:17 by fenglj492
[考研] 一志愿鲁东大学071000生物学学硕初试分数276求调剂 +26 慕绝cc 2026-04-09 30/1500 2026-04-14 18:50 by 蔡苏阳
[考研] 药学305求调剂 +10 玛卡巴卡boom 2026-04-10 10/500 2026-04-14 15:55 by zs92450
[考研] 366求调剂 +11 不知名的小卅 2026-04-11 11/550 2026-04-14 15:50 by zs92450
[考研] 调剂 +12 月@163.com 2026-04-11 12/600 2026-04-14 15:37 by zs92450
[考研] 农学0904 312求调剂 +4 Say Never 2026-04-11 4/200 2026-04-14 09:10 by zs92450
[考研] 305求调剂 +8 玛卡巴卡boom 2026-04-11 8/400 2026-04-14 09:04 by pengliang8036
[考研] 一志愿西交机械专硕求调剂 +9 求上岸的小王 2026-04-10 9/450 2026-04-13 16:08 by jiangguiquan11
[考研] 生物学调剂,一志愿西南大学348,Top期刊一区二作、二区三作,三等奖学金三次 +5 candyyyi 2026-04-09 5/250 2026-04-13 09:02 by 可淡不可忘
[考研] 22408 352分求调剂 +5 努力的夏末 2026-04-09 5/250 2026-04-12 19:17 by wj165256
[考研] 296求调剂 +14 汪!?! 2026-04-08 15/750 2026-04-11 20:28 by dongdian1
[考研] 085400 328分 求调剂 +10 喂你一个大橙子 2026-04-09 14/700 2026-04-11 19:53 by lqspecial
[考研] 22408 366分,本科211,一志愿西工大 +4 Rubt 2026-04-09 4/200 2026-04-10 19:51 by chemisry
[考研] 一志愿京区985,085401电子信息,本科电子信息 +3 阳光开朗的男孩 2026-04-10 3/150 2026-04-10 16:29 by sophia_93
[考研] 一志愿沪9,326生物学求相关专业调剂 +4 刘墨墨 2026-04-09 4/200 2026-04-10 12:07 by pengliang8036
[考研] 348求调剂 +3 candyyyi 2026-04-09 3/150 2026-04-09 17:20 by 段伟艳
信息提示
请填处理意见