5
$\begingroup$

I used PBE0 in my calculations using Quantum ESPRESSO . I have ran a scf calculation then I used Boltztrap by running the command btp2 -vv interpolate -m 3 ./ then btp2 -vv integrate interpolation.bt2 300:1001:100 .

I got the graph bellow, that I'm not able to modify. How can I extract the data and plot them using origin, please?

enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

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

$\endgroup$
9
  • 1
    $\begingroup$ I'm a beginner to Boltztrap can you guide me more please? I added the two codes to interface.py. I have ran the two commands but the file "btp2_plotbands.dat" is always empty.As I don't know where to put "btp2_plotbands.dat" I tried to put it in my xml file directory and I tried to put it also in the interface.py directory but it's always empty $\endgroup$
    – Camilla
    Mar 21, 2023 at 9:52
  • $\begingroup$ @Camilla you just run btp2 as usual, but it should now generate the data file; I added an example at the bottom of my post, does that help? $\endgroup$ Mar 21, 2023 at 12:56
  • $\begingroup$ unfortunatly the file is always empty. Can this problem have a relation with the method of Boltztrap installation in my laptop? $\endgroup$
    – Camilla
    Mar 21, 2023 at 13:44
  • $\begingroup$ @Camilla as long as you're running the Boltztrap version you changed, it should be OK. I just realised I forgot to add the file closing to my code snippet - I've just fixed it. I don't think that will be your problem, but it might be worth checking. $\endgroup$ Mar 21, 2023 at 16:18
  • 4
    $\begingroup$ You can probably find the email address on an institutional webpage in this case :) $\endgroup$ Mar 22, 2023 at 17:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .