版块导航
正在加载中...
客户端APP下载
论文辅导
申博辅导
登录
注册
帖子
帖子
用户
本版
应《网络安全法》要求,自2017年10月1日起,未进行实名认证将不得使用互联网跟帖服务。为保障您的帐号能够正常使用,请尽快对帐号进行手机号验证,感谢您的理解与支持!
24小时热门版块排行榜
>
论坛更新日志
(4187)
>
文献求助
(464)
>
虫友互识
(366)
>
导师招生
(292)
>
考博
(168)
>
招聘信息布告栏
(151)
>
硕博家园
(144)
>
论文道贺祈福
(106)
>
休闲灌水
(106)
>
博后之家
(91)
>
考研
(82)
>
论文投稿
(74)
>
基金申请
(63)
>
教师之家
(61)
>
公派出国
(50)
>
找工作
(46)
小木虫论坛-学术科研互动平台
»
计算模拟区
»
第一性原理
»
Vasp&MedeA
»
处理能带的脚本:vasp_band.py
1
1/1
返回列表
查看: 2865 | 回复: 0
只看楼主
@他人
存档
新回复提醒
(忽略)
收藏
在APP中查看
hakuna
木虫
(知名作家)
1ST强帖: 3
应助: 82
(初中生)
金币: 8735.9
散金: 158
红花: 126
帖子: 5599
在线: 1367.2小时
虫号: 167622
注册: 2006-01-15
专业: 考古理论
[交流]
处理能带的脚本:vasp_band.py
http://cmd.kist.re.kr/code/etc/vasp_band.py
CODE:
#!/usr/bin/python
################################################################################
## ##
## vasp_band.py: ##
## ##
## Plot energy bands from VASP in/out files ##
## You need files as following, ##
## ##
## - EIGENVAL (VASP output file) ##
## - OUTCAR (VASP output file) ##
## ##
## cf. './vasp_band.py -h' ##
## ##
## Designed by Jungho Shin ##
################################################################################
import os
import sys
import getopt
from numpy import *
##### default variables to be controled #####
inEigenvalName = 'EIGENVAL' ## the file name of "EIGENVAL" format
inOutcarName = 'OUTCAR' ## the file name of "OUTCAR" format
outDataName = 'band.dat' ## the name of a data(2D coordinate) file
optPersist = 1 ## (1 or 0) if 1, the plot remains on the screen
gpTitle = '< Energy Band Structure >' ## graph's title
gpSize = '0.7, 1.0' ## size of the plot
gpXrange = '[*:*]' ## X axis range
gpXlabel = 'K-points' ## X axis label
gpXticLabel = 0 ## X tic's label, if 0, expresstion by x value
gpYrange = '[*:*]' ## Y axis range
gpYlabel = 'Energy(eV)' ## Y axis label
gpTerm = 'x11' ## a type of terminal and command
gpPlotMethod = 'with line' ## plot method
gpPicForm = 'pos' ## image format
gpPosDefault = 'landscape enhanced color solid "Times-Roman" 15' ## postscript's defaults
gpPicName = 'band.eps' ## image file's name
gpKey = 'nokey' ## 'key' or 'nokey'
## if 'nokey', don't display the label of lines
##########
##### default variables to be fixed #####
blnEigenval = 7 ## the number of comment lines in "EIGENVAL" file
##########
##### options #####
optlist, args = getopt.getopt( sys.argv[1:],
'o:p:k:h', ['kpoints=' , 'eigenval=' ,
'outcar=' , 'blnKpoint=' ,
'title=' , 'size=' ,
'xRange=' , 'xLabel=' ,
'xTicLabel=' , 'yRange=' ,
'yLabel=' , 'term=' ,
'plotMethod=' , 'form=' ,
'epsDefault=' , 'picName='] )
for op,p in optlist:
if op == '-o' : outDataName = p
if op == '-p' : optPersist = int(p)
if op == '-k' : gpKey = p
if op == '-h' : help = 1
if op == '--eigenval' : inEigenvalName = p
if op == '--outcar' : inOutcarName = p
if op == '--title' : gpTitle = p
if op == '--size' : gpSize = p
if op == '--xRange' : gpXrange = p
if op == '--xLabel' : gpXlabel = p
if op == '--xTicLabel' : gpXticLabel = p.split()
if op == '--yRange' : gpYrange = p
if op == '--yLabel' : gpYlabel = p
if op == '--term' : gpTerm = p
if op == '--plotMethod' : gpPlotMethod = p
if op == '--form' : gpPicForm = p
if op == '--epsDefault' : gpPosDefault = p
if op == '--picName' : gpPicName = p
##########
##### print default variables #####
print ""
print ""
print " ** Printing Variables **"
print ""
print " -o : the file name of output data"
print " -p : if 1, the plot remains on the screen (0 or 1)"
print " -k : if 'nokey', don't display the label of lines",
print "('key' or 'nokey')"
print ""
print " --eigenval= : the file name of EIGENVAL format"
print " --outcar= : the file name of OUTCAR format"
print " --title= : graph's title"
print " --size= : size of the plot, ratio of x and y axis"
print " --xRange= : X axis range"
print " --xLabel= : X axis label"
print " --xTicLabel= : X tic label, about greek letter, add 'gk' at the front of alphabet."
print " : usage) --xTicLabel=' X W gkG L '"
print " --yRange= : Y axis range"
print " --yLabel= : Y axis label"
print " --term= : a type of terminal"
print " --plotMethod= : plotting method by Gnuplot command(plot)"
print " --form= : image format"
print " --epsDefault= : postscript's defaults"
print " --picName= : image file's name"
print ""
print " -o '%-s'" % outDataName
print " -p %-d" % optPersist
print " -k '%-s'" % gpKey
print " --eigenval='%-s'" % inEigenvalName
print " --outcar='%-s'" % inOutcarName
print " --title='%-s'" % gpTitle
print " --size='%-s'" % gpSize
print " --xRange='%-s'" % gpXrange
print " --xLabel='%-s'" % gpXlabel
if gpXticLabel==0: print " --xTicLabel=%d" % gpXticLabel
else:
print " --xTicLabel='",
for string in gpXticLabel: print "%s" % string,
print "'"
print " --yRange='%-s'" % gpYrange
print " --yLabel='%-s'" % gpYlabel
print " --term='%-s'" % gpTerm
print " --plotMethod='%s'" % gpPlotMethod
print " --form='%-s'" % gpPicForm
print " --epsDefault='%-s'"% gpPosDefault
print " --picName='%-s'" % gpPicName
print ""
print ""
if help==1: sys.exit()
##########
##### open file #####
inEigenval = open(inEigenvalName, 'r')
outData = open(outDataName, 'wb')
outGpInput = open('gnuinput.in', 'wb')
##########
##### extract 3D coordinates from the input line #####
def extract(inLine):
list = inLine.split()
x = float(list[0])
y = float(list[1])
z = float(list[2])
return x, y, z
##########
##### calculate distance between two points #####
def distCrd(x1, y1, z1, x2, y2, z2):
x21 = abs(x2 - x1)
y21 = abs(y2 - y1)
z21 = abs(z2 - z1)
dist21 = sqrt(x21*x21 + y21*y21 + z21*z21)
return dist21
##########
##### obtain y values(energy) from the "EIGENVAL" file #####
def obtainy():
xMinorCrd = inEigenval.readline() ## xyz
x, y, z = extract(xMinorCrd)
i=0 ; yValueList=[]
while i < nplotLine:
list = inEigenval.readline().split()
yValue = float(list[1])
yValueList.append(yValue)
i = i+1
next = inEigenval.readline() ## blank line
return x, y, z, yValueList, next
##########
##### append x tic label #####
def appendXticLabel(order):
if gpXticLabel==0: xMajorList.append('%s, ' % xMinor)
else:
if len(gpXticLabel) < order+1: print 'ERROR => Needed more tic labels of x axis!!'; sys.exit()
if gpXticLabel[order][0:2]=='gk': gpXticLabel[order] = "{/Symbol "+gpXticLabel[order][2]+"}"
xMajorList.append('"%s" %s, ' % (gpXticLabel[order], xMinor))
order = order+1
return order
##########
##### read comment(blank) lines #####
i=0
while i < blnEigenval:
if i==5:
list = inEigenval.readline().split()
nplotLine = int(list[2])
else:
line = inEigenval.readline()
i = i+1
##########
##### transfer format and write into the output file #####
fermiE = (os.popen('grep E-fermi %s | cut -d":" -f 2' % inOutcarName)).read().split()[0]
print 'Fermi energy is %.4f(eV)\n' % float(fermiE)
j=1; l=0
xMajorList=[]
xMinor, xMinorXb, xMinorYb, xMinorZb = 0, 0, 0, 0
l = appendXticLabel(l)
while 1:
xMinorXa, xMinorYa, xMinorZa, yValueList, next = obtainy()
dist = distCrd(xMinorXb, xMinorYb, xMinorZb, xMinorXa, xMinorYa, xMinorZa)
if (xMinorXa == xMinorXb and xMinorYa == xMinorYb and xMinorZa == xMinorZb): k=0
else: k=1
xMinorXb, xMinorYb, xMinorZb = xMinorXa, xMinorYa, xMinorZa
if j==1: dist=0
xMinor = xMinor + dist
if not (j>1 and k==0):
outData.write('%9.4f' % xMinor)
else:
l = appendXticLabel(l)
for yValue in yValueList:
yValue = yValue-float(fermiE)
if not (j>1 and k==0): outData.write('%9.4f' % yValue)
if not (j>1 and k==0): outData.write('\n')
if not next: break
j=2
l = appendXticLabel(l)
##########
##### use Gnuplot module #####
xticsStr = ''.join(xMajorList)
if optPersist==1: optPersist='persist'
else: optPersist='nopersist'
outGpInput.write("set term %s %s\n" % (gpTerm, optPersist))
outGpInput.write("set title '%s'\n" % gpTitle)
outGpInput.write("set size %s\n" % gpSize)
if gpKey=='key': outGpInput.write("set key\n")
else: outGpInput.write("unset key\n")
outGpInput.write("set xlabel '%s'\n" % gpXlabel)
if gpXrange=='[*:*]': gpXrange = '[*:'+str(xMinor+0.001*xMinor)+']'
outGpInput.write("set xrange %s\n" % gpXrange)
outGpInput.write("set xtics ( %s )\n" % xticsStr[0:-2])
outGpInput.write("set ylabel '%s'\n" % gpYlabel)
outGpInput.write("set yrange %s\n" % gpYrange)
outGpInput.write("plot '%s' using 1:2 %s\n" % (outDataName, gpPlotMethod))
i=3
while i < nplotLine+2:
outGpInput.write("replot '%s' using 1:%d %s\n" % (outDataName, i, gpPlotMethod))
i = i+1
if gpPicForm == 'pos': outGpInput.write("set term %s %s\n" % (gpPicForm, gpPosDefault))
else: outGpInput.write('set term %s\n' % gpPicForm)
outGpInput.write("set output '%s'\n" % gpPicName)
outGpInput.write("replot '%s' using 1:%d %s\n" % (outDataName, nplotLine+1, gpPlotMethod))
outGpInput.write("set term %s %s\n" % (gpTerm, optPersist))
inEigenval.close()
outData.close()
outGpInput.close()
os.popen('gnuplot gnuinput.in')
##########
回复此楼
» 收录本帖的淘帖专辑推荐
精华网帖收集
» 猜你喜欢
真诚求助:手里的省社科项目结项要求主持人一篇中文核心,有什么渠道能发核心吗
已经有8人回复
寻求一种能扛住强氧化性腐蚀性的容器密封件
已经有5人回复
论文投稿,期刊推荐
已经有6人回复
请问哪里可以有青B申请的本子可以借鉴一下。
已经有4人回复
孩子确诊有中度注意力缺陷
已经有14人回复
请问下大家为什么这个铃木偶联几乎不反应呢
已经有5人回复
请问有评职称,把科研教学业绩算分排序的高校吗
已经有5人回复
2025冷门绝学什么时候出结果
已经有3人回复
天津工业大学郑柳春团队欢迎化学化工、高分子化学或有机合成方向的博士生和硕士生加入
已经有4人回复
康复大学泰山学者周祺惠团队招收博士研究生
已经有6人回复
高级回复
1楼
2015-06-29 19:30:31
已阅
回复此楼
关注TA
给TA发消息
送TA红花
TA的回帖
智能机器人
Robot
(super robot)
我们都爱小木虫
找到一些相关的精华帖子,希望有用哦~
请大家帮一下忙,教教我怎样从P4VASP中导出Band的数据,然后再在Origin里面做出来。
已经有4人回复
VASP计算HOMO,LUMO轨道
已经有28人回复
提取能带数据脚本
已经有11人回复
vasp+dfpt算声子性质用phonopy软件处理数据时得到band图真的不忍直视,它怎么了??
已经有17人回复
推荐几个vasp处理计算结果的python脚本
已经有66人回复
P4VASP做pdos交流,及后续origin计算d-band center
已经有34人回复
VASP算同一物质超晶胞Band与原胞的差别很大
已经有12人回复
VASP计算Band作图的问题
已经有6人回复
Python版处理EIGENVAL以得到能带结构的程序
已经有70人回复
【求助】请问如何用P4VASP在LINUX系统下画能带图,或者导出数据
已经有5人回复
vasp5.2如何计算DOS和band structure?
已经有10人回复
vasp计算中的费米能问题
已经有20人回复
如何用vasp的计算结果画出 fat band
已经有4人回复
VASP计算输出文件里面哪里可以看到band gap啊?
已经有4人回复
vasp计算石墨烯能带时,dirac点是打开的,带隙不为零,与静态的DOSCAR也对不上
已经有10人回复
求处理vasp能带的小程序
已经有14人回复
【其他】vasp_band.exe处理的数据怎么最后不一样啊?
已经有15人回复
【求助】vasp计算Partial Charge,能带交叉的如何确定IBAND?
已经有13人回复
【求助】VASP计算的KPOINTS 设置,求助
已经有10人回复
【原创】处理elk能带的程序
已经有16人回复
【求助】vasp结果的图形化处理
已经有6人回复
【求助】请教vasp如何使本征值按每条能带输出
已经有18人回复
【转帖】强烈推荐使用phonopy计算声子谱
已经有44人回复
点击这里搜索更多相关资源
科研从小木虫开始,人人为我,我为人人
相关版块跳转
第一性原理
量子化学
计算模拟
分子模拟
仿真模拟
程序语言
我要订阅楼主
hakuna
的主题更新
1
1/1
返回列表
如果回帖内容含有宣传信息,请如实选中。否则帐号将被全论坛禁言
普通表情
龙
兔
虎
猫
高级回复
(可上传附件)
百度网盘
|
360云盘
|
千易网盘
|
华为网盘
在新窗口页面中打开自己喜欢的网盘网站,将文件上传后,然后将下载链接复制到帖子内容中就可以了。
信息提示
关闭
请填处理意见
关闭
确定