diff --git a/README.md b/README.md index a54ce2d5..f690e464 100644 --- a/README.md +++ b/README.md @@ -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
diff --git a/changelog.txt b/changelog.txt index c62e8cec..f5a31bc4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/pyprocar/__init__.py b/pyprocar/__init__.py index 1e5b0d7c..c5b5b413 100644 --- a/pyprocar/__init__.py +++ b/pyprocar/__init__.py @@ -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__ = "fvmunoz@gmail.com/alromero@mail.wvu.edu/ukh0001@mix.wvu.edu/petavazohi@mix.wvu.edu" __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 # diff --git a/pyprocar/scriptBandsplot.py b/pyprocar/scriptBandsplot.py index edfe1b37..7ab5a3fa 100644 --- a/pyprocar/scriptBandsplot.py +++ b/pyprocar/scriptBandsplot.py @@ -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 @@ -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) ########################## @@ -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) diff --git a/pyprocar/scriptCompareBands.py b/pyprocar/scriptCompareBands.py index 46a2bcfd..06d4d166 100755 --- a/pyprocar/scriptCompareBands.py +++ b/pyprocar/scriptCompareBands.py @@ -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 @@ -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) ########################## @@ -106,8 +109,9 @@ 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) @@ -115,7 +119,40 @@ def bandscompare(file,file2,mode='plain',abinit_output=None,abinit_output2=None, 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: diff --git a/setup.py b/setup.py index 02cd23c3..30e8d420 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ author='Francisco Munoz,Aldo Romero,Sobhit Singh,Uthpala Herath,Pedram Tavadze,Eric Bousquet,Xu He', author_email='fvmunoz@gmail.com,alromero@mail.wvu.edu,smsingh@mix.wvu.edu,ukh0001@mix.wvu.edu,petavazohi@mix.wvu.edu,eric.bousquet@uliege.be,mailhexu@gmail.com', 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',