def test_honeycomb(): lat = kwant.lattice.honeycomb(norbs=1) # Test simple honeycomb model with constant terms # Add discrete symmetries to the kwant builder as well, to check that they are # returned as well. syst = kwant.Builder(symmetry=TranslationalSymmetry(*lat.prim_vecs)) syst[lat.a(0, 0)] = 1 syst[lat.b(0, 0)] = 1 syst[lat.neighbors(1)] = -1 H = builder_to_model(syst) sg, cs = symmetries(H, hexagonal(sympy_R=False), prettify=True) assert len(sg) == 24 assert len(cs) == 0 # Test simple honeycomb model with value functions syst = kwant.Builder(symmetry=TranslationalSymmetry(*lat.prim_vecs)) syst[lat.a(0, 0)] = lambda site, ma: ma syst[lat.b(0, 0)] = lambda site, mb: mb syst[lat.neighbors(1)] = lambda site1, site2, t: t H = builder_to_model(syst) sg, cs = symmetries(H, hexagonal(sympy_R=False), prettify=True) assert len(sg) == 12 assert len(cs) == 0
def test_higher_dim(): # Test 0D finite system lat = kwant.lattice.cubic(norbs=1) syst = kwant.Builder() syst[lat(0, 0, 0)] = 1 syst[lat(1, 1, 0)] = 1 syst[lat(0, 1, 1)] = 1 syst[lat(1, 0, -1)] = 1 syst[lat(0, 0, 0), lat(1, 1, 0)] = -1 syst[lat(0, 0, 0), lat(0, 1, 1)] = -1 syst[lat(0, 0, 0), lat(1, 0, -1)] = -1 H = builder_to_model(syst) sg, cs = symmetries(H, prettify=True) assert len(sg) == 2 assert len(cs) == 5 # Test triangular lattice system embedded in 3D sym = TranslationalSymmetry([1, 1, 0], [0, 1, 1]) lat = kwant.lattice.cubic(norbs=1) syst = kwant.Builder(symmetry=sym) syst[lat(0, 0, 0)] = 1 syst[lat(0, 0, 0), lat(1, 1, 0)] = -1 syst[lat(0, 0, 0), lat(0, 1, 1)] = -1 syst[lat(0, 0, 0), lat(1, 0, -1)] = -1 H = builder_to_model(syst) sg, cs = symmetries(H, hexagonal(sympy_R=False), prettify=True) assert len(sg) == 24 assert len(cs) == 0
def test_real_space_basis(): lat = kwant.lattice.honeycomb(norbs=[1, 1]) sym = kwant.TranslationalSymmetry(lat.vec((1, 0)), lat.vec((0, 1))) bulk = kwant.Builder(sym) bulk[[lat.a(0, 0), lat.b(0, 0)]] = 0 bulk[lat.neighbors()] = 1 # Including real space symmetries symmetries = find_builder_symmetries(bulk) hex_group_2D = hexagonal() hex_group_2D = set( PointGroupElement( np.array(s.R).astype(float), s.conjugate, s.antisymmetry, None) for s in hex_group_2D) assert len(symmetries) == len(hex_group_2D) assert all([ s1 in symmetries and s2 in hex_group_2D for s1, s2 in zip(hex_group_2D, symmetries) ]) # Only onsite discrete symmetries symmetries = find_builder_symmetries(bulk, spatial_symmetries=False) onsites = [ PointGroupElement(np.eye(2), True, False, None), # T PointGroupElement(np.eye(2), True, True, None), # P PointGroupElement(np.eye(2), False, True, None), # C PointGroupElement(np.eye(2), False, False, None) ] # I assert len(symmetries) == len(onsites) assert all([ s1 in symmetries and s2 in onsites for s1, s2 in zip(onsites, symmetries) ])