Another pDOS Plotter

tl;dr: This python script generates many subplots based on a directories file. Download it here: DOS.Layered.zip

Hello All,

If you come here often for tutorials you may have seen some brief write ups on how to use dos.x and projwfc.x to generate pDOS data (here) or my python script to automatically generate a pDOS plot (here). Well recently I have been generating a bunch of data that needs to be compared side by side and I wanted a way to easily compare these datasets to eachother. So I fired up the old python engine and wanted to share with you a nifty little plotting tool I made for plotting several pDOS plots at once.

The basic idea of the script is as follows:

  • Dynamically create subplots
  • Automatically fill in the graph below the Fermi Level
  • Automatically generate relevant labels
  • Be coded in a modular way that can be expanded

Keeping this all in mind, I more or less too my old plotting code and made it more modular. I also made it exploit numpy arrays to make the filling in a bit easier. The basic operation of this script is as follows:

  1. Searches for a file called ‘directories’
    •   This contains the directory and label information
    •   If this is not present, it will just use the current directory and assume no label
  2. It will attempt to determine the fermi level of all diretories
    •   If it does not find it, it will ask
  3. It will then plot all the *wfc* files in the subdirectories
  4. Finally it will apply all relevant labels to the graph and ask the user for a title to the graph
    •   It will also note the current working directory for posterity reasons

The files ‘directories’ is what guides this whole process. This is simply a tab-delimited file that has the following in each line: FolderName SubPlotTitle. As an example, here is the one I used to generate the plots in this graph:

N.5 -0.5e
Neutral 0.0e
P.5 +0.5e

In this case I have three subfolders: N.5, Neutral, P.5 and want them to be titled, respectively, -0.5e, 0.0e, +0.5e. In order to run this file (mainly to make the plots nice and colorful), you need a file called color.key which simply colors the bars by the color scheme that jmol uses. You can download color.key here: color.key. You can specify this in the header of your DOS script.

The rest of the script is commented. So feel free to modify it and use it to your hearts content. By just changing the directories file, I was able to generate the following plots with one keystroke:

1 Subplot

2 Subplots

3 Subplots

The whole script is below, but you can download it here: DOS.Layered.py

A zip of the main files can be found here:

Happy computing,

Levi

2 comments Add yours

Leave a Reply

Your email address will not be published. Required fields are marked *