make VASP bands using EIGENVAL and OUTCAR
Yuan Fang
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
function bandplot(path1,fname1,path2,fname2) //normal bands plot
string path1,fname1,path2,fname2
variable a,i,t,j,k
variable fermilevel=7.0772 //fermilevel
string str,fword,nkpts,nbnds
Open/R a path1 + ":" + fname1
for(i=0;i<5;i++)
FReadLine a, str
endfor
FReadLine a, str
i=0
t=0
do
fword=stringfromlist(i,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==2)
nkpts=fword
endif
if(t==3)
nbnds=fword
endif
endif
i=i+1
while(t<3)
make/d/n=(str2num(nkpts),str2num(nbnds)) w
for(i=0;i<str2num(nkpts);i++)
FReadLine a, str
FReadLine a, str
for(j=0;j<str2num(nbnds);j++)
FReadLine a, str
k=0
t=0
do
fword=stringfromlist(k,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==2)
w[i][j]=str2num(fword)
endif
endif
k=k+1
while(t<2)
endfor
endfor
for(i=0;i<str2num(nbnds);i++)
make/d/n=(str2num(nkpts)) tmp
tmp=w[p][i]-fermilevel
duplicate tmp $"wave"+num2str(i)
killwaves tmp
endfor
killwaves w
close a
Open/R a path2 + ":" + fname2
make/d/n=3 kold,knew
make/d/n=(str2num(nkpts)) kpt
do
FReadLine a, str
if(strlen(str)==0)
break
endif
if(stringmatch(str,"*k-points in units of 2pi/SCALE*")==1)
FReadLine a, str
i=0
t=0
do
fword=stringfromlist(i,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==1)
kold[0]=str2num(fword)
elseif(t==2)
kold[1]=str2num(fword)
elseif(t==3)
kold[2]=str2num(fword)
endif
endif
i=i+1
while(t<3)
kpt[0]=0
for(i=1;i<str2num(nkpts);i++)
FReadLine a, str
k=0
t=0
do
fword=stringfromlist(k,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==1)
knew[0]=str2num(fword)
elseif(t==2)
knew[1]=str2num(fword)
elseif(t==3)
knew[2]=str2num(fword)
endif
endif
k=k+1
while(t<3)
if(mod(i,100)==0)
kpt[i]=kpt[i-1]
else
kpt[i]=kpt[i-1]+sqrt((knew[0]-kold[0])^2+(knew[1]-kold[1])^2+(knew[2]-kold[2])^2)
endif
kold=knew
endfor
endif
while(1)
killwaves kold,knew
close a
for(i=0;i<str2num(nbnds);i++)
if(i==0)
display $"wave"+num2str(i) vs kpt
else
appendtograph $"wave"+num2str(i) vs kpt
endif
endfor
end
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
function bandplot(path1,fname1,path2,fname2) //normal bands plot
string path1,fname1,path2,fname2
variable a,i,t,j,k
variable fermilevel=7.0772 //fermilevel
string str,fword,nkpts,nbnds
Open/R a path1 + ":" + fname1
for(i=0;i<5;i++)
FReadLine a, str
endfor
FReadLine a, str
i=0
t=0
do
fword=stringfromlist(i,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==2)
nkpts=fword
endif
if(t==3)
nbnds=fword
endif
endif
i=i+1
while(t<3)
make/d/n=(str2num(nkpts),str2num(nbnds)) w
for(i=0;i<str2num(nkpts);i++)
FReadLine a, str
FReadLine a, str
for(j=0;j<str2num(nbnds);j++)
FReadLine a, str
k=0
t=0
do
fword=stringfromlist(k,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==2)
w[i][j]=str2num(fword)
endif
endif
k=k+1
while(t<2)
endfor
endfor
for(i=0;i<str2num(nbnds);i++)
make/d/n=(str2num(nkpts)) tmp
tmp=w[p][i]-fermilevel
duplicate tmp $"wave"+num2str(i)
killwaves tmp
endfor
killwaves w
close a
Open/R a path2 + ":" + fname2
make/d/n=3 kold,knew
make/d/n=(str2num(nkpts)) kpt
do
FReadLine a, str
if(strlen(str)==0)
break
endif
if(stringmatch(str,"*k-points in units of 2pi/SCALE*")==1)
FReadLine a, str
i=0
t=0
do
fword=stringfromlist(i,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==1)
kold[0]=str2num(fword)
elseif(t==2)
kold[1]=str2num(fword)
elseif(t==3)
kold[2]=str2num(fword)
endif
endif
i=i+1
while(t<3)
kpt[0]=0
for(i=1;i<str2num(nkpts);i++)
FReadLine a, str
k=0
t=0
do
fword=stringfromlist(k,str," ")
if (stringmatch(fword,"")!=1)
t=t+1
if(t==1)
knew[0]=str2num(fword)
elseif(t==2)
knew[1]=str2num(fword)
elseif(t==3)
knew[2]=str2num(fword)
endif
endif
k=k+1
while(t<3)
if(mod(i,100)==0)
kpt[i]=kpt[i-1]
else
kpt[i]=kpt[i-1]+sqrt((knew[0]-kold[0])^2+(knew[1]-kold[1])^2+(knew[2]-kold[2])^2)
endif
kold=knew
endfor
endif
while(1)
killwaves kold,knew
close a
for(i=0;i<str2num(nbnds);i++)
if(i==0)
display $"wave"+num2str(i) vs kpt
else
appendtograph $"wave"+num2str(i) vs kpt
endif
endfor
end
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
December 22, 2019 at 05:25 am - Permalink