Symmetry Detection
pg_detect
pg_detect.py — Point-group detection.
This module exposes a single public function, find_point_group(), which implements the Beruski & Vidal (2013) decision-tree algorithm.
The megafunction is decomposed into three private classifiers: _classify_linear() — Ia ~= 0 (linear molecules) _classify_spherical_top() — Ia ~= Ib ~= Ic (cubic/icosahedral) _classify_symmetric_top() — two equal MOIT eigenvalues
Internal implementation is split across three focused sub-modules: rotation_detection.py — Cn axis searches reflection_detection.py — sigma plane searches special_geometry.py — icosahedral and octahedral geometry
- API Internal API Internal API Overview Module Organization Symmetry Detection
PointGroupResult
dataclass
PointGroupResult(pg: str, paxis: ndarray, saxis: ndarray)
Return value of find_point_group().
Attributes:
-
pg(str) –Schoenflies point-group symbol (e.g. "C2v", "D3h", "Oh").
-
paxis((ndarray, shape(3))) –Principal symmetry axis in the original molecule frame. Zero vector when not applicable (e.g. C1).
-
saxis((ndarray, shape(3))) –Secondary axis defining the canonical orientation. Zero vector when not applicable.
- API Internal API
-
API
Internal API
Decomposition & Candidate Generation
pg_decompose_unique_point_group
_classify_linear
_classify_linear(mol, positions, masses, geom_tol)
Classify a linear molecule (Ia ~= 0). Returns PointGroupResult.
Source code in minimalsym/core/pg_detect.py
61 62 63 64 65 | |
_classify_spherical_top
_classify_spherical_top(mol, positions, masses, geom_tol)
Classify a spherical top (Ia ~= Ib ~= Ic). Discriminates T/O/I families by the number of distinct C2 axes. Returns PointGroupResult.
Source code in minimalsym/core/pg_detect.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
_validate_all_c2_ortho
_validate_all_c2_ortho(positions, masses, geom_tol, paxis, c2_ortho, Cn_order)
Validate the c2 orthogonal rotations for a molecule. Generates all the c2 orthogonal axis from c2_ortho, generates their rotation matrix and validates it.
Source code in minimalsym/core/pg_detect.py
143 144 145 146 147 148 149 150 151 152 153 | |
_validate_all_sigmav
_validate_all_sigmav(positions, masses, geom_tol, paxis, sigmav, Cn_order)
Validate the vertical mirror planes for a molecule. Generates all the norm axis of the mirror planes from sigmav, generates their reflection matrix and validates it.
Source code in minimalsym/core/pg_detect.py
155 156 157 158 159 160 161 162 163 164 165 | |
_classify_subfamily
_classify_subfamily(mol, seas, positions, masses, geom_tol, paxis, Cn_order)
Determine the point-group subfamily (h/v/d/S2n/pure) once paxis and Cn_order are known. Returns the full Schoenflies symbol and updated saxis.
Source code in minimalsym/core/pg_detect.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
_classify_general
_classify_general(mol, positions, masses, geom_tol)
Classify a general symmetry. Returns PointGroupResult.
Source code in minimalsym/core/pg_detect.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
find_point_group
find_point_group(mol)
Find the point group of a molecule.
Returns the Schoenflies symbol and the primary/secondary axes that define the canonical orientation with respect to the generated symmetry elements.
Algorithm summary (Beruski & Vidal 2013)
- Compute the moment-of-inertia tensor (MOIT) and its eigenvalues Ia <= Ib <= Ic.
- Classify the rotor type from the eigenvalues:
- Linear (Ia ~= 0): C0v or D0h.
- Spherical top (Ia ~= Ib ~= Ic): T, Td, Th, O, Oh, I, Ih.
- Symmetric top and Asymmetric rotor: Cn, Cnv, Cnh, Dn, Dnh, Dnd, Sn, C1, Cs, Ci.
- Subfamily (h/v/d) is determined from sigma_h, sigma_v, and ortho-C2.
Based on: Beruski, Otávio; Vidal, Luciano N. J. Comp. Chem. 2013. doi:10.1002/jcc.23493
Parameters:
-
mol(Atoms) –Molecule with mol.info["geom_tol"] set to the geometric tolerance.
Returns:
Raises:
-
Exception–If mol.info["geom_tol"] is not set.
Source code in minimalsym/core/pg_detect.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
rotation_detection
rotation_detection.py — Search for proper rotation axes (Cn).
Public names consumed by pg_detect.py: RotationElement, _find_rotation_sets, _find_rotations, _linear_mol_axis, _find_a_c2, _is_there_ortho_c2, _num_C2, _highest_order_axis
- API Internal API Internal API Overview Module Organization Symmetry Detection
RotationElement
RotationElement(axis, order)
Data structure holding a candidate rotation axis and its order.
-
API
Internal API
Symmetry Detection
rotation_detection
-
API
Internal API
Symmetry Detection
rotation_detection
Source code in minimalsym/core/rotation_detection.py
22 23 24 | |
_rotation_set_union
_rotation_set_union(rotation_set: RotationElement) -> list[RotationElement]
Return the union of all per-SEA rotation sets.
Source code in minimalsym/core/rotation_detection.py
36 37 38 39 40 41 42 43 | |
unique_rotation_elements
unique_rotation_elements(elements)
Return a list of RotationElement objects with duplicates removed, using eq.
Source code in minimalsym/core/rotation_detection.py
47 48 49 50 51 52 53 | |
_find_rotation_sets
_find_rotation_sets(mol, SEAs) -> list[list[RotationElement]]
For each SEA, find the set of possible RotationElements.
Parameters:
-
mol(Atoms) – -
SEAs(List[SEA]) –
Returns:
-
List[List[RotationElement]]–
Source code in minimalsym/core/rotation_detection.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
_find_rotations
_find_rotations(mol, rotation_set)
Find RotationElements in rotation_set that leave the molecule invariant.
Parameters:
-
mol(Atoms) – -
rotation_set(List[List[RotationElement]]) –
Returns:
-
List[RotationElement]–
Source code in minimalsym/core/rotation_detection.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
_linear_mol_axis
_linear_mol_axis(mol)
Return the axis that best aligns with a linear molecule.
Parameters:
-
mol(Atoms) –
Returns:
-
array–shape (3,)
Source code in minimalsym/core/rotation_detection.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
_highest_order_axis
_highest_order_axis(rotations)
Return the order of the highest-order rotation in the list.
Source code in minimalsym/core/rotation_detection.py
189 190 191 192 193 194 | |
_compute_R_max
_compute_R_max(positions, axis)
Return the maximum perpendicular distance of any atom from the given axis.
Source code in minimalsym/core/rotation_detection.py
199 200 201 202 203 204 205 | |
_validate_c2_candidate
_validate_c2_candidate(raw_axis, positions, masses, geom_tol, exclude_axis)
Shared C2 validation kernel: normalize → exclude-filter → invariance test.
Normalises raw_axis, rejects it if it coincides with exclude_axis
(pass np.zeros(3) to disable the filter), and tests whether the
corresponding C2 rotation leaves the molecule invariant.
Parameters:
-
raw_axis((ndarray, shape(3))) –candidate vector (need not be unit)
-
exclude_axis((ndarray, shape(3))) –axis to reject (zeros(3) = no filter)
Returns:
-
(ndarray, shape(3))–Normalised unit axis if the candidate passes all checks; zeros(3) otherwise.
Source code in minimalsym/core/rotation_detection.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
_c2a
_c2a(positions, masses, geom_tol, sea_subset, exclude_axis=zeros(3), return_all=False)
Find C_2 axes from origin-to-midpoint vectors of atom pairs within a SEA.
Candidate = normalised (pos[i] + pos[j]).
Source code in minimalsym/core/rotation_detection.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
_c2b
_c2b(positions, masses, geom_tol, sea_subset, exclude_axis=zeros(3), return_all=False)
Find C_2 axes from individual atom position vectors within a SEA.
Candidate = normalised pos[i].
Source code in minimalsym/core/rotation_detection.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
_c2c
_c2c(positions, masses, geom_tol, sea1_subset, sea2_subset, exclude_axis=zeros(3))
Find a C_2 axis from the cross-product of two linear-SEA bond vectors.
Candidate = normalised cross(r_SEA1, r_SEA2). Returns the unit axis or zeros(3) if the candidate is rejected.
Source code in minimalsym/core/rotation_detection.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
_find_a_c2
_find_a_c2(mol, SEAs)
Search for any C_2 axis; return the first one found.
Parameters:
-
mol(Atoms) – -
SEAs(List[SEA]) –
Returns:
-
(array, shape(3) or None)–
Source code in minimalsym/core/rotation_detection.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
_is_there_ortho_c2
_is_there_ortho_c2(mol, SEAs, paxis)
Search for a C_2 axis orthogonal to paxis; return the first one found.
Parameters:
-
mol(Atoms) – -
SEAs(List[SEA]) – -
paxis((array, shape(3))) –
Returns:
-
tuple(bool, array or None)–
Source code in minimalsym/core/rotation_detection.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
_num_C2
_num_C2(mol, SEAs)
Count distinct C_2 axes and return them.
Parameters:
-
mol(Atoms) – -
SEAs(List[SEA]) –
Returns:
-
tuple(int, List[array]) or None–
Source code in minimalsym/core/rotation_detection.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
reflection_detection
reflection_detection.py — Search for reflection planes (sigma).
Public names consumed by pg_detect.py: _is_there_sigmah, _is_there_sigmav, mol_is_planar, _planar_mol_axis
- API Internal API Internal API Overview Module Organization Symmetry Detection
_is_there_sigmah
_is_there_sigmah(mol, paxis)
Check for a horizontal reflection plane (normal = paxis).
Parameters:
-
mol(Atoms) – -
paxis((array, shape(3))) –
Returns:
-
bool–
Source code in minimalsym/core/reflection_detection.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
_is_there_sigmav
_is_there_sigmav(mol, SEAs, paxis)
Check for vertical reflection planes (normal perpendicular to paxis).
Parameters:
-
mol(Atoms) – -
SEAs(List[SEA]) – -
paxis((array, shape(3))) –
Returns:
-
tuple(bool, array or None)–
Source code in minimalsym/core/reflection_detection.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
mol_is_planar
mol_is_planar(mol)
Check if all atoms lie in a common plane.
Parameters:
-
mol(Atoms) –
Returns:
-
bool–
Source code in minimalsym/core/reflection_detection.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
_planar_mol_axis
_planar_mol_axis(mol)
Return the normal to the plane of a planar molecule.
Parameters:
-
mol(Atoms) –
Returns:
-
array–shape (3,) or None
Source code in minimalsym/core/reflection_detection.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
special_geometry
special_geometry.py — Special-geometry axis detection for icosahedral (Ih/I) and octahedral (Oh/O) point groups.
Public names consumed by pg_detect.py: _find_C3s_for_Ih, _find_C4s_for_Oh
- API Internal API Internal API Overview Module Organization Symmetry Detection
_jit_find_C3s_for_Ih
_jit_find_C3s_for_Ih(size, positions, masses, geom_tol)
Find the 10 unique C3 axes of an icosahedral (Ih/I) molecule.
Geometric basis
The icosahedron has 20 triangular faces; each face defines one C3 axis (through its centroid), but opposite faces share an axis, giving 10 distinct axes. Each C3 axis passes through a pair of antipodal triangular face-centers.
Strategy
Enumerate all triples (i, j, k) of atoms. A triple forms an equilateral triangle when all three pairwise squared distances are equal within geom_tol. The C3 axis candidate is the normal to the plane of the triangle. The candidate is accepted only if the full C3 rotation leaves the molecule invariant.
Complexity: O(n^3) atom triples.
Parameters:
-
size(int) – -
positions((ndarray, shape(n, 3))) – -
masses((ndarray, shape(n))) – -
geom_tol(float) –
Returns:
-
(list[ndarray], shape(3))–exactly 10 unique unit C3-axis vectors.
Raises:
-
Exception–If the number of unique axes found is not 10.
Source code in minimalsym/core/special_geometry.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
_find_C3s_for_Ih
_find_C3s_for_Ih(mol)
Find the 10 unique C3 axes for an Ih/I molecule so paxis and saxis can be defined.
Parameters:
-
mol(Atoms) –
Returns:
-
(List[array], shape(3))–
Source code in minimalsym/core/special_geometry.py
96 97 98 99 100 101 102 103 104 105 106 107 108 | |
_check_square
_check_square(va, vb, a, b, c, d, positions, masses, geom_tol)
Test whether four edge lengths form a square and, if so, return the C4 axis.
A square has four equal sides (a==b==c==d within geom_tol). The C4 axis is the normal to the plane of the square: cross(edge1, edge2).
Parameters:
-
va((ndarray, shape(3))) –Two adjacent edge vectors of the candidate quadrilateral.
-
vb((ndarray, shape(3))) –Two adjacent edge vectors of the candidate quadrilateral.
-
a(float) –Squared lengths of the four sides to compare.
-
b(float) –Squared lengths of the four sides to compare.
-
c(float) –Squared lengths of the four sides to compare.
-
d(float) –Squared lengths of the four sides to compare.
-
positions(ndarray) – -
masses(ndarray) – -
geom_tol(float) –
Returns:
-
(ndarray, shape(3))–Unit C4-axis if valid square and rotation leaves molecule invariant; otherwise a zero vector.
Source code in minimalsym/core/special_geometry.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
_jit_find_C4s_for_Oh
_jit_find_C4s_for_Oh(size, positions, masses, geom_tol)
Find the 3 unique C4 axes of an octahedral (Oh/O) molecule.
Geometric basis
The octahedron has 6 vertices in 3 orthogonal pairs; each pair defines one C4 axis, giving 3 perpendicular axes.
Strategy
Enumerate all quadruples (i, j, k, l). Each is tested in three cyclic orderings to check whether any forms a square. Complexity: O(n^4).
Parameters:
-
size(int) – -
positions((ndarray, shape(n, 3))) – -
masses((ndarray, shape(n))) – -
geom_tol(float) –
Returns:
-
list of np.ndarray, shape (3,)–exactly 3 unique unit C4-axis vectors.
Raises:
-
Exception–If the number of unique axes found is not 3.
Source code in minimalsym/core/special_geometry.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
_find_C4s_for_Oh
_find_C4s_for_Oh(mol)
Find the 3 C4 axes for an Oh/O molecule so paxis and saxis can be defined.
Parameters:
-
mol(Atoms) –
Returns:
-
(List[array], shape(3))–
Source code in minimalsym/core/special_geometry.py
234 235 236 237 238 239 240 241 242 243 244 245 246 | |