@@ -56,20 +56,26 @@ def __init__(self, system, config):
5656 """
5757
5858 if not isinstance (system , (str , _System )):
59- raise TypeError ("'system' must be of type 'str' or 'sire.system.System'" )
59+ msg = "'system' must be of type 'str' or 'sire.system.System'"
60+ _logger .error (msg )
61+ raise TypeError (msg )
6062
6163 if isinstance (system , str ):
6264 # Try to load the stream file.
6365 try :
6466 self ._system = _sr .stream .load (system )
6567 except :
66- raise IOError (f"Unable to load system from stream file: '{ system } '" )
68+ msg = f"Unable to load system from stream file: '{ system } '"
69+ _logger .error (msg )
70+ raise IOError (msg )
6771 else :
6872 self ._system = system .clone ()
6973
7074 # Validate the configuration.
7175 if not isinstance (config , _Config ):
72- raise TypeError ("'config' must be of type 'somd2.config.Config'" )
76+ msg = "'config' must be of type 'somd2.config.Config'"
77+ _logger .error (msg )
78+ raise TypeError (msg )
7379 self ._config = config
7480 self ._config ._extra_args = {}
7581
@@ -89,7 +95,9 @@ def __init__(self, system, config):
8995
9096 self ._system = apply_pert (self ._system , self ._config .pert_file )
9197 except Exception as e :
92- raise IOError (f"Unable to apply perturbation to reference system: { e } " )
98+ msg = f"Unable to apply perturbation to reference system: { e } "
99+ _logger .error (msg )
100+ raise IOError (msg )
93101
94102 # If we're not using SOMD1 compatibility, then reconstruct the original
95103 # perturbable system.
@@ -102,7 +110,9 @@ def __init__(self, system, config):
102110 try :
103111 self ._system .molecules ("property is_perturbable" )
104112 except KeyError :
105- raise KeyError ("No perturbable molecules in the system" )
113+ msg = "No perturbable molecules in the system"
114+ _logger .error (msg )
115+ raise KeyError (msg )
106116
107117 # Link properties to the lambda = 0 end state.
108118 self ._system = _sr .morph .link_to_reference (self ._system )
@@ -238,16 +248,19 @@ def __init__(self, system, config):
238248 # at lambda = 0.5.
239249 if isinstance (self ._config .rest2_scale , float ):
240250 if self ._config .num_lambda != len (self ._lambda_values ):
241- raise ValueError (
242- "REST2 scaling can currently only be used when 'lambda_values' is unset."
243- )
251+ msg = "REST2 scaling can currently only be used when 'lambda_values' is unset."
252+ _logger . error ( msg )
253+ raise ValueError ( msg )
244254 if (
245255 self ._lambda_energy != self ._lambda_values
246256 and self ._config .rest2_scale != 1.0
247257 ):
248- raise ValueError (
249- "'rest2_scale' can only be used when 'lambda_energy' matches 'lambda_values'."
258+ msg = (
259+ "REST2 scaling can currently only be used when "
260+ "'lambda_energy' matches 'lambda_values'."
250261 )
262+ _logger .error (msg )
263+ raise ValueError (msg )
251264 scale_factors = []
252265 for lambda_value in self ._lambda_values :
253266 scale_factors .append (
@@ -325,13 +338,15 @@ def __init__(self, system, config):
325338 try :
326339 atoms = selection_to_atoms (self ._system , self ._config .rest2_selection )
327340 except :
328- raise ValueError ("Invalid 'rest2_selection' value." )
341+ msg = "Invalid 'rest2_selection' value."
342+ _logger .error (msg )
343+ raise ValueError (msg )
329344
330345 # Make sure the user hasn't selected all atoms.
331346 if len (atoms ) == self ._system .num_atoms ():
332- raise ValueError (
333- "REST2 selection cannot contain all atoms in the system."
334- )
347+ msg = "REST2 selection cannot contain all atoms in the system."
348+ _logger . error ( msg )
349+ raise ValueError ( msg )
335350
336351 # Flag whether this is a GPU simulation.
337352 self ._is_gpu = self ._config .platform in ["cuda" , "opencl" , "hip" ]
@@ -892,8 +907,8 @@ def get_last_config(output_directory):
892907 config = self ._config .as_dict ()
893908 except :
894909 _logger .info (
895- f""" No config files found in { self ._config .output_directory } ,
896- attempting to retrieve config from lambda = 0 checkpoint file."" "
910+ f"No config files found in { self ._config .output_directory } , "
911+ " attempting to retrieve config from lambda = 0 checkpoint file."
897912 )
898913 try :
899914 system_temp = _sr .stream .load (
0 commit comments