Пример #1
0
def band_structure(
    direct_space_basis,
    pseudo_fname,
    k_list_fname,
    G_norm_cutoff,
    n_bands,
    ):

    # -- get all necessary objects needed to compute the band structure
    pseudo_Gs, pseudo_coefficients = read_pseudo(pseudo_fname)
    k_vectors = read_kpoints(k_list_fname)
    reciprocal_space_basis = \
        get_reciprocal_space_elementary_vectors(direct_space_basis)
    rs_dot = get_Euclidean_dot_product(reciprocal_space_basis)

    assert pseudo_Gs.shape[0] == pseudo_coefficients.size
    assert k_vectors.shape[1] == 3

    # -- Basis of G vectors used for the matrix diagonalization
    G_basis = get_ordered_stars(reciprocal_space_basis, G_norm_cutoff)

    # -- generate potential matrix, which is k-independent
    potential_matrix = build_potential_matrix(
            G_basis, pseudo_Gs, pseudo_coefficients
            )

    # -- loop over the k points to compute the band energies
    band_energies = []
    for idx, k_vec in enumerate(k_vectors):
        kinetic_matrix = build_kinetic_matrix(k_vec, G_basis, rs_dot)
        hamiltonian = kinetic_matrix + potential_matrix
        eigvals = np.sort(eigvalsh(hamiltonian))[:n_bands]
        band_energies += [eigvals]

    # -- simple check to see if the eigenvalues are real
    band_energies = np.array(band_energies)
    assert np.abs(band_energies.imag).sum() < 1e-3

    return band_energies
Пример #2
0
def test_read_pseudo():

    filename = 'test_pseudo.dat'

    with open('test_pseudo.dat', 'w') as fin:
        fin.write('#\n')
        fin.write('3  4  5  0.2  0.1\n')
        fin.write('  4  1  87  0.99  -0.27\n')

    reference_G_vectors = np.array([
        [3, 4,  5],
        [4, 1, 87]
        ]).astype('int')

    reference_coefficients = np.array([
        0.2+0.1j, 0.99-0.27j]).astype('complex')

    G_vectors, coefficients = read_pseudo(filename)

    assert np.abs(reference_G_vectors - G_vectors).sum() < 1e-6
    assert np.abs(reference_coefficients - coefficients).sum() < 1e-6

    os.remove(filename)
    return