tbplas.Z2

class tbplas.Z2(cell: Any, num_occ: int, **kwargs)

Class for evaluating the Z2 topological invariant.

Reference: https://journals.aps.org/prb/abstract/10.1103/PhysRevB.84.075119

_num_occ

number of occupied bands of the primitive cell

Type:

int

_d_mat

D matrix for single k-point in the reference

Type:

(num_occ, num_occ) complex128 array

_f_mat

F matrix for (ka_i, ka_i+1)

Type:

(num_occ, num_occ) complex128 array

__init__(cell: Any, num_occ: int, **kwargs) None
Parameters:
  • cell – primitive cell under investigation

  • num_occ – number of occupied bands of the primitive cell

  • kwargs – arguments for DiagSolver.__init__

Raises:

ValueError – if num_occ is larger than num_orb of the primitive cell

Methods

__init__(cell, num_occ, **kwargs)

param cell:

primitive cell under investigation

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_bands(k_points[, convention, solver, ...])

Calculate band structure along given k_path.

calc_dos(k_points[, e_min, e_max, e_step, ...])

Calculate density of states for given energy range and step.

calc_phases([ka_array, kb_array, kc])

Calculate the phases of WF centers as function of kb (eqn.

calc_states(k_points[, convention, solver, ...])

Calculate energies and wave functions on k-points.

count_crossing(phases[, phase_ref])

Count the number that the phases go across a reference value.

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.

reorder_phases(phases[, threshold, smooth])

Reorder the phases to improve continuity and smoothness.

Attributes

is_master

Determine whether this is the master process.

lat_vec

Get the lattice vectors of the model.

model_is_pc

Check if the model is a primitive cell.

mpi_enabled

Determine whether MPI is enabled.

num_occ

Interface for the _num_occ attribute.

num_orb

Get the number of orbitals in the model.

rank

Interface for the '__rank' attribute.

recip_lat_vec

Get the reciprocal lattice vectors of the model in 1/nm.

size

Interface for the '__size' attribute.

__init__(cell: Any, num_occ: int, **kwargs) None
Parameters:
  • cell – primitive cell under investigation

  • num_occ – number of occupied bands of the primitive cell

  • kwargs – arguments for DiagSolver.__init__

Raises:

ValueError – if num_occ is larger than num_orb of the primitive cell

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_bands(k_points: ndarray, convention: int = 1, solver: str = 'lapack', orbital_indices: Union[Iterable[int], ndarray] = None, **kwargs) namedtuple

Calculate band structure along given k_path.

The result is a named tuple with the following attributes: k_len: (num_kpt,) float64 array, length of k-path bands: (num_kpt, num_bands) float64 array, band structure proj: (num_kpt, num_bands) float64 array, projection on selected orbitals

Parameters:
  • k_points – (num_kpt, 3) float64 array FRACTIONAL coordinates of the k-points

  • convention – convention for setting up the Hamiltonian

  • solver – solver type, should be “lapack” or “arpack”

  • orbital_indices – indices of orbitals for evaluating projection, take all orbitals into consideration if no orbitals are specified

  • kwargs – arguments for the arpack solver

Returns:

k_len, band structure and projection packed in named tuple

Raises:

ValueError – if solver is neither lapack nor arpack

calc_dos(k_points: ndarray, e_min: float = None, e_max: float = None, e_step: float = 0.05, sigma: float = 0.05, basis: str = 'Gaussian', g_s: int = 1, **kwargs) Tuple[ndarray, ndarray]

Calculate density of states for given energy range and step.

Parameters:
  • k_points – (num_kpt, 3) float64 array FRACTIONAL coordinates of k-points

  • e_min – lower bound of the energy range in eV

  • e_max – upper hound of the energy range in eV

  • e_step – energy step in eV

  • sigma – broadening parameter in eV

  • basis – basis function to approximate the Delta function

  • g_s – spin degeneracy

  • kwargs – arguments for ‘calc_bands’

Returns:

(energies, dos) energies: (num_grid,) float64 array energy grid corresponding to e_min, e_max and e_step dos: (num_grid,) float64 array density of states in states/eV

Raises:

ValueError – if basis is neither Gaussian nor Lorentzian, or the solver is neither lapack nor arpack

calc_phases(ka_array: ndarray = None, kb_array: ndarray = None, kc: float = 0.0) Tuple[ndarray, ndarray]

Calculate the phases of WF centers as function of kb (eqn. 12 of ref).

Parameters:
  • ka_array – (num_ka,) float64 array FRACTIONAL coordinates of the loop along a-axis

  • kb_array – (num_kb,) float64 array FRACTIONAL coordinates of the loop along b-axis

  • kc – float FRACTIONAL coordinate of the loop along c-axis

Returns:

(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

calc_states(k_points: ndarray, convention: int = 1, solver: str = 'lapack', all_reduce: bool = True, **kwargs) Tuple[ndarray, ndarray]

Calculate energies and wave functions on k-points.

Parameters:
  • k_points – (num_kpt, 3) float64 array FRACTIONAL coordinates of the k-points

  • convention – convention for setting up the Hamiltonian

  • solver – solver type, should be “lapack” or “arpack”

  • all_reduce – whether to call MPI_Allreduce to synchronize the results on each process

  • kwargs – arguments for the arpack solver

Returns:

(bands, states) bands: (num_kpt, num_bands) float64 array energies on the k-points states: (num_kpt, num_bands, num_orb) complex128 array wave functions on the k-points, each ROW of states[i_k] is a wave function

Raises:

ValueError – if solver is neither lapack nor arpack

static count_crossing(phases: ndarray, phase_ref: float = 0.5) int

Count the number that the phases go across a reference value.

The Z2 topological invariant is determined as num_crossing % 2.

NOTE: the phases must be CORRECTLY reordered before passing to this function. Otherwise, the crossing number will be wrong!

If the reordering algorithm fails to work by all means, then you have to plot the phases using scatter plot and count the crossing number manually.

Parameters:
  • phases – (num_kpt, num_occ) float64 array phases of WF centers

  • phase_ref – reference value

Returns:

number of crossing

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

reorder_phases(phases: ndarray, threshold: float = 0.1, smooth: bool = True) ndarray

Reorder the phases to improve continuity and smoothness.

NOTE: sometimes this method may not work properly. In that case, try to increase threshold and the density of kb_array.

Parameters:
  • phases – (num_kpt, num_occ) float64 array phases of WF centers

  • threshold – threshold for detecting discontinuity

  • smooth – whether to smooth the phases by ensuring the continuity of 1st order derivative with respect to kb

Returns:

(num_kpt, num_occ) float64 array reordered phases

__weakref__

list of weak references to the object (if defined)

property is_master: bool

Determine whether this is the master process.

property lat_vec: ndarray

Get the lattice vectors of the model.

Returns:

(3, 3) float64 array lattice vectors of in nm

property model_is_pc: bool

Check if the model is a primitive cell.

Returns:

whether the model is a primitive cell

property mpi_enabled: bool

Determine whether MPI is enabled.

property num_occ: int

Interface for the _num_occ attribute.

Returns:

number of occupied bands

property num_orb: int

Get the number of orbitals in the model.

Returns:

number of orbitals

property rank: int

Interface for the ‘__rank’ attribute.

Returns:

rank of this MPI process

property recip_lat_vec: ndarray

Get the reciprocal lattice vectors of the model in 1/nm.

Returns:

(3, 3) float64 array reciprocal lattice vectors of in nm

property size: int

Interface for the ‘__size’ attribute.

Returns:

number of MPI processes