d0fus 3.3.0__tar.gz → 3.3.2__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 (32) hide show
  1. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_figures.py +326 -42
  2. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_radial_build_functions.py +99 -36
  3. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_EXE/D0FUS_run.py +29 -16
  4. {d0fus-3.3.0 → d0fus-3.3.2}/PKG-INFO +7 -7
  5. {d0fus-3.3.0 → d0fus-3.3.2}/README.md +6 -6
  6. {d0fus-3.3.0 → d0fus-3.3.2}/d0fus.egg-info/PKG-INFO +7 -7
  7. {d0fus-3.3.0 → d0fus-3.3.2}/d0fus.egg-info/SOURCES.txt +1 -0
  8. {d0fus-3.3.0 → d0fus-3.3.2}/pyproject.toml +1 -1
  9. d0fus-3.3.2/tests/test_figures.py +33 -0
  10. {d0fus-3.3.0 → d0fus-3.3.2}/tests/test_radial_build_functions.py +10 -7
  11. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS.py +0 -0
  12. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_cost_data.py +0 -0
  13. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_cost_functions.py +0 -0
  14. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_import.py +0 -0
  15. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_machine_presets.py +0 -0
  16. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_parameterization.py +0 -0
  17. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_physical_functions.py +0 -0
  18. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_BIB/D0FUS_power_flow.py +0 -0
  19. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_EXE/D0FUS_genetic.py +0 -0
  20. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_EXE/D0FUS_popcon.py +0 -0
  21. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_EXE/D0FUS_scan.py +0 -0
  22. {d0fus-3.3.0 → d0fus-3.3.2}/D0FUS_EXE/D0FUS_uncertainty.py +0 -0
  23. {d0fus-3.3.0 → d0fus-3.3.2}/LICENSE +0 -0
  24. {d0fus-3.3.0 → d0fus-3.3.2}/d0fus.egg-info/dependency_links.txt +0 -0
  25. {d0fus-3.3.0 → d0fus-3.3.2}/d0fus.egg-info/entry_points.txt +0 -0
  26. {d0fus-3.3.0 → d0fus-3.3.2}/d0fus.egg-info/requires.txt +0 -0
  27. {d0fus-3.3.0 → d0fus-3.3.2}/d0fus.egg-info/top_level.txt +0 -0
  28. {d0fus-3.3.0 → d0fus-3.3.2}/setup.cfg +0 -0
  29. {d0fus-3.3.0 → d0fus-3.3.2}/tests/test_blanket_layers.py +0 -0
  30. {d0fus-3.3.0 → d0fus-3.3.2}/tests/test_modes.py +0 -0
  31. {d0fus-3.3.0 → d0fus-3.3.2}/tests/test_physical_functions.py +0 -0
  32. {d0fus-3.3.0 → d0fus-3.3.2}/tests/test_plant_balance.py +0 -0
@@ -66,7 +66,8 @@ if __name__ != "__main__":
66
66
  _offset_contour,
67
67
  f_TBR,
68
68
  )
69
- from .D0FUS_parameterization import DEFAULT_CONFIG, E_ELEM, BLANKET_CONCEPTS, radial_layers_effective
69
+ from .D0FUS_parameterization import (DEFAULT_CONFIG, E_ELEM, BLANKET_CONCEPTS,
70
+ radial_layers_effective, radial_build_feasibility)
70
71
 
71
72
  # Standalone-execution imports (development / testing)
72
73
  else:
@@ -101,7 +102,8 @@ else:
101
102
  _offset_contour,
102
103
  f_TBR,
103
104
  )
104
- from D0FUS_BIB.D0FUS_parameterization import DEFAULT_CONFIG, E_ELEM, BLANKET_CONCEPTS, radial_layers_effective
105
+ from D0FUS_BIB.D0FUS_parameterization import (DEFAULT_CONFIG, E_ELEM, BLANKET_CONCEPTS,
106
+ radial_layers_effective, radial_build_feasibility)
105
107
 
106
108
 
107
109
  # =============================================================================
@@ -2982,6 +2984,38 @@ def _smooth_closed(R, Z, frac=0.045):
2982
2984
  return _sm(R), _sm(Z)
2983
2985
 
2984
2986
 
2987
+ # Palette of the radial-build figures (plot_assembly_side_view, plot_radial_build)
2988
+ _RB_ALPHA = 0.72
2989
+ _RB_COL = {
2990
+ "plasma": "#7E3FA8", # violet
2991
+ "FW": "#9AA0A6", # grey
2992
+ "breeder": "#E8853A", # orange
2993
+ "TF": "#D1495B", # red
2994
+ "CS": "#3E6DB5", # blue
2995
+ }
2996
+ # Structure, shield and vacuum-vessel layers: green shades, darkest at the plasma side
2997
+ _RB_GREEN_ROLES = ("structure", "multiplier", "shield_HT", "shield_LT", "VV")
2998
+ _RB_GREEN_SHADES = ("#1B5E20", "#2E7D32", "#43A047", "#66BB6A", "#86C98E", "#A5D6A7")
2999
+
3000
+
3001
+ def _rb_green_colors(layers):
3002
+ """Green shade of each structure / shield / VV layer, by index in ``layers``."""
3003
+ order = [i for i, L in enumerate(layers) if L["role"] in _RB_GREEN_ROLES]
3004
+ return {gi: _RB_GREEN_SHADES[min(k, len(_RB_GREEN_SHADES) - 1)]
3005
+ for k, gi in enumerate(order)}
3006
+
3007
+
3008
+ def _rb_label(L, short=False):
3009
+ """Display name of a radial-build layer (legend names of plot_assembly_side_view)."""
3010
+ role = L["role"]
3011
+ name = L["name"].split("(")[0].strip()
3012
+ full = {"SOL": "Scrape-off layer", "FW": "First wall",
3013
+ "breeder": "Breeding blanket", "gap": "Gap"}
3014
+ abbr = {"SOL": "SOL", "FW": "FW", "breeder": "BB", "gap": "Gap",
3015
+ "shield_HT": "HT shield", "shield_LT": "LT shield", "VV": "VV"}
3016
+ return (abbr if short else full).get(role, name)
3017
+
3018
+
2985
3019
  def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
