def test_symmgroup(): def assert_eq_hash(a, b): assert hash(a) == hash(b) assert a == b assert_eq_hash(group.Identity(), group.Identity()) tr = Grid([8, 4, 3]).translation_group assert_eq_hash(tr(), tr(0) @ tr(1) @ tr(2)) assert_eq_hash(tr().remove_duplicates(), tr()) assert tr() @ tr() != tr() assert_eq_hash((tr() @ tr()).remove_duplicates(), tr())
def test_grid_space_group(): g = nk.graph.Chain(8) _check_symmgroups(g) assert g.rotation_group().elems == [group.Identity()] assert len(g.point_group()) == 2 # one reflection assert len(g.space_group()) == 8 * 2 # translations * reflection g = nk.graph.Grid([8, 2], pbc=False) _check_symmgroups(g) assert len(g.rotation_group()) == 2 assert len(g.point_group()) == 4 assert g.point_group() == g.space_group() # no PBC, no translations g = nk.graph.Grid([3, 3, 3], pbc=[True, True, False]) _check_symmgroups(g) assert len(g.rotation_group()) == 8 assert len(g.point_group()) == 16 # D_4 × Z_2 assert len(g.space_group()) == 3 * 3 * 16 g = nk.graph.Grid([3, 3, 3, 3], pbc=[True, True, False, False]) _check_symmgroups(g) assert len(g.rotation_group()) == 32 assert len(g.point_group()) == 64 # D_4 × D_4 assert len(g.space_group()) == 3 * 3 * 64 g = nk.graph.Hypercube(3, 2) _check_symmgroups(g) assert len(g.space_group()) == len(g.automorphisms()) g = nk.graph.Hypercube(4, 2) _check_symmgroups(g) # 4x4 square has even higher symmetry assert len(g.space_group()) < len(g.automorphisms())
def test_grid_translations(): for ndim in 1, 2: g = Grid([4] * ndim, pbc=True) translations = g.translation_group() assert len(translations) == g.n_nodes _check_symmgroup(g.automorphisms(), translations) g = Grid([4] * ndim, pbc=False) translations = g.translation_group() assert translations.elems == [group.Identity()] # only identity g = Grid([8, 4, 3], pbc=[True, False, False]) assert len(g.translation_group()) == 8 g = Grid([8, 4, 3], pbc=[True, True, False]) assert len(g.translation_group()) == 8 * 4 assert g.translation_group(2).elems == [group.Identity()] # only identity g = Grid([8, 4, 3], pbc=[True, True, True]) assert len(g.translation_group()) == 8 * 4 * 3 assert len(g.translation_group(dim=0)) == 8 assert len(g.translation_group(dim=1)) == 4 assert len(g.translation_group(dim=2)) == 3 t1 = g.translation_group() t2 = ( g.translation_group(dim=0) @ g.translation_group(dim=1) @ g.translation_group(dim=2) ) assert t1 == t2 t2 = ( g.translation_group(dim=2) @ g.translation_group(dim=1) @ g.translation_group(dim=0) ) assert t1 != t2 assert g.translation_group(dim=(0, 1)) == g.translation_group( 0 ) @ g.translation_group(1)
def test_inverse(grp): inv = grp.inverse for i, j in enumerate(inv): assert_equal(grp._canonical(grp[i] @ grp[j]), grp._canonical(group.Identity()))