|
4 | 4 |
|
5 | 5 | from pySDC.helpers.stats_helper import get_sorted |
6 | 6 | from pySDC.core.Collocation import CollBase as Collocation |
7 | | -from pySDC.implementations.problem_classes.Battery import battery_n_condensators |
| 7 | +from pySDC.implementations.problem_classes.Battery import battery_n_capacitors |
8 | 8 | from pySDC.implementations.sweeper_classes.imex_1st_order import imex_1st_order |
9 | 9 | from pySDC.implementations.controller_classes.controller_nonMPI import controller_nonMPI |
10 | 10 | from pySDC.projects.PinTSimE.battery_model import get_recomputed |
@@ -116,7 +116,7 @@ def main(use_switch_estimator=True): |
116 | 116 |
|
117 | 117 | # fill description dictionary for easy step instantiation |
118 | 118 | description = dict() |
119 | | - description['problem_class'] = battery_n_condensators # pass problem class |
| 119 | + description['problem_class'] = battery_n_capacitors # pass problem class |
120 | 120 | description['problem_params'] = problem_params # pass problem parameters |
121 | 121 | description['sweeper_class'] = imex_1st_order # pass sweeper |
122 | 122 | description['sweeper_params'] = sweeper_params # pass sweeper parameters |
@@ -150,7 +150,7 @@ def main(use_switch_estimator=True): |
150 | 150 |
|
151 | 151 | recomputed = False |
152 | 152 |
|
153 | | - check_solution(stats, use_switch_estimator) |
| 153 | + check_solution(stats, level_params['dt'], use_switch_estimator) |
154 | 154 |
|
155 | 155 | plot_voltages(description, recomputed, use_switch_estimator) |
156 | 156 |
|
@@ -203,28 +203,60 @@ def plot_voltages(description, recomputed, use_switch_estimator, cwd='./'): |
203 | 203 | plt_helper.plt.close(fig) |
204 | 204 |
|
205 | 205 |
|
206 | | -def check_solution(stats, use_switch_estimator): |
| 206 | +def check_solution(stats, dt, use_switch_estimator): |
207 | 207 | """ |
208 | 208 | Function that checks the solution based on a hardcoded reference solution. Based on check_solution function from @brownbaerchen. |
209 | 209 |
|
210 | 210 | Args: |
211 | 211 | stats (dict): Raw statistics from a controller run |
| 212 | + dt (float): initial time step |
212 | 213 | use_switch_estimator (bool): flag if the switch estimator wants to be used or not |
213 | 214 | """ |
214 | 215 |
|
215 | 216 | data = get_data_dict(stats, use_switch_estimator) |
216 | 217 |
|
217 | 218 | if use_switch_estimator: |
218 | | - msg = 'Error when using the switch estimator for battery_2condensators:' |
219 | | - expected = { |
220 | | - 'cL': 1.2065280755094876, |
221 | | - 'vC1': 1.0094825899806945, |
222 | | - 'vC2': 1.0050052828742688, |
223 | | - 'switch1': 1.6094379124373626, |
224 | | - 'switch2': 3.209437912457051, |
225 | | - 'restarts': 2.0, |
226 | | - 'sum_niters': 1568, |
227 | | - } |
| 219 | + msg = f'Error when using the switch estimator for battery_2condensators for dt={dt:.1e}:' |
| 220 | + if dt == 1e-2: |
| 221 | + expected = { |
| 222 | + 'cL': 1.2065280755094876, |
| 223 | + 'vC1': 1.0094825899806945, |
| 224 | + 'vC2': 1.0050052828742688, |
| 225 | + 'switch1': 1.6094379124373626, |
| 226 | + 'switch2': 3.209437912457051, |
| 227 | + 'restarts': 2.0, |
| 228 | + 'sum_niters': 1568, |
| 229 | + } |
| 230 | + elif dt == 4e-1: |
| 231 | + expected = { |
| 232 | + 'cL': 1.1842780233981391, |
| 233 | + 'vC1': 1.0094891393319418, |
| 234 | + 'vC2': 1.00103823232433, |
| 235 | + 'switch1': 1.6075867934844466, |
| 236 | + 'switch2': 3.209437912436633, |
| 237 | + 'restarts': 2.0, |
| 238 | + 'sum_niters': 2000, |
| 239 | + } |
| 240 | + elif dt == 4e-2: |
| 241 | + expected = { |
| 242 | + 'cL': 1.180493652021971, |
| 243 | + 'vC1': 1.0094825917376264, |
| 244 | + 'vC2': 1.0007713468084405, |
| 245 | + 'switch1': 1.6094074085553605, |
| 246 | + 'switch2': 3.209437912440314, |
| 247 | + 'restarts': 2.0, |
| 248 | + 'sum_niters': 2364, |
| 249 | + } |
| 250 | + elif dt == 4e-3: |
| 251 | + expected = { |
| 252 | + 'cL': 1.1537529501025199, |
| 253 | + 'vC1': 1.001438946726028, |
| 254 | + 'vC2': 1.0004331625246141, |
| 255 | + 'switch1': 1.6093728710270467, |
| 256 | + 'switch2': 3.217437912434171, |
| 257 | + 'restarts': 2.0, |
| 258 | + 'sum_niters': 8920, |
| 259 | + } |
228 | 260 |
|
229 | 261 | got = { |
230 | 262 | 'cL': data['cL'][-1], |
|
0 commit comments