25def run_case(equations, loop_conversion, linsol='gmres', label=''):
27 sim = RadClusterSimulation(
28 I=I, V=V, solver_mode=
'full_system',
29 equations=equations, cascade=
'fission',
30 C_floor=1e-25, he_kinetics=
'quasi_steady_state',
31 i_mobile=5, v_mobile=2,
34 overrides = {
'T': 673}
35 if equations ==
'bin_moment':
36 overrides.update(i_discrete=8, v_discrete=4, I_bin=10, V_bin=6,
37 shape_function=
'linear')
39 overrides.update(i_discrete=I, v_discrete=V, I_bin=0, V_bin=0)
40 overrides[
'n_loop_min'] = 4
43 for key, val
in overrides.items():
45 for d
in (inp.production_fission, inp.production_fusion, inp.diffusion,
46 inp.reactions, inp.energetics, inp.dissociation):
51 inp.reactions[key] = val
52 inp._calculate_derived()
56 't_span': (1e-6, 1.0),
'n_points': 40,
'log_time':
True,
57 'rtol': 1e-6,
'atol': 1e-20,
'timeout_s': 120,
58 'loop_conversion': int(loop_conversion),
59 'solver_method': {
'linsol': linsol,
'preconditioner':
'Jacobi'},
63 old = sys.stdout, sys.stderr
64 sys.stdout = sys.stderr = buf
66 results = sim.run(solver_config=solver_config, save_output=
False)
67 except Exception
as exc:
68 sys.stdout, sys.stderr = old
69 print(f
"[{label}] EXCEPTION: {type(exc).__name__}: {exc}")
70 print(buf.getvalue()[-2000:])
73 sys.stdout, sys.stderr = old
76 print(f
"[{label}] no results")
77 print(buf.getvalue()[-2000:])
82 return float(a[-1])
if a
is not None and len(a)
else float(
'nan')
84 dFP = last(
'delta_FP')
85 n100 = last(
'N_loops_100')
86 n111 = last(
'N_loops_111')
87 f111 = last(
'f_111_loop')
88 mean100 = last(
'mean_n_100')
89 npts = len(results.get(
't', []))
90 print(f
"[{label}] pts={npts:3d} delta_FP={dFP:.2e} "
91 f
"N_111={n111:.3e} N_100={n100:.3e} f_111={f111:.4f} "
92 f
"mean_n_100={mean100:.2f}")