예제 #1
0
def _get_kpts(atoms, **params):
    """Converts top-level 'kpts' argument to native keywords"""
    kpts = params.get('kpts')
    if kpts is None:
        return params

    nwpw = params.get('nwpw', dict())

    if 'monkhorst-pack' in nwpw or 'brillouin_zone' in nwpw:
        raise ValueError("Redundant k-points specified!")

    if isinstance(kpts, KPoints):
        nwpw['brillouin_zone'] = kpts.kpts
    elif isinstance(kpts, dict):
        if kpts.get('gamma', False) or 'size' not in kpts:
            nwpw['brillouin_zone'] = kpts2kpts(kpts, atoms).kpts
        else:
            nwpw['monkhorst-pack'] = ' '.join(map(str, kpts['size']))
    elif isinstance(kpts, np.ndarray):
        nwpw['brillouin_zone'] = kpts
    else:
        nwpw['monkhorst-pack'] = ' '.join(map(str, kpts))

    params['nwpw'] = nwpw
    return params
예제 #2
0
def test_kpts2kpts(lat):
    print()
    print(lat)
    bandpath = lat.bandpath()
    a = Atoms()
    a.cell = lat.tocell().complete()
    a.pbc[:lat.ndim] = True
    path = {'path': bandpath.path}
    bandpath2 = kpts2kpts(path, atoms=a)
    print('cell', a.cell)
    print('Original', bandpath)
    print('path', path)
    print('Produced by kpts2kpts', bandpath2)
    sp = set(bandpath.special_points)
    sp2 = set(bandpath2.special_points)
    msg = ('Input and output bandpath from kpts2kpts dont agree!\n'
           'Input: {}\n Output: {}'.format(bandpath, bandpath2))
    assert sp == sp2, msg
예제 #3
0
파일: kpts2kpts.py 프로젝트: shuchingou/ase
from ase.calculators.calculator import kpts2kpts
from ase.lattice import all_variants
from ase import Atoms

# This function tests whether giving a bandpath
# and an atoms object with a completed cell to
# kpts2kpts actually produces a band path with
# the same special points in the end. If this
# isn't fulfilled then it means that something
# has gone wrong (most likely that the bravais
# lattice wasn't correctly identified).
for lat in all_variants():
    print()
    print(lat)
    bandpath = lat.bandpath()
    a = Atoms()
    a.cell = lat.tocell().complete()
    a.pbc[:lat.ndim] = True
    path = {'path': bandpath.path}
    bandpath2 = kpts2kpts(path, atoms=a)
    print('cell', a.cell)
    print('Original', bandpath)
    print('path', path)
    print('Produced by kpts2kpts', bandpath2)
    sp = set(bandpath.special_points)
    sp2 = set(bandpath2.special_points)
    msg = ('Input and output bandpath from kpts2kpts dont agree!\n'
           'Input: {}\n Output: {}'.format(bandpath, bandpath2))
    assert sp == sp2, msg