PyTASER DFT Example#

In the following examples, we use the outputs from a DFT calculation, using VASP, to generate the predicted absorption spectra under various conditions. Specifically, this requires the calculation of the orbital derivatives between electronic bands, which can be achieved using the LOPTICS INCAR tag in VASP (see (https://www.vasp.at/wiki/index.php/LOPTICS).

Note: In order for VASP to output the necessary information for PyTASER to compute the full absorption spectrum under various excitation conditions, the following tags must be set in the INCAR file:

LOPTICS = True  # calculate the frequency dependent dielectric matrix
LVEL = True  # output the full interband orbital derivative information to the WAVEDER
ISYM = 0  # turn off symmetry, currently required for parsing the WAVEDER with pymatgen

We note that alternatively, if only a single-point electronic structure calculation has been performed with VASP (i.e. with no WAVEDER output), we can still plot the JDOS of the material in the dark, under illumination, and the difference between them, as shown later.

Parse DFT Outputs#

[4]:
from pytaser.generator import TASGenerator
[5]:
tg = TASGenerator.from_vasp_outputs("CdTe/k666_Optics/vasprun.xml", "CdTe/k666_Optics/WAVEDER")
[6]:
tas = tg.generate_tas(energy_min=0, energy_max=7, temp=300, conc=1e22, cshift=1e-3)
# Note that we set cshift to a small value here to avoid too much broadening of the spectrum
# If not set, this defaults to the value of `CSHIFT` used in the underlying VASP calculation (see docstrings for more info)
Calculating oscillator strengths (spin up, dark): 20736it [00:07, 2831.83it/s]
Calculating oscillator strengths (spin up, under illumination): 20736it [00:07, 2813.94it/s]

Save Parsed Outputs to File#

Parsing the orbital derivative data in the WAVEDER file can sometimes take a little time to run, depending on the kpoint density. To save time when (re-)running our analysis, we can save the generated TAS object to a json file like this:

[7]:
from monty.serialization import dumpfn
dumpfn(tas, "cdte_tas.json")

When we want to redo some of this analysis, in this notebook or a new one, we can now load the TAS object from the json file without having to re-parse the WAVEDER data, like this:

[8]:
from monty.serialization import loadfn
tas = loadfn("cdte_tas.json")

Plotting#

Let’s plot the predicted TAS spectrum for this material, under the conditions we specified above:

[12]:
from pytaser.plotter import TASPlotter

plot_dft = TASPlotter(tas, material_name="CdTe")
energy_plot = plot_dft.get_plot(
    xaxis="energy", transition_cutoff=0.01, xmin=0, xmax=5, yaxis="tas")
# Reverse axis for better comparison to experiment
energy_plot.gca().invert_xaxis()
_images/dft_examples_13_0.png

In this example case, our kpoints are not fully converged to give a smooth spectrum, and so ideally for comparing to experiment we would want a denser kpoint mesh!

We can also plot the predicted TAS as a function of wavelength, by setting xaxis="wavelength":

[16]:
from pytaser.plotter import TASPlotter

plot_dft = TASPlotter(tas, material_name="CdTe")
energy_plot = plot_dft.get_plot(
    xaxis="wavelength", transition_cutoff=0.01, xmin=300, yaxis="tas")
_images/dft_examples_16_0.png

Plotting the Effective Absorption#

We can also plot the predicted effective absorption in the dark and under illumination, by setting yaxis="alpha":

[19]:
from pytaser.plotter import TASPlotter

plot_dft = TASPlotter(tas, material_name="CdTe")
energy_plot = plot_dft.get_plot(
    xaxis="energy", transition_cutoff=0.01, yaxis="alpha")
_images/dft_examples_19_0.png

We can see that under these conditions, we expect stimulated emission to occur at our bandgap energy (around 0.7 eV here), as we have population inversion at our VBM/CBM, with ɑ (light) being negative at this energy

Plotting the Joint Density of States (JDOS)#

Some other plotting options include the ability to plot the JDOS (in the dark and under illumination) with yaxis="jdos", or the difference in JDOS between the dark and illuminated state with yaxis="jdos_diff":

Note: Additional keyword arguments provided to get_plot() are passed to plt.legend(), so you can use this to customise the plot legend as shown below (see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html)

[25]:
from pytaser.plotter import TASPlotter

plot_dft = TASPlotter(tas, material_name="CdTe")
energy_plot = plot_dft.get_plot(
    xaxis="energy", transition_cutoff=0.01, yaxis="jdos", ncols=2, fontsize=18, frameon=False)
_images/dft_examples_23_0.png
[29]:
from pytaser.plotter import TASPlotter

plot_dft = TASPlotter(tas, material_name="CdTe")
energy_plot = plot_dft.get_plot(
    xaxis="energy", transition_cutoff=0.01, yaxis="jdos_diff", reverse=True, fancybox=False, shadow=True)
_images/dft_examples_24_0.png

Parse DFT Outputs (JDOS Only)#

As mentioned above, if we’ve only performed a single-point electronic structure calculation with VASP, we can still plot the JDOS of the material in the dark, under illumination, and the difference between them, as shown below.

[30]:
from pytaser.generator import TASGenerator
[31]:
tg = TASGenerator.from_vasp_outputs("CdTe/k666_Optics/vasprun.xml")  # No WAVEDER file this time
[32]:
tas = tg.generate_tas(energy_min=0, energy_max=7, temp=300, conc=1e22)

In this case if we set yaxis = "tas", it will use the difference in JDOS between the dark and illuminated state to generate an estimated TAS spectrum:

[33]:
from pytaser.plotter import TASPlotter

plot_dft = TASPlotter(tas, material_name="CdTe")
energy_plot = plot_dft.get_plot(
    xaxis="energy", transition_cutoff=0.01, xmin=0, xmax=5, yaxis="tas")
# Reverse axis for better comparison to experiment
energy_plot.gca().invert_xaxis()
_images/dft_examples_31_0.png

Similarly, we can directly plot the JDOS in the dark and under illumination with yaxis="jdos":

[34]:
from pytaser.plotter import TASPlotter

plot_dft = TASPlotter(tas, material_name="CdTe")
energy_plot = plot_dft.get_plot(
    xaxis="energy", transition_cutoff=0.01, yaxis="jdos", ncols=2, fontsize=18, frameon=False)
_images/dft_examples_33_0.png