2986
3020
  """Poloidal (R-Z) cross-section of the full radial build.
2987
3021
 
@@ -3082,20 +3116,19 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3082
3116
  # smoothing them would alter layer widths and can create overlaps.
3083
3117
 
3084
3118
  # -- Colour scheme ------------------------------------------------------
3085
- ALPHA = 0.72
3086
- col_plasma = "#7E3FA8" # violet
3119
+ ALPHA = _RB_ALPHA
3120
+ col_plasma = _RB_COL["plasma"]
3087
3121
  col_sol = "white" # SOL drawn as open space (see docstring)
3088
- col_fw = "#9AA0A6" # grey
3089
- col_bb = "#E8853A" # orange
3090
- col_tf = "#D1495B" # red
3091
- col_cs = "#3E6DB5" # blue
3122
+ col_fw = _RB_COL["FW"]
3123
+ col_bb = _RB_COL["breeder"]
3124
+ col_tf = _RB_COL["TF"]
3125
+ col_cs = _RB_COL["CS"]
3092
3126
  col_gap = "white"
3093
3127
  # green shades (inner -> outer) for the structure/shield/VV block
3094
- GREEN_ROLES = ("structure", "multiplier", "shield_HT", "shield_LT", "VV")
3095
- green_shades = ["#1B5E20", "#2E7D32", "#43A047", "#66BB6A", "#86C98E", "#A5D6A7"]
3128
+ GREEN_ROLES = _RB_GREEN_ROLES
3129
+ green_shades = list(_RB_GREEN_SHADES)
3096
3130
  green_order = [i for i, L in enumerate(layers) if L["role"] in GREEN_ROLES]
3097
- green_color = {gi: green_shades[min(k, len(green_shades) - 1)]
3098
- for k, gi in enumerate(green_order)}
3131
+ green_color = _rb_green_colors(layers)
3099
3132
 
3100
3133
  def _role_color(i, L):
3101
3134
  r = L["role"]
@@ -3297,6 +3330,251 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3297
3330
  return fig
3298
3331
 
3299
3332
 
3333
+ # ---------------------------------------------------------------------------
3334
+ # B2b — Midplane radial build (bar from the machine axis to the TF outer face)
3335
+ # ---------------------------------------------------------------------------
3336
+
3337
+ def _midplane_build(run: dict) -> list:
3338
+ """
3339
+ Midplane radial build of a run, as contiguous segments from R = 0 to the
3340
+ outer face of the TF outboard leg.
3341
+
3342
+ Order: CS bore, CS, TF-CS gap (wedging only), TF inboard leg, inboard
3343
+ layers (TF -> LCFS), plasma (2a), outboard layers (LCFS -> TF), TF
3344
+ outboard leg. The layers and their midplane widths (delta_ib, delta_ob)
3345
+ come from radial_layers_effective, as in plot_assembly_side_view; layers
3346
+ of zero width are dropped. The outboard stack fills b + Delta_TF, its last
3347
+ gap taking the remaining space. The outboard leg has the inboard thickness
3348
+ c_TF, as in f_TF_cross_section. When the mandatory layers do not fit
3349
+ (radial_build_feasibility), each side is a single 'build' segment.
3350
+
3351
+ Parameters
3352
+ ----------
3353
+ run : dict D0FUS run output.
3354
+
3355
+ Returns
3356
+ -------
3357
+ list of dict, inboard to outboard, each with: name, short (abbreviated
3358
+ name), role, R_in, R_out [m], color, alpha.
3359
+ """
3360
+ R0, a = float(run["R0"]), float(run["a"])
3361
+ bd = _resolve_build(run)
3362
+ b, c_TF, Delta_TF = bd["b"], bd["c_TF"], bd["Delta_TF"]
3363
+ if radial_build_feasibility(bd["Blanket_choice"], b, Delta_TF)["feasible"]:
3364
+ layers = radial_layers_effective(
3365
+ bd["Blanket_choice"], b, Delta_TF,
3366
+ float(run.get("delta_BB_IB", 0.50)), float(run.get("delta_BB_OB", 0.50)),
3367
+ float(run.get("delta_shield_IB", 0.30)), float(run.get("delta_shield_OB", 0.30)))
3368
+ else:
3369
+ layers = []
3370
+ green = _rb_green_colors(layers)
3371
+
3372
+ def _seg(name, short, role, R_in, R_out, color, alpha=_RB_ALPHA):
3373
+ return dict(name=name, short=short, role=role, R_in=float(R_in),
3374
+ R_out=float(R_out), color=color, alpha=alpha)
3375
+
3376
+ def _stack(R_start, side, budget, order):
3377
+ if not layers:
3378
+ return ([_seg("Blanket and shield", "Build", "build", R_start,
3379
+ R_start + budget, "#D9D9D9", 1.0)] if budget > 1e-9 else [])
3380
+ segs, R = [], R_start
3381
+ for i in order:
3382
+ L = layers[i]
3383
+ width = float(L["delta_" + side])
3384
+ if width <= 1e-9:
3385
+ continue
3386
+ if L["role"] in ("SOL", "gap"):
3387
+ color, alpha = "white", 1.0
3388
+ elif L["role"] in ("FW", "breeder"):
3389
+ color, alpha = _RB_COL[L["role"]], _RB_ALPHA
3390
+ else:
3391
+ color, alpha = green.get(i, _RB_GREEN_SHADES[-1]), _RB_ALPHA
3392
+ segs.append(_seg(_rb_label(L), _rb_label(L, short=True), L["role"], R,
3393
+ R + width, color, alpha))
3394
+ R += width
3395
+ return segs
3396
+
3397
+ gap_eff = bd["Gap"] if run.get("Choice_Buck_Wedg", "Wedging") == "Wedging" else 0.0
3398
+ R_TF_in = bd["R_TF_in"] # plasma-side face of the TF inboard leg
3399
+ R_ob = R0 + a + b + Delta_TF # plasma-side face of the TF outboard leg
3400
+ segs = [_seg("CS bore", "Bore", "bore", 0.0, bd["R_CS_int"], "#EFEFEF", 1.0),
3401
+ _seg("CS", "CS", "CS", bd["R_CS_int"], bd["R_CS_ext"], _RB_COL["CS"])]
3402
+ if gap_eff > 0:
3403
+ segs.append(_seg("TF-CS gap", "Gap", "gap", bd["R_CS_ext"],
3404
+ bd["R_CS_ext"] + gap_eff, "white", 1.0))
3405
+ segs.append(_seg("TF inboard leg", "TF", "TF", R_TF_in - c_TF, R_TF_in, _RB_COL["TF"]))
3406
+ segs += _stack(R_TF_in, "ib", b, range(len(layers) - 1, -1, -1))
3407
+ segs.append(_seg("Plasma", "Plasma", "plasma", R0 - a, R0 + a, _RB_COL["plasma"]))
3408
+ segs += _stack(R0 + a, "ob", b + Delta_TF, range(len(layers)))
3409
+ segs.append(_seg("TF outboard leg", "TF", "TF", R_ob, bd["R_TF_out"], _RB_COL["TF"]))
3410
+ return segs
3411
+
3412
+
3413
+ def plot_radial_build(run: dict, save_dir: str | None = None) -> None:
3414
+ """
3415
+ Midplane radial build: bar from the machine axis to the TF outer face.
3416
+
3417
+ Top: the whole build at scale (CS bore, CS, TF legs, inboard and outboard
3418
+ layers, plasma), with the inboard build b, the outboard build b + Delta_TF
3419
+ and the major radius R0. Bottom: zooms on the inboard (TF -> LCFS) and
3420
+ outboard (LCFS -> TF) layers, each layer labelled with its width (above the
3421
+ bar, with a leader line, when the layer is too thin).
3422
+ Same layers and colours as plot_assembly_side_view (see _midplane_build).
3423
+ White segments are empty: scrape-off layer and gaps.
3424
+
3425
+ Parameters
3426
+ ----------
3427
+ run : dict D0FUS run output.
3428
+ save_dir : str or None Saves run_radial_build.png there; otherwise shown.
3429
+ """
3430
+ segs = _midplane_build(run)
3431
+ R0, a = float(run["R0"]), float(run["a"])
3432
+ bd = _resolve_build(run)
3433
+ b, Delta_TF = bd["b"], bd["Delta_TF"]
3434
+ R_TF_in, R_end = bd["R_TF_in"], segs[-1]["R_out"]
3435
+ R_ob = R0 + a + b + Delta_TF
3436
+ i_pl = next(i for i, s in enumerate(segs) if s["role"] == "plasma")
3437
+ ib = [s for s in segs[:i_pl] if s["R_in"] >= R_TF_in - 1e-9]
3438
+ ob = [s for s in segs[i_pl + 1:] if s["R_out"] <= R_ob + 1e-9]
3439
+
3440
+ # Fixed layout in inches, so that the label fit tests of _bar are exact
3441
+ fig_w, fig_h = 9.0, 4.95
3442
+ x0, w_main, w_zoom, gap = 0.4, 8.35, 3.95, 0.45
3443
+ h_main, h_zoom = 1.45, 1.7
3444
+ fig = plt.figure(figsize=(fig_w, fig_h))
3445
+ ax = fig.add_axes([x0 / fig_w, 3.05 / fig_h, w_main / fig_w, h_main / fig_h])
3446
+ ax_ib = fig.add_axes([x0 / fig_w, 0.5 / fig_h, w_zoom / fig_w, h_zoom / fig_h])
3447
+ ax_ob = fig.add_axes([(x0 + w_zoom + gap) / fig_w, 0.5 / fig_h, w_zoom / fig_w,
3448
+ h_zoom / fig_h])
3449
+
3450
+ def _text_w(text, size):
3451
+ """Approximate length of the longest line of a label [in] (0.6 em per glyph)."""
3452
+ return 0.6 * size / 72.0 * max(len(t) for t in text.split("\n"))
3453
+
3454
+ def _spread(want, widths, lo, hi):
3455
+ """Centres of labels of given widths, wanted at increasing positions, without
3456
+ overlap and inside [lo, hi]. Overlapping labels merge into a cluster centred
3457
+ on the mean of their wanted positions."""
3458
+ def _place(cl):
3459
+ total = sum(widths[i] for i in cl)
3460
+ x = max(lo, min(float(np.mean([want[i] for i in cl])) - 0.5 * total,
3461
+ hi - total))
3462
+ centres = []
3463
+ for i in cl:
3464
+ centres.append(x + 0.5 * widths[i])
3465
+ x += widths[i]
3466
+ return centres
3467
+ clusters, k = [[i] for i in range(len(want))], 0
3468
+ while k < len(clusters) - 1:
3469
+ left, right = clusters[k], clusters[k + 1]
3470
+ if (_place(left)[-1] + 0.5 * widths[left[-1]]
3471
+ > _place(right)[0] - 0.5 * widths[right[0]] + 1e-12):
3472
+ clusters[k] = left + clusters.pop(k + 1)
3473
+ k = max(k - 1, 0) # the merged cluster may now reach its left neighbour
3474
+ else:
3475
+ k += 1
3476
+ return [c for cl in clusters for c in _place(cl)]
3477
+
3478
+ def _bar(axis, items, y_top, axis_w, axis_h, x_lo, x_hi, size, digits, above):
3479
+ """Bar of segments on y in [0, 1], ylim (-0.02, y_top). Labels inside: two
3480
+ lines, horizontal then vertical, full name then abbreviation, then one vertical
3481
+ line. Else above the bar (zooms only), spread apart, with leader lines."""
3482
+ axis.set_xlim(x_lo, x_hi)
3483
+ axis.set_ylim(-0.02, y_top)
3484
+ per_m = axis_w / (x_hi - x_lo) # inches per metre
3485
+ bar_h = axis_h / (y_top + 0.02) # bar height [in]
3486
+ line = 1.3 * size / 72.0 # width of one vertical line [in]
3487
+ tops = [] # labels placed above the bar
3488
+ for s in items:
3489
+ w = s["R_out"] - s["R_in"]
3490
+ axis.add_patch(plt.Rectangle((s["R_in"], 0.0), w, 1.0, fc=s["color"],
3491
+ alpha=s["alpha"], ec="none", zorder=2))
3492
+ axis.plot([s["R_in"], s["R_in"]], [0.0, 1.0], color="grey", lw=0.4, zorder=3)
3493
+ width = (f"2a = {w:.{digits}f} m" if s["role"] == "plasma"
3494
+ else f"{w:.{digits}f} m")
3495
+ seg_in, xc = w * per_m, 0.5 * (s["R_in"] + s["R_out"])
3496
+ tries = [(f"{name}\n{width}", rot) for name in (s["name"], s["short"])
3497
+ for rot in (0, 90)]
3498
+ tries += [(f"{name} {width}", 90) for name in (s["name"], s["short"])]
3499
+ for text, rot in tries:
3500
+ n_lines = text.count("\n") + 1
3501
+ fits = (_text_w(text, size) <= 0.9 * seg_in if rot == 0 else
3502
+ _text_w(text, size) <= 0.9 * bar_h and n_lines * line <= seg_in)
3503
+ if fits:
3504
+ axis.text(xc, 0.5, text, ha="center", va="center", fontsize=size,
3505
+ rotation=rot, linespacing=1.25, zorder=5)
3506
+ break
3507
+ else:
3508
+ if above:
3509
+ # One line if it fits in the space above the bar, else two
3510
+ text = f"{s['short']} {width}"
3511
+ if _text_w(text, size - 1) > (y_top - 1.16) * bar_h:
3512
+ text = f"{s['short']}\n{width}"
3513
+ tops.append((xc, text))
3514
+ if tops:
3515
+ # Width of each vertical label [m]: its lines at size - 1, plus a small gap
3516
+ widths = [((t.count("\n") + 1) * 1.35 * (size - 1) / 72.0 + 0.015) / per_m
3517
+ for _, t in tops]
3518
+ for (xc, text), x in zip(tops, _spread([xc for xc, _ in tops], widths,
3519
+ x_lo, x_hi)):
3520
+ axis.plot([xc, xc, x, x], [1.0, 1.03, 1.12, 1.15], color="grey", lw=0.5,
3521
+ zorder=3)
3522
+ axis.text(x, 1.16, text, ha="center", va="bottom", fontsize=size - 1,
3523
+ rotation=90, linespacing=1.1, zorder=5)
3524
+ axis.plot([items[-1]["R_out"]] * 2, [0.0, 1.0], color="grey", lw=0.4, zorder=3)
3525
+ axis.add_patch(plt.Rectangle((items[0]["R_in"], 0.0),
3526
+ items[-1]["R_out"] - items[0]["R_in"], 1.0,
3527
+ fc="none", ec="black", lw=0.8, zorder=4))
3528
+ axis.set_yticks([])
3529
+ for side in ("left", "right", "top"):
3530
+ axis.spines[side].set_visible(False)
3531
+ axis.tick_params(labelsize=9, direction="out")
3532
+ axis.set_xlabel("$R$ [m]", fontsize=10)
3533
+
3534
+ # -- Whole build ----------------------------------------------------------
3535
+ pad = 0.01 * R_end
3536
+ _bar(ax, segs, 1.62, w_main, h_main, -pad, R_end + pad, 9, 2, above=False)
3537
+
3538
+ def _span(R1, R2, label):
3539
+ ax.annotate("", xy=(R2, 1.2), xytext=(R1, 1.2), zorder=6,
3540
+ arrowprops=dict(arrowstyle="<->", color="#333333", lw=0.9,
3541
+ mutation_scale=9, shrinkA=0, shrinkB=0))
3542
+ ax.text(0.5 * (R1 + R2), 1.26, label, ha="center", va="bottom", fontsize=9,
3543
+ color="#333333", zorder=6)
3544
+
3545
+ _span(R_TF_in, R0 - a, f"$b$ = {b:.2f} m")
3546
+ _span(R0 + a, R_ob, f"$b + \\Delta_{{TF}}$ = {b + Delta_TF:.2f} m")
3547
+ for y1, y2 in ((0.0, 0.27), (0.73, 1.0)): # R0 line, broken at the label
3548
+ ax.plot([R0, R0], [y1, y2], color="black", lw=0.8, ls="--", zorder=6)
3549
+ ax.text(R0, 1.06, f"$R_0$ = {R0:.2f} m", ha="center", va="bottom", fontsize=9,
3550
+ zorder=6)
3551
+
3552
+ # -- Zooms on the inboard and outboard layers ----------------------------
3553
+ zooms = ((ax_ib, ib, "Inboard, TF to LCFS", f"$b$ = {b:.3f} m"),
3554
+ (ax_ob, ob, "Outboard, LCFS to TF",
3555
+ f"$b + \\Delta_{{TF}}$ = {b + Delta_TF:.3f} m"))
3556
+ for axis, items, title, total in zooms:
3557
+ if not items: # no radial space on that side
3558
+ axis.set_axis_off()
3559
+ continue
3560
+ lo, hi = items[0]["R_in"], items[-1]["R_out"]
3561
+ pz = 0.02 * (hi - lo)
3562
+ _bar(axis, items, 2.25, w_zoom, h_zoom, lo - pz, hi + pz, 8, 3, above=True)
3563
+ for x, text, ha in ((0.0, title, "left"), (1.0, total, "right")):
3564
+ axis.text(x, 1.03, text, transform=axis.transAxes, ha=ha, va="bottom",
3565
+ fontsize=9.5, fontweight="bold")
3566
+ axis.xaxis.set_major_locator(plt.MaxNLocator(6))
3567
+
3568
+ Bmax = run.get("B_max")
3569
+ head = f"Midplane radial build: $R_0$ = {R0:.2f} m, $a$ = {a:.2f} m"
3570
+ if Bmax is not None and np.isfinite(Bmax):
3571
+ head += f", $B_{{max,TF}}$ = {float(Bmax):.1f} T"
3572
+ head += f", {run.get('Choice_Buck_Wedg', 'Wedging')}"
3573
+ fig.text(x0 / fig_w, (fig_h - 0.12) / fig_h, head, ha="left", va="top", fontsize=11,
3574
+ fontweight="bold")
3575
+ _save_or_show(fig, save_dir, "run_radial_build")
3576
+
3577
+
3300
3578
  def plot_blanket_concepts_comparison(save_dir: str | None = None) -> None:
3301
3579
  """
