Ejemplo n.º 1
0
def find_builder_symmetries(builder, momenta=None, params=None,
                            spatial_symmetries=True, prettify=True):
    """Finds the symmetries of a Kwant system using qsymm.

    Parameters
    ----------
    builder : `~kwant.builder.Builder`
    momenta : list of strings or None
        Names of momentum variables, if None 'k_x', 'k_y', ... is used.
    params : dict, optional
        Dictionary of parameter names and their values; used when
        evaluating the Hamiltonian matrix elements.
    spatial_symmetries : bool (default True)
        If True, search for all symmetries.
        If False, only searches for the symmetries that are declarable in
        `~kwant.builder.Builder` objects, i.e. time-reversal symmetry,
        particle-hole symmetry, chiral symmetry, or conservation laws.
        This can save computation time.
    prettify : bool (default True)
        Whether to carry out sparsification of the continuous symmetry
        generators, in general an arbitrary linear combination of the
        symmetry generators is returned.

    Returns
    -------
    symmetries : list of qsymm.PointGroupElements and/or qsymm.ContinuousGroupElement
        The symmetries of the Kwant system.
    """

    if params is None:
        params = dict()

    ham = builder_to_model(builder, momenta=momenta,
                           real_space=False, params=params)

    dim = len(np.array(builder.symmetry.periods))

    if spatial_symmetries:
        candidates = bravais_point_group(builder.symmetry.periods, tr=True,
                                         ph=True, generators=False,
                                         verbose=False)
    else:
        candidates = [
            qsymm.PointGroupElement(np.eye(dim), True, False, None),  # T
            qsymm.PointGroupElement(np.eye(dim), True, True, None),   # P
            qsymm.PointGroupElement(np.eye(dim), False, True, None)]  # C
    sg, cg = qsymm.symmetries(ham, candidates, prettify=prettify,
                              continuous_rotations=False)
    return list(sg) + list(cg)
Ejemplo n.º 2
0
def test_find_builder_discrete_symmetries():
    symm_class = ['AI', 'D', 'AIII', 'BDI']
    class_dict = {
        'AI': ['time_reversal'],
        'D': ['particle_hole'],
        'AIII': ['chiral'],
        'BDI': ['time_reversal', 'particle_hole', 'chiral']
    }
    sym_dict = {
        'time_reversal': qsymm.PointGroupElement(np.eye(2), True, False, None),
        'particle_hole': qsymm.PointGroupElement(np.eye(2), True, True, None),
        'chiral': qsymm.PointGroupElement(np.eye(2), False, True, None)
    }
    n = 4
    rng = 11
    for sym in symm_class:
        # Random Hamiltonian in the symmetry class
        h_ons = kwant.rmt.gaussian(n, sym, rng=rng)
        h_hop = 10 * kwant.rmt.gaussian(2 * n, sym, rng=rng)[:n, n:]
        # Make a Kwant builder in the symmetry class and find its symmetries
        lat = kwant.lattice.square(norbs=n)
        bulk = kwant.Builder(TranslationalSymmetry([1, 0], [0, 1]))
        bulk[lat(0, 0)] = h_ons
        bulk[kwant.builder.HoppingKind((1, 0), lat)] = h_hop
        bulk[kwant.builder.HoppingKind((0, 1), lat)] = h_hop
        builder_symmetries = find_builder_symmetries(bulk,
                                                     spatial_symmetries=True,
                                                     prettify=True)

        # Equality of symmetries ignores unitary part
        fourfold_rotation = qsymm.PointGroupElement(np.array([[0, 1], [1, 0]]),
                                                    False, False, None)
        assert fourfold_rotation in builder_symmetries
        class_symmetries = class_dict[sym]
        for class_symmetry in class_symmetries:
            assert sym_dict[class_symmetry] in builder_symmetries