Skip to content

Python interface

Mykhailo Klymenko edited this page Feb 19, 2020 · 1 revision

Below is a short example demonstrating usage of the tb package. More illustrative examples can be found in the ipython notebooks in the directory jupyter_notebooks inside the source directory.

If the package is properly installed, the work starts with the import of all necessary modules:

import tb

Below we demonstrate band structure computation for bulk silicon using empirical tight-binding method.

  1. First, one needs to specify atomic species and corresponding basis sets. It is possible to use custom basis set as is shown in examples in the ipython notebooks. Here we use predefined basis sets.

    tb.Orbitals.orbital_sets = {'Si': 'SiliconSP3D5S'}
  2. Specify geometry of the system - determine position of atoms and specify periodic boundary conditions if any. This is done by creating an object of the class Hamiltonian with proper arguments.

    xyz_file = """2
    Si cell
    Si1       0.0000000000    0.0000000000    0.0000000000
    Si2       1.3750000000    1.3750000000    1.3750000000
    """
    
    h = tb.Hamiltonian(xyz=xyz_file, nn_distance=2.0)
  3. Initialize the Hamiltonian - compute Hamiltonian matrix elements

    For isolated system:

    h.initialize()
  4. Specify periodic boundary conditions:

    a_si = 5.50
    PRIMITIVE_CELL = [[0, 0.5 * a_si, 0.5 * a_si],
                     [0.5 * a_si, 0, 0.5 * a_si],
                     [0.5 * a_si, 0.5 * a_si, 0]]
    h.set_periodic_bc(PRIMITIVE_CELL)
  5. Specify wave vectors:

    sym_points = ['L', 'GAMMA', 'X', 'W', 'K', 'L', 'W', 'X', 'K', 'GAMMA']
    num_points = [15, 20, 15, 10, 15, 15, 15, 15, 20]
    k = tb.get_k_coords(sym_points, num_points)
  6. Find the eigenvalues and eigenstates of the Hamiltonian for each wave vector.

    vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=np.complex)
    
    for jj, i in enumerate(k):
        vals[jj, :], _ = h.diagonalize_periodic_bc(list(i))
    
    import matplotlib.pyplot as plt 
    plt.plot(np.sort(np.real(vals)))
    plt.show()
  7. Done.

Clone this wiki locally