@@ -94,24 +94,26 @@ def bandstats(
94
94
bandstructures = []
95
95
for vr_file in filenames :
96
96
vr = BSVasprun (vr_file , parse_projected_eigen = False )
97
- bs = vr .get_band_structure (line_mode = True )
97
+ bs = vr .get_band_structure (line_mode = True , efermi = "smart" )
98
98
bandstructures .append (bs )
99
- bs = get_reconstructed_band_structure (bandstructures , force_kpath_branches = False )
99
+ bs , kpt_mapping = get_reconstructed_band_structure (
100
+ bandstructures , force_kpath_branches = True , return_forced_branch_kpt_map = True
101
+ )
100
102
101
103
if bs .is_metal ():
102
104
logging .error ("ERROR: System is metallic!" )
103
105
sys .exit ()
104
106
105
- _log_band_gap_information (bs )
107
+ _log_band_gap_information (bs , kpt_mapping = kpt_mapping )
106
108
107
109
vbm_data = bs .get_vbm ()
108
110
cbm_data = bs .get_cbm ()
109
111
110
112
logging .info ("\n Valence band maximum:" )
111
- _log_band_edge_information (bs , vbm_data )
113
+ _log_band_edge_information (bs , vbm_data , kpt_mapping = kpt_mapping )
112
114
113
115
logging .info ("\n Conduction band minimum:" )
114
- _log_band_edge_information (bs , cbm_data )
116
+ _log_band_edge_information (bs , cbm_data , kpt_mapping = kpt_mapping )
115
117
116
118
if parabolic :
117
119
logging .info ("\n Using parabolic fitting of the band edges" )
@@ -179,11 +181,14 @@ def bandstats(
179
181
return {"hole_data" : hole_data , "electron_data" : elec_data }
180
182
181
183
182
- def _log_band_gap_information (bs ):
184
+ def _log_band_gap_information (bs , kpt_mapping = None ):
183
185
"""Log data about the direct and indirect band gaps.
184
186
185
187
Args:
186
188
bs (:obj:`~pymatgen.electronic_structure.bandstructure.BandStructureSymmLine`):
189
+ kpt_mapping (:obj:`dict`, optional): A mapping of k-point indicies from the
190
+ band structure with forced branches to the original band structure.
191
+
187
192
"""
188
193
bg_data = bs .get_band_gap ()
189
194
if not bg_data ["direct" ]:
@@ -199,6 +204,7 @@ def _log_band_gap_information(bs):
199
204
direct_kpoint = bs .kpoints [direct_kindex ].frac_coords
200
205
direct_kpoint = kpt_str .format (k = direct_kpoint )
201
206
eq_kpoints = bs .get_equivalent_kpoints (direct_kindex )
207
+ eq_kpoints = _map_kpoints (eq_kpoints , kpt_mapping )
202
208
k_indices = ", " .join (map (str , eq_kpoints ))
203
209
204
210
# add 1 to band indices to be consistent with VASP band numbers.
@@ -215,7 +221,9 @@ def _log_band_gap_information(bs):
215
221
216
222
direct_kindex = direct_data [Spin .up ]["kpoint_index" ]
217
223
direct_kpoint = kpt_str .format (k = bs .kpoints [direct_kindex ].frac_coords )
218
- k_indices = ", " .join (map (str , bs .get_equivalent_kpoints (direct_kindex )))
224
+ eq_kpoints = bs .get_equivalent_kpoints (direct_kindex )
225
+ eq_kpoints = _map_kpoints (eq_kpoints , kpt_mapping )
226
+ k_indices = ", " .join (map (str , eq_kpoints ))
219
227
b_indices = ", " .join (
220
228
[str (i + 1 ) for i in direct_data [Spin .up ]["band_indices" ]]
221
229
)
@@ -225,14 +233,16 @@ def _log_band_gap_information(bs):
225
233
logging .info (f" Band indices: { b_indices } " )
226
234
227
235
228
- def _log_band_edge_information (bs , edge_data ):
236
+ def _log_band_edge_information (bs , edge_data , kpt_mapping = None ):
229
237
"""Log data about the valence band maximum or conduction band minimum.
230
238
231
239
Args:
232
240
bs (:obj:`~pymatgen.electronic_structure.bandstructure.BandStructureSymmLine`):
233
241
The band structure.
234
242
edge_data (dict): The :obj:`dict` from ``bs.get_vbm()`` or
235
243
``bs.get_cbm()``
244
+ kpt_mapping (:obj:`dict`, optional): A mapping of k-point indicies from the
245
+ band structure with forced branches to the original band structure.
236
246
"""
237
247
if bs .is_spin_polarized :
238
248
spins = edge_data ["band_index" ].keys ()
@@ -247,7 +257,9 @@ def _log_band_edge_information(bs, edge_data):
247
257
248
258
kpoint = edge_data ["kpoint" ]
249
259
kpoint_str = kpt_str .format (k = kpoint .frac_coords )
250
- k_indices = ", " .join (map (str , edge_data ["kpoint_index" ]))
260
+ k_indices = ", " .join (
261
+ map (str , _map_kpoints (edge_data ["kpoint_index" ], kpt_mapping ))
262
+ )
251
263
k_degen = bs .get_kpoint_degeneracy (kpoint = kpoint .frac_coords )
252
264
253
265
if kpoint .label :
@@ -311,6 +323,13 @@ def _log_effective_mass_data(data, is_spin_polarized, mass_type="m_e"):
311
323
logging .info (f" { mass_type } : { eff_mass :.3f} | { band_str } | { kpoint_str } " )
312
324
313
325
326
+ def _map_kpoints (kpt_idxs , kpt_mapping ):
327
+ """Map k-point indices to the original band structure."""
328
+ if not kpt_mapping :
329
+ return kpt_idxs
330
+ return sorted (set ([kpt_mapping .get (k , k ) for k in kpt_idxs ]))
331
+
332
+
314
333
def _get_parser ():
315
334
parser = argparse .ArgumentParser (
316
335
description = """
0 commit comments