|
2 | 2 | import dill |
3 | 3 | from pathlib import Path |
4 | 4 |
|
5 | | -from pySDC.helpers.stats_helper import get_sorted |
| 5 | +from pySDC.helpers.stats_helper import sort_stats, filter_stats, get_sorted |
6 | 6 | from pySDC.core.Collocation import CollBase as Collocation |
7 | 7 | from pySDC.implementations.problem_classes.Battery import battery, battery_implicit |
8 | 8 | from pySDC.implementations.sweeper_classes.imex_1st_order import imex_1st_order |
@@ -99,7 +99,7 @@ def main(dt, problem, sweeper, use_switch_estimator, use_adaptivity): |
99 | 99 |
|
100 | 100 | # initialize controller parameters |
101 | 101 | controller_params = dict() |
102 | | - controller_params['logger_level'] = 20 |
| 102 | + controller_params['logger_level'] = 15 |
103 | 103 | controller_params['hook_class'] = log_data |
104 | 104 | controller_params['mssdc_jac'] = False |
105 | 105 |
|
@@ -182,7 +182,7 @@ def run(): |
182 | 182 | dt = 1e-3 |
183 | 183 | problem_classes = [battery, battery_implicit] |
184 | 184 | sweeper_classes = [imex_1st_order, generic_implicit] |
185 | | - use_switch_estimator = [False] |
| 185 | + use_switch_estimator = [True] |
186 | 186 | use_adaptivity = [False] |
187 | 187 |
|
188 | 188 | for problem, sweeper in zip(problem_classes, sweeper_classes): |
@@ -241,6 +241,33 @@ def plot_voltages(description, problem, sweeper, use_switch_estimator, use_adapt |
241 | 241 |
|
242 | 242 | fig.savefig('data/{}_model_solution_{}.png'.format(problem, sweeper), dpi=300, bbox_inches='tight') |
243 | 243 | plt_helper.plt.close(fig) |
| 244 | + |
| 245 | +def get_recomputed(stats, type, sortby): |
| 246 | + """ |
| 247 | + Function that filters statistics after a recomputation |
| 248 | + Args: |
| 249 | + stats (dict): Raw statistics from a controller run |
| 250 | + type (str): the type the be filtered |
| 251 | + sortby (str): string to specify which key to use for sorting |
| 252 | + Returns: |
| 253 | + sorted_list (list): list of filtered statistics |
| 254 | + """ |
| 255 | + |
| 256 | + sorted_nested_list = [] |
| 257 | + times_unique = np.unique([me[0] for me in get_sorted(stats, type=type)]) |
| 258 | + filtered_list = [ |
| 259 | + filter_stats( |
| 260 | + stats, |
| 261 | + time=t_unique, |
| 262 | + num_restarts=max([me.num_restarts for me in filter_stats(stats, type=type, time=t_unique).keys()]), |
| 263 | + type=type, |
| 264 | + ) |
| 265 | + for t_unique in times_unique |
| 266 | + ] |
| 267 | + for item in filtered_list: |
| 268 | + sorted_nested_list.append(sort_stats(item, sortby=sortby)) |
| 269 | + sorted_list = [item for sub_item in sorted_nested_list for item in sub_item] |
| 270 | + return sorted_list |
244 | 271 |
|
245 | 272 |
|
246 | 273 | def proof_assertions_description(description, use_adaptivity, use_switch_estimator): |
|
0 commit comments