Skip to content

Commit 07750d9

Browse files
committed
Change switching logic of models using a counter (but yields different results..)
1 parent 421bafe commit 07750d9

File tree

58 files changed

+316
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+316
-242
lines changed

pySDC/projects/PinTSimE/battery_2condensators_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def main(use_switch_estimator=True):
7878
sweeper_params = dict()
7979
sweeper_params['quad_type'] = 'LOBATTO'
8080
sweeper_params['num_nodes'] = 5
81-
sweeper_params['QI'] = 'LU' # For the IMEX sweeper, the LU-trick can be activated for the implicit part
81+
# sweeper_params['QI'] = 'LU' # For the IMEX sweeper, the LU-trick can be activated for the implicit part
8282
sweeper_params['initial_guess'] = 'spread'
8383

8484
# initialize problem parameters
@@ -98,7 +98,7 @@ def main(use_switch_estimator=True):
9898

9999
# initialize controller parameters
100100
controller_params = dict()
101-
controller_params['logger_level'] = 20
101+
controller_params['logger_level'] = 15
102102
controller_params['hook_class'] = log_data
103103

104104
# convergence controllers
@@ -164,7 +164,7 @@ def main(use_switch_estimator=True):
164164
restarts = np.array(get_sorted(stats, type='restart', recomputed=False))[:, 1]
165165
print("Restarts for dt: ", level_params['dt'], " -- ", np.sum(restarts))
166166

167-
assert np.mean(niters) <= 5, "Mean number of iterations is too high, got %s" % np.mean(niters)
167+
assert np.mean(niters) <= 4, "Mean number of iterations is too high, got %s" % np.mean(niters)
168168
f.close()
169169

170170
plot_voltages(description, use_switch_estimator)

pySDC/projects/PinTSimE/battery_model.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import dill
33
from pathlib import Path
44

5-
from pySDC.helpers.stats_helper import get_sorted
5+
from pySDC.helpers.stats_helper import sort_stats, filter_stats, get_sorted
66
from pySDC.core.Collocation import CollBase as Collocation
77
from pySDC.implementations.problem_classes.Battery import battery, battery_implicit
88
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):
9999

100100
# initialize controller parameters
101101
controller_params = dict()
102-
controller_params['logger_level'] = 20
102+
controller_params['logger_level'] = 15
103103
controller_params['hook_class'] = log_data
104104
controller_params['mssdc_jac'] = False
105105

@@ -182,7 +182,7 @@ def run():
182182
dt = 1e-3
183183
problem_classes = [battery, battery_implicit]
184184
sweeper_classes = [imex_1st_order, generic_implicit]
185-
use_switch_estimator = [False]
185+
use_switch_estimator = [True]
186186
use_adaptivity = [False]
187187

188188
for problem, sweeper in zip(problem_classes, sweeper_classes):
@@ -241,6 +241,33 @@ def plot_voltages(description, problem, sweeper, use_switch_estimator, use_adapt
241241

242242
fig.savefig('data/{}_model_solution_{}.png'.format(problem, sweeper), dpi=300, bbox_inches='tight')
243243
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
244271

245272

246273
def proof_assertions_description(description, use_adaptivity, use_switch_estimator):
3.05 MB
Binary file not shown.
3.59 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)