@@ -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
@@ -754,6 +762,15 @@ def integrator(self):
754762 else :
755763 return self ._omm_mols .getIntegrator ()
756764
765+ def get_rest2_scale (self ):
766+ """
767+ Return the current REST2 scaling factor.
768+ """
769+ if self .is_null ():
770+ return None
771+ else :
772+ return self ._omm_mols .get_rest2_scale ()
773+
757774 def info (self ):
758775 if self .is_null ():
759776 return None
@@ -953,14 +970,19 @@ def _rebuild_and_minimise(self):
953970
954971 from ..utils import Console
955972
956- Console . warning (
973+ msg = (
957974 "Something went wrong when running dynamics. The system will be "
958975 "minimised, and then dynamics will be attempted again. If an "
959976 "error still occurs, then it is likely that the step size is too "
960977 "large, the molecules are over-constrained, or there is something "
961- "more fundemental going wrong..."
978+ "more fundamental going wrong..."
962979 )
963980
981+ if self ._somd2_logger is not None :
982+ self ._somd2_logger .warning (msg )
983+ else :
984+ Console .warning (msg )
985+
964986 # rebuild the molecules
965987 from ..convert import to
966988
@@ -1909,16 +1931,8 @@ def get_rest2_scale(self):
19091931 """
19101932 Return the current REST2 scaling factor.
19111933 """
1912- if self .is_null ():
1913- return None
19141934 return self ._d .get_rest2_scale ()
19151935
1916- def set_rest2_scale (self , rest2_scale : float ):
1917- """
1918- Set the current REST2 scaling factor.
1919- """
1920- self ._d .set_rest2_scale (rest2_scale = rest2_scale )
1921-
19221936 def ensemble (self ):
19231937 """
19241938 Return the ensemble in which the simulation is being performed
0 commit comments