pytaser package#
pytaser.generator module#
- class pytaser.generator.TASGenerator(bs, kpoint_weights, dos, dfc=None)[source]#
Bases:
object
Class to generate a TAS spectrum (decomposed and cumulative) from a bandstructure and dos object.
- Parameters
bs – Pymatgen-based bandstructure object
kpoint_weights – kpoint weights either found by the function or inputted.
dos – Pymatgen-based dos object
dfc – Pymatgen-based DielectricFunctionCalculator object (for computing oscillator strengths)
- bs#
Pymatgen bandstructure object
- kpoint_weights#
k-point weights (degeneracies).
- dos#
Pymatgen-based dos object
- dfc#
Pymatgen-based DielectricFunctionCalculator object (for computing oscillator strengths)
- bg_centre#
Energy (eV) of the bandgap centre.
- vb#
Spin dict detailing the valence band maxima.
- cb#
Spin dict detailing the conduction band minima
- band_occupancies(temp, conc, dark=True)[source]#
Gives band occupancies.
- Parameters
temp – Temperature of material we wish to investigate (affects the FD distribution)
conc – Carrier concentration of holes and electrons (both are the same). Inversely proportional to pump-probe time delay.
dark – Bool; dark = True indicates pump is on.
- Returns
occs} for all bands across all k-points.
- Return type
A dictionary of {Spin
- classmethod from_mpid(mpid, bg=None, api_key=None, mpr=None)[source]#
Import the desired bandstructure and dos objects from the legacy Materials Project database.
- Parameters
mpid – The Materials Project ID of the desired material.
bg – The experimental bandgap (eV) of the material. If None, the band gap of the MP calculation will be used.
api_key – The user’s Materials Project API key.
mpr – An MPRester object if already generated by user.
- Returns
A TASGenerator object.
- classmethod from_vasp_outputs(vasprun_file, waveder_file=None, bg=None)[source]#
Create a TASGenerator object from VASP output files.
- Parameters
vasprun_file – Path to vasprun.xml file (to generate bandstructure object).
waveder_file – Path to WAVEDER file (to generate dielectric function calculator object,
moments) (to compute orbital derivatives and transition dipole) –
bg – Experimental bandgap of the material, used to rigidly shift the DFT results to match
None (this value. If) –
- Returns
A TASGenerator object.
- generate_tas(temp, conc, energy_min=0, energy_max=5, gaussian_width=0.1, cshift=None, step=0.01, light_occs=None, dark_occs=None, processes=None)[source]#
Generates TAS spectra based on inputted occupancies, and a specified energy mesh. If the TASGenerator has not been generated from VASP outputs (and thus does not have a dfc attribute), then the output TAS is generated using the change in joint density of states (JDOS) under illumination, with no consideration of oscillator strengths. Otherwise, the output TAS is generated considering all contributions to the predicted TAS spectrum.
- Parameters
temp – Temperature (K) of material we wish to investigate (affects the FD distribution)
conc – Carrier concentration (cm^-3) of holes and electrons (both are equivalent). Inversely proportional to pump-probe time delay.
energy_min – Minimum band transition energy to consider for energy mesh (eV)
energy_max – Maximum band transition energy to consider for energy mesh (eV)
gaussian_width – Width of gaussian curve
cshift – Complex shift in the Kramers-Kronig transformation of the dielectric function (see https://www.vasp.at/wiki/index.php/CSHIFT). If not set, uses the value of CSHIFT from the underlying VASP WAVEDER calculation. (only relevant if the TASGenerator has been generated from VASP outputs)
step – Interval between energy points in the energy mesh.
light_occs – Optional input parameter for occupancies of material under light, otherwise automatically calculated based on input temperature (temp) and carrier concentration (conc) [dict]
dark_occs – Optional input parameter for occupancies of material in dark, otherwise automatically calculated based on input temperature (temp) and carrier concentration (conc) [dict]
processes – Number of processes to use for multiprocessing. If not set, defaults to one less than the number of CPUs available.
- Returns
- TAS class containing the following inputs;
- tas_total: overall deltaT TAS spectrum for a material under the
specified conditions.
- jdos_diff_if: JDOS difference (from dark to light) across the energy mesh for a
specific band transition i (initial) -> f (final) [dict]
- jdos_light_total: overall JDOS (pump-on) for a material under the
specified conditions
- jdos_light_if: JDOS (pump-on) across the energy mesh for a specific band
transition i (initial) -> f (final) [dict]
- jdos_dark_total: overall JDOS (pump-off) for a material under the
specified conditions
- jdos_dark_if: JDOS (pump-off) across the energy mesh for a specific band
transition i (initial) -> f (final) [dict]
energy_mesh_ev: Energy mesh of spectra in eV, with an interval of ‘step’.
bandgap: Bandgap of the system, in eV, rounded to 2 decimal points
temp: Temperature of the system, in K
conc: Carrier concentration of the system, in cm^-3
- alpha_dark: Absorption coefficient of the material in the dark, in cm^-1 (only
calculated if the TASGenerator has been generated from VASP outputs)
- alpha_light_dict: Dictionary of band-to-band absorption, stimulated emission
and summed contributions to the total overall absorption coefficient under illumination, in cm^-1 (only calculated if the TASGenerator has been generated from VASP outputs)
- weighted_jdos_diff_if: JDOS difference (from dark to light) across the energy
mesh for a specific band transition i (initial) -> f (final), weighted by the oscillator strength of the transition [dict]
- weighted_jdos_light_if: JDOS (pump-on) across the energy mesh for a specific band
transition i (initial) -> f (final), weighted by the oscillator strength of the transition [dict]
- weighted_jdos_dark_if: JDOS (pump-off) across the energy mesh for a specific band
transition i (initial) -> f (final), weighted by the oscillator strength of the transition [dict]
- pytaser.generator.gaussian(x, width, center=0.0, height=None)[source]#
Returns the values of gaussian(x) where x is array-like.
- Parameters
x – Input array.
width – Width of the gaussian.
center – Center of the gaussian.
height – height of the gaussian. If height is None, a normalized gaussian is returned.
- pytaser.generator.get_cbm_vbm_index(bs)[source]#
- Parameters
bs – bandstructure object
- Returns
Valence and Conduction band as an index number for different spins.
- pytaser.generator.get_nonzero_band_transitions(occs, eigs_shifted, rspin, spin, sigma, nedos, deltae, ismear, min_band, max_band, nk)[source]#
Helper function to filter band transitions before (multi)processing
- pytaser.generator.jdos(bs, f, i, occs, energies, kweights, gaussian_width, spin=Spin.up)[source]#
- Parameters
bs – bandstructure object
f – final band
i – initial band
occs – occupancies over all bands.
energies – energy mesh (eV)
kweights – k-point weights
gaussian_width – width of gaussian plot.
spin – Which spin channel to include.
- Returns
Cumulative JDOS value for a specific i->f transition, with consideration of partial occupancy and spin polarisation.
- pytaser.generator.occ_dependent_alpha(dfc, occs, spin=Spin.up, sigma=None, cshift=None, processes=None, energy_max=6)[source]#
Calculate the expected optical absorption given the groundstate orbital derivatives and eigenvalues (via dfc) and specified band occupancies. Templated from pymatgen.io.vasp.optics.epsilon_imag().
- Parameters
dfc – DielectricFunctionCalculator object
occs – Array of band occupancies with shape (nspin, nbands, nkpoints)
spin – Which spin channel to include.
sigma – Smearing width (in eV) for broadening of the dielectric function (see https://www.vasp.at/wiki/index.php/SIGMA). If not set, uses the value of SIGMA from the underlying VASP WAVEDER calculation.
cshift – Complex shift in the Kramers-Kronig transformation of the dielectric function (see https://www.vasp.at/wiki/index.php/CSHIFT). If not set, uses the value of CSHIFT from the underlying VASP WAVEDER calculation.
processes – Number of processes to use for multiprocessing. If not set, defaults to one less than the number of CPUs available.
energy_max – Maximum band transition energy to consider (in eV). A minimum range of -6 eV to +6 eV is considered regardless of energy_max, to ensure a reasonable dielectric function output.
- Returns
(alpha_dict, tdm_array) where alpha_dict is a dictionary of band-to-band absorption, stimulated emission and summed contributions to the total overall absorption coefficient under illumination in cm^-1, and tdm_array is an array of shape (nbands, nbands, nkpoints) with the transition dipole matrix elements for each band-to-band transition.
- pytaser.generator.set_bandgap(bandstructure, dos, bandgap)[source]#
Shifts all bands of a material to correct the DFT-underestimated bandgap according to the input experimental bandgap.
- Parameters
bandstructure – PMG bandstructure object
dos – PMG dos object
bandgap – experimental bandgap from literature (float)
- Returns
new bandstructure and dos objects for the same material, but with corrected bandgap.
pytaser.kpoints module#
- pytaser.kpoints.get_kpoint_weights(bandstructure, time_reversal=True, symprec=0.1)[source]#
Function to calculate the kpoint_weights for non-magnetic materials (non-metals).
- Parameters
bandstructure – PMG bandstructure object
time_reversal –
symprec – Symmetry precision in Angstrom.(Lower value is more precise, but computationally more expensive)
- Returns
k-point_weights
pytaser.plotter module#
- class pytaser.plotter.TASPlotter(container, material_name=None)[source]#
Bases:
object
Class to generate a matplotlib plot of the TAS or JDOS spectra, with a specific energy mesh, material, and conditions.
- Parameters
container – TAS container class as generated by TASGenerator().generate_tas().
material_name – Name of material being investigated (string) [optional, for labelling]
- get_plot(relevant_transitions='auto', xaxis='wavelength', transition_cutoff=0.03, xmin=None, xmax=None, ymin=None, ymax=None, yaxis='tas', **kwargs)[source]#
Plots TAS spectra using the data generated in the TAS container class as generated by TASGenerator().generate_tas(). If the TASGenerator was not generated from VASP outputs, then the output TAS is generated using the change in joint density of states (JDOS) under illumination, with no consideration of oscillator strengths (“Total TAS (ΔJDOS only)”) – this behaviour can also be explicitly chosen by setting “yaxis” to “jdos_diff”.
Otherwise, the output TAS is generated considering all contributions to the predicted TAS spectrum (“Total TAS (Δɑ)”). If only the contribution from the change in absorption is desired, with stimulated emission neglected, set “yaxis” to “tas_absorption_only”.
One can also plot the JDOS before and after illumination, by setting “yaxis” to “jdos”, or the effective absorption coefficient (α, including absorption and stimulated emission) before and after illumination, by setting “yaxis” to “alpha”.
The individual band-to-band transitions which contribute to the JDOS/TAS are also shown (which can be controlled with the transition_cutoff argument – set to 1 to not show any band-band transitions), and these are weighted by the oscillator strength of the transition when TASGenerator was created from VASP objects and yaxis=”tas”, “tas_absorption_only” or “alpha”.
- Parameters
relevant_transitions – List containing individual transitions to be displayed in the plot alongside the total plot. If material is not spin-polarised, only write the bands involved [(-1,6),(2,7),(-8,-5)…] If spin-polarised, include the type of spin involved in transition [(-1,6, “down”),(2,7, “down”),(-8,-5, “up”)…] Default is ‘auto’ mode, which shows all band transitions above the transition_cutoff. Note that band-band transitions with overlapping extrema are scaled by 95% to avoid overlapping lines.
xaxis – Units for the energy mesh. Either “wavelength” or “energy”.
transition_cutoff – The minimum height of the band transition as a percentage threshold of the largest contributing transition (Across all kpoints, within the energy range specified). Default is 0.03 (3%).
xmin – Minimum energy point in mesh (float64)
xmax – Maximum energy point in mesh (float64)
ymin – Minimum absorption point. Default is 1.15 * minimum point.
ymax – Maximum absorption point. Default is 1.15 * maximum point.
yaxis –
What spectral data to plot. If yaxis = “tas” (default), will plot the predicted TAS spectrum considering all contributions to the TAS (if TASGenerator was created from VASP outputs)(“Total TAS (Δɑ)”), or just using the change in the joint density of states (JDOS) before & after illumination (“Total TAS (ΔJDOS only)”) – the latter can also be explicitly selected with yaxis = “jdos_diff”.
If yaxis = “tas_absorption_only”, will instead plot the predicted TAS spectrum considering only the change in absorption, with stimulated emission neglected. If yaxis = “jdos”, will plot the joint density of states before & after illumination. If yaxis = “alpha”, will plot the effective absorption coefficient (α, including absorption and stimulated emission) before and after illumination.
**kwargs – Additional arguments to be passed to matplotlib.pyplot.legend(); such as ncols (number of columns in the legend), loc (location of the legend), fontsize etc. (see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot .legend.html)
- Returns
Matplotlib pyplot of the desired spectrum, with labelled units.
pytaser.tas module#
- class pytaser.tas.Tas(tas_total, jdos_diff_if, jdos_light_total, jdos_light_if, jdos_dark_total, jdos_dark_if, energy_mesh_ev, bandgap, temp, conc, alpha_dark=None, alpha_light_dict=None, weighted_jdos_light_if=None, weighted_jdos_dark_if=None, weighted_jdos_diff_if=None)[source]#
Bases:
object
A container class for the data from TASgenerator.
- Parameters
tas_total – overall TAS spectrum for a material under the specified conditions
jdos_diff_if – JDOS difference (from dark to light) across the energy mesh for a specific band transition i (initial) -> f (final) [dict]
jdos_light_total – overall JDOS (pump-on) for a material under the specified conditions
jdos_light_if – JDOS (pump-on) across the energy mesh for a specific band transition i (initial) -> f (final) [dict]
jdos_dark_total – overall JDOS (pump-off) for a material under the specified conditions
jdos_dark_if – JDOS (pump-off) across the energy mesh for a specific band transition i (initial) -> f (final) [dict]
energy_mesh_ev – Energy mesh of spectra in eV, with an interval of ‘step’.
bandgap – Bandgap of the system in electronvolts (eV).
temp – Temperature (K) of material we wish to investigate (affects the FD distribution)
conc – Carrier concentration (cm^-3) of holes and electrons (both are equivalent). Inversely proportional to pump-probe time delay.
alpha_dark – Absorption coefficient of the material in the dark, in cm^-1.
alpha_light_dict – Dictionary of band-to-band absorption, stimulated emission and summed contributions to the total overall absorption coefficient under illumination, in cm^-1.
weighted_jdos_light_if – JDOS weighted by the transition dipole matrix (TDM) (pump-on) across the energy mesh for a specific band transition i (initial) -> f (final) [dict]
weighted_jdos_dark_if – JDOS weighted by the transition dipole matrix (TDM) (pump-off) across the energy mesh for a specific band transition i (initial) -> f (final) [dict]
weighted_jdos_diff_if – Difference in JDOS weighted by the transition dipole matrix (TDM) from dark to illumination across the energy mesh for a specific band transition i (initial) -> f (final) [dict]