d0fus 2.8.2__tar.gz → 2.8.3__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.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_figures.py +23 -7
  2. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_parameterization.py +22 -1
  3. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_physical_functions.py +281 -153
  4. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_EXE/D0FUS_genetic.py +6 -6
  5. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_EXE/D0FUS_popcon.py +8 -2
  6. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_EXE/D0FUS_run.py +205 -26
  7. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_EXE/D0FUS_scan.py +2 -2
  8. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_EXE/D0FUS_uncertainty.py +1 -2
  9. {d0fus-2.8.2 → d0fus-2.8.3}/PKG-INFO +1 -1
  10. {d0fus-2.8.2 → d0fus-2.8.3}/d0fus.egg-info/PKG-INFO +1 -1
  11. {d0fus-2.8.2 → d0fus-2.8.3}/pyproject.toml +1 -1
  12. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS.py +0 -0
  13. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_cost_data.py +0 -0
  14. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_cost_functions.py +0 -0
  15. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_import.py +0 -0
  16. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_machine_presets.py +0 -0
  17. {d0fus-2.8.2 → d0fus-2.8.3}/D0FUS_BIB/D0FUS_radial_build_functions.py +0 -0
  18. {d0fus-2.8.2 → d0fus-2.8.3}/LICENSE +0 -0
  19. {d0fus-2.8.2 → d0fus-2.8.3}/README.md +0 -0
  20. {d0fus-2.8.2 → d0fus-2.8.3}/d0fus.egg-info/SOURCES.txt +0 -0
  21. {d0fus-2.8.2 → d0fus-2.8.3}/d0fus.egg-info/dependency_links.txt +0 -0
  22. {d0fus-2.8.2 → d0fus-2.8.3}/d0fus.egg-info/entry_points.txt +0 -0
  23. {d0fus-2.8.2 → d0fus-2.8.3}/d0fus.egg-info/requires.txt +0 -0
  24. {d0fus-2.8.2 → d0fus-2.8.3}/d0fus.egg-info/top_level.txt +0 -0
  25. {d0fus-2.8.2 → d0fus-2.8.3}/setup.cfg +0 -0
