1. python脚本

读取EIGEVNVAL画能带


# -*- coding: UTF-8 -*-


import numpy as np
from pythtb import *
import pylab as pl

def readEIGENVAL():

    enFermi = -4.9487             #转化为浮点数


    eigfile = 'EIGENVAL'
    fIn = open(eigfile, 'r')
    lines = fIn.readlines()

    tmp = lines[5].rstrip().split()

    nKpts = int(tmp[1])
    nBnds = int(tmp[2])

    # print tmp
    # print 'No. of k-points', nKpts
    # print 'No. of bands', nBnds
    # print '------------------------'

    kpts = np.zeros((nKpts, 3), dtype=np.float)      #nkpts行,3列
    ens = np.zeros((nBnds, nKpts), dtype=np.float)

    for iKpt in range(nKpts):
        tmp = lines[7 + iKpt * (2 + nBnds)].rstrip().split()
        kpts[iKpt, 0] = float(tmp[0])
        kpts[iKpt, 1] = float(tmp[1])
        kpts[iKpt, 2] = float(tmp[2])
        print iKpt, kpts[iKpt,:]                    #得到的是k点坐标

        for iBnd in range(nBnds):
            tmp = lines[8 + iKpt * (2 + nBnds) + iBnd].rstrip().split()
            ens[iBnd, iKpt] = float(tmp[1]) - enFermi         #1为自旋向上,2为向下
            # print iKpt,iBnd,ens[iBnd, iKpt]

    kpts = np.array(kpts)           #把所有的k点放到一个列表里面
    # print kpts
    return nKpts, nBnds, kpts, ens, enFermi

nKpts, nBnds, kpts, ens, enFermi = readEIGENVAL()

print nKpts, nBnds

pl.figure(figsize=(16.0, 12.4))
pl.subplots_adjust(wspace=0.35)
pl.ylim(-10,10)
pl.xlim(0,nKpts)     #x轴坐标,即k点范围
pl.grid(True)

for i in range(nBnds):
    print i
    pl.plot(ens[i], 'g-', ms=5, mew=1)
# pl.plot(ens[8], 'g-', ms=5, mew=1)
# pl.plot(ens[9], 'g-', ms=5, mew=1)


pl.title(r'$\Gamma$')
pl.ylabel("Energy")
pl.show()
Comments to: 读取EIGEVNVAL画能带

您的邮箱地址不会被公开。 必填项已用 * 标注