Skip to content

Commit

Permalink
Automatic high symmetry points from KPOINTS
Browse files Browse the repository at this point in the history
  • Loading branch information
uthpalaherath committed May 22, 2019
1 parent 09618b9 commit cfd400b
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ v3.3 Mar 19, 2019 -- Added band unfolder.

v3.4 May 21, 2019 -- Bug fixes for plotting and added capability to plot meta-GGA

v3.5 May 22, 2019 -- added automatic high symmetry point labeling from KPOINTS file

Dependencies
------------
matplotlib <br />
Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ v3.2 Nov 26, 2018 -- Moved project to romerogroup.
v3.3 Mar 19, 2019 -- Added band unfolder.

v3.4 May 21, 2019 -- Bug fixes for plotting and added capability to plot meta-GGA

v3.5 May 22, 2019 -- added automatic high symmetry point labeling from KPOINTS file
4 changes: 2 additions & 2 deletions pyprocar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
__author__="Francisco Munoz,Aldo Romero,Sobhit Singh,Uthpala Herath,Pedram Tavadze,Eric Bousquet,Xu He"
__copyright__ = "Copyright 2019"
__version__ = "3.4"
__version__ = "3.5"
__email__ = "[email protected]/[email protected]/[email protected]/[email protected]"
__status__ = "Development"
__date__ ="May 21, 2019"
__date__ ="May 22, 2019"

# Copyright (C) 2019 Francisco Munoz,Aldo Romero,Sobhit Singh,Uthpala Herath,Pedram Tavadze,Eric Bousquet,Xu He
#
Expand Down
48 changes: 44 additions & 4 deletions pyprocar/scriptBandsplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@



