RadCluster
Graph-based cluster dynamics for irradiated materials
Loading...
Searching...
No Matches
check_loop_conversion_params.py
Go to the documentation of this file.
1"""
2check_loop_conversion_params.py — Phase-5 test: the ½⟨111⟩→⟨100⟩ conversion
3parameters are configurable through the Excel input path.
4
5Verifies that the 9 conversion/junction parameters added to the `Reactions`
6sheet:
7 1. load into ``InputData.reactions`` with the documented defaults;
8 2. are consumed by ``ReactionRates`` (LoopEnergetics T*/n_ref, n_loop_min);
9 3. actually drive the physics — overriding ``T_star_conv_C`` shifts the
10 calibrated ⟨100⟩ prelog magnitude F̂_100^0 and the conversion support.
11
12Run: python codes/Python_Testing/check_loop_conversion_params.py
13"""
14import sys
15from pathlib import Path
16
17ROOT = Path(__file__).resolve().parents[2]
18sys.path.insert(0, str(ROOT))
19
20from py_utils.input_data import InputData
21from py_utils.reaction_rates import ReactionRates
22
23DEFAULTS = {
24 "E_a0_conv": 1.8, "gamma_a_conv": 0.03, "nu0_conv": 1.0e13,
25 "T_star_conv_C": 450.0, "n_ref_conv": 30, "phi_max_junc": 0.5,
26 "sigma_s_junc": 0.35, "n_j_min_junc": 30, "n_loop_min": 4,
27}
28
29_fails = 0
30
31
32def check(name, cond, *info):
33 global _fails
34 if not cond:
35 _fails += 1
36 print(f" {'PASS' if cond else 'FAIL'} {name} {info if info else ''}")
37
38
39def main():
40 inp = InputData(I=200, V=200, physics_option="full_CD_fission")
41
42 # 1. loaded with documented defaults
43 for k, v in DEFAULTS.items():
44 got = inp.reactions.get(k)
45 check(f"{k} loaded", got is not None and abs(float(got) - float(v)) < 1e-9,
46 got)
47
48 # 2. consumed by ReactionRates
49 rr = ReactionRates(inp)
50 check("LoopEnergetics T* consumed",
51 abs(rr.loop_energetics.T_star_C - DEFAULTS["T_star_conv_C"]) < 1e-9,
52 rr.loop_energetics.T_star_C)
53 check("n_loop_min consumed", rr.n_loop_min == DEFAULTS["n_loop_min"],
54 rr.n_loop_min)
55
56 # 3. params drive the physics — override T* and confirm F̂_100^0 + support move
57 f0 = rr.loop_energetics.Fhat_100_0
58 supp0 = int((rr.Gamma_uni > 0).sum())
59 inp.reactions["T_star_conv_C"] = 520.0
60 rr2 = ReactionRates(inp)
61 f1 = rr2.loop_energetics.Fhat_100_0
62 supp1 = int((rr2.Gamma_uni > 0).sum())
63 check("override T* shifts Fhat_100_0", abs(f1 - f0) > 1e-6, (f0, f1))
64 check("override T* shifts conversion support", supp1 != supp0, (supp0, supp1))
65
66 print(f"\n{'ALL PASS' if not _fails else str(_fails) + ' FAILED'}")
67 return 1 if _fails else 0
68
69
70if __name__ == "__main__":
71 sys.exit(main())