tbplas.SpinTexture
- class tbplas.SpinTexture(cell: Any, k_grid: ndarray, spin_major: bool = True, **kwargs)
Spin texture calculator.
- _k_grid
FRACTIONAL coordinates of k-points
- Type:
(num_kpt, 3) float64 array
- _spin_major
whether the orbitals are stored in spin-major order
- Type:
bool
- _states
cache of wave functions
- Type:
(num_kpt, num_orb) complex128 array
- _hash_k
hash of k-grid
- Type:
int
- __init__(cell: Any, k_grid: ndarray, spin_major: bool = True, **kwargs) None
- Parameters:
cell – primitive cell for which properties will be evaluated
k_grid – FRACTIONAL coordinates of k-points
spin_major – whether the orbitals are stored in spin-major order
kwargs – arguments for DiagSolver.__init__
Methods
__init__
(cell, k_grid[, spin_major])- param cell:
primitive cell for which properties will be evaluated
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_states
(k_points[, convention, solver, ...])Calculate energies and wave functions on k-points.
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.
eval
([component])Calculate the expectation of Pauli matrix.
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.
split_spin
(state)Split spin-up and spin-down components for wave function at given k-point and band.
Update wave functions on self._k_grid.
Attributes
Determine whether this is the master process.
Get CARTESIAN coordinates of k-grid.
Interface for the _k_grid attribute.
Get the lattice vectors of the model.
Check if the model is a primitive cell.
Determine whether MPI is enabled.
Get the number of orbitals in the model.
Interface for the '__rank' attribute.
Get the reciprocal lattice vectors of the model in 1/nm.
Interface for the '__size' attribute.
- __init__(cell: Any, k_grid: ndarray, spin_major: bool = True, **kwargs) None
- Parameters:
cell – primitive cell for which properties will be evaluated
k_grid – FRACTIONAL coordinates of k-points
spin_major – whether the orbitals are stored in spin-major order
kwargs – arguments for DiagSolver.__init__
- 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_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
- 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
- eval(component: str = 'z') ndarray
Calculate the expectation of Pauli matrix.
- Parameters:
component – which Pauli matrix to evaluate
- Returns:
(num_kpt, num_orb) float64 array expectation of Pauli matrix
- 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
- split_spin(state: ndarray) Tuple[ndarray, ndarray]
Split spin-up and spin-down components for wave function at given k-point and band.
Two kinds of orbital orders are implemented: spin major: psi_{0+}, psi_{1+}, psi_{0-}, psi_{1-} orbital major: psi_{0+}, psi_{0-}, psi_{1+}, psi_{1-}
If the orbitals are sorted in neither spin nor orbital major, derive a new class from SpinTexture and overwrite this method.
- Parameters:
state – (num_orb,) complex128 array wave function at given k-point and band
- Returns:
(u, d) u: (num_orb//2,) complex128 array d: (num_orb//2,) complex128 array spin-up and spin-down components of the wave function
- update_states() None
Update wave functions on self._k_grid.
- Returns:
None
- __weakref__
list of weak references to the object (if defined)
- property is_master: bool
Determine whether this is the master process.
- property k_cart: ndarray
Get CARTESIAN coordinates of k-grid.
- Returns:
(num_kpt, 3) float64 array Cartesian coordinates of k-grid in 1/nm.
- property k_grid: ndarray
Interface for the _k_grid attribute.
- Returns:
(num_kpt, 3) float64 array Fractional coordinates of k-grid
- 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_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