Example #1
0
def main3():
    import sys
    sys.path.insert(0, '/home/mk/TB_project/tb')
    import tb

    a = tb.Atom('A')
    a.add_orbital('s', -0.7)

    tb.Atom.orbital_sets = {'A': a}

    tb.set_tb_params(PARAMS_A_A={'ss_sigma': -0.5},
                     PARAMS_B_B={'ss_sigma': -0.5},
                     PARAMS_A_B={'ss_sigma': -0.5},
                     PARAMS_B_C={'ss_sigma': -0.5},
                     PARAMS_A_C={'ss_sigma': -0.5})

    xyz_file = """1
    H cell
    A1       0.0000000000    0.0000000000    0.0000000000                                                                                                      
    """

    h = tb.Hamiltonian(xyz=xyz_file, nn_distance=2.1)
    h.initialize()
    h.set_periodic_bc([[0, 0, 1.0]])
    h_l, h_0, h_r = h.get_coupling_hamiltonians()

    energy = np.linspace(-3.0, 1.5, 700)

    sgf_l = []
    sgf_r = []

    for E in energy:
        L, R, _, _, _ = surface_greens_function(E, h_l, h_0, h_r)
        # L, R = surface_greens_function_poles_Shur(E, h_l, h_0, h_r)
        sgf_l.append(L)
        sgf_r.append(R)

    sgf_l = np.array(sgf_l)
    sgf_r = np.array(sgf_r)

    num_sites = h_0.shape[0]
    gf = np.linalg.pinv(
        np.multiply.outer(energy, np.identity(num_sites)) - h_0 - sgf_l -
        sgf_r)

    dos = -np.trace(np.imag(gf), axis1=1, axis2=2)

    tr = np.zeros((energy.shape[0]), dtype=np.complex)

    for j, E in enumerate(energy):
        gf0 = np.matrix(gf[j, :, :])
        gamma_l = 1j * (np.matrix(sgf_l[j, :, :]) -
                        np.matrix(sgf_l[j, :, :]).H)
        gamma_r = 1j * (np.matrix(sgf_r[j, :, :]) -
                        np.matrix(sgf_r[j, :, :]).H)
        tr[j] = np.real(np.trace(gamma_l * gf0 * gamma_r * gf0.H))
        dos[j] = np.real(np.trace(1j * (gf0 - gf0.H)))

    print(sgf_l.shape)
Example #2
0
def test_atomic_chain_two_kinds_of_atoms():
    site_energy1 = -1.0
    site_energy2 = -2.0
    coupling = -1.0
    l_const = 2.0

    a = tb.Atom('A')
    a.add_orbital(
        title='s',
        energy=site_energy1,
    )
    b = tb.Atom('B')
    b.add_orbital(
        title='s',
        energy=site_energy2,
    )

    tb.Atom.orbital_sets = {'A': a, 'B': b}

    xyz_file = """2
    H cell
    A       0.0000000000    0.0000000000    0.0000000000
    B       0.0000000000    0.0000000000    1.0000000000
    """
    tb.set_tb_params(PARAMS_A_B={'ss_sigma': coupling})
    h = tb.Hamiltonian(xyz=xyz_file, nn_distance=1.1)
    h.initialize()

    assert (h.is_hermitian(), True)

    PRIMITIVE_CELL = [[0, 0, l_const]]
    h.set_periodic_bc(PRIMITIVE_CELL)

    num_points = 10
    kk = np.linspace(0, 3.14 / 2, num_points, endpoint=True)

    band_structure = []

    for jj in range(num_points):
        vals, _ = h.diagonalize_periodic_bc([0.0, 0.0, kk[jj]])
        band_structure.append(vals)

    band_structure = np.array(band_structure)
    desired_value = np.zeros(band_structure.shape)

    b = site_energy1 + site_energy2
    c = site_energy1 * site_energy2 - (2.0 * coupling *
                                       np.cos(0.5 * kk * l_const))**2
    desired_value[:, 0] = 0.5 * (b - np.sqrt(b**2 - 4.0 * c))
    desired_value[:, 1] = 0.5 * (b + np.sqrt(b**2 - 4.0 * c))

    np.testing.assert_allclose(band_structure, desired_value, atol=1e-9)
