Calculators¶
- class rhodent.calculators.DensityCalculator(gpw_file, density_matrices, filter_occ=[], filter_unocc=[])[source]¶
Obtain induced density from frequency or pulse response density matrices.
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}).\]- Parameters:
gpw_file (
str
) – Filename of GPAW ground state filedensity_matrices (
BaseDensityMatrices
) – Object that gives the density matrix in the time or freqency domainfilter_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.
- property gd: GridDescriptor¶
Real space grid
- property gdshape: tuple[int, int, int]¶
Shape of the real space grid
- get_density(rho_ia, n1, n2, 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.
- Return type:
Distributed array with the density in real space on the root rank
- get_result_keys()[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()[source]¶
Iteratively calculate results. The results include the total induced density, and the densities of electrons and holes, optionally decomposed by
filter_occ
andfilter_unocc
.- Yields:
Tuple (work, result) on the root rank 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
Yields nothing on non-root ranks of the calculation communicator.
- 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
- property voronoi: VoronoiWeights¶
Voronoi weights object
- class rhodent.calculators.DipoleCalculator(density_matrices, voronoi, energies_occ, energies_unocc, sigma=None)[source]¶
Obtain contributions to induced dipole moment from density matrices
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}.\]This class can also compute projections of the above on Voronoi weights \(w_{ia}\).
- Parameters:
density_matrices (
BaseDensityMatrices
) – Object that gives the density matrix in the time or freqency domainvoronoi (
VoronoiWeights
|None
) – Voronoi weights objectenergies_occ (
list
[float
] |ndarray
[Any
,dtype
[float64
]]) – Energy grid (in eV) for occupied levels (hot holes)energies_unocc (
list
[float
] |ndarray
[Any
,dtype
[float64
]]) – Energy grid (in eV) for unoccupied levels (hot electrons)sigma (
Optional
[float
]) – Gaussian broadening width in eV
- 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 gridyield_proj_ou (
bool
) – The results should include projections of the dipole contributions on the energy griddecompose_v (
bool
) – The results should include the dipole moment and/or its contributions decomposed by Cartesian direction.v (
Optional
[int
]) – 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 gridyield_proj_ou (
bool
) – The results should include projections of the dipole contributions on the energy griddecompose_v (
bool
) – The results should include the dipole moment and/or its contributions decomposed by Cartesian direction.v (
Optional
[int
]) – 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
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
Yields nothing on non-root ranks of the calculation communicator.
- Return type:
Generator
[tuple
[WorkMetadata
,Result
],None
,None
]
- class rhodent.calculators.EnergyCalculator(density_matrices, voronoi, energies_occ, energies_unocc, sigma=None)[source]¶
Obtain energy contributions from pulse response density matrices.
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 energy are
\[E_{ia}^\text{c} = -\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],\]where
\[v_{ia} = \sqrt{2 f_{ia}} \int \psi^{(0)}_i(\boldsymbol{r}) \left(\boldsymbol{r}\cdot\hat{\boldsymbol{e}}_\text{pulse}\right) \psi^{(0)}_a(\boldsymbol{r}) \mathrm{d}\boldsymbol{r}.\]- Parameters:
density_matrices (
BaseDensityMatrices
) – Object that gives the density matrix in the time or freqency domainvoronoi (
VoronoiWeights
|None
) – Voronoi weights objectenergies_occ (
list
[float
] |ndarray
[Any
,dtype
[float64
]]) – Energy grid (in eV) for occupied levels (hot holes)energies_unocc (
list
[float
] |ndarray
[Any
,dtype
[float64
]]) – Energy grid (in eV) for unoccupied levels (hot electrons)sigma (
Optional
[float
]) – Gaussian broadening width in eV
- 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 Coulomb energy \(E_{ia}^\text{c}\)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})\) andyield_total_dists (
bool
) – The results should include the contributions the total energy and Coulomb 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{C} \delta(\varepsilon-\omega_{ia})\)direction (
int
|Sequence
[int
]) – Direction \(\hat{\boldsymbol{e}}_\text{pulse}\) 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 Coulomb energy \(E_{ia}^\text{c}\)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})\) andyield_total_dists (
bool
) – The results should include the contributions the total energy and Coulomb 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{C} \delta(\varepsilon-\omega_{ia})\)direction (
int
|Sequence
[int
]) – Direction \(\hat{\boldsymbol{e}}_\text{pulse}\) 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
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
Yields nothing on non-root ranks of the calculation communicator.
- Return type:
Generator
[tuple
[WorkMetadata
,Result
],None
,None
]
- class rhodent.calculators.HotCarriersCalculator(density_matrices, voronoi, energies_occ, energies_unocc, sigma=None)[source]¶
Obtain hot-carrier distributions, by calculating the second order response of the density matrix.
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\).
- Parameters:
density_matrices (
BaseDensityMatrices
) – Object that gives the density matrix in the time or freqency domainvoronoi (
VoronoiWeights
|None
) – Voronoi weights objectenergies_occ (
list
[float
] |ndarray
[Any
,dtype
[float64
]]) – Energy grid (in eV) for occupied levels (hot holes)energies_unocc (
list
[float
] |ndarray
[Any
,dtype
[float64
]]) – Energy grid (in eV) for unoccupied levels (hot electrons)sigma (
Optional
[float
]) – Gaussian broadening width in eV
- 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 gridyield_proj_hcdists (
bool
) – The results should include the projections of the hot-carrier distributions on the energy gridyield_total_P (
bool
) – The results should include the total hot-carrier distributions in the electron-hole basisyield_proj_P (
bool
) – The results should include the projections of the hot-carrier distributions in the electron-hole basisyield_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 gridyield_proj_hcdists (
bool
) – The results should include the projections of the hot-carrier distributions on the energy gridyield_total_P (
bool
) – The results should include the total hot-carrier distributions in the electron-hole basisyield_proj_P (
bool
) – The results should include the projections of the hot-carrier distributions in the electron-hole basisyield_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
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
Yields nothing on non-root ranks of the calculation communicator.
- Return type:
Generator
[tuple
[WorkMetadata
,Result
],None
,None
]