d0fus 2.9.0__tar.gz → 2.9.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.9.0 → d0fus-2.9.2}/D0FUS_EXE/D0FUS_genetic.py +45 -17
  2. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_EXE/D0FUS_run.py +41 -0
  3. {d0fus-2.9.0 → d0fus-2.9.2}/PKG-INFO +1 -1
  4. {d0fus-2.9.0 → d0fus-2.9.2}/d0fus.egg-info/PKG-INFO +1 -1
  5. {d0fus-2.9.0 → d0fus-2.9.2}/pyproject.toml +1 -1
  6. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS.py +0 -0
  7. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_cost_data.py +0 -0
  8. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_cost_functions.py +0 -0
  9. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_figures.py +0 -0
  10. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_import.py +0 -0
  11. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_machine_presets.py +0 -0
  12. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_parameterization.py +0 -0
  13. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_physical_functions.py +0 -0
  14. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_BIB/D0FUS_radial_build_functions.py +0 -0
  15. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_EXE/D0FUS_popcon.py +0 -0
  16. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_EXE/D0FUS_scan.py +0 -0
  17. {d0fus-2.9.0 → d0fus-2.9.2}/D0FUS_EXE/D0FUS_uncertainty.py +0 -0
  18. {d0fus-2.9.0 → d0fus-2.9.2}/LICENSE +0 -0
  19. {d0fus-2.9.0 → d0fus-2.9.2}/README.md +0 -0
  20. {d0fus-2.9.0 → d0fus-2.9.2}/d0fus.egg-info/SOURCES.txt +0 -0
  21. {d0fus-2.9.0 → d0fus-2.9.2}/d0fus.egg-info/dependency_links.txt +0 -0
  22. {d0fus-2.9.0 → d0fus-2.9.2}/d0fus.egg-info/entry_points.txt +0 -0
  23. {d0fus-2.9.0 → d0fus-2.9.2}/d0fus.egg-info/requires.txt +0 -0
  24. {d0fus-2.9.0 → d0fus-2.9.2}/d0fus.egg-info/top_level.txt +0 -0
  25. {d0fus-2.9.0 → d0fus-2.9.2}/setup.cfg +0 -0
@@ -165,7 +165,8 @@ from D0FUS_BIB.D0FUS_physical_functions import f_volume
165
165
  from D0FUS_BIB.D0FUS_radial_build_functions import Number_TF_coils, f_TF_cross_section
166
166
  from D0FUS_BIB.D0FUS_cost_functions import f_costs_Sheffield
167
167
  from D0FUS_BIB.D0FUS_cost_data import *
168
- from D0FUS_EXE.D0FUS_run import run, save_run_output, thermal_multiplier
168
+ from D0FUS_EXE.D0FUS_run import (run, save_run_output, thermal_multiplier,
169
+ resolve_operating_point, core_plasma_values)
169
170
 
170
171
  # Backwards-compatible alias: some legacy parts of the file may still use
171
172
  # the `dc_replace` name (and the docstring references it).
