Ejemplo n.º 1
0
def test_bravais_2d_cell_pbc():
    """Verify 2D Bravais lattice and band path versus pbc information."""

    from ase.cell import Cell

    cell = Cell([[1.,0.,0.],
                 [.1,1.,0.],
                 [0.,0.,0.]])
    lat = cell.get_bravais_lattice()
    print(cell.cellpar())
    print(lat)
    assert lat.name == 'OBL'

    cell[2, 2] = 7
    lat3d = cell.get_bravais_lattice()
    print(lat3d)
    assert lat3d.name == 'MCL'
    lat2d_pbc = cell.get_bravais_lattice(pbc=[1, 1, 0])
    print(lat2d_pbc)
    assert lat2d_pbc.name == 'OBL'

    path = cell.bandpath()
    print(path)

    path2d = cell.bandpath(pbc=[1, 1, 0])
    print(path2d)
    assert path2d.cell.rank == 2
    assert path2d.cell.get_bravais_lattice().name == 'OBL'
Ejemplo n.º 2
0
def kpath(cell, path=None, npoints=None, supercell_matrix=np.eye(3), eps=1e-3):
    mycell = Cell(cell)
    bpath = mycell.bandpath(path=path, npoints=npoints, eps=eps)
    kpts = bpath.kpts
    kpts = [np.dot(kpt, supercell_matrix) for kpt in kpts]
    x, X, knames = bpath.get_linear_kpoint_axis()
    return kpts, x, X, knames
Ejemplo n.º 3
0
def _path_lengths(path: str, cell: Cell, bands_point_num: int) -> List[int]:
    # Construct the metric for reciprocal space (based off Wannier90's "utility_metric" subroutine)
    recip_lat = 2 * math.pi * cell.reciprocal().array
    recip_metric = recip_lat @ recip_lat.T

    # Work out the lengths Wannier90 will assign each path (based off Wannier90's "plot_interpolate_bands" subroutine)
    kpath_pts: List[int] = []
    kpath_len: List[float] = []
    special_points = cell.bandpath().special_points

    path_list = path_str_to_list(path, special_points)

    for i, (start, end) in enumerate(zip(path_list[:-1], path_list[1:])):
        if start == ',':
            kpath_pts.append(0)
        elif end == ',':
            kpath_pts.append(1)
        else:
            vec = special_points[end] - special_points[start]
            kpath_len.append(math.sqrt(vec.T @ recip_metric @ vec))
            if i == 0:
                kpath_pts.append(bands_point_num)
            else:
                kpath_pts.append(int(round(bands_point_num * kpath_len[-1] / kpath_len[0])))
    return kpath_pts
Ejemplo n.º 4
0
def construct_kpoint_path(path: str, cell: Cell, bands_point_num: int) -> BandPath:
    path_lengths = _path_lengths(path, cell, bands_point_num)
    special_points = cell.bandpath().special_points

    path_list = path_str_to_list(path, special_points)

    kpts = []
    for start, end, npoints in zip(path_list[:-1], path_list[1:], path_lengths):
        if start == ',':
            pass
        elif end == ',':
            kpts.append(special_points[start].tolist())
        else:
            bp = bandpath(start + end, cell, npoints + 1)
            kpts += bp.kpts[:-1].tolist()
    # Don't forget about the final kpoint
    kpts.append(bp.kpts[-1].tolist())

    if len(kpts) != sum(path_lengths) + 1:
        raise AssertionError(
            'Did not get the expected number of kpoints; this suggests there is a bug in the code')

    return BandPath(cell=cell, kpts=kpts, path=path, special_points=special_points)
Ejemplo n.º 5
0
"""Verify 2D Bravais lattice and band path versus pbc information."""

from ase.cell import Cell

cell = Cell([[1., 0., 0.], [.1, 1., 0.], [0., 0., 0.]])
lat = cell.get_bravais_lattice()
print(cell.cellpar())
print(lat)
assert lat.name == 'OBL'

cell[2, 2] = 7
lat3d = cell.get_bravais_lattice()
print(lat3d)
assert lat3d.name == 'MCL'
lat2d_pbc = cell.get_bravais_lattice(pbc=[1, 1, 0])
print(lat2d_pbc)
assert lat2d_pbc.name == 'OBL'

path = cell.bandpath()
print(path)

path2d = cell.bandpath(pbc=[1, 1, 0])
print(path2d)
assert path2d.cell.rank == 2
assert path2d.cell.get_bravais_lattice().name == 'OBL'