def __init__(self, n): self._sym_n = SymmetricGroup(n) self._elements = self._sym_n._elements self._permutation_group = PermutationGroup(self._sym_n._elements) self._path_serialization = os.path.join( os.path.dirname(__file__), 'symmetric_groups/sym_{0}.json'.format(n)) self._subgroups = self.subgroups() self._trivial_group = PermutationGroup( Permutation([i for i in range(0, n)])) with open(self._path_serialization, 'w') as write_file: json.dump(self._subgroups, write_file)
def conjugate_subgroup(g, subgroup): elements_conjugated = [] for h in subgroup._elements: elements_conjugated.append(g * h * inv(g)) return PermutationGroup(elements_conjugated)
def __init__(self, name, permgroupgens, # permutation group generators irrepgens_dict, # dictionary with irrep generators, svwf_rep_gen_func, # function that generates a tuple with svwf representation generators rep3d_gens = None, # 3d (quaternion) representation generators of a point group: sequence of qpms.irep3 instances ): self.name = name self.permgroupgens = permgroupgens self.permgroup = PermutationGroup(*permgroupgens) self.irrepgens_dict = irrepgens_dict self.svwf_rep_gen_func = svwf_rep_gen_func self.irreps = dict() for irrepname, irrepgens in irrepgens_dict.items(): is1d = isinstance(irrepgens[0], (int,float,complex)) irrepdim = 1 if is1d else irrepgens[0].shape[0] self.irreps[irrepname] = generate_grouprep(self.permgroup, 1 if is1d else np.eye(irrepdim), permgroupgens, irrepgens, immultop = None if is1d else np.dot, imcmp = None if is1d else np.allclose ) self.rep3d_gens = rep3d_gens self.rep3d = None if rep3d_gens is None else generate_grouprep( self.permgroup, IRot3(), permgroupgens, rep3d_gens, immultop = None, imcmp = (lambda x, y: x.isclose(y)) )
def _to_perm_group(self): ''' Return an isomorphic permutation group and the isomorphism. The implementation is dependent on coset enumeration so will only terminate for finite groups. ''' from sympy.combinatorics import Permutation, PermutationGroup from sympy.combinatorics.homomorphisms import homomorphism from sympy import S if self.order() == S.Infinity: raise NotImplementedError("Permutation presentation of infinite " "groups is not implemented") if self._perm_isomorphism: T = self._perm_isomorphism P = T.image() else: C = self.coset_table([]) gens = self.generators images = [[C[i][2 * gens.index(g)] for i in range(len(C))] for g in gens] images = [Permutation(i) for i in images] P = PermutationGroup(images) T = homomorphism(self, P, gens, images, check=False) self._perm_isomorphism = T return P, T
def __init__(self, group, space=None): """ Create a new GroupAction :param group: `group` is either a SymPy Permutation, a list of SymPy Permutations, or a SymPy PermutationGroup. :param space: `space` is a set {0,1,2,...,n-1} that specifies the set to be acted upon. """ self.group = None if isinstance(group, PermutationGroup): self.group = group elif isinstance(group, Permutation): self.group = PermutationGroup([group]) elif isinstance(group, list): if len(group) > 0: self.group = PermutationGroup(group) else: self.group = PermutationGroup()
def symbolic_symmetry_group( permutation_indices: List[Tuple[int, ...]]) -> PermutationGroup: generators = [] for indices in permutation_indices: if len(indices) > 1: generators.extend(starmap(Permutation, combinations(indices, 2))) else: generators.append(Permutation(indices[0])) return PermutationGroup(*generators)
def group_Klein4(self): return PermutationGroup( [Permutation([1, 0, 2, 3]), Permutation([0, 1, 3, 2])])
def group_Z4(self): return PermutationGroup([Permutation([3, 0, 1, 2])])
def group_Klein4_N(self): return PermutationGroup([ Permutation([1, 0, 3, 2]), Permutation([2, 3, 0, 1]), Permutation([3, 2, 1, 0]) ])
def group_S3_twisted(self): return PermutationGroup([Permutation([2, 0, 1, 3, 4]), Permutation([1, 0, 2, 4, 3])])
def group_Dbl_Trans(self): return PermutationGroup([Permutation([1, 0, 3, 2])])
def group_A4(self): return PermutationGroup( [Permutation([2, 0, 1, 3]), Permutation([1, 0, 3, 2])])
def group_pair_disj_trans(self): return PermutationGroup([Permutation([1, 0, 2, 3, 4]), Permutation([0, 1, 3, 2, 4]), Permutation([1, 0, 3, 2, 4])])
def group_A5(self): return PermutationGroup([Permutation([4, 0, 1, 2, 3]), Permutation([2, 0, 1, 3, 4])])
def group_Z3(self): return PermutationGroup([Permutation([2, 0, 1, 3, 4]), Permutation([1, 2, 0, 3, 4])])
def group_D10(self): return PermutationGroup([Permutation([4, 0, 1, 2, 3]), Permutation([0, 4, 3, 2, 1])])
def group_GA1_5(self): return PermutationGroup([Permutation([4, 0, 1, 2, 3]), Permutation([0, 3, 1, 4, 2])])
def group_Z5(self): return PermutationGroup([Permutation([4, 0, 1, 2, 3])])
def group_S4(self): return PermutationGroup([Permutation([3, 0, 1, 2, 4]), Permutation([1, 0, 2, 3, 4])])
def group_S3_prod_S2(self): return PermutationGroup([Permutation([2, 0, 1, 3, 4]), Permutation([1, 0, 2, 3, 4]), Permutation([0, 1, 2, 4, 3])])
def group_D8(self): return PermutationGroup( [Permutation([3, 0, 1, 2]), Permutation([2, 1, 0, 3])])
def explicit_symbolic_symmetry_group( permutation_indices: List[Tuple[int, ...]]) -> PermutationGroup: generators = starmap(Permutation, permutation_indices) return PermutationGroup(*generators)
def group_S3(self): return PermutationGroup( [Permutation([2, 0, 1, 3]), Permutation([1, 0, 2, 3])])
def group_Trivial(self): return PermutationGroup([Permutation([0, 1, 2, 3])])
def group_dbl_trans_four(self): return PermutationGroup([Permutation([1, 0, 3, 2, 4]), Permutation([2, 3, 0, 1, 4]), Permutation([3, 2, 1, 0, 4])])
def group_S2(self): return PermutationGroup([Permutation([1, 0, 2, 3])])
theprojector[np.isclose(theprojector,x)] = x projectors[repi] = theprojector if do_bases: return projectors, bases else: return projectors # Group D3h; mostly legacy code (kept because of the the honeycomb lattice K-point code, whose generalised version not yet implemented) # Note that the size argument of permutations is necessary, otherwise e.g. c*c and b*b would not be evaluated equal # N.B. the weird elements as Permutation(N) – it means identity permutation of size N+1. rot3_perm = Permutation(0,1,2, size=5) # C3 rotation xflip_perm = Permutation(0,2, size=5) # vertical mirror zflip_perm = Permutation(3,4, size=5) # horizontal mirror D3h_srcgens = [rot3_perm,xflip_perm,zflip_perm] D3h_permgroup = PermutationGroup(*D3h_srcgens) # D3h D3h_irreps = { # Bradley, Cracknell p. 61 "E'" : generate_grouprep(D3h_permgroup, epsilon, D3h_srcgens, [alif, lam, epsilon], immultop = np.dot, imcmp = np.allclose), "E''" : generate_grouprep(D3h_permgroup, epsilon, D3h_srcgens, [alif, lam, -epsilon], immultop = np.dot, imcmp = np.allclose), # Bradley, Cracknell p. 59, or Dresselhaus, Table A.14 (p. 482) "A1'" : generate_grouprep(D3h_permgroup, 1, D3h_srcgens, [1,1,1]), "A2'" : generate_grouprep(D3h_permgroup, 1, D3h_srcgens, [1,-1,1]), "A1''" : generate_grouprep(D3h_permgroup, 1, D3h_srcgens, [1,-1,-1]), "A2''" : generate_grouprep(D3h_permgroup, 1, D3h_srcgens, [1,1,-1]), } #TODO lepší název fce; legacy, use group_info['D3h'].generate_grouprep() instead def gen_point_D3h_svwf_rep(lMax, vflip = 'x'): '''
def group_Z6(self): return PermutationGroup([Permutation([2, 0, 1, 3, 4]), Permutation([0, 1, 2, 4, 3])])