Example #3
0
def single_atom_chain():
    """
    Test set for a single-atom chain.

    :return:
    """

    sys.path.insert(0, '/home/mk/TB_project/tb')

    a = tb.Atom('A')
    a.add_orbital('s', 0.7)
    tb.Atom.orbital_sets = {'A': a}
    tb.set_tb_params(PARAMS_A_A={'ss_sigma': 0.5})

    xyz_file = """1
    H cell
    A1       0.0000000000    0.0000000000    0.0000000000
    """

    h = tb.Hamiltonian(xyz=xyz_file, nn_distance=1.1)
    h.initialize()
    h.set_periodic_bc([[0, 0, 1.0]])
    h_l, h_0, h_r = h.get_coupling_hamiltonians()
    num_sites = h_0.shape[0]

    energy = np.linspace(-3.0, 3.0, 300)

    tr = np.zeros((energy.shape[0]))
    dos = np.zeros((energy.shape[0]))

    sgf_l = []
    sgf_r = []

    for j, E in enumerate(energy):
        se_l, se_r = tb.surface_greens_function(E, h_l, h_0, h_r)
        sgf_l.append(se_l)
        sgf_r.append(se_r)
        gf = np.linalg.pinv(E * np.identity(num_sites) - h_0 - se_l - se_r)
        gf = np.matrix(gf)
        gamma_l = 1j * (np.matrix(se_l) - np.matrix(se_l).H)
        gamma_r = 1j * (np.matrix(se_r) - np.matrix(se_r).H)
        tr[j] = np.real(np.trace(gamma_l * gf * gamma_r * gf.H))
        dos[j] = np.real(np.trace(1j * (gf - gf.H)))

    sgf_l = np.array(sgf_l)
    sgf_r = np.array(sgf_r)

    return energy, dos, tr, h, sgf_l, sgf_r
def test_gf_single_atom_chain():
    sys.path.insert(0, '/home/mk/TB_project/tb')

    a = tb.Atom('A')
    a.add_orbital('s', 0.7)
    tb.Atom.orbital_sets = {'A': a}
    tb.set_tb_params(PARAMS_A_A={'ss_sigma': 0.5})

    xyz_file = """1
    H cell
    A1       0.0000000000    0.0000000000    0.0000000000
    """

    h = tb.Hamiltonian(xyz=xyz_file, nn_distance=1.1)
    h.initialize()
    h.set_periodic_bc([[0, 0, 1.0]])
    h_l, h_0, h_r = h.get_coupling_hamiltonians()

    energy = np.linspace(-3.0, 3.0, 300)

    sgf_l = []
    sgf_r = []

    for E in energy:
        L, R = tb.surface_greens_function(E, h_l, h_0, h_r)
        sgf_l.append(L)
        sgf_r.append(R)

    sgf_l = np.array(sgf_l)
    sgf_r = np.array(sgf_r)

    num_sites = h_0.shape[0]
    gf = np.linalg.pinv(
        np.multiply.outer(energy, np.identity(num_sites)) - h_0 - sgf_l -
        sgf_r)

    np.testing.assert_allclose(sgf_l, sgf_r, atol=1e-5)
    expected = h_l * simple_chain_greens_function(energy, h_0, h_r) * h_r
    np.testing.assert_allclose(np.squeeze(sgf_r),
                               np.squeeze(expected),
                               atol=1e-5)
Example #5
0
def test_simple_atomic_chain():
    site_energy = -1.0
    coupling = -1.0
    l_const = 1.0

    a = tb.Atom('A')
    a.add_orbital(
        title='s',
        energy=-1,
    )
    tb.Atom.orbital_sets = {'A': a}

    xyz_file = """1
    H cell
    A       0.0000000000    0.0000000000    0.0000000000
    """
    tb.set_tb_params(PARAMS_A_A={'ss_sigma': -1.0})
    h = tb.Hamiltonian(xyz=xyz_file, nn_distance=1.1)
    h.initialize()

    assert (h.is_hermitian(), True)

    PRIMITIVE_CELL = [[0, 0, l_const]]
    h.set_periodic_bc(PRIMITIVE_CELL)

    num_points = 10
    kk = np.linspace(0, 3.14 / l_const, num_points, endpoint=True)

    band_structure = []

    for jj in range(num_points):
        vals, _ = h.diagonalize_periodic_bc([0.0, 0.0, kk[jj]])
        band_structure.append(vals)

    band_structure = np.array(band_structure)

    desired_value = site_energy + 2 * coupling * np.cos(l_const * kk)
    np.testing.assert_allclose(band_structure,
                               desired_value[:, np.newaxis],
                               atol=1e-9)
