Skip to content

Commit

Permalink
Merge pull request #3293 from mcbennet/nxs_new_band_plotting
Browse files Browse the repository at this point in the history
Nexus: Allow bandstructure plotting with custom k-path
  • Loading branch information
ye-luo authored Jul 17, 2021
2 parents 5eaadb7 + 8ff890b commit c6ddb24
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions nexus/lib/pwscf_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,9 @@ def make_movie(self,filename,filepath=None):
#end def make_movie


def plot_bandstructure(self, filename=None, filepath=None, max_min_e = None, show=False, save=True, show_vbm_cbm=True):
def plot_bandstructure(self, filename=None, filepath=None, max_min_e = None, show=False, save=True, show_vbm_cbm=True,k_labels=None):
if 'bands' in self:
success = True
from structure import get_kpath
if filename==None:
filename = 'band_structure.pdf'
Expand Down Expand Up @@ -877,10 +878,35 @@ def plot_bandstructure(self, filename=None, filepath=None, max_min_e = None, sho
#end if
fig = figure()
ax = gca()
kpath = get_kpath(structure=self.input_structure, check_standard=False)
x = kpath['explicit_path_linearcoords']
labels = kpath['explicit_kpoints_labels']
nbands = self.input.system.nbnd

if k_labels is None:
kpath = get_kpath(structure=self.input_structure, check_standard=False)
x = kpath['explicit_path_linearcoords']
labels = kpath['explicit_kpoints_labels']
else:
labels = k_labels
# Calculate linear coordinates from self.kpoints_cart
x = []
prev_label = ''
ref_kpt = self.kpoints_cart[0]
ref_kpt_norm = np.linalg.norm(self.kpoints_cart[0])
for kpt_idx,kpt in enumerate(self.kpoints_cart):
curr_label = labels[kpt_idx]
if curr_label != '' and prev_label == '':
ref_kpt_norm+=np.linalg.norm(kpt-ref_kpt)
ref_kpt = kpt
elif curr_label != '' and prev_label != '':
ref_kpt = kpt
ref_kpt_norm+=np.linalg.norm(kpt-ref_kpt)
else:
pass
#end if
x.append(ref_kpt_norm+np.linalg.norm(kpt-ref_kpt))
#x.append(kpt_idx)
prev_label = curr_label
#end for
#end if
for nb in range(nbands):
y = []
for bi in self.bands.up:
Expand Down

0 comments on commit c6ddb24

Please sign in to comment.