44 def check(name, cond, *info):
46 tag =
"PASS" if cond
else "FAIL"
49 print(f
" {tag} {name} {info if info else ''}")
54 check(
"Gamma_uni shape == (I,)", G.shape == (I,), G.shape)
55 check(
"Gamma_uni >= 0", np.all(G >= 0.0))
56 check(
"Gamma_uni == 0 where dF <= 0", np.all(G[dF <= 0.0] == 0.0))
57 check(
"Gamma_uni > 0 for some (small) loops", np.any(G > 0.0),
58 f
"max={G.max():.3e} at n={int(G.argmax())+1}")
60 converting = np.where(G > 0.0)[0]
62 check(
"conversion support is small-loop biased",
63 converting.max() + 1 < I // 2,
64 f
"sizes n in [{converting.min()+1}, {converting.max()+1}]")
68 phi_max = float(inp.reactions.get(
"phi_max_junc", 0.5))
69 n_j_min = float(inp.reactions.get(
"n_j_min_junc", 30.0))
70 check(
"phi_junc shape == (I, I)", phi.shape == (I, I), phi.shape)
71 check(
"phi_junc in [0, phi_max]", np.all(phi >= 0.0)
and np.all(phi <= phi_max + 1e-12))
72 check(
"phi_junc symmetric", np.allclose(phi, phi.T, atol=1e-12))
73 check(
"phi_junc == 0 below n_j_min",
74 np.all(phi[: int(n_j_min) - 1, :] == 0.0)
and
75 np.all(phi[:, : int(n_j_min) - 1] == 0.0))
78 check(
"phi_junc peaks on the diagonal", abs(phi[k, k] - phi[k].max()) < 1e-12,
79 f
"phi[{k},{k}]={phi[k,k]:.3f}")
82 nlm = int(rr.n_loop_min)
83 check(
"K_100_grow == 0 below n_loop_min", np.all(rr.K_100_grow[: nlm - 1] == 0.0))
84 check(
"K_100_grow > 0 at/above n_loop_min", np.all(rr.K_100_grow[nlm - 1:] > 0.0))
85 check(
"K_100_shrink >= 0", np.all(rr.K_100_shrink >= 0.0))
86 check(
"G_100 (emission) >= 0", np.all(rr.G_100 >= 0.0))
87 check(
"G_100[0] == 0 (monomer cannot emit)", rr.G_100[0] == 0.0)
88 check(
"k2_100 == 0 (sessile)", np.all(rr.k2_100 == 0.0))
91 le = rr.loop_energetics
92 T = float(inp.derived[
"T"])
93 check(
"conversion_dF matches LoopEnergetics",
94 np.allclose(dF, le.driving_force_array(T, I), atol=1e-12))
96 print(f
"\n{'ALL PASS' if not fails else str(fails) + ' FAILED'}")
98 print(f
" [info] T={T:.0f} K, Gamma_uni max={G.max():.3e} s^-1, "
99 f
"converting sizes n<= {converting.max()+1 if converting.size else 0}, "
100 f
"Fhat_100_0={le.Fhat_100_0:.4f} eV/A")
101 return 1
if fails
else 0