shnitsel.analyze.spectra¶
Functions¶
|
Internal function to actually calculate the oscillator frequency for energies and transition dipoles. |
|
Function to obtain a dataarray containing the oscillator strength as a dataarray. |
|
Function to calculate oscillator strength fosc and create a new dataset with this variable assigned. |
|
Applies a gaussian smoothing kernel to the fosc data. |
|
Function to Get the broadened spectrum of the interstate energy and oscillator strength data to plot |
|
Function to calculate a gaussian-smoothed spectrum of an interstate dataset |
|
Function to calculate spectra |
|
Group spectra results into spectra involving the ground state or only excited states. |
|
Function to split Spectra into two groups. |
|
Function to calculate the spectra at all times. |
Module Contents¶
- _get_fosc(energy_interstate, dip_trans_norm)¶
Internal function to actually calculate the oscillator frequency for energies and transition dipoles.
- Parameters:
energy_interstate (DataArray) – The Array of Energies in the system.
dip_trans_norm (DataArray) – The array of associated norm of transition dipoles in the system.
- Returns:
The resulting oscillation frequency (f_osc) array.
- Return type:
DataArray
Notes
We use the following unitless form of f_osc: $$f_{osc} = frac{2}{3} frac{m_e}{hbar^2} cdot Delta E cdot frac{mu^2}{e^2}$$
- get_fosc(energy_per_or_interstate, dip_trans_norm)¶
Function to obtain a dataarray containing the oscillator strength as a dataarray.
- Parameters:
energy_interstate (DataArray) – The array of per- or inter-state energies in the system. If provided as a per-state energy, inter-state barriers will automatically be calculated.
dip_trans_norm (DataArray) – The array of associated transition dipoles in the system with their norm calculated across the direction dimension.
energy_per_or_interstate (xarray.DataArray)
- Returns:
The resulting datarray of oscillator strength f_osc
- Return type:
DataArray
- assign_fosc(ds)¶
Function to calculate oscillator strength fosc and create a new dataset with this variable assigned.
- Parameters:
ds (xr.Dataset) – Dataset from which to calculate fosc
- Returns:
Dataset with the member variable fosc set
- Return type:
xr.Dataset
- broaden_gauss(delta_E, fosc, agg_dim='frame', *, width_in_eV=0.5, nsamples=1000, xmin=0, xmax=None)¶
Applies a gaussian smoothing kernel to the fosc data.
Aggregation is performed along the agg_dim dimension.
- Parameters:
delta_E (xarray.DataArray) – values used for the x-axis, presumably $E_i$
fosc (xarray.DataArray) – values used for the y-axis, presumably $f_mathrm{osc}$
agg_dim (shnitsel.core.typedefs.DimName) – dimension along which to aggregate the many Gaussian distributions, by default ‘frame’
optional – dimension along which to aggregate the many Gaussian distributions, by default ‘frame’
width_in_eV (float) – the width of the Gaussian distributions used, by default 0.5 eV
optional – the width of the Gaussian distributions used, by default 0.5 eV
nsamples (int) – number of evenly spaced x-values over which to sample the distribution, by default 1000
optional – number of evenly spaced x-values over which to sample the distribution, by default 1000
xmax (float | None) – the maximum x-value, by default 3 standard deviations beyond the pre-broadened maximum
optional – the maximum x-value, by default 3 standard deviations beyond the pre-broadened maximum
xmin (float)
- Return type:
- ds_broaden_gauss(interstate, width_in_eV=0.5, nsamples=1000, xmax=None)¶
Function to Get the broadened spectrum of the interstate energy and oscillator strength data to plot a nice and smooth spectrum.
Width of the smoothing kernel is given in eV and the energy is assumed to be in eV or will be converted to eV.
- Parameters:
interstate (InterState) – Interstate dataset with energy_interstate and fosc information.
width_in_eV (float, optional) – Width of the gaussian smoothing kernel in eV. Defaults to 0.5 eV.
nsamples (int, optional) – Number of samples/steps in the range of the energy spectrum. Defaults to 1000.
xmax (float | None, optional) – Maximum of the energy range to consider for the spectrum. Defaults to None.
- Returns:
Resulting broadened spectrum statistics.
- Return type:
xr.DataArray
- get_spectrum(data, t, sc, rel_cutoff=0.01)¶
Function to calculate a gaussian-smoothed spectrum of an interstate dataset
- Parameters:
data (InterState) – An InterState dataset with fosc and energy data
t (float) – The time at which to evaluate the spectrum
sc (tuple[int, int]) – State combination identifier. Possibly an index or a tuple (from, to) of states.
rel_cutoff (float, optional) – Relative cutoff threshold. Values below the max of the resulting spectrum times this scale will be ignored. Defaults to 0.01.
- Returns:
- The Gauss-broadened spectrum of the provided data system.
If broadening across trajectories could not be performed, just returns the fosc array.
- Return type:
xr.DataArray
- calc_spectra(interstate, times=None, rel_cutoff=0.01)¶
Function to calculate spectra
- Parameters:
interstate (InterState) – An InterState transformed Dataset.
times (Iterable[float]|None, optional) – The times at which the spectrum should be calculated. Defaults to None. If None, will be initialized as [0,10,20,30]
rel_cutoff (float, optional) – Factor for the cutoff of broadened/smoothened spectrum relative to maximum. Defaults to 0.01.
- Returns:
Returns a dict of DataArrays indexed by (time, statecomb) tuples.
- Return type:
SpectraDictType
- get_spectra_groups(spectra)¶
Group spectra results into spectra involving the ground state or only excited states.
- Parameters:
spectra (SpectraDictType) – The Spectral calculation results, e.g. from calc_spectra(). Indexed by (timestep, state_combination) and yielding the associated spectrum.
- Returns:
First the spectra involving the ground state SpectraDictType: Second the spectra involving only excited states.
- Return type:
SpectraDictType
- sep_ground_excited_spectra(spectra, excited_transitions=None)¶
Function to split Spectra into two groups.
Can specify which state combinations should be grouped into excited transitions. If not provided a excited_transitions set, will assume all transitions not involving the ground state to be ‘excited’.
- Parameters:
- Returns:
First the spectra not involving excited state transitions SpectraDictType: Second the spectra involving only excited state transitions
- Return type:
SpectraDictType
- spectra_all_times(inter_state)¶
Function to calculate the spectra at all times.
Does not return a dict with only the relevant (t,sc) combinations as above but instead a full xr.DataArray with a time dimension that has spectrum data for all times within the dataset averaged across trajectories.
- Parameters:
inter_state (xr.Dataset) – The InterState transformed Dataset.
- Raises:
ValueError – If required variables or dimensions are missing
- Returns:
The resulting spectra across all times.
- Return type:
xr.DataArray