API Reference

Analyzer(info_name[, echo_details])

Class for analyzing correlation functions.

Berry(model[, overlap, echo_details])

Berry curvature and Chern number calculator.

BerryData(prefix)

Data class of Berry connection and curvature.

CachedSample([directory])

Sample with attributes loaded from disk.

ConfigParser(file_name)

Parser for *_config.dat and *_info.dat

DiagConfig()

Class for representing Diagonalization parameters.

DiagSolver(model[, overlap, echo_details])

Base class for solvers based on exact diagonalization.

GeneralOrbitalMap()

Helper class for converting orbital indices between pc and sc representations in general cases.

HopDict(num_orb)

Class for holding hopping terms in matrix form, reserved for compatibility with old version of TBPlaS.

JobInfo(file_name)

Container of parameters produced by TBPM calculations.

Lindhard(model[, overlap, echo_details])

Lindhard function calculator.

MPIEnv([echo_details])

Wrapper over MPI4PY APIs.

PCHopNotFoundError(hop_ind)

Exception for a non-existing Hopping term.

PCInterHopping(pc_bra, pc_ket)

Class for holding hopping terms between different primitive cells in hetero-structure.

ParamFit(k_points[, weights])

Class for fitting on-site energies and hopping parameters to reference band data.

PrimitiveCell([lat_vec, origin, unit])

Class for representing the primitive cell.

ProgressBar(num_tasks[, num_scales])

Class for reporting the progress for a time-consuming task.

RegularOrbitalMap(dim, num_orb_pc)

Similar to GeneralOrbitalMap, but the orbitals are generated using a 4-fold loops over dim_a, dim_b, dim_c and num_orb_pc.

RegularOrbitalMapVac(dim, num_orb_pc, ...)

Similar to RegularOrbitalMap, but can handle cases with vacancies.

SCInterHopping(sc_bra, sc_ket)

Container class for hopping terms between different supercells within the sample.

SK()

Class for evaluating hopping integrals using Slater-Koster formula.

SOC()

Class for evaluating spin-orbital coupling terms.

SOCTable()

Hard-coded spin-orbital coupling term table, generated using the 'print_soc_table' method of 'SOC' class.

SOCTable2()

Hard-coded spin-orbital coupling term table, taking from https://journals.aps.org/prb/abstract/10.1103/PhysRevB.82.245412

Sample(*args)

Combination of SuperCell and SCInterHopping.

SpinData(prefix)

Data class of spin texture.

SpinTexture(model[, overlap, echo_details])

Spin texture calculator.

SuperCell(prim_cell, dim[, pbc, check_dim, ...])

Class for representing a supercell from which the sample is constructed.

TBPMConfig()

Class for representing TBPM parameters.

TBPMSolver(model[, echo_details])

Wrapper class over C++ TBPM subroutines.

TestHelper(tester)

Helper class that makes unittest easier.

Timer()

Class for measuring the time usage of function calls within programs.

Visualizer([echo_details])

Class for quick data visualization.

Z2(model[, overlap, echo_details])

Class for evaluating the Z2 topological invariant.

calc_bands(model, k_path, **kwargs)

Function for quick calculation of band structure.

calc_dos(model, k_points, **kwargs)

Function for quick calculation of dos.

cart2frac(lat_vec, cart_coord[, origin])

Convert Cartesian coordinates to fractional coordinates. :param lat_vec: (3, 3) float64 array Cartesian coordinates of lattice vectors, with each ROW being a vector :param cart_coord: (num_coord, 3) float64 array Cartesian coordinates to convert :param origin: (3, ) float64 array Cartesian coordinate of lattice origin :return: (num_coord, 3) float64 array fractional coordinates in basis of lattice vectors.

cart2frac_s(lat_vec, cart_coord[, origin])

Convert a single Cartesian coordinate to fractional. :param lat_vec: (3, 3) float64 array Cartesian coordinates of lattice vectors, with each ROW being a vector :param cart_coord: (3, ) float64 array Cartesian coordinate to convert :param origin: (3, ) float64 array Cartesian coordinate of lattice origin :return: (3, ) float64 array fractional coordinate in basis of lattice vectors.

extend_prim_cell(prim_cell[, dim])

Extend primitive cell along a, b and c directions.

find_neighbors(cell_bra[, cell_ket, a_max, ...])

Find neighbours between the (0, 0, 0) cell of model_bra and nearby cells of cell_ket up to given cutoff distance.

