@@ -96,6 +96,8 @@ def run(dt, problem, sweeper, use_switch_estimator, use_adaptivity, V_ref):
9696 t0 = 0.0
9797 Tend = 0.3
9898
99+ assert dt < Tend , "Time step is too large for the time domain!"
100+
99101 # instantiate controller
100102 controller = controller_nonMPI (num_procs = 1 , controller_params = controller_params , description = description )
101103
@@ -156,6 +158,8 @@ def check(cwd='./'):
156158 V_ref = V_ref ,
157159 )
158160
161+ assert len (get_recomputed (stats , type = 'switch' , sortby = 'time' )) >= 1 , 'No switches found!'
162+
159163 fname = 'data/battery_dt{}_USE{}_USA{}_{}.dat' .format (dt_item , use_SE , use_A , sweeper .__name__ )
160164 f = open (fname , 'wb' )
161165 dill .dump (stats , f )
@@ -225,8 +229,8 @@ def accuracy_check(dt_list, problem, sweeper, V_ref, cwd='./'):
225229 stats_adapt = dill .load (f4 )
226230 f4 .close ()
227231
228- val_switch_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
229- t_switch_SE_adapt = [v [1 ] for v in val_switch_SE_adapt ]
232+ switches_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
233+ t_switch_SE_adapt = [v [1 ] for v in switches_SE_adapt ]
230234 t_switch_SE_adapt = t_switch_SE_adapt [- 1 ]
231235
232236 dt_SE_adapt_val = get_sorted (stats_SE_adapt , type = 'dt' , recomputed = False )
@@ -349,12 +353,12 @@ def differences_around_switch(
349353 stats_adapt = dill .load (f4 )
350354 f4 .close ()
351355
352- val_switch_SE = get_recomputed (stats_SE , type = 'switch' , sortby = 'time' )
353- t_switch = [v [1 ] for v in val_switch_SE ]
356+ switches_SE = get_recomputed (stats_SE , type = 'switch' , sortby = 'time' )
357+ t_switch = [v [1 ] for v in switches_SE ]
354358 t_switch = t_switch [- 1 ] # battery has only one single switch
355359
356- val_switch_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
357- t_switch_SE_adapt = [v [1 ] for v in val_switch_SE_adapt ]
360+ switches_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
361+ t_switch_SE_adapt = [v [1 ] for v in switches_SE_adapt ]
358362 t_switch_SE_adapt = t_switch_SE_adapt [- 1 ]
359363
360364 vC_SE = get_sorted (stats_SE , type = 'voltage C' , recomputed = False , sortby = 'time' )
@@ -493,12 +497,12 @@ def differences_over_time(dt_list, problem, sweeper, V_ref, cwd='./'):
493497 stats_adapt = dill .load (f4 )
494498 f4 .close ()
495499
496- val_switch_SE = get_recomputed (stats_SE , type = 'switch' , sortby = 'time' )
497- t_switch_SE = [v [1 ] for v in val_switch_SE ]
500+ switches_SE = get_recomputed (stats_SE , type = 'switch' , sortby = 'time' )
501+ t_switch_SE = [v [1 ] for v in switches_SE ]
498502 t_switch_SE = t_switch_SE [- 1 ] # battery has only one single switch
499503
500- val_switch_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
501- t_switch_SE_adapt = [v [1 ] for v in val_switch_SE_adapt ]
504+ switches_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
505+ t_switch_SE_adapt = [v [1 ] for v in switches_SE_adapt ]
502506 t_switch_SE_adapt = t_switch_SE_adapt [- 1 ]
503507
504508 dt_adapt = np .array (get_sorted (stats_adapt , type = 'dt' , recomputed = False , sortby = 'time' ))
@@ -654,12 +658,12 @@ def iterations_over_time(dt_list, maxiter, problem, sweeper, cwd='./'):
654658 times_adapt .append ([v [0 ] for v in iter_counts_adapt_val ])
655659 times .append ([v [0 ] for v in iter_counts_val ])
656660
657- val_switch_SE = get_recomputed (stats_SE , type = 'switch' , sortby = 'time' )
658- t_switch_SE = [v [1 ] for v in val_switch_SE ]
661+ switches_SE = get_recomputed (stats_SE , type = 'switch' , sortby = 'time' )
662+ t_switch_SE = [v [1 ] for v in switches_SE ]
659663 t_switches_SE .append (t_switch_SE [- 1 ])
660664
661- val_switch_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
662- t_switch_SE_adapt = [v [1 ] for v in val_switch_SE_adapt ]
665+ switches_SE_adapt = get_recomputed (stats_SE_adapt , type = 'switch' , sortby = 'time' )
666+ t_switch_SE_adapt = [v [1 ] for v in switches_SE_adapt ]
663667 t_switches_SE_adapt .append (t_switch_SE_adapt [- 1 ])
664668
665669 if len (dt_list ) > 1 :
0 commit comments