@@ -200,14 +200,29 @@ def load_daily_temperatures(csv_path: str) -> tuple[list[float], list[float]]:
200200 return days , temps
201201
202202
203+ def clean_bool (val : str , name : str = "unknown" ) -> bool :
204+ value = val .split ("#" )[0 ].strip ().lower ()
205+ true_values = ("true" , "1" , "yes" , "y" )
206+ false_values = ("false" , "0" , "no" , "n" )
207+
208+ if value in true_values :
209+ return True
210+ if value in false_values :
211+ return False
212+
213+ raise ValueError (
214+ f"Invalid boolean value for '{ name } ': '{ val } '. "
215+ f"Expected one of { true_values + false_values } ."
216+ )
217+
218+
203219def read_config_file (param_path : Path ) -> tuple [
204220 int , # number_of_iterations
205221 float , # dt_momentum
206222 int , # momentum_iteration_threshold
207223 float , # dt_global_model
208224 float , # dt_heat_transfer
209225 float , # dt_mass_conservation
210- float , # time_end_simulation
211226 float , # write_intervals_time
212227 int , # partition_shape_size
213228 float , # h_mesh_step_value
@@ -247,11 +262,13 @@ def clean_int(val: str) -> int:
247262 input_variables ["simulation" ]["momentum_iteration_threshold" ]
248263 )
249264
250- time_end_simulation = clean_float (
251- input_variables ["simulation" ]["time_end_simulation" ]
252- )
265+ permafrost = clean_bool (input_variables ["simulation" ]["permafrost" ], "permafrost" )
266+
267+ # time_end_simulation = clean_float(
268+ # input_variables["simulation"]["time_end_simulation"]
269+ # )
253270
254- write_intervals_time = clean_float (
271+ write_intervals_time : float = clean_float (
255272 input_variables ["simulation" ]["write_intervals_time" ]
256273 )
257274
@@ -301,7 +318,6 @@ def clean_int(val: str) -> int:
301318 dt_global_model ,
302319 dt_heat_transfer ,
303320 dt_mass_conservation ,
304- time_end_simulation ,
305321 write_intervals_time ,
306322 partition_shape_size ,
307323 h_mesh_step_value ,
@@ -316,6 +332,7 @@ def clean_int(val: str) -> int:
316332 temps_temperature_file ,
317333 results_pathname ,
318334 slope_radian ,
335+ permafrost ,
319336 )
320337
321338
0 commit comments