flatten_matrix(data)

Convert matrix with only one ROW or COLUMN to a ROW vector. :param data: (1, num_col) or (num_row, 1) array matrix to convert :return: (num_col, ) or (num_row, ) vector.

frac2cart(lat_vec, frac_coord[, origin])

Convert fractional coordinates to Cartesian coordinates. :param lat_vec: (3, 3) float64 array Cartesian coordinates of lattice vectors, with each ROW being a vector :param frac_coord: (num_coord, 3) float64 array fractional coordinates to convert in basis of lattice vectors :param origin: (3, ) float64 array Cartesian coordinate of lattice origin :return: (num_coord, 3) float64 array Cartesian coordinates converted from fractional coordinates.

frac2cart_s(lat_vec, frac_coord[, origin])

Convert a single fractional coordinate to Cartesian. :param lat_vec: (3, 3) float64 array Cartesian coordinates of lattice vectors, with each ROW being a vector :param frac_coord: (3, ) float64 array fractional coordinate to convert in basis of lattice vectors :param origin: (3, ) float64 array Cartesian coordinate of lattice origin :return: (3, ) float64 array Cartesian coordinate converted from fractional coordinate.

gen_kdist(lat_vec, kpoints)

Convert k_path generated by gen_path into distances in reciprocal space. :param lat_vec: (3, 3) float64 array Cartesian coordinates of lattice vectors, with each ROW being a vector :param kpoints: (nk, 3) float64 array fractional coordinates of kpoints :return: (nk, ) float64 array distance in reciprocal space in unit of reciprocal lattice vectors.

gen_kmesh(grid_size)

Generate uniform mesh grid in the first Brillouin zone. :param grid_size: (na, nb, nc) dimension of mesh grid along three directions :return: (na*nb*nc, 3) float64 array fractional coordinates of kpoints in the grid.

gen_kpath(hs_kpoints, num_interp)

Generate path in the reciprocal space connecting highly symmetric k-points. :param hs_kpoints: (nk, 3) float64 array fractional coordinates of highly symmetric k-points :param num_interp: (nk-1, ) tuple of integers numbers of intermediate k-points between two highly symmetric k-points :return: (kpath, hs_index) kpath: (sum(num_interp)+1, 3) float64 array fractional coordinates of k-points along the path hs_index: (nk, ) int32 array indices of highly symmetric k-points in kpath.

gen_lattice_vectors([a, b, c, alpha, beta, ...])

Generate lattice vectors from given lattice parameters.

gen_reciprocal_vectors(lat_vec)

Generate reciprocal lattice vectors from real-space lattice vectors.

gen_seeds(num_seeds)

Generate a list of random numbers from /dev/urandom as seeds for Python random number generator.

get_datetime([fmt])

Return current date and time.

get_lattice_area(lat_vec[, direction])

Calculate the area along given direction. :param lat_vec: (3, 3) float64 array Cartesian coordinates of lattice vectors, with each ROW being a vector :param direction: direction along which the area is evaluated, should be in ("a", "b", "c") :return: area along given direction in squared unit of lattice vectors.

get_lattice_volume(lat_vec)

Calculate the volume formed by lattice vectors. :param lat_vec: (3, 3) float64 array Cartesian coordinates of lattice vectors, with each ROW being a vector :return: lattice volume in cubic unit of lattice vectors.

get_qe_indices(config, energies)

Get the indices of quasi-eigenstates in energies, for calculating and analyzing DC conductivity. :param config: 'Config' instance parameters controlling TBPM calculation :param energies: (num_eng,) float64 array energies corresponding to TBPM steps, for indexing the quasi-eigenstates :return: indices of the quasi-eigenstates.

h5_load_complex(file_name, key[, transpose, ...])

Load a double complex matrix from hdf5 file.

h5_load_double(file_name, key[, transpose, ...])

Load a double matrix from hdf5 file.

h5_repack_directory([dir_name])

Repack all h5 files under given directory.

h5_repack_file(file_name)

Repack h5 file after shrinking dataset to free disk usage.

load_ac_cond(prefix[, data_name])

Load AC Conductivity from file. :param prefix: prefix of data file :param data_name: name of data file :return: (omegas, ac_cond) omegas: (num_omega,) float64 array energies in eV ac_cond: (num_omega,) complex128 array AC conductivity in e**2/(hbar*nm) in 3d case and e**2/hbar in 2d case.

