Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 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
Ejemplo n.º 4
0
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)
Ejemplo n.º 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)
Ejemplo n.º 6
0
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)