Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ThermoScreening/thermo/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,24 @@ def _molecule_from_atoms(atoms: List[Atom]) -> Molecule:
for atom in atoms:
names.append(atom.symbol)
coordinates.append(_real_position(atom.position))
_validate_unique_positions(coordinates)

return Molecule(names, coordinates)


def _validate_unique_positions(coordinates: List[np.ndarray]) -> None:
"""
Reject overlapping atoms before symmetry analysis.
"""

for index, position in enumerate(coordinates):
for previous in coordinates[:index]:
if np.allclose(position, previous, rtol=0.0, atol=1e-12):
raise TSValueError(
"Atom positions must not overlap for symmetry analysis."
)


def _point_group_analyzer(molecule):
"""
Build a pymatgen point-group analyzer without surfacing benign cast warnings.
Expand Down Expand Up @@ -241,6 +255,10 @@ def rotational_symmetry_number(atoms: List[Atom]) -> int:
int
The symmetry number of the system.
"""
if len(atoms) == 1:
_real_position(atoms[0].position)
return 1

mol = _molecule_from_atoms(atoms)
symmetry_number = _point_group_analyzer(mol).get_rotational_symmetry_number
if callable(symmetry_number):
Expand Down Expand Up @@ -323,6 +341,10 @@ def rotational_group_calc(atoms: List[Atom]) -> str:
str
The rotational group of the system.
"""
if len(atoms) == 1:
_real_position(atoms[0].position)
return "Kh"

mol = _molecule_from_atoms(atoms)
symb = _point_group_analyzer(mol).sch_symbol
return symb
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
dependencies = [
"numpy >= 1.26",
"scipy",
"pymatgen",
"pymatgen-core >= 2026.5.18",
"beartype",
"ase",
"rdkit",
Expand Down
Loading
Loading