High-level functions
For a deeper understanding of how the algorithms work internally, see the Algorithm Flowcharts.
api
minimalsym.py — Public API for molecular symmetry analysis.
Classes:
-
SymmetryResult–Container for a found symmetry result.
Functions:
-
get_point_group–Determine the point group of a molecule.
-
is_planar–Check whether all atoms of a molecule lie in a common plane.
-
get_inequivalent–Find symmetry-inequivalent atoms using all symmetry operations.
-
symmetrize–Symmetrize the geometry of a molecule to exact point-group symmetry.
-
generate_symmetry_candidates–Generate symmetry-consistent geometries compatible with a detected point group.
SymmetryResult
dataclass
SymmetryResult(mol: Atoms, pg: str, rmsd: float)
Container for a found symmetry result.
Attributes:
-
mol(Atoms) –Symmetrized molecule.
-
pg(str) –Schoenflies symbol of the point group.
-
rmsd(float) –RMSD between the original and symmetrized structure.
get_point_group
get_point_group(mol: Atoms, geom_tol: float = 0.05, eigen_tol: float | None = None, quiet: bool = True) -> str
Determine the point group of a molecule.
Parameters:
-
mol(Atoms) –Molecule to find point group.
-
geom_tol(float, default:0.05) –Geometric tolerance (default 0.05 Å).
-
eigen_tol(float, default:None) –Relative tolerance for eigenvalues (default None, internal worker will determine an appropriate float).
-
quiet(bool, default:True) –If
Truewarnings and debug messages will be disabled.
Returns:
-
str–Schoenflies symbol (e.g. "C2v", "D3h", "Oh").
Raises:
-
TypeError–mol is not ase.Atoms.
-
ValueError–geom_tol <= 0 or mol is empty.
-
RuntimeError–point-group detection failed internally.
Source code in minimalsym/api.py
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 | |
is_planar
is_planar(mol: Atoms, geom_tol: float = 0.05) -> bool
Check whether all atoms of a molecule lie in a common plane.
Parameters:
-
mol(Atoms) –Molecule to check planarity.
-
geom_tol(float, default:0.05) –Geometric tolerance (default 0.05 Å).
Returns:
-
bool–True if molecule is planar.
Raises:
-
TypeError–mol is not ase.Atoms.
-
ValueError–geom_tol <= 0 or mol has fewer than 3 atoms.
- Usage Examples Checking planarity
Source code in minimalsym/api.py
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 | |
get_inequivalent
get_inequivalent(mol_in: Atoms, geom_tol: float = 0.3, eigen_tol: float | None = None, quiet: bool = True) -> tuple[ndarray, ndarray]
Find symmetry-inequivalent atoms using all symmetry operations.
Two atoms are in the same equivalence class if any symmetry operation (proper or improper) maps one onto the other.
Parameters:
-
mol_in(Atoms) –Molecule to find symmetry-inewuivalent atoms.
-
geom_tol(float, default:0.3) –Geometric tolerance (default 0.3 Å)
-
eigen_tol(float, default:None) –Relative tolerance for eigenvalues (default None, internal worker will determine an appropriate float).
-
quiet(bool, default:True) –If
Truewarnings and debug messages will be disabled.
Returns:
-
unique(ndarray) –sorted representative atom indices (one per class).
-
parent(ndarray) –parent[i] is the representative of atom i.
Raises:
-
TypeError– -
ValueError– -
RuntimeError–
Source code in minimalsym/api.py
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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
symmetrize
symmetrize(mol_in: Atoms, geom_tol: float = 0.05, eigen_tol: float | None = None, quiet: bool = True) -> Atoms
Symmetrize the geometry of a molecule to exact point-group symmetry.
Concepts
SEA: Symmetry-equivalent atoms grouped by distance from center of mass. Symtext: Internal representation of symmetry elements and mappings.
Algorithm overview
- Build a Symtext at tolerance geom_tol to detect the point group and the atom permutation map.
- For each set of symmetry-equivalent atoms (SEA):
a. Linear molecules (C0v / D0h): project every atom onto the molecular axis (z). For D0h, inversion partners are handled explicitly.
b. Non-linear molecules: find the first non-trivial symmetry element that fixes the SEA representative (atom_i):
- C_n axis: project position onto the axis.
- sigma plane: project into the plane.
- i or S_n: place at the origin.
c. Map the remaining SEA atoms from the representative using the stored matrix representation of the connecting symel.
- Set mol.info["geom_tol"] = 1e-12 on the result so downstream detection sees exact symmetry.
Parameters:
-
mol_in(Atoms) –Molecule to be symmetrized.
-
geom_tol(float, default:0.05) –Tolerance for detecting the initial (possibly distorted) point group. Default is 0.05 Å.
-
eigen_tol(float, default:None) –Relative tolerance for eigenvalues (default None, internal worker will determine an appropriate float).
-
quiet(bool, default:True) –If
Truewarnings and debug messages will be disabled.
Returns:
-
Atoms–New Atoms object with symmetrized coordinates.
Raises:
-
RuntimeError–If Symtext construction fails.
-
Exception–Re-raises unexpected symmetry element types.
Source code in minimalsym/api.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
generate_symmetry_candidates
generate_symmetry_candidates(mol_in: Atoms, geom_tol: float = 0.05, eigen_tol: float | None = None, sort_by: int = 0, quiet: bool = True) -> list[SymmetryResult]
Generate symmetry-consistent geometries compatible with a detected point group.
Concepts
SEA: Symmetry-equivalent atoms grouped by distance from center of mass.
Symtext: Internal representation of symmetry elements and mappings.
Algorithm overview
- Build a Symtext at tolerance geom_tol to detect the approximate point group of the input structure.
- Decompose the detected point group into all compatible subgroups.
-
For each candidate point group:
a. Construct a Symtext object consistent with that subgroup.
b. For each set of symmetry-equivalent atoms (SEA):
- **Linear molecules** (C∞v / D∞h approximations): project atoms onto the molecular axis. - **Non-linear molecules**: - Project a representative atom onto the appropriate symmetry element (axis, plane, inversion center, etc.). - Map the remaining SEA atoms from the representative using the stored symmetry operations.c. Compute the RMSD between the original (aligned) geometry and the symmetrized structure.
-
Return all generated symmetrized molecules along with their point groups and RMSD values, sorted according to
sort_byparameter.
Parameters:
-
mol_in(Atoms) –Molecule to analyze and symmetrize into multiple candidate symmetries.
-
geom_tol(float, default:0.05) –Tolerance for detecting the initial (possibly distorted) point group. Default is 0.05 Å.
-
eigen_tol(float, default:None) –Relative tolerance for eigenvalues (default None, an internal routine determines an appropriate value).
-
sort_by(int, default:0) –Controls sorting of the returned list:
-
0 := sort by point group "size" (descending number of symmetry operations), then by RMSD (ascending).
-
1 := sort by RMSD (ascending), then by point group "size" (descending).
-
-
quiet(bool, default:True) –If
Truewarnings and debug messages will be disabled.
Returns:
-
list[SymmetryResult]–Symmetrized candidates with their point group and RMSD.
Raises:
-
RuntimeError–If Symtext construction fails for the initial molecule or any candidate point group.
-
Exception–Propagates unexpected exceptions encountered during projection or mapping.
Source code in minimalsym/api.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | |