calculation_helpers
Helper functions for several calculation tasks (such as integration).
- analytical_integration(D, I0, I1, fermi_energy, energy_grid, temperature)[source]
Perform analytical integration following the outline given by [1].
More specifically, this function solves Eq. 32, by constructing the weights itself.
- Parameters:
D (numpy.array or float) – Either LDOS or DOS data.
I0 (string) –
I_0 from Eq. 33. The user only needs to provide which function should be used. Arguments are:
F0
F1
F2
S0
S1
I1 (string) –
I_1 from Eq. 33. The user only needs to provide which function should be used. Arguments are:
F0
F1
F2
S0
S1
fermi_energy (float) – The fermi energy in eV.
energy_grid (numpy.array) – Energy grid on which the integration should be performed.
temperature (float) – Temperature in K.
- Returns:
integration_value – Value of the integral.
- Return type:
numpy.array or float
- entropy_multiplicator(energy, fermi_energy, temperature)[source]
Calculate the multiplicator function for the entropy integral.
The Entropy integral is
\[f(\epsilon)\log(f(\epsilon))+(1-f(\epsilon)\log(1-f(\epsilon))\]- Parameters:
energy (float or numpy.array) – Energy for which the Fermi function is supposed to be calculated in energy_units.
fermi_energy (float) – Fermi energy level in energy_units.
temperature (float) – Temperature in K.
- Returns:
multiplicator_val – Value of the multiplicator function.
- Return type:
float
- fermi_function(energy, fermi_energy, temperature, suppress_overflow=False)[source]
Calculate the Fermi function.
The Fermi function reads
\[f(\epsilon) = 1/(1 + e^{\frac{\epsilon-\epsilon_F}{k_\mathrm{B} T}})\]- Parameters:
energy (float or numpy.array) – Energy for which the Fermi function is supposed to be calculated in energy_units.
fermi_energy (float) – Fermi energy level in energy_units.
temperature (float) – Temperature in K.
suppress_overflow (bool) – If True, overflow that may occur in the exponent of the divisor of the Fermi function is suppressed. This is mathematically justifiable, but
- Returns:
fermi_val – Value of the Fermi function.
- Return type:
float
- gaussians(grid, centers, sigma)[source]
Calculate multiple gaussians on the same grid, but with different centers.
Gaussian functions are used as approximations to the delta in the Brillouin zone integration. Note that this defines Gaussians without the factor of \(1/\sqrt{2}\). All the Gaussians will have the same sigmas.
- Parameters:
grid (np.array) – Grid on which this Gaussian is defined.
centers (np.array) – Array of centers for the Gaussians
sigma (float) – Sigma value for the Gaussian.
- Returns:
multiple_gaussians – multiple gaussians on the same grid, but with different centers.
- Return type:
np.array
- get_beta(temperature)[source]
Calculate \(\beta = {(k_\mathrm{B}T)}^{-1}\).
- Parameters:
temperature (float) – Temperature in K
- Returns:
beta – Thermodynamic beta.
- Return type:
float
- get_f0_value(x, beta)[source]
Get the F0 value for the analytic integration formula.
- Parameters:
x (float) – x value for function.
beta (float) – Thermodynamic beta.
- Returns:
function_value – F0 value.
- Return type:
float
- get_f1_value(x, beta)[source]
Get the F1 value for the analytic integration formula.
- Parameters:
x (float) – x value for function.
beta (float) – Thermodynamic beta.
- Returns:
function_value – F1 value.
- Return type:
float
- get_f2_value(x, beta)[source]
Get the F2 value for the analytic integration formula.
- Parameters:
x (float) – x value for function.
beta (float) – Thermodynamic beta.
- Returns:
function_value – F2 value.
- Return type:
float
- get_s0_value(x, beta)[source]
Get the S0 value for the analytic integration formula.
- Parameters:
x (float) – x value for function.
beta (float) – Thermodynamic beta.
- Returns:
function_value – S0 value.
- Return type:
float
- get_s1_value(x, beta)[source]
Get the S1 value for the analytic integration formula.
- Parameters:
x (float) – x value for function.
beta (float) – Thermodynamic beta.
- Returns:
function_value – S1 value.
- Return type:
float
- integrate_values_on_spacing(values, spacing, method, axis=0)[source]
Integrate values assuming a uniform grid with a provided spacing.
Different integration methods are available.
- Parameters:
values (numpy.array) – Values to be integrated.
spacing (int) – Spacing of the grid on which the integration is performed.
method (string) –
Integration method to be used. Currently supported:
”trapezoid” for trapezoid method
”simpson” for Simpson method.
axis (int) – Axis along which the integration is performed.
- Returns:
integral_values – The value of the integral.
- Return type:
float