24小时热门版块排行榜    

Znn3bq.jpeg
查看: 2698  |  回复: 16
【奖励】 本帖被评价13次,作者锐利的碎片增加金币 10

锐利的碎片

木虫 (正式写手)


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

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

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

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

» 猜你喜欢

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

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

锐利的碎片

木虫 (正式写手)


用面向对象重新写了一遍程序,现在只写了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的回帖

akakcolin

金虫 (著名写手)


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

赞赞
3楼2011-02-26 11:39:46
已阅   回复此楼   关注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的回帖

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

★★★★★ 五星级
6楼2011-02-26 16:30:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

liangpei

木虫 (职业作家)


★★★ 三星级,支持鼓励

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

chambana

铁虫 (初入文坛)


支持原创,赞一个,顶!!
14楼2016-10-20 07:31:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

jzjy1994

新虫 (小有名气)


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

大佬
17楼2017-10-28 17:41: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   回复  
三星好评  顶一下,感谢分享!
gooselin15楼
2016-11-23 14:11   回复  
五星好评  顶一下,感谢分享!
whyyzf572516楼
2017-10-27 17:10   回复  
五星好评  顶一下,感谢分享!
相关版块跳转 我要订阅楼主 锐利的碎片 的主题更新
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 273求调剂 +6 白居不易. 2026-04-09 8/400 2026-04-15 22:02 by wooluyong
[考研] 求调剂 +11 小聂爱学习 2026-04-11 15/750 2026-04-15 21:57 by noqvsozv
[考研] 0854调剂 +13 长弓傲 2026-04-12 16/800 2026-04-15 13:45 by fenglj492
[考研] 211本科材料化工求调剂 +19 YHLAH 2026-04-11 23/1150 2026-04-14 22:25 by fenglj492
[考研] 一志愿鲁东大学071000生物学学硕初试分数276求调剂 +26 慕绝cc 2026-04-09 30/1500 2026-04-14 18:50 by 蔡苏阳
[考研] 调剂 +12 月@163.com 2026-04-11 12/600 2026-04-14 15:37 by zs92450
[考研] 一志愿哈工大 085600 277 12材科基求调剂 5+5 chenny174 2026-04-10 37/1850 2026-04-14 07:39 by Abskk
[考研] 297工科,求调剂? +13 河南农业大学-能 2026-04-12 13/650 2026-04-13 14:12 by dingyanbo1
[考研] 求调剂 +16 张番茄不炒蛋 2026-04-10 17/850 2026-04-12 13:58 by 熬夜成!
[考研] 326求调剂 +6 Shansyn 2026-04-10 6/300 2026-04-12 09:46 by hammer3
[考研] 307求调剂 +10 tzq94092 2026-04-10 10/500 2026-04-12 08:18 by wise999
[考研] 化工调剂求导师收留!一志愿失利,踏实肯干,有植物提取科研经历 +20 yzyzx 2026-04-09 21/1050 2026-04-12 00:12 by 小小小小啦啦啦
[考研] 343求调剂 +9 王国帅 2026-04-10 9/450 2026-04-11 20:31 by dongdian1
[考研] 284求调剂 +11 archer.. 2026-04-09 12/600 2026-04-11 20:23 by 蓝云思雨
[考研] 352 求调剂 +6 yzion 2026-04-11 8/400 2026-04-11 16:24 by 明月此时有
[考研] 087100初试311求调剂 +4 任雅琴 2026-04-09 4/200 2026-04-11 10:33 by zhq0425
[考研] 一志愿北理工298英一数二已上岸,感谢各位老师 +14 Reframe 2026-04-10 16/800 2026-04-10 23:07 by caotw2020
[考研] 调剂 +12 卷卷卷心菜_ 2026-04-09 13/650 2026-04-10 22:36 by Ftglcn90
[考研] 301求调剂 +5 149. 2026-04-10 5/250 2026-04-10 15:45 by 柴小白
[考研] 332,085601求调剂 +12 ydfyh 2026-04-09 14/700 2026-04-09 17:28 by wp06
信息提示
请填处理意见