d0fus 2.8.0__tar.gz → 2.8.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 (25) hide show
  1. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_figures.py +28 -16
  2. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_parameterization.py +4 -1
  3. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_physical_functions.py +16 -4
  4. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_radial_build_functions.py +268 -8
  5. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_EXE/D0FUS_popcon.py +2 -1
  6. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_EXE/D0FUS_run.py +87 -15
  7. {d0fus-2.8.0 → d0fus-2.8.2}/PKG-INFO +2 -2
  8. {d0fus-2.8.0 → d0fus-2.8.2}/README.md +1 -1
  9. {d0fus-2.8.0 → d0fus-2.8.2}/d0fus.egg-info/PKG-INFO +2 -2
  10. {d0fus-2.8.0 → d0fus-2.8.2}/pyproject.toml +1 -1
  11. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS.py +0 -0
  12. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_cost_data.py +0 -0
  13. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_cost_functions.py +0 -0
  14. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_import.py +0 -0
  15. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_BIB/D0FUS_machine_presets.py +0 -0
  16. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_EXE/D0FUS_genetic.py +0 -0
  17. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_EXE/D0FUS_scan.py +0 -0
  18. {d0fus-2.8.0 → d0fus-2.8.2}/D0FUS_EXE/D0FUS_uncertainty.py +0 -0
  19. {d0fus-2.8.0 → d0fus-2.8.2}/LICENSE +0 -0
  20. {d0fus-2.8.0 → d0fus-2.8.2}/d0fus.egg-info/SOURCES.txt +0 -0
  21. {d0fus-2.8.0 → d0fus-2.8.2}/d0fus.egg-info/dependency_links.txt +0 -0
  22. {d0fus-2.8.0 → d0fus-2.8.2}/d0fus.egg-info/entry_points.txt +0 -0
  23. {d0fus-2.8.0 → d0fus-2.8.2}/d0fus.egg-info/requires.txt +0 -0
  24. {d0fus-2.8.0 → d0fus-2.8.2}/d0fus.egg-info/top_level.txt +0 -0
  25. {d0fus-2.8.0 → d0fus-2.8.2}/setup.cfg +0 -0
@@ -1071,16 +1071,16 @@ def plot_Lz_cooling(
1071
1071
  # 4.29 % at C_alpha = 7.5; the same 4.29 % is now obtained at C_alpha = 5.7,
1072
1072
  # which is the new ITER deck calibration (Shimada 2007 projection).
1073
1073
  _HE_SCAN_ITER = [(3, 2.132), (4, 2.896), (5, 3.697), (5.7, 4.285),
1074
- (6, 4.546), (6.5, 4.992)]
1074
+ (6, 4.546), (6.5, 4.992), (6.6, 5.084)]
1075
1075
  # EU-DEMO 2017 deck, kept for the record but no longer plotted: the range to
1076
1076
  # expect for a DEMO-class device is not known with anything like the
1077
1077
  # confidence of the ITER projection, so showing it would invite more
1078
1078
  # commentary than it is worth. With the v2.8 balance its deck value
1079
- # C_alpha = 7.6 returns ~10 %, the European baseline assumption (the
1080
- # pre-v2.8 deck used C_alpha = 10 for 8.8 %).
1079
+ # C_alpha = 6.8 returns 8.8 %, against a European baseline that assumes
1080
+ # 10 % (the pre-v2.8 deck used C_alpha = 10 for the same 8.8 %).
1081
1081
  _HE_SCAN_DEMO = [(3, 3.670), (4, 4.947), (5, 6.263), (6, 7.627), (7, 9.053),
1082
1082
  (8, 10.564), (9, 12.200), (10, 14.038)]
1083
- _HE_ITER_LAST_FEASIBLE = 6.5 # beyond this the 500 MW ITER point does not close
1083
+ _HE_ITER_LAST_FEASIBLE = 6.6 # beyond this the 500 MW ITER point does not close
1084
1084
 
1085
1085
 
