Calculators#

Requiring full response#

These calculators require the full response from a TDDFT calculation in the form of a BaseResponse object.

class rhodent.calculators.DensityCalculator(gpw_file, response, filter_occ=[], filter_unocc=[], *, times=None, pulses=None, frequencies=None, frequency_broadening=0)[source]#

Calculate densities in the time or frequency domain.

The induced density (i.e. the density minus the ground state density) is to first order given by

\[\delta n(\boldsymbol{r}) = -2 \sum_{ia}^\text{eh} n_{ia}(\boldsymbol{r}) \mathrm{Re}\:\delta\rho_{ia}\]

plus PAW corrections, where \(n_{ia}(\boldsymbol{r})\) is the density of ground state Kohn-Sham pair \(ia\)

\[n_{ia}(\boldsymbol{r}) = \psi^{(0)}_i(\boldsymbol{r}) \psi^{(0)}_a(\boldsymbol{r}).\]

In the time domain, electrons and holes densities can be computed.

\[\begin{split}\begin{align} n^\text{holes}(\boldsymbol{r}) &= \sum_{ii'} n_{ii'}(\boldsymbol{r}) \delta\rho_{ii'} \\ n^\text{electrons}(\boldsymbol{r}) &= \sum_{aa'} n_{aa'}(\boldsymbol{r}) \delta\rho_{aa'}. \end{align}\end{split}\]

Refer to the documentation of HotCarriersCalculator for definitions of \(\delta\rho_{ii'}\) and \(\delta\rho_{aa'}\).

Parameters:
  • gpw_file (str) – File name of GPAW ground state file.

  • response (BaseResponse) – Response object.

  • filter_occ (Sequence[tuple[float, float]]) – Filters for occupied states (holes). Provide a list of tuples (low, high) to compute the density of holes with energies within the interval low-high.

  • filter_unocc (Sequence[tuple[float, float]]) – Filters for unoccupied states (electrons). Provide a list of tuples (low, high) to compute the density of excited electrons with energies within the interval low-high.

  • times (list[float] | ndarray[tuple[int], dtype[float64]] | None) –

    Compute densities in the time domain, for these times (or as close to them as possible). In units of as.

    May not be used together with frequencies or frequency_broadening.

  • pulses (Optional[Collection[Union[Perturbation, Laser, dict, None]]]) –

    Compute densities in the time domain, in response to these pulses. If none, then no pulse convolution is performed.

    May not be used together with frequencies or frequency_broadening.

  • frequencies (list[float] | ndarray[tuple[int], dtype[float64]] | None) –

    Compute densities in the frequency domain, for these frequencies. In units of eV.

    May not be used together with times or pulses.

  • frequency_broadening (float) –

    Compute densities in the frequency domain, with Gaussian broadening of this width. In units of eV.

    May not be used together with times or pulses.

property N_c: ndarray[tuple[Any, ...], dtype[int64]]#

Number of points in each Cartesian direction of the grid.

property calc: gpaw.GPAW#

GPAW calculator instance.

calculate_and_write(out_fname, which='induced', write_extra={})[source]#

Calculate density contributions.

Densities are saved in a numpy archive, ULM file or cube file depending on whether the file extension is .npz, .ulm, or .cube.

If the file extension is .cube then out_fname is taken to be a formatting string.

The formatting string should be a plain string containing variable placeholders within curly brackets {}. It should not be confused with a formatted string literal (f-string).

It acccepts the variables:

  • {time} - Time in units of as (time domain only).

  • {freq} - Frequency in units of eV (frequency domain only).

  • {which} - The which argument.

  • {pulsefreq} - Pulse frequency in units of eV (time domain only).

  • {pulsefwhm} - Pulse FWHM in units of fs (time domain only).

Examples:

  • out_fname = {which}_density_t{time:09.1f}.cube.

  • out_fname = {which}_density_w{freq:05.2f}.cube.

Parameters:
  • out_fname (str) – File name of the resulting data file.

  • which (str | list[str]) –

    String, or list of strings specifying the types of density to compute:

    • induced - Induced density.

    • holes - Holes density (only allowed in the time domain).

    • electrons - Electrons density (only allowed in the time domain).

  • write_extra (dict[str, Any]) – Dictionary of extra key-value pairs to write to the data file.

property cell_cv: ndarray[tuple[Any, ...], dtype[float64]]#

Cell vectors.

property gd: GridDescriptor#

Real space grid.

property gdshape: tuple[int, int, int]#

Shape of the real space grid.

get_density(rho_nn, nn_indices, fltn1=slice(None, None, None), fltn2=slice(None, None, None), u=0)[source]#

Calculate a real space density from a density matrix in the Kohn-Sham basis.

Parameters:
  • rho_nn (rhodent.typing.DistributedArray) – Density matrix \(\delta\rho_{ia}\), \(\delta\rho_{ii'}\), or \(\delta\rho_{aa'}\).

  • nn_indices (str) –

    Indices describing the density matrices rho_nn. One of

    • ia for induced density \(\delta\rho_{ia'}\).

    • ii for holes density \(\delta\rho_{ii'}\).

    • aa for electrons density \(\delta\rho_{aa'}\).

  • flt_n1 – Filter selecting rows of the density matrix.

  • flt_n2 – Filter selecting columns of the density matrix.

  • u (int) – k-point index.

Return type:

Distributed array with the density in real space on the root rank.

get_result_keys(yield_total=True, yield_electrons=False, yield_holes=False)[source]#

Get the keys that each result will contain, and dimensions thereof.

Return type:

Object representing the data that will be present in the result objects.

icalculate(yield_total=True, yield_electrons=False, yield_holes=False)[source]#

Iteratively calculate results.

Parameters:
  • yield_total (bool) – The results should include the total induced density.

  • yield_holes (bool) – The results should include the holes densities, optionally decomposed by filter_occ.

  • yield_electrons (bool) – The results should include the electrons densities, optionally decomposed by filter_unocc.

Yields:

Tuple (work, result) on the root rank of the calculation communicator. Does not yield on non-root ranks of the calculation communicator. –

work

An object representing the metadata (time, frequency or pulse) for the work done.

result

Object containg the calculation results for this time, frequency or pulse.

Return type:

Generator[tuple[WorkMetadata, Result], None, None]

property occ_filters: list[slice]#

List of energy filters for occupied states.

property unocc_filters: list[slice]#

List of energy filters for unoccupied states.

class rhodent.calculators.DipoleCalculator(response, voronoi=None, *, energies_occ=None, energies_unocc=None, sigma=None, times=None, pulses=None, frequencies=None, frequency_broadening=0)[source]#

Calculate the induced dipole moment in the time or frequency domain.

The induced dipole moment (i.e. the dipole moment minus the permanent component) is to first order given by

\[\delta\boldsymbol{\mu} = -2 \sum_{ia}^\text{eh} \boldsymbol{\mu}_{ia} \mathrm{Re}\:\delta\rho_{ia},\]

where \(\boldsymbol{\mu}_{ia}\) is the dipole matrix element of ground state Kohn-Sham pair \(ia\)

\[\boldsymbol{\mu}_{ia} = \int \psi^{(0)}_i(\boldsymbol{r}) \boldsymbol{r} \psi^{(0)}_a(\boldsymbol{r}) \mathrm{d}\boldsymbol{r},\]

and \(\delta\rho_{ia}\) the induced Kohn-Sham density matrix.

In the frequency domain, this calculator calculates the polarizability, i.e. the Fourier transform of the dipole moment divided by the perturbation.

\[\boldsymbol{\alpha}(\omega) = -2 \sum_{ia}^\text{eh} \boldsymbol{\mu}_{ia} \frac{\mathcal{F}\left[\mathrm{Re}\:\delta\rho_{ia}\right](\omega)}{v(\omega)}.\]

The absorption spectrum in units of dipole strength function is the imaginary part of the polarizability times a prefactor

\[\boldsymbol{S}(\omega) = \frac{2\omega}{\pi} \mathrm{Im}\:\boldsymbol{\alpha}(\omega).\]

This class can also compute projections of the above on Voronoi weights \(w_{ia}\).

Parameters:
  • response (BaseResponse) – Response object.

  • voronoi (VoronoiWeights | None) – Voronoi weights object.

  • energies_occ (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Energy grid in units of eV for occupied levels (holes).

  • energies_unocc (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Energy grid in units of eV for unoccupied levels (electrons)

  • sigma (float | None) – Gaussian broadening width for energy grid in units of eV.

  • times (list[float] | ndarray[tuple[int], dtype[float64]] | None) –

    Compute induced dipole in the time domain, for these times (or as close to them as possible). In units of as.

    May not be used together with frequencies or frequency_broadening.

  • pulses (Optional[Collection[Union[Perturbation, Laser, dict, None]]]) –

    Compute induced dipole in the time domain, in response to these pulses. If none, then no pulse convolution is performed.

    May not be used together with frequencies or frequency_broadening.

  • frequencies (list[float] | ndarray[tuple[int], dtype[float64]] | None) –

    Compute polarizability in the frequency domain, for these frequencies. In units of eV.

    May not be used together with times or pulses.

  • frequency_broadening (float) –

    Compute polarizability in the frequency domain, with Gaussian broadening of this width. In units of eV.

    May not be used together with times or pulses.

calculate_and_write(out_fname, write_extra={}, include_tcm=False, only_one_pulse=True)[source]#

Calculate induced dipole moments and transition contribution maps.

Dipole moments and contributions are saved in a numpy archive if the file extension is .npz or in an ULM file if the file extension is .ulm.

Parameters:
  • out_fname (str) – File name of the resulting data file.

  • write_extra (dict[str, Any]) – Dictionary of extra key-value pairs to write to the data file.

  • include_tcm (bool) – Whether the transition contribution map (TCM) to the dipole moments should be computed and saved.

  • only_one_pulse (bool) – If False, group arrays by pulse. Only valid in time domain.

get_result_keys(yield_total_ia=False, yield_proj_ia=False, yield_total_ou=False, yield_proj_ou=False, decompose_v=True, v=None)[source]#

Get the keys that each result will contain, and dimensions thereof.

Parameters:
  • yield_total_ia (bool) – The results should include the total dipole contributions in the electron-hole basis \(-2 \boldsymbol{\mu}_{ia} \mathrm{Re}\:\delta\rho_{ia}\).

  • yield_proj_ia (bool) – The results should include projections of the dipole contributions in the electron-hole basis \(-2 \boldsymbol{\mu}_{ia} \mathrm{Re}\:\delta\rho_{ia} w_{ia}\).

  • yield_total_ou (bool) – The results should include the total dipole contributions on the energy grid.

  • yield_proj_ou (bool) – The results should include projections of the dipole contributions on the energy grid.

  • decompose_v (bool) – The results should include the dipole moment and/or its contributions decomposed by Cartesian direction.

  • v (int | None) – If not None, then the results should include the v:th Cartesian component of the dipole moment and its contributions.

Return type:

ResultKeys

icalculate(yield_total_ia=False, yield_proj_ia=False, yield_total_ou=False, yield_proj_ou=False, decompose_v=True, v=None)[source]#

Iteratively calculate dipole contributions.

Parameters:
  • yield_total_ia (bool) – The results should include the total dipole contributions in the electron-hole basis \(-2 \boldsymbol{\mu}_{ia} \mathrm{Re}\:\delta\rho_{ia}\).

  • yield_proj_ia (bool) – The results should include projections of the dipole contributions in the electron-hole basis \(-2 \boldsymbol{\mu}_{ia} \mathrm{Re}\:\delta\rho_{ia} w_{ia}\).

  • yield_total_ou (bool) – The results should include the total dipole contributions on the energy grid.

  • yield_proj_ou (bool) – The results should include projections of the dipole contributions on the energy grid.

  • decompose_v (bool) – The results should include the dipole moment and/or its contributions decomposed by Cartesian direction.

  • v (int | None) – If not None, then the results should include the v:th Cartesian component of the dipole moment and its contributions.

Yields:

Tuple (work, result) on the root rank of the calculation communicator. Does not yield on non-root ranks of the calculation communicator. –

work

An object representing the metadata (time, frequency or pulse) for the work done.

result

Object containg the calculation results for this time, frequency or pulse.

Return type:

Generator[tuple[WorkMetadata, Result], None, None]

property oscillator_strength_prefactor: ndarray[tuple[Any, ...], dtype[float64]]#

Conversion factor from polarizability to dipole strength function.

class rhodent.calculators.EnergyCalculator(response, voronoi=None, *, filter_pair=(0, inf), energies_occ=None, energies_unocc=None, sigma=None, times=None, pulses=None)[source]#

Calculate energy contributions in the time domain.

The total energy can be written

\[E_\text{tot}(t) = E^{(0)}_\text{tot} + \sum_{ia}^\text{eh} E_{ia}(t) + E_\text{pulse}(t).\]

The contributions to the total energy are

\[E_{ia} = \frac{1}{2} \left[ p_{ia}\dot{q}_{ia} - q_{ia} \dot{p}_{ia} - v_{ia} q_{ia} \right],\]

the contributions to the Hartree-xc energy are

\[E_{ia}^\text{Hxc} = -\frac{1}{2} \left[ \omega_{ia} q_{ia}^2 - q_{ia} \dot{p}_{ia} - v_{ia} q_{ia} \right],\]

and the rate of energy change is

\[\dot{E}_{ia} = \frac{1}{2} \left[ p_{ia}\ddot{q}_{ia} - q_{ia} \ddot{p}_{ia} - v_{ia} \dot{q}_{ia} - \dot{v}_{ia} q_{ia} \right].\]

The matrix element \(v_{ia}\) can be computed from the dipole matrix element

\[\boldsymbol{\mu}_{ia} = \int \psi^{(0)}_i(\boldsymbol{r}) \boldsymbol{r} \psi^{(0)}_a(\boldsymbol{r}) \mathrm{d}\boldsymbol{r}\]

projected on the direction of the perturbation \(\hat{\boldsymbol{e}}\), the occupation number difference \(f_{ia}\) and the pulse amplitude \(v_\text{pulse}(t)\)

\[v_{ia} = \sqrt{2 f_{ia}} \boldsymbol{\mu}_{ia} \cdot\hat{\boldsymbol{e}} v_\text{pulse}.\]
Parameters:
  • response (BaseResponse) – Response object.

  • voronoi (VoronoiWeights | None) – Voronoi weights object.

  • filter_pair (tuple[float, float]) – Filter electron-hole pairs (occupied-unoccupied transitions) in summation of energies. Provide a tuples (low, high) to compute the sum of energies \(E_{ia}\) and \(E_{ia}^\text{Hxc}\) for pairs with transition energy \(\varepsilon_a-\varepsilon_{i}\) in the interval low-high (in units of eV).

  • energies_occ (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Energy grid in units of eV for occupied levels (holes).

  • energies_unocc (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Energy grid in units of eV for unoccupied levels (electrons).

  • sigma (float | None) – Gaussian broadening width for energy grid in units of eV.

  • times (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Compute energies in the time domain, for these times (or as close to them as possible). In units of as.

  • pulses (Optional[Collection[Union[Perturbation, Laser, dict, None]]]) – Compute energies in the time domain, in response to these pulses. If none, then no pulse convolution is performed.

calculate_and_write(out_fname, write_extra={}, include_tcm=False, save_dist=False, only_one_pulse=True)[source]#

Calculate energy contributions.

Energies are saved in a numpy archive if the file extension is .npz or in an ULM file if the file extension is .ulm.

Parameters:
  • out_fname (str) – File name of the resulting data file.

  • write_extra (dict[str, Any]) – Dictionary of extra key-value pairs to write to the data file.

  • include_tcm (bool) – Whether the transition contribution map (TCM) to the energies should be computed and saved.

  • save_dist (bool) – Whether the transition energy distributions should be computed and saved.

  • only_one_pulse (bool) – If False, group arrays by pulse.

get_result_keys(yield_total_E_ia=False, yield_proj_E_ia=False, yield_total_E_ou=False, yield_total_dists=False, direction=2)[source]#

Get the keys that each result will contain, and dimensions thereof.

Parameters:
  • yield_total_E_ia (bool) – The results should include the contributions in the electron-hole basis to the total energy \(E_{ia}\) and Hartree-xc energy \(E_{ia}^\text{Hxc}\)

  • yield_proj_E_ia (bool) – The results should include the contributions in the electron-hole basis to the total energy projected on the occupied and unoccupied Voronoi weights \(E_{ia} w_i\) and \(E_{ia} w_a\).

  • yield_total_E_ou (bool) – The results should include the contributions the total energy broadened on the occupied and unoccupied energy grids \(\sum_{ia} E_{ia}\delta(\varepsilon_\text{occ}-\varepsilon_{i}) \delta(\varepsilon_\text{unocc}-\varepsilon_{a})\) and

  • yield_total_dists (bool) – The results should include the contributions the total energy and Hartree-xc energy broadened by electronic transition energy onto the unoccupied energies grid \(\sum_{ia} E_{ia} \delta(\varepsilon-\omega_{ia})\) and \(\sum_{ia} E_{ia}^\text{Hxc} \delta(\varepsilon-\omega_{ia})\)

  • direction (int | Sequence[int]) – Direction \(\hat{\boldsymbol{e}}\) of the polarization of the pulse. Integer 0, 1 or 2 to specify x, y or z, or the direction vector specified as a list of three values. Default: polarization along z.

Return type:

ResultKeys

icalculate(yield_total_E_ia=False, yield_proj_E_ia=False, yield_total_E_ou=False, yield_total_dists=False, direction=2)[source]#

Iteratively calculate energies.

Parameters:
  • yield_total_E_ia (bool) – The results should include the contributions in the electron-hole basis to the total energy \(E_{ia}\) and Hartree-xc energy \(E_{ia}^\text{Hxc}\)

  • yield_proj_E_ia (bool) – The results should include the contributions in the electron-hole basis to the total energy projected on the occupied and unoccupied Voronoi weights \(E_{ia} w_i\) and \(E_{ia} w_a\).

  • yield_total_E_ou (bool) – The results should include the contributions the total energy broadened on the occupied and unoccupied energy grids \(\sum_{ia} E_{ia}\delta(\varepsilon_\text{occ}-\varepsilon_{i}) \delta(\varepsilon_\text{unocc}-\varepsilon_{a})\) and

  • yield_total_dists (bool) – The results should include the contributions the total energy and Hartree-xc energy broadened by electronic transition energy onto the unoccupied energies grid \(\sum_{ia} E_{ia} \delta(\varepsilon-\omega_{ia})\) and \(\sum_{ia} E_{ia}^\text{Hxc} \delta(\varepsilon-\omega_{ia})\)

  • direction (int | Sequence[int]) – Direction \(\hat{\boldsymbol{e}}\) of the polarization of the pulse. Integer 0, 1 or 2 to specify x, y or z, or the direction vector specified as a list of three values. Default: polarization along z.

Yields:

Tuple (work, result) on the root rank of the calculation communicator. Does not yield on non-root ranks of the calculation communicator. –

work

An object representing the metadata (time or pulse) for the work done.

result

Object containg the calculation results for this time and pulse.

Return type:

Generator[tuple[WorkMetadata, Result], None, None]

class rhodent.calculators.HotCarriersCalculator(response, voronoi=None, *, energies_occ=None, energies_unocc=None, sigma=None, times=None, pulses=None, frequencies=None, frequency_broadening=0)[source]#

Calculate hot-carrier distributions in the time domain.

For weak perturbations, the response of the density matrix is to first order non-zero only in the occupied-unoccupied space, i.e. the block off-diagonals

\[\begin{split}\delta\rho = \begin{bmatrix} 0 & [\delta\rho_{ai}^*] \\ [\delta\rho_{ia}] & 0 \end{bmatrix}.\end{split}\]

The unoccupied-occupied, or electron-hole, part of the density matrix is thus linear in perturbation and can by transformed using Fourier transforms.

From the first-order response, the second order response, i.e. the hole-hole (\(\delta\rho_{ii'}\)) and electron-electron (\(\delta\rho_{aa'}\)) parts can be obtained.

The hole-hole part is

\[\delta\rho_{ii'} = - \frac{1}{2} \sum_n^{f_n > f_i, f_n > f_{i'}} P_{ni} P_{ni'} + Q_{ni} Q_{ni'}\]

and the electron-hole part

\[\delta\rho_{aa'} = \frac{1}{2} \sum_n^{f_n < f_a, f_n < f_a'} P_{ia} P_{ia'} + Q_{ia} Q_{ia'}\]

where

\[\begin{split}\begin{align} P_{ia} &= \frac{2 \mathrm{Im}\:\delta\rho_{ia}}{\sqrt{2 f_{ia}}} \\ Q_{ia} &= \frac{2 \mathrm{Re}\:\delta\rho_{ia}}{\sqrt{2 f_{ia}}} , \end{align}\end{split}\]

where \(f_{ia}\) is the occupation number difference of pair \(ia\).

Hot-carrier distributions are calculated by convolution of \(\delta\rho_{ii'}\) (holes) and \(\delta\rho_{aa'}\) (electrons) by Gaussian broadening functions on the energy grid.

\[\begin{split}\begin{align} P^\text{holes}(\varepsilon) &= \sum_i \delta\rho_{ii'} G(\varepsilon - \varepsilon_i) \\ P^\text{electrons}(\varepsilon) &= \sum_a \delta\rho_{aa'} G(\varepsilon - \varepsilon_a) \end{align}\end{split}\]

where \(\varepsilon_n\) are Kohn-Sham energies and

\[G(\varepsilon - \varepsilon_n) = \frac{1}{\sqrt{2 \pi \sigma^2}} \exp\left(-\frac{ \left(\varepsilon_i - \varepsilon\right)^2 }{ 2 \sigma^2 }\right).\]

Projected hot-carrier distributions are defined

\[\begin{split}\begin{align} P^\text{holes}(\varepsilon) &= \sum_{ii'} \delta\rho_{ii'} w_{ii'} G(\varepsilon - \varepsilon_i) \\ P^\text{electrons}(\varepsilon) &= \sum_{aa'} \delta\rho_{aa'} w_{aa'} G(\varepsilon - \varepsilon_a). \end{align}\end{split}\]

The Voronoi weights are

\[W_{nn} = \left<\psi_n|\hat{w}|\psi_{n}\right> = \int w(\boldsymbol{r}) \psi_n^*(\boldsymbol{r}) \psi_{n}(\boldsymbol{r}) d\boldsymbol{r}\]

where the operator \(\hat{w} = w(\boldsymbol{r})\) is 1 in the Voronoi region of the atomic projections and 0 outside.

Parameters:
  • response (BaseResponse) – Response object.

  • voronoi (VoronoiWeights | None) – Voronoi weights object.

  • energies_occ (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Energy grid in units of eV for occupied levels (holes).

  • energies_unocc (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Energy grid in units of eV for unoccupied levels (electrons)

  • sigma (float | None) – Gaussian broadening width for energy grid in units of eV.

  • times (list[float] | ndarray[tuple[int], dtype[float64]] | None) – Compute hot carriers in the time domain, for these times (or as close to them as possible). In units of as.

  • pulses (Optional[Collection[Union[Perturbation, Laser, dict, None]]]) – Compute hot carriers in the time domain, in response to these pulses. If None no pulse convolution is performed.

calculate_distributions_and_write(out_fname, write_extra={}, average_times=True, only_one_pulse=True)[source]#

Calculate broadened hot-carrier energy distributions, optionally averaged over time.

HC distributions are saved in a numpy archive if the file extension is .npz or in a comma separated file if the file extension is .dat.

Parameters:
  • out_fname (str) – File name of the resulting data file.

  • write_extra (dict[str, Any]) – Dictionary of extra key-value pairs to write to the data file.

  • average_times (bool) – If True, an average over the given times will be taken. If false, then hot-carrier distributions are computed separately over the times, and each output is written separately for each time.

  • only_one_pulse (bool) – There is only one pulse, don’t group by pulse.

calculate_totals_by_pulse_and_write(out_fname, write_extra={})[source]#

Calculate the number of generated hot carriers, projected on groups of atoms, for a list of pulses.

HC numbers are saved in a numpy archive if the file extension is .npz or in a comma separated file if the file extension is .dat.

Parameters:

out_fname (str) – File name of the resulting data file.

calculate_totals_by_time_and_write(out_fname, write_extra={})[source]#

Calculate the number of generated hot carriers, projected on groups of atoms, for a list of times.

HC numbers are saved in a numpy archive if the file extension is .npz or in a comma separated file if the file extension is .dat.

Parameters:

out_fname (str) – File name of the resulting data file.

get_result_keys(yield_total_hcdists=False, yield_proj_hcdists=False, yield_total_P=False, yield_proj_P=False, yield_total_P_ou=False)[source]#

Get the keys that each result will contain, and dimensions thereof.

Parameters:
  • yield_total_hcdists (bool) – The results should include the total hot-carrier distributions on the energy grid.

  • yield_proj_hcdists (bool) – The results should include the projections of the hot-carrier distributions on the energy grid.

  • yield_total_P (bool) – The results should include the total hot-carrier distributions in the electron-hole basis.

  • yield_proj_P (bool) – The results should include the projections of the hot-carrier distributions in the electron-hole basis.

  • yield_total_P_ou (bool) – The results should include the transition matrix broadened on the energy grid.

icalculate(yield_total_hcdists=False, yield_proj_hcdists=False, yield_total_P=False, yield_proj_P=False, yield_total_P_ou=False)[source]#

Iteratively calculate second order density matrices and hot-carrier distributions.

Parameters:
  • yield_total_hcdists (bool) – The results should include the total hot-carrier distributions on the energy grid.

  • yield_proj_hcdists (bool) – The results should include the projections of the hot-carrier distributions on the energy grid.

  • yield_total_P (bool) – The results should include the total hot-carrier distributions in the electron-hole basis.

  • yield_proj_P (bool) – The results should include the projections of the hot-carrier distributions in the electron-hole basis.

  • yield_total_P_ou (bool) – The results should include the transition matrix broadened on the energy grid.

Yields:

Tuple (work, result) on the root rank of the calculation communicator. Does not yield on non-root ranks of the calculation communicator. –

work

An object representing the metadata (time and pulse) for the work done.

result

Object containg the calculation results for this time and pulse.

Return type:

Generator[tuple[WorkMetadata, Result], None, None]

Other calculators#

These calculators require other input files than the calculators for the full response, for example just the dipole moment file.

class rhodent.dos.DOSCalculator(eigenvalues, fermilevel, voronoi, energies, sigma, zerofermi=False)[source]#

Density of states (DOS) and partial DOS (PDOS) calculator.

Calculates DOS

\[\mathrm{DOS}(\varepsilon) = \Sigma_n G(\varepsilon - \varepsilon_n)\]

and PDOS

\[\mathrm{PDOS}(\varepsilon) = \Sigma_n w_{nn} G(\varepsilon - \varepsilon_n)\]

where \(\varepsilon_n\) are Kohn-Sham energies and \(G(\varepsilon - \varepsilon_n)\) a Gaussian broadening function

\[G(\varepsilon - \varepsilon_n) = \frac{1}{\sqrt{2 \pi \sigma^2}} \exp\left(-\frac{ \left(\varepsilon_i - \varepsilon\right)^2 }{ 2 \sigma^2 }\right).\]

The Voronoi weights are defined

\[W_{nn} = \left<\psi_n|\hat{w}|\psi_{n}\right> = \int w(\boldsymbol{r}) \psi_n^*(\boldsymbol{r}) \psi_{n}(\boldsymbol{r}) d\boldsymbol{r}\]

where the operator \(\hat{w} = w(\boldsymbol{r})\) is 1 in the Voronoi region of the atomic projections and 0 outside.

Parameters:
  • eigenvalues (list[float] | ndarray[tuple[Any, ...], dtype[float64]]) – List of eigenvalues \(\varepsilon_n\) (relative to Fermi level).

  • fermilevel (float) – Fermi level.

  • voronoi (VoronoiWeights | None) –

    Voronoi weights object defining the atomic projections for PDOS.

    Leave out if only DOS is desired.

  • energies (list[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Array of energies (in units of eV) for which the broadened PDOS is computed.

  • sigma (float) – Gaussian broadening width \(\sigma\) in units of eV.

  • zerofermi (bool) – Eigenvalues relative to Fermi level if True, else relative to vacuum

calculate_dos()[source]#

Calculate DOS.

Return type:

DOS on the root rank, None on other ranks.

calculate_dos_and_write(out_fname, write_extra={})[source]#

Calculate the DOS and write to file.

The DOS is saved in a numpy archive if the file extension is .npz or in a comma separated file if the file extension is .dat.

Parameters:
  • out_fname (Path | str) – File name of the resulting data file.

  • write_extra (dict[str, Any]) – Dictionary of additional data written to numpy archive (ignored for .dat) files.

calculate_pdos_and_write(out_fname, write_extra={}, write_extra_from_voronoi=False)[source]#

Calculate the PDOS and write to file.

The PDOS is saved in a numpy archive if the file extension is .npz or in a comma separated file if the file extension is .dat.

Parameters:
  • out_fname (Path | str) – File name of the resulting data file.

  • write_extra (dict[str, Any]) – Dictionary of additional data written to numpy archive (ignored for .dat) files.

  • write_extra_from_voronoi (bool) – If true, and voronoi is a ULM reader, extra key-value pairs are read from voronoi and written to the .npz file (ignored for .dat) files.

property energies: ndarray[tuple[Any, ...], dtype[float64]]#

Energy grid in units of eV.

classmethod from_calc(calc, voronoi, energies, sigma, zerofermi=False)[source]#

Initialize from GPAW calculator.

Parameters:
  • calc (gpaw.GPAW) – GPAW calculator.

  • voronoi (VoronoiWeights | None) –

    Voronoi weights object defining the atomic projections for PDOS.

    Leave out if only DOS is desired.

  • energies (list[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Array of energies (in units of eV) for which the broadened PDOS is computed.

  • sigma (float) – Gaussian broadening width \(\sigma\) in units of eV.

  • zerofermi (bool) – Eigenvalues relative to Fermi level if True, else relative to vacuum.

classmethod from_gpw(gpw_file, voronoi, energies, sigma, zerofermi=False)[source]#

Initialize from .gpw file.

Parameters:
  • gpw_file (Path | str) – File name of GPAW ground state file.

  • voronoi (VoronoiWeights | None) –

    Voronoi weights object defining the atomic projections for PDOS.

    Leave out if only DOS is desired.

  • energies (list[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Array of energies (in units of eV) for which the broadened PDOS is computed.

  • sigma (float) – Gaussian broadening width \(\sigma\) in units of eV.

  • zerofermi (bool) – Eigenvalues relative to Fermi level if True, else relative to vacuum.

icalculate_pdos()[source]#

Calculate PDOS for each of the atomic projections in the voronoi object..

Yields:

Once per set of Voronoi weights a dictionary with keys –

  • weight_n - Array of dimensions (Nn) of projections. None on non-root ranks.

  • pdos_e - Broadened PDOS. None on non-root ranks.

Return type:

Generator[dict[str, ndarray[tuple[Any, ...], dtype[float64]] | None], None, None]

property log: Logger#

Logger.

property sigma: float#

Gaussian broadening width in units of eV.

property voronoi: VoronoiWeights | None#

Voronoi weights object.

class rhodent.spectrum.SpectrumCalculator(times, dipole_moments, perturbation)[source]#

Spectrum calculator.

Calculates the dynamic polarizability and dipole strength function (the spectrum).

The polarizability \(\alpha(\omega)\) is related to the perturbation \(\mathcal{E}(\omega)\) and the Fouier transform of the dipole moment \(\boldsymbol\mu(t)\) as

\[\boldsymbol\alpha(\omega) \mathcal{E}(\omega) = \mathcal{F}[\boldsymbol\mu(t)](\omega).\]

The dipole strength function is

\[\boldsymbol{S}(\omega) = \frac{2}{\pi} \omega\:\mathrm{Im}[\boldsymbol\alpha(\omega)].\]

Both quantities can be broadened by supplying a non-zero value \(\sigma\). Then the convolution

\[\frac{1}{\sqrt{2\pi/\sigma^2}} \int_{-\infty}^{\infty} \boldsymbol\alpha(\omega') \exp\left(- \frac{(\omega - \omega')^2}{2\sigma^2}\right) \mathrm{d}\omega'\]

is computed. When the perturbation is a delta-kick, this can efficiently be computed by multiplying the dipole moment by a Gaussian envelope before Fourier transformation

\[\boldsymbol\mu(t) \exp(-\sigma^2 t^2 / 2).\]

For other perturbations, a FFT and IFFT is first performed to obtain the delta-kick response.

Parameters:
  • times (ndarray[tuple[Any, ...], dtype[float64]]) – Array (length T) of times in units of as.

  • dipole_moments (ndarray[tuple[Any, ...], dtype[float64]]) – Array (shape (T, 3)) of dipole moments in units of eÅ.

  • perturbation (Union[Perturbation, Laser, dict, None]) – The perturbation that was applied in the TDDFT calculation.

calculate_spectrum_and_write(out_fname, frequencies, frequency_broadening=0, write_extra={})[source]#

Calculate the dipole strength function (spectrum) and write to file.

The spectrum is saved in a numpy archive if the file extension is .npz or in a comma separated file if the file extension is .dat.

Parameters:
  • out_fname (Path | str) – File name of the resulting data file.

  • frequencies (list[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Array of frequencies for which to calculate the spectrum; in units of eV.

  • frequency_broadening (float) – Gaussian broadening width in units of eV. Default (0) is no broadening.

  • write_extra (dict[str, Any]) – Dictionary of additional data written to numpy archive (ignored for .dat) files.

property dipole_moments: ndarray[tuple[Any, ...], dtype[float64]]#

Array of dipole moments, in units of eÅ.

get_dipole_strength_function(frequencies, frequency_broadening=0)[source]#

Calculate the dipole strength function (spectrum) in units of 1/eV.

Parameters:
  • frequencies (list[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Array of frequencies for which to calculate the spectrum; in units of eV.

  • frequency_broadening (float) – Gaussian broadening width in units of eV. Default (0) is no broadening.

Return type:

Array of dipole strength function in units of 1/eV. The array has shape (N, 3), where N is length of frequencies.

get_dynamic_polarizability(frequencies, frequency_broadening=0)[source]#

Calculate the dynamic polarizability.

Parameters:
  • frequencies (list[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Array of frequencies for which to calculate the polarizability; in units of eV.

  • frequency_broadening (float) – Gaussian broadening width in atomic units. Default (0) is no broadening.

Return type:

Array of dynamic polarizabilities in (eÅ)**2/eV. The array has shape (N, 3), where N is the length of frequencies.

property perturbation: Perturbation#

The perturbation that was applied in the TDDFT calculation.

property times: ndarray[tuple[Any, ...], dtype[float64]]#

Array of times corresponding to dipole moments, in units of as.