3302
3580
  Compare the breeding-blanket concepts defined in BLANKET_CONCEPTS.
@@ -4229,6 +4507,9 @@ def plot_all(
4229
4507
  _p(26, "Radial build assembly (CS / TF / blanket)")
4230
4508
  plot_assembly_side_view(run, save_dir=save_dir)
4231
4509
 
4510
+ _p("26b", "Midplane radial build")
4511
+ plot_radial_build(run, save_dir=save_dir)
4512
+
4232
4513
  _p(27, "TF coil side view")
4233
4514
  plot_TF_side_view(run, save_dir=save_dir)
4234
4515
 
@@ -4264,31 +4545,32 @@ def plot_run(
4264
4545
  view_3d: bool = True,
4265
4546
  ) -> None:
4266
4547
  """
4267
- Render the run-specific figure set (18 figures, 17 without the 3D view).
4548
+ Render the run-specific figure set (19 figures, 18 without the 3D view).
4268
4549
 
4269
4550
  This is the subset called after each D0FUS run. It contains only the
4270
4551
  figures that depend on the current run configuration and results —
4271
4552
  no verification curves, no benchmarks, no scaling-law surveys.
4272
4553
 
4273
4554
  Figures produced:
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,
4555
+ [ 1/19] Tokamak LCFS comparison (with D0FUS overlay)
4556
+ [ 2/19] Miller flux surfaces (run geometry)
4557
+ [ 3/19] Shaping profiles κ(ρ), δ(ρ)
4558
+ [ 4/19] Kinetic profiles n(ρ), T(ρ), p(ρ)
4559
+ [ 5/19] Safety factor q(ρ) and current decomposition
4560
+ [ 6/19] Radiation profiles
4561
+ [ 7/19] Divertor two-point model (detachment vs SOL dissipation)
4562
+ [ 8/19] Radial build assembly (CS / TF / blanket)
4563
+ [ 9/19] Midplane radial build
4564
+ [10/19] TF coil side view
4565
+ [11/19] CICC TF conductor
4566
+ [12/19] CS cross-section
4567
+ [13/19] CICC CS conductor
4568
+ [14/19] Cost breakdown (Sheffield 2016 or Whyte 2024, CapEx / OpEx / COE)
4569
+ [15/19] Plasma temperature map T(rho)
4570
+ [16/19] Plasma density map n(rho)
4571
+ [17/19] Plant power balance — pulse
4572
+ [18/19] Plant power balance — dwell
4573
+ [19/19] 3D machine view (PyVista; skipped if PyVista is missing,
4292
4574
  or with view_3d=False)
4293
4575
 
4294
4576
  The breeding-blanket concept comparison does not depend on the run: it
@@ -4303,7 +4585,7 @@ def plot_run(
4303
4585
  view_3d : bool
4304
4586
  False skips the 3D machine view (command-line option --no-3d).
4305
4587
  """
4306
- N = 18 if view_3d else 17
4588
+ N = 19 if view_3d else 18
4307
4589
 
4308
4590
  # When saving, prefix each PNG with its order index so that the files sort
4309
4591
  # in the logical reading order: geometry (Miller), profiles, physics detail,
@@ -4355,27 +4637,29 @@ def plot_run(
4355
4637
  # ── Radial build & coils ──────────────────────────────────────────
4356
4638
  _emit(8, "Radial build assembly (CS / TF / blanket)",
4357
4639
  lambda: plot_assembly_side_view(run, save_dir=save_dir))
4358
- _emit(9, "TF coil side view",
4640
+ _emit(9, "Midplane radial build",
4641
+ lambda: plot_radial_build(run, save_dir=save_dir))
4642
+ _emit(10, "TF coil side view",
4359
4643
  lambda: plot_TF_side_view(run, save_dir=save_dir))
4360
- _emit(10, "CICC TF conductor",
4644
+ _emit(11, "CICC TF conductor",
4361
4645
  lambda: plot_CICC_cross_section(build_conductor_from_run(run, coil="TF"), save_dir=save_dir))
4362
- _emit(11, "CS cross-section",
4646
+ _emit(12, "CS cross-section",
4363
4647
  lambda: plot_CS_cross_section(run, save_dir=save_dir))
4364
- _emit(12, "CICC CS conductor",
4648
+ _emit(13, "CICC CS conductor",
4365
4649
  lambda: plot_CICC_cross_section(build_conductor_from_run(run, coil="CS"), save_dir=save_dir))
4366
4650
 
4367
4651
  # ── Techno-economic synthesis ─────────────────────────────────────
4368
- _emit(13, f"Cost breakdown ({(run.get('cost_breakdown') or {}).get('model', 'cost model off')})",
4652
+ _emit(14, f"Cost breakdown ({(run.get('cost_breakdown') or {}).get('model', 'cost model off')})",
4369
4653
  lambda: plot_cost_breakdown(run, save_dir=save_dir))
4370
4654
 
4371
4655
  # ── Plasma field maps ────────────────────────────────────
4372
- _emit(14, "Plasma temperature map", lambda: plot_temperature_map(run, save_dir=save_dir))
4373
- _emit(15, "Plasma density map", lambda: plot_density_map(run, save_dir=save_dir))
4656
+ _emit(15, "Plasma temperature map", lambda: plot_temperature_map(run, save_dir=save_dir))
4657
+ _emit(16, "Plasma density map", lambda: plot_density_map(run, save_dir=save_dir))
4374
4658
 
4375
4659
  # ── Phase-specific energy and power balance ───────────────────────
4376
- _emit(16, "Plant power balance (pulse)",
4660
+ _emit(17, "Plant power balance (pulse)",
4377
4661
  lambda: plot_plant_power_balance(run, phase="pulse", save_dir=save_dir))
4378
- _emit(17, "Plant power balance (dwell)",
4662
+ _emit(18, "Plant power balance (dwell)",
4379
4663
  lambda: plot_plant_power_balance(run, phase="dwell", save_dir=save_dir))
4380
4664
 
4381
4665
  # ── 3D machine view (optional PyVista dependency) ─────────────────
@@ -4388,7 +4672,7 @@ def plot_run(
4388
4672
  print(f" [warn] 3D machine view failed ({type(_e).__name__}: "
4389
4673
  f"{_e}) — skipped.")
4390
4674
  if view_3d:
4391
- _emit(18, "3D machine view (PyVista)", _fig_3d)
4675
+ _emit(19, "3D machine view (PyVista)", _fig_3d)
4392
4676
 
4393
4677
  print("Done.")
4394
4678
 
@@ -1653,28 +1653,49 @@ def _bore_log_integral(R, Z):
1653
1653
  return abs(np.sum(0.5 * (np.log(R) + np.log(R_next)) * (Z_next - Z)))
1654
1654
 
1655
1655
 
1656
- def calculate_E_mag_TF(B_max, a, b, R0, c, Delta_TF):
1656
+ # Gauss-Legendre rule (nodes and weights on [-1, 1]) of the winding-pack
1657
+ # depth integral of calculate_E_mag_TF.
1658
+ _EMAG_GL_T, _EMAG_GL_W = np.polynomial.legendre.leggauss(4)
1659
+
1660
+
1661
+ def calculate_E_mag_TF(B_max, a, b, R0, c, Delta_TF, c_WP, c_BP):
1657
1662
  """
1658
- Magnetic energy stored in the toroidal field.
1663
+ Magnetic energy stored in the toroidal field, bore and winding pack.
1664
+
1665
+ Axisymmetric limit: B = mu0 NI / (2 pi R), NI being the ampere-turns
1666
+ linked at the point. B_max sits on the plasma face of the winding pack,
1667
+ at R_e = R0 - a - b - c_BP, behind the backplate cover if any.
1668
+
1669
+ - Bore, enclosed by the plasma face of the winding pack (the cover
1670
+ included, it carries no current): B = B_max R_e / R.
1671
+ - Winding pack, at depth s from its plasma face: NI falls as in the
1672
+ thick cylinder of Winding_Pack_refined (uniform smeared current
1673
+ density, docs app:B_thick),
1674
+ f(s) = ((R_e - s)^2 - R_i^2) / (R_e^2 - R_i^2), R_i = R_e - c_WP.
1675
+ The winding cross-section is constant along the coil, so f(s) holds
1676
+ all around the Princeton-D.
1677
+ - Nose: no field.
1659
1678
 
1660
- Inside the TF coils the field is B(R) = B_max R_in / R, with B_max at
1661
- the plasma-facing face of the inboard leg, R_in = R0 - a - b. The
1662
- energy is integrated over the bore of the Princeton-D coil built by
1663
- f_TF_cross_section, the region enclosed by its inner contour:
1679
+ With G(s) = iint dR dZ / R over the region enclosed by the contour at
1680
+ depth s, an integration by parts gives
1664
1681
 
1665
- E_mag = (pi (B_max R_in)^2 / mu0) * iint dR dZ / R
1682
+ E_mag = (pi (B_max R_e)^2 / mu0) * int_0^c_WP w(s) G(s) ds,
1683
+ w(s) = -d(f^2)/ds, int_0^c_WP w(s) ds = 1,
1666
1684
 
1667
- The field energy inside the winding itself, a few percent, is not
1668
- included. The bore depends on the coil thickness c through the
1669
- centreline of the Princeton-D.
1685
+ the bore integral averaged over the depth of the winding pack. G(s) is
1686
+ the Green integral of the coil contour offset by c_BP + s. The 4-point
1687
+ Gauss-Legendre rule in s is converged to 1e-8 up to c_WP / R_e = 0.7.
1670
1688
 
1671
1689
  Parameters
1672
1690
  ----------
1673
- B_max : float Peak toroidal field at R_in [T].
1691
+ B_max : float Peak toroidal field at R_e [T].
1674
1692
  a, b, R0 : float Plasma minor radius, inboard build, major radius [m].
1675
- c : float TF inboard radial thickness [m]. c = 0 gives the bore
1676
- of a thin coil, used before c is known.
1693
+ c : float TF inboard radial thickness [m].
1677
1694
  Delta_TF : float Outboard port-access clearance [m] (Number_TF_coils).
1695
+ c_WP : float Winding-pack (current-carrying) thickness [m]. c_WP = 0
1696
+ gives the bore alone, used before c_WP is known.
1697
+ c_BP : float Backplate cover between the plasma face of the coil
1698
+ and its winding pack [m], 0 without cover (f_TF_cover).
1678
1699
 
1679
1700
  Returns
1680
1701
  -------
@@ -1685,11 +1706,25 @@ def calculate_E_mag_TF(B_max, a, b, R0, c, Delta_TF):
1685
1706
  Wilson, Superconducting Magnets (1983), ch. 9 (stored energy);
1686
1707
  File, Mills & Sheffield, IEEE Trans. Nucl. Sci. 18 (1971) 277 (shape).
1687
1708
  """
1688
- R_in = R0 - a - b
1689
- *_, R_bore, Z_bore = f_TF_cross_section(a, b, R0, c, Delta_TF)
1690
- if not (np.all(np.isfinite(R_bore)) and np.all(R_bore > 0)):
1709
+ R_e = R0 - a - b - c_BP
1710
+ *_, R_face, Z_face = f_TF_cross_section(a, b, R0, c, Delta_TF)
1711
+ if not (np.all(np.isfinite(R_face)) and np.all(R_face > 0) and R_e > 0):
1691
1712
  return np.nan
1692
- return np.pi * (B_max * R_in)**2 / μ0 * _bore_log_integral(R_bore, Z_bore)
1713
+
1714
+ def _G(s):
1715
+ # Region enclosed by the contour at depth s behind the cover
1716
+ return _bore_log_integral(*_offset_contour(R_face, Z_face, -(c_BP + s)))
1717
+
1718
+ E_unit = np.pi * (B_max * R_e)**2 / μ0
1719
+ if c_WP <= 0.0:
1720
+ return E_unit * _G(0.0)
1721
+
1722
+ # Depth average of G with the weight w(s) of the thick-cylinder profile
1723
+ R_i = R_e - c_WP
1724
+ s = 0.5 * c_WP * (_EMAG_GL_T + 1.0)
1725
+ w = 4.0 * (R_e - s) * ((R_e - s)**2 - R_i**2) / (R_e**2 - R_i**2)**2
1726
+ G = np.array([_G(s_k) for s_k in s])
1727
+ return E_unit * 0.5 * c_WP * np.sum(_EMAG_GL_W * w * G)
1693
1728
 
1694
1729
 
1695
1730
 
@@ -2624,7 +2659,7 @@ def f_H_CS_module(H_CS, N_sub_CS):
2624
2659
  # internal composition of the conductor is required, so they hold for every
2625
2660
  # TF/CS model implemented in D0FUS (academic, refined, CIRCE).
2626
2661
 
2627
- def f_J_coil_TF(B_max_TF, R_TF_out, c_TF):
2662
+ def f_J_coil_TF(B_max_TF, R_TF_out, c_TF, c_BP):
2628
2663
  """
2629
2664
  Overall current density of the TF inboard leg (J_coil scale).
2630
2665
 
@@ -2635,18 +2670,20 @@ def f_J_coil_TF(B_max_TF, R_TF_out, c_TF):
2635
2670
  Wedged (or bucked) TF coils fill the whole toroidal sector at any radius,
2636
2671
  so the inboard cross-section summed over the N_TF coils is the annulus
2637
2672
  between R_TF_out - c_TF and R_TF_out. Ampere's law on the toroidal path at
2638
- the high-field face gives the total ampere-turns, hence
2673
+ the high-field face of the winding pack, behind the backplate cover c_BP,
2674
+ gives the total ampere-turns, hence
2639
2675
 
2640
- N I_tot = 2 pi R_TF_out B_max_TF / mu0
2676
+ N I_tot = 2 pi (R_TF_out - c_BP) B_max_TF / mu0
2641
2677
  A_tot = pi (R_TF_out^2 - (R_TF_out - c_TF)^2)
2642
2678
  J_coil = N I_tot / A_tot
2643
- = 2 R_TF_out B_max_TF / [mu0 (R_TF_out^2 - (R_TF_out - c_TF)^2)]
2679
+ = 2 (R_TF_out - c_BP) B_max_TF / [mu0 (R_TF_out^2 - (R_TF_out - c_TF)^2)]
2644
2680
 
2645
2681
  Consistency. For the refined model the winding-pack solver defines
2646
2682
  alpha = 2 B_max R_ext / (mu0 J_wost (R_ext^2 - R_sep^2)), i.e. alpha is
2647
2683
  exactly the ratio of the WP-smeared current density to J_wost. Evaluating
2648
- the expression above with c_TF = c_WP therefore returns alpha * J_wost
2649
- identically. For the academic model the WP is sized from
2684
+ the expression above at the winding-pack face (R_TF_out = R_ext, c_BP = 0)
2685
+ with c_TF = c_WP therefore returns alpha * J_wost identically. For the
2686
+ academic model the WP is sized from
2650
2687
  S_cond = N I_tot / J_wost, so the same expression with c_TF = c_WP returns
2651
2688
  J_wost identically. Both identities were verified numerically to machine
2652
2689
  precision.
@@ -2661,6 +2698,9 @@ def f_J_coil_TF(B_max_TF, R_TF_out, c_TF):
2661
2698
  Total inboard radial thickness of the coil [m]. Pass the converged
2662
2699
  c (WP + nose + backplate) for J_coil, or c_WP alone for the
2663
2700
  winding-pack-scale density.
2701
+ c_BP : float
2702
+ Backplate cover in front of the winding pack [m] (f_TF_cover).
2703
+ B_max_TF sits at R_TF_out - c_BP.
2664
2704
 
2665
2705
  Returns
2666
2706
  -------
@@ -2680,7 +2720,7 @@ def f_J_coil_TF(B_max_TF, R_TF_out, c_TF):
2680
2720
  A_tot = np.pi * (R_TF_out**2 - R_in**2)
2681
2721
  if A_tot <= 0.0:
2682
2722
  return np.nan
2683
- return (2.0 * np.pi * R_TF_out * B_max_TF / μ0) / A_tot
2723
+ return (2.0 * np.pi * (R_TF_out - c_BP) * B_max_TF / μ0) / A_tot
2684
2724
 
2685
2725
 
2686
2726
  def f_J_coil_CS(B_CS, d_CS):
@@ -4249,7 +4289,9 @@ def f_TF_refined(a, b, R0, σ_TF, J_max_TF, B_max_TF, Choice_Buck_Wedg, omega, n
4249
4289
  omega : WP share of the vertical tension f_z,WP [-]
4250
4290
  (Auclair et al. 2026, Table 1 and Eq. 23)
4251
4291
  n : Conductor geometry factor for γ(α, n) [-]
4252
- c_BP : Backplate thickness (m)
4292
+ c_BP : Backplate cover on the plasma side of the winding pack (m),
4293
+ wedging only. B_max sits behind it, at R0 - a - b - c_BP
4294
+ (f_TF_cover, f_B0)
4253
4295
  coef_inboard_tension : Inboard share of the total vertical force [-]
4254
4296
  (keep 0.5 for consistency with the WP sigma_z; see Nose_refined)
4255
4297
  F_CClamp : Clamping (pre-compression) force [N], subtracted from the
@@ -4309,13 +4351,17 @@ def f_TF_refined(a, b, R0, σ_TF, J_max_TF, B_max_TF, Choice_Buck_Wedg, omega, n
4309
4351
 
4310
4352
  if Choice_Buck_Wedg == "Wedging":
4311
4353
 
4312
- c_WP, σ_r, σ_z, σ_theta, Steel_fraction = Winding_Pack_refined( R0, a, b, σ_TF, J_max_TF, B_max_TF, omega, n, grading=TF_grading, delta_port=delta_port, F_CClamp=F_CClamp)
4354
+ # Backplate cover on the plasma side, as in ITER [Sborchia 2008]: the
4355
+ # winding pack, with B_max on its face, starts at R0 - a - b - c_BP.
4356
+ b_WP = b + c_BP
4357
+
4358
+ c_WP, σ_r, σ_z, σ_theta, Steel_fraction = Winding_Pack_refined( R0, a, b_WP, σ_TF, J_max_TF, B_max_TF, omega, n, grading=TF_grading, delta_port=delta_port, F_CClamp=F_CClamp)
4313
4359
 
4314
4360
  # Vérification que c_WP est valide
4315
4361
  if c_WP is None or np.isnan(c_WP) or c_WP < 0:
4316
4362
  return np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan
4317
4363
 
4318
- c_Nose = R0 - a - b - c_WP - Nose_refined(R0 - a - b - c_WP, σ_TF, omega, B_max_TF, R0, a, b,
4364
+ c_Nose = R0 - a - b_WP - c_WP - Nose_refined(R0 - a - b_WP - c_WP, σ_TF, omega, B_max_TF, R0, a, b_WP,
4319
4365
  coef_inboard_tension, delta_port=delta_port, F_CClamp=F_CClamp)
4320
4366
 
4321
4367
  # Vérification que c_Nose est valide
@@ -4358,8 +4404,8 @@ def f_TF_refined(a, b, R0, σ_TF, J_max_TF, B_max_TF, Choice_Buck_Wedg, omega, n
4358
4404
  c_case_min = f_case_min * 2.0 * kappa * a
4359
4405
  c_Nose = max(c_Nose, c_case_min - c_BP)
4360
4406
 
4361
- # Vérification que la somme ne dépasse pas R0 - a - b
4362
- if (c_WP + c_Nose) > (R0 - a - b):
4407
+ # Vérification que la somme ne dépasse pas R0 - a - b - c_BP
4408
+ if (c_WP + c_Nose) > (R0 - a - b_WP):
4363
4409
  return np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan
4364
4410
 
4365
4411
  # Epaisseur totale de la bobine
@@ -4389,6 +4435,20 @@ def f_TF_refined(a, b, R0, σ_TF, J_max_TF, B_max_TF, Choice_Buck_Wedg, omega, n
4389
4435
  return c, c_WP, c_Nose, σ_z, σ_theta, σ_r, Steel_fraction
4390
4436
 
4391
4437
 
4438
+ def f_TF_cover(Radial_build_model, Choice_Buck_Wedg, c_BP):
4439
+ """
4440
+ Backplate cover between the plasma face of the TF coil and its winding
4441
+ pack [m].
4442
+
4443
+ Only the refined wedging build contains it (f_TF_refined,
4444
+ c = c_WP + c_Nose + c_BP). B_max then sits on the winding pack, behind
4445
+ the cover, at R0 - a - b - c_BP. The other builds have no cover.
4446
+ """
4447
+ if Choice_Buck_Wedg == "Wedging" and Radial_build_model in ("refined", "CIRCE"):
4448
+ return c_BP
4449
+ return 0.0
4450
+
4451
+
4392
4452
  #%% TF Benchmark
4393
4453
  if __name__ == "__main__":
4394
4454
  # TF coil benchmark table: D0FUS vs published references
@@ -6206,9 +6266,11 @@ if __name__ == "__main__":
6206
6266
  print("\n--- ITER TF ---")
6207
6267
  # Geometry: r_bore_in/out are the inner/outer radii of the toroidal volume
6208
6268
  # where B_tor exists, i.e., the TF inner and outer leg positions.
6209
- # Princeton-D bore of the ITER deck with the published B0 R0 = 5.3 x 6.2
6210
- # T m, i.e. B_max = 10.6 T at R0 - a - b = 3.1 m.
6211
- E_TF = calculate_E_mag_TF(5.3 * 6.2 / 3.1, 2.0, 1.1, 6.2, 0.9, 1.59)
6269
+ # ITER coil with the published B0 R0 = 5.3 x 6.2 T m: c = 0.90 m (DDD),
6270
+ # winding pack 0.633 m [Sborchia 2008, Fig. 2] behind a 0.07 m cover
6271
+ # (DDD), i.e. B_max = 10.85 T at R0 - a - b - c_BP = 3.03 m.
6272
+ E_TF = calculate_E_mag_TF(5.3 * 6.2 / 3.03, 2.0, 1.1, 6.2, 0.9, 1.59,
6273
+ 0.633, 0.07)
6212
6274
  E_TF_ref = 41e9
6213
6275
  # Discharge parameters [2]: 9 FDU, V_max ~ 6 kV, tau_dis ~ 11 s
6214
6276
  I_TF = 68e3
@@ -6784,9 +6846,9 @@ def f_cable_length(
6784
6846
  """
6785
6847
  Total cable conductor length for the TF and CS systems.
6786
6848
 
6787
- TF — Ampere's law on toroidal path at the plasma-facing inner face
6788
- (R_TF_in = R0 − a − b), consistent with the NI convention used
6789
- throughout D0FUS (save_run_output, calculate_E_mag_TF):
6849
+ TF — Ampere's law on toroidal path at the plasma face of the winding
6850
+ pack (R_TF_in = R0 − a − b − c_cover, f_TF_cover), consistent with the
6851
+ NI convention used throughout D0FUS (save_run_output, calculate_E_mag_TF):
6790
6852
  NI_total = Bmax_TF × 2π × R_TF_in / μ₀
6791
6853
  N_turns = NI_total / (N_TF × I_cond_TF)
6792
6854
  L_cable = N_TF × N_turns × L_turn_TF
@@ -6801,7 +6863,8 @@ def f_cable_length(
6801
6863
  N_TF : int Number of TF coils.
6802
6864
  L_turn_TF : float Princeton-D outer contour arc length [m].
6803
6865
  Bmax_TF : float Peak field on TF conductor [T].
6804
- R_TF_in : float Plasma-facing inner face radius = R0 − a − b [m].
6866
+ R_TF_in : float Winding-pack plasma face, where Bmax_TF sits,
6867
+ R0 − a − b − c_cover [m].
6805
6868
  This is the radius used for Ampere's law throughout
6806
6869
  D0FUS (consistent with N_turns displayed in output).
6807
6870
  I_cond_TF : float Operating current per TF conductor [A].
@@ -1554,15 +1554,20 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
1554
1554
  Marge_T_REBCO=Marge_T_REBCO, Eps=Eps, Tet=Tet,
1555
1555
  J_wost_Manual=J_wost_Manual if Supra_choice == 'Manual' else None)
1556
1556
 
1557
- # Stored energy in the Princeton-D bore. The bore depends on the coil
1558
- # thickness c, unknown here: thin-coil estimate (c = 0), refined by the
1559
- # fixed point of the TF sizing below.
1560
- E_mag_TF = calculate_E_mag_TF(Bmax_TF, a, b, R0, 0.0, Delta_TF)
1557
+ # Backplate cover in front of the winding pack, refined wedging only
1558
+ # (f_TF_cover). B_max sits behind it, for B0 and the stored energy.
1559
+ c_cover = f_TF_cover(Radial_build_model, Choice_Buck_Wedg, c_BP)
1560
+
1561
+ # Stored energy in the bore and the winding pack. Both depend on the coil
1562
+ # build, unknown here: thin-coil estimate (cover alone, c_WP = 0), refined
1563
+ # by the fixed point of the TF sizing below.
1564
+ E_mag_TF = calculate_E_mag_TF(Bmax_TF, a, b, R0, c_cover, Delta_TF,
1565
+ 0.0, c_cover)
1561
1566
  result_J_TF = _tf_cable(E_mag_TF)
1562
1567
  J_max_TF_conducteur = result_J_TF['J_wost']
1563
1568
 
1564
1569
  # ── On-axis magnetic field and alpha power ────────────────────────────────
1565
- B0_solution = f_B0(Bmax_TF, a, b, R0, b_cover=c_BP)
1570
+ B0_solution = f_B0(Bmax_TF, a, b, R0, b_cover=c_cover)
1566
1571
  # Charged-product and neutron fractions of P_fus (constant for D-T,
1567
1572
  # branch-weighted on the deck profiles for D-D).
1568
1573
  f_charged, f_neutron = f_fuel_power_split(
@@ -2943,7 +2948,7 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
2943
2948
  # WP envelope, stress concentrations, weld efficiency and manufacturing
2944
2949
  # tolerances not represented in the idealised CICC area model.
2945
2950
  # The quench protection sizes J_TF from the stored energy, and the
2946
- # Princeton-D bore holding that energy grows with c: fixed point on c,
2951
+ # bore and winding pack holding that energy grow with c: fixed point on c,
2947
2952
  # 2 to 4 sizings. delta_port = Delta_TF puts the outboard leg where the
2948
2953
  # ripple and port-access sizing placed it, in the vertical force.
2949
2954
  for _ in range(10):
@@ -2969,7 +2974,8 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
2969
2974
 
2970
2975
  if not np.isfinite(c):
2971
2976
  break
2972
- E_mag_c = calculate_E_mag_TF(Bmax_TF, a, b, R0, c, Delta_TF)
2977
+ E_mag_c = calculate_E_mag_TF(Bmax_TF, a, b, R0, c, Delta_TF,
2978
+ c_WP_TF, c_cover)
2973
2979
  if abs(E_mag_c - E_mag_TF) <= 1e-3 * E_mag_TF:
2974
2980
  break
2975
2981
  E_mag_TF = E_mag_c
@@ -3260,7 +3266,7 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
3260
3266
  # ── Cable conductor lengths ───────────────────────────────────────────────
3261
3267
  R_CS_ext_val = R0 - a - b - c - _gap_eff
3262
3268
  L_turn_CS = np.pi * (R_CS_ext_val + R_CS_ext_val - d) # 2π × R_mean
3263
- _R_TF_in = R0 - a - b # plasma-facing inner face, consistent with D0FUS NI convention
3269
+ _R_TF_in = R0 - a - b - c_cover # winding-pack face, where Bmax_TF sits (NI convention)
3264
3270
  (L_cable_TF, L_cable_CS,
3265
3271
  _Nturns_TF, _Nturns_CS) = f_cable_length(
3266
3272
  int(N_TF), L_turn_TF, Bmax_TF, _R_TF_in,
@@ -3334,7 +3340,7 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
3334
3340
  (V_cryo_LHe_solution, V_cryo_LN_solution) = f_cryo_LHe_LN_volume(P_cryo_electric_solution)
3335
3341
  house_load_components_solution = house_load_breakdown(
3336
3342
  config, _R_TF_out, R_bore_TF, c, _H_TF_D, Z_TF_bore_half, N_TF,
3337
- calculate_E_mag_TF(Bmax_TF, a, b, R0, c, Delta_TF),
3343
+ calculate_E_mag_TF(Bmax_TF, a, b, R0, c, Delta_TF, c_WP_TF, c_cover),
3338
3344
  P_cryo_cool_solution)
3339
3345
  P_house_load_solution = house_load_components_solution['P_house']
3340
3346
  # Coolant pumping on the heat extracted during the burn (nominal)
@@ -4024,7 +4030,10 @@ def _write_full_report(config, results, output_path, timestamp, input_file_path=
4024
4030
  named["J_wost_CS"] = J_CS_1
4025
4031
  named["J_coil_TF"] = f_J_coil_TF(config.Bmax_TF,
4026
4032
  config.R0 - config.a - config.b,
4027
- c_TF)
4033
+ c_TF,
4034
+ f_TF_cover(config.Radial_build_model,
4035
+ config.Choice_Buck_Wedg,
4036
+ config.c_BP))
4028
4037
  named["J_coil_CS"] = f_J_coil_CS(B_CS, c_CS)
4029
4038
  except Exception as e:
4030
4039
  notes.append(f" (results tuple not fully unpacked, part of the outputs is n/a: {e})")
@@ -4592,16 +4601,20 @@ def save_run_output(config: GlobalConfig,
4592
4601
  "for a thick breeder")
4593
4602
 
4594
4603
  # ── Magnetic stored energy and ampere-turns (display only) ────────────
4595
- # Princeton-D bore of the sized coil, as in run()
4604
+ # Bore and winding pack of the sized coil, as in run()
4596
4605
  _r_in_TF = config.R0 - config.a - config.b
4606
+ _c_cover = f_TF_cover(config.Radial_build_model, config.Choice_Buck_Wedg,
4607
+ config.c_BP)
4597
4608
  E_mag_TF_disp = calculate_E_mag_TF(config.Bmax_TF, config.a, config.b,
4598
- config.R0, c, Delta_TF_disp)
4609
+ config.R0, c, Delta_TF_disp,
4610
+ c_WP_TF, _c_cover)
4599
4611
  # House load breakdown, as in run()
4600
4612
  _hl = house_load_breakdown(config, _R_TF_out_disp, _R_bore_disp, c,
4601
4613
  _H_TF_disp, float(np.max(_Z_in_disp)), N_TF_disp,
4602
4614
  E_mag_TF_disp, P_cryo_cool)
4603
- # Ampere's law on toroidal path at inner bore: NI_total = B_max × 2π r_in / μ₀
4604
- NI_TF_total = config.Bmax_TF * 2 * np.pi * _r_in_TF / μ0
4615
+ # Ampere's law on toroidal path at the winding pack, behind the cover:
4616
+ # NI_total = B_max × 2π (r_in − c_cover) / μ₀
4617
+ NI_TF_total = config.Bmax_TF * 2 * np.pi * (_r_in_TF - _c_cover) / μ0
4605
4618
  # Per-coil ampere-turns and winding turns
4606
4619
  NI_TF_coil = NI_TF_total / N_TF_disp if N_TF_disp > 0 else np.nan
4607
4620
  Nturns_TF_coil = NI_TF_coil / config.I_cond if config.I_cond > 0 else np.nan
@@ -4638,7 +4651,7 @@ def save_run_output(config: GlobalConfig,
4638
4651
  # full coil cross-section, steel jacket and structural case included.
4639
4652
  # Both follow from Ampere's law and the converged build alone; see
4640
4653
  # f_J_coil_TF / f_J_coil_CS in D0FUS_radial_build_functions.
4641
- J_coil_TF = f_J_coil_TF(config.Bmax_TF, _r_in_TF, c)
4654
+ J_coil_TF = f_J_coil_TF(config.Bmax_TF, _r_in_TF, c, _c_cover)
4642
4655
  J_coil_CS = f_J_coil_CS(B_CS, d)
4643
4656
 
4644
4657
  # Impurity inventory for the per-species display, with the same coronal
@@ -5228,7 +5241,7 @@ def _generate_run_figures(config: GlobalConfig, results: tuple,
5228
5241
  output_path: str, verbose: int = 0,
5229
5242
  view_3d: bool = True) -> None:
5230
5243
  """
5231
- Generate and save run-specific figures (18, 17 without the 3D view) into
5244
+ Generate and save run-specific figures (19, 18 without the 3D view) into
5232
5245
  output_path/figures/.
5233
5246
 
5234
5247
  Calls D0FUS_figures.plot_run() which produces only the figures that
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d0fus
3
- Version: 3.3.0
3
+ Version: 3.3.2
4
4
  Summary: Design 0-dimensional for Fusion Systems - Tokamak power plant design and optimization tool
5
5
  Author-email: Timothé Auclair <timothe.auclair@proton.me>
6
6
  Maintainer-email: Timothé Auclair <timothe.auclair@proton.me>
@@ -42,19 +42,19 @@ Dynamic: license-file
42
42
  <a name="readme-top"></a>
43
43
 
44
44
  <p align="center">
45
- <img src="docs/figures/D0FUS_logo.png" alt="D0FUS logo" width="190">
45
+ <img src="https://raw.githubusercontent.com/IRFM/D0FUS/main/docs/figures/D0FUS_logo.png" alt="D0FUS logo" width="190">
46
46
  </p>
47
47
 
48
48
  <h1 align="center">D0FUS</h1>
49
49
 
50
50
  <p align="center">
51
51
  <a href="https://cecill.info/licences/Licence_CeCILL-C_V1-en.html"><img src="https://img.shields.io/badge/License-CeCILL--C-blue.svg" alt="License: CeCILL-C"></a>
52
- <a href="https://pypi.org/project/d0fus/"><img src="https://badge.fury.io/py/d0fus.svg" alt="PyPI version"></a>
52
+ <a href="https://pypi.org/project/d0fus/"><img src="https://img.shields.io/pypi/v/d0fus.svg" alt="PyPI version"></a>
53
53
  <a href="https://d0fus.readthedocs.io"><img src="https://readthedocs.org/projects/d0fus/badge/?version=latest" alt="Documentation"></a>
54
54
  </p>
55
55
 
56
56
  <p align="center">
57
- <img src="docs/figures/d0fus_capabilities_banner.png" alt="D0FUS capabilities" width="100%">
57
+ <img src="https://raw.githubusercontent.com/IRFM/D0FUS/main/docs/figures/d0fus_capabilities_banner.png" alt="D0FUS capabilities" width="100%">
58
58
  </p>
59
59
 
60
60
  <p align="center">
@@ -162,7 +162,7 @@ The mode is detected from the content of the input file. Text after `#` is a com
162
162
 
163
163
  | Mode | Purpose | Trigger in the deck |
164
164
  |------|---------|---------------------|
165
- | **RUN** | Single design point, 165 outputs, report files, 16 figures | Fixed values only (`R0 = 9`) |
165
+ | **RUN** | Single design point, 165 outputs, report files, 19 figures | Fixed values only (`R0 = 9`) |
166
166
  | **SCAN** | 2D feasibility map, 108 registered output quantities | Exactly 2 entries `[min, max, n_points]`, other than the POPCON pair |
167
167
  | **OPTIMIZATION** | Genetic cost minimisation (DEAP) | 2+ entries `[min, max]` |
168
168
  | **POPCON** | Operating map (n̄, T̄) at fixed machine | `nbar_line` and `Tbar` written `[min, max, n_points]` |
@@ -281,7 +281,7 @@ Continuous distributions: `norm(sigma)`, `norm(lo, hi)`, `norm(lo, centre, hi)`,
281
281
 
282
282
  ## Outputs
283
283
 
284
- Every mode writes a folder named after the mode and the time, to the second, under `D0FUS_OUTPUTS/<mode>/`. From a clone, `D0FUS_OUTPUTS` is at the root of the repository, whatever the working directory. For an installed package, it is in the working directory. A RUN produces `input_parameters.txt` (the deck), `output_highlight.txt` (key results), `output_detailed.txt` (every input including defaults, every output), and 18 figures (cross-section, Miller surfaces, profiles, q(ρ), radiation, divertor two-point, radial build, coil and CICC drawings, cost breakdown, temperature and density maps, pulse and dwell power-balance Sankey diagrams, PyVista 3D view skipped with `--no-3d`). A design without a solution gives NaN in the reports and figures. SCAN writes the 2D map, OPTIMIZATION the convergence plot, `optimization_summary.json` (settings, seed, Hall of Fame), a copy of the deck and the reports of the best design, POPCON the operating-contour map, UNCERTAINTY a summary with the feasible share and its confidence interval, the per-output distributions and figures.
284
+ Every mode writes a folder named after the mode and the time, to the second, under `D0FUS_OUTPUTS/<mode>/`. From a clone, `D0FUS_OUTPUTS` is at the root of the repository, whatever the working directory. For an installed package, it is in the working directory. A RUN produces `input_parameters.txt` (the deck), `output_highlight.txt` (key results), `output_detailed.txt` (every input including defaults, every output), and 19 figures (cross-section, Miller surfaces, profiles, q(ρ), radiation, divertor two-point, radial build as a cross-section and as a midplane bar, coil and CICC drawings, cost breakdown, temperature and density maps, pulse and dwell power-balance Sankey diagrams, PyVista 3D view skipped with `--no-3d`). A design without a solution gives NaN in the reports and figures. SCAN writes the 2D map, OPTIMIZATION the convergence plot, `optimization_summary.json` (settings, seed, Hall of Fame), a copy of the deck and the reports of the best design, POPCON the operating-contour map, UNCERTAINTY a summary with the feasible share and its confidence interval, the per-output distributions and figures.
285
285
 
286
286
  ---
287
287
 
@@ -311,7 +311,7 @@ Tests: `pip install -e ".[dev]"`, then `python -m pytest` from the repository ro
311
311
 
312
312
  ## License
313
313
 
314
- [CeCILL-C](https://cecill.info/licences/Licence_CeCILL-C_V1-en.html), a French free software license compatible with the GNU LGPL. See [LICENSE](LICENSE).
314
+ [CeCILL-C](https://cecill.info/licences/Licence_CeCILL-C_V1-en.html), a French free software license compatible with the GNU LGPL. See [LICENSE](https://github.com/IRFM/D0FUS/blob/main/LICENSE).
315
315
 
316
316
  © 2025-2026 CEA/IRFM
317
317
 
@@ -1,19 +1,19 @@
1
1
  <a name="readme-top"></a>
2
2
 
3
3
  <p align="center">
4
- <img src="docs/figures/D0FUS_logo.png" alt="D0FUS logo" width="190">
4
+ <img src="https://raw.githubusercontent.com/IRFM/D0FUS/main/docs/figures/D0FUS_logo.png" alt="D0FUS logo" width="190">
5
5
  </p>
6
6
 
7
7
  <h1 align="center">D0FUS</h1>
8
8
 
9
9
  <p align="center">
10
10
  <a href="https://cecill.info/licences/Licence_CeCILL-C_V1-en.html"><img src="https://img.shields.io/badge/License-CeCILL--C-blue.svg" alt="License: CeCILL-C"></a>
11
- <a href="https://pypi.org/project/d0fus/"><img src="https://badge.fury.io/py/d0fus.svg" alt="PyPI version"></a>
11
+ <a href="https://pypi.org/project/d0fus/"><img src="https://img.shields.io/pypi/v/d0fus.svg" alt="PyPI version"></a>
12
12
  <a href="https://d0fus.readthedocs.io"><img src="https://readthedocs.org/projects/d0fus/badge/?version=latest" alt="Documentation"></a>
13
13
  </p>
14
14
 
15
15
  <p align="center">
16
- <img src="docs/figures/d0fus_capabilities_banner.png" alt="D0FUS capabilities" width="100%">
16
+ <img src="https://raw.githubusercontent.com/IRFM/D0FUS/main/docs/figures/d0fus_capabilities_banner.png" alt="D0FUS capabilities" width="100%">
17
17
  </p>
18
18
 
19
19
  <p align="center">
@@ -121,7 +121,7 @@ The mode is detected from the content of the input file. Text after `#` is a com
121
121
 
122
122
  | Mode | Purpose | Trigger in the deck |
123
123
  |------|---------|---------------------|
124
- | **RUN** | Single design point, 165 outputs, report files, 16 figures | Fixed values only (`R0 = 9`) |
124
+ | **RUN** | Single design point, 165 outputs, report files, 19 figures | Fixed values only (`R0 = 9`) |
125
125
  | **SCAN** | 2D feasibility map, 108 registered output quantities | Exactly 2 entries `[min, max, n_points]`, other than the POPCON pair |
126
126
  | **OPTIMIZATION** | Genetic cost minimisation (DEAP) | 2+ entries `[min, max]` |
127
127
  | **POPCON** | Operating map (n̄, T̄) at fixed machine | `nbar_line` and `Tbar` written `[min, max, n_points]` |
@@ -240,7 +240,7 @@ Continuous distributions: `norm(sigma)`, `norm(lo, hi)`, `norm(lo, centre, hi)`,
240
240
 
241
241
  ## Outputs
242
242
 
243
- Every mode writes a folder named after the mode and the time, to the second, under `D0FUS_OUTPUTS/<mode>/`. From a clone, `D0FUS_OUTPUTS` is at the root of the repository, whatever the working directory. For an installed package, it is in the working directory. A RUN produces `input_parameters.txt` (the deck), `output_highlight.txt` (key results), `output_detailed.txt` (every input including defaults, every output), and 18 figures (cross-section, Miller surfaces, profiles, q(ρ), radiation, divertor two-point, radial build, coil and CICC drawings, cost breakdown, temperature and density maps, pulse and dwell power-balance Sankey diagrams, PyVista 3D view skipped with `--no-3d`). A design without a solution gives NaN in the reports and figures. SCAN writes the 2D map, OPTIMIZATION the convergence plot, `optimization_summary.json` (settings, seed, Hall of Fame), a copy of the deck and the reports of the best design, POPCON the operating-contour map, UNCERTAINTY a summary with the feasible share and its confidence interval, the per-output distributions and figures.
243
+ Every mode writes a folder named after the mode and the time, to the second, under `D0FUS_OUTPUTS/<mode>/`. From a clone, `D0FUS_OUTPUTS` is at the root of the repository, whatever the working directory. For an installed package, it is in the working directory. A RUN produces `input_parameters.txt` (the deck), `output_highlight.txt` (key results), `output_detailed.txt` (every input including defaults, every output), and 19 figures (cross-section, Miller surfaces, profiles, q(ρ), radiation, divertor two-point, radial build as a cross-section and as a midplane bar, coil and CICC drawings, cost breakdown, temperature and density maps, pulse and dwell power-balance Sankey diagrams, PyVista 3D view skipped with `--no-3d`). A design without a solution gives NaN in the reports and figures. SCAN writes the 2D map, OPTIMIZATION the convergence plot, `optimization_summary.json` (settings, seed, Hall of Fame), a copy of the deck and the reports of the best design, POPCON the operating-contour map, UNCERTAINTY a summary with the feasible share and its confidence interval, the per-output distributions and figures.
244
244
 
245
245
  ---
246
246
 
@@ -270,7 +270,7 @@ Tests: `pip install -e ".[dev]"`, then `python -m pytest` from the repository ro
270
270
 
271
271
  ## License
272
272
 
273
- [CeCILL-C](https://cecill.info/licences/Licence_CeCILL-C_V1-en.html), a French free software license compatible with the GNU LGPL. See [LICENSE](LICENSE).
273
+ [CeCILL-C](https://cecill.info/licences/Licence_CeCILL-C_V1-en.html), a French free software license compatible with the GNU LGPL. See [LICENSE](https://github.com/IRFM/D0FUS/blob/main/LICENSE).
274
274
 
275
275
  © 2025-2026 CEA/IRFM
276
276
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d0fus
3
- Version: 3.3.0
3
+ Version: 3.3.2
4
4
  Summary: Design 0-dimensional for Fusion Systems - Tokamak power plant design and optimization tool
5
5
  Author-email: Timothé Auclair <timothe.auclair@proton.me>
6
6
  Maintainer-email: Timothé Auclair <timothe.auclair@proton.me>
@@ -42,19 +42,19 @@ Dynamic: license-file
42
42
  <a name="readme-top"></a>
43
43
 
44
44
  <p align="center">
45
- <img src="docs/figures/D0FUS_logo.png" alt="D0FUS logo" width="190">
45
+ <img src="https://raw.githubusercontent.com/IRFM/D0FUS/main/docs/figures/D0FUS_logo.png" alt="D0FUS logo" width="190">
46
46
  </p>
47
47
 
48
48
  <h1 align="center">D0FUS</h1>
49
49
 
50
50
  <p align="center">
51
51
  <a href="https://cecill.info/licences/Licence_CeCILL-C_V1-en.html"><img src="https://img.shields.io/badge/License-CeCILL--C-blue.svg" alt="License: CeCILL-C"></a>
52
- <a href="https://pypi.org/project/d0fus/"><img src="https://badge.fury.io/py/d0fus.svg" alt="PyPI version"></a>
52
+ <a href="https://pypi.org/project/d0fus/"><img src="https://img.shields.io/pypi/v/d0fus.svg" alt="PyPI version"></a>
53
53
  <a href="https://d0fus.readthedocs.io"><img src="https://readthedocs.org/projects/d0fus/badge/?version=latest" alt="Documentation"></a>
54
54
  </p>
55
55
 
56
56
  <p align="center">
57
- <img src="docs/figures/d0fus_capabilities_banner.png" alt="D0FUS capabilities" width="100%">
57
+ <img src="https://raw.githubusercontent.com/IRFM/D0FUS/main/docs/figures/d0fus_capabilities_banner.png" alt="D0FUS capabilities" width="100%">
58
58
  </p>
59
59
 
60
60
  <p align="center">
@@ -162,7 +162,7 @@ The mode is detected from the content of the input file. Text after `#` is a com
162
162
 
163
163
  | Mode | Purpose | Trigger in the deck |
164
164
  |------|---------|---------------------|
165
- | **RUN** | Single design point, 165 outputs, report files, 16 figures | Fixed values only (`R0 = 9`) |
165
+ | **RUN** | Single design point, 165 outputs, report files, 19 figures | Fixed values only (`R0 = 9`) |
166
166
  | **SCAN** | 2D feasibility map, 108 registered output quantities | Exactly 2 entries `[min, max, n_points]`, other than the POPCON pair |
167
167
  | **OPTIMIZATION** | Genetic cost minimisation (DEAP) | 2+ entries `[min, max]` |
168
168
  | **POPCON** | Operating map (n̄, T̄) at fixed machine | `nbar_line` and `Tbar` written `[min, max, n_points]` |
@@ -281,7 +281,7 @@ Continuous distributions: `norm(sigma)`, `norm(lo, hi)`, `norm(lo, centre, hi)`,
281
281
 
282
282
  ## Outputs
283
283
 
284
- Every mode writes a folder named after the mode and the time, to the second, under `D0FUS_OUTPUTS/<mode>/`. From a clone, `D0FUS_OUTPUTS` is at the root of the repository, whatever the working directory. For an installed package, it is in the working directory. A RUN produces `input_parameters.txt` (the deck), `output_highlight.txt` (key results), `output_detailed.txt` (every input including defaults, every output), and 18 figures (cross-section, Miller surfaces, profiles, q(ρ), radiation, divertor two-point, radial build, coil and CICC drawings, cost breakdown, temperature and density maps, pulse and dwell power-balance Sankey diagrams, PyVista 3D view skipped with `--no-3d`). A design without a solution gives NaN in the reports and figures. SCAN writes the 2D map, OPTIMIZATION the convergence plot, `optimization_summary.json` (settings, seed, Hall of Fame), a copy of the deck and the reports of the best design, POPCON the operating-contour map, UNCERTAINTY a summary with the feasible share and its confidence interval, the per-output distributions and figures.
284
+ Every mode writes a folder named after the mode and the time, to the second, under `D0FUS_OUTPUTS/<mode>/`. From a clone, `D0FUS_OUTPUTS` is at the root of the repository, whatever the working directory. For an installed package, it is in the working directory. A RUN produces `input_parameters.txt` (the deck), `output_highlight.txt` (key results), `output_detailed.txt` (every input including defaults, every output), and 19 figures (cross-section, Miller surfaces, profiles, q(ρ), radiation, divertor two-point, radial build as a cross-section and as a midplane bar, coil and CICC drawings, cost breakdown, temperature and density maps, pulse and dwell power-balance Sankey diagrams, PyVista 3D view skipped with `--no-3d`). A design without a solution gives NaN in the reports and figures. SCAN writes the 2D map, OPTIMIZATION the convergence plot, `optimization_summary.json` (settings, seed, Hall of Fame), a copy of the deck and the reports of the best design, POPCON the operating-contour map, UNCERTAINTY a summary with the feasible share and its confidence interval, the per-output distributions and figures.
285
285
 
286
286
  ---
287
287
 
@@ -311,7 +311,7 @@ Tests: `pip install -e ".[dev]"`, then `python -m pytest` from the repository ro
311
311
 
312
312
  ## License
313
313
 
314
- [CeCILL-C](https://cecill.info/licences/Licence_CeCILL-C_V1-en.html), a French free software license compatible with the GNU LGPL. See [LICENSE](LICENSE).
314
+ [CeCILL-C](https://cecill.info/licences/Licence_CeCILL-C_V1-en.html), a French free software license compatible with the GNU LGPL. See [LICENSE](https://github.com/IRFM/D0FUS/blob/main/LICENSE).
315
315
 
316
316
  © 2025-2026 CEA/IRFM
317
317
 
@@ -23,6 +23,7 @@ d0fus.egg-info/entry_points.txt
23
23
  d0fus.egg-info/requires.txt
24
24
  d0fus.egg-info/top_level.txt
25
25
  tests/test_blanket_layers.py
26
+ tests/test_figures.py
26
27
  tests/test_modes.py
27
28
  tests/test_physical_functions.py
28
29
  tests/test_plant_balance.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "d0fus"
7
- version = "3.3.0"
7
+ version = "3.3.2"
8
8
  description = "Design 0-dimensional for Fusion Systems - Tokamak power plant design and optimization tool"
9
9
  readme = "README.md"
10
10
  license = {text = "CeCILL-C"}
@@ -0,0 +1,33 @@
1
+ """Midplane radial build drawn by ``plot_radial_build``: the segments of
2
+ ``_midplane_build`` tile the midplane from the machine axis to the outer face of
3
+ the TF outboard leg. Structural checks only, no frozen values.
4
+ """
5
+ import pytest
6
+
7
+ from D0FUS_BIB.D0FUS_figures import _midplane_build, demo_run_dict, plot_radial_build
8
+
9
+
10
+ @pytest.mark.parametrize("variant", [
11
+ {}, # ITER demo, wedging with a TF-CS gap
12
+ {"Choice_Buck_Wedg": "Bucking"}, # no TF-CS gap
13
+ {"Delta_TF": 0.8}, # outboard clearance for port access
14
+ {"b": 0.15}, # compressed mandatory layers
15
+ {"b": 0.0}, # no radial space for the layers
16
+ ])
17
+ def test_midplane_build_tiles_the_midplane(variant):
18
+ run = dict(demo_run_dict(), **variant)
19
+ segs = _midplane_build(run)
20
+ R0, a, b, c_TF = run["R0"], run["a"], run["b"], run["c_TF"]
21
+ Delta_TF = run.get("Delta_TF", 0.0)
22
+ assert segs[0]["R_in"] == 0.0
23
+ for prev, nxt in zip(segs, segs[1:]):
24
+ assert nxt["R_in"] == pytest.approx(prev["R_out"], abs=1e-9)
25
+ assert all(s["R_out"] > s["R_in"] for s in segs)
26
+ plasma = next(s for s in segs if s["role"] == "plasma")
27
+ assert (plasma["R_in"], plasma["R_out"]) == pytest.approx((R0 - a, R0 + a))
28
+ assert segs[-1]["R_out"] == pytest.approx(R0 + a + b + Delta_TF + c_TF)
29
+
30
+
31
+ def test_plot_radial_build_writes_png(tmp_path):
32
+ plot_radial_build(demo_run_dict(), save_dir=str(tmp_path))
33
+ assert (tmp_path / "run_radial_build.png").is_file()
@@ -95,7 +95,7 @@ def test_j_coil_alpha_identities():
95
95
  J_w = rng.uniform(20e6, 300e6)
96
96
  R_sep = R_ext - c_WP
97
97
  alpha = 2 * B * R_ext / (μ0 * J_w * (R_ext**2 - R_sep**2))
98
- err_TF = max(err_TF, abs(f_J_coil_TF(B, R_ext, c_WP) / (alpha * J_w) - 1.0))
98
+ err_TF = max(err_TF, abs(f_J_coil_TF(B, R_ext, c_WP, 0.0) / (alpha * J_w) - 1.0))
99
99
  d = rng.uniform(0.05, 1.5)
100
100
  B_CS = rng.uniform(4.0, 25.0)
101
101
  alpha = B_CS / (μ0 * J_w * d)
@@ -105,8 +105,8 @@ def test_j_coil_alpha_identities():
105
105
 
106
106
 
107
107
  def test_j_coil_degenerate_geometry_returns_nan():
108
- assert np.isnan(f_J_coil_TF(10.0, 3.0, np.nan))
109
- assert np.isnan(f_J_coil_TF(10.0, 3.0, 0.0))
108
+ assert np.isnan(f_J_coil_TF(10.0, 3.0, np.nan, 0.0))
109
+ assert np.isnan(f_J_coil_TF(10.0, 3.0, 0.0, 0.0))
110
110
  assert np.isnan(f_J_coil_CS(10.0, 0.0))
111
111
  assert np.isnan(f_J_coil_CS(np.nan, 0.5))
112
112
 
@@ -134,8 +134,11 @@ def test_bore_log_integral_rectangle_exact():
134
134
 
135
135
 
136
136
  def test_e_mag_tf_iter():
137
- # ITER TF: 41 GJ [Mitchell IEEE TAS 18 (2008)], 10 %.
138
- E_TF = calculate_E_mag_TF(5.3 * 6.2 / 3.1, 2.0, 1.1, 6.2, 0.9, 1.59)
137
+ # ITER TF: 41 GJ [Mitchell IEEE TAS 18 (2008)], 10 %. Bore and winding
138
+ # pack: c = 0.90 m (DDD), WP 0.633 m [Sborchia IEEE TAS 18 (2008),
139
+ # Fig. 2] behind a 0.07 m cover (DDD), B0 R0 = 5.3 x 6.2 T m.
140
+ E_TF = calculate_E_mag_TF(5.3 * 6.2 / 3.03, 2.0, 1.1, 6.2, 0.9, 1.59,
141
+ 0.633, 0.07)
139
142
  np.testing.assert_allclose(E_TF, 41e9, rtol=0.10)
140
143
 
141
144
 
@@ -145,7 +148,7 @@ ITER_DECK = os.path.join(REPO_ROOT, "D0FUS_INPUTS", "1_run_ITER.txt")
145
148
 
146
149
  @pytest.mark.skipif(not os.path.exists(ITER_DECK), reason="ITER reference deck not present")
147
150
  def test_iter_deck_frozen_radial_build():
148
- # Anti-drift guard on the frozen 2026-10 coil quantities (< 0.5 %).
151
+ # Anti-drift guard on the frozen 2026-11 coil quantities (< 0.5 %).
149
152
  # Run in a fresh subprocess, as in the source block: in-process module
150
153
  # state can shift the CS sizing (see the note in the source).
151
154
  code = textwrap.dedent("""
@@ -153,7 +156,7 @@ def test_iter_deck_frozen_radial_build():
153
156
  import numpy as np
154
157
  from D0FUS_EXE.D0FUS_run import load_config_from_file, run
155
158
  res = run(load_config_from_file(%r), verbose=0)
156
- frozen = {44: 0.9385, 45: 0.5029, 46: 0.3656, 51: 0.7254, 1: 12.009}
159
+ frozen = {44: 0.9455, 45: 0.5145, 46: 0.3610, 51: 0.7532, 1: 12.290}
157
160
  names = {44: 'c_TF', 45: 'c_WP', 46: 'c_Nose', 51: 'd_CS', 1: 'B_CS'}
158
161
  for i, v in frozen.items():
159
162
  np.testing.assert_allclose(float(res[i]), v, rtol=5e-3, err_msg=names[i])
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes