subgroup
Subgroup enumeration for crystallographic space groups.
This module provides tools to enumerate translationengleiche (t-) subgroups of a space group, identify their space group type, and expand the asymmetric unit when reducing symmetry.
Primary use case: expanding asymmetric units to contain complete molecules (e.g., urea with Z' = 0.5 -> Z' = 1).
StandardSettingResult
dataclass
Result of identifying the standard ITA setting for a set of symops.
Attributes:
| Name | Type | Description |
|---|---|---|
sg_number |
int
|
ITA space group number |
sg_symbol |
str
|
Short Hermann-Mauguin symbol |
choice |
str
|
Space group choice (e.g. "b", "2", "") |
basis_transform |
ndarray | None
|
P matrix (3x3), None if identity |
origin_shift |
ndarray | None
|
p vector (3,), None if zero shift |
target_symops |
tuple[int, ...]
|
Integer codes of the matched standard setting |
Source code in chmpy/crystal/subgroup.py
SubgroupEnumerator
Enumerate and verify t-subgroups of a space group.
Uses BFS with closure checking to enumerate translationengleiche subgroups (same lattice, fewer point operations).
Attributes:
| Name | Type | Description |
|---|---|---|
sg_table |
Precomputed SpaceGroupTable for the parent group |
|
parent_sg |
The parent SpaceGroup |
Source code in chmpy/crystal/subgroup.py
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 | |
enumerate_all(max_index=8)
Enumerate all t-subgroups up to a given index.
Uses BFS: starts from the identity, iteratively adds generators, computes closure, and collects unique subgroups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_index
|
int
|
Maximum index [G:H] to consider. Subgroups with |G|/|H| > max_index are excluded. |
8
|
Returns:
| Type | Description |
|---|---|
list[SubgroupResult]
|
List of SubgroupResult for each unique subgroup found, |
list[SubgroupResult]
|
sorted by index (ascending) then by number of symops. |
Source code in chmpy/crystal/subgroup.py
find_by_index(index)
Find all subgroups with a specific index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
The desired index [G:H] |
required |
Returns:
| Type | Description |
|---|---|
list[SubgroupResult]
|
List of SubgroupResult with the specified index |
Source code in chmpy/crystal/subgroup.py
find_for_target_z_prime(current_z_prime, target)
Find subgroups that achieve a target Z'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_z_prime
|
float
|
Current Z' value |
required |
target
|
float
|
Desired Z' value |
required |
Returns:
| Type | Description |
|---|---|
list[SubgroupResult]
|
List of SubgroupResult that would produce the target Z' |
Source code in chmpy/crystal/subgroup.py
from_space_group(sg)
classmethod
Create a SubgroupEnumerator from a SpaceGroup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sg
|
SpaceGroup
|
The space group to enumerate subgroups of |
required |
Returns:
| Type | Description |
|---|---|
SubgroupEnumerator
|
SubgroupEnumerator ready to enumerate subgroups |
Source code in chmpy/crystal/subgroup.py
verify_is_subgroup(symop_indices)
Verify that a set of symop indices forms a valid subgroup.
Checks closure, identity, and inverses using the Cayley table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symop_indices
|
Sequence[int]
|
Indices to verify |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the indices form a valid subgroup |
Source code in chmpy/crystal/subgroup.py
SubgroupResult
dataclass
Result of computing a t-subgroup.
Attributes:
| Name | Type | Description |
|---|---|---|
symop_indices |
tuple[int, ...]
|
Indices into parent group's symop list |
index |
int
|
[G:H] = |G|/|H|, the index of the subgroup |
space_group_number |
int | None
|
ITA number if matches known group, else None |
space_group_symbol |
str | None
|
Symbol if identified, else None |
point_group_symbol |
str
|
Point group symbol (always identified) |
z_prime_factor |
float
|
Factor by which Z' increases (equals the index) |
Source code in chmpy/crystal/subgroup.py
compute_closure(generators, sg_table)
Compute group closure of generator indices using the Cayley table.
Uses the multiplication and inverse tables for O(1) composition, iteratively expanding the set until no new elements are produced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generators
|
frozenset[int]
|
Frozenset of symop indices (into sg_table) |
required |
sg_table
|
SpaceGroupTable
|
Precomputed space group table with Cayley table |
required |
Returns:
| Type | Description |
|---|---|
frozenset[int]
|
Frozenset of all symop indices in the closure |
Source code in chmpy/crystal/subgroup.py
expand_asymmetric_unit(asymmetric_unit, symops, subgroup_indices, sg_table, tolerance=0.0001)
Expand asymmetric unit when reducing to a subgroup.
First deduplicates the input asymmetric unit (removing atoms that are already related by parent group symmetry), then for each unique atom computes its stabilizer, finds coset representatives (symops in G but not accounted for by the subgroup), and generates new independent atoms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asymmetric_unit
|
AsymmetricUnit
|
The original asymmetric unit (may contain redundancy) |
required |
symops
|
list[SymmetryOperation]
|
Parent group's symmetry operations |
required |
subgroup_indices
|
Sequence[int]
|
Indices of symops forming the subgroup |
required |
sg_table
|
SpaceGroupTable
|
Parent group's SpaceGroupTable |
required |
tolerance
|
float
|
Tolerance for position comparison |
0.0001
|
Returns:
| Type | Description |
|---|---|
AsymmetricUnit
|
New AsymmetricUnit with expanded atom list |
Source code in chmpy/crystal/subgroup.py
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 | |
identify_standard_setting(symops)
Identify which standard ITA setting a set of symops corresponds to.
Uses a multi-tier strategy via _identify_match(): 1. Exact code match — already standard 2. Origin shift only (P=I) 3. Basis transform P + exact match 4. Basis transform P + origin shift p 5. Centering reduction + eigenvector transforms
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symops
|
list[SymmetryOperation]
|
List of SymmetryOperation objects |
required |
Returns:
| Type | Description |
|---|---|
StandardSettingResult | None
|
StandardSettingResult if a match is found, None otherwise |