Example #6
0
def main():

    from tb.aux_functions import get_k_coords

    path_to_xyz_file = """2
                              Bilayer Bismuth
                              Bi   -2.164513   -1.249682  1.73744 
                              Bi   0.0    0.0    0.0
                           """

    path_to_xyz_file = """2
                              Bilayer Bismuth
                              Bi   -2.2666 -1.30862212 -1.59098161
                              Bi   0.0    0.0    0.0
                           """

    # path_to_pdf_file = '../band_structure_of_bulk_bismuth.pdf'
    species = 'Bi'
    basis_set = 'Bismuth'
    sym_points = ['M', 'GAMMA', 'K']
    # sym_points = ['GAMMA', 'GAMMA']

    num_points = [40, 40]
    # num_points = [1]
    indices_of_bands = range(0, 16)

    primitive_cell = data_bi_bilayer.cell

    Atom.orbital_sets = {species: bi}

    tb.set_tb_params(PARAMS_BI_BI1=data_bi_bilayer.PARAMS_BI_BI1,
                     PARAMS_BI_BI2=data_bi_bilayer.PARAMS_BI_BI2,
                     PARAMS_BI_BI3=data_bi_bilayer.PARAMS_BI_BI3)

    k_points = get_k_coords(sym_points, num_points,
                            data_bi_bilayer.SPECIAL_K_POINTS_BI)

    list_of_spin_orbit_couplings = [1.8]
    # list_of_spin_orbit_couplings = np.linspace(0, 3.0, 40)

    band_structure = []
    for ii, item in enumerate(list_of_spin_orbit_couplings):

        h = Hamiltonian(xyz=path_to_xyz_file,
                        nn_distance=4.7,
                        so_coupling=item)
        h.initialize(radial_dep)
        h.set_periodic_bc(primitive_cell)
        # plot_atom_positions1(h, h.ct.virtual_and_interfacial_atoms, radial_dep)

        for jj, item in enumerate(k_points):
            # h = Hamiltonian(xyz=path_to_xyz_file, nn_distance=5.6)
            # h.initialize(radial_dep)
            # h.set_periodic_bc(primitive_cell, radial_dep)data_bi_bulk.py
            # data_bi_bilayer.LAMBDA = list_of_spin_orbit_couplings[ii]
            [eigenvalues, _] = h.diagonalize_periodic_bc(k_points[jj])
            band_structure.append(eigenvalues)

    band_structure = np.array(band_structure)

    ax = plt.axes()
    ax.plot(band_structure[:, indices_of_bands])
    ax.set_xlabel("")
    ax.set_ylabel("Energy (eV)")
    ax.set_title("")
    plt.tight_layout()
    plt.ylim((-2, 2))
    plt.show()
def test_gf_complex_chain():
    sys.path.insert(0, '/home/mk/TB_project/tb')

    a = tb.Atom('A')
    a.add_orbital('s', -0.7)
    b = tb.Atom('B')
    b.add_orbital('s', -0.5)
    c = tb.Atom('C')
    c.add_orbital('s', -0.3)

    tb.Atom.orbital_sets = {'A': a, 'B': b, 'C': c}

    tb.set_tb_params(PARAMS_A_A={'ss_sigma': -0.5},
                     PARAMS_B_B={'ss_sigma': -0.5},
                     PARAMS_A_B={'ss_sigma': -0.5},
                     PARAMS_B_C={'ss_sigma': -0.5},
                     PARAMS_A_C={'ss_sigma': -0.5})

    xyz_file = """4
    H cell
    A1       0.0000000000    0.0000000000    0.0000000000
    B2       0.0000000000    0.0000000000    1.0000000000
    A2       0.0000000000    1.0000000000    0.0000000000
    B3       0.0000000000    1.0000000000    1.0000000000
    """

    h = tb.Hamiltonian(xyz=xyz_file, nn_distance=1.1)
    h.initialize()
    h.set_periodic_bc([[0, 0, 2.0]])
    h_l, h_0, h_r = h.get_coupling_hamiltonians()

    energy = np.linspace(-3.0, 1.5, 700)

    sgf_l = []
    sgf_r = []

    for E in energy:
        L, R = tb.surface_greens_function(E, h_l, h_0, h_r)
        sgf_l.append(L)
        sgf_r.append(R)

    sgf_l = np.array(sgf_l)
    sgf_r = np.array(sgf_r)

    num_sites = h_0.shape[0]
    gf = np.linalg.pinv(
        np.multiply.outer(energy, np.identity(num_sites)) - h_0 - sgf_l -
        sgf_r)

    tr = np.zeros((energy.shape[0]))
    dos = np.zeros((energy.shape[0]))

    for j, E in enumerate(energy):
        gf0 = np.matrix(gf[j, :, :])
        gamma_l = 1j * (np.matrix(sgf_l[j, :, :]) -
                        np.matrix(sgf_l[j, :, :]).H)
        gamma_r = 1j * (np.matrix(sgf_r[j, :, :]) -
                        np.matrix(sgf_r[j, :, :]).H)
        tr[j] = np.real(np.trace(gamma_l * gf0 * gamma_r * gf0.H))
        dos[j] = np.real(np.trace(1j * (gf0 - gf0.H)))

    np.testing.assert_allclose(dos, expected_dos_of_complex_chain(), atol=1e-5)
    np.testing.assert_allclose(tr, expected_tr_of_complex_chain(), atol=1e-5)