tbplas.Solver

class tbplas.Solver(sample: Sample, config: Config, enable_mpi: bool = False, echo_details: bool = True, **kwargs)

Wrapper class over FORTRAN TBPM subroutines.

_sample

sample for which TBPM calculations will be performed

Type:

‘Sample’ instance

_config

parameters controlling TBPM calculation

Type:

‘Config’ instance

output['directory']

Output directory. Default value: “sim_data”.

Type:

str

output['prefix']

Prefix prepended to the output files. Default value: timestamp.

Type:

str

output['corr_AC']

AC conductivity correlation output file. Default value: f”sim_data/{timestamp}.corr_AC”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['corr_DC']

DC conductivity correlation output file. Default value: f”sim_data/{timestamp}.corr_DC”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['corr_DOS']

DOS correlation output file. Default value: f”sim_data/{timestamp}.corr_DOS”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['corr_LDOS']

LDOS correlation output file. Default value: f”sim_data/{timestamp}.corr_LDOS”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['corr_dyn_pol']

AC conductivity correlation output file. Default value: f”sim_data/{timestamp}.corr_dyn_pol”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['hall_mu']

mu_{mn} output file. Default value: f”sim_data/{timestamp}.hall_mu”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['qe']

Quasi-eigenstates output file. Default value: f”sim_data/{timestamp}.qe”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['ldos_haydock']

LDOS output file from Haydock method. Default value: f”sim_data/{timestamp}.ldos_haydock”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

output['psi_t']

Time-dependent wave function output file. Default value: f”sim_data/{timestamp}.psi_t”. The actual output file will have a suffix of ‘npy’ or ‘h5’ depending on the output format.

Type:

str

__init__(sample: Sample, config: Config, enable_mpi: bool = False, echo_details: bool = True, **kwargs) None
Parameters:
  • sample – sample for which TBPM calculations will be performed

  • config – parameters controlling TBPM calculations

  • enable_mpi – whether to enable parallelism using MPI

  • echo_details – whether to output parallelization details

  • kwargs – arguments for ‘set_output’

Raises:

ValueError – if illegal parameters are detected in config

Methods

__init__(sample, config[, enable_mpi, ...])

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_corr_ac_cond()

Calculate correlation function of optical (AC) conductivity.

calc_corr_dc_cond()

Calculate correlation function of electronic (DC) conductivity.

calc_corr_dos()

Calculate correlation function of density of states (DOS).

calc_corr_dyn_pol()

Calculate correlation function of dynamical polarization.

calc_corr_ldos()

Calculate correlation function of local density of states (DOS).

calc_hall_mu()

Calculate mu_{mn} required for the evaluation of Hall conductivity using Kubo-Bastin formula.

calc_ldos_haydock()

Calculate local density of states (LDOS) using Haydock recursion method.

calc_psi_t(psi_0, time_log[, dt_scale, ...])

Calculate propagation of wave function from given initial state.

calc_quasi_eigenstates([save_data])

Calculate quasi-eigenstates.

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.

save_config([filename])

Save self.config to a .pkl file.

set_output([directory, prefix])

Setup directory and file names for output.

Attributes

is_master

Determine whether this is the master process.

mpi_enabled

Determine whether MPI is enabled.

rank

Interface for the '__rank' attribute.

size

Interface for the '__size' attribute.

__init__(sample: Sample, config: Config, enable_mpi: bool = False, echo_details: bool = True, **kwargs) None
Parameters:
  • sample – sample for which TBPM calculations will be performed

  • config – parameters controlling TBPM calculations

  • enable_mpi – whether to enable parallelism using MPI

  • echo_details – whether to output parallelization details

  • kwargs – arguments for ‘set_output’

Raises:

ValueError – 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_corr_ac_cond() ndarray

Calculate correlation function of optical (AC) conductivity.

Returns:

(4, nr_time_steps) complex128 array AC correlation function in 4 directions: xx, xy, yx, yy, respectively Unit is e^2/h_bar^2 * (eV)^2 * nm^2.

calc_corr_dc_cond() Tuple[ndarray, ndarray]

Calculate correlation function of electronic (DC) conductivity.

Returns:

(corr_dos, corr_dc) 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

calc_corr_dos() ndarray

Calculate correlation function of density of states (DOS).

Returns:

(nr_time_steps+1,) complex128 array dimensionless DOS correlation function

calc_corr_dyn_pol() ndarray

Calculate correlation function of dynamical polarization.

Returns:

(n_q_points, nr_time_steps) float64 array dimensionless Dynamical polarization correlation function.

calc_corr_ldos() ndarray

Calculate correlation function of local density of states (DOS).

Returns:

(nr_time_steps+1,) complex128 array dimensionless LDOS correlation function

calc_hall_mu() ndarray

Calculate mu_{mn} required for the evaluation of Hall conductivity using Kubo-Bastin formula.

Reference: https://journals.aps.org/prl/pdf/10.1103/PhysRevLett.114.116602

Returns:

(n_kernel, n_kernel) complex128 array mu_{mn} in eqn. 4 in the reference paper, which will be utilized to evaluate Hall conductivity using Kubo-Bastin formula n_kernel = self.config.dckb[“n_kernel”] Unit is nm^2/h_bar^2 * (eV)^2.

calc_ldos_haydock() Tuple[ndarray, ndarray]

Calculate local density of states (LDOS) using Haydock recursion method.

CAUTION: this method works for only one site. Although it can be adopted to deal with multiple sites, the time usage will be unaffordable. Use TBPM instead if you want to calculate LDOS for multiple sites.

Ref: https://journals.jps.jp/doi/10.1143/JPSJ.80.054710

Returns:

(energies, ldos) energies: (2*nr_time_steps+1,) float64 array energies in eV ldos: (2*nr_time_steps+1,) float64 array LDOS value to corresponding energies in 1/eV

Raises:

RuntimeError – if more than 1 mpi process is used

calc_psi_t(psi_0: ndarray, time_log: ndarray, dt_scale: float = 1.0, save_data: bool = False) ndarray

Calculate propagation of wave function from given initial state.

NOTES: a demo of nr_time_steps and time_log nr_time_steps: 1, 2, 3, 4, 5, 6, 7, 8

time_log: 0, 1, 2, 3, 4, 5, 6, 7, 8

Parameters:
  • psi_0 – (num_orb_sample,) complex128 array expansion coefficients of initial wave function

  • time_log – (num_time,) int64 array steps on which time the time-dependent wave function will be logged For example, t=0 stands for the initial wave function, while t=1 indicates the wave function AFTER the 1st propagation.

  • dt_scale – scale factor for the time step with respect to the default value

  • save_data – whether to save time-dependent wave function

Returns:

(num_time, num_orb_sample) complex128 array time-dependent wave function according to time_log

Raises:
  • RuntimeError – if more than 1 mpi process is used

  • ValueError – if any time in time_log not in [0, nr_time_steps].

calc_quasi_eigenstates(save_data: bool = False) ndarray

Calculate quasi-eigenstates.

Parameters:

save_data – whether to save quasi-eigenstates

Returns:

(n_energies, n_indptr-1) float64 array Quasi-eigenstates of the sample states[i, :] is a quasi-eigenstate at energy of config.quasi_eigenstates[‘energies’][i].

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

save_config(filename: str = 'config.pkl') None

Save self.config to a .pkl file.

Parameters:

filename – file name of the .pkl file

Returns:

None

set_output(directory: str = 'sim_data', prefix: str = None) None

Setup directory and file names for output.

Parameters:
  • directory – directory for writing files

  • prefix – prefix prepended to output files

Returns:

None

__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