load_bands(prefix[, data_name])

Load band structure. :param prefix: prefix of data file :param data_name: name of data file :return: (k_len, bands) k_len: (num_kpt,) float64 array, length of k-path bands: (num_kpt, num_bands) float64 array, band structure.

load_berry(prefix[, data_name])

Load Berry curvature. :param prefix: prefix of data files :param data_name: name of data file :return: (kpt_cart, bands, omega_xy) kpt_cart: (num_kpt, 3) float64 array Cartesian coordinates of k-points bands: (num_kpt, num_states) float64 array energies in eV omega_xy: (num_kpt, num_states) float64 array Berry curvature in NM^2.

load_corr_ac_cond(prefix[, data_name])

Load AC Conductivity correlation function. :param prefix: prefix of data file :param data_name: name of data file :return: (4, num_steps) complex128 array AC correlation function along xx, yx, xy, yy directions Unit is e^2/h_bar^2 * (eV)^2 * nm^2.

load_corr_bands(prefix[, data_name])

Load band structure correlation function. :param prefix: prefix of data file :param data_name: name of data file :return: (k_len, corr_bands) k_len: (num_kpt, ) float64 array length of kpath in 1/nm corr_bands: (num_kpt, num_steps+1) complex128 array correlation for each k-point.

load_corr_dc_cond(prefix[, data_name])

Load DC conductivity correlation function. :param prefix: prefix of data file :param data_name: name of data file :return: (corr_dos, corr_dc_cond) corr_dos: (num_steps,) complex128 array dimensionless DOS correlation function corr_dc_cond: (2, num_eng, num_steps_dc) complex128 array DC conductivity correlation function in e^2/h_bar^2 * (eV)^2 * nm^2 in accordance with config.dckb_energies.

load_corr_dos(prefix[, data_name])

Load DOS correlation function. :param prefix: prefix of data file :param data_name: name of data file :return: (num_steps+1, ) complex128 array dimensionless DOS correlation function.

load_corr_dyn_pol(prefix[, data_name])

Load dynamic polarizability correlation function. :param prefix: prefix of data file :param data_name: name of data file :return: (num_qpt, num_steps) float64 array dimensionless Dynamical polarization correlation function.

load_dos(prefix[, data_name])

Load DOS. :param prefix: prefix of data file :param data_name: name of data file :return: (energies, dos) energies: (num_eng,) float64 array energies determined by e_min, e_max and e_step dos: (num_eng,) float64 array density of states in states/eV.

load_dyn_pol(prefix[, data_name])

Load dynamic polarizability from file. :param prefix: prefix of data file :param data_name: name of data file :return: (omegas, dyn_pol) omegas: (num_omega,) float64 array energies in eV dyn_pol: (num_qpt, num_omega) complex128 array dynamic polarizability in 1/(eV*nm**2) or 1/(eV*nm**3).

load_epsilon(prefix[, data_name])

Load dielectric function from file. :param prefix: prefix of data file :param data_name: name of data file :return: (omegas, epsilon) omegas: (num_omega,) float64 array energies in eV epsilon: (num_qpt, num_omega) complex128 array relative dielectric function.

load_hall_cond(prefix[, data_name])

Load LDOS data produced by Haydock method. :param prefix: prefix of data file :param data_name: name of data file :return: (energies, conductivity) energies: (num_eng, ) float64 array chemical potentials specified in config.dckb_energies conductivity: (num_eng, ) float64 array Hall conductivity according to energies.

load_ldos_haydock(prefix[, data_name])

Load LDOS data produced by Haydock method. :param prefix: prefix of data file :param data_name: name of data file :return: (energies, ldos) energies: (2*num_steps+1, ) float64 array energies in eV ldos: (2*num_steps+1, ) float64 array LDOS value to corresponding energies in 1/eV.

load_quasi_eigen(prefix[, data_name])

Load squared quasi-eigenstates. :param prefix: prefix of data file :param data_name: name of data file :return: (num_qe, num_orb) float64 array Each row is a squared quasi-eigenstate at energy of config.qe_energies.

load_spin(prefix[, data_name])

Load spin data. :param prefix: prefix of data files :param data_name: name of data file :return: (kpt_cart, bands, sigma_x, sigma_y, sigma_z) kpt_cart: (num_kpt, 3) bands: (num_kpt, num_states) sigma_* (num_kpt, num_states).

load_states(prefix)

