tbplas.CachedSample

class tbplas.CachedSample(directory: str = 'sample')

Sample with attributes loaded from disk.

_directory

directory within which the data is saved

Type:

str

_attr

dictionary containing the key-value type attributes

Type:

dict

Note

There are two cases where we need to save/load the sample. Most of the time we are just doing post-processing, and need only the essential attributes of the sample. We may also load the sample for another full TBPM run. For the former case, the attributes are loaded during initialization and reloaded in init_*. For the latter case, the attributes and arrays are loaded in init_*.

__init__(directory: str = 'sample') None
Parameters:

directory – directory within which the data is saved

Methods

__init__([directory])

apply_magnetic_field(intensity[, gauge])

Apply magnetic field perpendicular to xOy-plane to -z direction via Peierls substitution.

get_array()

Get all array attributes for sending to C++ extensions. :return: name tuple with orb_eng, orb_pos, hop_ind, hop_eng, lat_vec, dr and sc0_lat_vec as attributes.

init_array([force_init])

Interface for initializing the arrays.

init_hop([force_init])

Reserved for compatibility.

init_orb_eng([force_init])

Reserved for compatibility.

init_orb_pos([force_init])

Reserved for compatibility.

plot([fig_name, fig_size, fig_dpi, ...])

Plot lattice vectors, orbitals, and hopping terms to axes.

reset_array()

Reset all arrays.

Attributes

num_hop

Get the total number of hopping terms of the sample.

num_orb

Get the total number of orbitals of the sample.

sc0_lat_vec

Get lattice vectors of the first supercell. :return: (3, 3) float64 array Cartesian coordinates of lattice vectors in NM.

sc0_origin

Get origin of the first supercell. :return: (3, ) float64 array Cartesian coordinates of origin in NM.

__init__(directory: str = 'sample') None
Parameters:

directory – directory within which the data is saved

apply_magnetic_field(intensity: float, gauge: int = 0) None

Apply magnetic field perpendicular to xOy-plane to -z direction via Peierls substitution.

The gauge-invariant Peierls phase from R_i to R_j is evaluated as

exp[-1j * |e|/(2*h_bar*c) * (R_i - R_j) * (A_i + A_j)]

or

exp[1j * |e|/(2*h_bar*c) * (R_j - R_i) * (A_j + A_i)]

For the reference, see eqn. 10-11 of ref [1] and eqn. 19-20 of ref [2]. Be aware that ref [1] uses |e| while ref [2] uses e with sign.

For perpendicular magnetic pointing to +z, we have A = (-By, 0, 0). Then

(R_j - R_i) * (A_j + A_i) = -B * (y_j + y_i) * (x_j - x_i)

However, there isn’t the minus sign in the source code of TBPLaS. This is because we are considering a magnetic field pointing to -z.

Note that the above formulae use Gaussian units. For SI units, the speed of light vanishes. This is verified by checking the dimension under SI units:

[e]/[h_bar] = IT/(L^2 M T^-1) = L^-2 M^-1 I T^-2 [R][A] = L * (M T^-2 I^-1 L) = L^2 M I^-1 T^-2

which cancel out upon multiplication. Similarly, under Gaussian units we have: [e]/[c*h_bar] = L^(-3/2) M^(-1/2) T [R][A] = L^(3/2) M^(1/2) T which also cancel out upon multiplication.

The analysis also inspires to calculate the scaling factor in SI units as:

|e/2h_bar| = 759633724404755.2

However, we use nm for lengths. So the scaling factor should be divided by 1e18, yielding 0.0007596337244047553. That is exactly the magic number pi / 4135.666734 = 0.0007596339008078771 in the source code of TBPLaS.

Reference: [1] https://journals.aps.org/prb/pdf/10.1103/PhysRevB.51.4940 [2] https://journals.jps.jp/doi/full/10.7566/JPSJ.85.074709

Parameters:
  • intensity – magnetic B field in Tesla

  • gauge – gauge of vector potential of the magnetic field to -z 0 for (By, 0, 0), 1 for (0, -Bx, 0), 2 for (0.5By, -0.5Bx, 0)

Returns:

None

get_array() namedtuple

Get all array attributes for sending to C++ extensions. :return: name tuple with orb_eng, orb_pos, hop_ind, hop_eng, lat_vec,

dr and sc0_lat_vec as attributes

init_array(force_init: bool = False) None

Interface for initializing the arrays.

If any array is empty, build all arrays from scratch. Otherwise, build them when force_init is True.

Parameters:

force_init – whether to force initializing the arrays from scratch even if they have already been initialized

Returns:

None

init_hop(force_init: bool = False) None

Reserved for compatibility. Use init_array instead.

init_orb_eng(force_init: bool = False) None

Reserved for compatibility. Use init_array instead.

init_orb_pos(force_init: bool = False) None

Reserved for compatibility. Use init_array instead.

plot(fig_name: str = None, fig_size: Tuple[float, float] = None, fig_dpi: int = 300, with_orbitals: bool = True, with_cells: bool = True, with_conj: bool = False, orb_color: Callable[[ndarray], List[str]] = None, hop_as_arrows: bool = True, hop_eng_cutoff: float = 1e-05, hop_color: str = 'r', view: str = 'ab') None

Plot lattice vectors, orbitals, and hopping terms to axes.

Parameters:
  • fig_name – file name to which the figure will be saved

  • fig_size – width and height of the figure

  • fig_dpi – resolution of the figure file

  • with_orbitals – whether to plot orbitals as filled circles

  • with_cells – whether to plot borders of primitive cells

  • with_conj – whether to plot conjugate hopping terms as well

  • orb_color – function for coloring the orbitals

  • hop_as_arrows – whether to plot hopping terms as arrows

  • hop_eng_cutoff – cutoff for showing hopping terms

  • hop_color – color of hopping terms

  • view – kind of view point, should be in ‘ab’, ‘bc’, ‘ca’, ‘ba’, ‘cb’, ‘ac’

Returns:

None

reset_array() None

Reset all arrays. :return: None

__weakref__

list of weak references to the object

property num_hop: int

Get the total number of hopping terms of the sample. :return: total number of hopping terms

property num_orb: int

Get the total number of orbitals of the sample. :return: total number of orbitals

property sc0_lat_vec: ndarray

Get lattice vectors of the first supercell. :return: (3, 3) float64 array

Cartesian coordinates of lattice vectors in NM

property sc0_origin: ndarray

Get origin of the first supercell. :return: (3, ) float64 array

Cartesian coordinates of origin in NM