def bandsplot(file,mode='scatter',color='blue',abinit_output=None,spin='0',atoms=None,orbitals=None,fermi=None,elimit=None,mask=None,markersize=0.02,cmap='jet',vmax=None,vmin=None,grid=True,marker='o',permissive=False,human=False,savefig=None,kticks=None,knames=None,title=None,outcar=None):
def bandsplot(file,mode='scatter',color='blue',abinit_output=None,spin='0',atoms=None,orbitals=None,fermi=None,elimit=None,mask=None,markersize=0.02,cmap='jet',vmax=None,vmin=None,grid=True,marker='o',permissive=False,human=False,savefig=None,kticks=None,knames=None,title=None,outcar=None,kpointsfile=None):
#First handling the options, to get feedback to the user and check
#that the input makes sense.
#It is quite long
Expand Down Expand Up @@ -38,6 +38,9 @@ def bandsplot(file,mode='scatter',color='blue',abinit_output=None,spin='0',atoms
print("The zero of energy is arbitrary\n")
fermi = 0

if kpointsfile is None:
print("No KPOINTS file present. Please set knames and kticks manually.")


###################reading abinit output (added by uthpala) ##########################

Expand Down Expand Up @@ -73,19 +76,56 @@ def bandsplot(file,mode='scatter',color='blue',abinit_output=None,spin='0',atoms
if human is not None:
print("human : ", human)
print("Savefig : ", savefig)
print("kticks : ", kticks)
print("knames : ", knames)
if kpointsfile is None:
print("kticks : ", kticks)
print("knames : ", knames)
print("title : ", title)

print("outcar : ", outcar)

#If ticks and names are given we should use them#

#If KPOINTS file is given:
if kpointsfile is not None:
#Getting the high symmetry point names from KPOINTS file
f = open(kpointsfile)
KPread = f.read()
f.close()

KPmatrix = re.findall('reciprocal[\s\S]*',KPread)
tick_labels = np.array(re.findall('!\s(.*)',KPmatrix[0]))
knames=[]
knames=[tick_labels[0]]

for i in range(len(tick_labels)-1):
if tick_labels[i] !=tick_labels[i+1]:
knames.append(tick_labels[i+1])

knames = [str("$"+latx+"$") for latx in knames]

#getting the number of grid points from the KPOINTS file
f2 = open(kpointsfile)
KPreadlines = f2.readlines()
f2.close()
numgridpoints = int(KPreadlines[1].split()[0])

kticks=[0]
gridpoint=0
for kt in range(len(knames)-1):
gridpoint=gridpoint+numgridpoints
kticks.append(gridpoint-1)
print("knames : ", knames)
print("kticks : ", kticks)


#If ticks and names are given by user manually:
if kticks is not None and knames is not None:
ticks = list(zip(kticks,knames))
elif kticks is not None:
ticks = list(zip(kticks,kticks))
else:
ticks = None



#The spin argument should be a number (index of an array), or
#'st'. In the last case it will be handled separately (later)
Expand Down
45 changes: 41 additions & 4 deletions pyprocar/scriptCompareBands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@



def bandscompare(file,file2,mode='plain',abinit_output=None,abinit_output2=None,spin='0',spin2='0',atoms=None,atoms2=None,orbitals=None,orbitals2=None,fermi=None,fermi2=None,elimit=None,mask=None,markersize=0.02,markersize2=0.02,cmap='jet',vmax=None,vmin=None,vmax2=None,vmin2=None,grid=True,marker=',',marker2=',',permissive=False,human=False,savefig=None,kticks=None,knames=None,title=None,outcar=None,outcar2=None,color='r',color2='g',legend='PROCAR1',legend2='PROCAR2'):
def bandscompare(file,file2,mode='plain',abinit_output=None,abinit_output2=None,spin='0',spin2='0',atoms=None,atoms2=None,orbitals=None,orbitals2=None,fermi=None,fermi2=None,elimit=None,mask=None,markersize=0.02,markersize2=0.02,cmap='jet',vmax=None,vmin=None,vmax2=None,vmin2=None,grid=True,marker=',',marker2=',',permissive=False,human=False,savefig=None,kticks=None,knames=None,title=None,outcar=None,outcar2=None,color='r',color2='g',legend='PROCAR1',legend2='PROCAR2',kpointsfile=None):
#First handling the options, to get feedback to the user and check
#that the input makes sense.
#It is quite long
Expand Down Expand Up @@ -55,6 +55,9 @@ def bandscompare(file,file2,mode='plain',abinit_output=None,abinit_output2=None,
print("The zero of energy is arbitrary\n")
fermi2 = 0

if kpointsfile is None:
print("No KPOINTS file present. Please set knames and kticks manually.")


###################reading abinit output (added by uthpala) ##########################

Expand Down Expand Up @@ -106,16 +109,50 @@ def bandscompare(file,file2,mode='plain',abinit_output=None,abinit_output2=None,
print("human : ", human)
print("Savefig : ", savefig)
print("kticks : ", kticks)
print("knames : ", knames)
print("title : ", title)
if kpointsfile is None:
print("knames : ", knames)
print("title : ", title)

print("outcar #1 : ", outcar)
print("outcar #2 : ", outcar2)

print("legend #1 : ",legend)
print("legend #2 : ",legend2)

#If ticks and names are given we should use them#
#If KPOINTS file is given:
if kpointsfile is not None:
#Getting the high symmetry point names from KPOINTS file
f = open(kpointsfile)
KPread = f.read()
f.close()

KPmatrix = re.findall('reciprocal[\s\S]*',KPread)
tick_labels = np.array(re.findall('!\s(.*)',KPmatrix[0]))
knames=[]
knames=[tick_labels[0]]

for i in range(len(tick_labels)-1):
if tick_labels[i] !=tick_labels[i+1]:
knames.append(tick_labels[i+1])

knames = [str("$"+latx+"$") for latx in knames]

#getting the number of grid points from the KPOINTS file
f2 = open(kpointsfile)
KPreadlines = f2.readlines()
f2.close()
numgridpoints = int(KPreadlines[1].split()[0])

kticks=[0]
gridpoint=0
for kt in range(len(knames)-1):
gridpoint=gridpoint+numgridpoints
kticks.append(gridpoint-1)
print("knames : ", knames)
print("kticks : ", kticks)


#If ticks and names are given by user manually:
if kticks is not None and knames is not None:
ticks = list(zip(kticks,knames))
elif kticks is not None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
author='Francisco Munoz,Aldo Romero,Sobhit Singh,Uthpala Herath,Pedram Tavadze,Eric Bousquet,Xu He',
author_email='[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]',
url='https://github.com/romerogroup/pyprocar',
download_url='https://github.com/romerogroup/pyprocar/archive/3.4.tar.gz',
download_url='https://github.com/romerogroup/pyprocar/archive/3.5.tar.gz',
packages=['pyprocar',
'pyprocar.utilsprocar',
'pyprocar.fermisurface',
Expand Down

0 comments on commit cfd400b

Please sign in to comment.