tbplas.Analyzer
- class tbplas.Analyzer(sample: Sample, config: Config, dimension: int = 3, enable_mpi: bool = False, echo_details: bool = False)
Class for analyzing correlation functions.
- _sample
sample for which TBPM calculations will be performed
- Type:
‘Sample’ instance
- _config
parameters controlling TBPM calculation
- Type:
‘Config’ instance
- _dimension
dimension of the system
- Type:
int
- __init__(sample: Sample, config: Config, dimension: int = 3, enable_mpi: bool = False, echo_details: bool = False) None
- Parameters:
sample – sample for which TBPM calculations will be performed
config – parameters controlling TBPM calculations
dimension – dimension of the sample
enable_mpi – whether to enable parallelism using MPI
echo_details – whether to output parallelization details
- Raises:
ValueError – if dimension is neither 2 nor 3, or if illegal parameters are detected in config
Methods
__init__
(sample, config[, dimension, ...])- param sample:
sample for which TBPM calculations will be performed
all_average
(data_local)Average results over random samples broadcast to all process.
all_reduce
(data_local)Reduce local data and broadcast to all processes.
average
(data_local)Average results over random samples and store results to master process.
barrier
()Wrapper for self.comm.Barrier.
bcast
(data_local)Broadcast data from master to other processes.
calc_ac_cond
(corr_ac[, window])Calculate optical (AC) conductivity from correlation function.
calc_dc_cond
(corr_dos, corr_dc[, ...])Calculate electronic (DC) conductivity at zero temperature from its correlation function.
calc_diff_coeff
(corr_dc[, window_dc])Calculate diffusion coefficient form DC correlation function.
calc_dos
(corr_dos[, window])Calculate DOS from correlation function.
calc_dyn_pol
(corr_dyn_pol[, window])Calculate dynamical polarization from correlation function.
calc_epsilon
(dyn_pol)Calculate dielectric function from dynamical polarization.
calc_epsilon_q0
(omegas, ac_cond)Calculate dielectric function from AC conductivity for q=0.
calc_hall_cond
(mu_mn[, unit])Calculate Hall conductivity according to Kubo-Bastin formula mu_mn.
calc_ldos
(corr_ldos[, window])Calculate LDOS from correlation function.
dist_bound
(n_max)Same as dist_range, but returns the lower and upper bounds.
dist_list
(raw_list[, algorithm])Distribute a list over processes.
dist_range
(n_max)Distribute range(n_max) over processes.
log
([event, fmt])Log the date and time of event.
print
([text])Print text on master process.
reduce
(data_local)Reduce local data to master process.
Attributes
Determine whether this is the master process.
Determine whether MPI is enabled.
Interface for the '__rank' attribute.
Interface for the '__size' attribute.
- __init__(sample: Sample, config: Config, dimension: int = 3, enable_mpi: bool = False, echo_details: bool = False) None
- Parameters:
sample – sample for which TBPM calculations will be performed
config – parameters controlling TBPM calculations
dimension – dimension of the sample
enable_mpi – whether to enable parallelism using MPI
echo_details – whether to output parallelization details
- Raises:
ValueError – if dimension is neither 2 nor 3, or if illegal parameters are detected in config
- all_average(data_local: ndarray) ndarray
Average results over random samples broadcast to all process.
- Parameters:
data_local – local results on each process
- Returns:
averaged data from data_local
- all_reduce(data_local: ndarray) ndarray
Reduce local data and broadcast to all processes.
- Parameters:
data_local – local results on each process
- Returns:
summed data from data_local
- average(data_local: ndarray) ndarray
Average results over random samples and store results to master process.
- Parameters:
data_local – local results on each process
- Returns:
averaged data from data_local
- barrier() None
Wrapper for self.comm.Barrier.
- bcast(data_local: ndarray) None
Broadcast data from master to other processes.
- Parameters:
data_local – local results on each process
- Returns:
None
- calc_ac_cond(corr_ac: ~numpy.ndarray, window: ~typing.Callable = <function window_exp>) Tuple[ndarray, ndarray]
Calculate optical (AC) conductivity from correlation function.
Reference: eqn. 300-301 of graphene note.
The unit of AC conductivity in 2d case follows: [sigma] = [1/(h_bar * omega * A)] * [j^2] * [dt]
= 1/(eV*nm^2) * e^2/h_bar^2 * (eV)^2 * nm^2 * h_bar/eV = e^2/h_bar
which is consistent with the results from Lindhard function.
The reason for nr_orbitals in the prefactor is that every electron contribute freely to the conductivity, and we have to take the number of electrons into consideration. See eqn. 222-223 of the note for more details.
- Parameters:
corr_ac – (4, nr_time_steps) complex128 array AC correlation function in 4 directions: xx, xy, yx, yy, respectively Unit should be e^2/h_bar^2 * (eV)^2 * nm^2.
window – window function for integral
- Returns:
(omegas, ac_cond) omegas: (nr_time_steps,) float64 array frequencies in eV ac_cond: (4, nr_time_steps) complex128 array ac conductivity values corresponding to omegas for 4 directions (xx, xy, yx, yy, respectively) The unit is e^2/(h_bar*nm) in 3d case and e^2/h_bar in 2d case.
- calc_dc_cond(corr_dos: ~numpy.ndarray, corr_dc: ~numpy.ndarray, window_dos: ~typing.Callable = <function window_hanning>, window_dc: ~typing.Callable = <function window_exp>) Tuple[ndarray, ndarray]
Calculate electronic (DC) conductivity at zero temperature from its correlation function.
Reference: eqn. 381 of graphene note.
The unit of DC conductivity in 2d case follows: [sigma] = [D/A] * [j^2] * [dt]
= 1/(eV*nm^2) * e^2/h_bar^2 * (eV)^2 * nm^2 * h_bar/eV = e^2/h_bar
which is consistent with the result of Lindhard function.
NOTE: the xy and yx components of conductivity are not accurate. So they will not be evaluated.
NOTE: Here we need to call analyze_corr_dos to obtain DOS, which is intended to analyze the result of calc_corr_dos by design. As in the fortran extension, the results of calc_corr_dos and calc_corr_ldos have the length of nr_time_steps+1, while that of calc_corr_dc has length of nr_time_steps. This is due to incomplete update of the source code. tbpm_dos and tbpm_ldos have been update, while other subroutines are not. So here we need to insert 1.0 to the head of corr_dos by calc_corr_dc before calling analyze_corr_dos.
- Parameters:
corr_dos – (nr_time_steps,) complex128 array dimensionless DOS correlation function
corr_dc – (2, n_energies, nr_time_steps) complex128 array DC conductivity correlation function in e^2/h_bar^2 * (eV)^2 * nm^2
window_dos – window function for DOS integral
window_dc – window function for DC integral
- Returns:
(energies, dc) energies: (n_energies,) float64 array energies in eV dc: (2, n_energies) float64 array dc conductivity values for xx and yy directions in the same unit as ac conductivity
- calc_diff_coeff(corr_dc: ~numpy.ndarray, window_dc: ~typing.Callable = <function window_exp>) Tuple[ndarray, ndarray]
Calculate diffusion coefficient form DC correlation function.
Reference: eqn. 43-44 of feature article.
The unit of diff_coeff follows: [diff_coeff] = [1/e^2] * [j^2] * [dt]
= 1/e^2 * e^2/h_bar^2 * (eV)^2 * nm^2 * h_bar/eV = eV*nm^2/h_bar
which does not depend on system dimension.
- Parameters:
corr_dc – (2, n_energies, nr_time_steps) complex128 array DC conductivity correlation function in e^2/h_bar^2 * (eV)^2 * nm^2
window_dc – window function for DC integral
- Returns:
(time, diff_coeff) time: (nr_time_steps,) float64 array time for diffusion coefficient in h_bar/eV diff_coeff: (2, n_energies, nr_time_steps) complex128 array diffusion coefficient in nm^2/(h_bar/eV)
- calc_dos(corr_dos: ~numpy.ndarray, window: ~typing.Callable = <function window_hanning>) Tuple[ndarray, ndarray]
Calculate DOS from correlation function.
Reference: eqn. 16-17 of feature article.
- The unit of dos follows:
[dos] = [C_DOS] [dt] = h_bar / eV
So possibly the formula misses a h_bar on the denominator. Anyway, the DOS is correct since it is explicitly normalized to 1.
- Parameters:
corr_dos – (nr_time_steps+1,) complex128 array dimensionless DOS correlation function
window – window function for integral
- Returns:
(energies, dos) energies: (2*nr_time_steps,) float64 array energies in eV dos: (2*nr_time_steps,) float64 array DOS in 1/eV
- calc_dyn_pol(corr_dyn_pol: ~numpy.ndarray, window: ~typing.Callable = <function window_exp_ten>) Tuple[ndarray, ndarray, ndarray]
Calculate dynamical polarization from correlation function.
Reference: https://journals.aps.org/prb/abstract/10.1103/PhysRevB.84.035439
The unit of dp in 2d case follows: [dp] = [1/A] * [C_DP] * [dt]
= 1/nm^2 * 1 * h_bar/eV = h_bar/(eV*nm^2)
which is inconsistent with the output of Lindhard! So, possibly the formula misses a h_bar on the denominator.
- Parameters:
corr_dyn_pol – (n_q_points, nr_time_steps) float64 array dimensionless dynamical polarization correlation function
window – window function for integral
- Returns:
(q_points, omegas, dyn_pol) q_points: (n_q_points, 3) float64 array Cartesian coordinates of q-points in 1/nm omegas: (nr_time_steps,) float64 array frequencies in eV dyn_pol: (n_q_points, nr_time_steps) complex128 array dynamical polarization values corresponding to q-points and omegas The unit is 1/(eV*nm^2) or 1/(eV*nm^3) depending on the dimension.
- calc_epsilon(dyn_pol: ndarray) ndarray
Calculate dielectric function from dynamical polarization.
- Parameters:
dyn_pol – (n_q_points, nr_time_steps) complex128 array dynamical polarization
- Returns:
(n_q_points, nr_time_steps) complex128 array dielectric function
- calc_epsilon_q0(omegas: ndarray, ac_cond: ndarray) ndarray
Calculate dielectric function from AC conductivity for q=0.
- Parameters:
omegas – (nr_time_steps,) float64 array energies in eV
ac_cond – (4, nr_time_steps) complex128 array AC conductivity in e**2/(h_bar*nm) in 3d case
- Returns:
(4, nr_time_steps,) complex128 array relative dielectric function
- Raises:
ValueError – if dimension is not 3
- calc_hall_cond(mu_mn: ndarray, unit: str = 'h_bar') Tuple[ndarray, ndarray]
Calculate Hall conductivity according to Kubo-Bastin formula mu_mn.
Reference: https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.114.116602
The unit of hall_cond in 2d case from eqn. 1 of the reference follows: [hall_cond] = [h_bar*e^2/Omega] * [dE * Tr<…>]
= h_bar*e^2/nm^2 * 1/eV * nm^2/h_bar^2 * eV = e^2/h_bar
which is consistent with AC and DC conductivity. Note that the delta function in the formula has the unit of 1/eV.
The unit can also be determined from enq. 4 as: [hall_cond] = [e^2*h_bar/(Omega*delaE^2)] * [mu]
= h_bar/(nm^2*V^2) * nm^2 * (eV)^2 / h_bar^2 = e^2/h_bar
Note that the scaled energy is dimensionless.
- Parameters:
mu_mn – (n_kernel, n_kernel) complex128 array output of solver.calc_hall_mu in nm^2/h_bar^2 * (eV)^2
unit – unit of Hall conductivity, set to ‘h_bar’ to use ‘e^2/h_bar’ and ‘h’ to use ‘e^2/h’
- Returns:
(energies, conductivity) energies: float64 array chemical potentials specified in config.dckb[‘energies’] conductivity: float64 array Hall conductivity according to energies
- Raises:
ValueError – if unit is neither ‘h_bar’ nor ‘h’
- calc_ldos(corr_ldos: ~numpy.ndarray, window: ~typing.Callable = <function window_hanning>) Tuple[ndarray, ndarray]
Calculate LDOS from correlation function.
- Parameters:
corr_ldos – (nr_time_steps+1,) complex128 array dimensionless LDOS correlation function
window – window function for integral
- Returns:
(energies, ldos) energies: (2*nr_time_steps,) float64 array energies in eV ldos: (2*nr_time_steps,) float64 array LDOS in 1/eV
- dist_bound(n_max: int) Tuple[int, int]
Same as dist_range, but returns the lower and upper bounds. Both of the bounds are close, i.e. [i_min, i_max].
- Parameters:
n_max – upper bound of range
- Returns:
lower and upper bounds of subrange assigned to this process
- dist_list(raw_list: List[Any], algorithm: str = 'range') List[Any]
Distribute a list over processes.
- Parameters:
raw_list – raw list to distribute
algorithm – distribution algorithm, should be either “remainder” or “range”
- Returns:
sublist assigned to this process
- dist_range(n_max: int) range
Distribute range(n_max) over processes.
- Parameters:
n_max – upper bound of the range
- Returns:
subrange assigned to this process
- log(event: str = '', fmt: str = '%x %X') None
Log the date and time of event.
- Parameters:
event – notice of the event
fmt – date and time format
- Returns:
None.
- print(text: str = '') None
Print text on master process.
NOTE: flush=True is essential for some MPI implementations, e.g. MPICH3.
- Parameters:
text – text to print
- Returns:
None
- reduce(data_local: ndarray) ndarray
Reduce local data to master process.
- Parameters:
data_local – local results on each process
- Returns:
summed data from data_local
- __weakref__
list of weak references to the object (if defined)
- property is_master: bool
Determine whether this is the master process.
- property mpi_enabled: bool
Determine whether MPI is enabled.
- property rank: int
Interface for the ‘__rank’ attribute.
- Returns:
rank of this MPI process
- property size: int
Interface for the ‘__size’ attribute.
- Returns:
number of MPI processes