@@ -1933,6 +1933,7 @@ def plot_resistivity_models(
1933
1933
  # rho_ped : float Normalised pedestal radius (1.0 = no pedestal)
1934
1934
  # n_ped_frac : float n_ped / nbar [-]
1935
1935
  # T_ped_frac : float T_ped / Tbar [-]
1936
+ # tau_i_e : float T_i / T_e ratio [-] (pressure closure, default 1)
1936
1937
  # q95 : float Safety factor at ρ₉₅ [-]
1937
1938
  # Z_eff : float Effective ion charge [-]
1938
1939
  # Impurities (optional — absent or None → species not plotted)
@@ -1992,6 +1993,7 @@ def _radiation_emissivity(
1992
1993
  n_ped_frac: float,
1993
1994
  T_ped_frac: float,
1994
1995
  impurities: dict,
1996
+ Vprime_data: tuple | None = None,
1995
1997
  ) -> dict:
1996
1998
  """
1997
1999
  Compute local volumetric radiation emissivity profiles.
@@ -2010,13 +2012,18 @@ def _radiation_emissivity(
2010
2012
  n_ped_frac : float n_ped / nbar.
2011
2013
  T_ped_frac : float T_ped / Tbar.
2012
2014
  impurities : dict {species: f_imp}, e.g. {'W': 5e-5, 'Ne': 3e-3}.
2015
+ Vprime_data : tuple or None
2016
+ Flux-surface volume data of the run (precompute_Vprime). The profiles
2017
+ are normalised with the same volume weight as run(): Miller V'/V in
2018
+ refined mode, cylindrical 2 rho when None (Academic mode).
2013
2019
 
2014
2020
  Returns
2015
2021
  -------
2016
2022
  dict with keys 'rho', 'P_brem', 'P_sync', and one key per impurity species.
2017
2023
  """
2018
- n_hat = f_nprof(1.0, nu_n, rho, rho_ped, n_ped_frac) # normalised density shape
2019
- T_arr = f_Tprof(Tbar, nu_T, rho, rho_ped, T_ped_frac) # [keV]
2024
+ # Same volume-average normalisation as the physics chain (run())
2025
+ n_hat = f_nprof(1.0, nu_n, rho, rho_ped, n_ped_frac, Vprime_data) # normalised density shape
2026
+ T_arr = f_Tprof(Tbar, nu_T, rho, rho_ped, T_ped_frac, Vprime_data) # [keV]
2020
2027
 
2021
2028
  n_e = nbar * 1e20 * n_hat # [m⁻³]
2022
2029
  T_eV = np.clip(T_arr * 1e3, 10.0, None) # [eV], floored for Lz interpolation
@@ -2068,15 +2075,23 @@ def plot_run_nTp(
2068
2075
  run : dict D0FUS run output (see section header for key list).
2069
2076
  n_rho : int Number of radial grid points.
2070
2077
  save_dir : str or None
2078
+
2079
+ Notes
2080
+ -----
2081
+ The profiles are normalised with the volume weight of run() (Miller V'/V
2082
+ in refined mode, cylindrical 2 rho in Academic mode), so that n_e(0),
2083
+ T_e(0) and p(ρ) are those used by the physics chain. The pressure follows
2084
+ f_pbar: p = (1 + τ_ie) n_e T_e (n_i ≈ n_e, T_i = τ_ie T_e).
2071
2085
  """
2072
2086
  nbar, Tbar, nu_n, nu_T, rho_ped, n_ped_frac, T_ped_frac = _resolve_kinetics(run)
2073
- Z_eff = float(run.get("Z_eff", 1.7))
2087
+ tau_i_e = float(run.get("tau_i_e", 1.0))
2088
+ Vprime_data = run.get("Vprime_data", None)
2074
2089
  rho = np.linspace(0.0, 1.0, n_rho)
2075
2090
 
2076
- n_prof = f_nprof(nbar, nu_n, rho, rho_ped, n_ped_frac) # [10²⁰ m⁻³]
2077
- T_prof = f_Tprof(Tbar, nu_T, rho, rho_ped, T_ped_frac) # [keV]
2078
- # Total pressure [kPa]: p = n_e (1 + 1/Z_eff) T_e
2079
- p_prof = (n_prof * 1e20) * (1.0 + 1.0 / Z_eff) * (T_prof * 1e3) * E_ELEM / 1e3
2091
+ n_prof = f_nprof(nbar, nu_n, rho, rho_ped, n_ped_frac, Vprime_data) # [10²⁰ m⁻³]
2092
+ T_prof = f_Tprof(Tbar, nu_T, rho, rho_ped, T_ped_frac, Vprime_data) # [keV]
2093
+ # Total pressure [kPa], same closure as f_pbar: p = (1 + tau_i_e) n_e T_e
2094
+ p_prof = (n_prof * 1e20) * (1.0 + tau_i_e) * (T_prof * 1e3) * E_ELEM / 1e3
2080
2095
 
2081
2096
  fig, axes = plt.subplots(1, 3, figsize=(16, 5))
2082
2097
 
@@ -2464,6 +2479,7 @@ def plot_radiation_profile(
2464
2479
  rho, nbar, Tbar, nu_n, nu_T,
2465
2480
  rho_ped, n_ped_frac, T_ped_frac,
2466
2481
  impurities,
2482
+ Vprime_data=run.get("Vprime_data", None),
2467
2483
  )
2468
2484
 
2469
2485
  line_colors = {"W": "tab:red", "Ne": "tab:cyan", "Ar": "tab:purple"}
@@ -42,6 +42,16 @@ C_LIGHT = 2.99792458e8 # Speed of light [m/s] (CODATA 2018)
42
42
  E_ALPHA = 3.5168e6 * E_ELEM # Alpha particle energy [J]
43
43
  E_N = 14.0671e6 * E_ELEM # Neutron energy [J]
44
44
 
45
+ # D-D primary branches (no secondary T or 3He burn).
46
+ # Q-values from CODATA 2018 nuclear masses: Q(DDn) = 3.2689 MeV,
47
+ # Q(DDp) = 4.0327 MeV. Products share Q by momentum conservation
48
+ # (non-relativistic), as in PROCESS constants.py. NRL Plasma Formulary
49
+ # quotes 0.82 / 2.45 MeV and 1.01 / 3.02 MeV.
50
+ E_HE3_DD = 0.8195e6 * E_ELEM # 3He from D(d,n)3He [J]
51
+ E_N_DD = 2.4494e6 * E_ELEM # Neutron from D(d,n)3He [J]
52
+ E_T_DD = 1.0098e6 * E_ELEM # Triton from D(d,p)T [J]
53
+ E_P_DD = 3.0229e6 * E_ELEM # Proton from D(d,p)T [J]
54
+
45
55
  #%% D0FUS Global Configuration
46
56
  """
47
57
  Centralised repository of all user-adjustable design parameters,
@@ -109,6 +119,14 @@ class GlobalConfig:
109
119
  f_GW_target : float = 0.85 # Target Greenwald fraction (Tbar_mode='greenwald') [-]
110
120
  Tbar_min : float = 4.0 # Lower Tbar bracket for the f_GW solve [keV]
111
121
  Tbar_max : float = 30.0 # Upper Tbar bracket for the f_GW solve [keV]
122
+ P_fus_mode : str = 'manual'
123
+ # Fusion power prescription mode:
124
+ # 'manual' : P_fus above is used directly.
125
+ # 'greenwald' : P_fus is SOLVED (brentq on log10 P_fus) so that the
126
+ # converged point sits at f_GW_target at the deck Tbar.
127
+ # The deck P_fus is the initial guess, and the bracket is
128
+ # expanded by decades. Exclusive with Tbar_mode='greenwald'.
129
+ # Natural choice for D-D devices, where P_fus is an output.
112
130
  tau_i_e : float = 1.0 # Ion-to-electron temperature ratio T_i/T_e [-]
113
131
  # 1.0 -> single-temperature plasma (T_i = T_e).
114
132
  # Prescribed: T_i(rho) = tau_i_e * T_e(rho),
@@ -204,7 +222,10 @@ class GlobalConfig:
204
222
  ms : float = 0.3 # Vertical stability margin parameter [-]
205
223
 
206
224
  # ── 4. Plasma composition ────────────────────────────────────────────────
207
- Atomic_mass : float = 2.5 # Volume-averaged ionic mass [AMU] (D-T: 2.5)
225
+ Fuel : str = 'DT' # Fuel mix: 'DT' (50/50 D-T) or 'DD' (pure D,
226
+ # Bosch-Hale D(d,n)3He + D(d,p)T, no secondary burn,
227
+ # ash = 3He from the neutron branch)
228
+ Atomic_mass : float = 2.5 # Volume-averaged ionic mass [AMU] (D-T: 2.5, D-D: 2.0)
208
229
  Zeff : float = None # Effective plasma charge [-].
209
230
  # None -> computed self-consistently from the impurity
210
231
  # inventory (impurity_species + f_imp_core) and the