1086
1086
  def plot_He_fraction(
@@ -1104,16 +1104,16 @@ def plot_He_fraction(
1104
1104
  consistent with the design point of Chapter 2 by construction. This
1105
1105
  matters, because the standalone formula and the converged run do not
1106
1106
  agree: the former returns 4.6 % helium at C_alpha = 5 for ITER-like
1107
- parameters, the latter 2.7 %, the difference coming from the profiles,
1108
- the impurity dilution and the flux-surface volume weight.
1107
+ parameters, the latter 3.7 %, the difference coming from the impurity
1108
+ dilution, the pedestal profiles and the flux-surface volume weight.
1109
1109
 
1110
1110
  C_alpha is not a quantity one reads off a reference design. In PROCESS,
1111
1111
  for instance, the helium fraction is the input and tau_He*/tau_E an
1112
1112
  output, the only input on the ratio being a lower bound whose default is
1113
1113
  5.0 (constraint 62). It is therefore calibrated deck by deck so that the
1114
- predicted ash fraction lands on the projected one: 7.5 for ITER here.
1114
+ predicted ash fraction lands on the projected one: 5.7 for ITER here.
1115
1115
 
1116
- Past C_alpha ~ 9 the deck no longer closes: the dilution is such that
1116
+ Past C_alpha ~ 6.6 the deck no longer closes: the dilution is such that
1117
1117
  500 MW cannot be held under the density limit and the solver returns no
1118
1118
  design point. The curve stops there, which is a result in itself.
1119
1119
 
@@ -1154,7 +1154,7 @@ def plot_He_fraction(
1154
1154
  ax.set_xlabel(r"Removal efficiency $C_\alpha = \tau_\alpha^{*} / \tau_E$",
1155
1155
  fontsize=15)
1156
1156
  ax.set_ylabel(r"Helium ash fraction $f_\alpha$ [%]", fontsize=15)
1157
- ax.set_xlim(3, 9.6)
1157
+ ax.set_xlim(3, 7.2)
1158
1158
  ax.set_ylim(0, 6.6)
1159
1159
  ax.grid(True, alpha=0.28, lw=0.6)
1160
1160
  ax.tick_params(labelsize=13)
@@ -3116,7 +3116,11 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3116
3116
 
3117
3117
  col_line = "black"
3118
3118
  col_dim = "#333333"
3119
- h_cs = (kappa * a + b + 1.0)
3119
+ # CS half-height from the run dict (resolved once by f_H_CS).
3120
+ _H_CS_fig = run.get("H_CS")
3121
+ if _H_CS_fig is None or not np.isfinite(_H_CS_fig) or _H_CS_fig <= 0:
3122
+ _H_CS_fig = np.nan
3123
+ h_cs = 0.5 * _H_CS_fig
3120
3124
 
3121
3125
  # -- Figure -------------------------------------------------------------
3122
3126
  fig, ax = plt.subplots(figsize=(12.5, 8.2))
@@ -3137,7 +3141,8 @@ def plot_assembly_side_view(run, save_dir=None, n_cs_modules=None):
3137
3141
  Rp, Zp = _cl(R_lcfs, Z_lcfs)
3138
3142
  ax.fill(Rp, Zp, fc=col_plasma, alpha=ALPHA, ec="none", zorder=zbase + N + 1)
3139
3143
 
3140
- # CS: blue winding pack, segmented into N_sub_CS modules with white gaps.
3144
+ # CS: blue winding pack, segmented into N_sub_CS modules.
3145
+ # The 2 % inter-module gap is COSMETIC; the physics stack fills H_CS.
3141
3146
  if n_cs_modules == 1:
3142
3147
  ax.add_patch(plt.Rectangle((R_CS_int, -h_cs), c_CS, 2 * h_cs,
3143
3148
  fc=col_cs, alpha=ALPHA, ec="none", zorder=4))
@@ -3390,7 +3395,10 @@ def plot_CS_cross_section(
3390
3395
  R_CS_int = bd["R_CS_int"] # Inner radius of winding pack [m]
3391
3396
  R_CS_ext = bd["R_CS_ext"] # Outer radius of winding pack [m]
3392
3397
  c_CS = bd["c_CS"] # Winding-pack radial thickness [m]
3393
- H_CS = 2.0 * (kappa_edge * a + bd["b"] + 1.0)
3398
+ # CS height from the run dict (resolved once by f_H_CS).
3399
+ H_CS = run.get("H_CS")
3400
+ if H_CS is None or not np.isfinite(H_CS) or H_CS <= 0:
3401
+ H_CS = np.nan
3394
3402
  h_cs = H_CS / 2.0
3395
3403
 
3396
3404
  # ── Black-and-white colour scheme (matches TF side view) ────────
@@ -3959,10 +3967,14 @@ def plot_tokamak_3D(run: dict, save_dir: str | None = None,
3959
3967
  # Central solenoid: annulus R_CS_int -> R_CS_ext from the flux-swing
3960
3968
  # sizing. Height convention shared with plot_CS_cross_section,
3961
3969
  # clamped inside the TF bore interior. The CS is drawn segmented into
3962
- # N_sub_CS axial modules (quench-protection subdivision computed by
3963
- # D0FUS; 1 = monobloc), with the same 2 % inter-module gap convention
3964
- # as plot_assembly_side_view.
3965
- H_CS = min(2.0 * (kappa_edge * a + b + 1.0), H_TF - 2.0 * c_TF - 0.1)
3970
+ # N_sub_CS axial modules (an input: module count and number of independent
3971
+ # dump units in the quench model; 1 = monobloc). The 2 % inter-module gap
3972
+ # is COSMETIC, as in plot_assembly_side_view.
3973
+ # CS height from the run dict (resolved once by f_H_CS). No clamp against
3974
+ # the TF envelope: f_H_CS already references it to the TF bore.
3975
+ H_CS = run.get("H_CS")
3976
+ if H_CS is None or not np.isfinite(H_CS) or H_CS <= 0:
3977
+ H_CS = H_TF - 2.0 * c_TF
3966
3978
  n_mod = max(1, int(run.get("N_sub_CS", 1)))
3967
3979
  g_mod = 0.02 * H_CS if n_mod > 1 else 0.0
3968
3980
  mod_h = (H_CS - (n_mod - 1) * g_mod) / n_mod
@@ -317,7 +317,10 @@ class GlobalConfig:
317
317
  Gap : float = 0.10 # CS–TF mechanical clearance [m]
318
318
  n_shape_CS : float = 1.0 # CS conductor shape factor (1 = square, 0 = optimal) [-]
319
319
  N_sub_CS : int = 6 # Number of CS sub-modules [-]
320
- H_CS : float = None # CS total height [m]. None = 2(κa + b + 1) (default formula)
320
+ H_CS : float = None # CS total height [m]. None = TF winding-pack
321
+ # inside height (f_H_CS). Set a number to force
322
+ # it, e.g. a published allocation (EU-DEMO
323
+ # Baseline 2018: 17.92 m).
321
324
  f_swing_usable : float = 0.75 # Fraction of the CS bipolar swing usable for the
322
325
  # inductive flux budget [-]. The CS hardware swings
323
326
  # over the full bipolar range (-I_max → +I_max) and
@@ -1206,7 +1206,8 @@ if __name__ == "__main__":
1206
1206
  import D0FUS_BIB.D0FUS_figures as figs
1207
1207
  figs.plot_nT_profiles()
1208
1208
 
1209
- def f_nbar_line(nbar_vol, nu_n, rho_ped=1.0, n_ped_frac=0.0, N=2000):
1209
+ def f_nbar_line(nbar_vol, nu_n, rho_ped=1.0, n_ped_frac=0.0, N=2000,
1210
+ Vprime_data=None):
1210
1211
  """
1211
1212
  Convert volume-averaged electron density to line-averaged density.
1212
1213
 
@@ -1252,6 +1253,14 @@ def f_nbar_line(nbar_vol, nu_n, rho_ped=1.0, n_ped_frac=0.0, N=2000):
1252
1253
  rho_ped : float Normalised pedestal radius (default 1.0).
1253
1254
  n_ped_frac : float n_ped / n̄.
1254
1255
  N : int Integration points (default 2000).
1256
+ Vprime_data: tuple or None Flux-surface Jacobian used to normalise the
1257
+ profile to nbar_vol. MUST be the same Vprime_data as the run that
1258
+ produced nbar_vol. None (default) falls back to the cylindrical
1259
+ volume element 2 rho drho, which is correct in Academic geometry
1260
+ only. Passing None while nbar_vol is a refined-Miller volume
1261
+ average rebuilds a profile of the wrong amplitude and peaking: on
1262
+ the SF Plant V2 point this returned 1.968e20 instead of 2.102e20,
1263
+ a 6.8 % error propagating to f_GW, the L-H threshold and Ip.
1255
1264
 
1256
1265
  Returns
1257
1266
  -------
@@ -1273,10 +1282,12 @@ def f_nbar_line(nbar_vol, nu_n, rho_ped=1.0, n_ped_frac=0.0, N=2000):
1273
1282
  """
1274
1283
  rho_arr = np.linspace(0.0, 1.0, N)
1275
1284
  return float(np.trapezoid(f_nprof(nbar_vol, nu_n, rho_arr,
1276
- rho_ped, n_ped_frac), rho_arr))
1285
+ rho_ped, n_ped_frac,
1286
+ Vprime_data), rho_arr))
1277
1287
 
1278
1288
 
1279
- def f_nbar_vol_from_line(nbar_line, nu_n, rho_ped=1.0, n_ped_frac=0.0, N=2000):
1289
+ def f_nbar_vol_from_line(nbar_line, nu_n, rho_ped=1.0, n_ped_frac=0.0, N=2000,
1290
+ Vprime_data=None):
1280
1291
  """
1281
1292
  Convert line-averaged electron density to volume-averaged density.
1282
1293
 
@@ -1288,12 +1299,13 @@ def f_nbar_vol_from_line(nbar_line, nu_n, rho_ped=1.0, n_ped_frac=0.0, N=2000):
1288
1299
  nu_n : float Density peaking exponent.
1289
1300
  rho_ped, n_ped_frac : float Pedestal parameters.
1290
1301
  N : int Integration points.
1302
+ Vprime_data: tuple or None Flux-surface Jacobian, see f_nbar_line().
1291
1303
 
1292
1304
  Returns
1293
1305
  -------
1294
1306
  nbar_vol : float Volume-averaged density [same unit as nbar_line].
1295
1307
  """
1296
- ratio = f_nbar_line(1.0, nu_n, rho_ped, n_ped_frac, N)
1308
+ ratio = f_nbar_line(1.0, nu_n, rho_ped, n_ped_frac, N, Vprime_data)
1297
1309
  return nbar_line / ratio
1298
1310
 
1299
1311
  if __name__ == "__main__":
@@ -2483,6 +2483,232 @@ def get_cache_stats():
2483
2483
  'hit_rate': _cable_density_stats['hits'] / total if total > 0 else 0
2484
2484
  }
2485
2485
 
2486
+ #%% CS height
2487
+
2488
+ def f_H_CS(Z_TF_bore_half):
2489
+ """
2490
+ Total height of the central solenoid [m]: the TF winding-pack inside height.
2491
+
2492
+ Same reference as PROCESS (z_cs_half = z_tf_inside_half) and as Duchateau
2493
+ et al., Fusion Eng. Des. 89 (2014) 2606, Sec. 5.2, which builds H_CS from
2494
+ the TF inner line. No derating factor: on the EU-DEMO 2017 deck the rule
2495
+ returns 17.08 m against the 17.92 m of CS space allocated in Baseline 2018
2496
+ [Sarasola et al., IEEE TAS 30(4) 4200705 (2020)], i.e. -4.7 %.
2497
+
2498
+ H_CS does not enter the CS radial sizing, the flux capacity
2499
+ Psi_CS = (2 pi / 3) B_CS (R_e^2 + R_e R_i + R_i^2) being the
2500
+ infinite-solenoid expression. It sets the stored energy, the axial stress
2501
+ and every extensive quantity: ampere-turns, turns, conductor length,
2502
+ volume, mass, cost. Single source of truth, no consumer may re-derive it.
2503
+
2504
+ Parameters
2505
+ ----------
2506
+ Z_TF_bore_half : float
2507
+ Inside half-height of the TF winding pack [m], i.e. max(Z_in) of the
2508
+ inner contour returned by f_TF_cross_section.
2509
+
2510
+ Returns
2511
+ -------
2512
+ float
2513
+ CS total height [m], NaN if the input is not usable.
2514
+ """
2515
+ if Z_TF_bore_half is None or not np.isfinite(Z_TF_bore_half):
2516
+ return np.nan
2517
+ if Z_TF_bore_half <= 0.0:
2518
+ return np.nan
2519
+ return 2.0 * float(Z_TF_bore_half)
2520
+
2521
+
2522
+ def f_H_CS_module(H_CS, N_sub_CS):
2523
+ """
2524
+ Height of one CS module [m]: H_CS / N_sub_CS.
2525
+
2526
+ Inter-module gaps are ignored, being about 4 % of the module height on ITER
2527
+ [DDD11-3, ITER_D_2NHKHH v3.0, Table 4-2]. The gaps drawn in the figures are
2528
+ cosmetic.
2529
+
2530
+ Parameters
2531
+ ----------
2532
+ H_CS : float CS total height [m].
2533
+ N_sub_CS : int Number of CS modules [-].
2534
+
2535
+ Returns
2536
+ -------
2537
+ float
2538
+ Module height [m], NaN if the inputs are not usable.
2539
+ """
2540
+ if H_CS is None or not np.isfinite(H_CS) or H_CS <= 0.0:
2541
+ return np.nan
2542
+ return float(H_CS) / max(int(N_sub_CS), 1)
2543
+
2544
+
2545
+ #%% Coil-scale (overall) current densities
2546
+
2547
+ # =============================================================================
2548
+ # CURRENT DENSITY SCALES
2549
+ # =============================================================================
2550
+ #
2551
+ # The current density of a superconducting magnet can be quoted on several
2552
+ # reference cross-sections. From the smallest to the largest:
2553
+ #
2554
+ # J_SC intrinsic critical current density of the superconducting
2555
+ # material alone (filaments for LTS, REBCO layer for HTS).
2556
+ # J_non_Cu critical current density on the non-copper cross-section,
2557
+ # adding the strand matrix (Nb3Sn) or the substrate and buffer
2558
+ # layers (REBCO). This is what the scaling laws return, and what
2559
+ # manufacturers tabulate against B and T. In D0FUS it is the
2560
+ # 'J_non_Cu' entry of calculate_cable_current_density().
2561
+ # J_strand strand (or tape) current density, adding the copper stabiliser
2562
+ # carried inside the strand.
2563
+ # J_wost engineering current density "without steel", on the full CICC
2564
+ # cross-section minus the steel jacket. It includes the strands,
2565
+ # the interstrand helium void, the dedicated helium channel and
2566
+ # the electrical insulation. This is the 'J_wost' entry of
2567
+ # calculate_cable_current_density() and the quantity the radial
2568
+ # build solvers are driven by.
2569
+ # J_coil overall coil current density, on the full coil cross-section
2570
+ # including the steel jacket, the structural case and any extra
2571
+ # insulation. This is the quantity that appears in the magnet
2572
+ # current-carrying capability of the whole inboard leg.
2573
+ #
2574
+ # The two functions below return J_coil for the TF and CS systems. Both follow
2575
+ # from Ampere's law and the converged radial build alone: no assumption on the
2576
+ # internal composition of the conductor is required, so they hold for every
2577
+ # TF/CS model implemented in D0FUS (academic, refined, CIRCE).
2578
+
2579
+ def f_J_coil_TF(B_max_TF, R_TF_out, c_TF):
2580
+ """
2581
+ Overall current density of the TF inboard leg (J_coil scale).
2582
+
2583
+ The reference cross-section is the FULL inboard leg of the TF system,
2584
+ winding pack + steel nose + backplate, in contrast with J_wost which is
2585
+ referenced to the non-steel part of the conductor only.
2586
+
2587
+ Wedged (or bucked) TF coils fill the whole toroidal sector at any radius,
2588
+ so the inboard cross-section summed over the N_TF coils is the annulus
2589
+ between R_TF_out - c_TF and R_TF_out. Ampere's law on the toroidal path at
2590
+ the high-field face gives the total ampere-turns, hence
2591
+
2592
+ N I_tot = 2 pi R_TF_out B_max_TF / mu0
2593
+ A_tot = pi (R_TF_out^2 - (R_TF_out - c_TF)^2)
2594
+ J_coil = N I_tot / A_tot
2595
+ = 2 R_TF_out B_max_TF / [mu0 (R_TF_out^2 - (R_TF_out - c_TF)^2)]
2596
+
2597
+ Consistency. For the refined model the winding-pack solver defines
2598
+ alpha = 2 B_max R_ext / (mu0 J_wost (R_ext^2 - R_sep^2)), i.e. alpha is
2599
+ exactly the ratio of the WP-smeared current density to J_wost. Evaluating
2600
+ the expression above with c_TF = c_WP therefore returns alpha * J_wost
2601
+ identically. For the academic model the WP is sized from
2602
+ S_cond = N I_tot / J_wost, so the same expression with c_TF = c_WP returns
2603
+ J_wost identically. Both identities were verified numerically to machine
2604
+ precision.
2605
+
2606
+ Parameters
2607
+ ----------
2608
+ B_max_TF : float
2609
+ Peak toroidal field at the inboard conductor face [T].
2610
+ R_TF_out : float
2611
+ Radius of the plasma-facing TF face, R0 - a - b [m].
2612
+ c_TF : float
2613
+ Total inboard radial thickness of the coil [m]. Pass the converged
2614
+ c (WP + nose + backplate) for J_coil, or c_WP alone for the
2615
+ winding-pack-scale density.
2616
+
2617
+ Returns
2618
+ -------
2619
+ float
2620
+ Overall current density [A/m^2], NaN if the geometry is degenerate.
2621
+ """
2622
+ if (B_max_TF is None or R_TF_out is None or c_TF is None):
2623
+ return np.nan
2624
+ B_max_TF = float(B_max_TF)
2625
+ R_TF_out = float(R_TF_out)
2626
+ c_TF = float(c_TF)
2627
+ if not (np.isfinite(B_max_TF) and np.isfinite(R_TF_out) and np.isfinite(c_TF)):
2628
+ return np.nan
2629
+ R_in = R_TF_out - c_TF
2630
+ if R_TF_out <= 0.0 or c_TF <= 0.0 or R_in < 0.0:
2631
+ return np.nan
2632
+ A_tot = np.pi * (R_TF_out**2 - R_in**2)
2633
+ if A_tot <= 0.0:
2634
+ return np.nan
2635
+ return (2.0 * np.pi * R_TF_out * B_max_TF / μ0) / A_tot
2636
+
2637
+
2638
+ def f_J_coil_CS(B_CS, d_CS):
2639
+ """
2640
+ Overall current density of the CS winding pack (J_coil scale).
2641
+
2642
+ The CS is modelled as a thick solenoid of radial thickness d_CS and
2643
+ height H_CS. Ampere's law on an axial path through the bore gives
2644
+ N I_tot = B_CS H_CS / mu0, and the reference cross-section is
2645
+ A = H_CS d_CS, so H_CS cancels:
2646
+
2647
+ J_coil = B_CS / (mu0 d_CS)
2648
+
2649
+ The CS models carry no separate structural case, so this cross-section
2650
+ already includes the steel jacket: it is the J_coil scale of the CS.
2651
+
2652
+ Consistency. f_CS_refined and f_CS_CIRCE define
2653
+ alpha = B_CS / (mu0 J_wost d), so the expression above returns
2654
+ alpha * J_wost identically, i.e. the same smeared current density
2655
+ J_smear that enters the mechanical model (curl B = mu0 J_smear).
2656
+
2657
+ Parameters
2658
+ ----------
2659
+ B_CS : float
2660
+ Peak field at the CS bore [T], full bipolar swing convention.
2661
+ d_CS : float
2662
+ CS winding-pack radial thickness [m].
2663
+
2664
+ Returns
2665
+ -------
2666
+ float
2667
+ Overall current density [A/m^2], NaN if the geometry is degenerate.
2668
+ """
2669
+ if B_CS is None or d_CS is None:
2670
+ return np.nan
2671
+ B_CS = float(B_CS)
2672
+ d_CS = float(d_CS)
2673
+ if not (np.isfinite(B_CS) and np.isfinite(d_CS)) or d_CS <= 0.0:
2674
+ return np.nan
2675
+ return B_CS / (μ0 * d_CS)
2676
+
2677
+ #%% Coil-scale current density test
2678
+
2679
+ if __name__ == "__main__":
2680
+ # The J_coil expressions must reproduce, at the winding-pack scale, the
2681
+ # alpha definitions the mechanical solvers are built on. Two identities
2682
+ # are asserted, both exact by construction:
2683
+ # TF : f_J_coil_TF(B, R_ext, c_WP) == alpha * J_wost with
2684
+ # alpha = 2 B R_ext / (mu0 J_wost (R_ext^2 - R_sep^2)) [Winding_Pack_refined]
2685
+ # CS : f_J_coil_CS(B_CS, d) == alpha * J_wost with
2686
+ # alpha = B_CS / (mu0 J_wost d) [f_CS_refined]
2687
+ _rng = np.random.default_rng(0)
2688
+ _err_TF, _err_CS = 0.0, 0.0
2689
+ for _ in range(500):
2690
+ _R_ext = _rng.uniform(1.0, 6.0)
2691
+ _c_WP = _rng.uniform(0.02, 0.6) * _R_ext
2692
+ _B = _rng.uniform(4.0, 25.0)
2693
+ _J_w = _rng.uniform(20e6, 300e6)
2694
+ _R_sep = _R_ext - _c_WP
2695
+ _alpha = 2 * _B * _R_ext / (μ0 * _J_w * (_R_ext**2 - _R_sep**2))
2696
+ _err_TF = max(_err_TF,
2697
+ abs(f_J_coil_TF(_B, _R_ext, _c_WP) / (_alpha * _J_w) - 1.0))
2698
+ _d = _rng.uniform(0.05, 1.5)
2699
+ _B_CS = _rng.uniform(4.0, 25.0)
2700
+ _alpha = _B_CS / (μ0 * _J_w * _d)
2701
+ _err_CS = max(_err_CS,
2702
+ abs(f_J_coil_CS(_B_CS, _d) / (_alpha * _J_w) - 1.0))
2703
+ assert _err_TF < 1e-12, _err_TF
2704
+ assert _err_CS < 1e-12, _err_CS
2705
+ # Degenerate geometries must return NaN rather than raising.
2706
+ assert np.isnan(f_J_coil_TF(10.0, 3.0, np.nan))
2707
+ assert np.isnan(f_J_coil_TF(10.0, 3.0, 0.0))
2708
+ assert np.isnan(f_J_coil_CS(10.0, 0.0))
2709
+ assert np.isnan(f_J_coil_CS(np.nan, 0.5))
2710
+ print(f"OK J_coil scales: TF err = {_err_TF:.1e}, CS err = {_err_CS:.1e}")
2711
+
2486
2712
  #%% Without Steel current density test
2487
2713
 
2488
2714
  """
@@ -5838,6 +6064,23 @@ def f_TF_cross_section(a: float, b: float, R0: float,
5838
6064
  L_turn : float Outer-contour arc length (one full turn) [m].
5839
6065
  R_out, Z_out : ndarray Outer Princeton-D contour.
5840
6066
  R_in, Z_in : ndarray Inner (offset) contour.
6067
+
6068
+ Notes
6069
+ -----
6070
+ The constant-tension shape is built on the conductor centreline and offset
6071
+ by +-c/2, as in PROCESS (mid-plane winding-pack radii); L_turn is the
6072
+ centreline length, the conductor path. Building the shape on the outer
6073
+ envelope instead, as before v2.9, maximises k = 0.5 ln(r2/r1) and gives a
6074
+ coil 8 % (EU-DEMO 2017) to 13 % (SF Plant V2) taller, with L_turn taken on
6075
+ the outer face, a further 7 % of conductor.
6076
+
6077
+ Accuracy. The ODE matches a quadrature of the analytic curve
6078
+ R(alpha) = r2 exp(k(sin alpha - 1)) to below 1 mm, and A_cross equals
6079
+ L_turn * c to 0.05 %. Against the built ITER coil (~14 m) the two
6080
+ conventions bracket: centreline 13.1 m, outer envelope 14.5 m. Neither is
6081
+ exact because ITER's D is not constant-tension; the centreline is kept as
6082
+ the one with a physical basis. A coil still coming out too tall points at
6083
+ the inboard build of the deck, not at the shape.
5841
6084
  """
5842
6085
  R_bore = R0 - a - b - c
5843
6086
  R_TF_out = R0 + a + b + Delta_TF + c
@@ -5852,8 +6095,17 @@ def f_TF_cross_section(a: float, b: float, R0: float,
5852
6095
  return (R_bore, R_TF_out, np.nan, np.nan, np.nan,
5853
6096
  _nan_pts, _nan_pts, _nan_pts, _nan_pts)
5854
6097
 
5855
- R_out, Z_out = _princeton_D_contour(R_bore, R_TF_out)
5856
- R_in, Z_in = _offset_contour(R_out, Z_out, c)
6098
+ # Shape on the conductor centreline, faces at +-c/2 (see Notes).
6099
+ r1_cl = R_bore + 0.5 * c
6100
+ r2_cl = R_TF_out - 0.5 * c
6101
+ if not (r2_cl > r1_cl > 0.0):
6102
+ _nan_pts = np.full(2, np.nan)
6103
+ return (R_bore, R_TF_out, np.nan, np.nan, np.nan,
6104
+ _nan_pts, _nan_pts, _nan_pts, _nan_pts)
6105
+
6106
+ R_cl, Z_cl = _princeton_D_contour(r1_cl, r2_cl)
6107
+ R_out, Z_out = _offset_contour(R_cl, Z_cl, -0.5 * c)
6108
+ R_in, Z_in = _offset_contour(R_cl, Z_cl, 0.5 * c)
5857
6109
 
5858
6110
  H_TF = 2.0 * float(Z_out.max())
5859
6111
 
@@ -5861,7 +6113,8 @@ def f_TF_cross_section(a: float, b: float, R0: float,
5861
6113
  return abs(0.5 * np.sum(R * np.roll(Z, -1) - np.roll(R, -1) * Z))
5862
6114
 
5863
6115
  A_cross = _area(R_out, Z_out) - _area(R_in, Z_in)
5864
- L_turn = float(np.sum(np.hypot(np.diff(R_out), np.diff(Z_out))))
6116
+ # Turn length on the centreline: this is the conductor path.
6117
+ L_turn = float(np.sum(np.hypot(np.diff(R_cl), np.diff(Z_cl))))
5865
6118
 
5866
6119
  return R_bore, R_TF_out, H_TF, A_cross, L_turn, R_out, Z_out, R_in, Z_in
5867
6120
 
@@ -6087,12 +6340,11 @@ def f_radial_build_layers(
6087
6340
 
6088
6341
  def f_V_CS(a: float, b: float, c: float, d: float,
6089
6342
  R0: float, κ: float,
6090
- Gap: float, Choice_Buck_Wedg: str) -> float:
6343
+ Gap: float, Choice_Buck_Wedg: str,
6344
+ H_CS: float = None) -> float:
6091
6345
  """
6092
6346
  Volume of the full CS solenoid (annular right cylinder, all modules).
6093
6347
 
6094
- Formula consistent with f_volume():
6095
- H_CS = 2 × (κ·a + b + 1)
6096
6348
  V_CS_geom = π × H_CS × (R_CS_ext² − R_CS_int²)
6097
6349
 
6098
6350
  Parameters
@@ -6104,6 +6356,11 @@ def f_V_CS(a: float, b: float, c: float, d: float,
6104
6356
  κ : float Plasma elongation [-].
6105
6357
  Gap : float Radial TF bore → CS gap (Wedging only) [m].
6106
6358
  Choice_Buck_Wedg : str 'Wedging', 'Bucking', or 'Plug'.
6359
+ H_CS : float, optional
6360
+ CS total height [m], as resolved by f_H_CS. MUST be passed by any
6361
+ caller that also uses H_CS elsewhere, otherwise the volume and the
6362
+ ampere-turns describe two different coils. When omitted the legacy
6363
+ expression 2 (κ a + b + 1) is used, for backward compatibility only.
6107
6364
 
6108
6365
  Returns
6109
6366
  -------
@@ -6112,7 +6369,8 @@ def f_V_CS(a: float, b: float, c: float, d: float,
6112
6369
  _gap_eff = Gap if Choice_Buck_Wedg == 'Wedging' else 0.0
6113
6370
  R_CS_ext = R0 - a - b - c - _gap_eff
6114
6371
  R_CS_int = R_CS_ext - d
6115
- H_CS = 2.0 * (κ * a + b + 1)
6372
+ if H_CS is None or not np.isfinite(H_CS) or H_CS <= 0.0:
6373
+ H_CS = f_H_CS(κ, a, b, model='legacy')
6116
6374
  return np.pi * H_CS * (R_CS_ext ** 2 - R_CS_int ** 2)
6117
6375
 
6118
6376
 
@@ -6277,7 +6535,9 @@ def f_cable_length(
6277
6535
  N_sub_CS : int Number of CS modules.
6278
6536
  L_turn_CS : float Mean CS turn perimeter = π × (R_ext + R_int) [m].
6279
6537
  B_CS : float CS peak field [T].
6280
- H_CS_NI : float CS height for NI computation = 2(κa + b + 1) [m].
6538
+ H_CS_NI : float CS total height used for the solenoid Ampere law [m].
6539
+ Pass the H_CS resolved by f_H_CS, the same value that
6540
+ feeds the stored energy, the volume and the stresses.
6281
6541
 
6282
6542
  Returns
6283
6543
  -------
@@ -223,7 +223,8 @@ def compute_popcon(config, grid_spec, verbose=1):
223
223
 
224
224
  for jn, nbl in enumerate(nbar_line_grid):
225
225
  nbar_vol = f_nbar_vol_from_line(nbl, nu_n, rho_ped=rho_ped,
226
- n_ped_frac=n_ped_frac)
226
+ n_ped_frac=n_ped_frac,
227
+ Vprime_data=Vprime_data)
227
228
  P_fus = P_REF * (nbar_vol / n_ref_vol)**2
228
229
  P_alpha = f_P_alpha(P_fus)
229
230
 
@@ -894,7 +894,11 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
894
894
  rho_ped=rho_ped, n_ped_frac=n_ped_frac,
895
895
  T_ped_frac=T_ped_frac,
896
896
  Vprime_data=Vprime_data, tau_i_e=tau_i_e)
897
- nbar_line_loc = f_nbar_line(nbar_loc, nu_n, rho_ped, n_ped_frac)
897
+ # Vprime_data is required: nbar_loc is a volume average on the refined
898
+ # Miller Jacobian, so the profile rebuilt inside f_nbar_line must use
899
+ # the same volume element (see the f_nbar_line docstring).
900
+ nbar_line_loc = f_nbar_line(nbar_loc, nu_n, rho_ped, n_ped_frac,
901
+ Vprime_data=Vprime_data)
898
902
 
899
903
  # Radiative power losses [MW]
900
904
  # Fuel bremsstrahlung: uses Z_eff,fuel (D+T+He only) to avoid
@@ -2123,6 +2127,25 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
2123
2127
  # requirement proportionally: both the inductive (Ψ_ind ∝ Ip) and resistive
2124
2128
  # (Ψ_res = Ce μ0 R0 Ip) terms scale with the inductively-ramped current fraction.
2125
2129
  ΨRampUp *= (1.0 - getattr(config, 'f_heat_ramp', 0.0))
2130
+ # ── TF Princeton-D cross-section geometry ─────────────────────────────────
2131
+ # Solved here rather than after the CS block because the CS height is
2132
+ # referenced to the TF winding-pack inside height (see f_H_CS). The ODE is
2133
+ # solved once per run and every consumer reuses this result.
2134
+ (R_bore_TF, _R_TF_out, _H_TF_D, _A_cross_TF, L_turn_TF,
2135
+ _R_out, _Z_out, _R_in, _Z_in) = f_TF_cross_section(a, b, R0, c, Delta_TF)
2136
+ Z_TF_bore_half = float(np.max(_Z_in)) if np.all(np.isfinite(_Z_in)) else np.nan
2137
+
2138
+ # ── CS height: single source of truth ────────────────────────────────────
2139
+ # An explicit config.H_CS wins, otherwise f_H_CS gives the TF bore inside
2140
+ # height. The resolved value is written back into the config so that every
2141
+ # consumer (the CS solvers via _CS_geometry_init, the volume, the cable
2142
+ # inventory, the report and the figures) sees the same height.
2143
+ if config.H_CS is None or not (config.H_CS > 0):
2144
+ H_CS = f_H_CS(Z_TF_bore_half)
2145
+ config = dc_replace(config, H_CS=H_CS)
2146
+ else:
2147
+ H_CS = float(config.H_CS)
2148
+
2126
2149
  # ==============================================================================
2127
2150
  # CENTRAL SOLENOID (CS) DESIGN
2128
2151
  # Determines the CS radial thickness 'd' to satisfy the Volt-second budget.
@@ -2200,10 +2223,6 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
2200
2223
  alpha_GR=config.alpha_giacomin, f0=config.f0_zanca)
2201
2224
  if density_limit_model != 'greenwald':
2202
2225
  nG_solution = n_DL_line * Greenwald_limit
2203
- # ── TF Princeton-D cross-section geometry ─────────────────────────────────
2204
- (R_bore_TF, _R_TF_out, _H_TF_D, _A_cross_TF, L_turn_TF,
2205
- _R_out, _Z_out, _R_in, _Z_in) = f_TF_cross_section(a, b, R0, c, Delta_TF)
2206
-
2207
2226
  # Component volumes — only V_FI used; Princeton-D H_TF for the FI cylinder
2208
2227
  (_, _, _, V_FI) = f_volume(a, b, c, d, R0, κ, Delta_TF, _H_TF_D)
2209
2228
 
@@ -2211,7 +2230,7 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
2211
2230
  # f_V_TF(a,b,R0,c,N_TF,Delta_TF) = A_cross * 2π * R_bore / N_TF but it would
2212
2231
  # call f_TF_cross_section a second time (ODE solve). Use pre-computed values.
2213
2232
  V_TF_one = _A_cross_TF * 2.0 * np.pi * R_bore_TF / float(N_TF)
2214
- V_CS_geom = f_V_CS(a, b, c, d, R0, κ, Gap, Choice_Buck_Wedg)
2233
+ V_CS_geom = f_V_CS(a, b, c, d, R0, κ, Gap, Choice_Buck_Wedg, H_CS=H_CS)
2215
2234
 
2216
2235
  # ── Radial build layer volumes ────────────────────────────────────────────
2217
2236
  # All boundaries are real 3D contours; volumes via exact _moment_area integrals.
@@ -2269,7 +2288,7 @@ def run(config: GlobalConfig = None, verbose: int = 0) -> tuple:
2269
2288
  _Nturns_TF, _Nturns_CS) = f_cable_length(
2270
2289
  int(N_TF), L_turn_TF, Bmax_TF, _R_TF_in,
2271
2290
  I_cond,
2272
- N_sub_CS, L_turn_CS, B_CS, H_TF) # H_TF = 2(κa+b+1) = H_CS_NI
2291
+ N_sub_CS, L_turn_CS, B_CS, H_CS) # CS Ampere law uses the resolved H_CS
2273
2292
 
2274
2293
  # ── Material masses ───────────────────────────────────────────────────────
2275
2294
  (M_steel_TF, M_sc_TF, M_cu_TF, M_In_TF, M_total_TF,
@@ -2574,6 +2593,21 @@ def _build_run_dict(config: GlobalConfig, results: tuple) -> dict:
2574
2593
  except (TypeError, ValueError):
2575
2594
  return fallback
2576
2595
 
2596
+ # ── TF Princeton-D contour and CS height (single resolution) ─────────────
2597
+ # Same rule as run(). Solved once and reused by the cost block below.
2598
+ try:
2599
+ (_, _, _H_TF_cb, _, _, _, _, _, _Z_in_cb) = f_TF_cross_section(
2600
+ config.a, config.b, config.R0, c_TF, Delta_TF)
2601
+ _Z_bore_half_cb = (float(np.max(_Z_in_cb))
2602
+ if np.all(np.isfinite(_Z_in_cb)) else np.nan)
2603
+ except Exception:
2604
+ _H_TF_cb, _Z_bore_half_cb = np.nan, np.nan
2605
+ if config.H_CS is not None and config.H_CS > 0:
2606
+ _H_CS_rd = float(config.H_CS)
2607
+ else:
2608
+ _H_CS_rd = f_H_CS(_Z_bore_half_cb)
2609
+ _H_CS_mod_rd = f_H_CS_module(_H_CS_rd, config.N_sub_CS)
2610
+
2577
2611
  # ── Techno-economic breakdown (Sheffield), recomputed here so the cost
2578
2612
  # figure matches the run() report. Mirrors the run() cost block exactly;
2579
2613
  # empty dict when cost_model is off or any required input is unavailable.
@@ -2584,7 +2618,6 @@ def _build_run_dict(config: GlobalConfig, results: tuple) -> dict:
2584
2618
  _P_e_c = max(_P_elec, 1.0)
2585
2619
  _T_op_c = results[132]; _CF_c = results[135]
2586
2620
  _t_bl_c = results[130]; _t_div_c = results[131]; _V_rb_BB_c = results[138]
2587
- _, _, _H_TF_cb, *_ = f_TF_cross_section(config.a, config.b, config.R0, c_TF, Delta_TF)
2588
2621
  (_, _, _, _V_FI_c) = f_volume(config.a, config.b, c_TF, c_CS, config.R0,
2589
2622
  kappa_edge, Delta_TF, _H_TF_cb)
2590
2623
  _cr = f_costs_Sheffield(
@@ -2661,6 +2694,10 @@ def _build_run_dict(config: GlobalConfig, results: tuple) -> dict:
2661
2694
  "c_WP": _f(c_WP_TF, 0.36),
2662
2695
  "c_nose": _f(c_Nose_TF, 0.20),
2663
2696
  "c_CS": _f(c_CS, 0.70),
2697
+ # CS vertical build [m] — resolved by f_H_CS, consumed by the report
2698
+ # and by the figures.
2699
+ "H_CS": _H_CS_rd,
2700
+ "H_CS_module": _H_CS_mod_rd,
2664
2701
  "N_TF": N_TF,
2665
2702
  "N_sub_CS": config.N_sub_CS, # CS axial segmentation (1 = monobloc)
2666
2703
  "Delta_TF": Delta_TF, # Extra outboard radial clearance from port-access constraint [m]
@@ -2867,6 +2904,17 @@ def _write_full_report(config, results, output_path, timestamp, input_file_path=
2867
2904
  for i, nm in enumerate(names_rest):
2868
2905
  if i < len(rest):
2869
2906
  named[nm] = rest[i]
2907
+ # Coil-scale (overall) current densities, derived from Ampere's law
2908
+ # and the converged build. J_TF / J_CS_1 returned by the solvers are
2909
+ # J_wost, i.e. referenced to the non-steel cross-section only; J_coil
2910
+ # is referenced to the full coil cross-section (steel jacket, nose and
2911
+ # backplate included). See f_J_coil_TF / f_J_coil_CS.
2912
+ named["J_wost_TF"] = J_TF
2913
+ named["J_wost_CS"] = J_CS_1
2914
+ named["J_coil_TF"] = f_J_coil_TF(config.Bmax_TF,
2915
+ config.R0 - config.a - config.b,
2916
+ c_TF)
2917
+ named["J_coil_CS"] = f_J_coil_CS(B_CS, c_CS)
2870
2918
  except Exception:
2871
2919
  pass
2872
2920
 
@@ -3059,7 +3107,8 @@ def _write_full_report(config, results, output_path, timestamp, input_file_path=
3059
3107
  lines.append("")
3060
3108
 
3061
3109
  emit("10. OUTPUTS - TF coil (winding pack, composition, structure)", [
3062
- ("TF current density J_TF", "J_TF", "A/m^2"),
3110
+ ("TF current density J_wost_TF (no steel)", "J_wost_TF", "A/m^2"),
3111
+ ("TF current density J_coil_TF (full TF leg)", "J_coil_TF", "A/m^2"),
3063
3112
  ("TF radial thickness c_TF", "c_TF", "m"),
3064
3113
  ("TF winding-pack thickness c_WP", "c_WP", "m"),
3065
3114
  ("TF nose thickness c_nose", "c_nose", "m"),
@@ -3069,7 +3118,6 @@ def _write_full_report(config, results, output_path, timestamp, input_file_path=
3069
3118
  ("TF axial stress sz_TF", "sz_TF", "Pa"),
3070
3119
  ("TF hoop stress st_TF", "st_TF", "Pa"),
3071
3120
  ("TF radial stress sr_TF", "sr_TF", "Pa"),
3072
- ("TF von Mises stress sf_TF", "sf_TF", "Pa"),
3073
3121
  ("TF SC fraction f_sc_TF", "f_sc_TF", "-"),
3074
3122
  ("TF Cu fraction f_cu_TF", "f_cu_TF", "-"),
3075
3123
  ("TF He-pipe fraction f_He_pipe_TF", "f_He_pipe_TF", "-"),
@@ -3093,17 +3141,19 @@ def _write_full_report(config, results, output_path, timestamp, input_file_path=
3093
3141
  ])
3094
3142
 
3095
3143
  emit("11. OUTPUTS - CS coil (winding pack, composition, structure)", [
3096
- ("CS current density J_CS_1", "J_CS_1", "A/m^2"),
3144
+ ("CS current density J_wost_CS (no steel)", "J_wost_CS", "A/m^2"),
3145
+ ("CS current density J_coil_CS (steel incl.)", "J_coil_CS", "A/m^2"),
3097
3146
  ("CS field (alt.) B_CS2", "B_CS2", "T"),
3098
3147
  ("CS current density (alt.) J_CS2", "J_CS2", "A/m^2"),
3099
3148
  ("CS radial thickness c_CS", "c_CS", "m"),
3149
+ ("CS total height H_CS", "H_CS", "m"),
3150
+ ("CS module height H_CS_module", "H_CS_module", "m"),
3100
3151
  ("CS module count N_sub_CS", "N_sub_CS", "-"),
3101
3152
  ("CS shape exponent n_shape_CS", "n_shape_CS", "-"),
3102
3153
  ("CS steel fraction Steel_fraction_CS", "Steel_fraction_CS", "-"),
3103
3154
  ("CS axial stress sz_CS", "sz_CS", "Pa"),
3104
3155
  ("CS hoop stress st_CS", "st_CS", "Pa"),
3105
3156
  ("CS radial stress sr_CS", "sr_CS", "Pa"),
3106
- ("CS von Mises stress sf_CS", "sf_CS", "Pa"),
3107
3157
  ("CS SC fraction f_sc_CS", "f_sc_CS", "-"),
3108
3158
  ("CS Cu fraction f_cu_CS", "f_cu_CS", "-"),
3109
3159
  ("CS He-pipe fraction f_He_pipe_CS", "f_He_pipe_CS", "-"),
@@ -3313,7 +3363,15 @@ def save_run_output(config: GlobalConfig,
3313
3363
  Nturns_TF_coil = NI_TF_coil / config.I_cond if config.I_cond > 0 else np.nan
3314
3364
 
3315
3365
  # CS geometry from converged radial build
3316
- _H_CS = _H_TF # Same vertical extent as TF
3366
+ # CS height: same resolution as run(), reusing the display cross-section
3367
+ # above so no extra ODE solve.
3368
+ if config.H_CS is not None and config.H_CS > 0:
3369
+ _H_CS, _H_CS_src = float(config.H_CS), 'forced'
3370
+ else:
3371
+ _Z_bore_half = (float(np.max(_Z_in_disp))
3372
+ if np.all(np.isfinite(_Z_in_disp)) else np.nan)
3373
+ _H_CS, _H_CS_src = f_H_CS(_Z_bore_half), 'TF bore'
3374
+ _H_CS_mod = f_H_CS_module(_H_CS, config.N_sub_CS)
3317
3375
  if np.isfinite(B_CS) and np.isfinite(r_d) and np.isfinite(r_c) and r_c > r_d:
3318
3376
  E_mag_CS_disp = calculate_E_mag_CS(B_CS, r_d, r_c, _H_CS)
3319
3377
  # Ampere's law on axial path through bore: NI_total = B_max × H / μ₀
@@ -3328,6 +3386,15 @@ def save_run_output(config: GlobalConfig,
3328
3386
  NI_CS_mod = np.nan
3329
3387
  Nturns_CS_mod = np.nan
3330
3388
 
3389
+ # ── Coil-scale (overall) current densities (display only) ─────────────
3390
+ # J_wost, returned by the radial build solvers, is referenced to the
3391
+ # non-steel cross-section of the conductor. J_coil is referenced to the
3392
+ # full coil cross-section, steel jacket and structural case included.
3393
+ # Both follow from Ampere's law and the converged build alone; see
3394
+ # f_J_coil_TF / f_J_coil_CS in D0FUS_radial_build_functions.
3395
+ J_coil_TF = f_J_coil_TF(config.Bmax_TF, _r_in_TF, c)
3396
+ J_coil_CS = f_J_coil_CS(B_CS, d)
3397
+
3331
3398
  # Re-parse multi-impurity config for per-species display
3332
3399
  _Z_CORONAL = {'Be': 4, 'C': 6, 'N': 7, 'Ne': 10, 'Ar': 18, 'Kr': 34, 'Xe': 44, 'W': 46}
3333
3400
  _sp_raw = config.impurity_species
@@ -3406,6 +3473,8 @@ def save_run_output(config: GlobalConfig,
3406
3473
  if config.Choice_Buck_Wedg == 'Wedging':
3407
3474
  print(f"[O] Gap (TF inner bore -> CS outer face) : {config.Gap:.3f} [m]", file=out)
3408
3475
  print(f"[O] d (CS winding-pack radial thickness) : {d:.3f} [m]", file=out)
3476
+ print(f"{'[O] H_CS (CS total height, ' + _H_CS_src + ')':<52}: {_H_CS:.3f} [m]", file=out)
3477
+ print(f"[O] H_CS/mod (CS module height) : {_H_CS_mod:.3f} [m]", file=out)
3409
3478
  print("-------------------------------------------------------------------------", file=out)
3410
3479
  print(f"[O] Kappa (Plasma elongation) : {κ:.3f}", file=out)
3411
3480
  print(f"[O] Kappa_95 (Elongation at 95% flux surface) : {κ_95:.3f}", file=out)
@@ -3422,8 +3491,11 @@ def save_run_output(config: GlobalConfig,
3422
3491
  print(f"[I] Bmax_TF (Peak field on TF conductor) : {config.Bmax_TF:.3f} [T]", file=out)
3423
3492
  print(f"[O] B0 (On-axis magnetic field) : {B0:.3f} [T]", file=out)
3424
3493
  print(f"[O] BCS (CS peak magnetic field) : {B_CS:.3f} [T]", file=out)
3425
- print(f"[O] J_E-TF (TF engineering current density) : {J_TF/1e6:.3f} [MA/m²]", file=out)
3426
- print(f"[O] J_E-CS (CS engineering current density) : {J_CS/1e6:.3f} [MA/m²]", file=out)
3494
+ print(f"[O] Engineering current density, by reference section", file=out)
3495
+ print(f"[O] ├ J_wost-TF (TF cable, steel jacket excluded) : {J_TF/1e6:.3f} [MA/m²]", file=out)
3496
+ print(f"[O] ├ J_coil-TF (TF leg: WP + nose + backplate) : {J_coil_TF/1e6:.3f} [MA/m²]", file=out)
3497
+ print(f"[O] ├ J_wost-CS (CS cable, steel jacket excluded) : {J_CS/1e6:.3f} [MA/m²]", file=out)
3498
+ print(f"[O] └ J_coil-CS (CS pack, steel jacket included) : {J_coil_CS/1e6:.3f} [MA/m²]", file=out)
3427
3499
  print(f"[O] E_mag_TF (TF stored magnetic energy) : {E_mag_TF_disp/1e9:.3f} [GJ]", file=out)
3428
3500
  print(f"[O] E_mag_CS (CS stored magnetic energy) : {E_mag_CS_disp/1e9:.3f} [GJ]", file=out)
3429
3501
  print(f"[I] I_cond (Operating current per conductor) : {config.I_cond/1e3:.1f} [kA]", file=out)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d0fus
3
- Version: 2.8.0
3
+ Version: 2.8.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@gmail.com>
6
6
  Maintainer-email: Timothé Auclair <timothe.auclair@gmail.com>
@@ -278,7 +278,7 @@ Full derivations, validity domains and references: thesis, Chapter 1 and Appendi
278
278
 
279
279
  ## Version and citation
280
280
 
281
- The tag **v2.7.0** is the reference version of the thesis: the manuscript documents this exact state of the code, and the benchmarks of its Chapter 2 (module level, coil-by-coil against six machines, EU-DEMO 2017 and ITER device level) were produced with it. To cite D0FUS, use `CITATION.cff` (GitHub's *Cite this repository* button) or cite the thesis:
281
+ To cite D0FUS, use `CITATION.cff` (GitHub's *Cite this repository* button) or cite the thesis:
282
282
 
283
283
  > T. Auclair, *Apport des supraconducteurs à haute température critique au dimensionnement de machines de fusion nucléaire par confinement magnétique*, PhD thesis, Aix-Marseille Université / CEA-IRFM, 2026.
284
284
 
@@ -234,7 +234,7 @@ Full derivations, validity domains and references: thesis, Chapter 1 and Appendi
234
234
 
235
235
  ## Version and citation
236
236
 
237
- The tag **v2.7.0** is the reference version of the thesis: the manuscript documents this exact state of the code, and the benchmarks of its Chapter 2 (module level, coil-by-coil against six machines, EU-DEMO 2017 and ITER device level) were produced with it. To cite D0FUS, use `CITATION.cff` (GitHub's *Cite this repository* button) or cite the thesis:
237
+ To cite D0FUS, use `CITATION.cff` (GitHub's *Cite this repository* button) or cite the thesis:
238
238
 
239
239
  > T. Auclair, *Apport des supraconducteurs à haute température critique au dimensionnement de machines de fusion nucléaire par confinement magnétique*, PhD thesis, Aix-Marseille Université / CEA-IRFM, 2026.
240
240
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d0fus
3
- Version: 2.8.0
3
+ Version: 2.8.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@gmail.com>
6
6
  Maintainer-email: Timothé Auclair <timothe.auclair@gmail.com>
@@ -278,7 +278,7 @@ Full derivations, validity domains and references: thesis, Chapter 1 and Appendi
278
278
 
279
279
  ## Version and citation
280
280
 
281
- The tag **v2.7.0** is the reference version of the thesis: the manuscript documents this exact state of the code, and the benchmarks of its Chapter 2 (module level, coil-by-coil against six machines, EU-DEMO 2017 and ITER device level) were produced with it. To cite D0FUS, use `CITATION.cff` (GitHub's *Cite this repository* button) or cite the thesis:
281
+ To cite D0FUS, use `CITATION.cff` (GitHub's *Cite this repository* button) or cite the thesis:
282
282
 
283
283
  > T. Auclair, *Apport des supraconducteurs à haute température critique au dimensionnement de machines de fusion nucléaire par confinement magnétique*, PhD thesis, Aix-Marseille Université / CEA-IRFM, 2026.
284
284
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "d0fus"
7
- version = "2.8.0"
7
+ version = "2.8.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"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes