@@ -56,20 +56,26 @@ def __init__(self, system, config):
56
56
"""
57
57
58
58
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 )
60
62
61
63
if isinstance (system , str ):
62
64
# Try to load the stream file.
63
65
try :
64
66
self ._system = _sr .stream .load (system )
65
67
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 )
67
71
else :
68
72
self ._system = system .clone ()
69
73
70
74
# Validate the configuration.
71
75
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 )
73
79
self ._config = config
74
80
self ._config ._extra_args = {}
75
81
@@ -89,7 +95,9 @@ def __init__(self, system, config):
89
95
90
96
self ._system = apply_pert (self ._system , self ._config .pert_file )
91
97
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 )
93
101
94
102
# If we're not using SOMD1 compatibility, then reconstruct the original
95
103
# perturbable system.
@@ -102,7 +110,9 @@ def __init__(self, system, config):
102
110
try :
103
111
self ._system .molecules ("property is_perturbable" )
104
112
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 )
106
116
107
117
# Link properties to the lambda = 0 end state.
108
118
self ._system = _sr .morph .link_to_reference (self ._system )
@@ -238,16 +248,19 @@ def __init__(self, system, config):
238
248
# at lambda = 0.5.
239
249
if isinstance (self ._config .rest2_scale , float ):
240
250
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 )
244
254
if (
245
255
self ._lambda_energy != self ._lambda_values
246
256
and self ._config .rest2_scale != 1.0
247
257
):
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'."
250
261
)
262
+ _logger .error (msg )
263
+ raise ValueError (msg )
251
264
scale_factors = []
252
265
for lambda_value in self ._lambda_values :
253
266
scale_factors .append (
@@ -325,13 +338,15 @@ def __init__(self, system, config):
325
338
try :
326
339
atoms = selection_to_atoms (self ._system , self ._config .rest2_selection )
327
340
except :
328
- raise ValueError ("Invalid 'rest2_selection' value." )
341
+ msg = "Invalid 'rest2_selection' value."
342
+ _logger .error (msg )
343
+ raise ValueError (msg )
329
344
330
345
# Make sure the user hasn't selected all atoms.
331
346
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 )
335
350
336
351
# Flag whether this is a GPU simulation.
337
352
self ._is_gpu = self ._config .platform in ["cuda" , "opencl" , "hip" ]
@@ -892,8 +907,8 @@ def get_last_config(output_directory):
892
907
config = self ._config .as_dict ()
893
908
except :
894
909
_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."
897
912
)
898
913
try :
899
914
system_temp = _sr .stream .load (
0 commit comments