I don't see a way to do this from the command-line, but as BoltzTraP2 is written in Python, you can add it in. This worked for me:
Edit "interface.py" and go to the "parse_plotbands" routine. First, we open a file to put our data in, I called it "btp2_plotbands.dat" and put it in the variable output_file
, just after it creates the figure plt.figure
. I also put some meta-data in there, so I have a chance of remembering what the data was in the file, and then some headings for the subsequent output:
plt.figure()
ax = plt.gca()
ticks = []
dividers = []
offset = 0.
#####################################################################
# Output to file; blame Phil Hasnip
#####################################################################
output_file=open("btp2_plotbands.dat", "w")
print("# Output data from btp2 plotbands subcommand",file=output_file)
print("#",file=output_file)
print("# ",data.fermi," <-- Fermi energy from DFT (Ha)",file=output_file)
print("#",file=output_file)
print("# Plot abscissa energy kpoint coords ",file=output_file)
print("# kx ky kz",file=output_file)
#####################################################################
A little later on in that routine, you'll see the code which interpolates the bands onto the fine Fourier-style mesh, and puts the eigenvalues into the egrid
variable, before plotting it in the figure; I added file output immediately after this:
# Create the plot
nbands = egrid.shape[0]
for i in range(nbands):
plt.plot(dkp, egrid[i, :], lw=2.)
ticks += dcl.tolist()
dividers += [dcl[0], dcl[-1]]
offset = dkp[-1]
#####################################################################
# Write out the interpolated energy eigenvalues; blame Phil Hasnip
#####################################################################
for j in range(len(dkp)):
print(dkp[j],kp[j][0],kp[j][1],kp[j][2],end=" ",file=output_file)
for i in range(nbands):
print(egrid[i,j],end=" ",file=output_file)
print(" ",file=output_file)
# Now close the file
output_file.close()
#####################################################################
ax.set_xticks(ticks)
ax.set_xticklabels([])
Now when you run btp2
with the "plotbands" subcommand, it should print the interpolated band-structure data to the file "btp2_plotbands.dat", as well as plotting it.
Example
Suppose you have output from your favourite supported electronic structure package in the current directory. First you use BoltzTraP2 to interpolate the eigenvalues from your electronic structure code onto a finer k-point grid, for example:
btp2 -vv interpolate -m 5 .
where "-vv" instructs btp2
to tell you what it's doing, "-m 5" tells it the fineness of the interpolated grid you want, and "." means you want it to look for your electronic structure data in the current directory. The interpolated data will be put in the file "interpolation.bt2" (NB BoltzTraP2 doesn't handle multiple electronic structure calculations in the same directory).
Now you want to take that interpolated data, determine the band-structure for some k-point path in the Brillouin zone, and plot it. For example,
btp2 plotbands interpolation.bt2 ["[0.0, 0.0, 0.0], [0.5, 0.0, 0.0], [0.5, 0.5, 0.0]"]
Here, we're directly asking BoltzTraP2 to plot the bands (the "plotbands" subcommand) using the interpolated data in "interpolation.bt2", which is just generated in the previous step, and to use the k-point path in the list (in fractional reciprocal-space coordinates). Note that the k-points we give in the list are the turning points of the path, BoltzTraP2 will automatically generate a fairly fine sampling along each path segment.
This will generate a plot using matplotlib, as usual, but our changes to the code will mean that it also writes the data to a file called "btp2_plotbands.dat", in the current working directory.
For more information on BoltzTraP2 itself, see the BoltzTraP2 documentation and tutorials, e.g. https://gitlab.com/sousaw/BoltzTraP2/-/wikis/tutorial