Load eigenvalues and eigenstates. :param prefix: prefix of data files :return: (bands, states) bands: (num_kpt, num_bands) float64 array band structure states: (num_kpt, num_bands, num_orb) complex128 array eigenstates at each k-point, with each ROW being a state.

load_wft(prefix[, data_name])

Load wave function. :param prefix: prefix of data file :param data_name: name of data file :return: (num_time, num_orb) complex128 array Each row is time-dependent wave function at config.wft_time_save.

load_z2(prefix[, data_name])

Load Z2 data. :param prefix: prefix of data file :param data_name: name of data file :return: (kb_array, phases) kb_array: (num_kb,) float64 array FRACTIONAL coordinates of the loop along b-axis phases: (num_kpt, num_occ) float64 array phases of WF centers.

make_antimonene([with_soc, soc_lambda, c])

Make antimonene primitive cell.

make_bismuth()

Make bilayer bismuth primitive cell.

make_black_phosphorus([c])

Make black phosphorus primitive cell.

make_graphene_diamond([c, t])

Make graphene primitive cell in diamond shape.

make_graphene_rect([from_scratch, c, t])

Make graphene cell in rectangular shape.

make_graphene_soc([is_qsh])

Set up the primitive cell of graphene according to Kane-Mele model.

make_graphene_sp([c])

Make 8-band graphene primitive cell.

make_hetero_layer(prim_cell, hetero_lattice, ...)

Make one layer in the hetero-structure by reshaping primitive cell to given lattice vectors. :param prim_cell: primitive cell of the layer :param hetero_lattice: (3, 3) float64 array Cartesian coordinates of hetero-structure lattice vectors in NANOMETER :param kwargs: arguments for 'reshape_prim_cell' :return: layer in the hetero-structure.

make_mos2_soc()

Make MoS2 primitive cell with SOC.

make_tmdc([material])

Make TMDC primitive cell.

merge_prim_cell(*args)

Merge primitive cells and inter-hopping dictionaries to build a large primitive cell. :param args: primitive cells and inter-hopping terms within the large primitive cell :return: merged primitive cell.

mpienv_finalize()

Finalize MPI environment.

mpienv_init()

Initialize MPI environment.

np_load_complex(file_name[, transpose, flatten])

Load a double complex matrix from text file.

np_load_double(file_name[, transpose, flatten])

Load a double matrix from text file.

print_banner_block(text[, width, mark, end])

Print a banner like #----------------------------------# # FOO # #----------------------------------# to stdout.

print_banner_line(text[, width, mark, end])

Print a banner like '#--------------- FOO ---------------#' to stdout.

reshape_prim_cell(prim_cell, lat_frac[, delta])

Reshape primitive cell to given lattice vectors. :param prim_cell: primitive cell from which the reshaped cell is constructed :param lat_frac: (3, 3) float64 array FRACTIONAL coordinates of lattice vectors of reshaped cell in basis vectors of primitive cell :param delta: small displacement added to orbital positions such that orbitals fall on cell borders will not be clipped :return: reshaped cell.

rotate_coord(coord[, angle, axis, center])

Rotate Cartesian coordinates according to Euler angles.

spiral_prim_cell(prim_cell[, angle, center, ...])

Rotate and shift primitive cell with respect to z-axis, reserved for compatibility. :param prim_cell: primitive cell to twist :param angle: twisting angle in RADIANs, NOT degrees :param center: (3, ) float64 array Cartesian coordinates of the rotation center in NANOMETER :param shift: distance of shift in NANOMETER :return: None.

split_list(raw_list, num_group[, algorithm])

Split given list into different groups.

split_range(n_max[, num_group])

Split range(n_max) into different groups.

wan2pc([seed_name, correct_hop, hop_eng_cutoff])

Create primitive cell from output of Wannier90. :param seed_name: seed_name of Wannier90 output files :param correct_hop: whether to correct hopping terms using data in seed_name_wsvec.dat :param hop_eng_cutoff: energy cutoff for hopping terms in eV Hopping terms with energy below this threshold will be dropped. :return: primitive cell created from Wannier90 output files :raise FileNotFoundError: if seed_name_wsvec.dat is not found.

window_exp(i, tnr)

Exponential window function.

window_exp_ten(i, tnr)

Exponential window function with base 10.

window_hanning(i, tnr)

Hanning window function.

write_item(f, key, value)

Write key, value pairs to file.