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
12 changes: 12 additions & 0 deletions ThermoScreening/thermo/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,20 @@ def _vibrational_contribution(self):
Returns
-------
None

Raises
------
TSValueError
If a kept vibrational frequency is imaginary (non-positive), which
would otherwise make the harmonic formulas return NaN.
"""

if np.any(self._system.real_vibrational_frequencies <= 0):
raise TSValueError(
"Imaginary (non-positive) vibrational frequencies are present; "
"the geometry is not a minimum."
)

self._compute_vibrational_partition_function()
self._compute_vibrational_entropy()
self._compute_vibrational_energy()
Expand Down
12 changes: 12 additions & 0 deletions tests/thermo/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ def test_total_entropy_matches_ase(symbols, positions, freqs, dof, geometry, sig
assert ts_total == pytest.approx(ase_total, abs=0.05)


def test_thermo_rejects_imaginary_vibrational_mode():
# an imaginary (negative) mode in the kept dof set used to give NaN; it now
# raises (the geometry is not a minimum)
with pytest.raises(TSValueError, match="[Ii]maginary"):
_ts_thermo(
["O", "H", "H"],
[[0, 0, 0.119], [0, 0.763, -0.477], [0, -0.763, -0.477]],
[-500.0, 3657.0, 3756.0],
3,
)


def test_rotational_contribution_handles_linear_and_monatomic():
# linear and monatomic species used to give -inf rotational entropy
co2 = _ts_thermo(["C", "O", "O"], [[0, 0, 0], [0, 0, 1.16], [0, 0, -1.16]],
Expand Down
Loading