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
21 changes: 12 additions & 9 deletions ThermoScreening/thermo/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,15 @@ def __init__(
self._center_of_mass = center_of_mass(atoms, self._mass)
self._symmetry_number = rotational_symmetry_number(atoms)
self._rotational_group = rotational_group_calc(atoms)
if self._cell is None:
self._spacegroup_number = None
self._spacegroup = None
else:
if isinstance(self._cell, Cell):
self._spacegroup_number = spacegroup_number(atoms, self._cell)
self._spacegroup = spacegroup(atoms, self._cell)
else:
# Periodic input arrives as a raw cell array (from read_xyz/read_gen)
# and the spacegroup is unused by the gas-phase RRHO calculation, so
# degrade to None instead of feeding a non-Cell into spacegroup().
self._spacegroup_number = None
self._spacegroup = None
self._imaginary_frequencies = imaginary_frequencies(vibrational_frequencies)
self._has_imaginary_frequencies = check_imaginary_frequencies(
self._imaginary_frequencies
Expand Down Expand Up @@ -823,17 +826,17 @@ def rotational_group(self) -> str:
return self._rotational_group

@property
def spacegroup_number(self) -> None | str:
def spacegroup_number(self) -> None | int:
"""
The spacegroup of the system.
The spacegroup number of the system.

Returns
-------
str, None
The spacegroup of the system.
int, None
The spacegroup number of the system.
"""

return self._spacegroup
return self._spacegroup_number

@property
def spacegroup(self) -> None | str:
Expand Down
37 changes: 37 additions & 0 deletions tests/thermo/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,43 @@ def test_system(self):

assert system.periodicity is False

def test_system_accepts_periodic_ndarray_cell(self):
# read_xyz/read_gen hand back a raw ndarray cell for periodic input;
# System must construct instead of raising on the spacegroup hint, and
# degrade the (unused) spacegroup to None.
cell = np.array([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]])

system = System(
self.atoms,
periodicity=True,
cell=cell,
solvation=None,
solvent=None,
charge=0,
electronic_energy=-33.6052447996,
vibrational_frequencies=np.array([-1, -2, 0.1, 1, 2, 3, 4, 5, 6]),
)

assert system.spacegroup_number is None
assert system.spacegroup is None

def test_spacegroup_properties_map_to_their_attributes(self):
system = System(
self.atoms,
periodicity=False,
cell=None,
solvation=None,
solvent=None,
charge=0,
electronic_energy=-33.6052447996,
vibrational_frequencies=np.array([-1, -2, 0.1, 1, 2, 3, 4, 5, 6]),
)
system._spacegroup_number = 1
system._spacegroup = "P1"

assert system.spacegroup_number == 1
assert system.spacegroup == "P1"

np.testing.assert_array_equal(system.center_of_mass, [1, 0, 0])

assert system.pbc == [False, False, False]
Expand Down
Loading