53 buf, (so, se) = io.StringIO(), (sys.stdout, sys.stderr)
55 sys.stdout = sys.stderr = buf
56 sim = RadClusterSimulation(I=I, V=V, solver_mode=
"full_system",
57 equations=equations, cascade=
"fission",
58 he_kinetics=
"quasi_steady_state",
59 i_mobile=5, v_mobile=5)
60 if equations ==
"bin_moment":
62 re_mod.apply_bin_config(sim, {
"equations":
"bin_moment",
63 "i_discrete": I,
"v_discrete": V,
64 "I_bin": 0,
"V_bin": 0,
65 "shape_function":
"linear"})
66 sim.input_data._calculate_derived()
68 G = float(sim.input_data.reactions[
"G"])
69 cfg = {
"t_span": (1e-6, DOSE / G),
"n_points": 16,
"log_time":
True,
70 "rtol": 1e-5,
"atol": 1e-20,
"timeout_s": 900,
71 "solver_method": {
"linsol":
"gmres",
"preconditioner":
"woodbury",
72 "concentration_threshold": 1e-22},
74 return sim.run(solver_config=cfg, save_output=
False), sim
76 sys.stdout, sys.stderr = so, se
81 if "--big" in sys.argv:
85 rb, sb =
run(
"bin_moment")
86 rd, _ =
run(
"discrete")
87 yb, yd = np.asarray(rb[
"y"]), np.asarray(rd[
"y"])
88 print(f
"state length: bin_moment {yb.shape[0]}, discrete {yd.shape[0]}"
89 f
" (N_eq {getattr(sb.rate_equations, 'N_eq', '?')})")
92 print(f
"\nper-size 1/2<111> at the final time:\n{'n':>5} {'bin_moment':>13}"
93 f
" {'discrete':>13} {'ratio':>10}")
94 for n
in (2, 5, 10, 20, 40, 80, 150, 300, 600, I - 1):
95 a, b = yb[n - 1, -1], yd[n - 1, -1]
96 r = a / b
if b
else float(
"inf")
97 worst = max(worst, abs(r - 1.0))
98 print(f
"{n:5d} {a:13.5e} {b:13.5e} {r:10.4f}")
100 print(
"\nBoth paths must carry loop-loop coarsening (P.loop_coal) and pile a")
101 print(
"product past the grid edge AT the edge. When rhs_case2 lacked the")
102 print(
"channel the per-size ratio ran 0.49 at n=40 and 906 at n=150; when it")
103 print(
"had the channel but dropped the overflow instead of piling it, the")
104 print(
"last size sat at 2.24x while everything below agreed to 0.04%.")
106 for k
in (
"mean_n_111",
"N_loops_111",
"mean_n_v"):
107 a = float(np.asarray(rb[k])[-1])
108 b = float(np.asarray(rd[k])[-1])
109 rel = abs(a - b) / max(abs(b), 1e-300)
110 flag =
" <-- DISAGREES" if rel > TOL
else " ok"
111 print(f
" {k:14s} bm={a:12.5e} disc={b:12.5e} rel={rel:9.2e}{flag}")
113 ok = all(abs(float(np.asarray(rb[k])[-1]) - float(np.asarray(rd[k])[-1]))
114 / max(abs(float(np.asarray(rd[k])[-1])), 1e-300) <= TOL
115 for k
in (
"mean_n_111",
"N_loops_111"))
116 print(
"\nRESULT:",
"paths agree" if ok
else "PATHS DISAGREE")
117 return 0
if ok
else 1