Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nexus: Allow bandstructure plotting with custom k-path #3293

Merged
merged 4 commits into from
Jul 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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