Skip to content

Commit d3a0e2c

Browse files
authored
Merge pull request #387 from OpenBioSim/feature_somd2_logger
Use SOMD2 logger for dynamics warnings
2 parents 908a6a6 + dd366e0 commit d3a0e2c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

doc/source/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.
2121

2222
* Fix ``delta`` parameter in soft-core Coulomb potential.
2323

24+
* When possible, use the ``SOMD2`` logger for dynamics warnings.
25+
2426
`2025.3.0 <https://github.com/openbiosim/sire/compare/2025.2.0...2025.3.0>`__ - November 2025
2527
---------------------------------------------------------------------------------------------
2628

src/sire/mol/_dynamics.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ def __init__(self, mols=None, map=None, **kwargs):
304304
else:
305305
self._pressure = None
306306

307+
# Try importing the SOMD2 logger.
308+
try:
309+
from somd2 import _logger as somd2_logger
310+
311+
self._somd2_logger = somd2_logger
312+
except:
313+
self._somd2_logger = None
314+
307315
def is_null(self):
308316
return self._sire_mols is None
309317

@@ -953,14 +961,19 @@ def _rebuild_and_minimise(self):
953961

954962
from ..utils import Console
955963

956-
Console.warning(
964+
msg = (
957965
"Something went wrong when running dynamics. The system will be "
958966
"minimised, and then dynamics will be attempted again. If an "
959967
"error still occurs, then it is likely that the step size is too "
960968
"large, the molecules are over-constrained, or there is something "
961-
"more fundemental going wrong..."
969+
"more fundamental going wrong..."
962970
)
963971

972+
if self._somd2_logger is not None:
973+
self._somd2_logger.warning(msg)
974+
else:
975+
Console.warning(msg)
976+
964977
# rebuild the molecules
965978
from ..convert import to
966979

0 commit comments

Comments
 (0)