@@ -521,6 +521,58 @@ def get_spg_representation(self):
521521 one_hot: a (15, 26) numpy (0, 1) array
522522 """
523523 return self .lattice_id , self .get_spg_symmetry_object ().to_one_hot ()
524+
525+ def get_subgroup_composition (self , ids = None , g_types = ['t' , 'k' ], max_atoms = 100 ,
526+ verbose = False ):
527+ """
528+ Get the composition of the subgroup Wyckoff positions.
529+
530+ Args:
531+ ids (list, optional): List of Wyckoff position indices.
532+ verbose (bool): Whether to print debug information.
533+ g_types (list): List of subgroup types to consider ('t' for translationengleiche, 'k' for klassengleiche).
534+ max_atoms (int): Maximum number of atoms to consider for subgroup search.
535+
536+ Returns:
537+ list: List of multiplicities of the Wyckoff positions.
538+ """
539+ if verbose :
540+ strs = f"{ self .number } ({ self .symbol } ): "
541+ for id in ids :
542+ wp = self [id ]
543+ strs += f"{ wp .multiplicity } { wp .letter } "
544+ print (strs )
545+ sub_symmetries = []
546+ N_atoms = sum ([self [id ].multiplicity for id in ids ])
547+
548+ for g_type in g_types :
549+ if g_type == 't' :
550+ sub = self .get_max_t_subgroup ()
551+ else :
552+ sub = self .get_max_k_subgroup ()
553+
554+ for i , sub_g in enumerate (sub ['subgroup' ]):
555+ if N_atoms * sub ['index' ][i ] > max_atoms :
556+ continue
557+ sub_gg = Group (sub_g )
558+ relation = sub ['relations' ][i ]#; print(relation)
559+ sub_ids = []
560+ for id in ids :
561+ true_id = len (self )- id - 1
562+ relation [true_id ].sort ()
563+ for r in relation [true_id ]:
564+ letter = r [- 1 ]#; print("test letter:", relation[true_id])
565+ sub_ids .append (len (sub_gg ) - letters .index (letter ) - 1 )
566+ data = (sub_g , sub_ids )
567+ if data not in sub_symmetries :
568+ sub_symmetries .append (data )
569+ if verbose :
570+ strs = f"{ sub_gg .number } ({ sub_gg .symbol } ): "
571+ for id in sub_ids :
572+ wp = sub_gg [id ]
573+ strs += f"{ wp .multiplicity } { wp .letter } "
574+ print (strs , data )
575+ return sub_symmetries
524576
525577 def get_lattice_id (self ):
526578 """
0 commit comments