1"""Does the d_111 deficit scale with i_discrete rather than with I_bin?
3The M2R ladder held i_discrete = 50 and varied I_bin 2 -> 33. The deficit was
4flat at ~-5 to -7% across all of it, and B8 agrees with B32 far better than
5either agrees with the exact arm. An error that does not respond to the knob
6being turned is controlled by a knob that was NOT turned -- and the one held
7fixed is the discrete/bin interface at i_discrete.
9The I_bin = 0 control passed to 0.000% precisely because i_discrete = I there,
10i.e. no interface at all. So: hold I_bin and sweep i_discrete. If the
11deficit collapses as i_discrete grows, the fault is at the interface (or in the
12binned region's treatment of sizes just above it), not in bin resolution.
15sys.path.insert(0,
"/Users/ghoni/Documents/GitHub/RadCluster")
16sys.path.insert(0,
"/Users/ghoni/Documents/GitHub/RadCluster/radcluster_code/digital_twin")
17os.environ[
"OMP_NUM_THREADS"] =
"4"
18from radcluster_code.py_utils.simulation
import RadClusterSimulation
19import run_ensemble
as re_mod
21I, DOSE = 1000, float(os.environ.get(
"PDOSE",
"0.05"))
22i_d, nb = int(sys.argv[1]), int(sys.argv[2])
23eq =
"discrete" if nb == 0
and i_d >= I
else "bin_moment"
25sim = RadClusterSimulation(I=I, V=I, solver_mode=
"full_system", equations=eq,
26 cascade=
"fission", he_kinetics=
"quasi_steady_state",
27 i_mobile=5, v_mobile=5)
28cfg = {
"equations": eq,
"i_discrete": i_d,
"v_discrete": i_d,
29 "I_bin": nb,
"V_bin": nb,
"shape_function":
"linear"}
30re_mod.apply_bin_config(sim, cfg)
31sim.input_data.reactions[
"LOOP_NETWORK_LOSS"] = 1
32sim.input_data.reactions[
"LOOP_COAL"] = 1
33sim.input_data._calculate_derived(); sim.rebuild_rates()
34G = float(sim.input_data.reactions[
"G"])
35scfg = {
"t_span": (1e-6, DOSE / G),
"n_points": 45,
"log_time":
True,
36 "required_times": (DOSE / G,),
"rtol": 1e-5,
"atol": 1e-20,
38 "solver_method": {
"linsol":
"gmres",
"preconditioner":
"woodbury",
39 "concentration_threshold": 1e-22},
42res = sim.run_adaptive(solver_config=scfg, save_output=
False, timeout_s=1800,
45cfg2 = dict(cfg); cfg2.update({
"I": I,
"V": I,
"dose": DOSE,
46 "C_floor": float(sim.input_data.reactions.get(
"C_floor", 1e-15))})
47o = re_mod.observe(res, sim, cfg2, 1.0)
48neq = int(getattr(sim.rate_equations,
"N_eq", -1))
49print(f
"IDRESULT i_d={i_d:5d} I_bin={nb:3d} N_eq={neq:5d} wall={w:6.1f}s "
50 f
"N_111={o['N_loops_111']:.4e} d_111={o['d_111_nm']:.4f} "
51 f
"mean_n_111={o['mean_n_111']:.2f} d_100={o['d_100_nm']:.4f} "
52 f
"d_cav={o['d_cavity_nm']:.4f}")