Skip to content

Commit 26546b3

Browse files
committed
New restarts section in the hooks
1 parent e3b4f9b commit 26546b3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pySDC/projects/PinTSimE/battery_2condensators_model.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ def post_step(self, step, level_number):
5353
type='voltage C2',
5454
value=L.uend[2],
5555
)
56-
self.increment_stats(
56+
self.add_to_stats(
5757
process=step.status.slot,
5858
time=L.time,
5959
level=L.level_index,
6060
iter=0,
6161
sweep=L.status.sweep,
6262
type='restart',
63-
value=1,
64-
initialize=0,
63+
value=int(step.status.get('restart')),
6564
)
6665

6766

pySDC/projects/PinTSimE/estimation_check_extended.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,23 @@ def check(cwd='./'):
121121
Routine to check the differences between using a switch estimator or not
122122
"""
123123

124-
dt_list = [1e-1, 1e-2, 1e-3]
124+
dt_list = [4e-1, 4e-2, 4e-3]
125125
use_switch_estimator = [True, False]
126126
restarts_all = []
127127
restarts_dict = dict()
128128
for dt_item in dt_list:
129-
for item in use_switch_estimator:
130-
stats, description = run(dt=dt_item, use_switch_estimator=item)
129+
for use_SE in use_switch_estimator:
130+
stats, description = run(dt=dt_item, use_switch_estimator=use_SE)
131131

132-
assert len(get_recomputed(stats, type='switch', sortby='time')) >= 1, 'No switches found!'
132+
if use_SE:
133+
assert len(get_recomputed(stats, type='switch', sortby='time')) >= 1, 'No switches found for dt={}!'.format(dt_item)
133134

134-
fname = 'data/battery_2condensators_dt{}_USE{}.dat'.format(dt_item, item)
135+
fname = 'data/battery_2condensators_dt{}_USE{}.dat'.format(dt_item, use_SE)
135136
f = open(fname, 'wb')
136137
dill.dump(stats, f)
137138
f.close()
138139

139-
if item:
140+
if use_SE:
140141
restarts_dict[dt_item] = np.array(get_sorted(stats, type='restart', recomputed=None, sortby='time'))
141142
restarts = restarts_dict[dt_item][:, 1]
142143
restarts_all.append(np.sum(restarts))
@@ -203,10 +204,10 @@ def check(cwd='./'):
203204
restarts_dt = restarts_dict[dt_item]
204205
for i in range(len(restarts_dt[:, 0])):
205206
if round(restarts_dt[i, 0], 13) == round(t_switch[0], 13):
206-
restarts_dt_switch1.append(np.sum(restarts_dt[0:i, 1]))
207+
restarts_dt_switch1.append(np.sum(restarts_dt[0 : i - 1, 1]))
207208

208209
if round(restarts_dt[i, 0], 13) == round(t_switch[1], 13):
209-
restarts_dt_switch2.append(np.sum(restarts_dt[i - 1 :, 1]))
210+
restarts_dt_switch2.append(np.sum(restarts_dt[i - 2 :, 1]))
210211

211212
setup_mpl()
212213
fig1, ax1 = plt_helper.plt.subplots(1, 1, figsize=(4.5, 3))

0 commit comments

Comments
 (0)