Hi!
I used the following to get and plot the band structure of the material mp-92.
from pymatgen.electronic_structure.plotter import BSPlotter
def plot_bandstructure(bs):
BSPlotter(bs).get_plot().show()
with MPRester(api_key) as mpr:
bs = mpr.get_bandstructure_by_material_id("mp-92")
plot_bandstructure(bs)
I need help to do the following:
- Print High Symmetry Kpoints with their labels.
- Export band structures as a text file.
Thanks in advance.
Edit:
I tried as following:
api_key = "#########"
output_file = "band_structure.txt"
with MPRester(api_key) as mpr:
bs = mpr.get_bandstructure_by_material_id("mp-92")
bands = bs.bands
kpoints = bs.kpoints
labels_dict = bs.labels_dict
spin_component = Spin.up
with open(output_file, 'w') as file:
file.write("# kx ky kz label E1 E2 E3 ... (energies for each band)\n")
for i, (kpoint, label) in enumerate(zip(kpoints, labels_dict)):
file.write(f"{kpoint.frac_coords[0]:.6f} {kpoint.frac_coords[1]:.6f} {kpoint.frac_coords[2]:.6f} {label} ")
file.write(" ".join(f"{energy:.6f}" for energy in bands[spin_component][i])) # Specify the spin component
file.write("\n")
But the results are not logic for me. Here is a part of the produced file:
# kx ky kz label E1 E2 E3 ... (energies for each band)
0.000000 0.000000 0.000000 \Gamma -4.608600 -4.608300 -4.607200 -4.605400 -4.602900 .......
0.000000 0.000000 0.005376 X 6.591500 6.571000 6.518100 6.446800 6.365600 6.278700 ........
0.000000 0.000000 0.010753 M 6.591500 6.591900 6.592800 6.594500 6.596800 6.599700 ........
0.000000 0.000000 0.016129 Z 6.984000 7.003100 7.051600 7.115500 7.186500 7.260200 ........
0.000000 0.000000 0.021505 P 10.681400 10.683800 10.691000 10.702900 10.719600 10.7 ........
0.000000 0.000000 0.026882 N 16.626300 16.618900 16.597400 16.562800 16.517000 16.4 ........
0.000000 0.000000 0.032258 Z_1 17.894500 17.891500 17.882700 17.868200 17.848200 17 ........
K points don’t make sense in addition to there are different numbers of bands at each k point.