d0fus 3.2.0__tar.gz → 3.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_cost_functions.py +10 -9
  2. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_figures.py +86 -60
  3. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_parameterization.py +107 -50
  4. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_physical_functions.py +158 -130
  5. d0fus-3.3.0/D0FUS_BIB/D0FUS_power_flow.py +618 -0
  6. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_radial_build_functions.py +146 -201
  7. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_EXE/D0FUS_run.py +287 -95
  8. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_EXE/D0FUS_scan.py +1 -1
  9. {d0fus-3.2.0 → d0fus-3.3.0}/PKG-INFO +10 -6
  10. {d0fus-3.2.0 → d0fus-3.3.0}/README.md +7 -3
  11. {d0fus-3.2.0 → d0fus-3.3.0}/d0fus.egg-info/PKG-INFO +10 -6
  12. {d0fus-3.2.0 → d0fus-3.3.0}/d0fus.egg-info/SOURCES.txt +7 -1
  13. {d0fus-3.2.0 → d0fus-3.3.0}/pyproject.toml +3 -3
  14. d0fus-3.3.0/tests/test_blanket_layers.py +61 -0
  15. d0fus-3.3.0/tests/test_modes.py +61 -0
  16. d0fus-3.3.0/tests/test_physical_functions.py +83 -0
  17. d0fus-3.3.0/tests/test_plant_balance.py +109 -0
  18. d0fus-3.3.0/tests/test_radial_build_functions.py +164 -0
  19. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS.py +0 -0
  20. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_cost_data.py +0 -0
  21. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_import.py +0 -0
  22. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_BIB/D0FUS_machine_presets.py +0 -0
  23. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_EXE/D0FUS_genetic.py +0 -0
  24. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_EXE/D0FUS_popcon.py +0 -0
  25. {d0fus-3.2.0 → d0fus-3.3.0}/D0FUS_EXE/D0FUS_uncertainty.py +0 -0
  26. {d0fus-3.2.0 → d0fus-3.3.0}/LICENSE +0 -0
  27. {d0fus-3.2.0 → d0fus-3.3.0}/d0fus.egg-info/dependency_links.txt +0 -0
  28. {d0fus-3.2.0 → d0fus-3.3.0}/d0fus.egg-info/entry_points.txt +0 -0
  29. {d0fus-3.2.0 → d0fus-3.3.0}/d0fus.egg-info/requires.txt +0 -0
  30. {d0fus-3.2.0 → d0fus-3.3.0}/d0fus.egg-info/top_level.txt +0 -0
  31. {d0fus-3.2.0 → d0fus-3.3.0}/setup.cfg +0 -0
@@ -164,7 +164,7 @@ def f_costs_Whyte(discount_rate, T_life, S_FW, t_life_bl_fpy, f_burn, E_net):
164
164
  #%% 3. Sheffield (2016) model (2010 US$)
165
165
 
166
166
  def f_costs_Sheffield(discount_rate, contingency, T_life, T_build,
167
- P_t, P_t_smoothed, P_e, E_net, P_aux, E_store_th,
167
+ P_t, P_t_turbine, P_e, E_net, P_aux, E_store_th,
168
168
  Av, t_rep_bl_yr, t_rep_div_yr,
169
169
  V_FI, V_pc, V_sg, V_bl, S_tt,
170
170
  Supra_cost_factor):
@@ -194,8 +194,9 @@ def f_costs_Sheffield(discount_rate, contingency, T_life, T_build,
194
194
  - The COE divides by the annual net electricity E_net, which counts
195
195
  the fixed loads (cryoplant, house load) over the whole year,
196
196
  outages included.
197
- - Pulsed plant: the BoP thermal scaling uses the turbine-side thermal
198
- power P_t_smoothed, and the thermal store is costed (c_store_sfd).
197
+ - Pulsed plant: the BoP thermal scaling uses the turbine thermal
198
+ design power P_t_turbine, and the thermal store is costed
199
+ (c_store_sfd).
199
200
  The turbine term keeps the net P_e, on which Sheffield & Milora
200
201
  calibrated it (900 M$ at 1200 MWe).
201
202
 
@@ -207,9 +208,9 @@ def f_costs_Sheffield(discount_rate, contingency, T_life, T_build,
207
208
  T_build : int Construction time [yr].
208
209
  P_t : float Thermal power during the burn [MWth]
209
210
  (heat transfer system).
210
- P_t_smoothed : float Thermal power to the turbine, cycle average
211
- through the thermal store [MWth]. P_t in steady
212
- state.
211
+ P_t_turbine : float Turbine thermal design power, the largest heat
212
+ flow to the turbine over the burn and the dwell
213
+ [MWth]. P_t in steady state.
213
214
  P_e : float Net electric power, cycle average during
214
215
  operation [MWe], >= 0 (BoP and O&M scalings).
215
216
  E_net : float Annual net electricity [MWh/yr]. The COE is NaN
@@ -253,7 +254,7 @@ def f_costs_Sheffield(discount_rate, contingency, T_life, T_build,
253
254
  C_bl, spare_tt_sfd, C_tt,
254
255
  spare_aux_sfd, C_aux)
255
256
  (C_D, C_BOP_tot, C_syst) = f_direct_cost_Sheffield(C_BoP_sfd, C_tur_sfd,
256
- P_tur_sfd, P_e, P_t_smoothed,
257
+ P_tur_sfd, P_e, P_t_turbine,
257
258
  P_BoP_sfd, x_BoP_sfd,
258
259
  C_bld_sfd, V_bld_sfd,
259
260
  x_bld_sfd, V_FI, C_FI, C_st)
@@ -515,7 +516,7 @@ if __name__ == "__main__":
515
516
  return err < tol_pct
516
517
 
517
518
  print("=" * 72)
518
- print(" D0FUS_cost_functions.py — standalone validation")
519
+ print(" D0FUS_cost_functions.py — standalone verification")
519
520
  print("=" * 72)
520
521
 
521
522
  # ── 1. Capital Recovery Factor ───────────────────────────────────────────
@@ -557,7 +558,7 @@ if __name__ == "__main__":
557
558
  T_life = 40,
558
559
  T_build = 8,
559
560
  P_t = 4150.0,
560
- P_t_smoothed = 4150.0,
561
+ P_t_turbine = 4150.0,
561
562
  P_e = _P_e,
562
563
  E_net = _E_net,
563
564
  P_aux = 200.0,
@@ -1433,7 +1433,7 @@ def plot_TF_thickness_vs_field(
1433
1433
  mechanical models (Academic/refined × Wedging/Bucking).
1434
1434
 
1435
1435
  An optional MADE benchmark scatter dataset is superimposed on the Wedging
1436
- panel for EU-DEMO validation.
1436
+ panel for EU-DEMO verification.
1437
1437
 
1438
1438
  Parameters
1439
1439
  ----------
@@ -1445,7 +1445,7 @@ def plot_TF_thickness_vs_field(
1445
1445
  Default 60 MA/m². The refined cable model (Maddock
1446
1446
  adiabatic hotspot) predicts ~40 MA/m² for HTS at
1447
1447
  20 T,
1448
- From Giannini 2023 Fig. 20 (validated FEM
1448
+ From Giannini 2023 Fig. 20 (FEM-verified
1449
1449
  design at 20.3 T): 234 conductors × 107 kA over
1450
1450
  a WP area of 0.67 m² gives J_WP = 38 MA/m²
1451
1451
  (including steel). Correcting for a typical jacket
@@ -3056,25 +3056,30 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3056
3056
  R_lcfs = R0 + a * np.cos(theta + np.arcsin(delta) * np.sin(theta))
3057
3057
  Z_lcfs = (kappa * a) * np.sin(theta)
3058
3058
 
3059
- _rb = f_radial_build_layers(
3060
- a=a, b=b, κ=kappa, δ=delta, R0=R0, Delta_TF=Delta_TF,
3061
- f_kappa_SOL=f_kappa_SOL, f_div_area_fraction=f_div,
3062
- R_tf_in=R_tf_in, Z_tf_in=Z_tf_in, Blanket_choice=Blanket_choice)
3063
- layers = _rb["layers"]
3059
+ from .D0FUS_parameterization import radial_build_feasibility
3060
+ _availability = radial_build_feasibility(Blanket_choice, b, Delta_TF)
3061
+ # Keep one rendering pipeline for feasible and infeasible builds. The
3062
+ # latter has no radial layers, but retains the *identical* coil geometry,
3063
+ # palette, legend placement, dimension arrows, axes and title.
3064
+ _layers_feasible = bool(_availability["feasible"])
3065
+ if _layers_feasible:
3066
+ _rb = f_radial_build_layers(
3067
+ a=a, b=b, κ=kappa, δ=delta, R0=R0, Delta_TF=Delta_TF,
3068
+ f_kappa_SOL=f_kappa_SOL, f_div_area_fraction=f_div,
3069
+ R_tf_in=R_tf_in, Z_tf_in=Z_tf_in, Blanket_choice=Blanket_choice,
3070
+ delta_BB_IB=float(run.get("delta_BB_IB", 0.50)),
3071
+ delta_BB_OB=float(run.get("delta_BB_OB", 0.50)),
3072
+ delta_shield_IB=float(run.get("delta_shield_IB", 0.30)),
3073
+ delta_shield_OB=float(run.get("delta_shield_OB", 0.30)))
3074
+ layers = _rb["layers"]
3075
+ else:
3076
+ layers = []
3064
3077
  N = len(layers)
3065
- i_breeder = next(i for i, L in enumerate(layers) if L["role"] == "breeder")
3078
+ i_breeder = next((i for i, L in enumerate(layers)
3079
+ if L["role"] == "breeder"), None)
3066
3080
 
3067
- # The breeder outer boundary is the deepest inward offset of the TF face and
3068
- # can still self-intersect at the rounded junction; a stronger periodic
3069
- # smoothing there (and a lighter one on the shallower outer layers) removes
3070
- # the residual spike. A self-intersection is a high-frequency feature, so a
3071
- # wide Hann window averages it into a smooth bulge.
3072
- for i, L in enumerate(layers):
3073
- if i >= i_breeder:
3074
- frac_o = 0.08 if i == i_breeder else 0.045
3075
- L["R_outer"], L["Z_outer"] = _smooth_closed(L["R_outer"], L["Z_outer"], frac=frac_o)
3076
- if i > i_breeder:
3077
- L["R_inner"], L["Z_inner"] = _smooth_closed(L["R_inner"], L["Z_inner"], frac=0.045)
3081
+ # Layer contours are already nested on common polar rays; independently
3082
+ # smoothing them would alter layer widths and can create overlaps.
3078
3083
 
3079
3084
  # -- Colour scheme ------------------------------------------------------
3080
3085
  ALPHA = 0.72
@@ -3166,7 +3171,7 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3166
3171
  OUT = dict(color=col_line, lw=0.9, zorder=zbase + N + 4)
3167
3172
  SOL_L = next((L for L in layers if L["role"] == "SOL"), None)
3168
3173
  FW_L = next((L for L in layers if L["role"] == "FW"), None)
3169
- BB_L = layers[i_breeder]
3174
+ BB_L = layers[i_breeder] if i_breeder is not None else None
3170
3175
  green_outer_L = layers[green_order[-1]] if green_order else BB_L
3171
3176
 
3172
3177
  def _outline(R, Z):
@@ -3178,8 +3183,10 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3178
3183
  _outline(SOL_L["R_outer"], SOL_L["Z_outer"]) # plasma+SOL group
3179
3184
  if FW_L is not None:
3180
3185
  _outline(FW_L["R_outer"], FW_L["Z_outer"]) # first wall
3181
- _outline(BB_L["R_outer"], BB_L["Z_outer"]) # breeding blanket
3182
- _outline(green_outer_L["R_outer"], green_outer_L["Z_outer"]) # structure/shield/VV block
3186
+ if BB_L is not None:
3187
+ _outline(BB_L["R_outer"], BB_L["Z_outer"]) # breeding blanket
3188
+ if green_outer_L is not None:
3189
+ _outline(green_outer_L["R_outer"], green_outer_L["Z_outer"]) # structure/shield/VV
3183
3190
  _outline(R_tf_in, Z_tf_in) # TF inner face
3184
3191
  _outline(R_tf_out, Z_tf_out) # TF outer face
3185
3192
 
@@ -3204,8 +3211,9 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3204
3211
  def _clean(nm):
3205
3212
  return nm.split("(")[0].strip() if "(" in nm else nm
3206
3213
 
3207
- leg = [Patch(fc=col_plasma, alpha=ALPHA, ec="grey", lw=0.4, label="Plasma"),
3208
- Patch(fc=col_sol, ec="grey", lw=0.4, label="Scrape-off layer")]
3214
+ leg = [Patch(fc=col_plasma, alpha=ALPHA, ec="grey", lw=0.4, label="Plasma")]
3215
+ if _layers_feasible:
3216
+ leg.append(Patch(fc=col_sol, ec="grey", lw=0.4, label="Scrape-off layer"))
3209
3217
  seen = set()
3210
3218
  for i, L in enumerate(layers):
3211
3219
  r = L["role"]
@@ -4133,13 +4141,13 @@ def plot_all(
4133
4141
  _p("1c", "δ = 0.6 (κ − 1) vs machines")
4134
4142
  plot_delta_trend(save_dir=save_dir)
4135
4143
 
4136
- _p(2, "Shaping profiles κ(ρ), δ(ρ) — validation")
4144
+ _p(2, "Shaping profiles κ(ρ), δ(ρ) — verification")
4137
4145
  plot_shaping_profiles(save_dir=save_dir)
4138
4146
 
4139
4147
  _p(3, "Run shaping profiles κ(ρ), δ(ρ)")
4140
4148
  plot_shaping_run(run, save_dir=save_dir)
4141
4149
 
4142
- _p(4, "Miller flux surfaces — validation")
4150
+ _p(4, "Miller flux surfaces — verification")
4143
4151
  plot_miller_surfaces(save_dir=save_dir)
4144
4152
 
4145
4153
  _p(5, "Run Miller flux surfaces")
@@ -4215,8 +4223,8 @@ def plot_all(
4215
4223
  _p(24, "CS thickness vs flux swing")
4216
4224
  plot_CS_thickness_vs_flux(cfg=cfg, save_dir=save_dir)
4217
4225
 
4218
- _p(25, "CIRCE stress-model validation")
4219
- plot_CIRCE_stress_validation(save_dir=save_dir)
4226
+ _p(25, "CIRCE stress-model verification")
4227
+ plot_CIRCE_stress_verification(save_dir=save_dir)
4220
4228
 
4221
4229
  _p(26, "Radial build assembly (CS / TF / blanket)")
4222
4230
  plot_assembly_side_view(run, save_dir=save_dir)
@@ -4240,35 +4248,47 @@ def plot_all(
4240
4248
  print("Done.")
4241
4249
 
4242
4250
 
4251
+ def plot_plant_power_balance(run: dict, phase: str = "pulse", save_dir=None) -> None:
4252
+ """Power-flow Sankey: connected pulse/dwell paths and recirculation loops.
4253
+
4254
+ Delegates to the dependency-light renderer (no additional package).
4255
+ All values are computed by D0FUS; its electrical model is unchanged.
4256
+ """
4257
+ from .D0FUS_power_flow import plot_plant_power_balance as _render_flow
4258
+ _render_flow(run, phase=phase, save_dir=save_dir)
4259
+
4260
+
4243
4261
  def plot_run(
4244
4262
  run: dict,
4245
4263
  save_dir: str | None = None,
4246
4264
  view_3d: bool = True,
4247
4265
  ) -> None:
4248
4266
  """
4249
- Render the run-specific figure set (16 figures, 15 without the 3D view).
4267
+ Render the run-specific figure set (18 figures, 17 without the 3D view).
4250
4268
 
4251
4269
  This is the subset called after each D0FUS run. It contains only the
4252
4270
  figures that depend on the current run configuration and results —
4253
- no validation curves, no benchmarks, no scaling-law surveys.
4271
+ no verification curves, no benchmarks, no scaling-law surveys.
4254
4272
 
4255
4273
  Figures produced:
4256
- [ 1/16] Tokamak LCFS comparison (with D0FUS overlay)
4257
- [ 2/16] Miller flux surfaces (run geometry)
4258
- [ 3/16] Shaping profiles κ(ρ), δ(ρ)
4259
- [ 4/16] Kinetic profiles n(ρ), T(ρ), p(ρ)
4260
- [ 5/16] Safety factor q(ρ) and current decomposition
4261
- [ 6/16] Radiation profiles
4262
- [ 7/16] Divertor two-point model (detachment vs SOL dissipation)
4263
- [ 8/16] Radial build assembly (CS / TF / blanket)
4264
- [ 9/16] TF coil side view
4265
- [10/16] CICC TF conductor
4266
- [11/16] CS cross-section
4267
- [12/16] CICC CS conductor
4268
- [13/16] Cost breakdown (Sheffield 2016, CapEx / OpEx / COE)
4269
- [14/16] Plasma temperature map T(rho)
4270
- [15/16] Plasma density map n(rho)
4271
- [16/16] 3D machine view (PyVista; skipped if PyVista is missing,
4274
+ [ 1/18] Tokamak LCFS comparison (with D0FUS overlay)
4275
+ [ 2/18] Miller flux surfaces (run geometry)
4276
+ [ 3/18] Shaping profiles κ(ρ), δ(ρ)
4277
+ [ 4/18] Kinetic profiles n(ρ), T(ρ), p(ρ)
4278
+ [ 5/18] Safety factor q(ρ) and current decomposition
4279
+ [ 6/18] Radiation profiles
4280
+ [ 7/18] Divertor two-point model (detachment vs SOL dissipation)
4281
+ [ 8/18] Radial build assembly (CS / TF / blanket)
4282
+ [ 9/18] TF coil side view
4283
+ [10/18] CICC TF conductor
4284
+ [11/18] CS cross-section
4285
+ [12/18] CICC CS conductor
4286
+ [13/18] Cost breakdown (Sheffield 2016 or Whyte 2024, CapEx / OpEx / COE)
4287
+ [14/18] Plasma temperature map T(rho)
4288
+ [15/18] Plasma density map n(rho)
4289
+ [16/18] Plant power balance — pulse
4290
+ [17/18] Plant power balance — dwell
4291
+ [18/18] 3D machine view (PyVista; skipped if PyVista is missing,
4272
4292
  or with view_3d=False)
4273
4293
 
4274
4294
  The breeding-blanket concept comparison does not depend on the run: it
@@ -4283,7 +4303,7 @@ def plot_run(
4283
4303
  view_3d : bool
4284
4304
  False skips the 3D machine view (command-line option --no-3d).
4285
4305
  """
4286
- N = 16 if view_3d else 15
4306
+ N = 18 if view_3d else 17
4287
4307
 
4288
4308
  # When saving, prefix each PNG with its order index so that the files sort
4289
4309
  # in the logical reading order: geometry (Miller), profiles, physics detail,
@@ -4345,13 +4365,19 @@ def plot_run(
4345
4365
  lambda: plot_CICC_cross_section(build_conductor_from_run(run, coil="CS"), save_dir=save_dir))
4346
4366
 
4347
4367
  # ── Techno-economic synthesis ─────────────────────────────────────
4348
- _emit(13, "Cost breakdown (Sheffield 2016)",
4368
+ _emit(13, f"Cost breakdown ({(run.get('cost_breakdown') or {}).get('model', 'cost model off')})",
4349
4369
  lambda: plot_cost_breakdown(run, save_dir=save_dir))
4350
4370
 
4351
4371
  # ── Plasma field maps ────────────────────────────────────
4352
4372
  _emit(14, "Plasma temperature map", lambda: plot_temperature_map(run, save_dir=save_dir))
4353
4373
  _emit(15, "Plasma density map", lambda: plot_density_map(run, save_dir=save_dir))
4354
4374
 
4375
+ # ── Phase-specific energy and power balance ───────────────────────
4376
+ _emit(16, "Plant power balance (pulse)",
4377
+ lambda: plot_plant_power_balance(run, phase="pulse", save_dir=save_dir))
4378
+ _emit(17, "Plant power balance (dwell)",
4379
+ lambda: plot_plant_power_balance(run, phase="dwell", save_dir=save_dir))
4380
+
4355
4381
  # ── 3D machine view (optional PyVista dependency) ─────────────────
4356
4382
  # plot_tokamak_3D guards its own import and any render failure, so a
4357
4383
  # missing or broken PyVista installation never aborts the figure bank.
@@ -4362,20 +4388,20 @@ def plot_run(
4362
4388
  print(f" [warn] 3D machine view failed ({type(_e).__name__}: "
4363
4389
  f"{_e}) — skipped.")
4364
4390
  if view_3d:
4365
- _emit(16, "3D machine view (PyVista)", _fig_3d)
4391
+ _emit(18, "3D machine view (PyVista)", _fig_3d)
4366
4392
 
4367
4393
  print("Done.")
4368
4394
 
4369
4395
  # =============================================================================
4370
- # 7. CIRCE stress-model validation
4396
+ # 7. CIRCE stress-model verification
4371
4397
  # =============================================================================
4372
4398
 
4373
- def plot_CIRCE_stress_validation(
4399
+ def plot_CIRCE_stress_verification(
4374
4400
  nu: float = 0.3,
4375
4401
  save_dir=None,
4376
4402
  ) -> None:
4377
4403
  """
4378
- Validate the F_CIRCE0D finite-element stress solver against three
4404
+ Verify the F_CIRCE0D finite-element stress solver against three
4379
4405
  analytical reference cases:
4380
4406
 
4381
4407
  Test 1 : Pressurised thin cylinder — Lamé exact solution.
@@ -4425,7 +4451,7 @@ def plot_CIRCE_stress_validation(
4425
4451
  ax.plot(r, sigma_t_lame / 1e6, "r--", lw=1.5, label=r"$\sigma_\theta$ (Lamé)")
4426
4452
  ax.set_xlabel("r [m]", fontsize=11)
4427
4453
  ax.set_ylabel("Stress [MPa]", fontsize=11)
4428
- ax.set_title("Test 1: Pressurised cylinder\n(Lamé analytical validation)", fontsize=10)
4454
+ ax.set_title("Test 1: Pressurised cylinder\n(Lamé analytical verification)", fontsize=10)
4429
4455
  ax.legend(fontsize=8)
4430
4456
  ax.grid(True, alpha=0.3)
4431
4457
 
@@ -4456,10 +4482,10 @@ def plot_CIRCE_stress_validation(
4456
4482
  ax.legend(loc="upper right", fontsize=8)
4457
4483
  ax.grid(True, alpha=0.3)
4458
4484
 
4459
- plt.suptitle("CIRCE0D stress-model validation suite",
4485
+ plt.suptitle("CIRCE0D stress-model verification suite",
4460
4486
  fontsize=13, fontweight="bold")
4461
4487
  plt.tight_layout()
4462
- _save_or_show(fig, save_dir, "CIRCE_stress_validation")
4488
+ _save_or_show(fig, save_dir, "CIRCE_stress_verification")
4463
4489
 
4464
4490
 
4465
4491
  # =============================================================================
@@ -5011,7 +5037,7 @@ def plot_CS_benchmark_table(cfg=None, save_dir=None) -> None:
5011
5037
  # 20.35 mm CICC with a 1.5 mm jacket carrying 14.5 kA at a
5012
5038
  # 23 mm pitch (Wu 2008, Guo 2016), i.e. 36 and not 45 MA/m2.
5013
5039
  # The same reconstruction on its TF conductor returns the
5014
- # value the TF benchmark already uses, which validates it.
5040
+ # value the TF benchmark already uses, which verifies it.
5015
5041
  "kappa": 1.9, "J_wost": 36e6, "Gap": 0.193, "H_CS": 2.75},
5016
5042
  "ARC": {"Ψplateau": 32.0, "a_cs": 1.10, "b_cs": 0.86, "c_cs": 0.64,
5017
5043
  "R0_cs": 3.30, "B_TF": 23, "B_cs": 12.9, "σ_CS": 700e6,
@@ -6066,7 +6092,7 @@ def build_figure_registry():
6066
6092
  run dict -> 'run' (rendered by plot_all on a run dict)
6067
6093
  results -> 'uncertainty' (Monte-Carlo robustness figures)
6068
6094
  scan_results -> 'scan'
6069
- anything else -> 'standalone' (parametric / validation figures
6095
+ anything else -> 'standalone' (parametric / verification figures
6070
6096
  taking explicit physics arguments)
6071
6097
 
6072
6098
  Returns
@@ -6106,7 +6132,7 @@ _CATEGORY_ORDER = ('meta', 'run', 'standalone', 'scan', 'uncertainty')
6106
6132
  _CATEGORY_LABEL = {
6107
6133
  'meta': 'META — full catalogue renderer',
6108
6134
  'run': 'RUN-DICT FIGURES — rendered from a D0FUS run dict',
6109
- 'standalone': 'STANDALONE FIGURES — parametric / validation '
6135
+ 'standalone': 'STANDALONE FIGURES — parametric / verification '
6110
6136
  '(explicit physics arguments)',
6111
6137
  'scan': 'SCAN FIGURES — rendered from scan-mode outputs',
6112
6138
  'uncertainty': 'UNCERTAINTY FIGURES — rendered from UQ outputs',
@@ -6289,7 +6315,7 @@ def _standalone_main():
6289
6315
  """
6290
6316
  D0FUS_uncertainty_figures.py -- decision-oriented plots for the uncertainty study.
6291
6317
 
6292
- Restyled for the thesis: one restrained, colourblind-safe palette (validated
6318
+ Restyled for the thesis: one restrained, colourblind-safe palette (checked
6293
6319
  status + categorical + single-blue slots), recessive axes, and a per-figure
6294
6320
  style applied through a context manager so it never leaks into the module's
6295
6321
  other (RUN/SCAN/GENETIC) figures. Each figure carries a one-line plain-language
@@ -6315,7 +6341,7 @@ reading note so it stands on its own:
6315
6341
  import functools
6316
6342
  from matplotlib.gridspec import GridSpec, GridSpecFromSubplotSpec
6317
6343
 
6318
- # --- validated, colourblind-safe palette (status + categorical + one blue) ----
6344
+ # --- checked, colourblind-safe palette (status + categorical + one blue) ------
6319
6345
  _INK, _INK2, _MUTED = "#1a1a19", "#52514e", "#8a8880"
6320
6346
  _GRIDC, _SURF = "#e4e3dd", "#ffffff"
6321
6347
  _GOOD, _AQUA, _BLUE, _BLUE_L = "#0ca30c", "#1baf7a", "#2a78d6", "#86b6ef"
@@ -109,7 +109,7 @@ class GlobalConfig:
109
109
  to a conservative DEMO-class power plant baseline.
110
110
 
111
111
  Instances are frozen: a field cannot be changed after creation. Derive a
112
- variant with dataclasses.replace(), which builds a new, validated object.
112
+ variant with dataclasses.replace(), which builds a new, checked object.
113
113
  Every field is checked at creation (see __post_init__): numbers must be
114
114
  numbers, booleans must be booleans, and option fields must take one of
115
115
  the values listed in CONFIG_OPTIONS.
@@ -151,6 +151,10 @@ class GlobalConfig:
151
151
  R0 : float = 9.0 # Major plasma radius [m]
152
152
  a : float = 3.0 # Minor plasma radius [m]
153
153
  b : float = 1.2 # Breeding blanket + neutron shield radial thickness [m]
154
+ delta_BB_IB : float = 0.50 # Requested inboard breeder zone [m]
155
+ delta_BB_OB : float = 0.50 # Requested outboard breeder zone [m]
156
+ delta_shield_IB : float = 0.30 # Requested inboard shielding, HT + LT halves [m]
157
+ delta_shield_OB : float = 0.30 # Requested outboard shielding, HT + LT halves [m]
154
158
  Bmax_TF : float = 12.0 # Peak magnetic field on TF conductor [T]
155
159
  Bmax_CS_adm : float = 25.0 # Peak magnetic field allowed on the CS [T]
156
160
  P_fus : float = 2000.0 # Total fusion power [MW]
@@ -433,6 +437,16 @@ class GlobalConfig:
433
437
  Marge_T_NbTi : float = 1.7 # NbTi temperature margin [K]
434
438
  Marge_T_REBCO : float = 5.0 # REBCO temperature margin [K]
435
439
 
440
+ # REBCO lift-factor fit, M. Fletcher (2026, own study, unpublished):
441
+ # LF = numerator / (a0 + a1*T + (b0 + b1*T + b2*T**2)*B), T in K, B in T.
442
+ # Shared between TF and CS (dimensionless result), reported only.
443
+ LF_numerator : float = 0.062
444
+ LF_a0 : float = 1.22e-2
445
+ LF_a1 : float = 5.49e-4
446
+ LF_b0 : float = 1.27e-3
447
+ LF_b1 : float = -2.70e-5
448
+ LF_b2 : float = 5.93e-6
449
+
436
450
  # Strand / tape operating parameters
437
451
  Eps : float = -6e-3 # Effective axial strain for Nb₃Sn [-]
438
452
  # Ref: Corato et al. (2016)
@@ -621,6 +635,10 @@ class GlobalConfig:
621
635
  ValueError
622
636
  Option value not in CONFIG_OPTIONS, e.g. "Tbar_mode = greenwlad".
623
637
  """
638
+ for key in ('delta_BB_IB', 'delta_BB_OB', 'delta_shield_IB', 'delta_shield_OB'):
639
+ value = getattr(self, key)
640
+ if not isinstance(value, (int, float, np.integer, np.floating)) or isinstance(value, bool) or not np.isfinite(value) or value < 0:
641
+ raise ValueError(f"{key} must be a finite nonnegative thickness [m].")
624
642
  for f in fields(self):
625
643
  value = getattr(self, f.name)
626
644
  default = f.default
@@ -896,7 +914,7 @@ def preset_refined(**overrides) -> 'GlobalConfig':
896
914
  Build a GlobalConfig configured for the physically detailed 'refined'
897
915
  mode.
898
916
 
899
- All sub-mode selectors are set to their best-validated physics-based
917
+ All sub-mode selectors are set to their best-verified physics-based
900
918
  counterparts; engineering, geometric and economic fields keep their
901
919
  GlobalConfig defaults. Pass keyword arguments to surcharge any field
902
920
  after the preset has been applied.
@@ -1429,53 +1447,92 @@ def plant_conversion(config) -> tuple:
1429
1447
  return M, eta, f_pump
1430
1448
 
1431
1449
 
1432
- def radial_layers_effective(Blanket_choice: str, b: float, Delta_TF: float = 0.0) -> list:
1433
- """
1434
- Concept-specific radial-build layer stack with the breeder layer's width
1435
- resolved to a value.
1436
-
1437
- Returns BLANKET_CONCEPTS[Blanket_choice]['radial_layers'] (ordered plasma ->
1438
- TF) as a list of dicts, each augmented with 'delta_ib' and 'delta_ob' [m]
1439
- (IB/OB thickness). Every fixed-width layer has delta_ib == delta_ob ==
1440
- 'width'. The single 'breeder' layer's thickness is the residual of b (IB)
1441
- / b + Delta_TF (OB) once every other layer's width has been subtracted:
1442
-
1443
- delta_breeder_ib = b - sum(fixed widths)
1444
- delta_breeder_ob = b + Delta_TF - sum(fixed widths)
1450
+ def radial_build_feasibility(Blanket_choice, b, Delta_TF=0.0):
1451
+ """Midplane budgets against the mandatory components of the concept.
1445
1452
 
1446
- When b is smaller than the fixed stack, the fixed layers are scaled by
1447
- b / sum(fixed widths) so that the stack still fits: the breeder then
1448
- vanishes inboard and keeps Delta_TF outboard. Each layer carries this
1449
- scale as 'stack_scale' (1 when the stack fits).
1450
-
1451
- Parameters
1452
- ----------
1453
- Blanket_choice : str Concept key (see BLANKET_CONCEPTS).
1454
- b : float Breeding blanket + shield radial thickness [m].
1455
- Delta_TF : float Outboard port-access radial clearance [m].
1456
-
1457
- Returns
1458
- -------
1459
- list of dict, one per layer, each with: name, role, width (None for
1460
- breeder), rho (None if not concept-specific — falls back to GlobalConfig at
1461
- run time), delta_ib, delta_ob.
1453
+ A side whose budget is below the mandatory sum is built compressed
1454
+ (radial_layers_effective). The build is infeasible only without any
1455
+ radial space.
1462
1456
  """
1463
- concept = material_blanket(Blanket_choice)
1464
- fixed_sum = sum(layer['width'] for layer in concept['radial_layers']
1465
- if layer['width'] is not None)
1466
- scale = min(1.0, b / fixed_sum) if fixed_sum > 0 else 1.0
1467
- delta_ib = max(b - scale * fixed_sum, 0.0)
1468
- delta_ob = max(b + Delta_TF - scale * fixed_sum, 0.0)
1469
-
1470
- layers = []
1471
- for layer in concept['radial_layers']:
1472
- entry = dict(layer)
1473
- if entry['width'] is None:
1474
- entry['delta_ib'] = delta_ib
1475
- entry['delta_ob'] = delta_ob
1476
- else:
1477
- entry['delta_ib'] = scale * entry['width']
1478
- entry['delta_ob'] = scale * entry['width']
1479
- entry['stack_scale'] = scale
1480
- layers.append(entry)
1481
- return layers
1457
+ import math
1458
+ if not all(math.isfinite(v) for v in (b, Delta_TF)):
1459
+ raise ValueError('Radial dimensions must be finite.')
1460
+ layers = material_blanket(Blanket_choice)['radial_layers']
1461
+ mandatory = sum(L['width'] for L in layers[:-1]
1462
+ if L['role'] not in {'breeder','structure','multiplier','shield_HT','shield_LT'})
1463
+ available_ib, available_ob = b, b + Delta_TF
1464
+ return {'feasible': available_ib > 0 and available_ob > 0,
1465
+ 'available_ib': available_ib, 'available_ob': available_ob,
1466
+ 'mandatory_ib': mandatory, 'mandatory_ob': mandatory}
1467
+
1468
+
1469
+ def radial_layers_effective(Blanket_choice: str, b: float, Delta_TF: float = 0.0,
1470
+ delta_BB_IB: float = 0.50, delta_BB_OB: float = 0.50,
1471
+ delta_shield_IB: float = 0.30,
1472
+ delta_shield_OB: float = 0.30) -> list:
1473
+ """Allocate IB/OB layers with mandatory > shields > breeding priority.
1474
+
1475
+ When a budget is below the mandatory layers, these are scaled to fit,
1476
+ without shield, breeder or structure, as in D0FUS 3.2 ('stack_scale'
1477
+ below 1). Structural and multiplier layers are contingent on a positive
1478
+ breeder.
1479
+ The final gap takes the remaining space. Mandatory widths never shrink.
1480
+ Each side is clipped independently, with its own breeder and shield
1481
+ targets. HT and LT each receive half the achieved shielding thickness.
1482
+ """
1483
+ import math
1484
+ values = (b, Delta_TF, delta_BB_IB, delta_BB_OB, delta_shield_IB, delta_shield_OB)
1485
+ if any(not math.isfinite(v) for v in values) or any(v < 0 for v in values):
1486
+ raise ValueError('Radial dimensions must be finite and nonnegative.')
1487
+ original = material_blanket(Blanket_choice)['radial_layers']
1488
+ layers = [dict(layer) for layer in original]
1489
+ if not layers or layers[-1]['role'] != 'gap':
1490
+ raise ValueError('The last radial-build layer must be the residual TF gap.')
1491
+ dependent = {'breeder', 'structure', 'multiplier'}
1492
+ scales = []
1493
+ for side, budget, target, shield_target in (
1494
+ ('ib', b, delta_BB_IB, delta_shield_IB),
1495
+ ('ob', b + Delta_TF, delta_BB_OB, delta_shield_OB)):
1496
+ key = 'delta_' + side
1497
+ mandatory = sum(L['width'] for L in layers[:-1]
1498
+ if L['role'] not in dependent | {'shield_HT', 'shield_LT'})
1499
+ if budget + 1e-10 < mandatory:
1500
+ # Compressed stack: mandatory layers scaled to the budget
1501
+ if budget <= 0:
1502
+ return []
1503
+ scale = budget / mandatory
1504
+ for L in layers[:-1]:
1505
+ kept = L['role'] not in dependent | {'shield_HT', 'shield_LT'}
1506
+ L[key] = L['width'] * scale if kept else 0.0
1507
+ layers[-1][key] = 0.0
1508
+ scales.append(scale)
1509
+ continue
1510
+ free = max(0.0, budget - mandatory)
1511
+ shield = min(shield_target, free)
1512
+ remaining = max(0.0, free - shield)
1513
+ dependent_fixed = sum(L['width'] for L in layers
1514
+ if L['role'] in {'structure', 'multiplier'})
1515
+ # No partial structural assemblies: fit the mandatory associated
1516
+ # components and a strictly positive breeder, or remove them all.
1517
+ breeder = min(target, max(0.0, remaining - dependent_fixed)) if target > 0 else 0.0
1518
+ present = breeder > 1e-10
1519
+ if not present:
1520
+ breeder = 0.0
1521
+ for L in layers[:-1]:
1522
+ role = L['role']
1523
+ if role == 'breeder':
1524
+ value = breeder
1525
+ elif role in ('structure', 'multiplier'):
1526
+ value = L['width'] if present else 0.0
1527
+ elif role in ('shield_HT', 'shield_LT'):
1528
+ value = shield / 2.0
1529
+ else:
1530
+ value = L['width']
1531
+ L[key] = value
1532
+ used = sum(L[key] for L in layers[:-1])
1533
+ layers[-1][key] = max(0.0, budget - used)
1534
+ if abs(sum(L[key] for L in layers) - budget) > 1e-8:
1535
+ raise ArithmeticError('Radial layer allocation does not close.')
1536
+ for L in layers:
1537
+ L['stack_scale'] = min(scales, default=1.0)
1538
+ return layers