@@ -2949,6 +2950,9 @@ def run_genetic_optimization(input_file,
2949
2950
 
2950
2951
  config = GlobalConfig(**{k: v for k, v in all_params.items()
2951
2952
  if k in GlobalConfig.__dataclass_fields__})
2953
+ # Resolve Greenwald closures (Tbar_mode / P_fus_mode) so that the summary
2954
+ # and save_run_output report the solved Tbar and P_fus, as in main()
2955
+ config = resolve_operating_point(config)
2952
2956
  final_output = run(config, verbose=0)
2953
2957
 
2954
2958
  # Extract key metrics via centralised index map
@@ -2966,6 +2970,8 @@ def run_genetic_optimization(input_file,
2966
2970
  d_CS = final_output[_IDX['d']]
2967
2971
  r_d = final_output[_IDX['r_d']]
2968
2972
  Ip = final_output[_IDX['Ip']]
2973
+ B0 = final_output[_IDX['B0']]
2974
+ _core = core_plasma_values(config, final_output)
2969
2975
 
2970
2976
  # Select kink parameter for final reporting (consistent with GA evaluation)
2971
2977
  _kink_param = static_inputs.get('kink_parameter',
@@ -3021,22 +3027,44 @@ def run_genetic_optimization(input_file,
3021
3027
  _within = _C_invest_best * 1e3 <= _budget if np.isfinite(_C_invest_best) else False
3022
3028
  _tag = "WITHIN BUDGET" if _within else "OVER BUDGET"
3023
3029
  print(f" Budget ceiling: {_budget*1e-3:.1f} B EUR [{_tag}]")
3024
- print(f"\n Best design metrics:")
3025
- print(f" R0 (major radius): {config.R0:.4f} [m]")
3026
- print(f" Volume proxy (V/P_fus): {cost:.4f} [m^3/MW]")
3027
- print(f" COE (Sheffield): {_COE_best:.1f} [EUR/MWh]")
3028
- print(f" C_invest: {_C_invest_best:.2f} [B EUR]")
3029
- print(f" Q factor: {Q:.2f}")
3030
- print(f" Ip: {Ip:.2f} MA")
3031
- print(f" P_elec: {P_elec:.1f} MW")
3032
- print(f" n_line/nG: {nbar_line/nG:.3f} ({(1-nbar_line/nG)*100:+.1f}% margin)")
3033
- print(f" betaN_total/betaN_limit: {betaN_total/betaN_lim:.3f} "
3034
- f"({(1-betaN_total/betaN_lim)*100:+.1f}% margin, toroidal incl. fast α)")
3035
- if Ip_lim is not None:
3036
- print(f" Ip/Ip_limit: {Ip/Ip_lim:.3f} ({(1-Ip/Ip_lim)*100:+.1f}% margin)")
3037
- q_lim = static_inputs.get('q_limit', DEFAULT_CONFIG.q_limit)
3038
- print(f" {_q_label}/q_limit: {q_kink/q_lim:.3f} ({(q_kink/q_lim-1)*100:+.1f}% margin)")
3039
- print(f" c_TF: {c_TF:.3f} m d_CS: {d_CS:.3f} m r_d: {r_d:.3f} m")
3030
+ print("\n Best design metrics:")
3031
+ print(f" R0 (major radius) : {config.R0:9.3f} [m]")
3032
+ print(f" B0 (on-axis field) : {B0:9.3f} [T]")
3033
+ print(f" Ip (plasma current) : {Ip:9.2f} [MA]")
3034
+ print(f" Q (fusion gain) : {Q:9.2f}")
3035
+ print(f" P_elec (net electric) : {P_elec:9.1f} [MWe]")
3036
+ print(f" COE (Sheffield) : {_COE_best:9.1f} [EUR/MWh]")
3037
+ print(f" C_invest : {_C_invest_best:9.2f} [B EUR]")
3038
+ print(f" V/P_fus (volume proxy) : {cost:9.4f} [m^3/MW]")
3039
+ print(f" c_TF / d_CS / r_d : {c_TF:.3f} / {d_CS:.3f} / {r_d:.3f} [m]")
3040
+
3041
+ print("\n Core plasma (rho = 0):")
3042
+ print(f" Te0 / Ti0 : {_core['Te0']:.2f} / {_core['Ti0']:.2f} [keV]")
3043
+ print(f" ne0 / ni0 (fuel ions) : {_core['ne0']:.3f} / {_core['ni0']:.3f} [1e20 m^-3]")
3044
+
3045
+ # Operational limits: margin > 0 means inside the limit
3046
+ def _lim_row(label, value, limit, upper=True, note=""):
3047
+ if limit is None or not np.isfinite(limit) or limit <= 0:
3048
+ print(f" {label:<26s}{value:10.3f}{'':>10s}{'':>11s} {note}")
3049
+ return
3050
+ margin = (1.0 - value / limit) if upper else (value / limit - 1.0)
3051
+ print(f" {label:<26s}{value:10.3f}{limit:10.3f}{margin*100:+9.1f} % {note}")
3052
+
3053
+ _nG_GW = Ip / (np.pi * config.a**2) # Greenwald density Ip/(pi a^2)
3054
+ _dl_mod = static_inputs.get('density_limit_model', DEFAULT_CONFIG.density_limit_model)
3055
+ _dl_fac = static_inputs.get('Greenwald_limit', DEFAULT_CONFIG.Greenwald_limit)
3056
+ _Ip_lim = (float(Ip_lim) if isinstance(Ip_lim, (int, float, np.integer, np.floating))
3057
+ else None)
3058
+ print(f"\n {'Operational limits':<29s}{'value':>10s}{'limit':>10s}{'margin':>11s}")
3059
+ _lim_row("n_line / n_limit [1e20]", nbar_line, nG,
3060
+ note=f"({_dl_mod} x {_dl_fac:g})")
3061
+ _lim_row("n_line / n_G [1e20]", nbar_line, _nG_GW,
3062
+ note="(Greenwald, Ip/pi a^2)")
3063
+ _lim_row("betaN / betaN_limit", betaN_total, betaN_lim,
3064
+ note="(thermal + fast alpha)")
3065
+ _lim_row(f"{_q_label} / q_limit", q_kink, q_lim, upper=False)
3066
+ _lim_row("Ip / Ip_limit [MA]", Ip, _Ip_lim,
3067
+ note="" if _Ip_lim is not None else "(no ceiling)")
3040
3068
 
3041
3069
  # Radial build sanity check on final design
3042
3070
  _rb_ok, _rb_reason = check_radial_build(
@@ -250,6 +250,47 @@ def thermal_multiplier(config):
250
250
  return f_n * M_blanket_effective(config.Blanket_choice) + 1.0 - f_n
251
251
 
252
252
 
253
+ def core_plasma_values(config, results):
254
+ """
255
+ On-axis plasma values (rho = 0) of a converged design.
256
+
257
+ T_e0 and n_e0 follow f_Tprof / f_nprof with the run() normalisation
258
+ (Miller V' in refined geometry, cylindrical otherwise). T_i0 = tau_i_e
259
+ T_e0. n_i0 is the fuel-ion density from quasi-neutrality with the He
260
+ ash and the impurity inventory: n_i0 = n_e0 (1 - 2 f_He - sum_j <Z_j> c_j).
261
+
262
+ Parameters
263
+ ----------
264
+ config : GlobalConfig Resolved configuration (Tbar, P_fus prescribed).
265
+ results : tuple Return value of run(config).
266
+
267
+ Returns
268
+ -------
269
+ dict Te0, Ti0 [keV], ne0, ni0 [1e20 m^-3]. NaN on failed designs.
270
+ """
271
+ nu_n, nu_T, rho_ped, n_ped_frac, T_ped_frac = _profile_params(config)
272
+ nbar, f_He = float(results[12]), float(results[40])
273
+ kappa_edge, kappa_95, delta_edge, delta_95 = (float(x) for x in results[62:66])
274
+ if not (np.isfinite(nbar) and np.isfinite(f_He)):
275
+ return dict(Te0=np.nan, Ti0=np.nan, ne0=np.nan, ni0=np.nan)
276
+ Vprime_data = None
277
+ if (config.Plasma_geometry == 'refined'
278
+ and np.isfinite(kappa_edge) and np.isfinite(delta_edge)):
279
+ # Same grid as run(), so the profile normalisation is identical
280
+ Vprime_data = precompute_Vprime(
281
+ config.R0, config.a, kappa_edge, delta_edge,
282
+ geometry_model='refined', kappa_95=kappa_95, delta_95=delta_95,
283
+ N_rho=500, N_theta=200)
284
+ Te0 = float(f_Tprof(config.Tbar, nu_T, 0.0, rho_ped=rho_ped,
285
+ T_ped_frac=T_ped_frac, Vprime_data=Vprime_data))
286
+ ne0 = float(f_nprof(nbar, nu_n, 0.0, rho_ped=rho_ped,
287
+ n_ped_frac=n_ped_frac, Vprime_data=Vprime_data))
288
+ species, conc = _parse_impurity_inventory(config)
289
+ Z1 = sum(get_Z_mean(sp, config.Tbar) * c for sp, c in zip(species, conc))
290
+ return dict(Te0=Te0, Ti0=config.tau_i_e * Te0,
291
+ ne0=ne0, ni0=ne0 * (1.0 - 2.0 * f_He - Z1))
292
+
293
+
253
294
  def resolve_Tbar(config: GlobalConfig, verbose: int = 0) -> GlobalConfig:
254
295
  """
255
296
  Resolve the volume-averaged temperature according to config.Tbar_mode.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d0fus
3
- Version: 2.9.0
3
+ Version: 2.9.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>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d0fus
3
- Version: 2.9.0
3
+ Version: 2.9.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>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "d0fus"
7
- version = "2.9.0"
7
+ version = "2.9.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
File without changes
File without changes